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()); |