From: Erik V. <ev...@us...> - 2010-01-07 20:48:51
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv30381/rails/ui/swing Modified Files: ORUIManager.java GameUIManager.java Log Message: Created non-modal version of CheckBoxDialog and a method to deal with such dialogs in the UI Managers. ExchangeTokens and ReachDestination action dialogs now no longer block other windows. Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** ORUIManager.java 1 Jan 2010 18:59:52 -0000 1.40 --- ORUIManager.java 7 Jan 2010 20:48:06 -0000 1.41 *************** *** 3,6 **** --- 3,7 ---- import java.util.*; + import javax.swing.JDialog; import javax.swing.JOptionPane; *************** *** 11,14 **** --- 12,16 ---- 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; *************** *** 16,20 **** import rails.util.Util; ! public class ORUIManager { protected ORWindow orWindow; --- 18,22 ---- import rails.util.Util; ! public class ORUIManager implements DialogOwner { protected ORWindow orWindow; *************** *** 28,31 **** --- 30,36 ---- public GameUIManager gameUIManager; + protected JDialog currentDialog = null; + protected PossibleAction currentDialogAction = null; + private OperatingRound oRound; private PublicCompanyI[] companies; *************** *** 434,438 **** protected void reachDestinations (ReachDestinations action) { - int index; List<String> options = new ArrayList<String>(); List<PublicCompanyI> companies = action.getPossibleCompanies(); --- 439,442 ---- *************** *** 445,468 **** orWindow.setVisible(true); orWindow.toFront(); ! boolean[] destined = ! new CheckBoxDialog(orPanel, ! LocalText.getText("DestinationsReached"), ! LocalText.getText("DestinationsReachedPrompt"), ! options.toArray(new String[0])) ! .getSelectedOptions(); ! for (index=0; index < options.size(); index++) { if (destined[index]) { ! action.addReachedCompany(companies.get(index)); } } ! // Prevent that a null action gets processed if (action.getReachedCompanies() == null || action.getReachedCompanies().isEmpty()) return; ! ! if (orWindow.process(action)) { ! updateMessage(); ! } } } --- 449,487 ---- 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(); ! ! for (int index=0; index < options.length; index++) { if (destined[index]) { ! action.addReachedCompany(action.getPossibleCompanies().get(index)); } } ! // Prevent that a null action gets processed if (action.getReachedCompanies() == null || action.getReachedCompanies().isEmpty()) return; ! ! } else { ! return; } + + gameUIManager.processOnServer(currentDialogAction); } Index: GameUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameUIManager.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** GameUIManager.java 30 Dec 2009 22:10:18 -0000 1.29 --- GameUIManager.java 7 Jan 2010 20:48:11 -0000 1.30 *************** *** 5,10 **** import java.util.*; ! import javax.swing.JFileChooser; ! import javax.swing.JOptionPane; import org.apache.log4j.Logger; --- 5,9 ---- import java.util.*; ! import javax.swing.*; import org.apache.log4j.Logger; *************** *** 14,17 **** --- 13,17 ---- import rails.game.action.*; import rails.ui.swing.elements.CheckBoxDialog; + import rails.ui.swing.elements.DialogOwner; import rails.util.*; *************** *** 19,23 **** * This class is called by main() and loads all of the UI components */ ! public class GameUIManager { public static GameUIManager instance = null; --- 19,23 ---- * This class is called by main() and loads all of the UI components */ ! public class GameUIManager implements DialogOwner { public static GameUIManager instance = null; *************** *** 28,31 **** --- 28,35 ---- public ORWindow orWindow; // TEMPORARY private StartRoundWindow startRoundWindow; + + protected JDialog currentDialog = null; + protected PossibleAction currentDialogAction = null; + public static ImageLoader imageLoader; *************** *** 233,237 **** orWindow.setVisible(true); stockChart.setVisible(false); ! } else if (SwitchableUIRound.class.isAssignableFrom(currentRoundType) ) { log.debug("UI entering switchable round type"); --- 237,241 ---- orWindow.setVisible(true); stockChart.setVisible(false); ! } else if (SwitchableUIRound.class.isAssignableFrom(currentRoundType) ) { log.debug("UI entering switchable round type"); *************** *** 350,353 **** --- 354,358 ---- playerName, c.getName() ); + String discardedTrainName = (String) JOptionPane.showInputDialog(orWindow, *************** *** 370,374 **** public void exchangeTokens (ExchangeTokens action) { ! int index, cityNumber; String prompt, cityName, hexName, oldCompName; String[] ct; --- 375,379 ---- public void exchangeTokens (ExchangeTokens action) { ! int cityNumber; String prompt, cityName, hexName, oldCompName; String[] ct; *************** *** 414,430 **** orWindow.setVisible(true); orWindow.toFront(); ! boolean[] exchanged = ! new CheckBoxDialog(orWindow.getORPanel(), ! LocalText.getText("ExchangeTokens"), ! prompt, ! options.toArray(new String[0])) ! .getSelectedOptions(); ! for (index=0; index < options.size(); index++) { if (exchanged[index]) { ! oldTokens.get(index).setSelected(true); } } ! orWindow.process(action); } } --- 419,452 ---- orWindow.setVisible(true); orWindow.toFront(); ! ! currentDialogAction = action; ! currentDialog = new CheckBoxDialog(this, ! LocalText.getText("ExchangeTokens"), ! prompt, ! options.toArray(new String[0])); ! ! } ! } ! ! 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(); ! ! for (int index=0; index < options.length; index++) { if (exchanged[index]) { ! action.getTokensToExchange().get(index).setSelected(true); } } ! } else { ! return; } + + processOnServer(currentDialogAction); } |