From: Erik V. <ev...@us...> - 2010-02-06 23:48:34
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9732/rails/ui/swing Modified Files: ORUIManager.java Log Message: Allow special token lays at any time during OR. This has changed the way that OR steps are handled. These can now be used again in the UI. Goal was to enable the extra NF token lay in 1835 Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** ORUIManager.java 3 Feb 2010 20:21:16 -0000 1.51 --- ORUIManager.java 6 Feb 2010 23:48:25 -0000 1.52 *************** *** 34,38 **** private int orCompIndex; ! private int orStep; private int localStep; --- 34,38 ---- private int orCompIndex; ! private GameDef.OrStep orStep; private int localStep; *************** *** 283,286 **** --- 283,294 ---- prepareBonusToken((LayBonusToken) actions.get(0)); + + } else if (actionType == LayBaseToken.class) { + + /* Only used outside the token laying step */ + // Can currently handle only one location! + LayBaseToken lbt = (LayBaseToken) actions.get(0); + map.selectHex(map.getHexByName(lbt.getLocations().get(0).getName())); + layBaseToken (lbt); } else if (actionType == BuyBonusToken.class) { *************** *** 304,307 **** --- 312,320 ---- repayLoans ((RepayLoans)actions.get(0)); + + } else if (actionType == UseSpecialProperty.class) { + + useSpecialProperty ((UseSpecialProperty)actions.get(0)); + } *************** *** 1071,1074 **** --- 1084,1095 ---- } } + + /** Used to process some special properties from the 'Special' menu */ + /* In fact currently not used */ + protected void useSpecialProperty (UseSpecialProperty action) { + + gameUIManager.processOnServer(action); + + } public void updateStatus() { *************** *** 1093,1098 **** log.debug("Or comp index = " + orCompIndex+" in round "+oRound.getRoundName()); log.debug("OR company = " + orComp.getName()); ! log.debug("OR step=" + orStep + " " ! + (orStep >= 0 ? OperatingRound.stepNames[orStep] : "")); if (oRound.getOperatingCompanyIndex() != orCompIndex) { --- 1114,1118 ---- log.debug("Or comp index = " + orCompIndex+" in round "+oRound.getRoundName()); log.debug("OR company = " + orComp.getName()); ! log.debug("OR step=" + orStep); if (oRound.getOperatingCompanyIndex() != orCompIndex) { *************** *** 1106,1110 **** orPanel.initPrivateBuying(privatesCanBeBoughtNow); ! if (possibleActions.contains(LayTile.class)) { orPanel.initTileLayingStep(); --- 1126,1131 ---- orPanel.initPrivateBuying(privatesCanBeBoughtNow); ! //if (possibleActions.contains(LayTile.class)) { ! if (orStep == GameDef.OrStep.LAY_TRACK) { orPanel.initTileLayingStep(); *************** *** 1115,1119 **** mapRelatedActions.addAll(possibleActions.getType(LayTile.class)); ! } else if (possibleActions.contains(LayBaseToken.class)) { orWindow.requestFocus(); --- 1136,1141 ---- mapRelatedActions.addAll(possibleActions.getType(LayTile.class)); ! //} else if (possibleActions.contains(LayBaseToken.class)) { ! } else if (orStep == GameDef.OrStep.LAY_TOKEN) { orWindow.requestFocus(); *************** *** 1199,1203 **** orPanel.enableLoanRepayment (possibleActions.getType(RepayLoans.class).get(0)); ! } else if (orStep == OperatingRound.STEP_FINAL) { // Does not occur??? orPanel.finishORCompanyTurn(orCompIndex); --- 1221,1225 ---- orPanel.enableLoanRepayment (possibleActions.getType(RepayLoans.class).get(0)); ! } else if (orStep == GameDef.OrStep.FINAL) { // Does not occur??? orPanel.finishORCompanyTurn(orCompIndex); *************** *** 1207,1211 **** orPanel.enableLoanTaking (possibleActions.getType(TakeLoans.class).get(0)); } ! setMapRelatedActions(mapRelatedActions); --- 1229,1233 ---- orPanel.enableLoanTaking (possibleActions.getType(TakeLoans.class).get(0)); } ! setMapRelatedActions(mapRelatedActions); *************** *** 1246,1264 **** orPanel.initSpecialActions(); ! // Bonus tokens can be laid anytime, so we must also handle ! // these outside the token laying step. ! if (possibleActions.contains(LayBonusToken.class) ! && !possibleActions.contains(LayBaseToken.class)) { ! List<LayBonusToken> bonusTokenActions = ! possibleActions.getType(LayBonusToken.class); ! for (LayBonusToken btAction : bonusTokenActions) { ! SpecialTokenLay stl = btAction.getSpecialProperty(); ! //BonusToken token = (BonusToken) stl.getToken(); ! //String text = ! // LocalText.getText("LayBonusToken", ! // token.toString(), ! // stl.getLocationCodeString() ); ! orPanel.addSpecialAction(btAction, stl.toMenu()); } } --- 1268,1281 ---- 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) ! && orStep != GameDef.OrStep.LAY_TOKEN) { ! List<LayToken> tokenActions = ! possibleActions.getType(LayToken.class); ! for (LayToken tAction : tokenActions) { ! SpecialTokenLay stl = tAction.getSpecialProperty(); ! orPanel.addSpecialAction(tAction, stl.toMenu()); } } *************** *** 1284,1287 **** --- 1301,1314 ---- LocalText.getText("DestinationsReached")); } + + // Any other special properties, to be shown in the "Special" menu. + // (Currently not used) + if (possibleActions.contains(UseSpecialProperty.class)) { + for (UseSpecialProperty usp : possibleActions.getType(UseSpecialProperty.class)) { + SpecialPropertyI sp = usp.getSpecialProperty(); + orPanel.addSpecialAction(usp, sp.getInfo()); + } + } + checkForGameSpecificActions(); |