(ActionEvent arg0)
| 334 | } |
| 335 | |
| 336 | public void actionPerformed(ActionEvent arg0) |
| 337 | { |
| 338 | if(this.createVisible) |
| 339 | { |
| 340 | if(arg0.getSource()==this.noButtonCreate) |
| 341 | { |
| 342 | this.showCreateGame(false); |
| 343 | this.showMessage = false; |
| 344 | this.repaint(); |
| 345 | } |
| 346 | else if(arg0.getSource()==this.yesButtonCreate || arg0.getSource()==nameFieldCreate || arg0.getSource()==portFieldCreate) |
| 347 | { |
| 348 | try |
| 349 | { |
| 350 | String name = nameFieldCreate.getText(); |
| 351 | int port = Integer.parseInt(portFieldCreate.getText()); |
| 352 | |
| 353 | if(name!=null && name.length()!=0) |
| 354 | { |
| 355 | if(name.length() > 20) |
| 356 | { |
| 357 | nameFieldCreate.setText(name.substring(0,20)); |
| 358 | } |
| 359 | else |
| 360 | { |
| 361 | this.showMessage("Creating..."); |
| 362 | |
| 363 | try |
| 364 | { |
| 365 | graphwar.createGame(port); |
| 366 | graphwar.getGlobalClient().createRoom(name, port); |
| 367 | graphwar.getGameData().addPlayer(graphwar.getGlobalClient().getLocalPlayerName()); |
| 368 | this.showCreateGame(false); |
| 369 | this.showMessage = false; |
| 370 | } |
| 371 | catch (IOException e) |
| 372 | { |
| 373 | this.showMessage("Failed! Check if port is not already in use."); |
| 374 | |
| 375 | e.printStackTrace(); |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | catch(NumberFormatException e) |
| 381 | { |
| 382 | this.showMessage("Port must be a number."); |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | else if(showMessageVisible) |
| 387 | { |
| 388 | if(arg0.getSource()==okButton) |
| 389 | { |
| 390 | if(graphwar.getGameData().getGameState() == Constants.NONE) |
| 391 | { |
| 392 | graphwar.getUI().setScreen(Constants.MAIN_MENU_SCREEN); |
| 393 |
nothing calls this directly
no test coverage detected