(Graphwar graphwar, String confFile)
| 76 | private static Font font = new Font("Sans", Font.BOLD, 12); |
| 77 | |
| 78 | public MainMenuScreen(Graphwar graphwar, String confFile) throws InterruptedException, IOException |
| 79 | { |
| 80 | super(); |
| 81 | |
| 82 | this.graphwar = graphwar; |
| 83 | |
| 84 | this.setLayout(null); |
| 85 | this.setBounds(0,0,Constants.WIDTH,Constants.HEIGHT); |
| 86 | |
| 87 | InputStreamReader in = new InputStreamReader(graphwar.getClass().getResourceAsStream(confFile)); |
| 88 | BufferedReader read = new BufferedReader(in); |
| 89 | |
| 90 | // Stack used to add components in reverse order, because swing draws components added first first |
| 91 | // and that is not intuitive to the way the data is read from the files |
| 92 | Stack<Component> components = new Stack<Component>(); |
| 93 | |
| 94 | ///// Main Screen ///////////// |
| 95 | |
| 96 | int numBackgroundImages = Integer.parseInt(GraphUtil.nextLine(read)); |
| 97 | backgroundImages = new JLabel[numBackgroundImages]; |
| 98 | |
| 99 | for(int i=0; i<numBackgroundImages; i++) |
| 100 | { |
| 101 | backgroundImages[i] = GraphUtil.makeBackgroundImage(graphwar, read); |
| 102 | components.push(backgroundImages[i]); |
| 103 | } |
| 104 | |
| 105 | this.joinGlobal = GraphUtil.makeButton(graphwar, read); |
| 106 | this.createGame = GraphUtil.makeButton(graphwar, read); |
| 107 | this.joinGame = GraphUtil.makeButton(graphwar, read); |
| 108 | |
| 109 | components.push(joinGlobal); |
| 110 | components.push(createGame); |
| 111 | components.push(joinGame); |
| 112 | |
| 113 | this.joinGlobal.addActionListener(this); |
| 114 | this.createGame.addActionListener(this); |
| 115 | this.joinGame.addActionListener(this); |
| 116 | |
| 117 | ///////////// Join Global Sub-menu /////// |
| 118 | |
| 119 | numBackgroundImages = Integer.parseInt(GraphUtil.nextLine(read)); |
| 120 | backgroundsGlobal = new JLabel[numBackgroundImages]; |
| 121 | |
| 122 | for(int i=0; i<numBackgroundImages; i++) |
| 123 | { |
| 124 | backgroundsGlobal[i] = GraphUtil.makeBackgroundImage(graphwar, read); |
| 125 | components.push(backgroundsGlobal[i]); |
| 126 | } |
| 127 | |
| 128 | this.nameFieldGlobal = GraphUtil.makeTextField(read); |
| 129 | this.yesButtonGlobal = GraphUtil.makeButton(graphwar, read); |
| 130 | this.noButtonGlobal = GraphUtil.makeButton(graphwar, read); |
| 131 | |
| 132 | components.push(nameFieldGlobal); |
| 133 | components.push(yesButtonGlobal); |
| 134 | components.push(noButtonGlobal); |
| 135 |
nothing calls this directly
no test coverage detected