From: Erik V. <ev...@us...> - 2010-01-08 21:28:33
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23981/rails/ui/swing Modified Files: StatusWindow.java ORUIManager.java StartRoundWindow.java GameUIManager.java Log Message: Added nonmodal RadioButtonDialog2 and apply to Repay Loans Index: StatusWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StatusWindow.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** StatusWindow.java 1 Jan 2010 18:59:20 -0000 1.31 --- StatusWindow.java 8 Jan 2010 21:27:48 -0000 1.32 *************** *** 15,20 **** import rails.game.*; import rails.game.action.*; ! import rails.ui.swing.elements.ActionButton; ! import rails.ui.swing.elements.ActionMenuItem; import rails.util.Config; import rails.util.LocalText; --- 15,19 ---- import rails.game.*; import rails.game.action.*; ! import rails.ui.swing.elements.*; import rails.util.Config; import rails.util.LocalText; *************** *** 25,29 **** */ public class StatusWindow extends JFrame implements ActionListener, ! KeyListener, ActionPerformer { private static final long serialVersionUID = 1L; --- 24,28 ---- */ public class StatusWindow extends JFrame implements ActionListener, ! KeyListener, ActionPerformer, DialogOwner { private static final long serialVersionUID = 1L; *************** *** 525,530 **** } ! gameUIManager.processOnServer(executedAction); ! return true; } --- 524,528 ---- } ! return gameUIManager.processOnServer(executedAction); } *************** *** 534,537 **** --- 532,552 ---- } + /** Stub */ + public void dialogActionPerformed () { + + } + + public JDialog getCurrentDialog() { + return gameUIManager.getCurrentDialog(); + } + + public PossibleAction getCurrentDialogAction () { + return gameUIManager.getCurrentDialogAction(); + } + + public void setCurrentDialog (JDialog dialog, PossibleAction action) { + gameUIManager.setCurrentDialog(dialog, action); + } + public void displayServerMessage() { String[] message = DisplayBuffer.get(); Index: StartRoundWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StartRoundWindow.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** StartRoundWindow.java 16 Nov 2009 18:11:19 -0000 1.33 --- StartRoundWindow.java 8 Jan 2010 21:27:54 -0000 1.34 *************** *** 79,83 **** private final StartPacket packet; private final int[] crossIndex; ! private final StartRoundI round; private final GameUIManager gameUIManager; --- 79,83 ---- private final StartPacket packet; private final int[] crossIndex; ! private final StartRound round; private final GameUIManager gameUIManager; Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** ORUIManager.java 7 Jan 2010 20:48:06 -0000 1.41 --- ORUIManager.java 8 Jan 2010 21:27:54 -0000 1.42 *************** *** 30,36 **** public GameUIManager gameUIManager; - protected JDialog currentDialog = null; - protected PossibleAction currentDialogAction = null; - private OperatingRound oRound; private PublicCompanyI[] companies; --- 30,33 ---- *************** *** 449,469 **** orWindow.setVisible(true); orWindow.toFront(); ! ! currentDialogAction = action; ! currentDialog = new CheckBoxDialog(this, LocalText.getText("DestinationsReached"), LocalText.getText("DestinationsReachedPrompt"), options.toArray(new String[0])); } } ! public void dialogActionPerformed () { if (currentDialog instanceof CheckBoxDialog && currentDialogAction instanceof ReachDestinations) { ! CheckBoxDialog dialog = (CheckBoxDialog) currentDialog; ReachDestinations action = (ReachDestinations) currentDialogAction; ! boolean[] destined = dialog.getSelectedOptions(); String[] options = dialog.getOptions(); --- 446,469 ---- orWindow.setVisible(true); orWindow.toFront(); ! ! CheckBoxDialog dialog = new CheckBoxDialog(this, LocalText.getText("DestinationsReached"), LocalText.getText("DestinationsReachedPrompt"), options.toArray(new String[0])); + setCurrentDialog (dialog, action); } } ! public void dialogActionPerformed () { + JDialog currentDialog = getCurrentDialog(); + PossibleAction currentDialogAction = getCurrentDialogAction(); + if (currentDialog instanceof CheckBoxDialog && currentDialogAction instanceof ReachDestinations) { ! CheckBoxDialog dialog = (CheckBoxDialog) currentDialog; ReachDestinations action = (ReachDestinations) currentDialogAction; ! boolean[] destined = dialog.getSelectedOptions(); String[] options = dialog.getOptions(); *************** *** 474,489 **** } } ! // Prevent that a null action gets processed if (action.getReachedCompanies() == null || action.getReachedCompanies().isEmpty()) return; ! } else { return; } ! gameUIManager.processOnServer(currentDialogAction); } public void hexClicked(GUIHex clickedHex, GUIHex selectedHex) { --- 474,501 ---- } } ! // Prevent that a null action gets processed if (action.getReachedCompanies() == null || action.getReachedCompanies().isEmpty()) return; ! } else { return; } ! gameUIManager.processOnServer(currentDialogAction); } + public JDialog getCurrentDialog() { + return gameUIManager.getCurrentDialog(); + } + + public PossibleAction getCurrentDialogAction () { + return gameUIManager.getCurrentDialogAction(); + } + + public void setCurrentDialog (JDialog dialog, PossibleAction action) { + gameUIManager.setCurrentDialog(dialog, action); + } + public void hexClicked(GUIHex clickedHex, GUIHex selectedHex) { Index: GameUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameUIManager.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** GameUIManager.java 7 Jan 2010 20:48:11 -0000 1.30 --- GameUIManager.java 8 Jan 2010 21:27:54 -0000 1.31 *************** *** 162,170 **** statusWindow.setGameActions(); ! if (result) { ! return activeWindow.processImmediateAction(); ! } else { ! return false; ! } } --- 162,168 ---- statusWindow.setGameActions(); ! if (!result) return false; ! ! return activeWindow.processImmediateAction(); } *************** *** 420,428 **** orWindow.toFront(); ! currentDialogAction = action; ! currentDialog = new CheckBoxDialog(this, LocalText.getText("ExchangeTokens"), prompt, options.toArray(new String[0])); } --- 418,426 ---- orWindow.toFront(); ! CheckBoxDialog dialog = new CheckBoxDialog(this, LocalText.getText("ExchangeTokens"), prompt, options.toArray(new String[0])); + setCurrentDialog (dialog, action); } *************** *** 439,447 **** String[] options = dialog.getOptions(); for (int index=0; index < options.length; index++) { if (exchanged[index]) { ! action.getTokensToExchange().get(index).setSelected(true); } } } else { return; --- 437,467 ---- String[] options = dialog.getOptions(); + int numberSelected = 0; for (int index=0; index < options.length; index++) { if (exchanged[index]) { ! numberSelected++; } } + + int minNumber = action.getMinNumberToExchange(); + int maxNumber = action.getMaxNumberToExchange(); + if (numberSelected < minNumber + || numberSelected > maxNumber) { + if (minNumber == maxNumber) { + JOptionPane.showMessageDialog(null, + LocalText.getText("YouMustSelect1", minNumber)); + } else { + JOptionPane.showMessageDialog(null, + LocalText.getText("YouMustSelect2", minNumber, maxNumber)); + } + exchangeTokens (action); + return; + + } + for (int index=0; index < options.length; index++) { + if (exchanged[index]) { + action.getTokensToExchange().get(index).setSelected(true); + } + } } else { return; *************** *** 451,454 **** --- 471,490 ---- } + public JDialog getCurrentDialog() { + return currentDialog; + } + + public PossibleAction getCurrentDialogAction () { + return currentDialogAction; + } + + public void setCurrentDialog (JDialog dialog, PossibleAction action) { + if (currentDialog != null) { + currentDialog.dispose(); + } + currentDialog = dialog; + currentDialogAction = action; + } + public void saveGame(GameAction saveAction) { |