From: Stefan F. <ste...@us...> - 2010-03-14 13:10:24
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27643/rails/ui/swing Modified Files: StatusWindow.java GameUIManager.java Log Message: Updated EndOfGame Handling (undo possible, ranking display step by step, updated forced share selling message display, LocalText) Index: StatusWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StatusWindow.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** StatusWindow.java 8 Mar 2010 20:33:27 -0000 1.39 --- StatusWindow.java 14 Mar 2010 13:10:15 -0000 1.40 *************** *** 6,9 **** --- 6,10 ---- import java.awt.event.*; import java.util.ArrayList; + import java.util.Collections; import java.util.List; *************** *** 324,334 **** public void setCorrectionMenu() { ! // Update the menu correctionMenu.removeAll(); correctionMenu.setEnabled(false); List<CorrectionModeAction> corrections = possibleActions.getType(CorrectionModeAction.class); ! if (corrections != null) { for (CorrectionModeAction a : corrections) { ActionCheckBoxMenuItem item = new ActionCheckBoxMenuItem ( --- 325,338 ---- public void setCorrectionMenu() { ! // Update the correction menu correctionMenu.removeAll(); correctionMenu.setEnabled(false); + // currently only shows CorrectionModeActions List<CorrectionModeAction> corrections = possibleActions.getType(CorrectionModeAction.class); ! ! ! if (corrections != null && !corrections.isEmpty()) { for (CorrectionModeAction a : corrections) { ActionCheckBoxMenuItem item = new ActionCheckBoxMenuItem ( *************** *** 366,371 **** public void updateStatus() { ! if (!(currentRound instanceof StockRound)) { return; ! } if (currentRound instanceof TreasuryShareRound) { --- 370,375 ---- public void updateStatus() { ! if (!(currentRound instanceof StockRound || currentRound instanceof EndOfGameRound)) ! return; if (currentRound instanceof TreasuryShareRound) { *************** *** 388,406 **** ((ShareSellingRound) currentRound).getRemainingCashToRaise(); if (!possibleActions.contains(SellShares.class)) { ! JOptionPane.showMessageDialog(this, LocalText.getText( ! "YouAreBankrupt", Bank.format(cash)), "", ! JOptionPane.OK_OPTION); /* * For now assume that this ends the game (not true in all * games) */ ! JOptionPane.showMessageDialog(this, ! gameUIManager.getGameManager().getGameReport(), "", JOptionPane.OK_OPTION); /* * All other wrapping up has already been done when calling * getSellableCertificates, so we can just finish now. */ ! finish(); ! return; } else { JOptionPane.showMessageDialog(this, LocalText.getText( --- 392,412 ---- ((ShareSellingRound) currentRound).getRemainingCashToRaise(); if (!possibleActions.contains(SellShares.class)) { ! // should not occur anymore ! // JOptionPane.showMessageDialog(this, LocalText.getText( ! // "YouMustRaiseCashButCannot", Bank.format(cash)), "", ! // JOptionPane.OK_OPTION); /* * For now assume that this ends the game (not true in all * games) + * sfy: changed now */ ! // JOptionPane.showMessageDialog(this, ! // gameUIManager.getGameManager().getGameReport(), "", JOptionPane.OK_OPTION); /* * All other wrapping up has already been done when calling * getSellableCertificates, so we can just finish now. */ ! // finish(); ! // return; } else { JOptionPane.showMessageDialog(this, LocalText.getText( *************** *** 408,412 **** JOptionPane.OK_OPTION); } ! } else if (!updateGameSpecificSettings()) { setTitle(LocalText.getText( --- 414,418 ---- JOptionPane.OK_OPTION); } ! } else if (currentRound instanceof StockRound && !updateGameSpecificSettings()) { setTitle(LocalText.getText( *************** *** 491,494 **** --- 497,502 ---- } + if (currentRound instanceof EndOfGameRound) endOfGame(); + pack(); *************** *** 638,680 **** } - public void reportGameOver() { - /* End of rails.game checks */ - - JOptionPane.showMessageDialog(this, "GAME OVER", "", - JOptionPane.OK_OPTION); - JOptionPane.showMessageDialog(this, - GameManager.getInstance().getGameReport(), "", - JOptionPane.OK_OPTION); - /* - * All other wrapping up has already been done when calling - * getSellableCertificates, so we can just finish now. - */ - finish(); - } - - public void reportBankBroken() { - - /* The message must become configuration-depedent */ - JOptionPane.showMessageDialog(this, - "Bank is broken. The rails.game will be over after the current set of ORs."); - } - /** ! * Finish the application. */ ! public void finish() { ! setVisible(true); ! gameUIManager.reportWindow.setVisible(true); ! gameUIManager.stockChart.setVisible(true); ! /* Disable all buttons */ passButton.setEnabled(true); passButton.setText(LocalText.getText("END_OF_GAME_CLOSE_ALL_WINDOWS")); gameUIManager.orWindow.finish(); ! toFront(); } ! public void keyReleased(KeyEvent e) {} --- 646,696 ---- } /** ! * End of Game processing */ ! public void endOfGame() { ! // setVisible(true); ! // gameUIManager.reportWindow.setVisible(true); ! // gameUIManager.stockChart.setVisible(true); ! ! setTitle(LocalText.getText("EoGTitle")); ! // Enable Passbutton passButton.setEnabled(true); passButton.setText(LocalText.getText("END_OF_GAME_CLOSE_ALL_WINDOWS")); + gameUIManager.orWindow.finish(); + } ! public void endOfGameReport() { + GameManagerI gm = GameManager.getInstance(); + + if (gm.getGameOverReportedUI()) + return; + else + gm.setGameOverReportedUI(true); + + JOptionPane.showMessageDialog(this, + LocalText.getText("EoGPressButton"), + LocalText.getText("EoGFinalRanking"), + JOptionPane.PLAIN_MESSAGE + ); + + // show game report line by line + List<String> gameReport = GameManager.getInstance().getGameReport(); + Collections.reverse(gameReport); + + StringBuilder report = new StringBuilder(); + for (String s:gameReport) { + report.insert(0, s); + JOptionPane.showMessageDialog(this, + report, + LocalText.getText("EoGFinalRanking"), + JOptionPane.PLAIN_MESSAGE + ); + } } ! public void keyReleased(KeyEvent e) {} Index: GameUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameUIManager.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** GameUIManager.java 14 Mar 2010 08:06:45 -0000 1.43 --- GameUIManager.java 14 Mar 2010 13:10:15 -0000 1.44 *************** *** 179,189 **** // End of game checks ! if (gameManager.isGameOver()) { ! ! statusWindow.reportGameOver(); ! ! return true; ! ! } // else if (gameManager.getBank().isJustBroken()) { // --- 179,189 ---- // End of game checks ! // if (gameManager.isGameOver()) { ! // ! // statusWindow.reportGameOver(); ! // ! // return true; ! // ! // } // else if (gameManager.getBank().isJustBroken()) { // *************** *** 207,210 **** --- 207,213 ---- } } + + // display the end of game report + if (gameManager.isGameOver()) statusWindow.endOfGameReport(); if (!result) return false; *************** *** 335,338 **** --- 338,342 ---- boolean correctionOverride = statusWindow.setupFor(currentRound); + correctionOverride = false; if (correctionOverride) { |