From: Erik V. <ev...@us...> - 2010-01-11 23:06:55
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20271/rails/ui/swing Modified Files: StatusWindow.java ORUIManager.java GameUIManager.java GameStatus.java Log Message: More dialogs made modal Index: StatusWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StatusWindow.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** StatusWindow.java 8 Jan 2010 21:27:48 -0000 1.32 --- StatusWindow.java 11 Jan 2010 23:06:08 -0000 1.33 *************** *** 15,19 **** import rails.game.*; import rails.game.action.*; ! import rails.ui.swing.elements.*; import rails.util.Config; import rails.util.LocalText; --- 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; *************** *** 24,28 **** */ public class StatusWindow extends JFrame implements ActionListener, ! KeyListener, ActionPerformer, DialogOwner { private static final long serialVersionUID = 1L; --- 25,29 ---- */ public class StatusWindow extends JFrame implements ActionListener, ! KeyListener, ActionPerformer { private static final long serialVersionUID = 1L; *************** *** 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(); --- 533,536 ---- Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** ORUIManager.java 8 Jan 2010 21:58:38 -0000 1.43 --- ORUIManager.java 11 Jan 2010 23:06:14 -0000 1.44 *************** *** 11,16 **** import rails.game.action.*; import rails.game.special.*; ! import rails.ui.swing.elements.CheckBoxDialog; ! import rails.ui.swing.elements.DialogOwner; import rails.ui.swing.hexmap.GUIHex; import rails.ui.swing.hexmap.HexMap; --- 11,15 ---- import rails.game.action.*; import rails.game.special.*; ! import rails.ui.swing.elements.*; import rails.ui.swing.hexmap.GUIHex; import rails.ui.swing.hexmap.HexMap; *************** *** 1096,1124 **** Bank.format(minNumber * loanAmount))); numberRepaid = minNumber; } else { ! List<String> options = new ArrayList<String>(); ! for (int i=minNumber; i<=maxNumber; i++) { if (i == 0) { ! options.add(LocalText.getText("None")); } else { ! options.add(LocalText.getText("RepayLoan", i, Bank.format(loanAmount), ! Bank.format(i * loanAmount))); } } ! Object choice = JOptionPane.showInputDialog(orWindow, LocalText.getText("SelectLoansToRepay", action.getCompanyName()), ! LocalText.getText("Select"), ! JOptionPane.QUESTION_MESSAGE, ! null, ! options.toArray(), ! options.get(minNumber == 0 ? 1 : minNumber)); ! ! numberRepaid = minNumber + options.indexOf(choice); ! } - action.setNumberTaken(numberRepaid); - orWindow.process(action); } --- 1095,1120 ---- Bank.format(minNumber * loanAmount))); numberRepaid = minNumber; + action.setNumberTaken(numberRepaid); + orWindow.process(action); } else { ! //List<String> options = new ArrayList<String>(); ! String[] options = new String[maxNumber-minNumber+1]; ! for (int i=minNumber, j=0; i<=maxNumber; i++, j++) { if (i == 0) { ! options[j] = LocalText.getText("None"); } else { ! options[j] = LocalText.getText("RepayLoan", i, Bank.format(loanAmount), ! Bank.format(i * loanAmount)); } } ! RadioButtonDialog currentDialog = new RadioButtonDialog (gameUIManager, ! LocalText.getText("Select"), LocalText.getText("SelectLoansToRepay", action.getCompanyName()), ! options, ! 0); ! gameUIManager.setCurrentDialog (currentDialog, action); } } Index: GameStatus.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameStatus.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** GameStatus.java 5 Jan 2010 20:54:05 -0000 1.35 --- GameStatus.java 11 Jan 2010 23:06:15 -0000 1.36 *************** *** 626,636 **** if (options.size() > 1) { if (startCompany) { ! index = ! new RadioButtonDialog(this, ! LocalText.getText("PleaseSelect"), ! LocalText.getText("WHICH_START_PRICE", ! playerName, ! companyName), ! options.toArray(new String[0]), -1).getSelectedOption(); } else { String sp = --- 626,637 ---- if (options.size() > 1) { if (startCompany) { ! RadioButtonDialog dialog = new RadioButtonDialog (gameUIManager, ! LocalText.getText("PleaseSelect"), ! LocalText.getText("WHICH_START_PRICE", ! playerName, ! companyName), ! options.toArray(new String[0]), -1); ! gameUIManager.setCurrentDialog(dialog, actions.get(0)); ! return; } else { String sp = Index: GameUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameUIManager.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** GameUIManager.java 8 Jan 2010 21:27:54 -0000 1.31 --- GameUIManager.java 11 Jan 2010 23:06:15 -0000 1.32 *************** *** 12,17 **** import rails.game.*; import rails.game.action.*; ! import rails.ui.swing.elements.CheckBoxDialog; ! import rails.ui.swing.elements.DialogOwner; import rails.util.*; --- 12,16 ---- import rails.game.*; import rails.game.action.*; ! import rails.ui.swing.elements.*; import rails.util.*; *************** *** 125,129 **** // In some cases an Undo requires a different follow-up lastAction = action; ! if (action != null) action.setActed(); log.debug("==Passing to server: " + action); --- 124,131 ---- // 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); *************** *** 428,470 **** public void dialogActionPerformed () { ! if (currentDialog instanceof CheckBoxDialog ! && currentDialogAction instanceof ExchangeTokens) { ! CheckBoxDialog dialog = (CheckBoxDialog) currentDialog; ! ExchangeTokens action = (ExchangeTokens) currentDialogAction; ! boolean[] exchanged = dialog.getSelectedOptions(); ! 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; ! } processOnServer(currentDialogAction); --- 430,503 ---- public void dialogActionPerformed () { + dialogActionPerformed(false); + } ! public void dialogActionPerformed (boolean ready) { ! if (!ready) { ! if (currentDialog instanceof RadioButtonDialog ! && currentDialogAction instanceof StartCompany) { ! RadioButtonDialog dialog = (RadioButtonDialog) currentDialog; ! StartCompany action = (StartCompany) currentDialogAction; ! int index = dialog.getSelectedOption(); ! if (index > 0) { ! int price = action.getStartPrices()[index]; ! action.setStartPrice(price); ! action.setNumberBought(action.getCertificate().getShares()); ! } else { ! // No selection done - no action ! return; ! } ! ! ! } else if (currentDialog instanceof CheckBoxDialog ! && currentDialogAction instanceof ExchangeTokens) { ! ! CheckBoxDialog dialog = (CheckBoxDialog) currentDialog; ! ExchangeTokens action = (ExchangeTokens) currentDialogAction; ! boolean[] exchanged = dialog.getSelectedOptions(); ! 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 if (currentDialog instanceof RadioButtonDialog ! && currentDialogAction instanceof RepayLoans) { ! ! RadioButtonDialog dialog = (RadioButtonDialog) currentDialog; ! RepayLoans action = (RepayLoans) currentDialogAction; ! int selected = dialog.getSelectedOption(); ! action.setNumberTaken(action.getMinNumber() + selected); ! } else { ! return; ! } ! } processOnServer(currentDialogAction); |