From: Erik V. <ev...@us...> - 2009-01-21 20:18:36
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26428/rails/ui/swing Modified Files: ORUIManager.java ORPanel.java Log Message: Added 1856 loan repayment step at end of OR. Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ORUIManager.java 15 Jan 2009 20:53:28 -0000 1.25 --- ORUIManager.java 21 Jan 2009 20:18:23 -0000 1.26 *************** *** 345,348 **** --- 345,352 ---- takeLoans ((TakeLoans)actions.get(0)); + + } else if (actionType == RepayLoans.class) { + + repayLoans ((RepayLoans)actions.get(0)); } *************** *** 1051,1056 **** } ! protected void repayLoans () { } --- 1055,1098 ---- } ! protected void repayLoans (RepayLoans action) { ! ! int minNumber = action.getMinNumber(); ! int maxNumber = action.getMaxNumber(); ! int loanAmount = action.getPrice(); ! int numberRepaid = 0; + if (minNumber == maxNumber) { + // No choice, just tell him + JOptionPane.showMessageDialog (orWindow, + LocalText.getText("RepayLoan", + minNumber, + Bank.format(loanAmount), + 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"), + 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); } *************** *** 1147,1156 **** setMessage(message); ! } else if (possibleActions.contains(BuyTrain.class)/* ! * || ! * possibleActions.contains(DiscardTrain.class) ! */) { - // orPanel.initTrainBuying(oRound.getOperatingCompany().mayBuyTrains()); orPanel.initTrainBuying(true); --- 1189,1194 ---- setMessage(message); ! } else if (possibleActions.contains(BuyTrain.class)) { orPanel.initTrainBuying(true); *************** *** 1159,1167 **** } else if (possibleActions.contains(DiscardTrain.class)) { - // discardTrain(); ! } else if (possibleActions.contains(TakeLoans.class)) { ! orPanel.enableLoanTaking (possibleActions.getType(TakeLoans.class).get(0)); } else if (orStep == OperatingRound.STEP_FINAL) { --- 1197,1204 ---- } else if (possibleActions.contains(DiscardTrain.class)) { ! } else if (possibleActions.contains(RepayLoans.class)) { ! orPanel.enableLoanRepayment (possibleActions.getType(RepayLoans.class).get(0)); } else if (orStep == OperatingRound.STEP_FINAL) { Index: ORPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORPanel.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ORPanel.java 11 Jan 2009 17:24:46 -0000 1.28 --- ORPanel.java 21 Jan 2009 20:18:23 -0000 1.29 *************** *** 724,727 **** --- 724,742 ---- takeLoans.setEnabled(action != null); } + + public void enableLoanRepayment (RepayLoans action) { + + repayLoans.setPossibleAction(action); + repayLoans.setEnabled(true); + + loansCaption.setHighlight(true); + + button1.setText(LocalText.getText("RepayLoans")); + button1.setActionCommand(REPAY_LOANS_CMD); + button1.setPossibleAction(action); + button1.setMnemonic(KeyEvent.VK_R); + button1.setEnabled(true); + button1.setVisible(true); + } public void finishORCompanyTurn(int orCompIndex) { |