From: Erik V. <ev...@us...> - 2010-01-14 20:43:28
|
Update of /cvsroot/rails/18xx/rails/ui/swing/gamespecific/_18EU In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv3214/rails/ui/swing/gamespecific/_18EU Modified Files: GameUIManager_18EU.java Log Message: Changes related to non-modal dialogs Index: GameUIManager_18EU.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GameUIManager_18EU.java 11 Jan 2010 23:06:17 -0000 1.1 --- GameUIManager_18EU.java 14 Jan 2010 20:43:18 -0000 1.2 *************** *** 1,6 **** --- 1,9 ---- package rails.ui.swing.gamespecific._18EU; + import java.util.List; + import javax.swing.JOptionPane; + import rails.game.City; import rails.game.PublicCompanyI; import rails.game.action.MergeCompanies; *************** *** 51,71 **** StartCompany_18EU action = (StartCompany_18EU) currentDialogAction; ! if (action.getMinorsToMerge() != null) { // Up to phase 5: a minor to merge has been selected (or not) int choice = dialog.getSelectedOption(); ! if (choice >= 0) { ! action.setChosenMinor(action.getMinorsToMerge().get(choice)); ! } else { ! return; } } else if (action.getAvailableHomeStations() != null) { // From phase 6: a home station has been selected (or not) int index = dialog.getSelectedOption(); ! if (index >= 0) { ! action.setHomeStation(action.getAvailableHomeStations().get(index)); ! } else { ! return; } } } else { --- 54,124 ---- StartCompany_18EU action = (StartCompany_18EU) currentDialogAction; ! if (action.getPrice() == 0) { ! ! // The price will be set first ! int index = dialog.getSelectedOption(); ! if (index < 0) return; ! action.setStartPrice(action.getStartPrices()[index]); ! ! // Set up another dialog for the next step ! List<PublicCompanyI> minors = action.getMinorsToMerge(); ! ! if (minors != null && !minors.isEmpty()) { ! // Up to phase 6, a minor must be exchanged ! String[] options = new String[minors.size()]; ! int i = 0; ! for (PublicCompanyI minor : minors) { ! options[i++] = ! "Minor " + minor.getName() + " " ! + minor.getLongName(); ! } ! dialog = new RadioButtonDialog (this, ! LocalText.getText("PleaseSelect"), ! LocalText.getText( ! "SelectMinorToMerge", ! action.getCertificate().getCompany().getName()), ! options, -1); ! setCurrentDialog(dialog, action); ! return; ! } else { ! ! // From phase 6, no minors are involved, but a home station must be chosen ! List<City> cities = action.getAvailableHomeStations(); ! if (cities != null && !cities.isEmpty()) { ! String[] options = new String[cities.size()]; ! for (int i = 0; i < options.length; i++) { ! options[i] = cities.get(i).toString(); ! } ! dialog = new RadioButtonDialog (this, ! LocalText.getText("PleaseSelect"), ! LocalText.getText( ! "SelectHomeStation", ! action.getCertificate().getCompany().getName()), ! options, -1); ! setCurrentDialog(dialog, action); ! return; ! ! } ! } ! } else if (action.getMinorsToMerge() != null) { // Up to phase 5: a minor to merge has been selected (or not) int choice = dialog.getSelectedOption(); ! if (choice < 0) { ! // Also reset price ! action.setStartPrice(0); ! return; } + action.setChosenMinor(action.getMinorsToMerge().get(choice)); + } else if (action.getAvailableHomeStations() != null) { // From phase 6: a home station has been selected (or not) int index = dialog.getSelectedOption(); ! if (index < 0) { ! // Also reset price ! action.setStartPrice(0); ! return; } + action.setHomeStation(action.getAvailableHomeStations().get(index)); } } else { |