From: Erik V. <ev...@us...> - 2010-04-29 22:15:19
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv13687/rails/ui/swing Modified Files: ORUIManager.java Log Message: Fixed station numbering effect on token laying in multi-city tiles Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** ORUIManager.java 29 Apr 2010 19:47:32 -0000 1.68 --- ORUIManager.java 29 Apr 2010 22:15:11 -0000 1.69 *************** *** 9,15 **** import org.jgrapht.graph.SimpleGraph; ! import rails.algorithms.NetworkEdge; ! import rails.algorithms.NetworkGraphBuilder; ! import rails.algorithms.NetworkVertex; import rails.game.*; import rails.game.action.*; --- 9,13 ---- import org.jgrapht.graph.SimpleGraph; ! import rails.algorithms.*; import rails.game.*; import rails.game.action.*; *************** *** 60,64 **** private boolean mapCorrectionEnabled = false; private MapCorrectionAction mapCorrectionAction = null; ! /** * Will be set true if a cancelled action does not need to be reported to --- 58,62 ---- private boolean mapCorrectionEnabled = false; private MapCorrectionAction mapCorrectionAction = null; ! /** * Will be set true if a cancelled action does not need to be reported to *************** *** 125,129 **** } } ! private SimpleGraph<NetworkVertex, NetworkEdge> getCompanyGraph(){ MapManager mapManager = gameUIManager.getGameManager().getMapManager(); --- 123,127 ---- } } ! private SimpleGraph<NetworkVertex, NetworkEdge> getCompanyGraph(){ MapManager mapManager = gameUIManager.getGameManager().getMapManager(); *************** *** 134,138 **** return graph; } ! public <T extends PossibleAction> void setMapRelatedActions(List<T> actions) { --- 132,136 ---- return graph; } ! public <T extends PossibleAction> void setMapRelatedActions(List<T> actions) { *************** *** 142,146 **** allowedTileLays.clear(); allowedTokenLays.clear(); ! for (T action : actions) { if (action instanceof LayTile) { --- 140,144 ---- allowedTileLays.clear(); allowedTokenLays.clear(); ! for (T action : actions) { if (action instanceof LayTile) { *************** *** 168,172 **** hexUpgrades = null; } ! if (allowedTokenLays.size() == 0 && tokenLayingEnabled) { /* Finish token laying step */ --- 166,170 ---- hexUpgrades = null; } ! if (allowedTokenLays.size() == 0 && tokenLayingEnabled) { /* Finish token laying step */ *************** *** 185,189 **** hexUpgrades = null; } ! if (allowedTileLays.size() > 0) { nextSubStep = ORUIManager.SELECT_HEX_FOR_TILE; --- 183,187 ---- hexUpgrades = null; } ! if (allowedTileLays.size() > 0) { nextSubStep = ORUIManager.SELECT_HEX_FOR_TILE; *************** *** 207,212 **** case (LayTile.SPECIAL_PROPERTY): SpecialPropertyI sp = layTile.getSpecialProperty(); ! if (sp == null || !(sp instanceof SpecialTileLay) || ! ((SpecialTileLay)sp).requiresConnection()) break; case (LayTile.LOCATION_SPECIFIC): --- 205,210 ---- case (LayTile.SPECIAL_PROPERTY): SpecialPropertyI sp = layTile.getSpecialProperty(); ! if (sp == null || !(sp instanceof SpecialTileLay) || ! ((SpecialTileLay)sp).requiresConnection()) break; case (LayTile.LOCATION_SPECIFIC): *************** *** 215,219 **** } } ! // standard upgrades if (mapHexes) { --- 213,217 ---- } } ! // standard upgrades if (mapHexes) { *************** *** 225,229 **** } } ! // activate upgrades for (MapHex hex:hexUpgrades) { --- 223,227 ---- } } ! // activate upgrades for (MapHex hex:hexUpgrades) { *************** *** 232,236 **** } } ! if (allowedTokenLays.size() > 0) { nextSubStep = ORUIManager.SELECT_HEX_FOR_TOKEN; --- 230,234 ---- } } ! if (allowedTokenLays.size() > 0) { nextSubStep = ORUIManager.SELECT_HEX_FOR_TOKEN; *************** *** 254,258 **** hexUpgrades.addAll(layToken.getLocations()); } ! // standard tokens if (mapHexes) { --- 252,256 ---- hexUpgrades.addAll(layToken.getLocations()); } ! // standard tokens if (mapHexes) { *************** *** 268,273 **** } } ! } ! setLocalStep(nextSubStep); tileLayingEnabled = allowedTileLays.size() > 0; --- 266,271 ---- } } ! } ! setLocalStep(nextSubStep); tileLayingEnabled = allowedTileLays.size() > 0; *************** *** 299,303 **** extraMessage = LocalText.getText("CorrectMap" + mapCorrectionAction.getStep().name()); } ! if (localStep == ORUIManager.SELECT_HEX_FOR_TILE) { /* Compose prompt for tile laying */ --- 297,301 ---- extraMessage = LocalText.getText("CorrectMap" + mapCorrectionAction.getStep().name()); } ! if (localStep == ORUIManager.SELECT_HEX_FOR_TILE) { /* Compose prompt for tile laying */ *************** *** 400,406 **** prepareBonusToken((LayBonusToken) actions.get(0)); ! } else if (actionType == LayBaseToken.class) { ! /* Only used outside the token laying step */ // Can currently handle only one location! --- 398,404 ---- prepareBonusToken((LayBonusToken) actions.get(0)); ! } else if (actionType == LayBaseToken.class) { ! /* Only used outside the token laying step */ // Can currently handle only one location! *************** *** 429,441 **** repayLoans ((RepayLoans)actions.get(0)); ! } else if (actionType == UseSpecialProperty.class) { ! useSpecialProperty ((UseSpecialProperty)actions.get(0)); ! } else if (actions.get(0) instanceof CorrectionAction) { ! processCorrectionAction((CorrectionAction)actions.get(0)); ! } --- 427,439 ---- repayLoans ((RepayLoans)actions.get(0)); ! } else if (actionType == UseSpecialProperty.class) { ! useSpecialProperty ((UseSpecialProperty)actions.get(0)); ! } else if (actions.get(0) instanceof CorrectionAction) { ! processCorrectionAction((CorrectionAction)actions.get(0)); ! } *************** *** 595,604 **** selectedHex.forcedRotateTile(); map.repaint(selectedHex.getBounds()); ! } else checkClickedHex = true; break; } if (checkClickedHex && clickedHex !=null && clickedHex != selectedHex) { ! map.selectHex(clickedHex); mapCorrectionAction.selectHex(clickedHex.getHexModel()); orWindow.process(mapCorrectionAction); --- 593,602 ---- selectedHex.forcedRotateTile(); map.repaint(selectedHex.getBounds()); ! } else checkClickedHex = true; break; } if (checkClickedHex && clickedHex !=null && clickedHex != selectedHex) { ! map.selectHex(clickedHex); mapCorrectionAction.selectHex(clickedHex.getHexModel()); orWindow.process(mapCorrectionAction); *************** *** 783,789 **** city.getNumber(), ((MapHex) selectedHex.getModel()).getConnectionString( ! selectedHex.getCurrentTile(), ! ((MapHex) selectedHex.getModel()).getCurrentTileRotation(), ! city.getNumber())) ; prompts.add(prompt); promptToCityMap.put(prompt, city); --- 781,787 ---- city.getNumber(), ((MapHex) selectedHex.getModel()).getConnectionString( ! selectedHex.getCurrentTile(), ! ((MapHex) selectedHex.getModel()).getCurrentTileRotation(), ! city.getRelatedStation().getNumber())) ; prompts.add(prompt); promptToCityMap.put(prompt, city); *************** *** 905,914 **** public void operatingCosts(){ ! List<String> textOC = new ArrayList<String>(); List<OperatingCost> actionOC = possibleActions.getType(OperatingCost.class); ! for (OperatingCost ac:actionOC) { ! String suggestedCostText; if (ac.isFreeEntryAllowed()) --- 903,912 ---- public void operatingCosts(){ ! List<String> textOC = new ArrayList<String>(); List<OperatingCost> actionOC = possibleActions.getType(OperatingCost.class); ! for (OperatingCost ac:actionOC) { ! String suggestedCostText; if (ac.isFreeEntryAllowed()) *************** *** 916,932 **** else suggestedCostText = Bank.format(ac.getAmount()); ! OperatingCost.OCType t = ac.getOCType(); ! if (t == OperatingCost.OCType.LAY_TILE) ! textOC.add(LocalText.getText("OCLayTile", suggestedCostText )); ! ! if (t == OperatingCost.OCType.LAY_BASE_TOKEN) ! textOC.add(LocalText.getText("OCLayBaseToken", suggestedCostText )); } ! if (!textOC.isEmpty()) { ! String chosenOption = (String) JOptionPane.showInputDialog(orWindow, LocalText.getText("OCSelectMessage"), LocalText.getText("OCSelectTitle"), --- 914,930 ---- else suggestedCostText = Bank.format(ac.getAmount()); ! OperatingCost.OCType t = ac.getOCType(); ! if (t == OperatingCost.OCType.LAY_TILE) ! textOC.add(LocalText.getText("OCLayTile", suggestedCostText )); ! ! if (t == OperatingCost.OCType.LAY_BASE_TOKEN) ! textOC.add(LocalText.getText("OCLayBaseToken", suggestedCostText )); } ! if (!textOC.isEmpty()) { ! String chosenOption = (String) JOptionPane.showInputDialog(orWindow, LocalText.getText("OCSelectMessage"), LocalText.getText("OCSelectTitle"), *************** *** 952,956 **** chosenAction.setAmount(chosenAction.getAmount()); } ! if (orWindow.process(chosenAction)) { updateMessage(); --- 950,954 ---- chosenAction.setAmount(chosenAction.getAmount()); } ! if (orWindow.process(chosenAction)) { updateMessage(); *************** *** 959,963 **** } } ! public void buyTrain() { --- 957,961 ---- } } ! public void buyTrain() { *************** *** 1212,1216 **** return; } ! if (tileLayingEnabled) { if (selectedHex == null) { --- 1210,1214 ---- return; } ! if (tileLayingEnabled) { if (selectedHex == null) { *************** *** 1321,1331 **** } } ! /** Used to process some special properties from the 'Special' menu */ /* In fact currently not used */ protected void useSpecialProperty (UseSpecialProperty action) { ! gameUIManager.processOnServer(action); ! } --- 1319,1329 ---- } } ! /** Used to process some special properties from the 'Special' menu */ /* In fact currently not used */ protected void useSpecialProperty (UseSpecialProperty action) { ! gameUIManager.processOnServer(action); ! } *************** *** 1333,1340 **** gameUIManager.processOnServer(action); ! } ! ! public void updateStatus() { --- 1331,1338 ---- gameUIManager.processOnServer(action); ! } ! ! public void updateStatus() { *************** *** 1372,1376 **** // initialize operating costs actions orPanel.initOperatingCosts(possibleActions.contains(OperatingCost.class)); ! // initial deactivation of MapTileCorrection Actions mapCorrectionEnabled = false; --- 1370,1374 ---- // initialize operating costs actions orPanel.initOperatingCosts(possibleActions.contains(OperatingCost.class)); ! // initial deactivation of MapTileCorrection Actions mapCorrectionEnabled = false; *************** *** 1388,1392 **** MapCorrectionAction action = (MapCorrectionAction) (possibleActions.getType(MapCorrectionAction.class)).get(0); ! mapCorrectionEnabled = true; mapCorrectionAction = action; --- 1386,1390 ---- MapCorrectionAction action = (MapCorrectionAction) (possibleActions.getType(MapCorrectionAction.class)).get(0); ! mapCorrectionEnabled = true; mapCorrectionAction = action; *************** *** 1486,1490 **** orPanel.enableLoanTaking (possibleActions.getType(TakeLoans.class).get(0)); } ! if (!mapCorrectionEnabled) setMapRelatedActions(mapRelatedActions); --- 1484,1488 ---- orPanel.enableLoanTaking (possibleActions.getType(TakeLoans.class).get(0)); } ! if (!mapCorrectionEnabled) setMapRelatedActions(mapRelatedActions); *************** *** 1526,1530 **** orPanel.initSpecialActions(); ! // Bonus tokens (and sometimes base tokens) can be laid anytime, // so we must also handle these outside the token laying step. if (possibleActions.contains(LayToken.class) --- 1524,1528 ---- orPanel.initSpecialActions(); ! // Bonus tokens (and sometimes base tokens) can be laid anytime, // so we must also handle these outside the token laying step. if (possibleActions.contains(LayToken.class) *************** *** 1534,1539 **** possibleActions.getType(LayToken.class); for (LayToken tAction : tokenActions) { ! ! if (tAction instanceof LayBaseToken && ((LayBaseToken)tAction).getType() == LayBaseToken.HOME_CITY) { // Forced action: select home city --- 1532,1537 ---- possibleActions.getType(LayToken.class); for (LayToken tAction : tokenActions) { ! ! if (tAction instanceof LayBaseToken && ((LayBaseToken)tAction).getType() == LayBaseToken.HOME_CITY) { // Forced action: select home city *************** *** 1542,1546 **** layBaseToken (lbt); return; ! } SpecialTokenLay stl = tAction.getSpecialProperty(); --- 1540,1544 ---- layBaseToken (lbt); return; ! } SpecialTokenLay stl = tAction.getSpecialProperty(); *************** *** 1569,1573 **** LocalText.getText("DestinationsReached")); } ! // Any other special properties, to be shown in the "Special" menu. // Example: 18AL AssignNamedTrains --- 1567,1571 ---- LocalText.getText("DestinationsReached")); } ! // Any other special properties, to be shown in the "Special" menu. // Example: 18AL AssignNamedTrains *************** *** 1578,1582 **** } } ! // Close Private if (possibleActions.contains(ClosePrivate.class)) { --- 1576,1580 ---- } } ! // Close Private if (possibleActions.contains(ClosePrivate.class)) { *************** *** 1585,1589 **** } } ! checkForGameSpecificActions(); --- 1583,1587 ---- } } ! checkForGameSpecificActions(); *************** *** 1683,1690 **** } ! public void updateUpgradesPanel(MapCorrectionAction action) { setLocalStep(MAP_CORRECTION); ! switch (action.getStep()) { case SELECT_HEX: --- 1681,1688 ---- } ! public void updateUpgradesPanel(MapCorrectionAction action) { setLocalStep(MAP_CORRECTION); ! switch (action.getStep()) { case SELECT_HEX: *************** *** 1724,1728 **** break; } ! log.debug("Active map tile correction"); upgradePanel.showCorrectionUpgrades(); --- 1722,1726 ---- break; } ! log.debug("Active map tile correction"); upgradePanel.showCorrectionUpgrades(); |