From: Stefan F. <ste...@us...> - 2012-05-08 17:28:50
|
rails/game/PublicCompany.java | 26 ++++++++++--- rails/game/PublicCompanyI.java | 7 +-- rails/ui/swing/MapPanel.java | 79 ++++++++++++++++++++--------------------- readme.txt | 14 +++---- version.number | 2 - 5 files changed, 71 insertions(+), 57 deletions(-) New commits: commit 40bc463df7d20844c2bb9b809e4587acd041b016 Author: Stefan Frey <ste...@we...> Date: Tue May 8 19:26:25 2012 +0200 prepared for release 1.7.4 diff --git a/readme.txt b/readme.txt index 4e4cb96..37d3ce1 100644 --- a/readme.txt +++ b/readme.txt @@ -1,16 +1,14 @@ -Rails release 1.7.3: +Rails release 1.7.4: A new maintenance release for Rails 1.x series This release fixes several recent bugs. -Contributors: Erik Vos, Martin Brumm, Stefan Frey +Contributors: Erik Vos, Stefan Frey -Bugs reported by Arne Osterlund, John David Galt, Volker Schnell +Bugs reported by James Romano, Mike Bourke, Volker Schnell List of bugs fixed: -- Fixed UI bug in 18EU: Missing text on DeclineToBid button -- Fixed bug with picture id (which prevented displaying Goderich -939 tile) -- Fixed wrong behavior of train obsoleting in 1830 Variants (Coalfield and Reading) -- Added text in report window about train rusting and obsoleting - +- 18EU Hamburg red-to-red bonus calculation incorrect +- Fixed exception in Map panel scrolling +- In 1835 Companies with a fixed start price postpone laying the current price token until floating time. diff --git a/version.number b/version.number index 6884297..fdf5bc6 100644 --- a/version.number +++ b/version.number @@ -1,5 +1,5 @@ #Property file that contains version number and the develop indicator -version=1.7.3 +version=1.7.4 # the following string "@DEVELOP@ is replaced by an empty string in the release version # this is done automatically by ant develop=@DEVELOP@ \ No newline at end of file commit b0634f88c4904471a7f07859628017d60b8715d5 Author: Erik Vos <eri...@xs...> Date: Tue May 8 13:55:25 2012 +0200 Companies with a fixed start price postpone laying the current price token until floating time. This applies to 1835 (bug reported by Volker Schnell) and 1825. Only defaults are set. For 1837, an (game or company) attribute must be added to set this rule also for the companies that don't ahve a fixed starting price.(cherry picked from commit d136bf8dd11a71574fee182a00c2f1277370a39d) diff --git a/rails/game/PublicCompany.java b/rails/game/PublicCompany.java index d7643e6..f9f69e3 100644 --- a/rails/game/PublicCompany.java +++ b/rails/game/PublicCompany.java @@ -29,10 +29,10 @@ public class PublicCompany extends Company implements PublicCompanyI { protected static int numberOfPublicCompanies = 0; - // Home base token lay times + // Home base & price token lay times protected static final int WHEN_STARTED = 0; protected static final int WHEN_FLOATED = 1; - protected static final int START_OF_FIRST_OR = 2; + protected static final int START_OF_FIRST_OR = 2; // Only applies to home base tokens // Base token lay cost calculation methods public static final String BASE_COST_SEQUENCE = "sequence"; @@ -235,6 +235,8 @@ public class PublicCompany extends Company implements PublicCompanyI { /*---- variables needed during initialisation -----*/ protected String startSpace = null; + protected int dropPriceToken = WHEN_STARTED; + protected int capitalisation = CAPITALISE_FULL; /** Fixed price (for a 1835-style minor) */ @@ -313,6 +315,11 @@ public class PublicCompany extends Company implements PublicCompanyI { floatPerc = tag.getAttributeAsInteger("floatPerc", floatPerc); startSpace = tag.getAttributeAsString("startspace"); + // Set the default price token drop time. + // Currently, no exceptions exist, so this value isn't changed anywhere yet. + // Any (future) games with exceptions to these defaults will require a separate XML attribute. + // Known games to have exceptions: 1837. + dropPriceToken = startSpace != null ? WHEN_FLOATED : WHEN_STARTED; fixedPrice = tag.getAttributeAsInteger("price", 0); @@ -934,8 +941,12 @@ public class PublicCompany extends Company implements PublicCompanyI { if (startSpace != null) { setParSpace(startSpace); - // The current price is set via the Stock Market - stockMarket.start(this, startSpace); + setCurrentSpace(startSpace); + + // Drop the current price token, if allowed at this point + if (dropPriceToken == WHEN_STARTED) { + stockMarket.start(this, startSpace); + } } @@ -1002,6 +1013,11 @@ public class PublicCompany extends Company implements PublicCompanyI { stockMarket.moveUp(this); } + // Drop the current price token, if allowed at this point + if (dropPriceToken == WHEN_FLOATED) { + stockMarket.start(this, getCurrentSpace()); + } + if (homeBaseTokensLayTime == WHEN_FLOATED) { layHomeBaseTokens(); } @@ -1170,7 +1186,7 @@ public class PublicCompany extends Company implements PublicCompanyI { * stock market. */ public void setCurrentSpace(StockSpaceI price) { - if (price != null) { + if (price != null && price != getCurrentSpace()) { currentPrice.setPrice(price); } } diff --git a/rails/game/PublicCompanyI.java b/rails/game/PublicCompanyI.java index ecd928f..7b28906 100644 --- a/rails/game/PublicCompanyI.java +++ b/rails/game/PublicCompanyI.java @@ -11,12 +11,11 @@ import rails.game.model.*; */ public interface PublicCompanyI extends CompanyI, CashHolder, TokenHolder { + /* Capitalisation options */ public static final int CAPITALISE_FULL = 0; - public static final int CAPITALISE_INCREMENTAL = 1; - public static final int CAPITALISE_WHEN_BOUGHT = 2; - + public void setIndex (int index); @@ -96,7 +95,7 @@ public interface PublicCompanyI extends CompanyI, CashHolder, TokenHolder { */ public boolean hasFloated(); - + public ModelObject getFloatedModel(); /** commit 99b6d76363ed8ab727117f74b5da915d896df2b1 Author: Erik Vos <eri...@xs...> Date: Tue May 8 12:03:06 2012 +0200 Fix exception in Map panel scrolling(cherry picked from commit bd86c17a13a6cb75d35af0d102a740ba7a234bb9) diff --git a/rails/ui/swing/MapPanel.java b/rails/ui/swing/MapPanel.java index 265defe..ba92268 100644 --- a/rails/ui/swing/MapPanel.java +++ b/rails/ui/swing/MapPanel.java @@ -2,9 +2,7 @@ package rails.ui.swing; import java.awt.*; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.KeyEvent; +import java.awt.event.*; import java.util.List; import javax.swing.*; @@ -14,7 +12,8 @@ import org.apache.log4j.Logger; import rails.game.MapManager; import rails.game.action.LayTile; import rails.game.action.LayToken; -import rails.ui.swing.hexmap.*; +import rails.ui.swing.hexmap.HexMap; +import rails.ui.swing.hexmap.HexMapImage; /** * MapWindow class displays the Map Window. It's shocking, I know. @@ -23,31 +22,31 @@ public class MapPanel extends JPanel { private static final long serialVersionUID = 1L; //defines how many pixels should be left as safety margin when calculating fit zooms - private static final int zoomFitSafetyMargin = 4; - + private static final int zoomFitSafetyMargin = 4; + private MapManager mmgr; private HexMap map; private HexMapImage mapImage; private JScrollPane scrollPane; - + private GameUIManager gameUIManager; - + private JLayeredPane layeredPane; private Dimension originalMapSize; private Dimension currentMapSize; - + //active fit-to zoom options private boolean fitToWidth = false; private boolean fitToHeight = false; protected static Logger log = - Logger.getLogger(MapPanel.class.getPackage().getName()); + Logger.getLogger(MapPanel.class.getPackage().getName()); public MapPanel(GameUIManager gameUIManager) { this.gameUIManager = gameUIManager; //Scale.set(15); Scale.set(16); - + setLayout(new BorderLayout()); mmgr = gameUIManager.getGameManager().getMapManager(); @@ -72,7 +71,7 @@ public class MapPanel extends JPanel { layeredPane.setPreferredSize(originalMapSize); map.setBounds(0, 0, originalMapSize.width, originalMapSize.height); map.addLayers(layeredPane, 1); - + if (mmgr.isMapImageUsed()) { mapImage = new HexMapImage (); mapImage.init(mmgr,map); @@ -80,14 +79,14 @@ public class MapPanel extends JPanel { mapImage.setBounds(0, 0, originalMapSize.width, originalMapSize.height); layeredPane.add(mapImage, -1); } - + scrollPane = new JScrollPane(layeredPane); scrollPane.setSize(originalMapSize); add(scrollPane, BorderLayout.CENTER); - + setSize(originalMapSize); setLocation(25, 25); - + //add listener for auto fit upon resize events addComponentListener(new ComponentAdapter() { @Override @@ -98,9 +97,11 @@ public class MapPanel extends JPanel { }); } - + public void scrollPaneShowRectangle(Rectangle rectangle) { - + + if (rectangle == null) return; + JViewport viewport = scrollPane.getViewport(); log.debug("ScrollPane viewPort =" + viewport); @@ -108,23 +109,23 @@ public class MapPanel extends JPanel { log.debug("Map size =" + map.getSize()); log.debug("ScrollPane visibleRect =" + scrollPane.getVisibleRect()); log.debug("viewport size =" + viewport.getSize()); - + double setX, setY; setX = Math.max(0, (rectangle.getCenterX() - viewport.getWidth() / 2)); setY = Math.max(0, (rectangle.getCenterY() - viewport.getHeight() / 2)); - + setX = Math.min(setX, Math.max(0, map.getSize().getWidth() - viewport.getWidth())); setY = Math.min(setY, Math.max(0, map.getSize().getHeight() - viewport.getHeight())); - + final Point viewPosition = new Point((int)setX, (int)setY); log.debug("ViewPosition for ScrollPane = " + viewPosition); SwingUtilities.invokeLater(new Runnable() { public void run() { - scrollPane.getViewport().setViewPosition(viewPosition); + scrollPane.getViewport().setViewPosition(viewPosition); } }); } - + public void setAllowedTileLays(List<LayTile> allowedTileLays) { map.setAllowedTileLays(allowedTileLays); } @@ -147,21 +148,21 @@ public class MapPanel extends JPanel { gameUIManager.getORUIManager().getORPanel().redrawRoutes(); layeredPane.revalidate(); } - + public void zoom (boolean in) { removeFitToOption(); map.zoom(in); adjustToNewMapZoom(); } - + /** * Zoom-to-fit functionality is based on the discrete zoom steps. * In order to achieve correctly fitting zoom, continuous adjustment factors are - * determined on top of that. + * determined on top of that. */ private void zoomFit (boolean fitToWidth, boolean fitToHeight) { if (!fitToWidth && !fitToHeight) return; - + ImageLoader imageLoader = GameUIManager.getImageLoader(); int zoomStep = map.getZoomStep(); @@ -179,7 +180,7 @@ public class MapPanel extends JPanel { //determine which dimension will be the critical one for the resize boolean isWidthCritical = ( !fitToHeight || (fitToWidth && idealFactorWidth < idealFactorHeight)); - + //check whether scrollbar will appear in the fit-to dimension and //reduce available size accordingly (not relevant for fit-to-window) if (isWidthCritical && idealFactorWidth > idealFactorHeight) { @@ -190,7 +191,7 @@ public class MapPanel extends JPanel { height -= scrollPane.getHorizontalScrollBar().getPreferredSize().height; idealFactorHeight = height / originalMapSize.height; } - + //abort resize if no space available if (width < 0 || height < 0) return; @@ -207,7 +208,7 @@ public class MapPanel extends JPanel { imageLoader.getZoomFactor(zoomStep+1) != imageLoader.getZoomFactor(zoomStep) ) zoomStep++; - + //decrease zoomFactor until constraints do hold //OR zoom cannot be decreased any more while @@ -221,44 +222,44 @@ public class MapPanel extends JPanel { imageLoader.getZoomFactor(zoomStep-1) != imageLoader.getZoomFactor(zoomStep) ) zoomStep--; - + //Determine and apply adjustment factor for precise fit double idealFactor = isWidthCritical ? idealFactorWidth : idealFactorHeight; imageLoader.setZoomAdjustmentFactor ( - idealFactor / imageLoader.getZoomFactor(zoomStep)); - + idealFactor / imageLoader.getZoomFactor(zoomStep)); + //trigger zoom execution map.setZoomStep(zoomStep); adjustToNewMapZoom(); } - + private void fitToOption (boolean fitToWidth, boolean fitToHeight) { //ignore if nothing has changed if (this.fitToWidth == fitToWidth && this.fitToHeight == fitToHeight ) return; - + this.fitToWidth = fitToWidth; this.fitToHeight = fitToHeight; zoomFit(fitToWidth, fitToHeight); } - + public void fitToWindow () { fitToOption (true, true); } - + public void fitToWidth () { fitToOption (true, false); } - + public void fitToHeight () { fitToOption (false, true); } - + public void removeFitToOption () { fitToWidth = false; fitToHeight = false; } - + public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1) { HelpWindow.displayHelp(gameUIManager.getHelp()); |
From: Stefan F. <ste...@us...> - 2012-05-30 12:00:37
|
rails/game/MapManager.java | 38 ++++++++++++++++++++++++++-- rails/ui/swing/elements/NonModalDialog.java | 1 readme.txt | 16 ++++++++--- version.number | 2 - 4 files changed, 49 insertions(+), 8 deletions(-) New commits: commit 9304a2d80b3af79420ee214fc2d3699d35f8cffc Author: Stefan Frey <ste...@we...> Date: Wed May 30 13:13:25 2012 +0200 preparations for 1.7.5 release diff --git a/readme.txt b/readme.txt index 37d3ce1..c74b11d 100644 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,4 @@ -Rails release 1.7.4: +Rails release 1.7.5: A new maintenance release for Rails 1.x series @@ -6,9 +6,15 @@ This release fixes several recent bugs. Contributors: Erik Vos, Stefan Frey -Bugs reported by James Romano, Mike Bourke, Volker Schnell +Bugs reported by John David Galt, Mike Bourke, Phil Davies + +New: +1856: Alternate Trains variant added +1856: Alternate Destinations variant added (not fully implemented yet) List of bugs fixed: -- 18EU Hamburg red-to-red bonus calculation incorrect -- Fixed exception in Map panel scrolling -- In 1835 Companies with a fixed start price postpone laying the current price token until floating time. +Phase extra info is reported in report window (e.g. Civil War in 18TN) +Tokens on map are updated after undo/redo +Fixed non-modal dialog bug during loading game +1835: preventing selling double non-president shares in parts. +1835: fixed 1835 hex distance calculation bug diff --git a/version.number b/version.number index fdf5bc6..905b3b7 100644 --- a/version.number +++ b/version.number @@ -1,5 +1,5 @@ #Property file that contains version number and the develop indicator -version=1.7.4 +version=1.7.5 # the following string "@DEVELOP@ is replaced by an empty string in the release version # this is done automatically by ant develop=@DEVELOP@ \ No newline at end of file commit 1e3e6ead6ded8d295f450ea127b118910155cdb6 Author: Erik Vos <eri...@xs...> Date: Mon May 28 15:28:49 2012 +0200 Fixed non-modal dialog bug during loading game. Non-modal dialogs try to center location on the 'parent' window, but centering fails if the parent is not visible. It is now also set visible beforehand.(cherry picked from commit 3429f9f58e6993b09c89f7f56fd4a7230ef1ede9) diff --git a/rails/ui/swing/elements/NonModalDialog.java b/rails/ui/swing/elements/NonModalDialog.java index 36d8581..15a3b37 100644 --- a/rails/ui/swing/elements/NonModalDialog.java +++ b/rails/ui/swing/elements/NonModalDialog.java @@ -83,6 +83,7 @@ public abstract class NonModalDialog extends JDialog implements ActionListener { pack(); // Center on owner + window.setVisible(true); // Window must be visible to find its location! int x = (int) window.getLocationOnScreen().getX() + (window.getWidth() - getWidth()) / 2; int y = (int) window.getLocationOnScreen().getY() commit 9e8781e4e46b8e641adb1022f659dd8f0742521b Author: Erik Vos <eri...@xs...> Date: Mon May 28 12:55:02 2012 +0200 Fixed 1835 hex distance calculation bug. Impassable hex sides are no longer disregarded.(cherry picked from commit 1210bffe332f0f978f828b2e7e38e77cc7267cc4) diff --git a/rails/game/MapManager.java b/rails/game/MapManager.java index dcd9cad..6cd4307 100644 --- a/rails/game/MapManager.java +++ b/rails/game/MapManager.java @@ -325,6 +325,40 @@ public class MapManager implements ConfigurableComponentI { } } + /** Return the hex adjacent to a given hex in a particular direction. + * Return null if that hex does not exist. + * @param hex The hex object for which an adjacent one is searched. + * @param orientation The direction where to look (values 0-5); + * @return The found MapHex object, or null. + */ + public MapHex getAdjacentHex (MapHex hex, int orientation) { + + int x = hex.getX(); + int y = hex.getY(); + int xx = getAdjacentX (x, y, orientation); + int yy = getAdjacentY (x, y, orientation); + + if (xx >= minX && xx <= maxX && yy >= minY && yy <= maxY) { + return hexes[xx][yy]; // null if undefined + } + return null; //outside the map border + } + + /** Return a List of all hexes adjacent to a given hex. + * @param hex The hex object for which all adjacent hexes are searched. + * @return The found list of MapHex objects. Can be empty, not null. + */ + public List<MapHex> getAdjacentHexes (MapHex hex) { + + List<MapHex> adjacentHexes = new ArrayList<MapHex> (); + MapHex adjacentHex; + + for (int i=0; i<6; i++) { + if ((adjacentHex = getAdjacentHex (hex, i)) != null) adjacentHexes.add(adjacentHex); + } + return adjacentHexes; + } + /** * @return Returns the currentTileOrientation. */ @@ -443,7 +477,7 @@ public class MapManager implements ConfigurableComponentI { distances.get(hex1).put(hex2, depth); } - for (MapHex hex3 : hex2.getNeighbors()) { + for (MapHex hex3 : getAdjacentHexes(hex2)) { if (hex3 == null) continue; if (distances.get(hex1).get(hex3) == null) { calculateHexDistances (hex1, hex3, depth+1); @@ -494,7 +528,7 @@ public class MapManager implements ConfigurableComponentI { public int getMapXOffset() { return mapXOffset; } - + public int getMapYOffset() { return mapYOffset; } |