MCPcopy Create free account
hub / github.com/catabriga/graphwar / actionPerformed

Method actionPerformed

src/Graphwar/GlobalScreen.java:336–448  ·  view source on GitHub ↗
(ActionEvent arg0)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

showCreateGameMethod · 0.95
showMessageMethod · 0.95
showShowMessageMethod · 0.95
createGameMethod · 0.80
getGlobalClientMethod · 0.80
getGameDataMethod · 0.80
setScreenMethod · 0.80
getUIMethod · 0.80
createRoomMethod · 0.45
addPlayerMethod · 0.45
getLocalPlayerNameMethod · 0.45
getGameStateMethod · 0.45

Tested by

no test coverage detected