From: Erik V. <ev...@us...> - 2010-01-20 19:52:55
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11359/rails/ui/swing Modified Files: StatusWindow.java StartRoundWindow.java GridPanel.java GameUIManager.java ORWindow.java Log Message: All displayMessage() methods moved to GameUIManager, which now uses the new nonmodal MessageDialog Index: StatusWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StatusWindow.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** StatusWindow.java 18 Jan 2010 18:49:05 -0000 1.35 --- StatusWindow.java 20 Jan 2010 19:52:43 -0000 1.36 *************** *** 560,570 **** } - public void displayServerMessage() { - String[] message = DisplayBuffer.get(); - if (message != null) { - JOptionPane.showMessageDialog(this, message); - } - } - public void setPassButton(NullAction action) { if (action != null) { --- 560,563 ---- Index: StartRoundWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StartRoundWindow.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** StartRoundWindow.java 8 Jan 2010 21:27:54 -0000 1.34 --- StartRoundWindow.java 20 Jan 2010 19:52:44 -0000 1.35 *************** *** 438,442 **** spinnerModel.setValue(mb); } else { - //itemNameButton[i].setToolTipText(LocalText.getText("ClickToSelectForBidding")); itemNameButton[i].setPossibleAction(action); } --- 438,441 ---- *************** *** 637,647 **** } - public void displayServerMessage() { - String[] message = DisplayBuffer.get(); - if (message != null) { - JOptionPane.showMessageDialog(this, message); - } - } - private void setItemNameButton(int i, boolean clickable) { --- 636,639 ---- Index: GridPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GridPanel.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GridPanel.java 14 Jan 2010 20:48:26 -0000 1.2 --- GridPanel.java 20 Jan 2010 19:52:44 -0000 1.3 *************** *** 100,107 **** } - public void displayPopup(String text) { - JOptionPane.showMessageDialog(this, text); - } - public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1) { --- 100,103 ---- Index: ORWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORWindow.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** ORWindow.java 14 Jan 2010 20:50:08 -0000 1.32 --- ORWindow.java 20 Jan 2010 19:52:44 -0000 1.33 *************** *** 15,19 **** import rails.common.GuiDef; ! import rails.game.*; import rails.game.action.*; import rails.util.LocalText; --- 15,20 ---- import rails.common.GuiDef; ! import rails.game.GameManager; ! import rails.game.OperatingRound; import rails.game.action.*; import rails.util.LocalText; *************** *** 124,128 **** boolean result = gameUIManager.processOnServer(action); // Display any error message ! displayServerMessage(); return result; --- 125,129 ---- boolean result = gameUIManager.processOnServer(action); // Display any error message ! //displayServerMessage(); return result; *************** *** 134,144 **** } - public void displayServerMessage() { - String[] message = DisplayBuffer.get(); - if (message != null) { - JOptionPane.showMessageDialog(this, message); - } - } - public void displayORUIMessage(String message) { if (message != null) { --- 135,138 ---- Index: GameUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameUIManager.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** GameUIManager.java 19 Jan 2010 19:48:58 -0000 1.35 --- GameUIManager.java 20 Jan 2010 19:52:44 -0000 1.36 *************** *** 67,70 **** --- 67,72 ---- protected boolean previousORWindowVisibilityHint; + protected boolean previousResult; + protected static Logger log = Logger.getLogger(GameUIManager.class.getPackage().getName()); *************** *** 132,136 **** public void startLoadedGame() { gameUIInit(); ! processOnServer(null); statusWindow.setGameActions(); } --- 134,138 ---- public void startLoadedGame() { gameUIInit(); ! processOnServer(new NullAction(NullAction.START_GAME)); statusWindow.setGameActions(); } *************** *** 138,163 **** public boolean processOnServer(PossibleAction action) { // In some cases an Undo requires a different follow-up lastAction = action; ! if (action != null) { action.setActed(); action.setPlayerName(getCurrentPlayer().getName()); - } ! log.debug("==Passing to server: " + action); ! ! Player player = getCurrentPlayer(); ! if (action != null && player != null) { ! action.setPlayerName(player.getName()); ! } ! // Process the action on the server ! boolean result = gameManager.process(action); ! // Follow-up the result ! log.debug("==Result from server: " + result); ! if (DisplayBuffer.getAutoDisplay()) activeWindow.displayServerMessage(); ! reportWindow.addLog(); // End of game checks --- 140,179 ---- public boolean processOnServer(PossibleAction action) { + boolean result = true; + // In some cases an Undo requires a different follow-up lastAction = action; ! ! if (action == null) { ! // If the action is null, we can skip processing ! // and continue with following up a previous action. ! // This occurs after a nonmodal Message dialog. ! result = previousResult; ! ! } else { action.setActed(); action.setPlayerName(getCurrentPlayer().getName()); ! log.debug("==Passing to server: " + action); ! Player player = getCurrentPlayer(); ! if (player != null) { ! action.setPlayerName(player.getName()); ! } ! // Process the action on the server ! result = previousResult = gameManager.process(action); ! // Follow-up the result ! log.debug("==Result from server: " + result); ! reportWindow.addLog(); ! if (DisplayBuffer.getAutoDisplay()) { ! if (displayServerMessage()) { ! // Interrupt processing. ! // Will be continued via dialogActionPerformed(). ! return true; ! } ! } ! } // End of game checks *************** *** 185,188 **** --- 201,217 ---- } + public boolean displayServerMessage() { + String[] message = DisplayBuffer.get(); + if (message != null) { + setCurrentDialog(new MessageDialog(this, + LocalText.getText("Message"), + "<html>" + Util.joinWithDelimiter(message, "<br>")), + null); + return true; + } + return false; + } + + public void updateUI() { *************** *** 521,525 **** action.setNumberTaken(action.getMinNumber() + selected); } else if (currentDialog instanceof MessageDialog) { ! // Nothing } else { return; --- 550,555 ---- action.setNumberTaken(action.getMinNumber() + selected); } else if (currentDialog instanceof MessageDialog) { ! // Nothing to do ! currentDialogAction = null; // Should already be null } else { return; *************** *** 527,531 **** } ! if (currentDialogAction != null) processOnServer(currentDialogAction); } --- 557,561 ---- } ! processOnServer(currentDialogAction); } |