You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(46) |
Dec
(57) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(51) |
Feb
(10) |
Mar
|
Apr
|
May
(14) |
Jun
|
Jul
(13) |
Aug
(30) |
Sep
(83) |
Oct
(56) |
Nov
(148) |
Dec
(107) |
2010 |
Jan
(260) |
Feb
(164) |
Mar
(183) |
Apr
(99) |
May
(160) |
Jun
(40) |
Jul
(33) |
Aug
(48) |
Sep
(22) |
Oct
(24) |
Nov
(1) |
Dec
(12) |
2011 |
Jan
(6) |
Feb
(15) |
Mar
(13) |
Apr
(37) |
May
(27) |
Jun
(29) |
Jul
(33) |
Aug
(20) |
Sep
(17) |
Oct
(20) |
Nov
(33) |
Dec
(17) |
2012 |
Jan
(39) |
Feb
(38) |
Mar
(20) |
Apr
(21) |
May
(17) |
Jun
(22) |
Jul
(16) |
Aug
(3) |
Sep
(9) |
Oct
(10) |
Nov
|
Dec
|
From: <ev...@us...> - 2011-02-06 19:29:12
|
Revision: 1482 http://rails.svn.sourceforge.net/rails/?rev=1482&view=rev Author: evos Date: 2011-02-06 19:29:06 +0000 (Sun, 06 Feb 2011) Log Message: ----------- Added "Load Recent Game" option to game setup screen. This option offers a selection of the 20 most recent saved files in and below the configured save directory. Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/ui/swing/GameSetupWindow.java trunk/18xx/rails/ui/swing/GameUIManager.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2011-02-05 20:00:15 UTC (rev 1481) +++ trunk/18xx/LocalisedText.properties 2011-02-06 19:29:06 UTC (rev 1482) @@ -352,6 +352,7 @@ LeaveAuctionOnPass=Leave private auction on pass LoadFailed=Load failed, reason: {0} LoadGame=Load Game +LoadRecentGame=Load Recent LOAD=Load LoadInterrupted=Load interrupted at this point, you can continue play from here LoansNotAllowed={0} may not take any loans Modified: trunk/18xx/rails/ui/swing/GameSetupWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/GameSetupWindow.java 2011-02-05 20:00:15 UTC (rev 1481) +++ trunk/18xx/rails/ui/swing/GameSetupWindow.java 2011-02-06 19:29:06 UTC (rev 1482) @@ -4,6 +4,7 @@ import java.awt.*; import java.awt.event.*; import java.io.File; +import java.io.IOException; import java.util.*; import java.util.List; @@ -13,8 +14,7 @@ import rails.common.GuiDef; import rails.game.*; -import rails.util.Config; -import rails.util.LocalText; +import rails.util.*; /** * The Game Setup Window displays the first window presented to the user. This @@ -25,7 +25,7 @@ private static final long serialVersionUID = 1L; GridBagConstraints gc; JPanel gameListPane, playersPane, buttonPane, optionsPane; - JButton newButton, loadButton, recoveryButton, quitButton, optionButton, infoButton, + JButton newButton, loadButton, recentButton, recoveryButton, quitButton, optionButton, infoButton, creditsButton, randomizeButton, configureButton; JComboBox gameNameBox = new JComboBox(); JComboBox[] playerBoxes = new JComboBox[Player.MAX_PLAYERS]; @@ -39,6 +39,9 @@ List<GameOption> availableOptions = new ArrayList<GameOption>(); String gameName; Game game; + + SortedSet<File> recentFiles; + String savedFileExtension; private ConfigWindow configWindow; @@ -68,6 +71,7 @@ newButton = new JButton(LocalText.getText("NewGame")); loadButton = new JButton(LocalText.getText("LoadGame")); + recentButton = new JButton(LocalText.getText("LoadRecentGame")); recoveryButton = new JButton(LocalText.getText("RecoverGame")); quitButton = new JButton(LocalText.getText("QUIT")); optionButton = new JButton(LocalText.getText("OPTIONS")); @@ -77,6 +81,7 @@ newButton.setMnemonic(KeyEvent.VK_N); loadButton.setMnemonic(KeyEvent.VK_L); + recentButton.setMnemonic(KeyEvent.VK_D); recoveryButton.setMnemonic(KeyEvent.VK_R); quitButton.setMnemonic(KeyEvent.VK_Q); optionButton.setMnemonic(KeyEvent.VK_O); @@ -99,6 +104,7 @@ newButton.addActionListener(this); loadButton.addActionListener(this); + recentButton.addActionListener(this); recoveryButton.addActionListener(this); quitButton.addActionListener(this); optionButton.addActionListener(this); @@ -109,6 +115,7 @@ buttonPane.add(newButton); buttonPane.add(loadButton); + buttonPane.add(recentButton); recoveryButton.setEnabled(Config.get("save.recovery.active", "no").equalsIgnoreCase("yes")); buttonPane.add(recoveryButton); @@ -116,7 +123,7 @@ buttonPane.add(quitButton); buttonPane.add(creditsButton); - buttonPane.setLayout(new GridLayout(3, 2)); + buttonPane.setLayout(new GridLayout(0, 2)); buttonPane.setBorder(BorderFactory.createLoweredBevelBorder()); optionsPane.setLayout(new FlowLayout()); @@ -252,6 +259,42 @@ } else { // cancel pressed return; } + } else if (arg0.getSource().equals(recentButton)) { + File saveDirectory = new File(Config.get("save.directory")); + if (saveDirectory == null) return; + + recentFiles = new TreeSet<File>(new Comparator<File> (){ + public int compare (File a, File b) { + return Math.round(b.lastModified() - a.lastModified()); + } + }); + savedFileExtension = Config.get("save.filename.extension"); + if (!Util.hasValue(savedFileExtension)) { + savedFileExtension = GameUIManager.DEFAULT_SAVE_EXTENSION; + } + savedFileExtension = "."+savedFileExtension; + + getRecentFiles(saveDirectory); + if (recentFiles == null || recentFiles.size() == 0) return; + File[] files = recentFiles.toArray(new File[]{}); + int numOptions = 20; + String[] options = new String[numOptions]; + int dirPathLength = saveDirectory.getPath().length(); + for (int i=0; i<numOptions;i++) { + // Get path relative to saveDirectory + options[i] = files[i].getPath().substring(dirPathLength+1); + } + String text = LocalText.getText("Select"); + String result = (String) JOptionPane.showInputDialog(this, text, text, + JOptionPane.OK_CANCEL_OPTION, + null, options, options[0]); + if (result == null) return; + File selectedFile = files[Arrays.asList(options).indexOf(result)]; + if (selectedFile != null) { + loadAndStartGame(selectedFile.getPath(), selectedFile.getParent()); + } else { // cancel pressed + return; + } } else if (arg0.getSource().equals(recoveryButton)) { String filePath = Config.get("save.recovery.filepath", "18xx_autosave.rails"); loadAndStartGame(filePath, null); @@ -317,6 +360,17 @@ } } } + + private void getRecentFiles (File dir) { + if (!dir.exists() || !dir.isDirectory()) return; + for (File entry : dir.listFiles()) { + if (entry.isFile() && entry.getName().endsWith(savedFileExtension)) { + recentFiles.add(entry); + } else if (entry.isDirectory()){ + getRecentFiles(entry); + } + } + } private void toggleOptions() { if (optionsPane.isVisible()) { Modified: trunk/18xx/rails/ui/swing/GameUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/GameUIManager.java 2011-02-05 20:00:15 UTC (rev 1481) +++ trunk/18xx/rails/ui/swing/GameUIManager.java 2011-02-06 19:29:06 UTC (rev 1482) @@ -54,7 +54,7 @@ protected static final String DEFAULT_SAVE_DIRECTORY = "save"; protected static final String DEFAULT_SAVE_PATTERN = "yyyyMMdd_HHmm"; - protected static final String DEFAULT_SAVE_EXTENSION = "rails"; + public static final String DEFAULT_SAVE_EXTENSION = "rails"; protected static final String NEXT_PLAYER_SUFFIX = "NEXT_PLAYER"; protected String saveDirectory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-02-05 20:00:23
|
Revision: 1481 http://rails.svn.sourceforge.net/rails/?rev=1481&view=rev Author: evos Date: 2011-02-05 20:00:15 +0000 (Sat, 05 Feb 2011) Log Message: ----------- Fix: in 1835, tile laying can hang if OBB owner lays first OBB special property tile. Modified Paths: -------------- trunk/18xx/rails/game/Game.java trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java Modified: trunk/18xx/rails/game/Game.java =================================================================== --- trunk/18xx/rails/game/Game.java 2011-02-05 15:10:22 UTC (rev 1480) +++ trunk/18xx/rails/game/Game.java 2011-02-05 20:00:15 UTC (rev 1481) @@ -13,7 +13,7 @@ import rails.util.Tag; public class Game { - public static final String version = "1.4.1"; + public static final String version = "1.4.1+"; /** The component Manager */ protected ComponentManager componentManager; Modified: trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java =================================================================== --- trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java 2011-02-05 15:10:22 UTC (rev 1480) +++ trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java 2011-02-05 20:00:15 UTC (rev 1481) @@ -219,10 +219,12 @@ } @Override public boolean layTile(LayTile action) { + + boolean hasJustLaidExtraOBBTile = action.getSpecialProperty() != null + && action.getSpecialProperty().getLocationNameString().matches("M1(5|7)"); // The extra OBB tiles may not both be laid in the same round - if (action.getSpecialProperty() != null - && action.getSpecialProperty().getLocationNameString().matches("M1(5|7)")) { + if (hasJustLaidExtraOBBTile) { if (hasLaidExtraOBBTile.booleanValue()) { String errMsg = LocalText.getText("InvalidTileLay"); DisplayBuffer.add(LocalText.getText("CannotLayTileOn", @@ -232,14 +234,18 @@ Bank.format(0), errMsg )); return false; + } else { + hasLaidExtraOBBTile.set(true); + // Done here to make getSpecialTileLays() return the correct value. + // It's provisional, on the assumption that other validations are OK. } } boolean result = super.layTile(action); - if (result && action.getSpecialProperty() != null - && action.getSpecialProperty().getLocationNameString().matches("M1(5|7)")) { - hasLaidExtraOBBTile.set(true); + if (!result && hasJustLaidExtraOBBTile) { + // Revert if tile lay is unsuccessful + hasLaidExtraOBBTile.set(false); } return result; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-02-05 15:10:29
|
Revision: 1480 http://rails.svn.sourceforge.net/rails/?rev=1480&view=rev Author: evos Date: 2011-02-05 15:10:22 +0000 (Sat, 05 Feb 2011) Log Message: ----------- Fixed bug that mangled operating sequence after PR formation in 1835. Was caused by introduction of dynamic operating sequence, which did not cover (minor) company closures. Modified Paths: -------------- trunk/18xx/rails/game/Round.java trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java Modified: trunk/18xx/rails/game/Round.java =================================================================== --- trunk/18xx/rails/game/Round.java 2011-02-03 23:22:49 UTC (rev 1479) +++ trunk/18xx/rails/game/Round.java 2011-02-05 15:10:22 UTC (rev 1480) @@ -268,6 +268,7 @@ Map<Integer, PublicCompanyI> operatingCompanies = new TreeMap<Integer, PublicCompanyI>(); + List<PublicCompanyI> newOperatingCompanies; StockSpaceI space; int key; int minorNo = 0; @@ -276,13 +277,15 @@ int lastOperatingCompanyIndex; if (reorder) { + newOperatingCompanies = oldOperatingCompanies; lastOperatingCompanyIndex = oldOperatingCompanies.indexOf(lastOperatingCompany); } else { + newOperatingCompanies = companyManager.getAllPublicCompanies(); lastOperatingCompanyIndex = -1; } - for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { - if (!canCompanyOperateThisRound(company)) continue; + for (PublicCompanyI company : newOperatingCompanies) { + if (!reorder && !canCompanyOperateThisRound(company)) continue; if (reorder && oldOperatingCompanies.indexOf(company) <= lastOperatingCompanyIndex) { Modified: trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java =================================================================== --- trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java 2011-02-03 23:22:49 UTC (rev 1479) +++ trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java 2011-02-05 15:10:22 UTC (rev 1480) @@ -138,7 +138,6 @@ @Override public void resume() { - PublicCompanyI prussian = companyManager.getPublicCompany(GameManager_1835.PR_ID); if (prussian.hasFloated() && !prussian.hasOperated() @@ -149,7 +148,7 @@ log.debug("M2 has not operated: PR can operate"); // Insert the Prussian before the first major company - // with a lower current price that hoas not yet operated + // with a lower current price that has not yet operated // and isn't currently operating int index = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-02-03 23:22:56
|
Revision: 1479 http://rails.svn.sourceforge.net/rails/?rev=1479&view=rev Author: evos Date: 2011-02-03 23:22:49 +0000 (Thu, 03 Feb 2011) Log Message: ----------- Fixed bug #3165621: 1889 port token could not be laid. Tile laying code has been generally cleaned up and simplified. Cases where a regular and a special property-originating tile can be laid on the same hex now work correctly (such as in 1899 hex G10 in the saved file provided with the above bug). Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/action/LayTile.java trunk/18xx/rails/game/move/MapChange.java trunk/18xx/rails/game/move/RemoveFromMap.java trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java trunk/18xx/rails/game/state/HashMapState.java trunk/18xx/rails/ui/swing/ORUIManager.java trunk/18xx/rails/ui/swing/UpgradesPanel.java trunk/18xx/rails/ui/swing/hexmap/GUIHex.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2011-02-01 17:27:05 UTC (rev 1478) +++ trunk/18xx/rails/game/OperatingRound.java 2011-02-03 23:22:49 UTC (rev 1479) @@ -43,9 +43,9 @@ // Non-persistent lists (are recreated after each user action) protected List<SpecialPropertyI> currentSpecialProperties = null; - protected List<LayTile> currentSpecialTileLays = new ArrayList<LayTile>(); + //protected List<LayTile> currentSpecialTileLays = new ArrayList<LayTile>(); - protected List<LayTile> currentNormalTileLays = new ArrayList<LayTile>(); + //protected List<LayTile> currentNormalTileLays = new ArrayList<LayTile>(); protected HashMapState<String, Integer> tileLaysPerColour = new HashMapState<String, Integer>("tileLaysPerColour"); @@ -419,7 +419,7 @@ // Was a special property used? if (stl != null) { stl.setExercised(); - currentSpecialTileLays.remove(action); + //currentSpecialTileLays.remove(action); log.debug("This was a special tile lay, " + (extra ? "" : " not") + " extra"); @@ -428,14 +428,9 @@ log.debug("This was a normal tile lay"); registerNormalTileLay(tile); } - - setSpecialTileLays(); - log.debug("There are now " + currentSpecialTileLays.size() - + " special tile lay objects"); } - if (tile == null || currentNormalTileLays.isEmpty() - && currentSpecialTileLays.isEmpty()) { + if (tile == null || !areTileLaysPossible()) { nextStep(); } @@ -460,33 +455,34 @@ int oldAllowedNumber = oldAllowedNumberObject.intValue(); if (oldAllowedNumber <= 0) return false; - if (!update) return true; + if (update) updateAllowedTileColours(colour, oldAllowedNumber); + return true; + } - /* - * We will assume that in all cases the following assertions hold: 1. If - * the allowed number for the colour of the just laid tile reaches zero, - * all normal tile lays have been consumed. 2. If any colour is laid, no - * different colours may be laid. THIS MAY NOT BE TRUE FOR ALL GAMES! - */ + /* + * We will assume that in all cases the following assertions hold: 1. If + * the allowed number for the colour of the just laid tile reaches zero, + * all normal tile lays have been consumed. 2. If any colour is laid, no + * different colours may be laid. THIS MAY NOT BE TRUE FOR ALL GAMES! + */ + protected void updateAllowedTileColours (String colour, int oldAllowedNumber) { + if (oldAllowedNumber <= 1) { - for (String key:tileLaysPerColour.viewKeySet()) { - tileLaysPerColour.put(key, new Integer(0)); - } + tileLaysPerColour.clear(); log.debug("No more normal tile lays allowed"); - currentNormalTileLays.clear(); + //currentNormalTileLays.clear();// Shouldn't be needed anymore ?? } else { for (String key:tileLaysPerColour.viewKeySet()) { if (colour.equals(key)) { - tileLaysPerColour.put(colour, new Integer(oldAllowedNumber-1)); + tileLaysPerColour.put(colour, oldAllowedNumber-1); } else { - tileLaysPerColour.put(key, new Integer(0)); + tileLaysPerColour.remove(colour); } } - log.debug((oldAllowedNumber - 1) + " more " + colour - + " tile lays allowed"); + log.debug((oldAllowedNumber - 1) + " additional " + colour + + " tile lays allowed; no other colours"); } - return true; } public boolean layBaseToken(LayBaseToken action) { @@ -1351,7 +1347,7 @@ * method should be called only once per company turn in an OR: at the start * of the tile laying step. */ - protected void getNormalTileLays() { + protected void initNormalTileLays() { // duplicate the phase colours Map<String, Integer> newTileColours = new HashMap<String, Integer>(getCurrentPhase().getTileColours()); @@ -1364,46 +1360,80 @@ tileLaysPerColour.initFromMap(newTileColours); } - protected void setNormalTileLays() { + protected List<LayTile> getNormalTileLays(boolean display) { /* Normal tile lays */ - currentNormalTileLays.clear(); + List<LayTile> currentNormalTileLays = new ArrayList<LayTile>(); + + // Check which colours can still be laid + Map <String, Integer> remainingTileLaysPerColour = new HashMap<String, Integer>(); - // Map<String,Integer> tileLaysPerColour = (Map<String,Integer>)(tileLaysPerColourState.getObject()); - - int sumLays = 0; - for (Integer i: tileLaysPerColour.viewValues()) - sumLays = sumLays + i; - if (sumLays != 0) { - // if (!tileLaysPerColour.isEmpty()) { - currentNormalTileLays.add(new LayTile(tileLaysPerColour.viewMap())); + int lays = 0; + for (String colourName: tileLaysPerColour.viewKeySet()) { + lays = tileLaysPerColour.get(colourName); + if (lays != 0) { + remainingTileLaysPerColour.put(colourName, lays); + } } - + if (!remainingTileLaysPerColour.isEmpty()) { + currentNormalTileLays.add(new LayTile(remainingTileLaysPerColour)); + } + + // NOTE: in a later stage tile lays will be specified per hex or set of hexes. + + if (display) { + int size = currentNormalTileLays.size(); + if (size == 0) { + log.debug("No normal tile lays"); + } else { + for (LayTile tileLay : currentNormalTileLays) { + log.debug("Normal tile lay: " + tileLay.toString()); + } + } + } + return currentNormalTileLays; } /** * Create a List of allowed special tile lays (see LayTile class). This * method should be called before each user action in the tile laying step. */ - protected void setSpecialTileLays() { + protected List<LayTile> getSpecialTileLays(boolean display) { /* Special-property tile lays */ - currentSpecialTileLays.clear(); + List<LayTile> currentSpecialTileLays = new ArrayList<LayTile>(); - if (!operatingCompany.get().canUseSpecialProperties()) return; + if (operatingCompany.get().canUseSpecialProperties()) { - for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { - if ( -// stl.getTile() != null && getCurrentPhase().isTileColourAllowed(stl.getTile().getColourName()) && - // if a tile is specified it must have a tile colour currently available - // commented out as it is not required and makes 1856 save files invalid - (stl.isExtra() || !currentNormalTileLays.isEmpty())) { - // If the special tile lay is not extra, it is only allowed if - // normal tile lays are also (still) allowed - currentSpecialTileLays.add(new LayTile(stl)); + for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { + if (stl.isExtra() + // If the special tile lay is not extra, it is only allowed if + // normal tile lays are also (still) allowed + || stl.getTile() != null + && checkNormalTileLay(stl.getTile(), false)) { + currentSpecialTileLays.add(new LayTile(stl)); + } } } + + if (display) { + int size = currentSpecialTileLays.size(); + if (size == 0) { + log.debug("No special tile lays"); + } else { + for (LayTile tileLay : currentSpecialTileLays) { + log.debug("Special tile lay: " + tileLay.toString()); + } + } + } + + return currentSpecialTileLays; } + + protected boolean areTileLaysPossible() { + return !tileLaysPerColour.isEmpty() + || !getSpecialTileLays(false).isEmpty(); + } protected void setNormalTokenLays() { @@ -2307,7 +2337,7 @@ if (noMapMode) { nextStep (GameDef.OrStep.LAY_TOKEN); } else { - getNormalTileLays(); // new: only called once per turn ? + initNormalTileLays(); // new: only called once per turn ? setStep (GameDef.OrStep.LAY_TRACK); } } @@ -2321,13 +2351,8 @@ possibleActions.add(new LayBaseToken (operatingCompany.get().getHomeHex())); forced = true; } else { - setNormalTileLays(); - setSpecialTileLays(); - log.debug("Normal tile lays: " + currentNormalTileLays.size()); - log.debug("Special tile lays: " + currentSpecialTileLays.size()); - - possibleActions.addAll(currentNormalTileLays); - possibleActions.addAll(currentSpecialTileLays); + possibleActions.addAll(getNormalTileLays(true)); + possibleActions.addAll(getSpecialTileLays(true)); possibleActions.add(new NullAction(NullAction.SKIP)); } Modified: trunk/18xx/rails/game/action/LayTile.java =================================================================== --- trunk/18xx/rails/game/action/LayTile.java 2011-02-01 17:27:05 UTC (rev 1478) +++ trunk/18xx/rails/game/action/LayTile.java 2011-02-03 23:22:49 UTC (rev 1479) @@ -85,6 +85,7 @@ public LayTile(Map<String, Integer> tileColours) { type = GENERIC; setTileColours (tileColours); + // NOTE: tileColours is currently only used for Help purposes. } public LayTile(SpecialTileLay specialProperty) { @@ -100,6 +101,8 @@ tiles.add(tile); } } + + } /** @@ -199,8 +202,10 @@ // Check the map. Sometimes 0 values creep in, and these can't easily // be intercepted in the UI code (see comment at previous method). // TODO This is a dirty fix, but the quickest one too. - for (String colourName : map.keySet()) { - if (map.get(colourName) > 0) tileColours.put(colourName, map.get(colourName)); + if (map != null) { + for (String colourName : map.keySet()) { + if (map.get(colourName) > 0) tileColours.put(colourName, map.get(colourName)); + } } } Modified: trunk/18xx/rails/game/move/MapChange.java =================================================================== --- trunk/18xx/rails/game/move/MapChange.java 2011-02-01 17:27:05 UTC (rev 1478) +++ trunk/18xx/rails/game/move/MapChange.java 2011-02-03 23:22:49 UTC (rev 1479) @@ -45,6 +45,8 @@ public boolean undo() { if (keyExisted) { map.put (key, oldValue); + } else { + map.remove(key); } return true; } Modified: trunk/18xx/rails/game/move/RemoveFromMap.java =================================================================== --- trunk/18xx/rails/game/move/RemoveFromMap.java 2011-02-01 17:27:05 UTC (rev 1478) +++ trunk/18xx/rails/game/move/RemoveFromMap.java 2011-02-03 23:22:49 UTC (rev 1479) @@ -25,9 +25,11 @@ public RemoveFromMap (Map<K, V> map, K key) { + keyExisted = map.containsKey(key); + if (!keyExisted) return; // Nothing to do this.map = map; this.key = key; - this.keyExisted = map.containsKey(key); + this.oldValue = map.get(key); MoveSet.add(this); } @@ -49,7 +51,7 @@ } public String toString() { - return "RemoveFromMap: remove key="+key+" from map"; + return "RemoveFromMap: remove key="+key+" value="+oldValue+" from map"; } } Modified: trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java =================================================================== --- trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java 2011-02-01 17:27:05 UTC (rev 1478) +++ trunk/18xx/rails/game/specific/_1835/OperatingRound_1835.java 2011-02-03 23:22:49 UTC (rev 1479) @@ -182,25 +182,42 @@ } @Override - protected void setSpecialTileLays() { + protected List<LayTile> getSpecialTileLays(boolean display) { /* Special-property tile lays */ - currentSpecialTileLays.clear(); + List<LayTile> currentSpecialTileLays = new ArrayList<LayTile>(); - if (!operatingCompany.get().canUseSpecialProperties()) return; + if (operatingCompany.get().canUseSpecialProperties()) { - for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { - if (stl.isExtra() || !currentNormalTileLays.isEmpty()) { + for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) { + if (stl.isExtra() + // If the special tile lay is not extra, it is only allowed if + // normal tile lays are also (still) allowed + || stl.getTile() != null + && getCurrentPhase().isTileColourAllowed(stl.getTile().getColourName())) { - // Exclude the second OBB free tile if the first was laid in this round - if (stl.getLocationNameString().matches("M1(7|9)") - && hasLaidExtraOBBTile.booleanValue()) continue; + // Exclude the second OBB free tile if the first was laid in this round + if (stl.getLocationNameString().matches("M1(7|9)") + && hasLaidExtraOBBTile.booleanValue()) continue; - currentSpecialTileLays.add(new LayTile(stl)); + currentSpecialTileLays.add(new LayTile(stl)); + } } } + + if (display) { + int size = currentSpecialTileLays.size(); + if (size == 0) { + log.debug("No special tile lays"); + } else { + for (LayTile tileLay : currentSpecialTileLays) { + log.debug("Special tile lay: " + tileLay.toString()); + } + } + } + + return currentSpecialTileLays; } - @Override public boolean layTile(LayTile action) { Modified: trunk/18xx/rails/game/state/HashMapState.java =================================================================== --- trunk/18xx/rails/game/state/HashMapState.java 2011-02-01 17:27:05 UTC (rev 1478) +++ trunk/18xx/rails/game/state/HashMapState.java 2011-02-03 23:22:49 UTC (rev 1479) @@ -1,8 +1,10 @@ package rails.game.state; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; @@ -58,9 +60,14 @@ } public void clear() { - for (K key:map.keySet()) { - remove(key); + // Two-step process to avoid concurrent modification exception + List<K> keys = new ArrayList<K>(); + for (K key : map.keySet()) { + keys.add(key); } + for (K key : keys) { + remove (key); + } } /** @@ -100,4 +107,8 @@ public Collection<V> viewValues() { return Collections.unmodifiableCollection(map.values()); } + + public boolean isEmpty() { + return map.isEmpty(); + } } Modified: trunk/18xx/rails/ui/swing/ORUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/ORUIManager.java 2011-02-01 17:27:05 UTC (rev 1478) +++ trunk/18xx/rails/ui/swing/ORUIManager.java 2011-02-03 23:22:49 UTC (rev 1479) @@ -748,13 +748,48 @@ if (selectedHex != null && selectedHex.canFixTile()) { List<LayTile> allowances = map.getTileAllowancesForHex(selectedHex.getHexModel()); - LayTile allowance = allowances.get(0); // TODO Wrong if we have an - // additional special - // property (18AL Lumber - // Terminal) + LayTile allowance = null; + TileI tile = selectedHex.getProvisionalTile(); + if (allowances.size() == 1) { + allowance = allowances.get(0); + } else { + // Check which allowance applies + // We'll restrict to cases where we have both a special property + // and a normal 'blanket' allowance. + // First check which is which. + List<TileI> sp_tiles; + List<MapHex> sp_hexes; + LayTile gen_lt = null; + for (LayTile lt : allowances) { + if (lt.getType() == LayTile.SPECIAL_PROPERTY) { + // Cases where a special property is used include: + // 1. SP refers to specified tiles, (one of) which is chosen: + // (examples: 18AL Lumber Terminal, 1889 Port) + if ((((sp_tiles = lt.getTiles()) != null + && sp_tiles.contains(tile)) + // 2. SP does not refer to specific tiles but it does refer to + // specified hexes, (one of) which is chosen: + // (example: 1830 hex B20) + || (sp_tiles == null + && (sp_hexes = lt.getLocations()) != null) + && sp_hexes.contains(selectedHex.getModel()))) { + allowance = lt; + break; + } + } else { + gen_lt = lt; + } + } + + // Default case: the generic allowance + // TODO It is not clear that all possible cases have been covered yet. + // But at least this works for 1830, 1889 + if (allowance == null) allowance = gen_lt; + + } allowance.setChosenHex(selectedHex.getHexModel()); allowance.setOrientation(selectedHex.getProvisionalTileRotation()); - allowance.setLaidTile(selectedHex.getProvisionalTile()); + allowance.setLaidTile(tile); relayBaseTokens (allowance); @@ -1726,7 +1761,7 @@ upgradePanel.setCancelEnabled(true); break; case SELECT_TILE: - upgradePanel.populate(); + upgradePanel.populate(gameUIManager.getCurrentPhase()); upgradePanel.setDoneEnabled(false); break; case ROTATE_OR_CONFIRM_TILE: Modified: trunk/18xx/rails/ui/swing/UpgradesPanel.java =================================================================== --- trunk/18xx/rails/ui/swing/UpgradesPanel.java 2011-02-01 17:27:05 UTC (rev 1478) +++ trunk/18xx/rails/ui/swing/UpgradesPanel.java 2011-02-03 23:22:49 UTC (rev 1479) @@ -6,6 +6,7 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; +import java.util.Set; import javax.swing.*; import javax.swing.border.Border; @@ -81,13 +82,14 @@ add(scrollPane); } - public void populate() { + public void populate(PhaseI currentPhase) { if (hexMap == null) hexMap = orUIManager.getMapPanel().getMap(); GUIHex uiHex = hexMap.getSelectedHex(); MapHex hex = uiHex.getHexModel(); orUIManager.tileUpgrades = new ArrayList<TileI>(); List<TileI> tiles; + Set<String> allowedColours = currentPhase.getTileColours().keySet(); for (LayTile layTile : hexMap.getTileAllowancesForHex(hex)) { tiles = layTile.getTiles(); @@ -95,21 +97,16 @@ for (TileI tile : uiHex.getCurrentTile().getValidUpgrades(hex, orUIManager.gameUIManager.getCurrentPhase())) { // Skip if not allowed in LayTile - if (!layTile.isTileColourAllowed(tile.getColourName())) continue; - + //if (!layTile.isTileColourAllowed(tile.getColourName())) continue; + if (!orUIManager.tileUpgrades.contains(tile)) orUIManager.tileUpgrades.add(tile); } } else { for (TileI tile : tiles) { - // Skip if not allowed in LayTile - if (layTile.getTileColours().get(tile.getColourName()) < 1) continue; + // Skip if colour is not allowed yet + if (!allowedColours.contains(tile.getColourName())) continue; - // special check: does the tile increase the colour number? - // this avoids that a special tile lay down or equalgrades existing tiles - // TODO EV: I'm not sure if this is a necessary precaution. - if (!layTile.isTileColourAllowed(tile.getColourName())) continue; - if (!orUIManager.tileUpgrades.contains(tile)) orUIManager.tileUpgrades.add(tile); } @@ -327,6 +324,7 @@ } } + // NOTE: NOT USED private void setSelectedCorrectionToken() { if (correctionTokenLabels == null || correctionTokenLabels.isEmpty()) return; int index = -1; @@ -475,7 +473,8 @@ super(tokenIcon); this.token = token; } - + + // NOTE: NOT USED TokenI getToken() { return token; } Modified: trunk/18xx/rails/ui/swing/hexmap/GUIHex.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUIHex.java 2011-02-01 17:27:05 UTC (rev 1478) +++ trunk/18xx/rails/ui/swing/hexmap/GUIHex.java 2011-02-03 23:22:49 UTC (rev 1479) @@ -871,5 +871,9 @@ hexMap.repaint(getBounds()); } } + + public String toString () { + return getName() + " (" + currentTile.getName() + ")"; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wak...@us...> - 2011-02-01 17:27:13
|
Revision: 1478 http://rails.svn.sourceforge.net/rails/?rev=1478&view=rev Author: wakko666 Date: 2011-02-01 17:27:05 +0000 (Tue, 01 Feb 2011) Log Message: ----------- Tag v1.4.1 Added Paths: ----------- tags/rails_1_4_1/ tags/rails_1_4_1/18xx/build.xml tags/rails_1_4_1/18xx/rails/game/Game.java tags/rails_1_4_1/18xx/rails.bat tags/rails_1_4_1/18xx/rails.sh Removed Paths: ------------- tags/rails_1_4_1/18xx/build.xml tags/rails_1_4_1/18xx/rails/game/Game.java tags/rails_1_4_1/18xx/rails.bat tags/rails_1_4_1/18xx/rails.sh Deleted: tags/rails_1_4_1/18xx/build.xml =================================================================== --- trunk/18xx/build.xml 2011-01-29 16:48:22 UTC (rev 1476) +++ tags/rails_1_4_1/18xx/build.xml 2011-02-01 17:27:05 UTC (rev 1478) @@ -1,160 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- WARNING: Eclipse auto-generated file. - Any modifications will be overwritten. - To include a user specific buildfile here, simply create one in the same - directory with the processing instruction <?eclipse.ant.import?> - as the first entry and export the buildfile again. --> -<project basedir="." default="build" name="18xx"> - <property environment="env"/> - <property name="debuglevel" value="source,lines,vars"/> - <property name="target" value="1.5"/> - <property name="source" value="1.5"/> - <property name="version" value="1.4"/> - <taskdef name="jarbundler" - classpath="tools/lib/jarbundler-2.1.0.jar" - classname="net.sourceforge.jarbundler.JarBundler" /> - <path id="18xx.classpath"> - <pathelement location="classes"/> - <pathelement location="lib/log4j-1.2/log4j-1.2.14.jar"/> - <pathelement location="lib/batik-1.6/batik-rasterizer.jar"/> - <pathelement location="lib/batik-1.6/batik.jar"/> - <pathelement location="lib/jgraph5/jgraph.jar"/> - <pathelement location="lib/jgrapht-0.7.3/jgrapht-jdk1.5.jar"/> - <pathelement location="lib/junit_3.8.2/junit.jar"/> - </path> - <target depends="clean" name="init"> - <mkdir dir="classes"/> - <copy includeemptydirs="false" todir="classes"> - <fileset dir="."> - <exclude name="**/*.launch"/> - <exclude name="**/*.java"/> - <exclude name="tools/**"/> - <exclude name="images/**"/> - </fileset> - </copy> - </target> - <target name="clean"> - <delete dir="classes"/> - <delete dir="jar"/> - </target> - <target depends="clean" name="cleanall"> - <delete dir="rails-${version}"/> - <delete dir="rails-mac-${version}"/> - <delete file="18xx.log"/> - </target> - <target depends="build-subprojects,build-project,build-release" name="build"/> - <target name="build-subprojects"/> - <target depends="init" name="build-project"> - <echo message="${ant.project.name}: ${ant.file}"/> - <javac debug="true" debuglevel="${debuglevel}" destdir="classes" source="${source}" target="${target}"> - <src path="."/> - <classpath refid="18xx.classpath"/> - </javac> - </target> - <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/> - <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler"> - <copy todir="${ant.library.dir}"> - <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> - </copy> - <unzip dest="${ant.library.dir}"> - <patternset includes="jdtCompilerAdapter.jar"/> - <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> - </unzip> - </target> - <target description="compile project with Eclipse compiler" name="build-eclipse-compiler"> - <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> - <antcall target="build"/> - </target> - <target name="build-release"> - <mkdir dir="jar"/> - <copy includeemptydirs="false" todir="jar"> - <fileset dir="classes"> - <exclude name="**/*.launch"/> - <exclude name="**/*.java"/> - <exclude name="rails/test/*"/> - <exclude name="18xx.log"/> - <exclude name="build.xml"/> - <exclude name="buildinfo.xml"/> - <exclude name="manifest"/> - <exclude name="doc/*"/> - <exclude name="html/*"/> - <exclude name="lib/**"/> - <exclude name="rails-${version}/**"/> - <exclude name="rails-*-${version}/**"/> - <exclude name="rails.bat"/> - <exclude name="rails.sh"/> - <exclude name=".project"/> - <exclude name=".classpath"/> - <exclude name="**/CVS/*"/> - <exclude name="**/.settings/*"/> - <exclude name="**/rails-${version}.jar"/> - </fileset> - </copy> - <mkdir dir="rails-${version}"/> - <copy includeemptydirs="false" todir="rails-${version}"> - <fileset dir="."> - <include name="LICENSE"/> - <include name="README"/> - <include name="AUTHORS"/> - <include name="rails.bat"/> - <include name="rails.sh"/> - <include name="my.properties"/> - <include name="LocalisedText.properties"/> - <include name="games.properties"/> - <include name="lib/**"/> - </fileset> - </copy> - <jar destfile="rails-${version}/rails-${version}.jar" basedir="jar" duplicate="preserve"> - <manifest> - <attribute name="Main-Class" value="rails.util.RunGame" /> - <attribute name="Class-Path" value="./my.properties ./LocalisedText.properties ./lib/log4j-1.2/log4j-1.2.14.jar ./lib/batik-1.6/lib/batik-transcoder.jar ./lib/batik-1.6/batik.jar ./lib/batik-1.6/lib/batik-util.jar ./lib/batik-1.6/lib/batik-script.jar ./lib/batik-1.6/lib/batik-bridge.jar ./lib/batik-1.6/lib/batik-ext.jar ./lib/batik-1.6/lib/batik-awt-util.jar ./lib/batik-1.6/lib/batik-dom.jar ./lib/batik-1.6/lib/batik-gvt.jar ./lib/jgraph5/jgraph.jar ./lib/jgrapht-0.7.3/jgrapht-jdk1.5.jar" /> - </manifest> - </jar> - </target> - <target name="build-mac"> - <mkdir dir="rails-mac-${version}" /> - <copy includeemptydirs="false" todir="rails-mac-${version}"> - <fileset dir="."> - <include name="LICENSE"/> - <include name="README"/> - <include name="AUTHORS"/> - <include name="my.properties"/> - </fileset> - </copy> - <jarbundler dir="rails-mac-${version}" - name="Rails" - mainclass="rails.util.RunGame" - icon="images/icon/rails.icns" - version="${version}"> - <jarfileset dir="rails-${version}"> - <include name="rails-${version}.jar"/> - <include name="lib/**"/> - </jarfileset> - <javaproperty name="apple.laf.useScreenMenuBar" value="true"/> - </jarbundler> - </target> - <target name="RunGame"> - <java classname="rails.util.RunGame" failonerror="true" fork="yes"> - <classpath refid="18xx.classpath"/> - </java> - </target> - <target name="TestGames"> - <property name="test.xml.dir" value="test/xml"/> - <property name="test.report.dir" value="test/report"/> - <mkdir dir="${test.xml.dir}"/> - <mkdir dir="${test.report.dir}"/> - <junit> - <classpath refid="18xx.classpath"/> - <formatter type="brief" usefile="false" /> - <formatter type="xml" /> - <test name ="test.TestGameBuilder" todir="${test.xml.dir}"/> - </junit> - <junitreport todir="${test.xml.dir}"> - <fileset dir="${test.xml.dir}"> - <include name="TEST-*.xml"/> - </fileset> - <report format="noframes" todir="${test.report.dir}"/> - </junitreport> - </target> - -</project> Copied: tags/rails_1_4_1/18xx/build.xml (from rev 1477, trunk/18xx/build.xml) =================================================================== --- tags/rails_1_4_1/18xx/build.xml (rev 0) +++ tags/rails_1_4_1/18xx/build.xml 2011-02-01 17:27:05 UTC (rev 1478) @@ -0,0 +1,160 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- WARNING: Eclipse auto-generated file. + Any modifications will be overwritten. + To include a user specific buildfile here, simply create one in the same + directory with the processing instruction <?eclipse.ant.import?> + as the first entry and export the buildfile again. --> +<project basedir="." default="build" name="18xx"> + <property environment="env"/> + <property name="debuglevel" value="source,lines,vars"/> + <property name="target" value="1.5"/> + <property name="source" value="1.5"/> + <property name="version" value="1.4.1"/> + <taskdef name="jarbundler" + classpath="tools/lib/jarbundler-2.1.0.jar" + classname="net.sourceforge.jarbundler.JarBundler" /> + <path id="18xx.classpath"> + <pathelement location="classes"/> + <pathelement location="lib/log4j-1.2/log4j-1.2.14.jar"/> + <pathelement location="lib/batik-1.6/batik-rasterizer.jar"/> + <pathelement location="lib/batik-1.6/batik.jar"/> + <pathelement location="lib/jgraph5/jgraph.jar"/> + <pathelement location="lib/jgrapht-0.7.3/jgrapht-jdk1.5.jar"/> + <pathelement location="lib/junit_3.8.2/junit.jar"/> + </path> + <target depends="clean" name="init"> + <mkdir dir="classes"/> + <copy includeemptydirs="false" todir="classes"> + <fileset dir="."> + <exclude name="**/*.launch"/> + <exclude name="**/*.java"/> + <exclude name="tools/**"/> + <exclude name="images/**"/> + </fileset> + </copy> + </target> + <target name="clean"> + <delete dir="classes"/> + <delete dir="jar"/> + </target> + <target depends="clean" name="cleanall"> + <delete dir="rails-${version}"/> + <delete dir="rails-mac-${version}"/> + <delete file="18xx.log"/> + </target> + <target depends="build-subprojects,build-project,build-release" name="build"/> + <target name="build-subprojects"/> + <target depends="init" name="build-project"> + <echo message="${ant.project.name}: ${ant.file}"/> + <javac debug="true" debuglevel="${debuglevel}" destdir="classes" source="${source}" target="${target}"> + <src path="."/> + <classpath refid="18xx.classpath"/> + </javac> + </target> + <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/> + <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler"> + <copy todir="${ant.library.dir}"> + <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> + </copy> + <unzip dest="${ant.library.dir}"> + <patternset includes="jdtCompilerAdapter.jar"/> + <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> + </unzip> + </target> + <target description="compile project with Eclipse compiler" name="build-eclipse-compiler"> + <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> + <antcall target="build"/> + </target> + <target name="build-release"> + <mkdir dir="jar"/> + <copy includeemptydirs="false" todir="jar"> + <fileset dir="classes"> + <exclude name="**/*.launch"/> + <exclude name="**/*.java"/> + <exclude name="rails/test/*"/> + <exclude name="18xx.log"/> + <exclude name="build.xml"/> + <exclude name="buildinfo.xml"/> + <exclude name="manifest"/> + <exclude name="doc/*"/> + <exclude name="html/*"/> + <exclude name="lib/**"/> + <exclude name="rails-${version}/**"/> + <exclude name="rails-*-${version}/**"/> + <exclude name="rails.bat"/> + <exclude name="rails.sh"/> + <exclude name=".project"/> + <exclude name=".classpath"/> + <exclude name="**/CVS/*"/> + <exclude name="**/.settings/*"/> + <exclude name="**/rails-${version}.jar"/> + </fileset> + </copy> + <mkdir dir="rails-${version}"/> + <copy includeemptydirs="false" todir="rails-${version}"> + <fileset dir="."> + <include name="LICENSE"/> + <include name="README"/> + <include name="AUTHORS"/> + <include name="rails.bat"/> + <include name="rails.sh"/> + <include name="my.properties"/> + <include name="LocalisedText.properties"/> + <include name="games.properties"/> + <include name="lib/**"/> + </fileset> + </copy> + <jar destfile="rails-${version}/rails-${version}.jar" basedir="jar" duplicate="preserve"> + <manifest> + <attribute name="Main-Class" value="rails.util.RunGame" /> + <attribute name="Class-Path" value="./my.properties ./LocalisedText.properties ./lib/log4j-1.2/log4j-1.2.14.jar ./lib/batik-1.6/lib/batik-transcoder.jar ./lib/batik-1.6/batik.jar ./lib/batik-1.6/lib/batik-util.jar ./lib/batik-1.6/lib/batik-script.jar ./lib/batik-1.6/lib/batik-bridge.jar ./lib/batik-1.6/lib/batik-ext.jar ./lib/batik-1.6/lib/batik-awt-util.jar ./lib/batik-1.6/lib/batik-dom.jar ./lib/batik-1.6/lib/batik-gvt.jar ./lib/jgraph5/jgraph.jar ./lib/jgrapht-0.7.3/jgrapht-jdk1.5.jar" /> + </manifest> + </jar> + </target> + <target name="build-mac"> + <mkdir dir="rails-mac-${version}" /> + <copy includeemptydirs="false" todir="rails-mac-${version}"> + <fileset dir="."> + <include name="LICENSE"/> + <include name="README"/> + <include name="AUTHORS"/> + <include name="my.properties"/> + </fileset> + </copy> + <jarbundler dir="rails-mac-${version}" + name="Rails" + mainclass="rails.util.RunGame" + icon="images/icon/rails.icns" + version="${version}"> + <jarfileset dir="rails-${version}"> + <include name="rails-${version}.jar"/> + <include name="lib/**"/> + </jarfileset> + <javaproperty name="apple.laf.useScreenMenuBar" value="true"/> + </jarbundler> + </target> + <target name="RunGame"> + <java classname="rails.util.RunGame" failonerror="true" fork="yes"> + <classpath refid="18xx.classpath"/> + </java> + </target> + <target name="TestGames"> + <property name="test.xml.dir" value="test/xml"/> + <property name="test.report.dir" value="test/report"/> + <mkdir dir="${test.xml.dir}"/> + <mkdir dir="${test.report.dir}"/> + <junit> + <classpath refid="18xx.classpath"/> + <formatter type="brief" usefile="false" /> + <formatter type="xml" /> + <test name ="test.TestGameBuilder" todir="${test.xml.dir}"/> + </junit> + <junitreport todir="${test.xml.dir}"> + <fileset dir="${test.xml.dir}"> + <include name="TEST-*.xml"/> + </fileset> + <report format="noframes" todir="${test.report.dir}"/> + </junitreport> + </target> + +</project> Deleted: tags/rails_1_4_1/18xx/rails/game/Game.java =================================================================== --- trunk/18xx/rails/game/Game.java 2011-01-29 16:48:22 UTC (rev 1476) +++ tags/rails_1_4_1/18xx/rails/game/Game.java 2011-02-01 17:27:05 UTC (rev 1478) @@ -1,342 +0,0 @@ -/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/Game.java,v 1.56 2010/06/06 13:01:00 evos Exp $ */ -package rails.game; - -import java.io.*; -import java.util.*; - -import org.apache.log4j.Logger; - -import rails.algorithms.RevenueManager; -import rails.game.action.PossibleAction; -import rails.game.special.SpecialProperty; -import rails.util.LocalText; -import rails.util.Tag; - -public class Game { - public static final String version = "1.4+"; - - /** The component Manager */ - protected ComponentManager componentManager; - protected GameManager gameManager; - protected CompanyManagerI companyManager; - protected PlayerManager playerManager; - protected PhaseManager phaseManager; - protected TrainManager trainManager; - protected StockMarketI stockMarket; - protected MapManager mapManager; - protected TileManager tileManager; - protected RevenueManager revenueManager; - protected Bank bank; - protected String name; - protected Tag componentManagerTag; - protected static String GAME_XML_FILE = "Game.xml"; - protected List<String> directories = new ArrayList<String>(); - protected Map<String, String> gameOptions; - - protected List<String> players; - - protected static Logger log = - Logger.getLogger(Game.class.getPackage().getName()); - - // The new Game entry point - public Game(String name, List<String> players, Map<String, String> options) { - - this.name = name; - this.gameOptions = options; - - gameOptions.put(GameOption.NUMBER_OF_PLAYERS, - String.valueOf(players.size())); - - for (String playerName : players) { - log.debug("Player: " + playerName); - } - for (String optionName : gameOptions.keySet()) { - log.debug("Option: " + optionName + "=" - + gameOptions.get(optionName)); - } - directories.add("data"); - directories.add("data/" + name); - - this.players = players; - } - - public String start() { - - if (players.size() < playerManager.minPlayers - || players.size() > playerManager.maxPlayers) { - return name+" is not configured to be played with "+players.size()+" players\n" - + "Please enter a valid number of players, or add a <Players> entry to data/"+name+"/Game.xml"; - } - - gameManager.startGame(gameOptions); - return null; - } - - public boolean setup() { - - try { - componentManagerTag = - Tag.findTopTagInFile(GAME_XML_FILE, directories, - ComponentManager.ELEMENT_ID); - if (componentManagerTag == null) { - throw new ConfigurationException( - "No Game XML element found in file " + GAME_XML_FILE); - } - - componentManagerTag.setGameOptions(gameOptions); - componentManager = - ComponentManager.configureInstance(name, componentManagerTag, gameOptions); - - log.info("========== Start of rails.game " + name + " =========="); - log.info("Rails version "+version); - ReportBuffer.add(LocalText.getText("GameIs", name)); - - // set special properties and token static variables - SpecialProperty.init(); - Token.init(); - - // Have the ComponentManager work through the other rails.game files - componentManager.finishPreparation(); - - playerManager = (PlayerManager) componentManager.findComponent("PlayerManager"); - if (playerManager == null) { - throw new ConfigurationException( - "No PlayerManager XML element found in file " + GAME_XML_FILE); - } - - bank = (Bank) componentManager.findComponent("Bank"); - if (bank == null) { - throw new ConfigurationException( - "No Bank XML element found in file " + GAME_XML_FILE); - } - - companyManager = - (CompanyManagerI) componentManager.findComponent(CompanyManagerI.COMPONENT_NAME); - if (companyManager == null) { - throw new ConfigurationException( - "No CompanyManager XML element found in file " - + GAME_XML_FILE); - } - stockMarket = - (StockMarketI) componentManager.findComponent(StockMarketI.COMPONENT_NAME); - if (stockMarket == null) { - throw new ConfigurationException( - "No StockMarket XML element found in file " - + GAME_XML_FILE); - } - gameManager = - (GameManager) componentManager.findComponent("GameManager"); - if (gameManager == null) { - throw new ConfigurationException( - "No GameManager XML element found in file " - + GAME_XML_FILE); - } - - phaseManager = - (PhaseManager) componentManager.findComponent("PhaseManager"); - if (phaseManager == null) { - throw new ConfigurationException( - "No PhaseManager XML element found in file " - + GAME_XML_FILE); - } - - trainManager = - (TrainManager) componentManager.findComponent("TrainManager"); - if (trainManager == null) { - throw new ConfigurationException( - "No TrainManager XML element found in file " - + GAME_XML_FILE); - } - - mapManager = - (MapManager) componentManager.findComponent("Map"); - if (mapManager == null) { - throw new ConfigurationException( - "No Map XML element found in file " - + GAME_XML_FILE); - } - - tileManager = - (TileManager) componentManager.findComponent("TileManager"); - if (tileManager == null) { - throw new ConfigurationException( - "No TileManager XML element found in file " - + GAME_XML_FILE); - } - - revenueManager = - (RevenueManager) componentManager.findComponent("RevenueManager"); - // revenueManager is optional so far -// if (revenueManager == null) { -// throw new ConfigurationException( -// "No RevenueManager XML element found in file " -// + GAME_XML_FILE); -// } - - /* - * Initialisations that involve relations between components can - * only be done after all XML has been processed. - */ - playerManager.setPlayers(players, bank); - gameManager.init(name, playerManager, companyManager, - phaseManager, trainManager, stockMarket, mapManager, - tileManager, revenueManager, bank); - - companyManager.finishConfiguration(gameManager); - trainManager.finishConfiguration(gameManager); - phaseManager.finishConfiguration(gameManager); - mapManager.finishConfiguration(gameManager); - bank.finishConfiguration(gameManager); - stockMarket.finishConfiguration(gameManager); - tileManager.finishConfiguration(gameManager); - if (revenueManager != null) - revenueManager.finishConfiguration(gameManager); - } catch (Exception e) { - String message = - LocalText.getText("GameSetupFailed", GAME_XML_FILE); - log.fatal(message, e); - System.out.println(e.getMessage()); - e.printStackTrace(); - DisplayBuffer.add(message + ":\n " + e.getMessage()); - return false; - } - - return true; - } - - @SuppressWarnings("unchecked") - public static Game load(String filepath) { - - Game game = null; - - log.debug("Loading game from file " + filepath); - String filename = filepath.replaceAll(".*[/\\\\]", ""); - - try { - ObjectInputStream ois = - new ObjectInputStream(new FileInputStream( - new File(filepath))); - - // New in 1.0.7: Rails version & save date/time. - // Allow for older saved file versions. - Object object = ois.readObject(); - if (object instanceof String) { - log.info("Reading Rails "+(String)object+" saved file "+filename); - object = ois.readObject(); - } else { - log.info("Reading Rails (pre-1.0.7) saved file "+filename); - } - if (object instanceof String) { - log.info("File was saved at "+(String)object); - object = ois.readObject(); - } - - long versionID = (Long) object; - log.debug("Saved versionID="+versionID+" (object="+object+")"); - long saveFileVersionID = GameManager.saveFileVersionID; - if (versionID != saveFileVersionID) { - throw new Exception("Save version " + versionID - + " is incompatible with current version " - + saveFileVersionID); - } - String name = (String) ois.readObject(); - log.debug("Saved game="+name); - Map<String, String> selectedGameOptions = - (Map<String, String>) ois.readObject(); - List<String> playerNames = (List<String>) ois.readObject(); - - game = new Game(name, playerNames, selectedGameOptions); - - if (!game.setup()) { - throw new ConfigurationException("Error in setting up " + name); - } - - String startError = game.start(); - if (startError != null) { - DisplayBuffer.add(startError); - return null; - } - GameManagerI gameManager = game.getGameManager(); - int numberOfActions = 0; - - log.debug("Starting to execute loaded actions"); - - gameManager.setReloading(true); - - Object actionObject = null; - while (true) { // Single-pass loop. - try { - actionObject = ois.readObject(); - } catch (EOFException e) { - // Allow saved file at start of game (with no actions). - break; - } - if (actionObject instanceof List) { - // Old-style: one List of PossibleActions - List<PossibleAction> executedActions = - (List<PossibleAction>) actionObject; - numberOfActions = executedActions.size(); - for (PossibleAction action : executedActions) { - if (!gameManager.processOnReload(action)) { - log.error ("Load interrupted"); - DisplayBuffer.add(LocalText.getText("LoadInterrupted")); - break; - } - } - } else if (actionObject instanceof PossibleAction) { - // New style: separate PossibleActionsObjects, since Rails 1.3.1 - while (actionObject instanceof PossibleAction) { - numberOfActions++; - if (!gameManager.processOnReload((PossibleAction)actionObject)) { - log.error ("Load interrupted"); - DisplayBuffer.add(LocalText.getText("LoadInterrupted")); - break; - } - try { - actionObject = ois.readObject(); - } catch (EOFException e) { - break; - } - } - } - break; - } - - // load user comments (is the last - if (actionObject instanceof SortedMap) { - ReportBuffer.setCommentItems((SortedMap<Integer, String>) actionObject); - log.debug("Found sorted map"); - } else { - try { - object = ois.readObject(); - if (object instanceof SortedMap) { - ReportBuffer.setCommentItems((SortedMap<Integer, String>) object); - } - } catch (IOException e) { - // continue without comments, if any IOException occurs - // sometimes not only the EOF Exception is raised - // but also the java.io.StreamCorruptedException: invalid type code - } - } - - ois.close(); - - gameManager.setReloading(false); - gameManager.finishLoading(); - return game; - - } catch (Exception e) { - log.error("Load failed", e); - DisplayBuffer.add(LocalText.getText("LoadFailed", e.getMessage())); - } - - return null; - } - - /*----- Getters -----*/ - - public GameManagerI getGameManager() { - return gameManager; - } - -} Copied: tags/rails_1_4_1/18xx/rails/game/Game.java (from rev 1477, trunk/18xx/rails/game/Game.java) =================================================================== --- tags/rails_1_4_1/18xx/rails/game/Game.java (rev 0) +++ tags/rails_1_4_1/18xx/rails/game/Game.java 2011-02-01 17:27:05 UTC (rev 1478) @@ -0,0 +1,342 @@ +/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/Game.java,v 1.56 2010/06/06 13:01:00 evos Exp $ */ +package rails.game; + +import java.io.*; +import java.util.*; + +import org.apache.log4j.Logger; + +import rails.algorithms.RevenueManager; +import rails.game.action.PossibleAction; +import rails.game.special.SpecialProperty; +import rails.util.LocalText; +import rails.util.Tag; + +public class Game { + public static final String version = "1.4.1"; + + /** The component Manager */ + protected ComponentManager componentManager; + protected GameManager gameManager; + protected CompanyManagerI companyManager; + protected PlayerManager playerManager; + protected PhaseManager phaseManager; + protected TrainManager trainManager; + protected StockMarketI stockMarket; + protected MapManager mapManager; + protected TileManager tileManager; + protected RevenueManager revenueManager; + protected Bank bank; + protected String name; + protected Tag componentManagerTag; + protected static String GAME_XML_FILE = "Game.xml"; + protected List<String> directories = new ArrayList<String>(); + protected Map<String, String> gameOptions; + + protected List<String> players; + + protected static Logger log = + Logger.getLogger(Game.class.getPackage().getName()); + + // The new Game entry point + public Game(String name, List<String> players, Map<String, String> options) { + + this.name = name; + this.gameOptions = options; + + gameOptions.put(GameOption.NUMBER_OF_PLAYERS, + String.valueOf(players.size())); + + for (String playerName : players) { + log.debug("Player: " + playerName); + } + for (String optionName : gameOptions.keySet()) { + log.debug("Option: " + optionName + "=" + + gameOptions.get(optionName)); + } + directories.add("data"); + directories.add("data/" + name); + + this.players = players; + } + + public String start() { + + if (players.size() < playerManager.minPlayers + || players.size() > playerManager.maxPlayers) { + return name+" is not configured to be played with "+players.size()+" players\n" + + "Please enter a valid number of players, or add a <Players> entry to data/"+name+"/Game.xml"; + } + + gameManager.startGame(gameOptions); + return null; + } + + public boolean setup() { + + try { + componentManagerTag = + Tag.findTopTagInFile(GAME_XML_FILE, directories, + ComponentManager.ELEMENT_ID); + if (componentManagerTag == null) { + throw new ConfigurationException( + "No Game XML element found in file " + GAME_XML_FILE); + } + + componentManagerTag.setGameOptions(gameOptions); + componentManager = + ComponentManager.configureInstance(name, componentManagerTag, gameOptions); + + log.info("========== Start of rails.game " + name + " =========="); + log.info("Rails version "+version); + ReportBuffer.add(LocalText.getText("GameIs", name)); + + // set special properties and token static variables + SpecialProperty.init(); + Token.init(); + + // Have the ComponentManager work through the other rails.game files + componentManager.finishPreparation(); + + playerManager = (PlayerManager) componentManager.findComponent("PlayerManager"); + if (playerManager == null) { + throw new ConfigurationException( + "No PlayerManager XML element found in file " + GAME_XML_FILE); + } + + bank = (Bank) componentManager.findComponent("Bank"); + if (bank == null) { + throw new ConfigurationException( + "No Bank XML element found in file " + GAME_XML_FILE); + } + + companyManager = + (CompanyManagerI) componentManager.findComponent(CompanyManagerI.COMPONENT_NAME); + if (companyManager == null) { + throw new ConfigurationException( + "No CompanyManager XML element found in file " + + GAME_XML_FILE); + } + stockMarket = + (StockMarketI) componentManager.findComponent(StockMarketI.COMPONENT_NAME); + if (stockMarket == null) { + throw new ConfigurationException( + "No StockMarket XML element found in file " + + GAME_XML_FILE); + } + gameManager = + (GameManager) componentManager.findComponent("GameManager"); + if (gameManager == null) { + throw new ConfigurationException( + "No GameManager XML element found in file " + + GAME_XML_FILE); + } + + phaseManager = + (PhaseManager) componentManager.findComponent("PhaseManager"); + if (phaseManager == null) { + throw new ConfigurationException( + "No PhaseManager XML element found in file " + + GAME_XML_FILE); + } + + trainManager = + (TrainManager) componentManager.findComponent("TrainManager"); + if (trainManager == null) { + throw new ConfigurationException( + "No TrainManager XML element found in file " + + GAME_XML_FILE); + } + + mapManager = + (MapManager) componentManager.findComponent("Map"); + if (mapManager == null) { + throw new ConfigurationException( + "No Map XML element found in file " + + GAME_XML_FILE); + } + + tileManager = + (TileManager) componentManager.findComponent("TileManager"); + if (tileManager == null) { + throw new ConfigurationException( + "No TileManager XML element found in file " + + GAME_XML_FILE); + } + + revenueManager = + (RevenueManager) componentManager.findComponent("RevenueManager"); + // revenueManager is optional so far +// if (revenueManager == null) { +// throw new ConfigurationException( +// "No RevenueManager XML element found in file " +// + GAME_XML_FILE); +// } + + /* + * Initialisations that involve relations between components can + * only be done after all XML has been processed. + */ + playerManager.setPlayers(players, bank); + gameManager.init(name, playerManager, companyManager, + phaseManager, trainManager, stockMarket, mapManager, + tileManager, revenueManager, bank); + + companyManager.finishConfiguration(gameManager); + trainManager.finishConfiguration(gameManager); + phaseManager.finishConfiguration(gameManager); + mapManager.finishConfiguration(gameManager); + bank.finishConfiguration(gameManager); + stockMarket.finishConfiguration(gameManager); + tileManager.finishConfiguration(gameManager); + if (revenueManager != null) + revenueManager.finishConfiguration(gameManager); + } catch (Exception e) { + String message = + LocalText.getText("GameSetupFailed", GAME_XML_FILE); + log.fatal(message, e); + System.out.println(e.getMessage()); + e.printStackTrace(); + DisplayBuffer.add(message + ":\n " + e.getMessage()); + return false; + } + + return true; + } + + @SuppressWarnings("unchecked") + public static Game load(String filepath) { + + Game game = null; + + log.debug("Loading game from file " + filepath); + String filename = filepath.replaceAll(".*[/\\\\]", ""); + + try { + ObjectInputStream ois = + new ObjectInputStream(new FileInputStream( + new File(filepath))); + + // New in 1.0.7: Rails version & save date/time. + // Allow for older saved file versions. + Object object = ois.readObject(); + if (object instanceof String) { + log.info("Reading Rails "+(String)object+" saved file "+filename); + object = ois.readObject(); + } else { + log.info("Reading Rails (pre-1.0.7) saved file "+filename); + } + if (object instanceof String) { + log.info("File was saved at "+(String)object); + object = ois.readObject(); + } + + long versionID = (Long) object; + log.debug("Saved versionID="+versionID+" (object="+object+")"); + long saveFileVersionID = GameManager.saveFileVersionID; + if (versionID != saveFileVersionID) { + throw new Exception("Save version " + versionID + + " is incompatible with current version " + + saveFileVersionID); + } + String name = (String) ois.readObject(); + log.debug("Saved game="+name); + Map<String, String> selectedGameOptions = + (Map<String, String>) ois.readObject(); + List<String> playerNames = (List<String>) ois.readObject(); + + game = new Game(name, playerNames, selectedGameOptions); + + if (!game.setup()) { + throw new ConfigurationException("Error in setting up " + name); + } + + String startError = game.start(); + if (startError != null) { + DisplayBuffer.add(startError); + return null; + } + GameManagerI gameManager = game.getGameManager(); + int numberOfActions = 0; + + log.debug("Starting to execute loaded actions"); + + gameManager.setReloading(true); + + Object actionObject = null; + while (true) { // Single-pass loop. + try { + actionObject = ois.readObject(); + } catch (EOFException e) { + // Allow saved file at start of game (with no actions). + break; + } + if (actionObject instanceof List) { + // Old-style: one List of PossibleActions + List<PossibleAction> executedActions = + (List<PossibleAction>) actionObject; + numberOfActions = executedActions.size(); + for (PossibleAction action : executedActions) { + if (!gameManager.processOnReload(action)) { + log.error ("Load interrupted"); + DisplayBuffer.add(LocalText.getText("LoadInterrupted")); + break; + } + } + } else if (actionObject instanceof PossibleAction) { + // New style: separate PossibleActionsObjects, since Rails 1.3.1 + while (actionObject instanceof PossibleAction) { + numberOfActions++; + if (!gameManager.processOnReload((PossibleAction)actionObject)) { + log.error ("Load interrupted"); + DisplayBuffer.add(LocalText.getText("LoadInterrupted")); + break; + } + try { + actionObject = ois.readObject(); + } catch (EOFException e) { + break; + } + } + } + break; + } + + // load user comments (is the last + if (actionObject instanceof SortedMap) { + ReportBuffer.setCommentItems((SortedMap<Integer, String>) actionObject); + log.debug("Found sorted map"); + } else { + try { + object = ois.readObject(); + if (object instanceof SortedMap) { + ReportBuffer.setCommentItems((SortedMap<Integer, String>) object); + } + } catch (IOException e) { + // continue without comments, if any IOException occurs + // sometimes not only the EOF Exception is raised + // but also the java.io.StreamCorruptedException: invalid type code + } + } + + ois.close(); + + gameManager.setReloading(false); + gameManager.finishLoading(); + return game; + + } catch (Exception e) { + log.error("Load failed", e); + DisplayBuffer.add(LocalText.getText("LoadFailed", e.getMessage())); + } + + return null; + } + + /*----- Getters -----*/ + + public GameManagerI getGameManager() { + return gameManager; + } + +} Deleted: tags/rails_1_4_1/18xx/rails.bat =================================================================== (Binary files differ) Copied: tags/rails_1_4_1/18xx/rails.bat (from rev 1477, trunk/18xx/rails.bat) =================================================================== (Binary files differ) Deleted: tags/rails_1_4_1/18xx/rails.sh =================================================================== --- trunk/18xx/rails.sh 2011-01-29 16:48:22 UTC (rev 1476) +++ tags/rails_1_4_1/18xx/rails.sh 2011-02-01 17:27:05 UTC (rev 1478) @@ -1,3 +0,0 @@ -#!/bin/bash - -java -jar ./rails-1.4.jar $1 \ No newline at end of file Copied: tags/rails_1_4_1/18xx/rails.sh (from rev 1477, trunk/18xx/rails.sh) =================================================================== --- tags/rails_1_4_1/18xx/rails.sh (rev 0) +++ tags/rails_1_4_1/18xx/rails.sh 2011-02-01 17:27:05 UTC (rev 1478) @@ -0,0 +1,3 @@ +#!/bin/bash + +java -jar ./rails-1.4.1.jar $1 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wak...@us...> - 2011-02-01 17:25:18
|
Revision: 1477 http://rails.svn.sourceforge.net/rails/?rev=1477&view=rev Author: wakko666 Date: 2011-02-01 17:25:11 +0000 (Tue, 01 Feb 2011) Log Message: ----------- Bump version numbers to 1.4.1 Modified Paths: -------------- trunk/18xx/build.xml trunk/18xx/rails/game/Game.java trunk/18xx/rails.bat trunk/18xx/rails.sh Modified: trunk/18xx/build.xml =================================================================== --- trunk/18xx/build.xml 2011-01-29 16:48:22 UTC (rev 1476) +++ trunk/18xx/build.xml 2011-02-01 17:25:11 UTC (rev 1477) @@ -9,7 +9,7 @@ <property name="debuglevel" value="source,lines,vars"/> <property name="target" value="1.5"/> <property name="source" value="1.5"/> - <property name="version" value="1.4"/> + <property name="version" value="1.4.1"/> <taskdef name="jarbundler" classpath="tools/lib/jarbundler-2.1.0.jar" classname="net.sourceforge.jarbundler.JarBundler" /> Modified: trunk/18xx/rails/game/Game.java =================================================================== --- trunk/18xx/rails/game/Game.java 2011-01-29 16:48:22 UTC (rev 1476) +++ trunk/18xx/rails/game/Game.java 2011-02-01 17:25:11 UTC (rev 1477) @@ -13,7 +13,7 @@ import rails.util.Tag; public class Game { - public static final String version = "1.4+"; + public static final String version = "1.4.1"; /** The component Manager */ protected ComponentManager componentManager; Modified: trunk/18xx/rails.bat =================================================================== (Binary files differ) Modified: trunk/18xx/rails.sh =================================================================== --- trunk/18xx/rails.sh 2011-01-29 16:48:22 UTC (rev 1476) +++ trunk/18xx/rails.sh 2011-02-01 17:25:11 UTC (rev 1477) @@ -1,3 +1,3 @@ #!/bin/bash -java -jar ./rails-1.4.jar $1 \ No newline at end of file +java -jar ./rails-1.4.1.jar $1 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-01-29 16:48:28
|
Revision: 1476 http://rails.svn.sourceforge.net/rails/?rev=1476&view=rev Author: evos Date: 2011-01-29 16:48:22 +0000 (Sat, 29 Jan 2011) Log Message: ----------- Allow game option names with localised parameters. Applies to 18Kaas to display "Version of Map" Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/18Kaas/Game.xml trunk/18xx/data/GamesList.xml trunk/18xx/rails/game/GameOption.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2011-01-28 19:49:39 UTC (rev 1475) +++ trunk/18xx/LocalisedText.properties 2011-01-29 16:48:22 UTC (rev 1476) @@ -644,6 +644,7 @@ Variant=Variant VariantIs=Variant is {0}. Version=Version +VersionOf=version of {0} WantToReplaceToken=Do you want to replace the {0} home token with one of {1}? WarningNeedCash=Warning: {0} will be deducted from the company revenue or from your personal cash WHICH_PRICE=Which price? Modified: trunk/18xx/data/18Kaas/Game.xml =================================================================== --- trunk/18xx/data/18Kaas/Game.xml 2011-01-28 19:49:39 UTC (rev 1475) +++ trunk/18xx/data/18Kaas/Game.xml 2011-01-29 16:48:22 UTC (rev 1476) @@ -2,7 +2,7 @@ <ComponentManager> <Component name="GameManager" class="rails.game.GameManager"> <Game name="18Kaas"/> - <GameOption name="Version" values="v1,v2" default="v2" /> + <GameOption name="VersionOf" parm="{MAP}" values="v1,v2" default="v2" /> <GameOption name="RouteAwareness" values="Highlight,Deactivate" default="Deactivate" /> <GameOption name="RevenueCalculation" values="Suggest,Deactivate" default="Deactivate" /> <GameOption name="18KaasRuhrgebiedDoublesOnlyMajors" type="toggle" default="yes" /> Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2011-01-28 19:49:39 UTC (rev 1475) +++ trunk/18xx/data/GamesList.xml 2011-01-29 16:48:22 UTC (rev 1476) @@ -139,7 +139,8 @@ Should work, but has not been extensively tested. Limitations as with 1830. </Description> - <Option name="Version" values="v1,v2" default="v2" /> + <Option name="VersionOf" parm="{MAP}" values="v1,v2" default="v2" /> + <!-- Note: a parameter in braces {...} will be localised for display--> <Option name="RouteAwareness" values="Highlight,Deactivate" default="Highlight" /> <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> <Option name="18KaasRuhrgebiedDoublesOnlyMajors" type="toggle" default="yes" /> Modified: trunk/18xx/rails/game/GameOption.java =================================================================== --- trunk/18xx/rails/game/GameOption.java 2011-01-28 19:49:39 UTC (rev 1475) +++ trunk/18xx/rails/game/GameOption.java 2011-01-29 16:48:22 UTC (rev 1476) @@ -2,6 +2,8 @@ package rails.game; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import rails.util.LocalText; @@ -27,10 +29,14 @@ // Some other common game options public static final String VARIANT = "Variant"; + // A regex to match parameters against + private static final Pattern pattern = Pattern.compile("\\{(.*)\\}"); public GameOption(String name, String[] parameters) { this.name = name; - if (parameters != null) parm = parameters.clone(); + if (parameters != null) { + parm = parameters.clone(); + } parametrisedName = constructParametrisedName (name, parameters); optionsMap.put(parametrisedName, this); } @@ -50,7 +56,15 @@ } public String getLocalisedName() { - return LocalText.getText(name, (Object[]) parm); + String[] localisedParms = null; + if (parm != null) { + localisedParms = parm.clone(); + for (int i=0; i<parm.length; i++) { + Matcher m = pattern.matcher(parm[i]); + if (m.matches()) localisedParms[i] = LocalText.getText(m.group(1)); + } + } + return LocalText.getText(name, (Object[]) localisedParms); } public String getType() { @@ -61,12 +75,6 @@ return isBoolean; } - /* - public void setParameters(String[] parameters) { - parm = parameters.clone(); - } - */ - public void setAllowedValues(List<String> values) { allowedValues = values; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-01-28 19:49:46
|
Revision: 1475 http://rails.svn.sourceforge.net/rails/?rev=1475&view=rev Author: evos Date: 2011-01-28 19:49:39 +0000 (Fri, 28 Jan 2011) Log Message: ----------- Added "Version" option to 18Kaas with values "v1" (includes Gouda on map) and "v2" (no Gouda, default). Modified Paths: -------------- trunk/18xx/data/18Kaas/Game.xml trunk/18xx/data/18Kaas/Map.xml Modified: trunk/18xx/data/18Kaas/Game.xml =================================================================== --- trunk/18xx/data/18Kaas/Game.xml 2011-01-28 19:47:51 UTC (rev 1474) +++ trunk/18xx/data/18Kaas/Game.xml 2011-01-28 19:49:39 UTC (rev 1475) @@ -2,6 +2,7 @@ <ComponentManager> <Component name="GameManager" class="rails.game.GameManager"> <Game name="18Kaas"/> + <GameOption name="Version" values="v1,v2" default="v2" /> <GameOption name="RouteAwareness" values="Highlight,Deactivate" default="Deactivate" /> <GameOption name="RevenueCalculation" values="Suggest,Deactivate" default="Deactivate" /> <GameOption name="18KaasRuhrgebiedDoublesOnlyMajors" type="toggle" default="yes" /> Modified: trunk/18xx/data/18Kaas/Map.xml =================================================================== --- trunk/18xx/data/18Kaas/Map.xml 2011-01-28 19:47:51 UTC (rev 1474) +++ trunk/18xx/data/18Kaas/Map.xml 2011-01-28 19:49:39 UTC (rev 1475) @@ -48,11 +48,20 @@ <Hex name="H19" tile="0"/> <Hex name="I4" tile="-1" city="Hoek van Holland"/> <Hex name="I6" tile="0"/> - <Hex name="I8" tile="-10" city="Gouda"/> + <IfOption name="Version" value="v1"> + <Hex name="I8" tile="-10" city="Gouda"/> + </IfOption> + <IfOption name="Version" value="v2"> + <Hex name="I8" tile="0"/> + </IfOption> <Hex name="I10" tile="0"/> <Hex name="I12" tile="-10" cost="80" label="U" city="Utrecht"/> <Hex name="I14" tile="-2" cost="80" city="Arnhem/Nijmegen"/> - <Hex name="I16" tile="0" cost="80"/> + <Hex name="I16" tile="0"> + <IfOption name="Version" value="v1"> + <Attributes cost="80"/> + </IfOption> + </Hex> <Hex name="I18" tile="0"/> <Hex name="J3" tile="-901" orientation="4" value="10,60" city="Engeland"/> <Hex name="J5" tile="-8" orientation="5"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-01-28 19:47:57
|
Revision: 1474 http://rails.svn.sourceforge.net/rails/?rev=1474&view=rev Author: evos Date: 2011-01-28 19:47:51 +0000 (Fri, 28 Jan 2011) Log Message: ----------- Added "Version" option to 18Kaas with values "v1" (includes Gouda on map) and "v2" (no Gouda, default). Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/GamesList.xml Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2011-01-28 19:44:46 UTC (rev 1473) +++ trunk/18xx/LocalisedText.properties 2011-01-28 19:47:51 UTC (rev 1474) @@ -643,6 +643,7 @@ USING_SP=using {0} Variant=Variant VariantIs=Variant is {0}. +Version=Version WantToReplaceToken=Do you want to replace the {0} home token with one of {1}? WarningNeedCash=Warning: {0} will be deducted from the company revenue or from your personal cash WHICH_PRICE=Which price? Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2011-01-28 19:44:46 UTC (rev 1473) +++ trunk/18xx/data/GamesList.xml 2011-01-28 19:47:51 UTC (rev 1474) @@ -139,6 +139,7 @@ Should work, but has not been extensively tested. Limitations as with 1830. </Description> + <Option name="Version" values="v1,v2" default="v2" /> <Option name="RouteAwareness" values="Highlight,Deactivate" default="Highlight" /> <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> <Option name="18KaasRuhrgebiedDoublesOnlyMajors" type="toggle" default="yes" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-01-28 19:44:52
|
Revision: 1473 http://rails.svn.sourceforge.net/rails/?rev=1473&view=rev Author: evos Date: 2011-01-28 19:44:46 +0000 (Fri, 28 Jan 2011) Log Message: ----------- Implemented setting default value in option dropdowns Modified Paths: -------------- trunk/18xx/rails/ui/swing/GameSetupWindow.java Modified: trunk/18xx/rails/ui/swing/GameSetupWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/GameSetupWindow.java 2011-01-22 15:22:39 UTC (rev 1472) +++ trunk/18xx/rails/ui/swing/GameSetupWindow.java 2011-01-28 19:44:46 UTC (rev 1473) @@ -349,6 +349,10 @@ for (String value : option.getAllowedValues()) { dropdown.addItem(value); } + String defaultValue = option.getDefaultValue(); + if (defaultValue != null) { + dropdown.setSelectedItem(defaultValue); + } optionsPane.add(dropdown); optionComponents.add(dropdown); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-01-22 15:22:45
|
Revision: 1472 http://rails.svn.sourceforge.net/rails/?rev=1472&view=rev Author: evos Date: 2011-01-22 15:22:39 +0000 (Sat, 22 Jan 2011) Log Message: ----------- Patch by Adam Badura to fix errors with loading from the command line. Modified Paths: -------------- trunk/18xx/rails/util/RunGame.java Modified: trunk/18xx/rails/util/RunGame.java =================================================================== --- trunk/18xx/rails/util/RunGame.java 2011-01-22 15:19:57 UTC (rev 1471) +++ trunk/18xx/rails/util/RunGame.java 2011-01-22 15:22:39 UTC (rev 1472) @@ -10,7 +10,7 @@ public static void main(String[] args) { - // intialize configuration + // Initialize configuration Config.setConfigSelection(); int nargs = 0; @@ -23,13 +23,35 @@ } if (nargs >= 1) { - loadGame (args); + // We have to run loadGame on an AWT EventQueue to make sure + // that NDC will properly initialize game key so that + // GameManager instance can be properly queried for. This is a + // consequence of NDC abuse. + loadGameOnEventQueue(args); } else { /* Start the rails.game selector, which will do all the rest. */ new GameSetupWindow(); } } + static void loadGameOnEventQueue(final String[] args) + { + try { + java.awt.EventQueue.invokeAndWait( + new Runnable() + { + public void run() { + loadGame(args); + } + } + ); + } catch (Exception e) { + System.err.println("Cannot load game: "+e.getMessage()); + e.printStackTrace(System.err); + System.exit(1); + } + } + static void loadGame (String[] args) { Game game = null; @@ -48,6 +70,12 @@ Class.forName(gameUIManagerClassName).asSubclass(GameUIManager.class); gameUIManager = gameUIManagerClass.newInstance(); gameUIManager.init(gameManager); + + String directory = new java.io.File(filepath).getParent(); + if(directory != null) { + gameUIManager.setSaveDirectory(directory); + } + gameUIManager.startLoadedGame(); } catch (Exception e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2011-01-22 15:20:03
|
Revision: 1471 http://rails.svn.sourceforge.net/rails/?rev=1471&view=rev Author: evos Date: 2011-01-22 15:19:57 +0000 (Sat, 22 Jan 2011) Log Message: ----------- Typo fixed Modified Paths: -------------- trunk/18xx/rails/game/Bank.java Modified: trunk/18xx/rails/game/Bank.java =================================================================== --- trunk/18xx/rails/game/Bank.java 2010-12-31 10:28:26 UTC (rev 1470) +++ trunk/18xx/rails/game/Bank.java 2011-01-22 15:19:57 UTC (rev 1471) @@ -15,7 +15,7 @@ private static final int DEFAULT_BANK_AMOUNT = 12000; private static final String DEFAULT_MONEY_FORMAT = "$@"; - /** The Bank's amont of cash */ + /** The Bank's amount of cash */ private CashModel money; /** The IPO */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-31 10:28:32
|
Revision: 1470 http://rails.svn.sourceforge.net/rails/?rev=1470&view=rev Author: evos Date: 2010-12-31 10:28:26 +0000 (Fri, 31 Dec 2010) Log Message: ----------- Set version to 1.4+ Modified Paths: -------------- trunk/18xx/rails/game/Game.java Modified: trunk/18xx/rails/game/Game.java =================================================================== --- trunk/18xx/rails/game/Game.java 2010-12-30 10:12:42 UTC (rev 1469) +++ trunk/18xx/rails/game/Game.java 2010-12-31 10:28:26 UTC (rev 1470) @@ -13,7 +13,7 @@ import rails.util.Tag; public class Game { - public static final String version = "1.4"; + public static final String version = "1.4+"; /** The component Manager */ protected ComponentManager componentManager; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-30 10:12:48
|
Revision: 1469 http://rails.svn.sourceforge.net/rails/?rev=1469&view=rev Author: evos Date: 2010-12-30 10:12:42 +0000 (Thu, 30 Dec 2010) Log Message: ----------- Added system property to define windows settings directories. Added ability to create a default settings file. Modified Paths: -------------- trunk/18xx/rails/ui/swing/StockChart.java trunk/18xx/rails/ui/swing/WindowSettings.java Modified: trunk/18xx/rails/ui/swing/StockChart.java =================================================================== --- trunk/18xx/rails/ui/swing/StockChart.java 2010-12-25 21:34:13 UTC (rev 1468) +++ trunk/18xx/rails/ui/swing/StockChart.java 2010-12-30 10:12:42 UTC (rev 1469) @@ -57,7 +57,8 @@ WindowSettings ws = gameUIManager.getWindowSettings(); Rectangle bounds = ws.getBounds(this); if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); - if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + if (bounds.width != -1 && bounds.height != -1 + && !ws.isDefaultUsed()) setSize(bounds.getSize()); ws.set(frame); } Modified: trunk/18xx/rails/ui/swing/WindowSettings.java =================================================================== --- trunk/18xx/rails/ui/swing/WindowSettings.java 2010-12-25 21:34:13 UTC (rev 1468) +++ trunk/18xx/rails/ui/swing/WindowSettings.java 2010-12-30 10:12:42 UTC (rev 1469) @@ -14,6 +14,8 @@ private Map<String, Rectangle> settings = new HashMap<String, Rectangle>(); private String filepath; + private String defaultpath; + private boolean defaultUsed = false; private static final String settingsfilename = "settings_xxxx.rails_ini"; @@ -21,8 +23,10 @@ Logger.getLogger(WindowSettings.class.getPackage().getName()); public WindowSettings (String gameName) { - String directory = Config.get("save.directory"); - filepath = directory + File.separator + settingsfilename.replace("xxxx", gameName); + String directory = System.getProperty("settings.directory"); + if (directory == null) directory = Config.get("save.directory"); + defaultpath = directory + File.separator + settingsfilename; + filepath = defaultpath.replace("xxxx", gameName); } private Rectangle rectangle (String windowName) { @@ -40,11 +44,26 @@ return rectangle (w.getClass().getSimpleName()); } + public boolean isDefaultUsed() { + return defaultUsed; + } + public void load () { + FileReader file; + try { + file = new FileReader (filepath); + } catch (FileNotFoundException e1) { + try { + file = new FileReader (defaultpath); + } catch (FileNotFoundException e2) { + return; + } + defaultUsed = true; + } BufferedReader in; try { - in = new BufferedReader (new FileReader (filepath)); + in = new BufferedReader (file); String line; String[] fields; int v; @@ -62,9 +81,6 @@ } } in.close(); - } catch (FileNotFoundException e) { - // No problem - return; } catch (Exception e) { log.error ("Error while loading "+filepath, e); } @@ -103,7 +119,7 @@ } out.close(); } catch (Exception e) { - + log.error ("Exception while saving window settings", e); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-25 21:34:19
|
Revision: 1468 http://rails.svn.sourceforge.net/rails/?rev=1468&view=rev Author: evos Date: 2010-12-25 21:34:13 +0000 (Sat, 25 Dec 2010) Log Message: ----------- Cleanup Modified Paths: -------------- trunk/18xx/rails/ui/swing/WindowSettings.java Modified: trunk/18xx/rails/ui/swing/WindowSettings.java =================================================================== --- trunk/18xx/rails/ui/swing/WindowSettings.java 2010-12-25 21:33:13 UTC (rev 1467) +++ trunk/18xx/rails/ui/swing/WindowSettings.java 2010-12-25 21:34:13 UTC (rev 1468) @@ -82,7 +82,6 @@ r.y = window.getY(); r.width = window.getWidth(); r.height = window.getHeight(); - log.debug("+++ Set "+name+" bounds to "+r.x+","+r.y+"/"+r.width+","+r.height); } return; } @@ -90,7 +89,7 @@ public void save () { // Save all settings to file - log.debug("=== Saving all window settings"); + log.debug("Saving all window settings"); try { PrintWriter out = new PrintWriter (new FileWriter (new File (filepath))); Rectangle r; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-25 21:33:19
|
Revision: 1467 http://rails.svn.sourceforge.net/rails/?rev=1467&view=rev Author: evos Date: 2010-12-25 21:33:13 +0000 (Sat, 25 Dec 2010) Log Message: ----------- Fixed ReportWindow Modified Paths: -------------- trunk/18xx/rails/ui/swing/AbstractReportWindow.java trunk/18xx/rails/ui/swing/ReportWindow.java trunk/18xx/rails/ui/swing/ReportWindowDynamic.java Modified: trunk/18xx/rails/ui/swing/AbstractReportWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-12-25 21:12:39 UTC (rev 1466) +++ trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-12-25 21:33:13 UTC (rev 1467) @@ -1,7 +1,7 @@ package rails.ui.swing; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import java.awt.Rectangle; +import java.awt.event.*; import javax.swing.JFrame; @@ -10,10 +10,16 @@ public abstract class AbstractReportWindow extends JFrame { private static final long serialVersionUID = 1L; - + + protected GameUIManager gameUIManager; + // can be set to false, than it cannot be closed protected boolean closeable = true; + public AbstractReportWindow (GameUIManager gameUIManager) { + this.gameUIManager = gameUIManager; + } + public void init() { setSize(400, 400); setLocation(600, 400); @@ -29,12 +35,29 @@ frame.dispose(); } }); - + final GameUIManager guiMgr = gameUIManager; + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + }); + + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(frame); + setVisible("yes".equalsIgnoreCase(Config.get("report.window.open"))); } - + public abstract void updateLog(); - + public abstract void scrollDown(); } \ No newline at end of file Modified: trunk/18xx/rails/ui/swing/ReportWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindow.java 2010-12-25 21:12:39 UTC (rev 1466) +++ trunk/18xx/rails/ui/swing/ReportWindow.java 2010-12-25 21:33:13 UTC (rev 1467) @@ -31,7 +31,6 @@ private JMenuItem saveItem, loadItem, printItem; private JMenuItem findItem, findBackItem, findNextItem, findPrevItem; - private GameUIManager gameUIManager; private GameManagerI gameManager; private String reportDirectory = Config.get("report.directory"); @@ -52,8 +51,8 @@ public ReportWindow(GameUIManager gameUIManager) { + super(gameUIManager); messageWindow = this; - this.gameUIManager = gameUIManager; this.gameManager = gameUIManager.getGameManager(); reportText = new JTextArea(); @@ -156,24 +155,6 @@ // default report window settings super.init(); - final JFrame frame = this; - final GameUIManager guiMgr = gameUIManager; - addComponentListener(new ComponentAdapter() { - @Override - public void componentMoved(ComponentEvent e) { - guiMgr.getWindowSettings().set(frame); - } - @Override - public void componentResized(ComponentEvent e) { - guiMgr.getWindowSettings().set(frame); - } - }); - - WindowSettings ws = gameUIManager.getWindowSettings(); - Rectangle bounds = ws.getBounds(this); - if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); - if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); - ws.set(frame); } /* (non-Javadoc) Modified: trunk/18xx/rails/ui/swing/ReportWindowDynamic.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-12-25 21:12:39 UTC (rev 1466) +++ trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-12-25 21:33:13 UTC (rev 1467) @@ -1,22 +1,13 @@ package rails.ui.swing; import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.EventQueue; import java.awt.Font; -import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.URL; import java.util.List; -import javax.swing.JButton; -import javax.swing.JEditorPane; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.UIManager; +import javax.swing.*; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import javax.swing.text.BadLocationException; @@ -38,36 +29,34 @@ public class ReportWindowDynamic extends AbstractReportWindow implements ActionListener, HyperlinkListener { private static final long serialVersionUID = 1L; - private GameUIManager gameUIManager; - private JLabel message; - + private JScrollPane reportPane; private JEditorPane editorPane; - + private JPanel buttonPanel; private ActionButton forwardButton; private ActionButton backwardButton; private JButton returnButton; private JButton playFromHereButton; private JButton commentButton; - + private boolean timeWarpMode; - + protected static Logger log = Logger.getLogger(ReportWindowDynamic.class.getPackage().getName()); public ReportWindowDynamic(GameUIManager gameUIManager) { - super(); - this.gameUIManager = gameUIManager; + super(gameUIManager); init(); } + @Override public void init() { super.init(); setLayout(new BorderLayout()); - + JPanel messagePanel = new JPanel(); messagePanel.setLayout(new BorderLayout()); @@ -75,7 +64,7 @@ message.setText( LocalText.getText("REPORT_TIMEWARP_ACTIVE")); message.setHorizontalAlignment(JLabel.CENTER); messagePanel.add(message, "North"); - + JPanel timeWarpButtons = new JPanel(); returnButton = new JButton(LocalText.getText("REPORT_LEAVE_TIMEWARP")); returnButton.addActionListener( @@ -98,7 +87,7 @@ timeWarpButtons.add(playFromHereButton); messagePanel.add(timeWarpButtons, "South"); add(messagePanel, "North"); - + editorPane = new JEditorPane(); editorPane.setEditable(false); editorPane.setContentType("text/html"); @@ -115,10 +104,10 @@ reportPane = new JScrollPane(editorPane); add(reportPane, "Center"); - + buttonPanel = new JPanel(); add(buttonPanel, "South"); - + backwardButton = new ActionButton(LocalText.getText("REPORT_MOVE_BACKWARD")); backwardButton.addActionListener(this); buttonPanel.add(backwardButton); @@ -126,8 +115,8 @@ forwardButton = new ActionButton(LocalText.getText("REPORT_MOVE_FORWARD")); forwardButton.addActionListener(this); buttonPanel.add(forwardButton); - - + + commentButton = new JButton(LocalText.getText("REPORT_COMMENT")); commentButton.addActionListener( new ActionListener() { @@ -150,15 +139,15 @@ } ); buttonPanel.add(commentButton); - + } - + @Override public void updateLog() { - // set the content of the pane to the current + // set the content of the pane to the current editorPane.setText(ReportBuffer.getReportItems()); scrollDown(); - + forwardButton.setEnabled(false); backwardButton.setEnabled(false); @@ -173,7 +162,7 @@ backwardButton.setEnabled(true); break; case GameAction.FORCED_UNDO: - if (undoFlag) break; // only activate forced undo, if no other undo available + if (undoFlag) break; // only activate forced undo, if no other undo available backwardButton.setPossibleAction(action); backwardButton.setEnabled(true); break; @@ -191,7 +180,7 @@ public void scrollDown() { // only set caret if visible if (!this.isVisible()) return; - + // find the active message in the parsed html code (not identical to the position in the html string) // thus the message indicator is used int caretPosition; @@ -206,7 +195,7 @@ editorPane.setCaretPosition(caretPositionStore); } } - + public void actionPerformed(ActionEvent e) { ActionButton button = (ActionButton)e.getSource(); GameAction action = (GameAction)button.getPossibleActions().get(0); @@ -215,8 +204,8 @@ activateTimeWarp(); } } - - + + gameUIManager.processOnServer(action); } @@ -235,7 +224,7 @@ private void gotoLastIndex() { gotoIndex(gameUIManager.getGameManager().getMoveStack().size()); } - + private void gotoIndex(int index) { MoveStack stack = gameUIManager.getGameManager().getMoveStack(); int currentIndex = stack.getIndex(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-25 21:12:46
|
Revision: 1466 http://rails.svn.sourceforge.net/rails/?rev=1466&view=rev Author: evos Date: 2010-12-25 21:12:39 +0000 (Sat, 25 Dec 2010) Log Message: ----------- Main windows keep their location and size across program restarts. The bounds per window and per game are saved in a file named like "settings_xxxx.rails_ini", where xxxx is the game name. This file is stored in the save directory (as does ConfigWindow), but I'm open to any other suggestions. For some reason that is beyond me, the ReportWindow refuses to register its bounds, so it doesn't work there yet. Modified Paths: -------------- trunk/18xx/rails/ui/swing/GameUIManager.java trunk/18xx/rails/ui/swing/ORWindow.java trunk/18xx/rails/ui/swing/ReportWindow.java trunk/18xx/rails/ui/swing/StartRoundWindow.java trunk/18xx/rails/ui/swing/StatusWindow.java trunk/18xx/rails/ui/swing/StockChart.java trunk/18xx/tiles/TileDictionary.18t Added Paths: ----------- trunk/18xx/rails/ui/swing/WindowSettings.java Modified: trunk/18xx/rails/ui/swing/GameUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/GameUIManager.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/GameUIManager.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -1,12 +1,6 @@ package rails.ui.swing; -import java.awt.Component; -import java.awt.Container; -import java.awt.EventQueue; import java.awt.Font; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; @@ -72,6 +66,8 @@ protected SimpleDateFormat saveDateTimeFormat; protected File lastFile, lastDirectory; + protected WindowSettings windowSettings; + protected boolean configuredStockChartVisibility = false; protected boolean previousStockChartVisibilityHint; @@ -93,13 +89,29 @@ this.gameManager = gameManager; uiHints = gameManager.getUIHints(); + initWindowSettings(); initSaveSettings(); initFontSettings(); - + configuredStockChartVisibility = "yes".equalsIgnoreCase(Config.get("stockchart.window.open")); } - + + private void initWindowSettings () { + + windowSettings = new WindowSettings (gameManager.getGameName()); + windowSettings.load(); + } + + public void terminate () { + getWindowSettings ().save(); + System.exit(0); + } + + public WindowSettings getWindowSettings () { + return windowSettings; + } + private void initSaveSettings() { saveDirectory = Config.get("save.directory"); if (!Util.hasValue(saveDirectory)) { @@ -126,7 +138,7 @@ } private void initFontSettings() { - + // font settings, can be game specific String fontType = Config.getGameSpecific("font.ui.name"); Font font = null; @@ -149,14 +161,14 @@ log.debug("Change text fonts to relative scale " + Scale.getFontScale()); changeGlobalFont(font, Scale.getFontScale()); } - + public void gameUIInit(boolean newGame) { imageLoader = new ImageLoader(); stockChart = new StockChart(this); if (Config.get("report.window.type").equalsIgnoreCase("static")) { - reportWindow = new ReportWindow(gameManager); + reportWindow = new ReportWindow(this); } else { reportWindow = new ReportWindowDynamic(this); } @@ -174,7 +186,7 @@ // GraphicsDevice[] gs = ge.getScreenDevices(); // log.debug("ScreenDevices = " + Arrays.toString(gs)); // statusWindow = statusWindowClass.getConstructor(GraphicsConfiguration.class).newInstance(gs[1].getDefaultConfiguration()); - + statusWindow.init(this); } catch (Exception e) { log.fatal("Cannot instantiate class " + statusWindowClassName, e); @@ -312,7 +324,7 @@ /* close current dialog */ setCurrentDialog(null, null); - + if (StockRound.class.isAssignableFrom(previousRoundType)) { log.debug("UI leaving Stock Round "+previousRoundName); statusWindow.finishRound(); @@ -454,7 +466,7 @@ } updateStatus(activeWindow); - + } /** Stub, to be overridden in subclasses for special round types */ @@ -708,7 +720,7 @@ File proposedFile = new File(filename); jfc.setSelectedFile(proposedFile); - + if (jfc.showSaveDialog(statusWindow) == JFileChooser.APPROVE_OPTION) { File selectedFile = jfc.getSelectedFile(); String filepath = selectedFile.getPath(); @@ -760,7 +772,7 @@ saveAction.setFilepath(filepath); processOnServer(saveAction); } - + } public void setSaveDirectory(String saveDirectory) { @@ -838,14 +850,14 @@ public boolean getGameParameterAsBoolean (GuiDef.Parm key) { return (Boolean) getGameParameter(key); } - + private void setEnabledWindow(boolean enabled, JFrame window, JFrame exceptionWindow) { - + if (window != null && window != exceptionWindow) { window.setEnabled(enabled); } } - /** + /** * deactivate all game windows, except the argument one */ public void setEnabledAllWindows(boolean enabled, JFrame exceptionWindow) { @@ -856,8 +868,8 @@ setEnabledWindow(enabled, startRoundWindow, exceptionWindow); setEnabledWindow(enabled, statusWindow, exceptionWindow); } - - + + private void updateWindowsLookAndFeel() { SwingUtilities.updateComponentTreeUI(statusWindow); statusWindow.pack(); @@ -870,7 +882,7 @@ SwingUtilities.updateComponentTreeUI(stockChart); stockChart.pack(); } - + /** update fonts settings * (after configuration changes) */ Modified: trunk/18xx/rails/ui/swing/ORWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/ORWindow.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/ORWindow.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -3,8 +3,7 @@ import java.awt.BorderLayout; import java.awt.Rectangle; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import java.awt.event.*; import java.util.ArrayList; import java.util.List; @@ -67,7 +66,7 @@ mapPanel = new MapPanel(gameUIManager); getContentPane().add(mapPanel, BorderLayout.CENTER); - + upgradePanel = new UpgradesPanel(orUIManager); getContentPane().add(upgradePanel, BorderLayout.WEST); addMouseListener(upgradePanel); @@ -93,6 +92,7 @@ log.debug("OrWindow size = " + this.getSize()); final JFrame frame = this; + final GameUIManager guiMgr = gameUIManager; addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { @@ -100,7 +100,25 @@ frame.dispose(); } }); + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + }); + pack(); + + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(frame); + gameUIManager.reportWindow.updateLog(); } Modified: trunk/18xx/rails/ui/swing/ReportWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindow.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/ReportWindow.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -3,12 +3,7 @@ import java.awt.*; import java.awt.event.*; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; +import java.io.*; import javax.swing.*; @@ -17,9 +12,7 @@ import rails.game.GameManagerI; import rails.game.ReportBuffer; import rails.ui.swing.elements.ActionMenuItem; -import rails.util.Config; -import rails.util.LocalText; -import rails.util.Util; +import rails.util.*; /** * This is the UI for the LogWindow. It displays logged messages to the user @@ -38,11 +31,12 @@ private JMenuItem saveItem, loadItem, printItem; private JMenuItem findItem, findBackItem, findNextItem, findPrevItem; + private GameUIManager gameUIManager; private GameManagerI gameManager; - + private String reportDirectory = Config.get("report.directory"); private String reportFile; - + private boolean editable = "yes".equalsIgnoreCase(Config.get("report.window.editable")); protected static final String SAVE_CMD = "Save"; @@ -52,14 +46,15 @@ protected static final String FIND_BACK_CMD = "FindBack"; protected static final String FIND_NEXT_CMD = "FindNext"; protected static final String FIND_PREV_CMD = "FindPrev"; - + protected static Logger log = Logger.getLogger(ReportWindow.class.getPackage().getName()); - - public ReportWindow(GameManagerI gameManager) { + + public ReportWindow(GameUIManager gameUIManager) { messageWindow = this; - this.gameManager = gameManager; + this.gameUIManager = gameUIManager; + this.gameManager = gameUIManager.getGameManager(); reportText = new JTextArea(); reportText.setEditable(editable); @@ -79,13 +74,13 @@ gbc.weightx = gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; messagePanel.add(messageScroller, gbc); - + menuBar = new JMenuBar(); fileMenu = new JMenu(LocalText.getText("FILE")); fileMenu.setMnemonic(KeyEvent.VK_F); editMenu = new JMenu(LocalText.getText("EDIT")); editMenu.setMnemonic(KeyEvent.VK_E); - + loadItem = new ActionMenuItem(LocalText.getText("LOAD")); loadItem.setActionCommand(LOAD_CMD); loadItem.setMnemonic(KeyEvent.VK_L); @@ -151,20 +146,40 @@ menuBar.add(fileMenu); menuBar.add(editMenu); - + setJMenuBar(menuBar); - + setContentPane(messagePanel); addKeyListener(this); - + // default report window settings super.init(); + + final JFrame frame = this; + final GameUIManager guiMgr = gameUIManager; + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + }); + + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(frame); } /* (non-Javadoc) * @see rails.ui.swing.ReportWindowI#updateLog() */ + @Override public void updateLog() { String newText = ReportBuffer.get(); if (newText.length() > 0) { @@ -173,6 +188,7 @@ } } + @Override public void scrollDown () { SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -197,7 +213,7 @@ findNext(true); } } - + private void loadReportFile() { JFileChooser jfc = new JFileChooser(); @@ -212,7 +228,7 @@ } else { return; } - + try { BufferedReader in = new BufferedReader (new FileReader(selectedFile)); String line; @@ -226,9 +242,9 @@ e.getMessage(), "", JOptionPane.ERROR_MESSAGE); } } - + private void saveReportFile () { - + JFileChooser jfc = new JFileChooser(); if (Util.hasValue(reportDirectory)) { jfc.setCurrentDirectory(new File(reportDirectory)); @@ -243,7 +259,7 @@ if (!selectedFile.getName().equalsIgnoreCase(reportFile)) { reportFile = filepath; } - + try { PrintWriter out = new PrintWriter (new FileWriter (new File (reportFile))); out.print(reportText.getText()); @@ -255,40 +271,40 @@ } } } - + private void findText(boolean backwards) { - + String text = reportText.getText(); - String target = JOptionPane.showInputDialog(reportText, + String target = JOptionPane.showInputDialog(reportText, LocalText.getText("EnterSearch")); if (!Util.hasValue(target)) return; - - int startPos = editable - ? reportText.getCaretPosition() + + int startPos = editable + ? reportText.getCaretPosition() : backwards ? text.length() : 0; int foundPos = backwards ? text.lastIndexOf(target, startPos) : text.indexOf(target, startPos); if (foundPos < 0) return; - + reportText.select(foundPos, foundPos + target.length()); } - + private void findNext(boolean backwards) { - + String text = reportText.getText(); String target = reportText.getSelectedText(); if (!Util.hasValue(target)) return; - + int startPos = reportText.getSelectionStart(); int foundPos = backwards ? text.lastIndexOf(target, startPos-1) : text.indexOf(target, startPos+1); if (foundPos < 0) return; - + reportText.select(foundPos, foundPos + target.length()); } - + public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1) { HelpWindow.displayHelp(gameManager.getHelp()); Modified: trunk/18xx/rails/ui/swing/StartRoundWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/StartRoundWindow.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/StartRoundWindow.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -186,8 +186,38 @@ addKeyListener(this); + // set closing behavior and listener + setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE ); + final JFrame thisFrame = this; + final GameUIManager guiMgr = gameUIManager; + addWindowListener(new WindowAdapter () { + @Override + public void windowClosing(WindowEvent e) { + if (JOptionPane.showConfirmDialog(thisFrame, LocalText.getText("CLOSE_WINDOW"), LocalText.getText("Select"), JOptionPane.OK_CANCEL_OPTION) + == JOptionPane.OK_OPTION) { + thisFrame.dispose(); + guiMgr.terminate(); + } + } + }); + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(thisFrame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(thisFrame); + } + }); pack(); + + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(thisFrame); } private void init() { @@ -321,19 +351,6 @@ dummyButton = new ClickField("", "", "", this, itemGroup); - // set closing behavior and listener - setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE ); - final JFrame thisFrame = this; - addWindowListener(new WindowAdapter () { - @Override - public void windowClosing(WindowEvent e) { - if (JOptionPane.showConfirmDialog(thisFrame, LocalText.getText("CLOSE_WINDOW"), LocalText.getText("Select"), JOptionPane.OK_CANCEL_OPTION) - == JOptionPane.OK_OPTION) { - thisFrame.dispose(); - System.exit(0); - } - } - }); } private void addField(JComponent comp, int x, int y, int width, int height, Modified: trunk/18xx/rails/ui/swing/StatusWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/StatusWindow.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/StatusWindow.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -1,10 +1,10 @@ /* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/ui/swing/StatusWindow.java,v 1.46 2010/06/15 20:16:54 evos Exp $*/ package rails.ui.swing; -import java.awt.BorderLayout; -import java.awt.Color; +import java.awt.*; import java.awt.event.*; import java.util.*; +import java.util.List; import javax.swing.*; @@ -256,11 +256,11 @@ log.fatal("Cannot instantiate class " + gameStatusClassName, e); System.exit(1); } - + gameStatus.init(this, gameUIManager); // put gameStatus into a JScrollPane JScrollPane gameStatusPane = new JScrollPane(gameStatus); - + buttonPanel = new JPanel(); passButton = new ActionButton(LocalText.getText("PASS")); @@ -299,19 +299,35 @@ setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE ); final JFrame frame = this; + final GameUIManager guiMgr = gameUIManager; addWindowListener(new WindowAdapter () { @Override public void windowClosing(WindowEvent e) { if (JOptionPane.showConfirmDialog(frame, LocalText.getText("CLOSE_WINDOW"), LocalText.getText("Select"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { frame.dispose(); - System.exit(0); + guiMgr.terminate(); } } }); + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + }); + pack(); - pack(); + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(frame); } public void setGameActions() { @@ -596,7 +612,7 @@ process(executedAction); } else if (command.equals(QUIT_CMD)) { - System.exit(0); + gameUIManager.terminate(); } else if (command.equals(REPORT_CMD)) { gameUIManager.reportWindow.setVisible(((JMenuItem) actor.getSource()).isSelected()); gameUIManager.reportWindow.scrollDown(); Modified: trunk/18xx/rails/ui/swing/StockChart.java =================================================================== --- trunk/18xx/rails/ui/swing/StockChart.java 2010-12-24 20:24:00 UTC (rev 1465) +++ trunk/18xx/rails/ui/swing/StockChart.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -33,6 +33,7 @@ stockPanel.setBackground(Color.LIGHT_GRAY); final JFrame frame = this; + final GameUIManager guiMgr = gameUIManager; addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { @@ -40,8 +41,24 @@ frame.dispose(); } }); + addComponentListener(new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + @Override + public void componentResized(ComponentEvent e) { + guiMgr.getWindowSettings().set(frame); + } + }); addKeyListener(this); pack(); + + WindowSettings ws = gameUIManager.getWindowSettings(); + Rectangle bounds = ws.getBounds(this); + if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation()); + if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize()); + ws.set(frame); } private void initialize() { Added: trunk/18xx/rails/ui/swing/WindowSettings.java =================================================================== --- trunk/18xx/rails/ui/swing/WindowSettings.java (rev 0) +++ trunk/18xx/rails/ui/swing/WindowSettings.java 2010-12-25 21:12:39 UTC (rev 1466) @@ -0,0 +1,114 @@ +package rails.ui.swing; + +import java.awt.Rectangle; +import java.io.*; +import java.util.*; + +import javax.swing.JFrame; + +import org.apache.log4j.Logger; + +import rails.util.Config; + +public class WindowSettings { + + private Map<String, Rectangle> settings = new HashMap<String, Rectangle>(); + private String filepath; + + private static final String settingsfilename = "settings_xxxx.rails_ini"; + + protected static Logger log = + Logger.getLogger(WindowSettings.class.getPackage().getName()); + + public WindowSettings (String gameName) { + String directory = Config.get("save.directory"); + filepath = directory + File.separator + settingsfilename.replace("xxxx", gameName); + } + + private Rectangle rectangle (String windowName) { + + if (settings.containsKey(windowName)) { + return settings.get(windowName); + } else { + Rectangle r = new Rectangle(-1, -1, -1, -1); + settings.put(windowName, r); + return r; + } + } + + public Rectangle getBounds (JFrame w) { + return rectangle (w.getClass().getSimpleName()); + } + + public void load () { + + BufferedReader in; + try { + in = new BufferedReader (new FileReader (filepath)); + String line; + String[] fields; + int v; + Rectangle r; + while ((line = in.readLine()) != null) { + fields = line.split("[\\.=]"); + if (fields.length < 3) continue; + v = Integer.parseInt(fields[2]); + r = rectangle(fields[0]); + switch (fields[1].charAt(0)) { + case 'X': r.x = v; break; + case 'Y': r.y = v; break; + case 'W': r.width = v; break; + case 'H': r.height = v; break; + } + } + in.close(); + } catch (FileNotFoundException e) { + // No problem + return; + } catch (Exception e) { + log.error ("Error while loading "+filepath, e); + } + + } + + public void set(JFrame window) { + + if (window != null) { + + // Save one window's settings + String name = window.getClass().getSimpleName(); + Rectangle r = rectangle (name); + r.x = window.getX(); + r.y = window.getY(); + r.width = window.getWidth(); + r.height = window.getHeight(); + log.debug("+++ Set "+name+" bounds to "+r.x+","+r.y+"/"+r.width+","+r.height); + } + return; + } + + public void save () { + + // Save all settings to file + log.debug("=== Saving all window settings"); + try { + PrintWriter out = new PrintWriter (new FileWriter (new File (filepath))); + Rectangle r; + Set<String> keys = new TreeSet<String> (settings.keySet()); + for (String name : keys) { + r = settings.get(name); + out.println(name+".X="+r.x); + out.println(name+".Y="+r.y); + out.println(name+".W="+r.width); + out.println(name+".H="+r.height); + } + out.close(); + } catch (Exception e) { + + } + + } + + +} + Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-24 20:24:07
|
Revision: 1465 http://rails.svn.sourceforge.net/rails/?rev=1465&view=rev Author: evos Date: 2010-12-24 20:24:00 +0000 (Fri, 24 Dec 2010) Log Message: ----------- Implemented usage of <TileSet><Tile> pictureID attribute. In 18EU this causes the correct green and brown plain track tiles (internally numbered 3080-3083 and 3544-3546) to be displayed. Modified Paths: -------------- trunk/18xx/data/18EU/TileSet.xml trunk/18xx/rails/ui/swing/RemainingTilesWindow.java trunk/18xx/rails/ui/swing/UpgradesPanel.java trunk/18xx/tiles/svg/tile3080.svg Added Paths: ----------- trunk/18xx/tiles/svg/tile3544.svg trunk/18xx/tiles/svg/tile3545.svg trunk/18xx/tiles/svg/tile3546.svg Modified: trunk/18xx/data/18EU/TileSet.xml =================================================================== --- trunk/18xx/data/18EU/TileSet.xml 2010-12-24 18:59:23 UTC (rev 1464) +++ trunk/18xx/data/18EU/TileSet.xml 2010-12-24 20:24:00 UTC (rev 1465) @@ -112,9 +112,9 @@ <Tile id="145" quantity="4" /> <Tile id="146" quantity="5" /> <Tile id="147" quantity="4" /> - <Tile id="544" quantity="3" /> - <Tile id="545" quantity="3" /> - <Tile id="546" quantity="3" /> + <Tile id="544" pic="3544" quantity="3" /> + <Tile id="545" pic="3545" quantity="3" /> + <Tile id="546" pic="3546" quantity="3" /> <Tile id="582" quantity="9" /> <Tile id="583" quantity="1"> <AllowsMultipleBasesOfOneCompany/> Modified: trunk/18xx/rails/ui/swing/RemainingTilesWindow.java =================================================================== --- trunk/18xx/rails/ui/swing/RemainingTilesWindow.java 2010-12-24 18:59:23 UTC (rev 1464) +++ trunk/18xx/rails/ui/swing/RemainingTilesWindow.java 2010-12-24 20:24:00 UTC (rev 1465) @@ -62,6 +62,7 @@ Field label; BufferedImage hexImage; ImageIcon hexIcon; + int picId; // Build the grid with tiles in the sequence as // these have been defined in Tiles.xml @@ -72,8 +73,9 @@ if (tileId <= 0) continue; tile = tmgr.getTile(tileId); + picId = tile.getPictureId(); - hexImage = GameUIManager.getImageLoader().getTile(tileId, 10); + hexImage = GameUIManager.getImageLoader().getTile(picId, 10); hexIcon = new ImageIcon(hexImage); hexIcon.setImage(hexIcon.getImage().getScaledInstance( (int) (hexIcon.getIconWidth() * GUIHex.NORMAL_SCALE * 0.8), Modified: trunk/18xx/rails/ui/swing/UpgradesPanel.java =================================================================== --- trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-12-24 18:59:23 UTC (rev 1464) +++ trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-12-24 20:24:00 UTC (rev 1465) @@ -174,7 +174,7 @@ orUIManager.setMessage(LocalText.getText("NoTiles")); } else { for (TileI tile : orUIManager.tileUpgrades) { - BufferedImage hexImage = getHexImage(tile.getId()); + BufferedImage hexImage = getHexImage(tile.getPictureId()); ImageIcon hexIcon = new ImageIcon(hexImage); // Cheap n' Easy rescaling. Modified: trunk/18xx/tiles/svg/tile3080.svg =================================================================== (Binary files differ) Added: trunk/18xx/tiles/svg/tile3544.svg =================================================================== --- trunk/18xx/tiles/svg/tile3544.svg (rev 0) +++ trunk/18xx/tiles/svg/tile3544.svg 2010-12-24 20:24:00 UTC (rev 1465) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#B46301" stroke="#B46301" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">544</text><path d="M 196,0 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 343,85 L 49,255" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,0 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 343,85 L 49,255" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> Added: trunk/18xx/tiles/svg/tile3545.svg =================================================================== --- trunk/18xx/tiles/svg/tile3545.svg (rev 0) +++ trunk/18xx/tiles/svg/tile3545.svg 2010-12-24 20:24:00 UTC (rev 1465) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#B46301" stroke="#B46301" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">545</text><path d="M 196,0 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,85 L 196,170" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,255 L 196,170" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,0 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,85 L 196,170" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,255 L 196,170" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> Added: trunk/18xx/tiles/svg/tile3546.svg =================================================================== --- trunk/18xx/tiles/svg/tile3546.svg (rev 0) +++ trunk/18xx/tiles/svg/tile3546.svg 2010-12-24 20:24:00 UTC (rev 1465) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#B46301" stroke="#B46301" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">546</text><path d="M 196,0 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 343,85 L 196,170" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,85 L 196,170" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,0 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 343,85 L 196,170" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 49,85 L 196,170" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-24 18:59:29
|
Revision: 1464 http://rails.svn.sourceforge.net/rails/?rev=1464&view=rev Author: evos Date: 2010-12-24 18:59:23 +0000 (Fri, 24 Dec 2010) Log Message: ----------- Implemented usage of <TileSet><Tile> pictureID attribute. In 18EU this causes the correct tiles (internally numbered 3081-3083) to be displayed. These tiles have also been replaced, as the original SVG images (from JA Tamplin) had a different orientation. Modified Paths: -------------- trunk/18xx/rails/ui/swing/hexmap/GUITile.java trunk/18xx/tiles/TileDictionary.18t trunk/18xx/tiles/svg/tile3081.svg trunk/18xx/tiles/svg/tile3082.svg trunk/18xx/tiles/svg/tile3083.svg Modified: trunk/18xx/rails/ui/swing/hexmap/GUITile.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-12-22 20:56:50 UTC (rev 1463) +++ trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-12-24 18:59:23 UTC (rev 1464) @@ -24,6 +24,7 @@ protected TileI tile = null; protected String tileType = null; + protected int picId; protected BufferedImage tileImage = null; protected int rotation = 0; @@ -53,6 +54,7 @@ this.hex = (MapHex)guiHex.getModel(); TileManager tileManager = guiHex.getHexMap().orUIManager.getTileManager(); tile = tileManager.getTile(tileId); + picId = tile.getPictureId(); if (hex.getTileOrientation() == MapHex.EW) { baseRotation = 0.5 * DEG60; @@ -250,7 +252,7 @@ int zoomStep = guiHex.getHexMap().getZoomStep(); - tileImage = imageLoader.getTile(tileId, zoomStep); + tileImage = imageLoader.getTile(picId, zoomStep); if (tileImage != null) { Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/svg/tile3081.svg =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/svg/tile3082.svg =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/svg/tile3083.svg =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-22 20:56:56
|
Revision: 1463 http://rails.svn.sourceforge.net/rails/?rev=1463&view=rev Author: evos Date: 2010-12-22 20:56:50 +0000 (Wed, 22 Dec 2010) Log Message: ----------- Fixed a problem where in 18EU minors were allowed to lay green tiles (bug #3064831). This was caused by the LayTile object have a tileColour allowance map entry {green=0}. This entry shouldn't have existed, but zero values weren't checked for anywhere either. This is now checked in two places. Modified Paths: -------------- trunk/18xx/rails/game/action/LayTile.java trunk/18xx/rails/ui/swing/UpgradesPanel.java Modified: trunk/18xx/rails/game/action/LayTile.java =================================================================== --- trunk/18xx/rails/game/action/LayTile.java 2010-12-18 21:42:03 UTC (rev 1462) +++ trunk/18xx/rails/game/action/LayTile.java 2010-12-22 20:56:50 UTC (rev 1463) @@ -84,7 +84,7 @@ public LayTile(Map<String, Integer> tileColours) { type = GENERIC; - this.tileColours = tileColours; + setTileColours (tileColours); } public LayTile(SpecialTileLay specialProperty) { @@ -189,11 +189,19 @@ } public boolean isTileColourAllowed(String tileColour) { - return tileColours.containsKey(tileColour); + return tileColours != null + && tileColours.containsKey(tileColour) + && tileColours.get(tileColour) > 0; } public void setTileColours(Map<String, Integer> map) { - tileColours = map; + tileColours = new HashMap<String, Integer>(); + // Check the map. Sometimes 0 values creep in, and these can't easily + // be intercepted in the UI code (see comment at previous method). + // TODO This is a dirty fix, but the quickest one too. + for (String colourName : map.keySet()) { + if (map.get(colourName) > 0) tileColours.put(colourName, map.get(colourName)); + } } Modified: trunk/18xx/rails/ui/swing/UpgradesPanel.java =================================================================== --- trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-12-18 21:42:03 UTC (rev 1462) +++ trunk/18xx/rails/ui/swing/UpgradesPanel.java 2010-12-22 20:56:50 UTC (rev 1463) @@ -91,17 +91,25 @@ for (LayTile layTile : hexMap.getTileAllowancesForHex(hex)) { tiles = layTile.getTiles(); - if (tiles == null) { + if (tiles == null) { for (TileI tile : uiHex.getCurrentTile().getValidUpgrades(hex, orUIManager.gameUIManager.getCurrentPhase())) { + // Skip if not allowed in LayTile + if (!layTile.isTileColourAllowed(tile.getColourName())) continue; + if (!orUIManager.tileUpgrades.contains(tile)) orUIManager.tileUpgrades.add(tile); } } else { for (TileI tile : tiles) { + // Skip if not allowed in LayTile + if (layTile.getTileColours().get(tile.getColourName()) < 1) continue; + // special check: does the tile increase the colour number? // this avoids that a special tile lay down or equalgrades existing tiles - if (tile.getColourNumber() <= uiHex.getCurrentTile().getColourNumber()) continue; + // TODO EV: I'm not sure if this is a necessary precaution. + if (!layTile.isTileColourAllowed(tile.getColourName())) continue; + if (!orUIManager.tileUpgrades.contains(tile)) orUIManager.tileUpgrades.add(tile); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-18 21:42:09
|
Revision: 1462 http://rails.svn.sourceforge.net/rails/?rev=1462&view=rev Author: evos Date: 2010-12-18 21:42:03 +0000 (Sat, 18 Dec 2010) Log Message: ----------- Fixed bug in ArrayListState / AddToList that caused CGR always to operate last in its formation OR. Modified Paths: -------------- trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/move/AddToList.java trunk/18xx/rails/game/specific/_1856/OperatingRound_1856.java trunk/18xx/rails/game/state/ArrayListState.java Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2010-12-18 21:40:56 UTC (rev 1461) +++ trunk/18xx/rails/game/OperatingRound.java 2010-12-18 21:42:03 UTC (rev 1462) @@ -2282,7 +2282,8 @@ } public int getOperatingCompanyIndex() { - return operatingCompanies.indexOf(getOperatingCompany()); + int index = operatingCompanies.indexOf(getOperatingCompany()); + return index; } /** Modified: trunk/18xx/rails/game/move/AddToList.java =================================================================== --- trunk/18xx/rails/game/move/AddToList.java 2010-12-18 21:40:56 UTC (rev 1461) +++ trunk/18xx/rails/game/move/AddToList.java 2010-12-18 21:42:03 UTC (rev 1462) @@ -19,7 +19,7 @@ protected String listName; protected Integer index; // if supplied insert at index position - public AddToList(List<E> list, E object, String listName, + public AddToList(List<E> list, E object, String listName, ModelObject modelToUpdate) { this.object = object; this.list = list; @@ -29,15 +29,25 @@ MoveSet.add(this); } - + public AddToList(List<E> list, E object, String listName) { - this (list, object, listName, null); + this.object = object; + this.list = list; + this.listName = listName; + this.index = null; + + MoveSet.add(this); } - - public void atIndex(int index) { + + public AddToList(List<E> list, E object, int index, String listName) { + this.object = object; + this.list = list; + this.listName = listName; this.index = index; - } + MoveSet.add(this); + } + @Override public boolean execute() { if (index == null) { @@ -58,7 +68,7 @@ @Override public String toString() { - if (index == null) + if (index == null) return "AddToList " + listName + ": " + object.toString(); else return "AddToList " + listName + ": " + object.toString() + " at index " + index; Modified: trunk/18xx/rails/game/specific/_1856/OperatingRound_1856.java =================================================================== --- trunk/18xx/rails/game/specific/_1856/OperatingRound_1856.java 2010-12-18 21:40:56 UTC (rev 1461) +++ trunk/18xx/rails/game/specific/_1856/OperatingRound_1856.java 2010-12-18 21:42:03 UTC (rev 1462) @@ -1,6 +1,7 @@ package rails.game.specific._1856; -import java.util.*; +import java.util.ArrayList; +import java.util.List; import rails.common.GuiDef; import rails.game.*; @@ -9,7 +10,6 @@ import rails.game.special.SellBonusToken; import rails.game.special.SpecialPropertyI; import rails.game.state.BooleanState; -import rails.game.state.IntegerState; import rails.util.LocalText; public class OperatingRound_1856 extends OperatingRound { Modified: trunk/18xx/rails/game/state/ArrayListState.java =================================================================== --- trunk/18xx/rails/game/state/ArrayListState.java 2010-12-18 21:40:56 UTC (rev 1461) +++ trunk/18xx/rails/game/state/ArrayListState.java 2010-12-18 21:42:03 UTC (rev 1462) @@ -43,7 +43,7 @@ } public void add(int index, E element) { - new AddToList<E>(list, element, listName).atIndex(index); + new AddToList<E>(list, element, index, listName); } public boolean remove(E element) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-18 21:41:03
|
Revision: 1461 http://rails.svn.sourceforge.net/rails/?rev=1461&view=rev Author: evos Date: 2010-12-18 21:40:56 +0000 (Sat, 18 Dec 2010) Log Message: ----------- Outcommented some debug logging. Modified Paths: -------------- trunk/18xx/rails/ui/swing/hexmap/GUITile.java Modified: trunk/18xx/rails/ui/swing/hexmap/GUITile.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-12-18 12:16:04 UTC (rev 1460) +++ trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-12-18 21:40:56 UTC (rev 1461) @@ -139,8 +139,8 @@ // stations must keep doing so (except when // downgrading to plain track, as in 1856) if (tile.hasStations()) { - log.debug("[" + i + "," + j + "] Found " - + oldTrack.getEndPoint(prevTileSide)); + //log.debug("[" + i + "," + j + "] Found " + // + oldTrack.getEndPoint(prevTileSide)); oldCities.put(prevTileSide, oldTrack.getEndPoint(prevTileSide)); } else { @@ -157,7 +157,7 @@ || prevTile.getTracksPerSide(otherOldEndPoint).isEmpty()) { continue rot; } - log.debug("[" + i + "," + j + "] Downgraded"); + //log.debug("[" + i + "," + j + "] Downgraded"); } } } @@ -197,18 +197,18 @@ lll = (6 + l - prevTileRotation) % 6; if (oldCities.get(lll) == null) continue; // If new tile is missing a connection, skip - log.debug("Found " + oldCities.get(kkk) + " & " - + oldCities.get(lll)); - log.debug("Check " + newCities.get(kkk) + " & " - + newCities.get(ll)); + //log.debug("Found " + oldCities.get(kkk) + " & " + // + oldCities.get(lll)); + //log.debug("Check " + newCities.get(kkk) + " & " + // + newCities.get(ll)); if (newCities.get(kk) == null || newCities.get(ll) == null) continue rot; // If connected cities do not correspond, skip // (this is the "OO brown upgrade get-right" feature) // Only apply this check if the number of cities has not decreased if (getTile().getNumStations() < prevTile.getNumStations()) continue; - log.debug("Compare "+oldCities.get(kkk)+"/"+oldCities.get(lll) - +" ~ "+newCities.get(kk)+"/"+newCities.get(ll)); + //log.debug("Compare "+oldCities.get(kkk)+"/"+oldCities.get(lll) + // +" ~ "+newCities.get(kk)+"/"+newCities.get(ll)); if ((oldCities.get(kkk).equals(oldCities.get(lll))) != (newCities.get(kk).equals(newCities.get(ll)))) { log.debug("No match!"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-18 12:16:10
|
Revision: 1460 http://rails.svn.sourceforge.net/rails/?rev=1460&view=rev Author: evos Date: 2010-12-18 12:16:04 +0000 (Sat, 18 Dec 2010) Log Message: ----------- 1889 fixes: - replaced tile #440 (had only one slot) - removed optional 3rd 6-train. Modified Paths: -------------- trunk/18xx/data/1889/Game.xml trunk/18xx/data/1889/Tiles.xml trunk/18xx/data/GamesList.xml trunk/18xx/tiles/TileDictionary.18t trunk/18xx/tiles/TileDictionary.xml trunk/18xx/tiles/Tiles.xml trunk/18xx/tiles/svg/tile440.svg Modified: trunk/18xx/data/1889/Game.xml =================================================================== --- trunk/18xx/data/1889/Game.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/data/1889/Game.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -19,7 +19,6 @@ <GameOption name="RevenueCalculation" values="Suggest,Deactivate" default="Deactivate" /> <GameOption name="NoMapMode" type="toggle" default="no" /> <GameOption name="BeginnerGame" type="toggle" default="no" /> - <GameOption name="WithOptional6Train" type="toggle" default="no"/> <GameOption name="UnlimitedTopTrains" parm="D" type="toggle" default="yes"/> <GameOption name="TwoPlayersCertLimit70Percent" type="toggle" default="yes"/> <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> Modified: trunk/18xx/data/1889/Tiles.xml =================================================================== --- trunk/18xx/data/1889/Tiles.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/data/1889/Tiles.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -180,7 +180,7 @@ <Track from="city1" gauge="normal" to="side0"/> </Tile> <Tile colour="green" id="440" name="1889 K5 green"> - <Station id="city1" position="0" slots="1" type="City" value="40"/> + <Station id="city1" position="0" slots="2" type="City" value="40"/> <Track from="city1" gauge="normal" to="side5"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side3"/> Modified: trunk/18xx/data/GamesList.xml =================================================================== --- trunk/18xx/data/GamesList.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/data/GamesList.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -85,7 +85,6 @@ <Option name="RevenueCalculation" values="Suggest,Deactivate" default="Suggest" /> <Option name="NoMapMode" type="toggle" default="no" /> <Option name="BeginnerGame" type="toggle" default="no" /> - <Option name="WithOptional6Train" type="toggle" default="no"/> <Option name="UnlimitedTopTrains" parm="D" type="toggle" default="yes"/> <Option name="TwoPlayersCertLimit70Percent" type="toggle" default="no"/> <Option name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> Modified: trunk/18xx/tiles/TileDictionary.18t =================================================================== (Binary files differ) Modified: trunk/18xx/tiles/TileDictionary.xml =================================================================== --- trunk/18xx/tiles/TileDictionary.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/tiles/TileDictionary.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -19306,7 +19306,7 @@ </category> <junctions> <junction> - <junType>jtCity</junType> + <junType>jtDoubleCity</junType> <position>tpCenter</position> <revenue> <value>40</value> Modified: trunk/18xx/tiles/Tiles.xml =================================================================== --- trunk/18xx/tiles/Tiles.xml 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/tiles/Tiles.xml 2010-12-18 12:16:04 UTC (rev 1460) @@ -3397,7 +3397,7 @@ <Track from="city1" gauge="normal" to="side0"/> </Tile> <Tile colour="green" id="440" name="1889 Takamatsu green"> - <Station id="city1" position="0" slots="1" type="City" value="40"/> + <Station id="city1" position="0" slots="2" type="City" value="40"/> <Track from="city1" gauge="normal" to="side5"/> <Track from="city1" gauge="normal" to="side4"/> <Track from="city1" gauge="normal" to="side3"/> Modified: trunk/18xx/tiles/svg/tile440.svg =================================================================== --- trunk/18xx/tiles/svg/tile440.svg 2010-12-15 21:49:12 UTC (rev 1459) +++ trunk/18xx/tiles/svg/tile440.svg 2010-12-18 12:16:04 UTC (rev 1460) @@ -1,2 +1,2 @@ -<?xml version="1.0"?> -<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#38AC00" stroke="#38AC00" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">440</text><circle cx="196" cy="170" r="51" fill="#FFFFFF" stroke="#FFFFFF" stroke-width="12"/><path d="M 196,170 L 49,85" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,255" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,85" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,255" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><circle cx="196" cy="170" r="51" fill="#FFFFFF" stroke="#000000" stroke-width="4"/><ellipse rx="38" ry="34" cx="123" cy="297" fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-linejoin="round"/><text x="123" y="297" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Bookman Old Style" font-size="51">40</text><text x="196" y="43" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="TimpaniHeavy" font-size="51">Takamatsu</text><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> +<?xml version="1.0"?> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="#38AC00" stroke="#38AC00" stroke-width="1" stroke-linejoin="round"/><text x="245" y="318" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Arial" font-size="34" font-weight="bold">440</text><polygon points="145,119 247,119 247,221 145,221" fill="#FFFFFF" stroke="#FFFFFF" stroke-width="12"/><circle cx="145" cy="170" r="51" fill="#FFFFFF" stroke="#FFFFFF" stroke-width="12"/><circle cx="247" cy="170" r="51" fill="#FFFFFF" stroke="#FFFFFF" stroke-width="12"/><path d="M 196,170 L 49,85" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,255" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 196,340" fill="none" stroke="#FFFFFF" stroke-width="34" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,85" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 49,255" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><path d="M 196,170 L 196,340" fill="none" stroke="#000000" stroke-width="26" stroke-linecap="butt" stroke-linejoin="round"/><polygon points="145,119 247,119 247,221 145,221" fill="#FFFFFF" stroke="#000000" stroke-width="4"/><circle cx="145" cy="170" r="51" fill="#FFFFFF" stroke="#000000" stroke-width="4"/><circle cx="247" cy="170" r="51" fill="#FFFFFF" stroke="#000000" stroke-width="4"/><ellipse rx="38" ry="34" cx="123" cy="297" fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-linejoin="round"/><text x="123" y="297" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="Bookman Old Style" font-size="51">40</text><text x="196" y="43" dy="0.3em" fill="#000000" stroke="#000000" text-anchor="middle" font-family="TimpaniHeavy" font-size="51">Takamatsu</text><path d=" M 98,0 L 294,0 L 392,170 L 294,340 L 98,340 L 0,170 Z" fill="none" stroke="black" stroke-width="1" stroke-linejoin="round"/></svg> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-12-15 21:49:18
|
Revision: 1459 http://rails.svn.sourceforge.net/rails/?rev=1459&view=rev Author: evos Date: 2010-12-15 21:49:12 +0000 (Wed, 15 Dec 2010) Log Message: ----------- Fix UI bug when only one start price is possible because of lack of cash Modified Paths: -------------- trunk/18xx/rails/game/action/StartCompany.java trunk/18xx/rails/ui/swing/GameStatus.java Modified: trunk/18xx/rails/game/action/StartCompany.java =================================================================== --- trunk/18xx/rails/game/action/StartCompany.java 2010-11-09 15:45:47 UTC (rev 1458) +++ trunk/18xx/rails/game/action/StartCompany.java 2010-12-15 21:49:12 UTC (rev 1459) @@ -38,7 +38,7 @@ } public boolean mustSelectAPrice() { - return startPrices != null && startPrices.length > 1; + return startPrices != null/* && startPrices.length > 1*/; } public void setStartPrice(int startPrice) { Modified: trunk/18xx/rails/ui/swing/GameStatus.java =================================================================== --- trunk/18xx/rails/ui/swing/GameStatus.java 2010-11-09 15:45:47 UTC (rev 1458) +++ trunk/18xx/rails/ui/swing/GameStatus.java 2010-12-15 21:49:12 UTC (rev 1459) @@ -623,13 +623,22 @@ startPrices = ((StartCompany) buy).getStartPrices(); Arrays.sort(startPrices); - for (int i = 0; i < startPrices.length; i++) { - options.add(LocalText.getText("StartCompany", - Bank.format(startPrices[i]), - sharePerCert, - Bank.format(sharesPerCert * startPrices[i]) )); + if (startPrices.length > 1) { + for (int i = 0; i < startPrices.length; i++) { + options.add(LocalText.getText("StartCompany", + Bank.format(startPrices[i]), + sharePerCert, + Bank.format(sharesPerCert * startPrices[i]) )); + buyActions.add(buy); + buyAmounts.add(startPrices[i]); + } + } else { + options.add (LocalText.getText("StartACompany", + companyName, + company.getPresidentsShare().getShare(), + Bank.format(company.getPresidentsShare().getShares() * startPrices[0]))); buyActions.add(buy); - buyAmounts.add(startPrices[i]); + buyAmounts.add(startPrices[0]); } } else { startPrices = new int[] {((StartCompany) buy).getPrice()}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2010-11-09 15:45:53
|
Revision: 1458 http://rails.svn.sourceforge.net/rails/?rev=1458&view=rev Author: evos Date: 2010-11-09 15:45:47 +0000 (Tue, 09 Nov 2010) Log Message: ----------- Replace bank cash display by "BROKEN" once that is the case. Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/rails/game/Bank.java trunk/18xx/rails/game/model/CashModel.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-10-30 12:17:07 UTC (rev 1457) +++ trunk/18xx/LocalisedText.properties 2010-11-09 15:45:47 UTC (rev 1458) @@ -26,7 +26,8 @@ BID=Bid BID_ITEM_LOG={0} bids {1} on {2}. Remaining free cash {3}. BID_ITEM={0} bids {1} on {2}. -BidMustBeMultipleOf=Invalid bid {0}: must be multiple of {1} +BidMustBeMultipleOf=Invalid bid {0}: must be multiple of {1} +BROKEN=BROKEN BUY=Buy BUY_PRIVATE=Buy Private BUY_SHARE_LOG={0} buys a {1}% share of {2} from {3} for {4}. Modified: trunk/18xx/rails/game/Bank.java =================================================================== --- trunk/18xx/rails/game/Bank.java 2010-10-30 12:17:07 UTC (rev 1457) +++ trunk/18xx/rails/game/Bank.java 2010-11-09 15:45:47 UTC (rev 1458) @@ -146,6 +146,7 @@ */ if (money.getCash() <= 0 && !broken.booleanValue()) { broken.set(true); + money.setText(LocalText.getText("BROKEN")); GameManager.getInstance().registerBrokenBank(); } } Modified: trunk/18xx/rails/game/model/CashModel.java =================================================================== --- trunk/18xx/rails/game/model/CashModel.java 2010-10-30 12:17:07 UTC (rev 1457) +++ trunk/18xx/rails/game/model/CashModel.java 2010-11-09 15:45:47 UTC (rev 1458) @@ -2,17 +2,22 @@ package rails.game.model; import rails.game.*; +import rails.game.state.StringState; public class CashModel extends ModelObject { - private int cash; - private CashHolder owner; + protected int cash; + protected CashHolder owner; + /** Text to be displayed instead of the cash amount (if length > 0) */ + protected StringState displayText = new StringState("BankCashDisplayText", ""); + public static final int SUPPRESS_ZERO = 1; public CashModel(CashHolder owner) { cash = 0; this.owner = owner; + displayText.addDependent(this); } public void setCash(int newCash) { @@ -36,7 +41,10 @@ */ @Override public String getText() { - if (cash == 0 && (option & SUPPRESS_ZERO) > 0 + String fixedText = displayText.getText(); + if (!"".equals(fixedText)) { + return fixedText; + } else if (cash == 0 && (option & SUPPRESS_ZERO) > 0 || owner instanceof PublicCompanyI && !((PublicCompanyI) owner).hasStarted()) { return ""; @@ -45,4 +53,7 @@ } } + public void setText (String text) { + displayText.set (text); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |