From a2297d91e38127817145c1a8dfedc286ec07dc99 Mon Sep 17 00:00:00 2001 From: Michael Pope Date: Wed, 29 Jul 2015 11:47:09 +0930 Subject: [PATCH 001/323] Strictly derive autosave directory from save directory. --- .../freecol/common/io/FreeColDirectories.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/net/sf/freecol/common/io/FreeColDirectories.java b/src/net/sf/freecol/common/io/FreeColDirectories.java index 50bc4081b..418c2cdeb 100644 --- a/src/net/sf/freecol/common/io/FreeColDirectories.java +++ b/src/net/sf/freecol/common/io/FreeColDirectories.java @@ -515,6 +515,16 @@ public class FreeColDirectories { } } + /** + * Derive the directory for the autosave files from the save directory. + */ + private static void deriveAutosaveDirectory() { + if (autosaveDirectory == null && saveDirectory != null) { + autosaveDirectory = new File(saveDirectory, AUTOSAVE_DIRECTORY); + if (!insistDirectory(autosaveDirectory)) autosaveDirectory = null; + } + } + // Main initialization/bootstrap routines. // These need to be called early before the subsidiary directory @@ -630,9 +640,7 @@ public class FreeColDirectories { saveDirectory = new File(getUserDataDirectory(), SAVE_DIRECTORY); if (!insistDirectory(saveDirectory)) return "main.userDir.fail"; } - - autosaveDirectory = new File(getSaveDirectory(), AUTOSAVE_DIRECTORY); - if (!insistDirectory(autosaveDirectory)) autosaveDirectory = null; + deriveAutosaveDirectory(); userModsDirectory = new File(getUserDataDirectory(), MODS_DIRECTORY); if (!insistDirectory(userModsDirectory)) userModsDirectory = null; @@ -644,7 +652,6 @@ public class FreeColDirectories { : null; } - // Directory accessors. // Where there are supported command line arguments there will also // be a mutator. @@ -843,9 +850,10 @@ public class FreeColDirectories { if (!file.exists() || !file.isFile() || !file.canRead()) return false; } setSavegameFile(file); - setSaveDirectory(file.getParentFile()); - File autoDirectory = new File(getSaveDirectory(), AUTOSAVE_DIRECTORY); - if (insistDirectory(autoDirectory)) autosaveDirectory = autoDirectory; + File parent = file.getParentFile(); + if (parent == null) parent = new File("."); + setSaveDirectory(parent); + deriveAutosaveDirectory(); return true; } From 8342697e76a8eb5a688e3a92e31d6dce8e191afd Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sat, 25 Jul 2015 20:35:12 +0930 Subject: [PATCH 002/323] Pluralization correction for coastal colony limit message. --- data/strings/FreeColMessages.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index 12a641fea..587b8c003 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -1802,7 +1802,7 @@ model.improvement.road.occupationString=R # Limits model.limit.independence.coastalColonies.name=Coastal Colony Limit -model.limit.independence.coastalColonies.description=You need at least %limit% coastal colonies in order to declare independence. +model.limit.independence.coastalColonies.description=You need at least %limit% coastal {{plural:%limit%|one=colony|other=colonies}} in order to declare independence. model.limit.independence.rebels.name=Rebel Limit model.limit.independence.rebels.description=At least %limit%% of your colonists must support independence. model.limit.independence.year.name=Year Limit From 396e080b9f89b9e7e506132c936c0271c8b16a07 Mon Sep 17 00:00:00 2001 From: Michael Pope Date: Wed, 15 Jul 2015 14:01:47 +0930 Subject: [PATCH 003/323] Add colonyCenter message. --- data/strings/FreeColMessages.properties | 1 + src/net/sf/freecol/common/model/Tile.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index 587b8c003..17844af40 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -131,6 +131,7 @@ cargoOnCarrier=Cargo on carrier cashInTreasureTrain=Cash in treasure train clearOrders=Clear orders colonists=Colonists +colonyCenter=colony center colopedia=Colopedia difficulty=Difficulty docks=Docks diff --git a/src/net/sf/freecol/common/model/Tile.java b/src/net/sf/freecol/common/model/Tile.java index a7de4c973..3b14610fb 100644 --- a/src/net/sf/freecol/common/model/Tile.java +++ b/src/net/sf/freecol/common/model/Tile.java @@ -1101,8 +1101,7 @@ public final class Tile extends UnitLocation implements Named, Ownable { StringTemplate t = StringTemplate.template("model.tile.nameLocation"); if (ct == this) { t.addStringTemplate("%location%", - // TODO-post-0.11.4-release: add message - StringTemplate.key("colopedia.terrain.colonyCenterTile")); + StringTemplate.key("colonyCenter")); } else { Direction d = getMap().getDirection(ct, this); if (d == null) return null; From 2ea457c26468e7ed80cf5423191f0d6db7170a78 Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sun, 5 Jul 2015 17:17:52 +0930 Subject: [PATCH 004/323] Distinguish famine (low food) from starvation (no food) in colony warnings. --- data/strings/FreeColMessages.properties | 1 + src/net/sf/freecol/common/model/Colony.java | 32 ++++++++++++--------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index 17844af40..e071c4e2d 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -2527,6 +2527,7 @@ model.colony.colonyStarved=The last colonist in %colony% has starved, leaving th model.colony.customs.sale=The Customs House at %colony% sold: %data%. model.colony.customs.saleData=%amount% %goods% for %gold% model.colony.famineFeared=Famine feared in %colony%. Only %number% turns of food left. +model.colony.starving=%colony% is starving. model.colony.newColonist=New colonist in %colony%. model.colony.newConvert=A new %nation% convert has arrived in %colony%. model.colony.notBuildingAnything=Nothing is being built in %colony%. diff --git a/src/net/sf/freecol/common/model/Colony.java b/src/net/sf/freecol/common/model/Colony.java index 735052a6e..8b280c34c 100644 --- a/src/net/sf/freecol/common/model/Colony.java +++ b/src/net/sf/freecol/common/model/Colony.java @@ -2255,19 +2255,25 @@ public class Colony extends Settlement implements Nameable, TradeLocation { List result = new ArrayList<>(); final int amount = getGoodsCount(goodsType); final int production = getNetProductionOf(goodsType); - - if (goodsType.isFoodType() && goodsType.isStorable()) { - // Food is never wasted -> new settler is produced - if (amount + production < 0) { - result.add(StringTemplate - .template("model.colony.famineFeared") - .addName("%colony%", getName()) - .addAmount("%number%", 0)); - } - } else { - int waste = (amount + production - getWarehouseCapacity()); - if (waste > 0 && !getExportData(goodsType).getExported() - && !goodsType.limitIgnored()) { + int waste; + + if (goodsType.isStorable()) { + if (goodsType.limitIgnored()) { + if (goodsType.isFoodType()) { + int starve = getStarvationTurns(); + if (starve == 0) { + result.add(StringTemplate + .template("model.colony.starving") + .addName("%colony%", getName())); + } else if (starve <= Colony.FAMINE_TURNS) { + result.add(StringTemplate + .template("model.colony.famineFeared") + .addName("%colony%", getName()) + .addAmount("%number%", starve)); + } + } + } else if (!getExportData(goodsType).getExported() + && (waste = amount + production - getWarehouseCapacity()) > 0) { result.add(StringTemplate .template("model.building.warehouseSoonFull") .addNamed("%goods%", goodsType) From 7e726dc768e06b14a8acba4c92e1ea2fc0b20700 Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sun, 5 Jul 2015 16:47:10 +0930 Subject: [PATCH 005/323] Generalize insufficient production warning. --- data/strings/FreeColMessages.properties | 2 +- data/strings/FreeColMessages_qqq.properties | 1 + src/net/sf/freecol/common/model/Colony.java | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index e071c4e2d..7d780e74c 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -2220,7 +2220,7 @@ model.colony.badGovernment=The government of %colony% is inefficient. Production model.colony.goodGovernment=Government efficiency has improved! Rebel sentiment in %colony% now equals or exceeds %number% percent. model.colony.governmentImproved1=The government of %colony% has improved, but is still inefficient. Production penalties still apply. model.colony.governmentImproved2=The government of %colony% has improved. Production penalties no longer apply. -model.colony.insufficientProduction=%outputAmount% more %outputType% could be produced in %colony%, if only we had %inputAmount% more %inputType% surplus. +model.colony.insufficientProduction=%outputAmount% more %outputType% could be produced in %colony%, if an extra %consumptionDeficit% were available. model.colony.lostGoodGovernment=Government efficiency has decreased! Rebel sentiment in %colony% no longer equals or exceeds %number% percent. Colony no longer gains any production bonus. model.colony.lostVeryGoodGovernment=Government efficiency has decreased! Rebel sentiment in %colony% no longer equals or exceeds %number% percent. Some production bonuses were lost. model.colony.minimumColonySize=%object% prevents reducing the population any further. diff --git a/data/strings/FreeColMessages_qqq.properties b/data/strings/FreeColMessages_qqq.properties index 226ad9e76..50368d033 100644 --- a/data/strings/FreeColMessages_qqq.properties +++ b/data/strings/FreeColMessages_qqq.properties @@ -504,6 +504,7 @@ model.unit.unitState.toAmerica=A symbol; shorthand for the action a specific uni model.unit.unitState.toEurope=A symbol; shorthand for the action a specific unit is doing on the map. See [http://www.freecol.org/images/screen-0.8.0-large.jpg example screenshot]. model.noAddReason.ownedByEnemy.description=Эта территория принадлежит другой нации. model.colony.customs.sale=A prefix for customs sales at a colony. The %data% part will be multiple instances of customs.saleData messages. +model.colony.insufficientProduction=Consumption deficit is a comma separated list of goods labels (e.g. "2 furs") model.region.north.name={{Identical|North}} model.region.center.name={{Identical|Center}} main.defaultPlayerName={{Identical|Player name}} diff --git a/src/net/sf/freecol/common/model/Colony.java b/src/net/sf/freecol/common/model/Colony.java index 8b280c34c..f0fa87887 100644 --- a/src/net/sf/freecol/common/model/Colony.java +++ b/src/net/sf/freecol/common/model/Colony.java @@ -2335,13 +2335,14 @@ public class Colony extends Settlement implements Nameable, TradeLocation { List input = info.getConsumptionDeficit(); if (input.isEmpty()) return null; - + StringTemplate label = StringTemplate.label(", "); + for (AbstractGoods ag : input) label.addStringTemplate(ag.getLabel()); + return StringTemplate.template("model.colony.insufficientProduction") .addName("%colony%", getName()) .addNamed("%outputType%", deficit.getType()) .addAmount("%outputAmount%", deficit.getAmount()) - .addNamed("%inputType%", input.get(0).getType()) - .addAmount("%inputAmount%", input.get(0).getAmount()); + .addStringTemplate("%consumptionDeficit%", label); } /** From 37714d165a973ae7fcf275254bd7381649a4618c Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sun, 5 Jul 2015 15:54:58 +0930 Subject: [PATCH 006/323] Add exported goods tooltip to ReportTradePanel. --- data/strings/FreeColMessages.properties | 3 ++- src/net/sf/freecol/client/gui/panel/ReportTradePanel.java | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index 7d780e74c..d9cd85fa1 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -3157,7 +3157,8 @@ report.requirements.surplus=A surplus of %goods% is being produced at report.trade.afterTaxes=Income after taxes report.trade.beforeTaxes=Income before taxes report.trade.cargoUnits=Units in Cargo -report.trade.hasCustomHouse=* This colony has a custom house; these goods are exported. +report.trade.export=Exporting %goods% above %amount% +report.trade.hasCustomHouse=* This colony has a custom house, and may export goods. report.trade.totalDelta=Total Production report.trade.totalUnits=Total Units report.trade.unitsSold=Units bought or sold diff --git a/src/net/sf/freecol/client/gui/panel/ReportTradePanel.java b/src/net/sf/freecol/client/gui/panel/ReportTradePanel.java index 5df300d83..14c44023a 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportTradePanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportTradePanel.java @@ -176,6 +176,13 @@ public final class ReportTradePanel extends ReportPanel { : Utility.CELLBORDER); goodsLabel.setForeground(GoodsLabel.getColor(goodsType, amount, colony)); + ExportData ed = colony.getExportData(goodsType); + if (ed.getExported()) { + goodsLabel.setToolTipText(Messages.message(StringTemplate + .template("report.trade.export") + .addNamed("%goods%", goodsType) + .addAmount("%amount%", ed.getExportLevel()))); + } reportPanel.add(goodsLabel, "cell " + column + " " + row); int production = colony.getNetProductionOf(goodsType); From 5de4460fc3f4c9dc0874bebf2f5e22d2a286dd1a Mon Sep 17 00:00:00 2001 From: Michael Pope Date: Tue, 28 Jul 2015 09:39:39 +0930 Subject: [PATCH 007/323] Enforce IntegerOption limits. --- .../sf/freecol/common/option/IntegerOption.java | 14 +++++++++++++- .../src/net/sf/freecol/common/model/LimitTest.java | 5 +++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/net/sf/freecol/common/option/IntegerOption.java b/src/net/sf/freecol/common/option/IntegerOption.java index 817e90c6e..e205fcfe2 100644 --- a/src/net/sf/freecol/common/option/IntegerOption.java +++ b/src/net/sf/freecol/common/option/IntegerOption.java @@ -102,6 +102,16 @@ public class IntegerOption extends AbstractOption { this.maximumValue = maximumValue; } + /** + * Limit a value with respect to the limits of this option. + * + * @param value The value to limit. + * @return The value limited by the option limits. + */ + public int limitValue(int value) { + return Math.min(Math.max(value, this.minimumValue), this.maximumValue); + } + // Interface Option @@ -131,7 +141,7 @@ public class IntegerOption extends AbstractOption { @Override public void setValue(Integer value) { final int oldValue = this.value; - this.value = value; + this.value = limitValue(value); if (value != oldValue && isDefined) { firePropertyChange(VALUE_TAG, oldValue, (int)value); @@ -189,6 +199,8 @@ public class IntegerOption extends AbstractOption { maximumValue = xr.getAttribute(MAXIMUM_VALUE_TAG, Integer.MAX_VALUE); minimumValue = xr.getAttribute(MINIMUM_VALUE_TAG, Integer.MIN_VALUE); + + this.value = limitValue(this.value); } /** diff --git a/test/src/net/sf/freecol/common/model/LimitTest.java b/test/src/net/sf/freecol/common/model/LimitTest.java index c5b315034..97510c8d5 100644 --- a/test/src/net/sf/freecol/common/model/LimitTest.java +++ b/test/src/net/sf/freecol/common/model/LimitTest.java @@ -135,10 +135,11 @@ public class LimitTest extends FreeColTestCase { assertTrue(colonyLimit.getLeftHandSide().appliesTo(colony)); assertTrue(colonyLimit.evaluate(dutch)); - IntegerOption option = spec().getIntegerOption(GameOptions.LAST_COLONIAL_YEAR); + IntegerOption option = spec() + .getIntegerOption(GameOptions.LAST_COLONIAL_YEAR); + option.setMinimumValue(1300); option.setValue(1300); assertFalse(yearLimit.evaluate(dutch)); - } public void testSuccessionLimits() { From 7aef6f5924e426a3c79176d657b3e06d832a78cd Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Wed, 29 Jul 2015 21:23:25 +0200 Subject: [PATCH 008/323] Simplify setSelectedTile, removing the single use goto clearing --- .../client/control/ConnectController.java | 4 ++-- .../client/control/InGameController.java | 10 ++++----- .../gui/CanvasMapEditorMouseListener.java | 4 ++-- .../client/gui/CanvasMouseListener.java | 12 +++++++++-- src/net/sf/freecol/client/gui/GUI.java | 3 +-- src/net/sf/freecol/client/gui/MapViewer.java | 21 ++++--------------- src/net/sf/freecol/client/gui/SwingGUI.java | 7 +++---- .../client/gui/action/ScaleMapAction.java | 2 +- 8 files changed, 28 insertions(+), 35 deletions(-) diff --git a/src/net/sf/freecol/client/control/ConnectController.java b/src/net/sf/freecol/client/control/ConnectController.java index ed17fd833..3403b6a1f 100644 --- a/src/net/sf/freecol/client/control/ConnectController.java +++ b/src/net/sf/freecol/client/control/ConnectController.java @@ -317,10 +317,10 @@ public final class ConnectController { activeUnit.getOwner().setNextActiveUnit(activeUnit); gui.setActiveUnit(activeUnit); } else { - gui.setSelectedTile(entryTile, false); + gui.setSelectedTile(entryTile); } } else { - gui.setSelectedTile(entryTile, false); + gui.setSelectedTile(entryTile); } } } diff --git a/src/net/sf/freecol/client/control/InGameController.java b/src/net/sf/freecol/client/control/InGameController.java index 2d32955f7..dbbf4ab8d 100644 --- a/src/net/sf/freecol/client/control/InGameController.java +++ b/src/net/sf/freecol/client/control/InGameController.java @@ -853,7 +853,7 @@ public final class InGameController implements NetworkConstants { // just select nothing and wait. ClientOptions options = freeColClient.getClientOptions(); if (tile != null) { - gui.setSelectedTile(tile, false); + gui.setSelectedTile(tile); } else if (options.getBoolean(ClientOptions.AUTO_END_TURN)) { doEndTurn(options.getBoolean(ClientOptions.SHOW_END_TURN_DIALOG)); } @@ -1631,7 +1631,7 @@ public final class InGameController implements NetworkConstants { } if (unit.getMovesLeft() <= 0) return false; displayModelMessages(false); - if (!gui.onScreen(tile)) gui.setSelectedTile(tile, false); + if (!gui.onScreen(tile)) gui.setSelectedTile(tile); return true; } @@ -2563,7 +2563,7 @@ public final class InGameController implements NetworkConstants { if (ret) { player.invalidateCanSeeTiles(); gui.setActiveUnit(null); - gui.setSelectedTile(tile, false); + gui.setSelectedTile(tile); } return ret; } @@ -2727,7 +2727,7 @@ public final class InGameController implements NetworkConstants { if (ret) { player.invalidateCanSeeTiles(); gui.setActiveUnit(null); - gui.setSelectedTile(tile, false); + gui.setSelectedTile(tile); freeColClient.getSoundController() .playSound("sound.event.buildingComplete"); // Check units present for treasure cash-in as they are now @@ -3826,7 +3826,7 @@ public final class InGameController implements NetworkConstants { Tile newTile = tile.getNeighbourOrNull(direction); if (newTile == null) return false; - gui.setSelectedTile(newTile, false); + gui.setSelectedTile(newTile); return true; } diff --git a/src/net/sf/freecol/client/gui/CanvasMapEditorMouseListener.java b/src/net/sf/freecol/client/gui/CanvasMapEditorMouseListener.java index 2282600fb..3b4d4b639 100644 --- a/src/net/sf/freecol/client/gui/CanvasMapEditorMouseListener.java +++ b/src/net/sf/freecol/client/gui/CanvasMapEditorMouseListener.java @@ -139,7 +139,7 @@ public final class CanvasMapEditorMouseListener extends AbstractCanvasListener try { if (e.getButton() == MouseEvent.BUTTON1) { Tile tile = mapViewer.convertToMapTile(e.getX(), e.getY()); - if (tile != null) getGUI().setSelectedTile(tile, false); + if (tile != null) getGUI().setSelectedTile(tile); startPoint = endPoint = null; } else if (e.getButton() == MouseEvent.BUTTON2) { @@ -167,7 +167,7 @@ public final class CanvasMapEditorMouseListener extends AbstractCanvasListener canvas.showEditSettlementDialog(tile.getIndianSettlement()); } } else { - getGUI().setSelectedTile(null, false); + getGUI().setSelectedTile(null); } } } catch (Exception ex) { diff --git a/src/net/sf/freecol/client/gui/CanvasMouseListener.java b/src/net/sf/freecol/client/gui/CanvasMouseListener.java index b471742d0..eac714fa9 100644 --- a/src/net/sf/freecol/client/gui/CanvasMouseListener.java +++ b/src/net/sf/freecol/client/gui/CanvasMouseListener.java @@ -205,7 +205,15 @@ public final class CanvasMouseListener implements ActionListener, MouseListener @Override public void actionPerformed(ActionEvent e) { doubleClickTimer.stop(); - mapViewer.setSelectedTile(mapViewer.convertToMapTile(centerX, centerY), - true); + Tile tile=mapViewer.convertToMapTile(centerX, centerY); + if(mapViewer.getViewMode() == GUI.MOVE_UNITS_MODE) { + // Clear goto order when active unit is on the tile + Unit unit=mapViewer.getActiveUnit(); + if(unit != null && unit.getTile() == tile) { + freeColClient.getInGameController().clearGotoOrders(unit); + mapViewer.updateCurrentPathForActiveUnit(); + } + } + mapViewer.setSelectedTile(tile); } } diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 0c7a3f6d4..7fd44f305 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -1632,8 +1632,7 @@ public class GUI { public void setFocusImmediately(Tile tileToFocus) { } - public boolean setSelectedTile(Tile newTileToSelect, - boolean clearGoToOrders) { + public boolean setSelectedTile(Tile newTileToSelect) { return true; // Pretending again. } diff --git a/src/net/sf/freecol/client/gui/MapViewer.java b/src/net/sf/freecol/client/gui/MapViewer.java index 183856961..f8e202365 100644 --- a/src/net/sf/freecol/client/gui/MapViewer.java +++ b/src/net/sf/freecol/client/gui/MapViewer.java @@ -947,7 +947,7 @@ public final class MapViewer { freeColClient.updateActions(); } else { updateCurrentPathForActiveUnit(); - if (!setSelectedTile(tile, false) + if (!setSelectedTile(tile) || freeColClient.getClientOptions() .getBoolean(ClientOptions.JUMP_TO_ACTIVE_UNIT)) { setFocus(tile); @@ -1064,8 +1064,7 @@ public final class MapViewer { *
  • If there is a {@link Colony} on the {@link Tile} the * {@link Canvas#showColonyPanel} will be invoked. *
  • If the tile contains a unit that can become active, then - * that unit will be set as the active unit, and clear their - * goto orders if clearGoToOrders is true + * that unit will be set as the active unit. *
  • If the two conditions above do not match, then the * selectedTile will become the map focus. * @@ -1074,20 +1073,18 @@ public final class MapViewer { * then nothing (except perhaps a map reposition) will happen. * * @param newTile The Tile, the tile to be selected - * @param clearGoToOrders Use true to clear goto - * orders of the unit which is activated * @return True if the focus was set. * @see #getSelectedTile * @see #setActiveUnit * @see #setFocus(Tile) */ - boolean setSelectedTile(Tile newTile, boolean clearGoToOrders) { + boolean setSelectedTile(Tile newTile) { Tile oldTile = this.selectedTile; boolean ret = false; selectedTile = newTile; if (getViewMode() == GUI.MOVE_UNITS_MODE) { - if (isNoActiveUnitAt(newTile)) { + if (activeUnit == null || activeUnit.getTile() != newTile) { if (newTile != null && newTile.hasSettlement()) { gui.showSettlement(newTile.getSettlement()); return false; @@ -1102,12 +1099,6 @@ public final class MapViewer { setFocus(newTile); ret = true; } - } else { - // Clear goto order when unit is already active - if (clearGoToOrders) { - freeColClient.getInGameController().clearGotoOrders(activeUnit); - updateCurrentPathForActiveUnit(); - } } } @@ -2498,10 +2489,6 @@ public final class MapViewer { && tile.getX() >= leftColumn && tile.getX() <= rightColumn; } - private boolean isNoActiveUnitAt(Tile tile) { - return activeUnit == null || activeUnit.getTile() != tile; - } - /** * Draws the borders of a territory on the given Tile. The * territory is either a country or a region. diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index 14c27a3fb..93ed20483 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -204,7 +204,7 @@ public class SwingGUI extends GUI { canvas.initializeInGame(); enableMapControls(freeColClient.getClientOptions() .getBoolean(ClientOptions.DISPLAY_MAP_CONTROLS)); - setSelectedTile(tile, false); + setSelectedTile(tile); } /** @@ -1658,9 +1658,8 @@ public class SwingGUI extends GUI { } @Override - public boolean setSelectedTile(Tile newTileToSelect, - boolean clearGoToOrders) { - return mapViewer.setSelectedTile(newTileToSelect, clearGoToOrders); + public boolean setSelectedTile(Tile newTileToSelect) { + return mapViewer.setSelectedTile(newTileToSelect); } @Override diff --git a/src/net/sf/freecol/client/gui/action/ScaleMapAction.java b/src/net/sf/freecol/client/gui/action/ScaleMapAction.java index 326bf09f1..65718ebb7 100644 --- a/src/net/sf/freecol/client/gui/action/ScaleMapAction.java +++ b/src/net/sf/freecol/client/gui/action/ScaleMapAction.java @@ -96,7 +96,7 @@ public class ScaleMapAction extends FreeColAction { t.getTileItemContainer().updateRiver(); }*/ - getGUI().setSelectedTile(map.getTile(0, 0), false); + getGUI().setSelectedTile(map.getTile(0, 0)); getGUI().refresh(); } From 167ecf98618f50493751ed06db8b7355d033e2bf Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Thu, 30 Jul 2015 19:18:38 +0930 Subject: [PATCH 009/323] Work around the lakes work around, BR#2878. --- .../sf/freecol/server/model/ServerRegion.java | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/src/net/sf/freecol/server/model/ServerRegion.java b/src/net/sf/freecol/server/model/ServerRegion.java index 9f66efd26..5ac429456 100644 --- a/src/net/sf/freecol/server/model/ServerRegion.java +++ b/src/net/sf/freecol/server/model/ServerRegion.java @@ -96,6 +96,21 @@ public class ServerRegion extends Region { this.setDiscoverable(true); } + /** + * Create a new fixed server region. + * + * @param map The Map to create in. + * @param key The key for the region. + * @param type The RegionType to use. + * @param parent The Region to be the parent of this one. + */ + private ServerRegion(Map map, String key, RegionType type, + Region parent) { + this(map.getGame(), key, type, parent); + + map.addRegion(this); + } + /** * Create a new fixed server region. * @@ -118,7 +133,6 @@ public class ServerRegion extends Region { this.discoveredIn = null; this.discoveredBy = null; this.scoreValue = 0; - game.getMap().addRegion(this); } @@ -241,7 +255,7 @@ public class ServerRegion extends Region { final int arcticHeight = Map.POLAR_HEIGHT; ServerRegion arctic = (ServerRegion)fixed.get("model.region.arctic"); if (arctic == null) { - arctic = new ServerRegion(game, "model.region.arctic", + arctic = new ServerRegion(map, "model.region.arctic", RegionType.LAND, null); for (int x = 0; x < map.getWidth(); x++) { for (int y = 0; y < arcticHeight; y++) { @@ -257,7 +271,7 @@ public class ServerRegion extends Region { final int antarcticHeight = map.getHeight() - Map.POLAR_HEIGHT - 1; ServerRegion antarctic = (ServerRegion)fixed.get("model.region.antarctic"); if (antarctic == null) { - antarctic = new ServerRegion(game, "model.region.antarctic", + antarctic = new ServerRegion(map, "model.region.antarctic", RegionType.LAND, null); for (int x = 0; x < map.getWidth(); x++) { for (int y = antarcticHeight; y < map.getHeight(); y++) { @@ -282,7 +296,7 @@ public class ServerRegion extends Region { ServerRegion northWest = (ServerRegion)fixed.get("model.region.northWest"); if (northWest == null) { - northWest = new ServerRegion(game, "model.region.northWest", + northWest = new ServerRegion(map, "model.region.northWest", RegionType.LAND, null); northWest.bounds.setBounds(new Rectangle(0,0,thirdWidth,thirdHeight)); lb.add("+NW"); @@ -291,7 +305,7 @@ public class ServerRegion extends Region { ServerRegion north = (ServerRegion)fixed.get("model.region.north"); if (north == null) { - north = new ServerRegion(game, "model.region.north", + north = new ServerRegion(map, "model.region.north", RegionType.LAND, null); north.bounds.setBounds(new Rectangle(thirdWidth,0,thirdWidth,thirdHeight)); lb.add("+N"); @@ -300,7 +314,7 @@ public class ServerRegion extends Region { ServerRegion northEast = (ServerRegion)fixed.get("model.region.northEast"); if (northEast == null) { - northEast = new ServerRegion(game, "model.region.northEast", + northEast = new ServerRegion(map, "model.region.northEast", RegionType.LAND, null); northEast.bounds.setBounds(new Rectangle(twoThirdWidth,0,thirdWidth,thirdHeight)); lb.add("+NE"); @@ -309,7 +323,7 @@ public class ServerRegion extends Region { ServerRegion west = (ServerRegion)fixed.get("model.region.west"); if (west == null) { - west = new ServerRegion(game, "model.region.west", + west = new ServerRegion(map, "model.region.west", RegionType.LAND, null); west.bounds.setBounds(new Rectangle(0,thirdHeight,thirdWidth,thirdHeight)); lb.add("+W"); @@ -318,7 +332,7 @@ public class ServerRegion extends Region { ServerRegion center = (ServerRegion)fixed.get("model.region.center"); if (center == null) { - center = new ServerRegion(game, "model.region.center", + center = new ServerRegion(map, "model.region.center", RegionType.LAND, null); center.bounds.setBounds(new Rectangle(thirdWidth,thirdHeight,thirdWidth,thirdHeight)); lb.add("+center"); @@ -327,7 +341,7 @@ public class ServerRegion extends Region { ServerRegion east = (ServerRegion)fixed.get("model.region.east"); if (east == null) { - east = new ServerRegion(game, "model.region.east", + east = new ServerRegion(map, "model.region.east", RegionType.LAND, null); east.bounds.setBounds(new Rectangle(twoThirdWidth,thirdHeight,thirdWidth,thirdHeight)); lb.add("+E"); @@ -336,7 +350,7 @@ public class ServerRegion extends Region { ServerRegion southWest = (ServerRegion)fixed.get("model.region.southWest"); if (southWest == null) { - southWest = new ServerRegion(game, "model.region.southWest", + southWest = new ServerRegion(map, "model.region.southWest", RegionType.LAND, null); southWest.bounds.setBounds(new Rectangle(0,twoThirdHeight,thirdWidth,thirdHeight)); lb.add("+SW"); @@ -345,7 +359,7 @@ public class ServerRegion extends Region { ServerRegion south = (ServerRegion)fixed.get("model.region.south"); if (south == null) { - south = new ServerRegion(game, "model.region.south", + south = new ServerRegion(map, "model.region.south", RegionType.LAND, null); south.bounds.setBounds(new Rectangle(thirdWidth,twoThirdHeight,thirdWidth,thirdHeight)); lb.add("+S"); @@ -354,7 +368,7 @@ public class ServerRegion extends Region { ServerRegion southEast = (ServerRegion)fixed.get("model.region.southEast"); if (southEast == null) { - southEast = new ServerRegion(game, "model.region.southEast", + southEast = new ServerRegion(map, "model.region.southEast", RegionType.LAND, null); southEast.bounds.setBounds(new Rectangle(twoThirdWidth,twoThirdHeight,thirdWidth,thirdHeight)); lb.add("+SE"); @@ -364,7 +378,7 @@ public class ServerRegion extends Region { boolean allOceans = true; ServerRegion pacific = (ServerRegion)fixed.get("model.region.pacific"); if (pacific == null) { - pacific = new ServerRegion(game, "model.region.pacific", + pacific = new ServerRegion(map, "model.region.pacific", RegionType.OCEAN, null); pacific.setDiscoverable(true); pacific.setScoreValue(PACIFIC_SCORE_VALUE); @@ -374,7 +388,7 @@ public class ServerRegion extends Region { result.add(pacific); ServerRegion northPacific = (ServerRegion)fixed.get("model.region.northPacific"); if (northPacific == null) { - northPacific = new ServerRegion(game, "model.region.northPacific", + northPacific = new ServerRegion(map, "model.region.northPacific", RegionType.OCEAN, pacific); northPacific.setDiscoverable(false); // discovers parent allOceans = false; @@ -383,7 +397,7 @@ public class ServerRegion extends Region { result.add(northPacific); ServerRegion southPacific = (ServerRegion)fixed.get("model.region.southPacific"); if (southPacific == null) { - southPacific = new ServerRegion(game, "model.region.southPacific", + southPacific = new ServerRegion(map, "model.region.southPacific", RegionType.OCEAN, pacific); southPacific.setDiscoverable(false); // discovers parent allOceans = false; @@ -393,7 +407,7 @@ public class ServerRegion extends Region { ServerRegion atlantic = (ServerRegion)fixed.get("model.region.atlantic"); if (atlantic == null) { - atlantic = new ServerRegion(game, "model.region.atlantic", + atlantic = new ServerRegion(map, "model.region.atlantic", RegionType.OCEAN, null); atlantic.setDiscoverable(false); allOceans = false; @@ -402,7 +416,7 @@ public class ServerRegion extends Region { result.add(atlantic); ServerRegion northAtlantic = (ServerRegion)fixed.get("model.region.northAtlantic"); if (northAtlantic == null) { - northAtlantic = new ServerRegion(game, "model.region.northAtlantic", + northAtlantic = new ServerRegion(map, "model.region.northAtlantic", RegionType.OCEAN, atlantic); northAtlantic.setDiscoverable(false); allOceans = false; @@ -411,7 +425,7 @@ public class ServerRegion extends Region { result.add(northAtlantic); ServerRegion southAtlantic = (ServerRegion)fixed.get("model.region.southAtlantic"); if (southAtlantic == null) { - southAtlantic = new ServerRegion(game, "model.region.southAtlantic", + southAtlantic = new ServerRegion(map, "model.region.southAtlantic", RegionType.OCEAN, atlantic); southAtlantic.setDiscoverable(false); allOceans = false; From cbb348dd4a6c0d3a39a933d83834de362499360a Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sun, 5 Jul 2015 17:32:51 +0930 Subject: [PATCH 010/323] Implement tooltips for the summary fields in RCCP. --- .../client/gui/panel/ReportCompactColonyPanel.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java index 9da827587..8cdebdc92 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java @@ -667,17 +667,19 @@ public final class ReportCompactColonyPanel extends ReportPanel break; case PRODUCTION: c = cWarn; - t = stpld("report.colony.production") + t = stpld("report.colony.production.maxProduction") .addName("%colony%", s.colony.getName()) .addNamed("%goods%", gt) - .addAmount("%amount%", gp.amount); + .addAmount("%amount%", gp.amount) + .addAmount("%more%", gp.extra); break; case CONSUMPTION: c = cWarn; - t = stpld("report.colony.production") + t = stpld("report.colony.production.maxConsumption") .addName("%colony%", s.colony.getName()) .addNamed("%goods%", gt) - .addAmount("%amount%", gp.amount); + .addAmount("%amount%", gp.amount) + .addAmount("%more%", gp.extra); break; default: throw new IllegalStateException("Bogus status: " + gp.status); From 250c2f0eae30fce9ccca13b502fc63bfc9338035 Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Thu, 16 Jul 2015 20:07:30 +0930 Subject: [PATCH 011/323] Add RCCP summary tooltips. --- .../gui/panel/ReportCompactColonyPanel.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java index 8cdebdc92..4af9b6cac 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java @@ -893,13 +893,15 @@ public final class ReportCompactColonyPanel extends ReportPanel // Colour: Plain t = mapEntriesByValue(rRegionMap, descendingIntegerComparator) .get(0).getKey().getLabel(); - reportPanel.add(newLabel(Messages.message(t), null, cPlain, null), + reportPanel.add(newLabel(Messages.message(t), null, cPlain, + stpld("report.colony.name.summary")), "newline"); // Field: The total of the size change field. // Colour: cGood if efficient/cAlarm if inefficient. reportPanel.add(newLabel(Integer.toString(rSizeChange), null, - (rSizeChange < 0) ? cAlarm : cGood, null)); + (rSizeChange < 0) ? cAlarm : cGood, + stpld("report.colony.growing.summary"))); // Field: The number of potential colony tiles that need // exploring. @@ -911,7 +913,8 @@ public final class ReportCompactColonyPanel extends ReportPanel } } reportPanel.add((tiles.isEmpty()) ? new JLabel() - : newLabel(Integer.toString(tiles.size()), null, cAlarm, null)); + : newLabel(Integer.toString(tiles.size()), null, cAlarm, + stpld("report.colony.exploring.summary"))); // Fields: The number of existing colony tiles that would // benefit from improvements. @@ -926,7 +929,9 @@ public final class ReportCompactColonyPanel extends ReportPanel } } reportPanel.add((tiles.isEmpty()) ? new JLabel() - : newLabel(Integer.toString(tiles.size()), null, cAlarm, null)); + : newLabel(Integer.toString(tiles.size()), null, cAlarm, + stpld("report.colony.tile." + ti.getSuffix() + + ".summary"))); } // Fields: The net production of each storable+non-trade-goods @@ -952,13 +957,16 @@ public final class ReportCompactColonyPanel extends ReportPanel throw new IllegalStateException("Bogus status: " + gp.status); } reportPanel.add((c == null) ? new JLabel() - : newLabel(Integer.toString(gp.amount), null, c, null)); + : newLabel(Integer.toString(gp.amount), null, c, + stpld("report.colony.production.summary") + .addNamed("%goods%", gt))); } // Field: New colonist arrival or famine warning. // Colour: cWarn if negative, else cGood reportPanel.add(newLabel(Integer.toString((int)rNewColonist), null, - (rNewColonist < 0) ? cWarn : cGood, null)); + (rNewColonist < 0) ? cWarn : cGood, + stpld("report.colony.arriving.summary"))); // Field: The required goods rates. // Colour: cPlain @@ -967,18 +975,22 @@ public final class ReportCompactColonyPanel extends ReportPanel : mapEntriesByValue(rNeeded, descendingDoubleComparator)) { labels.add(newLabel(String.format("%4.1f %s", e.getValue(), Messages.getName(e.getKey())), - null, cPlain, null)); + null, cPlain, + stpld("report.colony.making.summary") + .addNamed("%goods%", e.getKey()))); } // Field: What is being trained (attached to previous) // Colour: cPlain. teacherLen = Math.max(3, teacherLen); // Always some room here - labels.addAll(unitTypeLabels(rTeachers, teacherLen, null)); + labels.addAll(unitTypeLabels(rTeachers, teacherLen, + stpld("report.colony.making.educating.summary"))); addTogether(labels); // Field: The units that could be upgraded, followed by the units // that could be added. - addTogether(unitTypeLabels(rImprove, improveLen, null)); + addTogether(unitTypeLabels(rImprove, improveLen, + stpld("report.colony.improving.summary"))); } private List unitTypeLabels(Map unitTypeMap, From 7fe4c5f3d6c1dd79250d203b8b5a437c7a1fbef6 Mon Sep 17 00:00:00 2001 From: Michael Pope Date: Thu, 16 Jul 2015 09:06:22 +0930 Subject: [PATCH 012/323] Fix messages for getTileImprovementSuggestions. --- .../gui/panel/ReportCompactColonyPanel.java | 40 ++++++++++--------- .../gui/panel/ReportRequirementsPanel.java | 25 +++++------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java index 4af9b6cac..f09e0e9ba 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java @@ -580,17 +580,27 @@ public final class ReportCompactColonyPanel extends ReportPanel } if (n > 0) { c = cAlarm; - // TODO-post-0.11.4-release: temporary hack until 0.11.4-release - String key = ("model.improvement.plow".equals(ti.getId()) - || "model.improvement.clearForest".equals(ti.getId())) - ? "report.colony.plowing" - : ("model.improvement.road".equals(ti.getId())) - ? "report.colony.roadBuilding" - : null; - t = (key == null) ? null : stpld(key) - .addName("%colony%", s.colony.getName()) - .addAmount("%amount%", n); - // end temporary hack + if (n == 1) { + TileImprovementSuggestion tis = s.tileSuggestions.get(0); + for (Unit u : tis.tile.getUnitList()) { + if (u.getState() == Unit.UnitState.IMPROVING + && u.getWorkImprovement() != null + && u.getWorkImprovement().getType() + == tis.tileImprovementType) { + c = cWarn; // Work is underway + break; + } + } + t = stpld("report.colony.tile." + ti.getSuffix() + + ".specific") + .addName("%colony%", s.colony.getName()) + .addStringTemplate("%location%", + tis.tile.getColonyTileLocationLabel(s.colony)); + } else { + t = stpld("report.colony.tile." + ti.getSuffix()) + .addName("%colony%", s.colony.getName()) + .addAmount("%amount%", n); + } b = newButton(cac, Integer.toString(n), null, c, t); if (center) b.setFont(b.getFont().deriveFont(Font.BOLD)); } else { @@ -1028,13 +1038,7 @@ public final class ReportCompactColonyPanel extends ReportPanel stpld("report.colony.explore"))); for (TileImprovementType ti : this.spec.getTileImprovementTypeList()) { if (ti.isNatural()) continue; - // TODO-post-0.11.4-release: temporary hack until 0.11.4-release - String key = (("model.improvement.plow".equals(ti.getId())) - ? "report.colony.plow" - : ("model.improvement.road".equals(ti.getId())) - ? "report.colony.road" - : null) + ".header"; - // end temporary hack + String key = "report.colony.tile." + ti.getSuffix() + ".header"; reportPanel.add(newLabel(key, null, null, stpld(key))); } for (GoodsType gt : this.goodsTypes) { diff --git a/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java b/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java index d365becfb..83de5e9ea 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java @@ -190,20 +190,17 @@ public final class ReportRequirementsPanel extends ReportPanel { List tileSuggestions = colony.getTileImprovementSuggestions(); for (TileImprovementSuggestion tis : tileSuggestions) { - // TODO-post-0.11.4-release: temporary hack until 0.11.4-release - String key = (tis.isExploration()) - ? "report.requirements.exploreTile" - : ("model.improvement.plow".equals(tis.tileImprovementType.getId())) - ? ((tis.tile == colony.getTile()) - ? "report.requirements.plowCenter" - : "report.requirements.plowTile") - : ("model.improvement.clearForest".equals(tis.tileImprovementType.getId())) - ? "report.requirements.clearTile" - : ("model.improvement.road".equals(tis.tileImprovementType.getId())) - ? "report.requirements.roadTile" - : null; - // end temporary hack - addTileWarning(doc, colony, key, tis.tile); + if (tis.tileImprovementType == null) { + addTileWarning(doc, colony, "report.requirements.exploreTile", + tis.tile); + } else { + String key = "report.requirements.tile." + + tis.tileImprovementType.getSuffix(); + if (tis.tile == colony.getTile()) key += ".center"; + if (Messages.containsKey(key)) { + addTileWarning(doc, colony, key, tis.tile); + } + } } if (tileSuggestions.isEmpty() From fd3fd306b33ecc3bdfb2db1899960da22f801876 Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sat, 11 Jul 2015 20:45:22 +0930 Subject: [PATCH 013/323] Add work location to RCCP suggestion tool tips. --- .../client/gui/panel/ReportCompactColonyPanel.java | 4 ++++ src/net/sf/freecol/common/model/WorkLocation.java | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java index f09e0e9ba..db386d360 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java @@ -826,12 +826,16 @@ public final class ReportCompactColonyPanel extends ReportPanel ? stpld("report.colony.wanting") .addName("%colony%", colony.getName()) .addNamed("%unit%", type) + .addStringTemplate("%location%", + suggestion.workLocation.getLabel()) .addNamed("%goods%", suggestion.goodsType) .addAmount("%amount%", suggestion.amount) : stpld("report.colony.improving") .addName("%colony%", colony.getName()) .addNamed("%oldUnit%", suggestion.oldType) .addNamed("%unit%", type) + .addStringTemplate("%location%", + suggestion.workLocation.getLabel()) .addNamed("%goods%", suggestion.goodsType) .addAmount("%amount%", suggestion.amount); JButton b = newButton(cac, label, icon, diff --git a/src/net/sf/freecol/common/model/WorkLocation.java b/src/net/sf/freecol/common/model/WorkLocation.java index b24d95f53..22307982d 100644 --- a/src/net/sf/freecol/common/model/WorkLocation.java +++ b/src/net/sf/freecol/common/model/WorkLocation.java @@ -74,6 +74,7 @@ public abstract class WorkLocation extends UnitLocation } }; + public final WorkLocation workLocation; public final UnitType oldType; public final UnitType newType; public final GoodsType goodsType; @@ -86,6 +87,8 @@ public abstract class WorkLocation extends UnitLocation * could produce amount more * goodsType. * + * @param workLocation The WorkLocation to add + * a unit to. * @param oldType The optional UnitType currently * doing the work. * @param newType A new UnitType to do the work. @@ -93,8 +96,9 @@ public abstract class WorkLocation extends UnitLocation * @param amount The extra goods that would be produced if the * suggestion is taken. */ - public Suggestion(UnitType oldType, UnitType newType, - GoodsType goodsType, int amount) { + public Suggestion(WorkLocation workLocation, UnitType oldType, + UnitType newType, GoodsType goodsType, int amount) { + this.workLocation = workLocation; this.oldType = oldType; this.newType = newType; this.goodsType = goodsType; @@ -358,7 +362,7 @@ public abstract class WorkLocation extends UnitLocation } } return (!ok) ? null - : new Suggestion((unit == null) ? null : unit.getType(), + : new Suggestion(this, (unit == null) ? null : unit.getType(), better, goodsType, delta); } From 4adfbd55f89cd5078a0fb80e615c2fc7f05d71ef Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Thu, 16 Jul 2015 20:03:41 +0930 Subject: [PATCH 014/323] Add messages for RCCP improvements. --- data/mods/plantForest/ModMessages.properties | 6 +++ data/strings/FreeColMessages.properties | 55 ++++++++++++++------ 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/data/mods/plantForest/ModMessages.properties b/data/mods/plantForest/ModMessages.properties index 4c6e34a94..656832aa5 100644 --- a/data/mods/plantForest/ModMessages.properties +++ b/data/mods/plantForest/ModMessages.properties @@ -3,3 +3,9 @@ model.improvement.plantForest.action=Plant forest model.improvement.plantForest.occupationString=f plantForestAction.name=Plant forest plantForestAction.accelerator= +report.requirements.tile.plantForest=%type% to the %direction% of %colony% would benefit from planting a new forest. +report.requirements.tile.plantForest.center=%colony% would benefit from plant a forest on its tile. +report.colony.tile.plantForest.description=%colony% would benefit from reforesting {{plural:%amount%|one=one tile|other=%amount% tiles}} +report.colony.tile.plantForest.specific.description=%colony% would benefit from reforesting %location% +report.colony.tile.plantForest.header=f +report.colony.tile.plantForest.header.description=Number of colony tiles that would benefit from reforestation. diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index d9cd85fa1..fc3bff7d3 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -3035,40 +3035,59 @@ report.labour.workingAsOther=other # ReportColonyPanel # reuses colonyPanel.currentlyBuilding report.colony.arriving.description=%colony%: new %unit% {{plural:%turns%|one=next turn|other=in %turns% turns}} +report.colony.arriving.summary.description=The average number of turns before a new colonist arrives in the colonies of this continent report.colony.birth.description=Number of turns until a new colonist arrives or starves report.colony.explore.description=Number of tiles to Explore adjacent to this colony report.colony.explore.header=E report.colony.exploring.description=%colony% would benefit from exploring {{plural:%amount%|one=one tile|other=%amount% tiles}} +report.colony.exploring.summary.description=Total number of colony tiles that would benefit from exploring for this continent. report.colony.grow.description=Number of units the colony can grow by without harming production report.colony.grow.header=+ report.colony.growing.description=%colony% can grow by {{plural:%amount%|one=one unit|other=%amount% units}} without harming production +report.colony.growing.summary.description=The total number of colonists that can join colonies of this continent without harming production report.colony.improve.description=Units that could improve production. report.colony.improve.header=Improve -report.colony.improving.description=%colony%: To make %amount% more %goods%, replace %oldUnit% with %unit% -report.colony.wanting.description=%colony%: To make %amount% more %goods%, add %unit% +report.colony.improving.description=%colony% %location%: To make %amount% more %goods%, replace %oldUnit% with %unit% +report.colony.improving.summary.description=Units (type and count) that would benefit colonies of this continent report.colony.making.blocking.description=%colony%: %amount% %goods% needed for %buildable% {{plural:%turns%|one=next turn|other=in %turns% turns}} report.colony.making.constructing.description=%colony%: %buildable% completes {{plural:%turns%|one=next turn|other=in %turns% turns}} report.colony.making.description=What this colony is making report.colony.making.educating.description=%colony%: %teacher% graduates {{plural:%turns%|one=next turn|other=in %turns% turns}} +report.colony.making.educating.summary.description=Units (type and count) expected to graduate from schools of this continent report.colony.making.header=Making report.colony.making.noconstruction.description=%colony%: No construction occurring report.colony.making.noteach.description=%colony%: %teacher% lacks a student +report.colony.making.summary.description=The per turn %goods% deficit due to the unsatisfied building requirements of this continent report.colony.name.description=The list of colonies report.colony.name.header=Colony -report.colony.plow.description=Number of colony tiles that would benefit from Plowing -report.colony.plow.header=P -report.colony.plowing.description=%colony% would benefit from plowing {{plural:%amount%|one=one tile|other=%amount% tiles}} -report.colony.production.description=%colony%: net %goods% production = %amount% -report.colony.production.export.description=%colony%: net %goods% production is %amount% (exporting above %export%) +report.colony.name.summary.description=The region containing more of the above colonies of this continent +report.colony.production.description=%colony%: %amount% %goods% are being produced +report.colony.production.export.description=%colony%: %amount% %goods% are being produced (exporting above %export%) report.colony.production.header=Net %goods% production -report.colony.production.high.description=%colony%: net %goods% production = %amount%, full {{plural:%turns%|one=next turn|other=in %turns% turns}} -report.colony.production.low.description=%colony%: net %goods% production = %amount%, gone {{plural:%turns%|one=next turn|other=in %turns% turns}} -report.colony.production.waste.description=%colony%: net %goods% production = %amount%, warehouse will overflow, %waste% will be wasted -report.colony.road.description=Number of colony tiles that would benefit from Road building -report.colony.road.header=R -report.colony.roadBuilding.description=%colony% would benefit from building {{plural:%amount%|one=a road|other=%amount% roads}} +report.colony.production.high.description=%colony%: %amount% %goods% are being produced, full {{plural:%turns%|one=next turn|other=in %turns% turns}} +report.colony.production.low.description=%colony%: %amount% %goods% are being consumed, gone {{plural:%turns%|one=next turn|other=in %turns% turns}} +report.colony.production.maxConsumption.description=%colony%: %amount% %goods% are being consumed (could consume %more% more) +report.colony.production.maxProduction.description=%colony%: %amount% %goods% are being produced (could produce %more% more) +report.colony.production.summary.description=The amount of goods being produced or consumed +report.colony.production.waste.description=%colony%: %amount% %goods% are being produced, warehouse will overflow, %waste% will be wasted +report.colony.tile.clearForest.description=%colony% would benefit from clearing {{plural:%amount%|one=one tile|other=%amount% tiles}} +report.colony.tile.clearForest.specific.description=%colony% would benefit from clearing %location% +report.colony.tile.clearForest.header=C +report.colony.tile.clearForest.header.description=Number of colony tiles that would benefit from clearing. +report.colony.tile.clearForest.summary.description=Total number of colony tiles that would benefit from clearing for this continent. +report.colony.tile.plow.description=%colony% would benefit from plowing {{plural:%amount%|one=one tile|other=%amount% tiles}} +report.colony.tile.plow.specific.description=%colony% would benefit from plowing %location% +report.colony.tile.plow.header=P +report.colony.tile.plow.header.description=Number of colony tiles that would benefit from plowing. +report.colony.tile.plow.summary.description=Total number of colony tiles that would benefit from plowing for this continent. +report.colony.tile.road.description=%colony% would benefit from building {{plural:%amount%|one=a road|other=%amount% roads}} +report.colony.tile.road.specific.description=%colony% would benefit from building a road at %location% +report.colony.tile.road.header=R +report.colony.tile.road.header.description=Number of colony tiles that would benefit from road building. +report.colony.tile.road.summary.description=Total number of colony tiles that would benefit from road building for this continent. report.colony.shrinking.description=%colony% must shrink by {{plural:%amount%|one=one unit|other=%amount% units}} to improve production report.colony.starving.description=%colony%: starvation {{plural:%turns%|one=next turn|other=in %turns% turns}} +report.colony.wanting.description=%colony% %location%: To make %amount% more %goods%, add %unit% # ReportContinentalCongressPanel report.continentalCongress.available=Available @@ -3141,15 +3160,17 @@ report.production.update=Update # ReportRequirementsPanel report.requirements.badAssignment=%colony% has a %expert% currently working as %expertWork%, while a %nonExpert% is working as %nonExpertWork%. Production would be greater if the colonists swapped jobs. report.requirements.canTrainExperts={{plural:2|%unit%}} can be trained at -report.requirements.clearTile=%type% to the %direction% of %colony% would benefit from clearing. report.requirements.exploreTile=%type% to the %direction% of %colony% would benefit from exploration. report.requirements.met=All requirements are met. report.requirements.missingGoods=%colony% is producing %goods%, but requires more %input%. report.requirements.misusedExperts=There are {{plural:2|%unit%}} not working as %work% present at report.requirements.noExpert=%colony% is producing %goods%, but has no %unit%. -report.requirements.plowCenter=%colony% would benefit from plowing its tile. -report.requirements.plowTile=%type% to the %direction% of %colony% would benefit from plowing. -report.requirements.roadTile=%type% to the %direction% of %colony% would benefit from road building. +report.requirements.tile.clearForest=%type% to the %direction% of %colony% would benefit from clearing. +report.requirements.tile.clearForest.center=%colony% would benefit from clearing its tile. +report.requirements.tile.plow=%type% to the %direction% of %colony% would benefit from plowing. +report.requirements.tile.plow.center=%colony% would benefit from plowing its tile. +report.requirements.tile.road=%type% to the %direction% of %colony% would benefit from road building. +#report.requirements.tile.road.center can not happen report.requirements.severalExperts=Several {{plural:2|%unit%}} are present at report.requirements.surplus=A surplus of %goods% is being produced at From b8c21dc23c2b239506ab14693bc998cc38d8c81a Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 17:12:28 +0200 Subject: [PATCH 015/323] Remove opening of colony/settlement panel in MapViewer.setSelectedTile, fixing remaining part of BR#2875 --- .../freecol/client/control/InGameController.java | 4 +++- .../sf/freecol/client/gui/CanvasMouseListener.java | 5 +++++ src/net/sf/freecol/client/gui/MapViewer.java | 14 +++----------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/net/sf/freecol/client/control/InGameController.java b/src/net/sf/freecol/client/control/InGameController.java index dbbf4ab8d..556c66461 100644 --- a/src/net/sf/freecol/client/control/InGameController.java +++ b/src/net/sf/freecol/client/control/InGameController.java @@ -2727,6 +2727,8 @@ public final class InGameController implements NetworkConstants { if (ret) { player.invalidateCanSeeTiles(); gui.setActiveUnit(null); + gui.showColonyPanel((Colony)tile.getSettlement(), unit); + // FIXME: Check if next line can be removed or replaced gui.setSelectedTile(tile); freeColClient.getSoundController() .playSound("sound.event.buildingComplete"); @@ -2960,7 +2962,7 @@ public final class InGameController implements NetworkConstants { * Clears the goto orders of the given unit by setting its destination * to null. * - * Called from MapViewer.setSelectedTile + * Called from CanvasMouseListener * * @param unit The Unit to clear the destination for. * @return True if the unit has no destination. diff --git a/src/net/sf/freecol/client/gui/CanvasMouseListener.java b/src/net/sf/freecol/client/gui/CanvasMouseListener.java index eac714fa9..367c29472 100644 --- a/src/net/sf/freecol/client/gui/CanvasMouseListener.java +++ b/src/net/sf/freecol/client/gui/CanvasMouseListener.java @@ -212,6 +212,11 @@ public final class CanvasMouseListener implements ActionListener, MouseListener if(unit != null && unit.getTile() == tile) { freeColClient.getInGameController().clearGotoOrders(unit); mapViewer.updateCurrentPathForActiveUnit(); + } else { + if (tile != null && tile.hasSettlement()) { + freeColClient.getGUI().showSettlement(tile.getSettlement()); + return; + } } } mapViewer.setSelectedTile(tile); diff --git a/src/net/sf/freecol/client/gui/MapViewer.java b/src/net/sf/freecol/client/gui/MapViewer.java index f8e202365..977b7c718 100644 --- a/src/net/sf/freecol/client/gui/MapViewer.java +++ b/src/net/sf/freecol/client/gui/MapViewer.java @@ -1057,16 +1057,13 @@ public final class MapViewer { } /** - * Selects the tile at the specified position. There are three + * Selects the tile at the specified position. There are two * possible cases: * *
      - *
    1. If there is a {@link Colony} on the {@link Tile} the - * {@link Canvas#showColonyPanel} will be invoked. *
    2. If the tile contains a unit that can become active, then * that unit will be set as the active unit. - *
    3. If the two conditions above do not match, then the - * selectedTile will become the map focus. + *
    4. If not, the selectedTile will become the map focus. *
    * * If a unit is active and is located on the selected tile, @@ -1085,12 +1082,7 @@ public final class MapViewer { if (getViewMode() == GUI.MOVE_UNITS_MODE) { if (activeUnit == null || activeUnit.getTile() != newTile) { - if (newTile != null && newTile.hasSettlement()) { - gui.showSettlement(newTile.getSettlement()); - return false; - } - - // else, just select a unit on the selected tile + // select a unit on the selected tile Unit unitInFront = findUnitInFront(newTile); if (unitInFront != null) { ret = setActiveUnit(unitInFront); From f001515a73d9c55e0452a813d7fd143092a760e6 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 17:33:56 +0200 Subject: [PATCH 016/323] Update fixme for GUI.createMiniMapThumbNail method --- src/net/sf/freecol/client/gui/GUI.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 7fd44f305..9c5373737 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -278,6 +278,10 @@ public class GUI { /** * Create a thumbnail for the minimap. * + * FIXME: Delete all code inside this method and replace it with + * sensible code directly drawing in necessary size, + * without creating a throwaway GUI panel, drawing in wrong + * size and immediately resizing. * @return The created image. */ public BufferedImage createMiniMapThumbNail() { @@ -293,8 +297,6 @@ public class GUI { miniMap.paintMap(g1); g1.dispose(); - // FIXME: this can probably done more efficiently by applying - // a suitable AffineTransform to the Graphics2D int scaledWidth = Math.min((int)((64 * width) / (float)height), 128); BufferedImage scaledImage = new BufferedImage(scaledWidth, 64, BufferedImage.TYPE_INT_ARGB); From ec4c21dcc8ac52898cf9987453a8021aa75fa697 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 18:09:42 +0200 Subject: [PATCH 017/323] Move code for creating ImageIcons from InGameController to GUI --- .../client/control/ConnectController.java | 2 +- .../client/control/InGameController.java | 16 +++--- src/net/sf/freecol/client/gui/GUI.java | 49 ++++++++++++++----- .../gui/panel/MapEditorTransformPanel.java | 2 +- .../sf/freecol/common/debug/DebugUtils.java | 23 +++++---- 5 files changed, 58 insertions(+), 34 deletions(-) diff --git a/src/net/sf/freecol/client/control/ConnectController.java b/src/net/sf/freecol/client/control/ConnectController.java index 3403b6a1f..cab7568a2 100644 --- a/src/net/sf/freecol/client/control/ConnectController.java +++ b/src/net/sf/freecol/client/control/ConnectController.java @@ -420,7 +420,7 @@ public final class ConnectController { choices.add(new ChoiceItem<>(Messages.getName(n), n)); } String choice = gui.getChoice(true, null, - Messages.message("client.choicePlayer"), null, + Messages.message("client.choicePlayer"), "cancel", choices); if (choice == null) return false; // User cancelled diff --git a/src/net/sf/freecol/client/control/InGameController.java b/src/net/sf/freecol/client/control/InGameController.java index 556c66461..accbc9419 100644 --- a/src/net/sf/freecol/client/control/InGameController.java +++ b/src/net/sf/freecol/client/control/InGameController.java @@ -1373,7 +1373,7 @@ public final class InGameController implements NetworkConstants { // other special handling. Unit u = gui.getChoice(true, unit.getTile(), Messages.message("disembark.text"), - gui.createUnitImageIcon(unit), + unit, "none", choices); if (u == null) { // Cancelled, done. @@ -1426,7 +1426,7 @@ public final class InGameController implements NetworkConstants { } else { carrier = gui.getChoice(true, unit.getTile(), Messages.message("embark.text"), - gui.createUnitImageIcon(unit), + unit, "none", choices); if (carrier == null) return true; // User cancelled } @@ -1922,7 +1922,7 @@ public final class InGameController implements NetworkConstants { } goods = gui.getChoice(true, unit.getTile(), Messages.message("buyProposition.text"), - gui.createSettlementImageIcon(settlement), + settlement, "nothing", choices); if (goods == null) break; // Trade aborted by the player @@ -1979,7 +1979,7 @@ public final class InGameController implements NetworkConstants { } goods = gui.getChoice(true, unit.getTile(), Messages.message("sellProposition.text"), - gui.createSettlementImageIcon(settlement), + settlement, "nothing", choices); if (goods == null) break; // Trade aborted by the player @@ -2036,7 +2036,7 @@ public final class InGameController implements NetworkConstants { } Goods goods = gui.getChoice(true, unit.getTile(), Messages.message("gift.text"), - gui.createSettlementImageIcon(settlement), + settlement, "cancel", choices); if (goods != null && askServer().deliverGiftToSettlement(unit, settlement, goods)) { @@ -2117,7 +2117,7 @@ public final class InGameController implements NetworkConstants { } Player enemy = gui.getChoice(true, unit.getTile(), Messages.message("missionarySettlement.inciteQuestion"), - gui.createUnitImageIcon(unit), + unit, "missionarySettlement.cancel", choices); if (enemy == null) return true; int gold = askServer().incite(unit, direction, enemy, -1); @@ -4008,7 +4008,7 @@ public final class InGameController implements NetworkConstants { boolean ret = gui.confirm(true, null, StringTemplate .template("payArrears.text") .addAmount("%amount%", arrears), - gui.createGoodsImageIcon(type), + type, "ok", "cancel") && askServer().payArrears(type) && player.canTrade(type); @@ -4043,7 +4043,7 @@ public final class InGameController implements NetworkConstants { if (!gui.confirm(true, null, StringTemplate .template("payForBuilding.text") .addAmount("%amount%", price), - gui.createSettlementImageIcon(colony), + colony, "yes", "no")) { return false; } diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 9c5373737..68449160b 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -252,18 +252,6 @@ public class GUI { return (image==null) ? null : new ImageIcon(image); } - public ImageIcon createUnitImageIcon(Unit unit) { - return new ImageIcon(imageLibrary.getUnitImage(unit)); - } - - public ImageIcon createSettlementImageIcon(Settlement settlement) { - return new ImageIcon(imageLibrary.getSettlementImage(settlement)); - } - - public ImageIcon createGoodsImageIcon(GoodsType goodsType) { - return new ImageIcon(imageLibrary.getIconImage(goodsType)); - } - /** * Make image icon from an object. * @@ -517,6 +505,22 @@ public class GUI { return false; } + final public boolean confirm(boolean modal, Tile tile, + StringTemplate template, Settlement settlement, + String okKey, String cancelKey) { + return confirm(modal, tile, template, + new ImageIcon(imageLibrary.getSettlementImage(settlement)), + okKey, cancelKey); + } + + final public boolean confirm(boolean modal, Tile tile, + StringTemplate template, GoodsType goodsType, + String okKey, String cancelKey) { + return confirm(modal, tile, template, + new ImageIcon(imageLibrary.getIconImage(goodsType)), + okKey, cancelKey); + } + /** * Confirm that a unit should abandon its educational activity. * @@ -1114,6 +1118,27 @@ public class GUI { return null; } + final public T getChoice(boolean modal, Tile tile, Object explain, + String cancelKey, List> choices) { + return getChoice(modal, tile, explain, + (ImageIcon)null, cancelKey, choices); + } + + final public T getChoice(boolean modal, Tile tile, Object explain, + Unit unit, + String cancelKey, List> choices) { + return getChoice(modal, tile, explain, + new ImageIcon(imageLibrary.getUnitImage(unit)), cancelKey, choices); + } + + final public T getChoice(boolean modal, Tile tile, Object explain, + Settlement settlement, + String cancelKey, List> choices) { + return getChoice(modal, tile, explain, + new ImageIcon(imageLibrary.getSettlementImage(settlement)), + cancelKey, choices); + } + /** * General input dialog. * diff --git a/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java b/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java index 43c1cefc9..29ed90d10 100644 --- a/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java +++ b/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java @@ -313,7 +313,7 @@ public final class MapEditorTransformPanel extends FreeColPanel { } ResourceType choice = getGUI().getChoice(true, null, Messages.message("mapEditorTransformPanel.chooseResource"), - null, "cancel", choices); + "cancel", choices); if (choice != null) { t.addResource(new Resource(t.getGame(), t, choice, choice.getMaxValue())); diff --git a/src/net/sf/freecol/common/debug/DebugUtils.java b/src/net/sf/freecol/common/debug/DebugUtils.java index 7671d8abd..42639bfa0 100644 --- a/src/net/sf/freecol/common/debug/DebugUtils.java +++ b/src/net/sf/freecol/common/debug/DebugUtils.java @@ -121,8 +121,7 @@ public class DebugUtils { Collections.sort(buildings); BuildingType buildingType - = gui.getChoice(true, null, buildingTitle, null, "cancel", - buildings); + = gui.getChoice(true, null, buildingTitle, "cancel", buildings); if (buildingType == null) return; final Game sGame = server.getGame(); @@ -181,7 +180,7 @@ public class DebugUtils { } Collections.sort(fathers); - FoundingFather father = gui.getChoice(true, null, fatherTitle, null, + FoundingFather father = gui.getChoice(true, null, fatherTitle, "cancel", fathers); if (father != null) { server.getInGameController() @@ -329,7 +328,7 @@ public class DebugUtils { Collections.sort(uts); UnitType unitChoice = gui.getChoice(true, null, StringTemplate.template("prompt.selectUnitType"), - null, "cancel", uts); + "cancel", uts); if (unitChoice == null) return; Unit carrier = null, sCarrier = null; @@ -384,7 +383,7 @@ public class DebugUtils { Collections.sort(gtl); GoodsType goodsType = gui.getChoice(true, null, StringTemplate.template("prompt.selectGoodsType"), - null, "cancel", gtl); + "cancel", gtl); if (goodsType == null) return; String amount = gui.getInput(true, null, @@ -433,7 +432,7 @@ public class DebugUtils { Collections.sort(choices); Disaster disaster = gui.getChoice(true, null, StringTemplate.template("prompt.selectDisaster"), - null, "cancel", choices); + "cancel", choices); if (disaster == null) return; final FreeColServer server = freeColClient.getFreeColServer(); @@ -477,7 +476,7 @@ public class DebugUtils { Collections.sort(pcs); Player player = gui.getChoice(true, null, StringTemplate.template("prompt.selectOwner"), - null, "cancel", pcs); + "cancel", pcs); if (player == null) return; ServerPlayer sPlayer = sGame.getFreeColGameObject(player.getId(), @@ -517,7 +516,7 @@ public class DebugUtils { Collections.sort(pcs); Player player = gui.getChoice(true, null, StringTemplate.template("prompt.selectOwner"), - null, "cancel", pcs); + "cancel", pcs); if (player == null || unit.getOwner() == player) return; final Game sGame = server.getGame(); @@ -559,7 +558,7 @@ public class DebugUtils { Collections.sort(rcs); Role roleChoice = gui.getChoice(true, null, StringTemplate.template("prompt.selectRole"), - null, "cancel", rcs); + "cancel", rcs); if (roleChoice == null) return; sUnit.changeRole(roleChoice, roleChoice.getMaximumCount()); @@ -954,7 +953,7 @@ public class DebugUtils { Collections.sort(gtl); GoodsType goodsType = freeColClient.getGUI().getChoice(true, null, StringTemplate.template("prompt.selectGoodsType"), - null, "cancel", gtl); + "cancel", gtl); if (goodsType == null) return; String response = freeColClient.getGUI().getInput(true, null, @@ -1002,7 +1001,7 @@ public class DebugUtils { actions.add(new ChoiceItem<>(action)); } Collections.sort(actions); - MonarchAction action = gui.getChoice(true, null, monarchTitle, null, + MonarchAction action = gui.getChoice(true, null, monarchTitle, "cancel", actions); server.getInGameController().setMonarchAction(sPlayer, action); } @@ -1030,7 +1029,7 @@ public class DebugUtils { Collections.sort(rumours); RumourType rumourChoice = freeColClient.getGUI().getChoice(true, null, StringTemplate.template("prompt.selectLostCityRumour"), - null, "cancel", rumours); + "cancel", rumours); tile.getTileItemContainer().getLostCityRumour().setType(rumourChoice); sTile.getTileItemContainer().getLostCityRumour() .setType(rumourChoice); From 310d6652cad5298179c1f9852bcef375c92029d0 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 18:24:50 +0200 Subject: [PATCH 018/323] Move ImageIcon methods from GUI to Canvas, as they are only used there --- src/net/sf/freecol/client/gui/Canvas.java | 26 +++++++++++++++++++++-- src/net/sf/freecol/client/gui/GUI.java | 22 ------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/net/sf/freecol/client/gui/Canvas.java b/src/net/sf/freecol/client/gui/Canvas.java index 2b13fa73e..31572bd38 100644 --- a/src/net/sf/freecol/client/gui/Canvas.java +++ b/src/net/sf/freecol/client/gui/Canvas.java @@ -1950,6 +1950,28 @@ public final class Canvas extends JDesktopPane { showFreeColPanel(panel, indianSettlement.getTile(), true); } + /** + * Make image icon from an image. + * Use only if you know having null is possible! + * + * @param image The Image to create an icon for. + * @return The ImageIcon. + */ + private static ImageIcon createImageIcon(Image image) { + return (image==null) ? null : new ImageIcon(image); + } + + /** + * Make image icon from an object. + * + * @param display The FreeColObject to find an icon for. + * @return The ImageIcon found. + */ + private ImageIcon createObjectImageIcon(FreeColObject display) { + return (display == null) ? null + : createImageIcon(gui.getImageLibrary().getObjectImage(display, 2f)); + } + /** * Shows a message with some information and an "OK"-button. * @@ -1961,7 +1983,7 @@ public final class Canvas extends JDesktopPane { ImageIcon icon = null; Tile tile = null; if(displayObject != null) { - icon = gui.createObjectImageIcon(displayObject); + icon = createObjectImageIcon(displayObject); tile = (displayObject instanceof Location) ? ((Location)displayObject).getTile() : null; @@ -2110,7 +2132,7 @@ public final class Canvas extends JDesktopPane { ModelMessage m = messages.get(i); texts[i] = Messages.message(m); fcos[i] = game.getMessageSource(m); - icons[i] = gui.createObjectImageIcon(game.getMessageDisplay(m)); + icons[i] = createObjectImageIcon(game.getMessageDisplay(m)); if (tile == null && fcos[i] instanceof Location) { tile = ((Location)fcos[i]).getTile(); } diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 68449160b..249940341 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -241,28 +241,6 @@ public class GUI { public void clearGotoPath() { } - /** - * Make image icon from an image. - * Use only if you know having null is possible! - * - * @param image The Image to create an icon for. - * @return The ImageIcon. - */ - public static ImageIcon createImageIcon(Image image) { - return (image==null) ? null : new ImageIcon(image); - } - - /** - * Make image icon from an object. - * - * @param display The FreeColObject to find an icon for. - * @return The ImageIcon found. - */ - protected ImageIcon createObjectImageIcon(FreeColObject display) { - return (display == null) ? null - : createImageIcon(imageLibrary.getObjectImage(display, 2f)); - } - /** * Create a thumbnail for the minimap. * From c4cbf60165ecbf7ddb7914d9784f29c0690d9f8f Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 19:13:50 +0200 Subject: [PATCH 019/323] Make ConnectController not rely on the type of LoadingSavegameDialog --- .../client/control/ConnectController.java | 12 ++-- src/net/sf/freecol/client/gui/GUI.java | 4 +- .../client/gui/LoadingSavegameInfo.java | 64 +++++++++++++++++++ src/net/sf/freecol/client/gui/SwingGUI.java | 4 +- .../gui/panel/LoadingSavegameDialog.java | 10 +++ 5 files changed, 83 insertions(+), 11 deletions(-) create mode 100644 src/net/sf/freecol/client/gui/LoadingSavegameInfo.java diff --git a/src/net/sf/freecol/client/control/ConnectController.java b/src/net/sf/freecol/client/control/ConnectController.java index cab7568a2..79f4187eb 100644 --- a/src/net/sf/freecol/client/control/ConnectController.java +++ b/src/net/sf/freecol/client/control/ConnectController.java @@ -30,12 +30,15 @@ import java.util.logging.Logger; import javax.swing.SwingUtilities; import javax.xml.stream.XMLStreamException; -import net.sf.freecol.FreeCol; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import net.sf.freecol.FreeCol; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.gui.GUI; +import net.sf.freecol.client.gui.LoadingSavegameInfo; import net.sf.freecol.client.gui.panel.ChoiceItem; -import net.sf.freecol.client.gui.panel.LoadingSavegameDialog; import net.sf.freecol.common.FreeColException; import net.sf.freecol.common.ServerInfo; import net.sf.freecol.common.debug.FreeColDebugger; @@ -57,9 +60,6 @@ import net.sf.freecol.common.resources.ResourceManager; import net.sf.freecol.server.FreeColServer; import net.sf.freecol.server.FreeColServer.GameState; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - /** * The controller responsible for starting a server and connecting to it. @@ -581,7 +581,7 @@ public final class ConnectController { if (!gui.showLoadingSavegameDialog(defaultPublicServer, defaultSinglePlayer)) return false; - LoadingSavegameDialog lsd = gui.getLoadingSavegameDialog(); + LoadingSavegameInfo lsd = gui.getLoadingSavegameInfo(); singlePlayer = lsd.isSinglePlayer(); name = lsd.getServerName(); port = lsd.getPort(); diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 249940341..691d814ec 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -22,7 +22,6 @@ package net.sf.freecol.client.gui; import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics2D; -import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ActionListener; @@ -47,7 +46,6 @@ import net.sf.freecol.client.gui.panel.ColonyPanel; import net.sf.freecol.client.gui.panel.ColorChooserPanel; import net.sf.freecol.client.gui.panel.FreeColDialog; import net.sf.freecol.client.gui.panel.LabourData.UnitData; -import net.sf.freecol.client.gui.panel.LoadingSavegameDialog; import net.sf.freecol.client.gui.panel.MiniMap; import net.sf.freecol.client.gui.panel.Parameters; import net.sf.freecol.client.gui.panel.TradeRoutePanel; @@ -1152,7 +1150,7 @@ public class GUI { public void displayObject(FreeColObject fco) { } - public LoadingSavegameDialog getLoadingSavegameDialog() { + public LoadingSavegameInfo getLoadingSavegameInfo() { return null; } diff --git a/src/net/sf/freecol/client/gui/LoadingSavegameInfo.java b/src/net/sf/freecol/client/gui/LoadingSavegameInfo.java new file mode 100644 index 000000000..7beb3f8ff --- /dev/null +++ b/src/net/sf/freecol/client/gui/LoadingSavegameInfo.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2002-2015 The FreeCol Team + * + * This file is part of FreeCol. + * + * FreeCol is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * FreeCol is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FreeCol. If not, see . + */ + +package net.sf.freecol.client.gui; + +/** + * Used for transferring data for the savegame to be loaded. +*/ +public class LoadingSavegameInfo { + + private final boolean singlePlayer; + private final int port; + private final String serverName; + + public LoadingSavegameInfo(boolean singlePlayer, int port, String serverName) { + this.singlePlayer=singlePlayer; + this.port=port; + this.serverName=serverName; + } + + /** + * Is a single player game selected? + * + * @return True if single player is selected. + */ + public boolean isSinglePlayer() { + return singlePlayer; + } + + /** + * Get the selected port number. + * + * @return The port number. + */ + public int getPort() { + return port; + } + + /** + * Get the specified server name. + * + * @return The server name. + */ + public String getServerName() { + return serverName; + } + +} diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index 93ed20483..ac349f04f 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -906,8 +906,8 @@ public class SwingGUI extends GUI { } @Override - public LoadingSavegameDialog getLoadingSavegameDialog() { - return canvas.getLoadingSavegameDialog(); + public LoadingSavegameInfo getLoadingSavegameInfo() { + return canvas.getLoadingSavegameDialog().getInfo(); } @Override diff --git a/src/net/sf/freecol/client/gui/panel/LoadingSavegameDialog.java b/src/net/sf/freecol/client/gui/panel/LoadingSavegameDialog.java index 82d5e263e..a648d0681 100644 --- a/src/net/sf/freecol/client/gui/panel/LoadingSavegameDialog.java +++ b/src/net/sf/freecol/client/gui/panel/LoadingSavegameDialog.java @@ -35,6 +35,7 @@ import javax.swing.SpinnerNumberModel; import net.sf.freecol.FreeCol; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.gui.FontLibrary; +import net.sf.freecol.client.gui.LoadingSavegameInfo; import net.sf.freecol.common.i18n.Messages; @@ -146,6 +147,15 @@ public final class LoadingSavegameDialog extends FreeColConfirmDialog { return serverNameField.getName(); } + /** + * Get all important information at once. + * + * @return A LoadingSavegameInfo. + */ + public LoadingSavegameInfo getInfo() { + return new LoadingSavegameInfo(isSinglePlayer(), getPort(), getServerName()); + } + /** * Reset the dialog to a given state. * From 0a18e250a0500dc54f7fe25102f8e26103442688 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 19:26:50 +0200 Subject: [PATCH 020/323] Move ChoiceItem one level up, as it is no panel and is needed outside of gui --- src/net/sf/freecol/client/control/ConnectController.java | 2 +- src/net/sf/freecol/client/control/InGameController.java | 5 +++-- src/net/sf/freecol/client/gui/{panel => }/ChoiceItem.java | 2 +- src/net/sf/freecol/client/gui/GUI.java | 1 - src/net/sf/freecol/client/gui/SwingGUI.java | 1 - .../sf/freecol/client/gui/panel/CaptureGoodsDialog.java | 1 + .../client/gui/panel/ChooseFoundingFatherDialog.java | 1 + .../client/gui/panel/ConfirmDeclarationDialog.java | 2 +- src/net/sf/freecol/client/gui/panel/DumpCargoDialog.java | 1 + .../sf/freecol/client/gui/panel/EditSettlementDialog.java | 1 + src/net/sf/freecol/client/gui/panel/EmigrationDialog.java | 1 + .../sf/freecol/client/gui/panel/FreeColChoiceDialog.java | 1 + .../sf/freecol/client/gui/panel/FreeColConfirmDialog.java | 1 + src/net/sf/freecol/client/gui/panel/FreeColDialog.java | 1 + .../sf/freecol/client/gui/panel/FreeColInputDialog.java | 4 ++-- src/net/sf/freecol/client/gui/panel/LoadDialog.java | 3 ++- .../freecol/client/gui/panel/MapEditorTransformPanel.java | 3 ++- src/net/sf/freecol/client/gui/panel/MonarchDialog.java | 2 +- .../sf/freecol/client/gui/panel/NegotiationDialog.java | 2 +- src/net/sf/freecol/client/gui/panel/OptionsDialog.java | 1 + src/net/sf/freecol/client/gui/panel/ParametersDialog.java | 1 + src/net/sf/freecol/client/gui/panel/RiverStyleDialog.java | 6 +++--- src/net/sf/freecol/client/gui/panel/SaveDialog.java | 8 +++----- .../sf/freecol/client/gui/panel/ScaleMapSizeDialog.java | 1 + .../freecol/client/gui/panel/SelectDestinationDialog.java | 4 ++-- .../sf/freecol/client/gui/plaf/FreeColOptionPaneUI.java | 2 +- src/net/sf/freecol/common/debug/DebugUtils.java | 4 +++- 27 files changed, 37 insertions(+), 25 deletions(-) rename src/net/sf/freecol/client/gui/{panel => }/ChoiceItem.java (99%) diff --git a/src/net/sf/freecol/client/control/ConnectController.java b/src/net/sf/freecol/client/control/ConnectController.java index 79f4187eb..c5ad4c2aa 100644 --- a/src/net/sf/freecol/client/control/ConnectController.java +++ b/src/net/sf/freecol/client/control/ConnectController.java @@ -36,9 +36,9 @@ import org.w3c.dom.NodeList; import net.sf.freecol.FreeCol; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.GUI; import net.sf.freecol.client.gui.LoadingSavegameInfo; -import net.sf.freecol.client.gui.panel.ChoiceItem; import net.sf.freecol.common.FreeColException; import net.sf.freecol.common.ServerInfo; import net.sf.freecol.common.debug.FreeColDebugger; diff --git a/src/net/sf/freecol/client/control/InGameController.java b/src/net/sf/freecol/client/control/InGameController.java index accbc9419..160d54d8e 100644 --- a/src/net/sf/freecol/client/control/InGameController.java +++ b/src/net/sf/freecol/client/control/InGameController.java @@ -35,9 +35,9 @@ import javax.swing.SwingUtilities; import net.sf.freecol.FreeCol; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.GUI; import net.sf.freecol.client.gui.option.FreeColActionUI; -import net.sf.freecol.client.gui.panel.ChoiceItem; import net.sf.freecol.common.debug.DebugUtils; import net.sf.freecol.common.debug.FreeColDebugger; import net.sf.freecol.common.i18n.Messages; @@ -99,13 +99,14 @@ import net.sf.freecol.common.model.UnitType; import net.sf.freecol.common.model.UnitTypeChange.ChangeType; import net.sf.freecol.common.model.UnitWas; import net.sf.freecol.common.model.WorkLocation; -import static net.sf.freecol.common.util.CollectionUtils.*; import net.sf.freecol.common.util.LogBuilder; import net.sf.freecol.common.networking.NetworkConstants; import net.sf.freecol.common.networking.ServerAPI; import net.sf.freecol.common.option.BooleanOption; import net.sf.freecol.server.FreeColServer; +import static net.sf.freecol.common.util.CollectionUtils.*; + /** * The controller that will be used while the game is played. diff --git a/src/net/sf/freecol/client/gui/panel/ChoiceItem.java b/src/net/sf/freecol/client/gui/ChoiceItem.java similarity index 99% rename from src/net/sf/freecol/client/gui/panel/ChoiceItem.java rename to src/net/sf/freecol/client/gui/ChoiceItem.java index e09628f6f..725232dbc 100644 --- a/src/net/sf/freecol/client/gui/panel/ChoiceItem.java +++ b/src/net/sf/freecol/client/gui/ChoiceItem.java @@ -17,7 +17,7 @@ * along with FreeCol. If not, see . */ -package net.sf.freecol.client.gui.panel; +package net.sf.freecol.client.gui; import javax.swing.ImageIcon; diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 691d814ec..afb605371 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -41,7 +41,6 @@ import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.control.InGameController; import net.sf.freecol.client.control.InGameController.*; -import net.sf.freecol.client.gui.panel.ChoiceItem; import net.sf.freecol.client.gui.panel.ColonyPanel; import net.sf.freecol.client.gui.panel.ColorChooserPanel; import net.sf.freecol.client.gui.panel.FreeColDialog; diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index ac349f04f..bd2e1eb32 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -54,7 +54,6 @@ import javax.swing.filechooser.FileFilter; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.gui.animation.Animations; -import net.sf.freecol.client.gui.panel.ChoiceItem; import net.sf.freecol.client.gui.panel.ColonyPanel; import net.sf.freecol.client.gui.panel.ColorChooserPanel; import net.sf.freecol.client.gui.panel.CornerMapControls; diff --git a/src/net/sf/freecol/client/gui/panel/CaptureGoodsDialog.java b/src/net/sf/freecol/client/gui/panel/CaptureGoodsDialog.java index b4dfa4d13..bd0fe0164 100644 --- a/src/net/sf/freecol/client/gui/panel/CaptureGoodsDialog.java +++ b/src/net/sf/freecol/client/gui/panel/CaptureGoodsDialog.java @@ -38,6 +38,7 @@ import javax.swing.ListCellRenderer; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.model.Goods; import net.sf.freecol.common.model.Unit; diff --git a/src/net/sf/freecol/client/gui/panel/ChooseFoundingFatherDialog.java b/src/net/sf/freecol/client/gui/panel/ChooseFoundingFatherDialog.java index 72e5f2b0d..a9bd946c1 100644 --- a/src/net/sf/freecol/client/gui/panel/ChooseFoundingFatherDialog.java +++ b/src/net/sf/freecol/client/gui/panel/ChooseFoundingFatherDialog.java @@ -30,6 +30,7 @@ import javax.swing.JTabbedPane; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.model.FoundingFather; diff --git a/src/net/sf/freecol/client/gui/panel/ConfirmDeclarationDialog.java b/src/net/sf/freecol/client/gui/panel/ConfirmDeclarationDialog.java index 58ba4c9bf..74c5fd47e 100644 --- a/src/net/sf/freecol/client/gui/panel/ConfirmDeclarationDialog.java +++ b/src/net/sf/freecol/client/gui/panel/ConfirmDeclarationDialog.java @@ -42,7 +42,7 @@ import javax.swing.JTextField; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; -import net.sf.freecol.client.gui.GUI; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.panel.Flag.Background; import net.sf.freecol.client.gui.panel.Flag.Decoration; import net.sf.freecol.client.gui.panel.Flag.UnionPosition; diff --git a/src/net/sf/freecol/client/gui/panel/DumpCargoDialog.java b/src/net/sf/freecol/client/gui/panel/DumpCargoDialog.java index 64d87cd64..af9b45f4a 100644 --- a/src/net/sf/freecol/client/gui/panel/DumpCargoDialog.java +++ b/src/net/sf/freecol/client/gui/panel/DumpCargoDialog.java @@ -30,6 +30,7 @@ import javax.swing.JFrame; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.model.Goods; import net.sf.freecol.common.model.Unit; diff --git a/src/net/sf/freecol/client/gui/panel/EditSettlementDialog.java b/src/net/sf/freecol/client/gui/panel/EditSettlementDialog.java index 6def7e01b..141baf89f 100644 --- a/src/net/sf/freecol/client/gui/panel/EditSettlementDialog.java +++ b/src/net/sf/freecol/client/gui/panel/EditSettlementDialog.java @@ -37,6 +37,7 @@ import javax.swing.SpinnerNumberModel; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.GUI; import net.sf.freecol.client.gui.plaf.FreeColComboBoxRenderer; import net.sf.freecol.common.i18n.Messages; diff --git a/src/net/sf/freecol/client/gui/panel/EmigrationDialog.java b/src/net/sf/freecol/client/gui/panel/EmigrationDialog.java index 8355357f0..edf5f227b 100644 --- a/src/net/sf/freecol/client/gui/panel/EmigrationDialog.java +++ b/src/net/sf/freecol/client/gui/panel/EmigrationDialog.java @@ -29,6 +29,7 @@ import javax.swing.JTextArea; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.ImageLibrary; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.model.Europe; diff --git a/src/net/sf/freecol/client/gui/panel/FreeColChoiceDialog.java b/src/net/sf/freecol/client/gui/panel/FreeColChoiceDialog.java index ce334ccea..565c639c7 100644 --- a/src/net/sf/freecol/client/gui/panel/FreeColChoiceDialog.java +++ b/src/net/sf/freecol/client/gui/panel/FreeColChoiceDialog.java @@ -25,6 +25,7 @@ import javax.swing.ImageIcon; import javax.swing.JFrame; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; diff --git a/src/net/sf/freecol/client/gui/panel/FreeColConfirmDialog.java b/src/net/sf/freecol/client/gui/panel/FreeColConfirmDialog.java index 103fc80e9..1a4152de3 100644 --- a/src/net/sf/freecol/client/gui/panel/FreeColConfirmDialog.java +++ b/src/net/sf/freecol/client/gui/panel/FreeColConfirmDialog.java @@ -25,6 +25,7 @@ import javax.swing.ImageIcon; import javax.swing.JFrame; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; diff --git a/src/net/sf/freecol/client/gui/panel/FreeColDialog.java b/src/net/sf/freecol/client/gui/panel/FreeColDialog.java index d75bc8fbe..837635759 100644 --- a/src/net/sf/freecol/client/gui/panel/FreeColDialog.java +++ b/src/net/sf/freecol/client/gui/panel/FreeColDialog.java @@ -44,6 +44,7 @@ import javax.swing.SwingUtilities; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.control.InGameController; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.GUI; import net.sf.freecol.client.gui.ImageLibrary; import net.sf.freecol.client.gui.plaf.FreeColOptionPaneUI; diff --git a/src/net/sf/freecol/client/gui/panel/FreeColInputDialog.java b/src/net/sf/freecol/client/gui/panel/FreeColInputDialog.java index 3083e03e9..fcc6460d4 100644 --- a/src/net/sf/freecol/client/gui/panel/FreeColInputDialog.java +++ b/src/net/sf/freecol/client/gui/panel/FreeColInputDialog.java @@ -19,14 +19,14 @@ package net.sf.freecol.client.gui.panel; -import javax.swing.ImageIcon; - import java.util.List; import java.util.logging.Logger; +import javax.swing.ImageIcon; import javax.swing.JFrame; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; diff --git a/src/net/sf/freecol/client/gui/panel/LoadDialog.java b/src/net/sf/freecol/client/gui/panel/LoadDialog.java index 0d5cfd3d0..8dc868e20 100644 --- a/src/net/sf/freecol/client/gui/panel/LoadDialog.java +++ b/src/net/sf/freecol/client/gui/panel/LoadDialog.java @@ -24,11 +24,12 @@ import java.awt.event.ActionListener; import java.io.File; import java.util.List; -import javax.swing.filechooser.FileFilter; import javax.swing.JFileChooser; import javax.swing.JFrame; +import javax.swing.filechooser.FileFilter; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; diff --git a/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java b/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java index 29ed90d10..25efede23 100644 --- a/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java +++ b/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java @@ -38,12 +38,13 @@ import javax.swing.JToggleButton; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.control.MapEditorController; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.ImageLibrary; import net.sf.freecol.client.gui.MapViewer; import net.sf.freecol.common.i18n.Messages; +import net.sf.freecol.common.model.Direction; import net.sf.freecol.common.model.IndianNationType; import net.sf.freecol.common.model.LostCityRumour; -import net.sf.freecol.common.model.Direction; import net.sf.freecol.common.model.ModelMessage; import net.sf.freecol.common.model.Nation; import net.sf.freecol.common.model.Player; diff --git a/src/net/sf/freecol/client/gui/panel/MonarchDialog.java b/src/net/sf/freecol/client/gui/panel/MonarchDialog.java index 690746ba7..f2a5329c8 100644 --- a/src/net/sf/freecol/client/gui/panel/MonarchDialog.java +++ b/src/net/sf/freecol/client/gui/panel/MonarchDialog.java @@ -24,7 +24,6 @@ import java.awt.event.ActionListener; import java.util.List; import javax.swing.ImageIcon; - import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextArea; @@ -32,6 +31,7 @@ import javax.swing.JTextArea; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.FontLibrary; import net.sf.freecol.client.gui.ImageLibrary; import net.sf.freecol.common.i18n.Messages; diff --git a/src/net/sf/freecol/client/gui/panel/NegotiationDialog.java b/src/net/sf/freecol/client/gui/panel/NegotiationDialog.java index 1877a93f1..49c3555a8 100644 --- a/src/net/sf/freecol/client/gui/panel/NegotiationDialog.java +++ b/src/net/sf/freecol/client/gui/panel/NegotiationDialog.java @@ -24,7 +24,6 @@ import java.awt.Cursor; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -47,6 +46,7 @@ import javax.swing.SpinnerNumberModel; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.FontLibrary; import net.sf.freecol.common.debug.FreeColDebugger; import net.sf.freecol.common.i18n.Messages; diff --git a/src/net/sf/freecol/client/gui/panel/OptionsDialog.java b/src/net/sf/freecol/client/gui/panel/OptionsDialog.java index 09edb1ceb..1bfde9548 100644 --- a/src/net/sf/freecol/client/gui/panel/OptionsDialog.java +++ b/src/net/sf/freecol/client/gui/panel/OptionsDialog.java @@ -31,6 +31,7 @@ import net.miginfocom.swing.MigLayout; import net.sf.freecol.FreeCol; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.option.OptionGroupUI; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.io.FreeColDirectories; diff --git a/src/net/sf/freecol/client/gui/panel/ParametersDialog.java b/src/net/sf/freecol/client/gui/panel/ParametersDialog.java index 6853edfa0..db5685f9f 100644 --- a/src/net/sf/freecol/client/gui/panel/ParametersDialog.java +++ b/src/net/sf/freecol/client/gui/panel/ParametersDialog.java @@ -32,6 +32,7 @@ import javax.swing.JTextField; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; diff --git a/src/net/sf/freecol/client/gui/panel/RiverStyleDialog.java b/src/net/sf/freecol/client/gui/panel/RiverStyleDialog.java index ccdcad0cb..389e5476e 100644 --- a/src/net/sf/freecol/client/gui/panel/RiverStyleDialog.java +++ b/src/net/sf/freecol/client/gui/panel/RiverStyleDialog.java @@ -19,15 +19,15 @@ package net.sf.freecol.client.gui.panel; -import javax.swing.ImageIcon; -import javax.swing.JPanel; - import java.util.List; import java.util.logging.Logger; +import javax.swing.ImageIcon; import javax.swing.JFrame; +import javax.swing.JPanel; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.ImageLibrary; import net.sf.freecol.common.resources.ResourceManager; diff --git a/src/net/sf/freecol/client/gui/panel/SaveDialog.java b/src/net/sf/freecol/client/gui/panel/SaveDialog.java index 2b2713de2..6b87015de 100644 --- a/src/net/sf/freecol/client/gui/panel/SaveDialog.java +++ b/src/net/sf/freecol/client/gui/panel/SaveDialog.java @@ -21,17 +21,15 @@ package net.sf.freecol.client.gui.panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - -import javax.swing.JFileChooser; -import javax.swing.filechooser.FileFilter; - import java.io.File; - import java.util.List; +import javax.swing.JFileChooser; import javax.swing.JFrame; +import javax.swing.filechooser.FileFilter; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; /** diff --git a/src/net/sf/freecol/client/gui/panel/ScaleMapSizeDialog.java b/src/net/sf/freecol/client/gui/panel/ScaleMapSizeDialog.java index 84982f337..0f33e3a84 100644 --- a/src/net/sf/freecol/client/gui/panel/ScaleMapSizeDialog.java +++ b/src/net/sf/freecol/client/gui/panel/ScaleMapSizeDialog.java @@ -33,6 +33,7 @@ import javax.swing.JTextField; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.model.Map; diff --git a/src/net/sf/freecol/client/gui/panel/SelectDestinationDialog.java b/src/net/sf/freecol/client/gui/panel/SelectDestinationDialog.java index fe743c338..018d6d6a3 100644 --- a/src/net/sf/freecol/client/gui/panel/SelectDestinationDialog.java +++ b/src/net/sf/freecol/client/gui/panel/SelectDestinationDialog.java @@ -48,7 +48,7 @@ import javax.swing.event.ListSelectionListener; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; -import net.sf.freecol.client.gui.GUI; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.ImageLibrary; import net.sf.freecol.client.gui.plaf.FreeColComboBoxRenderer; import net.sf.freecol.common.i18n.Messages; @@ -73,8 +73,8 @@ import net.sf.freecol.common.model.Unit; import net.sf.freecol.common.model.UnitType; import net.sf.freecol.common.model.UnitTypeChange.ChangeType; import net.sf.freecol.common.model.pathfinding.GoalDeciders.MultipleAdjacentDecider; -import net.sf.freecol.common.util.LogBuilder; import net.sf.freecol.common.resources.ResourceManager; +import net.sf.freecol.common.util.LogBuilder; /** diff --git a/src/net/sf/freecol/client/gui/plaf/FreeColOptionPaneUI.java b/src/net/sf/freecol/client/gui/plaf/FreeColOptionPaneUI.java index 4df0492fa..35f7e7594 100644 --- a/src/net/sf/freecol/client/gui/plaf/FreeColOptionPaneUI.java +++ b/src/net/sf/freecol/client/gui/plaf/FreeColOptionPaneUI.java @@ -40,7 +40,7 @@ import javax.swing.plaf.basic.BasicOptionPaneUI; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.gui.ImageLibrary; -import net.sf.freecol.client.gui.panel.ChoiceItem; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.panel.MigPanel; import net.sf.freecol.common.i18n.Messages; diff --git a/src/net/sf/freecol/common/debug/DebugUtils.java b/src/net/sf/freecol/common/debug/DebugUtils.java index 42639bfa0..d50f57fcd 100644 --- a/src/net/sf/freecol/common/debug/DebugUtils.java +++ b/src/net/sf/freecol/common/debug/DebugUtils.java @@ -33,7 +33,7 @@ import javax.swing.event.ChangeListener; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.gui.GUI; -import net.sf.freecol.client.gui.panel.ChoiceItem; +import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.io.FreeColXMLWriter.WriteScope; import net.sf.freecol.common.model.Building; @@ -64,7 +64,9 @@ import net.sf.freecol.common.model.UnitType; import net.sf.freecol.common.option.BooleanOption; import net.sf.freecol.common.util.LogBuilder; import net.sf.freecol.common.util.RandomChoice; + import static net.sf.freecol.common.util.StringUtils.*; + import net.sf.freecol.server.FreeColServer; import net.sf.freecol.server.ai.AIColony; import net.sf.freecol.server.ai.AIMain; From 3e5b67dfc658f7a98b8d92b0411e1bf0ff00038a Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 19:54:31 +0200 Subject: [PATCH 021/323] Make MapEditorController independent from MapEditorTransformPanel.MapTransform --- .../client/control/MapEditorController.java | 19 ++++++++++++++----- .../gui/panel/MapEditorTransformPanel.java | 3 ++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/net/sf/freecol/client/control/MapEditorController.java b/src/net/sf/freecol/client/control/MapEditorController.java index a87b40017..c6e7f5e85 100644 --- a/src/net/sf/freecol/client/control/MapEditorController.java +++ b/src/net/sf/freecol/client/control/MapEditorController.java @@ -31,7 +31,6 @@ import javax.xml.stream.XMLStreamException; import net.sf.freecol.FreeCol; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.gui.GUI; -import net.sf.freecol.client.gui.panel.MapEditorTransformPanel.MapTransform; import net.sf.freecol.common.FreeColException; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.io.FreeColDirectories; @@ -48,8 +47,8 @@ import net.sf.freecol.common.option.MapGeneratorOptions; import net.sf.freecol.common.option.OptionGroup; import net.sf.freecol.common.util.LogBuilder; import net.sf.freecol.server.FreeColServer; -import net.sf.freecol.server.model.ServerPlayer; import net.sf.freecol.server.generator.MapGenerator; +import net.sf.freecol.server.model.ServerPlayer; /** @@ -65,11 +64,21 @@ public final class MapEditorController { private final GUI gui; + public interface IMapTransform { + + /** + * Applies this transformation to the given tile. + * @param t The Tile to be transformed, + */ + public abstract void transform(Tile t); + + } + /** * The transform that should be applied to a Tile * that is clicked on the map. */ - private MapTransform currentMapTransform = null; + private IMapTransform currentMapTransform = null; /** @@ -132,7 +141,7 @@ public final class MapEditorController { * @param mt The transform that should be applied to a * Tile that is clicked on the map. */ - public void setMapTransform(MapTransform mt) { + public void setMapTransform(IMapTransform mt) { currentMapTransform = mt; gui.updateMapControls(); } @@ -142,7 +151,7 @@ public final class MapEditorController { * @return The transform that should be applied to a * Tile that is clicked on the map. */ - public MapTransform getMapTransform() { + public IMapTransform getMapTransform() { return currentMapTransform; } diff --git a/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java b/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java index 25efede23..bf2566354 100644 --- a/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java +++ b/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java @@ -38,6 +38,7 @@ import javax.swing.JToggleButton; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.control.MapEditorController; +import net.sf.freecol.client.control.MapEditorController.IMapTransform; import net.sf.freecol.client.gui.ChoiceItem; import net.sf.freecol.client.gui.ImageLibrary; import net.sf.freecol.client.gui.MapViewer; @@ -196,7 +197,7 @@ public final class MapEditorTransformPanel extends FreeColPanel { * * @see #transform(Tile) */ - public abstract class MapTransform { + public abstract class MapTransform implements IMapTransform { /** * A panel with information about this transformation. From 94b94f56eb2ff83bcaa62e66b7e1c93cb95cbb0d Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 20:13:18 +0200 Subject: [PATCH 022/323] Remove dependence of GUI on ColonyPanel --- src/net/sf/freecol/client/gui/GUI.java | 4 +--- src/net/sf/freecol/client/gui/SwingGUI.java | 6 +++++- .../client/gui/panel/ReportCompactColonyPanel.java | 14 +++++--------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index afb605371..f4b4a8d5e 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -41,7 +41,6 @@ import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.control.InGameController; import net.sf.freecol.client.control.InGameController.*; -import net.sf.freecol.client.gui.panel.ColonyPanel; import net.sf.freecol.client.gui.panel.ColorChooserPanel; import net.sf.freecol.client.gui.panel.FreeColDialog; import net.sf.freecol.client.gui.panel.LabourData.UnitData; @@ -1244,8 +1243,7 @@ public class GUI { protected void showForeignColony(Settlement settlement) { } - public ColonyPanel showColonyPanel(Colony colony, Unit unit) { - return null; + public void showColonyPanel(Colony colony, Unit unit) { } public void showColopediaPanel(String nodeId) { diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index bd2e1eb32..c11fff36b 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -1036,7 +1036,11 @@ public class SwingGUI extends GUI { } @Override - public ColonyPanel showColonyPanel(Colony colony, Unit unit) { + public void showColonyPanel(Colony colony, Unit unit) { + canvas.showColonyPanel(colony, unit); + } + + public ColonyPanel showColonyPanel2(Colony colony, Unit unit) { return canvas.showColonyPanel(colony, unit); } diff --git a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java index db386d360..091bdb51b 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java @@ -36,14 +36,14 @@ import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; -import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.SwingConstants; + import net.miginfocom.swing.MigLayout; -import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.gui.ImageLibrary; +import net.sf.freecol.client.gui.SwingGUI; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.model.Ability; import net.sf.freecol.common.model.AbstractGoods; @@ -51,20 +51,15 @@ import net.sf.freecol.common.model.BuildableType; import net.sf.freecol.common.model.Building; import net.sf.freecol.common.model.Colony; import net.sf.freecol.common.model.Colony.TileImprovementSuggestion; -import net.sf.freecol.common.model.ColonyTile; import net.sf.freecol.common.model.ExportData; import net.sf.freecol.common.model.FreeColObject; import net.sf.freecol.common.model.Game; -import net.sf.freecol.common.model.Goods; import net.sf.freecol.common.model.GoodsContainer; import net.sf.freecol.common.model.GoodsType; -import net.sf.freecol.common.model.Location; import net.sf.freecol.common.model.Market; -import net.sf.freecol.common.model.Occupation; import net.sf.freecol.common.model.Player; import net.sf.freecol.common.model.ProductionInfo; import net.sf.freecol.common.model.Region; -import net.sf.freecol.common.model.Settlement; import net.sf.freecol.common.model.Specification; import net.sf.freecol.common.model.StringTemplate; import net.sf.freecol.common.model.Tile; @@ -74,9 +69,10 @@ import net.sf.freecol.common.model.UnitType; import net.sf.freecol.common.model.WorkLocation; import net.sf.freecol.common.model.WorkLocation.Suggestion; import net.sf.freecol.common.resources.ResourceManager; -import static net.sf.freecol.common.util.CollectionUtils.*; import net.sf.freecol.common.util.CollectionUtils.Accumulator; +import static net.sf.freecol.common.util.CollectionUtils.*; + /** * This panel displays the compact colony report. @@ -1122,7 +1118,7 @@ public final class ReportCompactColonyPanel extends ReportPanel } else { Colony colony = game.getFreeColGameObject(command, Colony.class); if (colony != null) { - getGUI().showColonyPanel(colony, null) + ((SwingGUI)getGUI()).showColonyPanel2(colony, null) .addClosingCallback(new Runnable() { @Override public void run() { From 57507f0d693d2993238ccb89fad205676afb05b5 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 20:24:23 +0200 Subject: [PATCH 023/323] Remove dependence of GUI on FreeColDialog --- src/net/sf/freecol/client/gui/GUI.java | 4 ---- src/net/sf/freecol/client/gui/SwingGUI.java | 1 - src/net/sf/freecol/client/gui/panel/FreeColDialog.java | 8 ++++---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index f4b4a8d5e..f9813db79 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -42,7 +42,6 @@ import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.control.InGameController; import net.sf.freecol.client.control.InGameController.*; import net.sf.freecol.client.gui.panel.ColorChooserPanel; -import net.sf.freecol.client.gui.panel.FreeColDialog; import net.sf.freecol.client.gui.panel.LabourData.UnitData; import net.sf.freecol.client.gui.panel.MiniMap; import net.sf.freecol.client.gui.panel.Parameters; @@ -1142,9 +1141,6 @@ public class GUI { return false; } - public void dialogRemove(FreeColDialog fcd) { - } - public void displayObject(FreeColObject fco) { } diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index c11fff36b..f3411deac 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -870,7 +870,6 @@ public class SwingGUI extends GUI { return canvas.containsInGameComponents(); } - @Override public void dialogRemove(FreeColDialog fcd) { canvas.dialogRemove(fcd); } diff --git a/src/net/sf/freecol/client/gui/panel/FreeColDialog.java b/src/net/sf/freecol/client/gui/panel/FreeColDialog.java index 837635759..d205bccb2 100644 --- a/src/net/sf/freecol/client/gui/panel/FreeColDialog.java +++ b/src/net/sf/freecol/client/gui/panel/FreeColDialog.java @@ -45,8 +45,8 @@ import javax.swing.SwingUtilities; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.control.InGameController; import net.sf.freecol.client.gui.ChoiceItem; -import net.sf.freecol.client.gui.GUI; import net.sf.freecol.client.gui.ImageLibrary; +import net.sf.freecol.client.gui.SwingGUI; import net.sf.freecol.client.gui.plaf.FreeColOptionPaneUI; import net.sf.freecol.common.i18n.Messages; import net.sf.freecol.common.model.Game; @@ -272,8 +272,8 @@ public class FreeColDialog extends JDialog implements PropertyChangeListener * * @return The GUI. */ - protected GUI getGUI() { - return freeColClient.getGUI(); + protected SwingGUI getGUI() { + return (SwingGUI)freeColClient.getGUI(); } /** @@ -429,7 +429,7 @@ public class FreeColDialog extends JDialog implements PropertyChangeListener public void removeNotify() { super.removeNotify(); - freeColClient.getGUI().dialogRemove(FreeColDialog.this); + getGUI().dialogRemove(FreeColDialog.this); removeAll(); if (this.pane != null) { From f483359f49afcb618cb6c66af912ce09a1171976 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Thu, 30 Jul 2015 20:28:51 +0200 Subject: [PATCH 024/323] Remove dependence of GUI on TradeRoutePanel --- src/net/sf/freecol/client/gui/GUI.java | 4 ---- src/net/sf/freecol/client/gui/SwingGUI.java | 1 - src/net/sf/freecol/client/gui/panel/FreeColPanel.java | 6 +++--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index f9813db79..265a17679 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -45,7 +45,6 @@ import net.sf.freecol.client.gui.panel.ColorChooserPanel; import net.sf.freecol.client.gui.panel.LabourData.UnitData; import net.sf.freecol.client.gui.panel.MiniMap; import net.sf.freecol.client.gui.panel.Parameters; -import net.sf.freecol.client.gui.panel.TradeRoutePanel; import net.sf.freecol.client.gui.panel.Utility; import net.sf.freecol.common.FreeColException; import net.sf.freecol.common.ServerInfo; @@ -1175,9 +1174,6 @@ public class GUI { public void removeInGameComponents() { } - public void removeTradeRoutePanel(TradeRoutePanel panel) { - } - public void requestFocusForSubPanel() { } diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index f3411deac..e2423a592 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -948,7 +948,6 @@ public class SwingGUI extends GUI { canvas.removeInGameComponents(); } - @Override public void removeTradeRoutePanel(TradeRoutePanel panel) { canvas.removeTradeRoutePanel(panel); } diff --git a/src/net/sf/freecol/client/gui/panel/FreeColPanel.java b/src/net/sf/freecol/client/gui/panel/FreeColPanel.java index 16d04e250..12d5507cf 100644 --- a/src/net/sf/freecol/client/gui/panel/FreeColPanel.java +++ b/src/net/sf/freecol/client/gui/panel/FreeColPanel.java @@ -39,8 +39,8 @@ import javax.swing.KeyStroke; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.control.InGameController; -import net.sf.freecol.client.gui.GUI; import net.sf.freecol.client.gui.ImageLibrary; +import net.sf.freecol.client.gui.SwingGUI; import net.sf.freecol.common.model.Colony; import net.sf.freecol.common.model.Game; import net.sf.freecol.common.model.Player; @@ -128,8 +128,8 @@ public abstract class FreeColPanel extends MigPanel implements ActionListener { * * @return The current GUI. */ - protected GUI getGUI() { - return freeColClient.getGUI(); + protected SwingGUI getGUI() { + return (SwingGUI)freeColClient.getGUI(); } /** From f96926ad03b79cb028f359319abf015d44017f63 Mon Sep 17 00:00:00 2001 From: Michael Pope Date: Fri, 31 Jul 2015 14:53:39 +0930 Subject: [PATCH 025/323] Use getColonyTileLocationLabel in RRP. --- data/strings/FreeColMessages.properties | 10 ++++------ .../client/gui/panel/ReportRequirementsPanel.java | 14 ++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index fc3bff7d3..65c67b71b 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -3160,16 +3160,14 @@ report.production.update=Update # ReportRequirementsPanel report.requirements.badAssignment=%colony% has a %expert% currently working as %expertWork%, while a %nonExpert% is working as %nonExpertWork%. Production would be greater if the colonists swapped jobs. report.requirements.canTrainExperts={{plural:2|%unit%}} can be trained at -report.requirements.exploreTile=%type% to the %direction% of %colony% would benefit from exploration. +report.requirements.exploreTile=%location% would benefit from exploration. report.requirements.met=All requirements are met. report.requirements.missingGoods=%colony% is producing %goods%, but requires more %input%. report.requirements.misusedExperts=There are {{plural:2|%unit%}} not working as %work% present at report.requirements.noExpert=%colony% is producing %goods%, but has no %unit%. -report.requirements.tile.clearForest=%type% to the %direction% of %colony% would benefit from clearing. -report.requirements.tile.clearForest.center=%colony% would benefit from clearing its tile. -report.requirements.tile.plow=%type% to the %direction% of %colony% would benefit from plowing. -report.requirements.tile.plow.center=%colony% would benefit from plowing its tile. -report.requirements.tile.road=%type% to the %direction% of %colony% would benefit from road building. +report.requirements.tile.clearForest=%location% would benefit from clearing. +report.requirements.tile.plow=%location% would benefit from plowing. +report.requirements.tile.road=%location% would benefit from road building. #report.requirements.tile.road.center can not happen report.requirements.severalExperts=Several {{plural:2|%unit%}} are present at report.requirements.surplus=A surplus of %goods% is being produced at diff --git a/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java b/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java index 83de5e9ea..517233053 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java @@ -196,7 +196,6 @@ public final class ReportRequirementsPanel extends ReportPanel { } else { String key = "report.requirements.tile." + tis.tileImprovementType.getSuffix(); - if (tis.tile == colony.getTile()) key += ".center"; if (Messages.containsKey(key)) { addTileWarning(doc, colony, key, tis.tile); } @@ -220,12 +219,9 @@ public final class ReportRequirementsPanel extends ReportPanel { private void addTileWarning(StyledDocument doc, Colony colony, String messageId, Tile tile) { if (messageId == null || !Messages.containsKey(messageId)) return; - // TODO-post-0.11.4-release: migrate to using Tile.getColonyTileLocationLabel() - Direction direction = colony.getTile().getDirection(tile); StringTemplate t = StringTemplate.template(messageId) - .addNamed("%type%", tile.getType()) - .addName("%colony%", colony.getName()); - if (direction != null) t.addNamed("%direction%", direction); + .addStringTemplate("%location%", + tile.getColonyTileLocationLabel(colony)); try { doc.insertString(doc.getLength(), "\n\n" + Messages.message(t), doc.getStyle("regular")); @@ -234,7 +230,8 @@ public final class ReportRequirementsPanel extends ReportPanel { } } - private void addBadAssignmentWarning(StyledDocument doc, Colony colony, Unit expert, Unit nonExpert) { + private void addBadAssignmentWarning(StyledDocument doc, Colony colony, + Unit expert, Unit nonExpert) { GoodsType expertGoods = expert.getWorkType(); GoodsType nonExpertGoods = nonExpert.getWorkType(); String colonyName = colony.getName(); @@ -257,7 +254,8 @@ public final class ReportRequirementsPanel extends ReportPanel { } } - private void addExpertWarning(StyledDocument doc, Colony c, GoodsType goodsType, UnitType workType) { + private void addExpertWarning(StyledDocument doc, Colony c, + GoodsType goodsType, UnitType workType) { String newMessage = Messages.message(StringTemplate .template("report.requirements.noExpert") .addName("%colony%", c.getName()) From 72190eeb7db6c262c0baee07f132f42928773b79 Mon Sep 17 00:00:00 2001 From: Michael Pope Date: Thu, 30 Jul 2015 09:54:42 +0930 Subject: [PATCH 026/323] Move splash.jpg into the FreeCol.jar. --- build.xml | 2 +- splash.jpg => build/splash.jpg | Bin data/strings/FreeColMessages.properties | 2 + doc/FreeCol.tex | 27 +++--- src/net/sf/freecol/FreeCol.java | 94 +++++++++++++++---- src/net/sf/freecol/client/FreeColClient.java | 11 ++- src/net/sf/freecol/client/gui/GUI.java | 5 +- src/net/sf/freecol/client/gui/SwingGUI.java | 13 +-- 8 files changed, 111 insertions(+), 43 deletions(-) rename splash.jpg => build/splash.jpg (100%) diff --git a/build.xml b/build.xml index 2c06c9979..1fa1b87fb 100644 --- a/build.xml +++ b/build.xml @@ -182,7 +182,7 @@ diff --git a/splash.jpg b/build/splash.jpg similarity index 100% rename from splash.jpg rename to build/splash.jpg diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index 65c67b71b..7038bd6f6 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -217,6 +217,7 @@ cli.error.home.notDir=%string% is not a directory. cli.error.home.notExists=Directory %string% does not exist. cli.error.save=Can not read saved game %string%. cli.error.serverPort=%string% is not a valid port number. +cli.error.splash=Splash file %name% not found. cli.error.timeout=%string% is too short (less than %minimum%). cli.advantages=set the type of ADVANTAGES (%advantages%) @@ -246,6 +247,7 @@ cli.no-intro=skip the intro video cli.no-java-check=skip the java version check cli.no-memory-check=skip the memory check cli.no-sound=run FreeCol without sound +cli.no-splash=skip the splash screen cli.private=start a private server (not published to the metaserver) cli.seed=provide a SEED for the pseudo-random number generator cli.server-name=specify a custom NAME for the server diff --git a/doc/FreeCol.tex b/doc/FreeCol.tex index 9253c613b..744cb00e5 100644 --- a/doc/FreeCol.tex +++ b/doc/FreeCol.tex @@ -336,8 +336,8 @@ options: \item\verb$--version$ Display the version number. \item\verb$--default-locale LOCALE$ Specify a locale. \item\verb$--freecol-data DIR$ Specify the directory that contains -FreeCol's data files. In general, you will only need to use this if -you have installed a modified copy of FreeCol's data files. + FreeCol's data files. In general, you will only need to use this if + you have installed a modified copy of FreeCol's data files. \item\verb$--advantages ADVANTAGES$ Set the European nation advantages type, which must be one of \texttt{Selected} (each nation may choose an advantage), \texttt{Fixed} (the standard advantage types are @@ -352,21 +352,22 @@ you have installed a modified copy of FreeCol's data files. European colonial nations (normally the classic four: Dutch, English, French, Spanish). \item\verb$--font FONTSPEC$ Override the default font with a Java -font specifier (e.g. Arial-BOLD-12). + font specifier (e.g. Arial-BOLD-12). \item\verb$--full-screen$ Run FreeCol in full screen mode. \item\verb$--load-savegame SAVEGAME_FILE$ Load the given - savegame. This is particularly useful in combination with the client + savegame. This is particularly useful in combination with the client option \hyperlink{show savegame settings}{show savegame settings}. \item\verb$--log-file FILE$ Override the location of the log file. \item\verb$--name NAME$ Specify a player name. \item\verb$--no-intro$ Skip the introductory video. -\item\verb$--no-sound$ Run FreeCol without sound. Note that the game -does not yet contain any music, so the only sounds you will hear will -be special effects. +\item\verb$--no-sound$ Run FreeCol without sound. Note that the game + does not yet contain background music, so the only sounds you will + hear will be special effects. +\item\verb$--no-splash$ Skip the splash screen. \item\verb$--server PORT$ Start a stand-alone server on the specified -port. If you don't know what that means, you will not need the option. + port. \item\verb$--server-help$ Display a help screen for the more advanced -server options. + server options. \item\verb$--splash FILE$ Specify the location of the splash screen file. \item\verb$--timeout TIMEOUT$ Specifies the number of seconds the server should wait for a player to answer a question (e.g. demands @@ -378,20 +379,20 @@ server options. exist this option will be ignored. \item\verb$--user-config-directory DIRECTORY$ Use the given directory instead of your default FreeCol user configuration directory to load - client and custom options. You can use this in order to run the + client and custom options. You can use this in order to run the game from a USB stick\index{USB stick}, for example. Please note that specifying a client options file on the command line will override the options directory. If the specified directory does not exist this option will be ignored. \item\verb$--user-data-directory DIRECTORY$ Use the given directory instead of your default FreeCol user data directory to load and save - games, and user mods. You can use this in order to run the - game from a USB stick\index{USB stick}, for example. Please note + games, and user mods. You can use this in order to run the + game from a USB stick\index{USB stick}, for example. Please note that specifying a save game file on the command line will override the save game directory. If the specified directory does not exist FreeCol will exit. \item\verb$--windowed[[=]WIDTHxHEIGHT]$ Run FreeCol in windowed mode, - and optionally explicitly set the window width and height. If the + and optionally explicitly set the window width and height. If the size is not specified FreeCol will attempt to use as much space as possible without overlapping menu bars et al. Window size determination is not always correct for all combinations of diff --git a/src/net/sf/freecol/FreeCol.java b/src/net/sf/freecol/FreeCol.java index 5cf7e19dd..aef00ed60 100644 --- a/src/net/sf/freecol/FreeCol.java +++ b/src/net/sf/freecol/FreeCol.java @@ -22,16 +22,23 @@ package net.sf.freecol; import java.awt.Dimension; import java.io.File; import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; import java.io.IOException; import java.lang.Thread.UncaughtExceptionHandler; import java.net.InetAddress; +import java.net.JarURLConnection; import java.net.URL; import java.net.JarURLConnection; import java.util.Locale; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.zip.ZipEntry; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; @@ -125,7 +132,7 @@ public final class FreeCol { private static final String JAVA_VERSION_MIN = "1.7"; private static final int MEMORY_MIN = 128; // Mbytes private static final int PORT_DEFAULT = 3541; - private static final String SPLASH_FILE_DEFAULT = "splash.jpg"; + private static final String SPLASH_DEFAULT = "splash.jpg"; private static final String TC_DEFAULT = "freecol"; public static final int TIMEOUT_DEFAULT = 60; // 1 minute public static final int TIMEOUT_MIN = 10; // 10s @@ -174,8 +181,8 @@ public final class FreeCol { private static int serverPort = -1; private static String serverName = null; - /** Where the splash file lives. */ - private static String splashFilename = SPLASH_FILE_DEFAULT; + /** A stream to get the splash image from. */ + private static InputStream splashStream; /** The TotalConversion / ruleset in play, defaults to "freecol". */ private static String tc = null; @@ -202,13 +209,30 @@ public final class FreeCol { */ public static void main(String[] args) { freeColRevision = FREECOL_VERSION; + JarURLConnection juc; try { - String revision = readVersion(FreeCol.class); - if (revision != null) { - freeColRevision += " (Revision: " + revision + ")"; + juc = getJarURLConnection(FreeCol.class); + } catch (IOException ioe) { + juc = null; + System.err.println("Unable to open class jar: " + + ioe.getMessage()); + } + if (juc != null) { + try { + String revision = readVersion(juc); + if (revision != null) { + freeColRevision += " (Revision: " + revision + ")"; + } + } catch (Exception e) { + System.err.println("Unable to load Manifest: " + + e.getMessage()); + } + try { + splashStream = getDefaultSplashStream(juc); + } catch (Exception e) { + System.err.println("Unable to open default splash: " + + e.getMessage()); } - } catch (Exception e) { - System.err.println("Unable to load Manifest: " + e.getMessage()); } // Java bug #7075600 causes BR#2554. The workaround is to set @@ -316,18 +340,43 @@ public final class FreeCol { /** - * Extract the package version from the class. + * Get the JarURLConnection from a class. * - * @param c The Class to extract from. - * @return A value of the package version attribute. + * @return The JarURLConnection. */ - private static String readVersion(Class c) throws IOException { + private static JarURLConnection getJarURLConnection(Class c) throws IOException { String resourceName = "/" + c.getName().replace('.', '/') + ".class"; URL url = c.getResource(resourceName); - Manifest mf = ((JarURLConnection)url.openConnection()).getManifest(); - return mf.getMainAttributes().getValue("Package-Version"); + return (JarURLConnection)url.openConnection(); + } + + /** + * Extract the package version from the class. + * + * @param juc The JarURLConnection to extract from. + * @return A value of the package version attribute. + */ + private static String readVersion(JarURLConnection juc) throws IOException { + Manifest mf = juc.getManifest(); + return (mf == null) ? null + : mf.getMainAttributes().getValue("Package-Version"); } + /** + * Get a stream for the default splash file. + * + * Note: Not bothering to check for nulls as this is called in try + * block that ignores all exceptions. + * + * @param juc The JarURLConnection to extract from. + * @return A suitable InputStream, or null on error. + */ + private static InputStream getDefaultSplashStream(JarURLConnection juc) throws IOException { + JarFile jf = juc.getJarFile(); + ZipEntry ze = jf.getEntry(SPLASH_DEFAULT); + return jf.getInputStream(ze); + } + /** * Exit printing fatal error message. * @@ -517,6 +566,9 @@ public final class FreeCol { options.addOption(OptionBuilder.withLongOpt("no-sound") .withDescription(Messages.message("cli.no-sound")) .create()); + options.addOption(OptionBuilder.withLongOpt("no-splash") + .withDescription(Messages.message("cli.no-splash")) + .create()); options.addOption(OptionBuilder.withLongOpt("private") .withDescription(Messages.message("cli.private")) .create()); @@ -722,6 +774,9 @@ public final class FreeCol { if (line.hasOption("no-sound")) { sound = false; } + if (line.hasOption("no-splash")) { + splashStream = null; + } if (line.hasOption("private")) { publicServer = false; @@ -744,7 +799,14 @@ public final class FreeCol { } if (line.hasOption("splash")) { - splashFilename = line.getOptionValue("splash"); + String splash = line.getOptionValue("splash"); + try { + FileInputStream fis = new FileInputStream(splash); + splashStream = fis; + } catch (FileNotFoundException fnfe) { + gripe(StringTemplate.template("cli.error.splash") + .addName("%name%", splash)); + } } if (line.hasOption("tc")) { @@ -1312,7 +1374,7 @@ public final class FreeCol { // savegame was specified on command line } final FreeColClient freeColClient - = new FreeColClient(splashFilename, fontName, guiScale, headless); + = new FreeColClient(splashStream, fontName, guiScale, headless); freeColClient.startClient(windowSize, userMsg, sound, introVideo, savegame, spec); } diff --git a/src/net/sf/freecol/client/FreeColClient.java b/src/net/sf/freecol/client/FreeColClient.java index f1d6ace99..bd216212f 100644 --- a/src/net/sf/freecol/client/FreeColClient.java +++ b/src/net/sf/freecol/client/FreeColClient.java @@ -21,6 +21,7 @@ package net.sf.freecol.client; import java.awt.Dimension; import java.io.File; +import java.io.InputStream; import java.io.IOException; import java.util.Collections; import java.util.List; @@ -132,21 +133,21 @@ public final class FreeColClient { private final boolean headless; - public FreeColClient(final String splashFilename, + public FreeColClient(final InputStream splashStream, final String fontName) { - this(splashFilename, fontName, FreeCol.GUI_SCALE_DEFAULT, true); + this(splashStream, fontName, FreeCol.GUI_SCALE_DEFAULT, true); } /** * Creates a new FreeColClient. Creates the control * objects. * - * @param splashFilename The name of the splash image. + * @param splashStream A stream to read the splash image from. * @param fontName An optional override of the main font. * @param scale The scale factor for gui elements. * @param headless Run in headless mode. */ - public FreeColClient(final String splashFilename, final String fontName, + public FreeColClient(final InputStream splashStream, final String fontName, final float scale, boolean headless) { mapEditor = false; this.headless = headless @@ -161,7 +162,7 @@ public final class FreeColClient { // Get the splash screen up early on to show activity. gui = (this.headless) ? new GUI(this, scale) : new SwingGUI(this, scale); - gui.displaySplashScreen(splashFilename); + gui.displaySplashScreen(splashStream); // Look for base data directory. Failure is fatal. File baseDirectory = FreeColDirectories.getBaseDirectory(); diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 265a17679..4432ccb0f 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -27,6 +27,7 @@ import java.awt.Rectangle; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.File; +import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -177,9 +178,9 @@ public class GUI { /** * Display the splash screen. * - * @param splashFilename The name of the file to find the image in. + * @param splashStream A stream to find the image in. */ - public void displaySplashScreen(final String splashFilename) { + public void displaySplashScreen(final InputStream splashStream) { } /** diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index e2423a592..d971df40a 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -30,21 +30,23 @@ import java.awt.Image; import java.awt.MouseInfo; import java.awt.Point; import java.awt.Rectangle; -import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.io.InputStream; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.logging.Level; +import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JWindow; @@ -217,15 +219,14 @@ public class SwingGUI extends GUI { /** * Display the splash screen. * - * @param splashFilename The name of the file to find the image in. + * @param splashStream A stream to read the splash image from. */ @Override - public void displaySplashScreen(final String splashFilename) { + public void displaySplashScreen(final InputStream splashStream) { splash = null; - if (splashFilename == null) - return; + if (splashStream == null) return; try { - Image im = Toolkit.getDefaultToolkit().getImage(splashFilename); + BufferedImage im = ImageIO.read(splashStream); splash = new JWindow(graphicsDevice.getDefaultConfiguration()); splash.getContentPane().add(new JLabel(new ImageIcon(im))); splash.pack(); From 14e703927eca2f1e08f64c63f564a86bcd7db6d6 Mon Sep 17 00:00:00 2001 From: Michael Pope Date: Tue, 28 Jul 2015 11:57:44 +0930 Subject: [PATCH 027/323] Add greyed unit icons for vacant education places in RCCP. --- data/strings/FreeColMessages.properties | 1 + .../gui/panel/ReportCompactColonyPanel.java | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index 7038bd6f6..8389c0ec7 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -3055,6 +3055,7 @@ report.colony.making.blocking.description=%colony%: %amount% %goods% needed for report.colony.making.constructing.description=%colony%: %buildable% completes {{plural:%turns%|one=next turn|other=in %turns% turns}} report.colony.making.description=What this colony is making report.colony.making.educating.description=%colony%: %teacher% graduates {{plural:%turns%|one=next turn|other=in %turns% turns}} +report.colony.making.educationVacancy.description=%colony%: {{plural:%number%|one=one student place is|other=%number% student places are}} vacant report.colony.making.educating.summary.description=Units (type and count) expected to graduate from schools of this continent report.colony.making.header=Making report.colony.making.noconstruction.description=%colony%: No construction occurring diff --git a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java index 091bdb51b..490cab07b 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java @@ -504,6 +504,8 @@ public final class ReportCompactColonyPanel extends ReportPanel */ private void updateColony(ColonySummary s) { final String cac = s.colony.getId(); + final UnitType defaultUnitType + = spec.getDefaultUnitType(s.colony.getOwner()); List buttons = new ArrayList<>(); JButton b; Color c; @@ -700,8 +702,7 @@ public final class ReportCompactColonyPanel extends ReportPanel if (s.newColonist > 0) { t = stpld("report.colony.arriving") .addName("%colony%", s.colony.getName()) - .addNamed("%unit%", - spec.getDefaultUnitType(s.colony.getOwner())) + .addNamed("%unit%", defaultUnitType) .addAmount("%turns%", s.newColonist); b = newButton(cac, Integer.toString(s.newColonist), null, cGood, t); @@ -755,8 +756,13 @@ public final class ReportCompactColonyPanel extends ReportPanel buttons.add(b); } - // Field: What is being trained. + // Field: What is being trained, including shadow units for vacant + // places. // Colour: cAlarm if completion is blocked, otherwise cPlain. + int empty = 0; + Building school = s.colony.getWorkLocationWithAbility(Ability.TEACH, + Building.class); + if (school != null) empty = school.getType().getWorkPlaces(); for (Entry e : mapEntriesByValue(s.teachers, descendingIntegerComparator)) { Unit u = e.getKey(); @@ -778,6 +784,18 @@ public final class ReportCompactColonyPanel extends ReportPanel cPlain, t); } buttons.add(b); + empty--; + } + + if (empty > 0) { + final ImageIcon emptyIcon + = new ImageIcon(this.lib.getTinyUnitImage(defaultUnitType, true)); + t = stpld("report.colony.making.educationVacancy") + .addName("%colony%", s.colony.getName()) + .addAmount("%number%", empty); + for (; empty > 0; empty--) { + buttons.add(newButton(cac, "", emptyIcon, cPlain, t)); + } } addTogether(buttons); From 8394732cb9cbfab04aacf5e895e765f3a0f04ec7 Mon Sep 17 00:00:00 2001 From: Michael Pope Date: Fri, 31 Jul 2015 14:19:25 +0930 Subject: [PATCH 028/323] Add back the colony popup for a case in IGC. --- src/net/sf/freecol/client/control/InGameController.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/net/sf/freecol/client/control/InGameController.java b/src/net/sf/freecol/client/control/InGameController.java index 160d54d8e..403eebb1f 100644 --- a/src/net/sf/freecol/client/control/InGameController.java +++ b/src/net/sf/freecol/client/control/InGameController.java @@ -907,6 +907,9 @@ public final class InGameController implements NetworkConstants { // Clear ordinary destinations if arrived. if (movePath(unit, path) && unit.isAtLocation(destination)) { askClearGotoOrders(unit); + Colony colony = (unit.hasTile()) ? unit.getTile().getColony() + : null; + if (colony != null) gui.showColonyPanel(colony, unit); // Check cash-in, and if the unit has moves left and was // not set to SKIPPED by moveDirection, then return true // to show that this unit could continue. @@ -2563,8 +2566,7 @@ public final class InGameController implements NetworkConstants { && !tile.hasSettlement(); if (ret) { player.invalidateCanSeeTiles(); - gui.setActiveUnit(null); - gui.setSelectedTile(tile); + gui.setActiveUnit(tile.getFirstUnit()); } return ret; } @@ -2727,10 +2729,7 @@ public final class InGameController implements NetworkConstants { && tile.hasSettlement(); if (ret) { player.invalidateCanSeeTiles(); - gui.setActiveUnit(null); gui.showColonyPanel((Colony)tile.getSettlement(), unit); - // FIXME: Check if next line can be removed or replaced - gui.setSelectedTile(tile); freeColClient.getSoundController() .playSound("sound.event.buildingComplete"); // Check units present for treasure cash-in as they are now From 1728101dbd630995a85407120d49067fdb9f9af0 Mon Sep 17 00:00:00 2001 From: Michael Pope Date: Tue, 16 Jun 2015 09:20:28 +0930 Subject: [PATCH 029/323] Simplification of InfoPanel mode, BR#2867b. --- src/net/sf/freecol/client/gui/panel/InfoPanel.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/net/sf/freecol/client/gui/panel/InfoPanel.java b/src/net/sf/freecol/client/gui/panel/InfoPanel.java index a30637022..d2393bee3 100644 --- a/src/net/sf/freecol/client/gui/panel/InfoPanel.java +++ b/src/net/sf/freecol/client/gui/panel/InfoPanel.java @@ -441,10 +441,7 @@ public final class InfoPanel extends FreeColPanel { ? InfoPanelMode.TILE : (unitInfoPanel.hasUnit()) ? InfoPanelMode.UNIT - : ((player = getFreeColClient().getMyPlayer()) != null - && !player.hasNextActiveUnit()) - ? InfoPanelMode.END - : InfoPanelMode.NONE; + : InfoPanelMode.END; } /** From a81761390e3e44b9ce364a9bd59061fc5b0b1319 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Fri, 31 Jul 2015 19:02:59 +0200 Subject: [PATCH 030/323] Tentatively fix BR#2806 Partially reverts git.1728101d, which still needs reconsideration. I think the problem was active units being available, but the InfoPanel not having the reference to the unit updated, but I can't verify it, as BR#2806 could never be reliably reproduced. --- src/net/sf/freecol/client/gui/panel/InfoPanel.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/net/sf/freecol/client/gui/panel/InfoPanel.java b/src/net/sf/freecol/client/gui/panel/InfoPanel.java index d2393bee3..1bc5555f3 100644 --- a/src/net/sf/freecol/client/gui/panel/InfoPanel.java +++ b/src/net/sf/freecol/client/gui/panel/InfoPanel.java @@ -441,6 +441,10 @@ public final class InfoPanel extends FreeColPanel { ? InfoPanelMode.TILE : (unitInfoPanel.hasUnit()) ? InfoPanelMode.UNIT + : ((player = getFreeColClient().getMyPlayer()) == null) + ? InfoPanelMode.NONE + : player.hasNextActiveUnit() + ? InfoPanelMode.UNIT : InfoPanelMode.END; } @@ -493,6 +497,10 @@ public final class InfoPanel extends FreeColPanel { */ public void update() { InfoPanelMode newMode = getMode(); + if(newMode == InfoPanelMode.UNIT && !unitInfoPanel.hasUnit()) { + unitInfoPanel.update( + getFreeColClient().getMyPlayer().getNextActiveUnit()); + } if (this.mode != newMode) { switch (this.mode = newMode) { case END: From a8ec7dbd79c41dedf12e24a4e4d98ed16d75e272 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Fri, 31 Jul 2015 19:39:39 +0200 Subject: [PATCH 031/323] Revert addition of cast in git.94b94f56, which got unnecessary through git.f483359f --- .../sf/freecol/client/gui/panel/ReportCompactColonyPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java index 490cab07b..7ed5b806c 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportCompactColonyPanel.java @@ -1136,7 +1136,7 @@ public final class ReportCompactColonyPanel extends ReportPanel } else { Colony colony = game.getFreeColGameObject(command, Colony.class); if (colony != null) { - ((SwingGUI)getGUI()).showColonyPanel2(colony, null) + getGUI().showColonyPanel2(colony, null) .addClosingCallback(new Runnable() { @Override public void run() { From 6df2c12b39b0532794f318d10677927bb9a207db Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Fri, 31 Jul 2015 19:48:09 +0200 Subject: [PATCH 032/323] Remove dependence of GUI on ColorChooserPanel --- src/net/sf/freecol/client/gui/GUI.java | 6 ------ src/net/sf/freecol/client/gui/SwingGUI.java | 1 - src/net/sf/freecol/client/gui/panel/ColorCellEditor.java | 4 ++-- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 4432ccb0f..49f9fd311 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -24,7 +24,6 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; -import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.File; import java.io.InputStream; @@ -42,7 +41,6 @@ import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.control.InGameController; import net.sf.freecol.client.control.InGameController.*; -import net.sf.freecol.client.gui.panel.ColorChooserPanel; import net.sf.freecol.client.gui.panel.LabourData.UnitData; import net.sf.freecol.client.gui.panel.MiniMap; import net.sf.freecol.client.gui.panel.Parameters; @@ -1242,10 +1240,6 @@ public class GUI { public void showColopediaPanel(String nodeId) { } - public ColorChooserPanel showColorChooserPanel(ActionListener al) { - return null; - } - public void showCompactLabourReport() { } diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index d971df40a..9651b7def 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -1048,7 +1048,6 @@ public class SwingGUI extends GUI { canvas.showColopediaPanel(nodeId); } - @Override public ColorChooserPanel showColorChooserPanel(ActionListener al) { return canvas.showColorChooserPanel(al); } diff --git a/src/net/sf/freecol/client/gui/panel/ColorCellEditor.java b/src/net/sf/freecol/client/gui/panel/ColorCellEditor.java index b7bb89202..eb1e2c0f2 100644 --- a/src/net/sf/freecol/client/gui/panel/ColorCellEditor.java +++ b/src/net/sf/freecol/client/gui/panel/ColorCellEditor.java @@ -32,7 +32,7 @@ import javax.swing.JTable; import javax.swing.table.TableCellEditor; import net.sf.freecol.client.FreeColClient; -import net.sf.freecol.client.gui.GUI; +import net.sf.freecol.client.gui.SwingGUI; /** @@ -98,7 +98,7 @@ public final class ColorCellEditor extends AbstractCellEditor @Override public void actionPerformed(ActionEvent event) { final String command = event.getActionCommand(); - GUI gui = freeColClient.getGUI(); + SwingGUI gui = (SwingGUI)freeColClient.getGUI(); if (null != command) switch (command) { case EDIT: this.colorChooserPanel = gui.showColorChooserPanel(this); From ee21593c0cdfad486b055793f4280cd53d03397d Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Fri, 31 Jul 2015 20:17:21 +0200 Subject: [PATCH 033/323] Clean up confirm methods in GUI and SwingGUI --- src/net/sf/freecol/client/gui/GUI.java | 31 +++---------- src/net/sf/freecol/client/gui/SwingGUI.java | 49 ++++++++++----------- 2 files changed, 28 insertions(+), 52 deletions(-) diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 49f9fd311..1e7d57fa8 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -448,48 +448,27 @@ public class GUI { * @param modal Is this a modal dialog? * @param tile An optional Tile to expose. * @param template The StringTemplate explaining the choice. - * @param obj An optional unit to make an icon for the dialog from. + * @param unit An optional unit to make an icon for the dialog from. * @param okKey A key for the "ok" button. * @param cancelKey A key for the "cancel" button. * @return True if the "ok" button was selected. */ public boolean confirm(boolean modal, Tile tile, - StringTemplate template, Unit obj, + StringTemplate template, Unit unit, String okKey, String cancelKey) { return false; } - /** - * General confirmation dialog. - * - * @param modal Is this a modal dialog? - * @param tile An optional Tile to expose. - * @param template The StringTemplate explaining the choice. - * @param icon An optional icon for the dialog. - * @param okKey A key for the "ok" button. - * @param cancelKey A key for the "cancel" button. - * @return True if the "ok" button was selected. - */ public boolean confirm(boolean modal, Tile tile, - StringTemplate template, ImageIcon icon, - String okKey, String cancelKey) { - return false; - } - - final public boolean confirm(boolean modal, Tile tile, StringTemplate template, Settlement settlement, String okKey, String cancelKey) { - return confirm(modal, tile, template, - new ImageIcon(imageLibrary.getSettlementImage(settlement)), - okKey, cancelKey); + return false; } - final public boolean confirm(boolean modal, Tile tile, + public boolean confirm(boolean modal, Tile tile, StringTemplate template, GoodsType goodsType, String okKey, String cancelKey) { - return confirm(modal, tile, template, - new ImageIcon(imageLibrary.getIconImage(goodsType)), - okKey, cancelKey); + return false; } /** diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index 9651b7def..a14d33101 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -734,9 +734,8 @@ public class SwingGUI extends GUI { */ @Override public boolean confirm(String textKey, String okKey, String cancelKey) { - return canvas.showConfirmDialog(true, null, - Messages.message(textKey), null, - okKey, cancelKey); + return canvas.showConfirmDialog(true, null, Messages.message(textKey), + null, okKey, cancelKey); } /** @@ -754,8 +753,7 @@ public class SwingGUI extends GUI { StringTemplate template, String okKey, String cancelKey) { return canvas.showConfirmDialog(modal, tile, - Utility.localizedTextArea(template), - null, okKey, cancelKey); + Utility.localizedTextArea(template), null, okKey, cancelKey); } /** @@ -764,40 +762,39 @@ public class SwingGUI extends GUI { * @param modal Is this a modal dialog? * @param tile An optional Tile to expose. * @param template The StringTemplate explaining the choice. - * @param obj An optional unit to make an icon for the dialog from. + * @param unit An optional unit to make an icon for the dialog from. * @param okKey A key for the "ok" button. * @param cancelKey A key for the "cancel" button. * @return True if the "ok" button was selected. */ @Override public boolean confirm(boolean modal, Tile tile, - StringTemplate template, Unit obj, + StringTemplate template, Unit unit, String okKey, String cancelKey) { return canvas.showConfirmDialog(modal, tile, - Utility.localizedTextArea(template), - (obj == null) ? null : new ImageIcon( - imageLibrary.getUnitImage(obj)), - okKey, cancelKey); + Utility.localizedTextArea(template), + new ImageIcon(imageLibrary.getUnitImage(unit)), + okKey, cancelKey); } - /** - * General confirmation dialog. - * - * @param modal Is this a modal dialog? - * @param tile An optional Tile to expose. - * @param template The StringTemplate explaining the choice. - * @param icon An optional icon for the dialog. - * @param okKey A key for the "ok" button. - * @param cancelKey A key for the "cancel" button. - * @return True if the "ok" button was selected. - */ @Override public boolean confirm(boolean modal, Tile tile, - StringTemplate template, ImageIcon icon, - String okKey, String cancelKey) { + StringTemplate template, Settlement settlement, + String okKey, String cancelKey) { return canvas.showConfirmDialog(modal, tile, - Utility.localizedTextArea(template), - icon, okKey, cancelKey); + Utility.localizedTextArea(template), + new ImageIcon(imageLibrary.getSettlementImage(settlement)), + okKey, cancelKey); + } + + @Override + public boolean confirm(boolean modal, Tile tile, + StringTemplate template, GoodsType goodsType, + String okKey, String cancelKey) { + return canvas.showConfirmDialog(modal, tile, + Utility.localizedTextArea(template), + new ImageIcon(imageLibrary.getIconImage(goodsType)), + okKey, cancelKey); } /** From 8f2348bbceb1576d329120654afe9011b98bc9a0 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Fri, 31 Jul 2015 20:47:21 +0200 Subject: [PATCH 034/323] Clean up getChoice methods in GUI and SwingGUI --- src/net/sf/freecol/client/gui/GUI.java | 68 +++++++++------------ src/net/sf/freecol/client/gui/SwingGUI.java | 43 +++++++++++-- 2 files changed, 67 insertions(+), 44 deletions(-) diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 1e7d57fa8..9590d7d83 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -33,7 +33,6 @@ import java.util.List; import java.util.Map; import java.util.logging.Logger; -import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.filechooser.FileFilter; @@ -67,6 +66,7 @@ import net.sf.freecol.common.model.IndianSettlement; import net.sf.freecol.common.model.Location; import net.sf.freecol.common.model.ModelMessage; import net.sf.freecol.common.model.Monarch.MonarchAction; +import net.sf.freecol.common.model.Nation; import net.sf.freecol.common.model.NationSummary; import net.sf.freecol.common.model.Player; import net.sf.freecol.common.model.Region; @@ -721,8 +721,7 @@ public class GUI { return getChoice(true, settlement.getTile(), Utility.localizedTextArea(settlement.getAlarmLevelLabel(player)), - new ImageIcon(imageLibrary.getSettlementImage(settlement)), - "cancel", choices); + settlement, "cancel", choices); } /** @@ -749,8 +748,7 @@ public class GUI { BoycottAction.DUMP_CARGO)); return getChoice(true, null, Utility.localizedTextArea(template), - new ImageIcon(imageLibrary.getIconImage(goods.getType())), - "cancel", choices); + goods.getType(), "cancel", choices); } /** @@ -777,8 +775,7 @@ public class GUI { BuyAction.HAGGLE)); return getChoice(true, unit.getTile(), Utility.localizedTextArea(template), - new ImageIcon(imageLibrary.getIconImage(goods.getType())), - "cancel", choices); + goods.getType(), "cancel", choices); } /** @@ -810,8 +807,7 @@ public class GUI { ClaimAction.STEAL)); return getChoice(true, tile, Utility.localizedTextArea(template), - new ImageIcon(imageLibrary.getMiscIconImage(owner.getNation())), - "indianLand.cancel", choices); + owner.getNation(), "indianLand.cancel", choices); } /** @@ -848,9 +844,7 @@ public class GUI { return getChoice(true, settlement.getTile(), Utility.localizedTextArea(template), - new ImageIcon( - imageLibrary.getSettlementImage(settlement)), - "cancel", choices); + settlement, "cancel", choices); } /** @@ -890,9 +884,7 @@ public class GUI { return getChoice(true, unit.getTile(), Utility.localizedTextArea(template), - new ImageIcon( - imageLibrary.getSettlementImage(settlement)), - "cancel", choices); + settlement, "cancel", choices); } /** @@ -949,9 +941,7 @@ public class GUI { return getChoice(true, unit.getTile(), Utility.localizedTextArea(template), - new ImageIcon( - imageLibrary.getSettlementImage(colony)), - "cancel", choices); + colony, "cancel", choices); } /** @@ -1011,9 +1001,7 @@ public class GUI { return getChoice(true, settlement.getTile(), Utility.localizedTextArea(template), - new ImageIcon( - imageLibrary.getSettlementImage(settlement)), - "cancel", choices); + settlement, "cancel", choices); } /** @@ -1045,8 +1033,7 @@ public class GUI { return getChoice(true, unit.getTile(), Utility.localizedTextArea(template), - new ImageIcon(imageLibrary.getIconImage(goods.getType())), - "cancel", choices); + goods.getType(), "cancel", choices); } @@ -1056,37 +1043,38 @@ public class GUI { * @param modal Is this a modal dialog? * @param tile An optional Tile to expose. * @param explain An object explaining the choice. - * @param icon An optional icon for the dialog. * @param cancelKey A key for the "cancel" button. * @param choices A list a ChoiceItems to choose from. * @return The selected value of the selected ChoiceItem, * or null if cancelled. */ public T getChoice(boolean modal, Tile tile, Object explain, - ImageIcon icon, String cancelKey, List> choices) { return null; } - final public T getChoice(boolean modal, Tile tile, Object explain, - String cancelKey, List> choices) { - return getChoice(modal, tile, explain, - (ImageIcon)null, cancelKey, choices); + public T getChoice(boolean modal, Tile tile, Object explain, + Unit unit, + String cancelKey, List> choices) { + return null; } - final public T getChoice(boolean modal, Tile tile, Object explain, - Unit unit, - String cancelKey, List> choices) { - return getChoice(modal, tile, explain, - new ImageIcon(imageLibrary.getUnitImage(unit)), cancelKey, choices); + public T getChoice(boolean modal, Tile tile, Object explain, + Settlement settlement, + String cancelKey, List> choices) { + return null; } - final public T getChoice(boolean modal, Tile tile, Object explain, - Settlement settlement, - String cancelKey, List> choices) { - return getChoice(modal, tile, explain, - new ImageIcon(imageLibrary.getSettlementImage(settlement)), - cancelKey, choices); + public T getChoice(boolean modal, Tile tile, Object explain, + GoodsType goodsType, + String cancelKey, List> choices) { + return null; + } + + public T getChoice(boolean modal, Tile tile, Object explain, + Nation nation, + String cancelKey, List> choices) { + return null; } /** diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index a14d33101..45e0f5698 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -87,6 +87,7 @@ import net.sf.freecol.common.model.IndianSettlement; import net.sf.freecol.common.model.Location; import net.sf.freecol.common.model.ModelMessage; import net.sf.freecol.common.model.Monarch.MonarchAction; +import net.sf.freecol.common.model.Nation; import net.sf.freecol.common.model.Player; import net.sf.freecol.common.model.Region; import net.sf.freecol.common.model.Settlement; @@ -813,7 +814,6 @@ public class SwingGUI extends GUI { * @param modal Is this a modal dialog? * @param tile An optional Tile to expose. * @param explain An object explaining the choice. - * @param icon An optional icon for the dialog. * @param cancelKey A key for the "cancel" button. * @param choices A list a ChoiceItems to choose from. * @return The selected value of the selected ChoiceItem, @@ -821,10 +821,45 @@ public class SwingGUI extends GUI { */ @Override public T getChoice(boolean modal, Tile tile, Object explain, - ImageIcon icon, String cancelKey, List> choices) { - return canvas.showChoiceDialog(modal, tile, explain, icon, - cancelKey, choices); + return canvas.showChoiceDialog(modal, tile, explain, + null, cancelKey, choices); + } + + @Override + public T getChoice(boolean modal, Tile tile, Object explain, + Unit unit, + String cancelKey, List> choices) { + return canvas.showChoiceDialog(modal, tile, explain, + new ImageIcon(imageLibrary.getUnitImage(unit)), + cancelKey, choices); + } + + @Override + public T getChoice(boolean modal, Tile tile, Object explain, + Settlement settlement, + String cancelKey, List> choices) { + return canvas.showChoiceDialog(modal, tile, explain, + new ImageIcon(imageLibrary.getSettlementImage(settlement)), + cancelKey, choices); + } + + @Override + public T getChoice(boolean modal, Tile tile, Object explain, + GoodsType goodsType, + String cancelKey, List> choices) { + return canvas.showChoiceDialog(modal, tile, explain, + new ImageIcon(imageLibrary.getIconImage(goodsType)), + cancelKey, choices); + } + + @Override + public T getChoice(boolean modal, Tile tile, Object explain, + Nation nation, + String cancelKey, List> choices) { + return canvas.showChoiceDialog(modal, tile, explain, + new ImageIcon(imageLibrary.getMiscIconImage(nation)), + cancelKey, choices); } /** From b379aeaecb77a7e09d0f2736ab0fd95c4a814b72 Mon Sep 17 00:00:00 2001 From: Sebastian Zhorel Date: Fri, 31 Jul 2015 21:59:48 +0200 Subject: [PATCH 035/323] Remove GUI.displayObject() --- src/net/sf/freecol/client/gui/GUI.java | 3 --- src/net/sf/freecol/client/gui/SwingGUI.java | 1 - src/net/sf/freecol/client/gui/panel/InformationPanel.java | 4 ++-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/net/sf/freecol/client/gui/GUI.java b/src/net/sf/freecol/client/gui/GUI.java index 9590d7d83..d7685e79c 100644 --- a/src/net/sf/freecol/client/gui/GUI.java +++ b/src/net/sf/freecol/client/gui/GUI.java @@ -1106,9 +1106,6 @@ public class GUI { return false; } - public void displayObject(FreeColObject fco) { - } - public LoadingSavegameInfo getLoadingSavegameInfo() { return null; } diff --git a/src/net/sf/freecol/client/gui/SwingGUI.java b/src/net/sf/freecol/client/gui/SwingGUI.java index 45e0f5698..7fb8c8104 100644 --- a/src/net/sf/freecol/client/gui/SwingGUI.java +++ b/src/net/sf/freecol/client/gui/SwingGUI.java @@ -914,7 +914,6 @@ public class SwingGUI extends GUI { * * @param fco The FreeColObject to display. */ - @Override public void displayObject(FreeColObject fco) { if (fco instanceof Colony) { canvas.showColonyPanel((Colony)fco, null); diff --git a/src/net/sf/freecol/client/gui/panel/InformationPanel.java b/src/net/sf/freecol/client/gui/panel/InformationPanel.java index 075869f74..0c4c64593 100644 --- a/src/net/sf/freecol/client/gui/panel/InformationPanel.java +++ b/src/net/sf/freecol/client/gui/panel/InformationPanel.java @@ -33,7 +33,7 @@ import javax.swing.JScrollPane; import net.miginfocom.swing.MigLayout; import net.sf.freecol.client.FreeColClient; -import net.sf.freecol.client.gui.GUI; +import net.sf.freecol.client.gui.SwingGUI; import net.sf.freecol.common.model.FreeColObject; import net.sf.freecol.common.model.Location; import net.sf.freecol.common.model.StringTemplate; @@ -75,7 +75,7 @@ public class InformationPanel extends FreeColPanel { super(freeColClient, new MigLayout("wrap 1, insets 200 10 10 10", "[510]", "[242]20[20]")); - final GUI gui = getGUI(); + final SwingGUI gui = getGUI(); JPanel textPanel = new MigPanel(); textPanel.setOpaque(false); textPanel.setLayout(new MigLayout("wrap 2", "", "top")); From 16b2aa31e7be08ea51435ba405d8cabcc0cc76ca Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sat, 1 Aug 2015 13:01:39 +0930 Subject: [PATCH 036/323] Add link for the manual to AboutPanel. --- data/strings/FreeColMessages.properties | 68 ++++++------------- .../freecol/client/gui/panel/AboutPanel.java | 15 +++- 2 files changed, 35 insertions(+), 48 deletions(-) diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index 8389c0ec7..13d580990 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -131,7 +131,6 @@ cargoOnCarrier=Cargo on carrier cashInTreasureTrain=Cash in treasure train clearOrders=Clear orders colonists=Colonists -colonyCenter=colony center colopedia=Colopedia difficulty=Difficulty docks=Docks @@ -217,7 +216,6 @@ cli.error.home.notDir=%string% is not a directory. cli.error.home.notExists=Directory %string% does not exist. cli.error.save=Can not read saved game %string%. cli.error.serverPort=%string% is not a valid port number. -cli.error.splash=Splash file %name% not found. cli.error.timeout=%string% is too short (less than %minimum%). cli.advantages=set the type of ADVANTAGES (%advantages%) @@ -247,7 +245,6 @@ cli.no-intro=skip the intro video cli.no-java-check=skip the java version check cli.no-memory-check=skip the memory check cli.no-sound=run FreeCol without sound -cli.no-splash=skip the splash screen cli.private=start a private server (not published to the metaserver) cli.seed=provide a SEED for the pseudo-random number generator cli.server-name=specify a custom NAME for the server @@ -1805,7 +1802,7 @@ model.improvement.road.occupationString=R # Limits model.limit.independence.coastalColonies.name=Coastal Colony Limit -model.limit.independence.coastalColonies.description=You need at least %limit% coastal {{plural:%limit%|one=colony|other=colonies}} in order to declare independence. +model.limit.independence.coastalColonies.description=You need at least %limit% coastal colonies in order to declare independence. model.limit.independence.rebels.name=Rebel Limit model.limit.independence.rebels.description=At least %limit%% of your colonists must support independence. model.limit.independence.year.name=Year Limit @@ -2222,7 +2219,7 @@ model.colony.badGovernment=The government of %colony% is inefficient. Production model.colony.goodGovernment=Government efficiency has improved! Rebel sentiment in %colony% now equals or exceeds %number% percent. model.colony.governmentImproved1=The government of %colony% has improved, but is still inefficient. Production penalties still apply. model.colony.governmentImproved2=The government of %colony% has improved. Production penalties no longer apply. -model.colony.insufficientProduction=%outputAmount% more %outputType% could be produced in %colony%, if an extra %consumptionDeficit% were available. +model.colony.insufficientProduction=%outputAmount% more %outputType% could be produced in %colony%, if only we had %inputAmount% more %inputType% surplus. model.colony.lostGoodGovernment=Government efficiency has decreased! Rebel sentiment in %colony% no longer equals or exceeds %number% percent. Colony no longer gains any production bonus. model.colony.lostVeryGoodGovernment=Government efficiency has decreased! Rebel sentiment in %colony% no longer equals or exceeds %number% percent. Some production bonuses were lost. model.colony.minimumColonySize=%object% prevents reducing the population any further. @@ -2529,7 +2526,6 @@ model.colony.colonyStarved=The last colonist in %colony% has starved, leaving th model.colony.customs.sale=The Customs House at %colony% sold: %data%. model.colony.customs.saleData=%amount% %goods% for %gold% model.colony.famineFeared=Famine feared in %colony%. Only %number% turns of food left. -model.colony.starving=%colony% is starving. model.colony.newColonist=New colonist in %colony%. model.colony.newConvert=A new %nation% convert has arrived in %colony%. model.colony.notBuildingAnything=Nothing is being built in %colony%. @@ -3037,60 +3033,40 @@ report.labour.workingAsOther=other # ReportColonyPanel # reuses colonyPanel.currentlyBuilding report.colony.arriving.description=%colony%: new %unit% {{plural:%turns%|one=next turn|other=in %turns% turns}} -report.colony.arriving.summary.description=The average number of turns before a new colonist arrives in the colonies of this continent report.colony.birth.description=Number of turns until a new colonist arrives or starves report.colony.explore.description=Number of tiles to Explore adjacent to this colony report.colony.explore.header=E report.colony.exploring.description=%colony% would benefit from exploring {{plural:%amount%|one=one tile|other=%amount% tiles}} -report.colony.exploring.summary.description=Total number of colony tiles that would benefit from exploring for this continent. report.colony.grow.description=Number of units the colony can grow by without harming production report.colony.grow.header=+ report.colony.growing.description=%colony% can grow by {{plural:%amount%|one=one unit|other=%amount% units}} without harming production -report.colony.growing.summary.description=The total number of colonists that can join colonies of this continent without harming production report.colony.improve.description=Units that could improve production. report.colony.improve.header=Improve -report.colony.improving.description=%colony% %location%: To make %amount% more %goods%, replace %oldUnit% with %unit% -report.colony.improving.summary.description=Units (type and count) that would benefit colonies of this continent +report.colony.improving.description=%colony%: To make %amount% more %goods%, replace %oldUnit% with %unit% +report.colony.wanting.description=%colony%: To make %amount% more %goods%, add %unit% report.colony.making.blocking.description=%colony%: %amount% %goods% needed for %buildable% {{plural:%turns%|one=next turn|other=in %turns% turns}} report.colony.making.constructing.description=%colony%: %buildable% completes {{plural:%turns%|one=next turn|other=in %turns% turns}} report.colony.making.description=What this colony is making report.colony.making.educating.description=%colony%: %teacher% graduates {{plural:%turns%|one=next turn|other=in %turns% turns}} -report.colony.making.educationVacancy.description=%colony%: {{plural:%number%|one=one student place is|other=%number% student places are}} vacant -report.colony.making.educating.summary.description=Units (type and count) expected to graduate from schools of this continent report.colony.making.header=Making report.colony.making.noconstruction.description=%colony%: No construction occurring report.colony.making.noteach.description=%colony%: %teacher% lacks a student -report.colony.making.summary.description=The per turn %goods% deficit due to the unsatisfied building requirements of this continent report.colony.name.description=The list of colonies report.colony.name.header=Colony -report.colony.name.summary.description=The region containing more of the above colonies of this continent -report.colony.production.description=%colony%: %amount% %goods% are being produced -report.colony.production.export.description=%colony%: %amount% %goods% are being produced (exporting above %export%) +report.colony.plow.description=Number of colony tiles that would benefit from Plowing +report.colony.plow.header=P +report.colony.plowing.description=%colony% would benefit from plowing {{plural:%amount%|one=one tile|other=%amount% tiles}} +report.colony.production.description=%colony%: net %goods% production = %amount% +report.colony.production.export.description=%colony%: net %goods% production is %amount% (exporting above %export%) report.colony.production.header=Net %goods% production -report.colony.production.high.description=%colony%: %amount% %goods% are being produced, full {{plural:%turns%|one=next turn|other=in %turns% turns}} -report.colony.production.low.description=%colony%: %amount% %goods% are being consumed, gone {{plural:%turns%|one=next turn|other=in %turns% turns}} -report.colony.production.maxConsumption.description=%colony%: %amount% %goods% are being consumed (could consume %more% more) -report.colony.production.maxProduction.description=%colony%: %amount% %goods% are being produced (could produce %more% more) -report.colony.production.summary.description=The amount of goods being produced or consumed -report.colony.production.waste.description=%colony%: %amount% %goods% are being produced, warehouse will overflow, %waste% will be wasted -report.colony.tile.clearForest.description=%colony% would benefit from clearing {{plural:%amount%|one=one tile|other=%amount% tiles}} -report.colony.tile.clearForest.specific.description=%colony% would benefit from clearing %location% -report.colony.tile.clearForest.header=C -report.colony.tile.clearForest.header.description=Number of colony tiles that would benefit from clearing. -report.colony.tile.clearForest.summary.description=Total number of colony tiles that would benefit from clearing for this continent. -report.colony.tile.plow.description=%colony% would benefit from plowing {{plural:%amount%|one=one tile|other=%amount% tiles}} -report.colony.tile.plow.specific.description=%colony% would benefit from plowing %location% -report.colony.tile.plow.header=P -report.colony.tile.plow.header.description=Number of colony tiles that would benefit from plowing. -report.colony.tile.plow.summary.description=Total number of colony tiles that would benefit from plowing for this continent. -report.colony.tile.road.description=%colony% would benefit from building {{plural:%amount%|one=a road|other=%amount% roads}} -report.colony.tile.road.specific.description=%colony% would benefit from building a road at %location% -report.colony.tile.road.header=R -report.colony.tile.road.header.description=Number of colony tiles that would benefit from road building. -report.colony.tile.road.summary.description=Total number of colony tiles that would benefit from road building for this continent. +report.colony.production.high.description=%colony%: net %goods% production = %amount%, full {{plural:%turns%|one=next turn|other=in %turns% turns}} +report.colony.production.low.description=%colony%: net %goods% production = %amount%, gone {{plural:%turns%|one=next turn|other=in %turns% turns}} +report.colony.production.waste.description=%colony%: net %goods% production = %amount%, warehouse will overflow, %waste% will be wasted +report.colony.road.description=Number of colony tiles that would benefit from Road building +report.colony.road.header=R +report.colony.roadBuilding.description=%colony% would benefit from building {{plural:%amount%|one=a road|other=%amount% roads}} report.colony.shrinking.description=%colony% must shrink by {{plural:%amount%|one=one unit|other=%amount% units}} to improve production report.colony.starving.description=%colony%: starvation {{plural:%turns%|one=next turn|other=in %turns% turns}} -report.colony.wanting.description=%colony% %location%: To make %amount% more %goods%, add %unit% # ReportContinentalCongressPanel report.continentalCongress.available=Available @@ -3163,15 +3139,15 @@ report.production.update=Update # ReportRequirementsPanel report.requirements.badAssignment=%colony% has a %expert% currently working as %expertWork%, while a %nonExpert% is working as %nonExpertWork%. Production would be greater if the colonists swapped jobs. report.requirements.canTrainExperts={{plural:2|%unit%}} can be trained at -report.requirements.exploreTile=%location% would benefit from exploration. +report.requirements.clearTile=%type% to the %direction% of %colony% would benefit from clearing. +report.requirements.exploreTile=%type% to the %direction% of %colony% would benefit from exploration. report.requirements.met=All requirements are met. report.requirements.missingGoods=%colony% is producing %goods%, but requires more %input%. report.requirements.misusedExperts=There are {{plural:2|%unit%}} not working as %work% present at report.requirements.noExpert=%colony% is producing %goods%, but has no %unit%. -report.requirements.tile.clearForest=%location% would benefit from clearing. -report.requirements.tile.plow=%location% would benefit from plowing. -report.requirements.tile.road=%location% would benefit from road building. -#report.requirements.tile.road.center can not happen +report.requirements.plowCenter=%colony% would benefit from plowing its tile. +report.requirements.plowTile=%type% to the %direction% of %colony% would benefit from plowing. +report.requirements.roadTile=%type% to the %direction% of %colony% would benefit from road building. report.requirements.severalExperts=Several {{plural:2|%unit%}} are present at report.requirements.surplus=A surplus of %goods% is being produced at @@ -3179,8 +3155,7 @@ report.requirements.surplus=A surplus of %goods% is being produced at report.trade.afterTaxes=Income after taxes report.trade.beforeTaxes=Income before taxes report.trade.cargoUnits=Units in Cargo -report.trade.export=Exporting %goods% above %amount% -report.trade.hasCustomHouse=* This colony has a custom house, and may export goods. +report.trade.hasCustomHouse=* This colony has a custom house; these goods are exported. report.trade.totalDelta=Total Production report.trade.totalUnits=Total Units report.trade.unitsSold=Units bought or sold @@ -3196,6 +3171,7 @@ report.turn.playerNation=%player%'s %nation% # AboutPanel aboutPanel.copyright=Copyright © 2002-2015 The FreeCol Team aboutPanel.legalDisclaimer=FreeCol is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version. +aboutPanel.manual=FreeCol Manual Download aboutPanel.officialSite=Official site: aboutPanel.sfProject=SourceForge project: aboutPanel.version=Version: diff --git a/src/net/sf/freecol/client/gui/panel/AboutPanel.java b/src/net/sf/freecol/client/gui/panel/AboutPanel.java index 16206315a..8e1f79f16 100644 --- a/src/net/sf/freecol/client/gui/panel/AboutPanel.java +++ b/src/net/sf/freecol/client/gui/panel/AboutPanel.java @@ -72,13 +72,15 @@ import net.sf.freecol.common.resources.ResourceManager; */ public final class AboutPanel extends FreeColPanel { - private static final Logger logger = Logger - .getLogger(AboutPanel.class.getName()); + private static final Logger logger = Logger.getLogger(AboutPanel.class.getName()); public static final String SITE_URL = "http://www.freecol.org"; public static final String PROJECT_URL = "http://sourceforge.net/projects/freecol/"; + private static final String MANUAL_URL + = "http://www.freecol.org/documentation/freecol-user-manual.html"; + /** * The constructor that will add the items to this panel. @@ -131,6 +133,15 @@ public final class AboutPanel extends FreeColPanel { apProjectURL.setFont(fontNormal); add(apProjectURL, "newline"); + // Manual + JLabel apManual = Utility.localizedLabel("aboutPanel.manual"); + apManual.setFont(fontBold); + add(apManual, "newline 10"); + JButton apManualURL = Utility.getLinkButton(MANUAL_URL, null, + MANUAL_URL); + apManualURL.addActionListener(this); + add(apManualURL, "newline"); + // License Disclaimer JTextArea apLegal = Utility.localizedTextArea("aboutPanel.legalDisclaimer"); From 62073e9c8e38c6c9331d66110e8947fe98987dfb Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sat, 1 Aug 2015 19:34:36 +0930 Subject: [PATCH 037/323] Make sure IR#164 is fixed. --- src/net/sf/freecol/client/FreeColClient.java | 9 ++++++--- src/net/sf/freecol/client/control/InGameController.java | 2 +- src/net/sf/freecol/client/gui/action/NewAction.java | 2 +- src/net/sf/freecol/client/gui/menu/MapEditorMenuBar.java | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/net/sf/freecol/client/FreeColClient.java b/src/net/sf/freecol/client/FreeColClient.java index bd216212f..2f39342be 100644 --- a/src/net/sf/freecol/client/FreeColClient.java +++ b/src/net/sf/freecol/client/FreeColClient.java @@ -734,14 +734,17 @@ public final class FreeColClient { * * When the game is clear, show the new game panel. * - * Called from the New action, often from the button on the MainPanel. + * Called from the New action, often from the button on the MainPanel, + * and IGC.victory() + * + * @param prompt If true, prompt to confirm stopping the game. */ - public void newGame() { + public void newGame(boolean prompt) { Specification specification = null; if (getGame() != null) { if (isMapEditor()) { specification = getGame().getSpecification(); - } else if (gui.confirmStopGame()) { + } else if (!prompt || gui.confirmStopGame()) { getConnectController().quitGame(true); FreeColSeed.incrementFreeColSeed(); } else { diff --git a/src/net/sf/freecol/client/control/InGameController.java b/src/net/sf/freecol/client/control/InGameController.java index 403eebb1f..580c0f629 100644 --- a/src/net/sf/freecol/client/control/InGameController.java +++ b/src/net/sf/freecol/client/control/InGameController.java @@ -4661,7 +4661,7 @@ public final class InGameController implements NetworkConstants { */ public boolean victory(Boolean quit) { if (quit) { - freeColClient.quit(); + freeColClient.newGame(false); } else { askServer().continuePlaying(); } diff --git a/src/net/sf/freecol/client/gui/action/NewAction.java b/src/net/sf/freecol/client/gui/action/NewAction.java index baa8fdccb..7b011d965 100644 --- a/src/net/sf/freecol/client/gui/action/NewAction.java +++ b/src/net/sf/freecol/client/gui/action/NewAction.java @@ -52,7 +52,7 @@ public class NewAction extends FreeColAction { if (freeColClient.isMapEditor()) { freeColClient.getMapEditorController().newMap(); } else { - freeColClient.newGame(); + freeColClient.newGame(true); } } } diff --git a/src/net/sf/freecol/client/gui/menu/MapEditorMenuBar.java b/src/net/sf/freecol/client/gui/menu/MapEditorMenuBar.java index 70c7395e2..eb0885e8d 100644 --- a/src/net/sf/freecol/client/gui/menu/MapEditorMenuBar.java +++ b/src/net/sf/freecol/client/gui/menu/MapEditorMenuBar.java @@ -117,7 +117,7 @@ public class MapEditorMenuBar extends FreeColMenuBar { try { options.save(mapOptionsFile); } catch (FileNotFoundException fnfe) {} - freeColClient.newGame(); + freeColClient.newGame(true); } }); menu.add(playItem); From c4786ac94955458f0b13be3aa1bb674fe66b724e Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sat, 1 Aug 2015 20:40:13 +0930 Subject: [PATCH 038/323] Portuguese mountain order, IR#180. --- data/strings/FreeColMessages.properties | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties index 13d580990..b8bc97b81 100644 --- a/data/strings/FreeColMessages.properties +++ b/data/strings/FreeColMessages.properties @@ -4796,16 +4796,16 @@ model.nation.portuguese.region.river.22=São Francisco model.nation.portuguese.region.river.23=Parnaíba model.nation.portuguese.region.river.24=Tietê -model.nation.portuguese.region.mountain.1=Serra da Estrela -model.nation.portuguese.region.mountain.2=Serra do Morião -model.nation.portuguese.region.mountain.3=Serra de Santa Bárbara -model.nation.portuguese.region.mountain.4=Serra da Ribeirinha -model.nation.portuguese.region.mountain.5=Serra da Boa Viagem -model.nation.portuguese.region.mountain.6=Serra da Marofa -model.nation.portuguese.region.mountain.7=Serra do Bussaco -model.nation.portuguese.region.mountain.8=Serra da Coroa -model.nation.portuguese.region.mountain.9=Serra de Sintra -model.nation.portuguese.region.mountain.10=Monte Pascoal +model.nation.portuguese.region.mountain.1=Monte Pascoal +model.nation.portuguese.region.mountain.2=Serra da Estrela +model.nation.portuguese.region.mountain.3=Serra do Morião +model.nation.portuguese.region.mountain.4=Serra de Santa Bárbara +model.nation.portuguese.region.mountain.5=Serra da Ribeirinha +model.nation.portuguese.region.mountain.6=Serra da Boa Viagem +model.nation.portuguese.region.mountain.7=Serra da Marofa +model.nation.portuguese.region.mountain.8=Serra do Bussaco +model.nation.portuguese.region.mountain.9=Serra da Coroa +model.nation.portuguese.region.mountain.10=Serra de Sintra model.nation.portuguese.region.mountain.11=Serra Geral model.nation.portuguese.region.mountain.12=Serra do Mar model.nation.portuguese.region.mountain.13=Serra Vermelha From 56ecbac7f74100a9acc73f48a0dced6ee9d45d1f Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sun, 2 Aug 2015 10:49:47 +0930 Subject: [PATCH 039/323] Fix region generation, BR#2885. --- .../server/generator/TerrainGenerator.java | 277 +++++++++--------- 1 file changed, 134 insertions(+), 143 deletions(-) diff --git a/src/net/sf/freecol/server/generator/TerrainGenerator.java b/src/net/sf/freecol/server/generator/TerrainGenerator.java index 53dafb4fe..1c8f2952a 100644 --- a/src/net/sf/freecol/server/generator/TerrainGenerator.java +++ b/src/net/sf/freecol/server/generator/TerrainGenerator.java @@ -20,6 +20,7 @@ package net.sf.freecol.server.generator; import java.awt.Rectangle; +import java.util.Arrays; import java.util.ArrayList; import java.util.EnumMap; import java.util.HashMap; @@ -124,26 +125,6 @@ public class TerrainGenerator { / 100; } - /** - * Set a parent region from the geographic regions now we - * know where each region is. - * - * @param sr The ServerRegion to find a parent for. - * @param geographicRegions A list of all the geographic - * ServerRegions. - */ - private void setGeographicRegion(ServerRegion sr, - List geographicRegions) { - for (ServerRegion gr : geographicRegions) { - if (gr.containsCenter(sr)) { - sr.setParent(gr); - gr.addChild(sr); - gr.setSize(gr.getSize() + sr.getSize()); - break; - } - } - } - /** * Creates a random tile for the specified position. * @@ -354,12 +335,10 @@ public class TerrainGenerator { * landmass is created. * * @param map The Map to work on. - * @param geographicRegions A list of all the geographic - * ServerRegions. * @param lb A LogBuilder to log to. + * @return A list of created ServerRegions. */ - private void createLandRegions(Map map, - List geographicRegions, LogBuilder lb) { + private List createLandRegions(Map map, LogBuilder lb) { // Create "explorable" land regions int continents = 0; boolean[][] landmap = new boolean[map.getWidth()][map.getHeight()]; @@ -482,13 +461,48 @@ public class TerrainGenerator { * LAND_REGIONS_SCORE_VALUE), LAND_REGION_MIN_SCORE); sr.setScoreValue(score); - setGeographicRegion(sr, geographicRegions); lb.add("Created land region ", sr.toString(), " (size ", sr.getSize(), ", score ", sr.getScoreValue(), ", parent ", ((sr.getParent() == null) ? "(null)" : sr.getParent().toString()), ")\n"); } + return Arrays.asList(Arrays.copyOfRange(landregions, 1, continents+1)); + } + + /** + * Pick a good tile to put elevated terrain on. + * + * @param map A Map to choose from. + * @return A suitable Tile, or null if none found. + */ + private Tile getGoodMountainTile(Map map) { + final TileType hills = spec.getTileType("model.tile.hills"); + final TileType mountains = spec.getTileType("model.tile.mountains"); + Tile t = null; + nextTry: for (;;) { + if ((t = map.getRandomLandTile(random)) == null) break; + + if (t.getType() == hills || t.getType() == mountains) { + continue; // Already on high ground + } + + // Do not add hills too close to a mountain range + // this would defeat the purpose of adding random hills. + for (Tile tile : t.getSurroundingTiles(3)) { + if (tile.getType() == mountains) continue nextTry; + } + + // Do not add hills too close to the ocean/lake this + // helps with good locations for building colonies on + // shore. + for (Tile tile : t.getSurroundingTiles(1)) { + if (!tile.isLand()) continue nextTry; + } + + break; // OK, good tile found. + } + return t; } /** @@ -496,12 +510,11 @@ public class TerrainGenerator { * of mountain ranges depends on the map size. * * @param map The map to use. - * @param geographicRegions A list of all the geographic - * ServerRegions. * @param lb A LogBuilder to log to. + * @return A list of created ServerRegions. */ - private void createMountains(Map map, List geographicRegions, - LogBuilder lb) { + private List createMountains(Map map, LogBuilder lb) { + List result = new ArrayList<>(); float randomHillsRatio = 0.5f; // 50% of user settings will be allocated for random hills // here and there the rest will be allocated for large @@ -516,70 +529,54 @@ public class TerrainGenerator { "Maximum length of mountain ranges is ", maximumLength, "\n"); // lookup the resources from specification - TileType hills = spec.getTileType("model.tile.hills"); - TileType mountains = spec.getTileType("model.tile.mountains"); + final TileType hills = spec.getTileType("model.tile.hills"); + final TileType mountains = spec.getTileType("model.tile.mountains"); if (hills == null || mountains == null) { throw new RuntimeException("Both Hills and Mountains TileTypes must be defined"); } // Generate the mountain ranges int counter = 0; - nextTry: for (int tries = 0; tries < 100; tries++) { - if (counter < number) { - Tile startTile = map.getRandomLandTile(random); - if (startTile == null) return; // No land found! + for (int tries = 0; tries < 100; tries++) { + Tile startTile = getGoodMountainTile(map); + if (startTile == null) break; - if (startTile.getType() == hills - || startTile.getType() == mountains) { - // already a high ground - continue; - } - - // do not start a mountain range too close to another - for (Tile t : startTile.getSurroundingTiles(3)) { - if (t.getType() == mountains) continue nextTry; - } - - // Do not add a mountain range too close to the - // ocean/lake this helps with good locations for - // building colonies on shore - for (Tile t : startTile.getSurroundingTiles(2)) { - if (!t.isLand()) continue nextTry; - } - - ServerRegion mountainRegion = new ServerRegion(game, RegionType.MOUNTAIN); - Direction direction = Direction.getRandomDirection("getLand", - logger, random); - int length = maximumLength - - randomInt(logger, "MLen", random, maximumLength/2); - for (int index = 0; index < length; index++) { - Tile nextTile = startTile.getNeighbourOrNull(direction); - if (nextTile == null || !nextTile.isLand()) continue; - nextTile.setType(mountains); - mountainRegion.addTile(nextTile); - counter++; - for (Tile neighbour : nextTile.getSurroundingTiles(1)) { - if (!neighbour.isLand() - || neighbour.getType() == mountains) continue; - int r = randomInt(logger, "MSiz", random, 8); - if (r == 0) { - neighbour.setType(mountains); - mountainRegion.addTile(neighbour); - counter++; - } else if (r > 2) { - neighbour.setType(hills); - mountainRegion.addTile(neighbour); - } + ServerRegion mountainRegion + = new ServerRegion(game, RegionType.MOUNTAIN); + startTile.setType(mountains); + mountainRegion.addTile(startTile); + Direction direction = Direction.getRandomDirection("getLand", + logger, random); + int length = maximumLength + - randomInt(logger, "MLen", random, maximumLength/2); + for (int index = 0; index < length; index++) { + Tile nextTile = startTile.getNeighbourOrNull(direction); + if (nextTile == null || !nextTile.isLand()) continue; + nextTile.setType(mountains); + mountainRegion.addTile(nextTile); + counter++; + for (Tile neighbour : nextTile.getSurroundingTiles(1)) { + if (!neighbour.isLand() + || neighbour.getType() == mountains) continue; + int r = randomInt(logger, "MSiz", random, 8); + if (r == 0) { + neighbour.setType(mountains); + mountainRegion.addTile(neighbour); + counter++; + } else if (r > 2) { + neighbour.setType(hills); + mountainRegion.addTile(neighbour); } } - int scoreValue = 2 * mountainRegion.getSize(); - mountainRegion.setScoreValue(scoreValue); - setGeographicRegion(mountainRegion, geographicRegions); - lb.add("Created mountain region (direction ", direction, - ", length ", length, - ", size ", mountainRegion.getSize(), - ", score value ", scoreValue, ").\n"); } + int scoreValue = 2 * mountainRegion.getSize(); + mountainRegion.setScoreValue(scoreValue); + result.add(mountainRegion); + lb.add("Created mountain region (direction ", direction, + ", length ", length, + ", size ", mountainRegion.getSize(), + ", score value ", scoreValue, ").\n"); + if (counter >= number) break; } lb.add("Added ", counter, " mountain range tiles.\n"); @@ -587,35 +584,17 @@ public class TerrainGenerator { number = (int) (getApproximateLandCount() * randomHillsRatio) / mapOptions.getInteger(MapGeneratorOptions.MOUNTAIN_NUMBER); counter = 0; - nextTry: for (int tries = 0; tries < 1000; tries++) { - if (counter < number) { - Tile t = map.getRandomLandTile(random); - if (t == null) return; + for (int tries = 0; tries < 1000; tries++) { + Tile t = getGoodMountainTile(map); + if (t == null) break; - if (t.getType() == hills || t.getType() == mountains) { - continue; // Already on high ground - } - - // Do not add hills too close to a mountain range - // this would defeat the purpose of adding random hills. - for (Tile tile : t.getSurroundingTiles(3)) { - if (tile.getType() == mountains) continue nextTry; - } - - // Do not add hills too close to the ocean/lake this - // helps with good locations for building colonies on - // shore. - for (Tile tile : t.getSurroundingTiles(1)) { - if (!tile.isLand()) continue nextTry; - } - - // 25% mountains, 75% hills - boolean m = randomInt(logger, "MorH", random, 4) == 0; - t.setType((m) ? mountains : hills); - counter++; - } + // 25% mountains, 75% hills + boolean m = randomInt(logger, "MorH", random, 4) == 0; + t.setType((m) ? mountains : hills); + if (++counter >= number) break; } - lb.add("Added ", counter, " random hills tiles.\n"); + lb.add("Added ", counter, " random hilly tiles.\n"); + return result; } /** @@ -623,12 +602,11 @@ public class TerrainGenerator { * on the map size. * * @param map The Map to create rivers on. - * @param geographicRegions A list of all the geographic - * ServerRegions. * @param lb A LogBuilder to log to. + * @return A list of created ServerRegions. */ - private void createRivers(Map map, List geographicRegions, - LogBuilder lb) { + private List createRivers(Map map, LogBuilder lb) { + List result = new ArrayList<>(); final TileImprovementType riverType = spec.getTileImprovementType("model.improvement.river"); final int number = getApproximateLandCount() @@ -637,18 +615,16 @@ public class TerrainGenerator { HashMap riverMap = new HashMap<>(); List rivers = new ArrayList<>(); - for (int i = 0; i < number; i++) { - nextTry: for (int tries = 0; tries < 100; tries++) { + outer: for (int i = 0; i < number; i++) { + for (int tries = 0; tries < 100; tries++) { Tile tile = map.getRandomLandTile(random); - if (tile == null) return; + if (tile == null) break outer; if (!riverType.isTileTypeAllowed(tile.getType())) continue; // check the river source/spring is not too close to the ocean for (Tile neighborTile : tile.getSurroundingTiles(2)) { - if (!neighborTile.isLand()) { - continue nextTry; - } + if (!neighborTile.isLand()) continue; } if (riverMap.get(tile) == null) { // no river here yet @@ -657,9 +633,9 @@ public class TerrainGenerator { if (river.flowFromSource(tile)) { lb.add("Created new river with length ", river.getLength(), "\n"); - map.addRegion(riverRegion); + result.add(riverRegion); rivers.add(river); - counter++; + if (++counter >= number) break; } else { lb.add("Failed to generate river.\n"); } @@ -677,22 +653,20 @@ public class TerrainGenerator { } scoreValue *= 2; region.setScoreValue(scoreValue); - setGeographicRegion(region, geographicRegions); lb.add("Created river region (length ", river.getLength(), ", score value ", scoreValue, ").\n"); } + return result; } /** * Finds all the lake regions. * * @param map The Map to work on. - * @param geographicRegions A list of all the geographic - * ServerRegions. * @param lb A LogBuilder to log to. + * @return A list of created ServerRegions. */ - private void createLakeRegions(Map map, - List geographicRegions, LogBuilder lb) { + private List createLakeRegions(Map map, LogBuilder lb) { final TileType lakeType = spec.getTileType("model.tile.lake"); // Create the water map, and find any tiles that are water but @@ -711,13 +685,11 @@ public class TerrainGenerator { } } } - for (ServerRegion sr : makeLakes(map, lakes)) { - setGeographicRegion(sr, geographicRegions); - } lb.add("\n"); + + return makeLakes(map, lakes); } - /** * Make lake regions from unassigned lake tiles. * @@ -989,31 +961,49 @@ public class TerrainGenerator { } } game.setMap(map); - List fixed = ServerRegion.requireFixedRegions(map, lb); - List geographic = new ArrayList<>(); - for (ServerRegion sr : fixed) { - if (sr.isGeographic()) geographic.add(sr); - } + // Build the regions. + List fixed = ServerRegion.requireFixedRegions(map, lb); + List newRegions = new ArrayList<>(); if (importTerrain) { if (!fixRegions.isEmpty()) { // Fix the tiles missing regions. - createLakeRegions(map, geographic, lb); - createLandRegions(map, geographic, lb); + newRegions.addAll(createLakeRegions(map, lb)); + newRegions.addAll(createLandRegions(map, lb)); } } else { map.resetHighSeas( mapOptions.getInteger(MapGeneratorOptions.DISTANCE_TO_HIGH_SEA), mapOptions.getInteger(MapGeneratorOptions.MAXIMUM_DISTANCE_TO_EDGE)); if (mapHasLand) { - createMountains(map, geographic, lb); - createRivers(map, geographic, lb); - createLakeRegions(map, geographic, lb); - createLandRegions(map, geographic, lb); + newRegions.addAll(createMountains(map, lb)); + newRegions.addAll(createRivers(map, lb)); + newRegions.addAll(createLakeRegions(map, lb)); + newRegions.addAll(createLandRegions(map, lb)); } } - map.fixupRegions(); lb.shrink("\n"); + // Connect all new regions to their geographic parent and add to + // the map. + List geographic = new ArrayList<>(); + for (ServerRegion sr : fixed) { + if (sr.isGeographic()) geographic.add(sr); + } + for (ServerRegion sr : newRegions) { + for (ServerRegion gr : geographic) { + if (gr.containsCenter(sr)) { + sr.setParent(gr); + gr.addChild(sr); + gr.setSize(gr.getSize() + sr.getSize()); + break; + } + } + map.addRegion(sr); + } + + // Probably only needed on import of old maps. + map.fixupRegions(); + // Add the bonuses only after the map is completed. // Otherwise we risk creating resources on fields where they // do not belong (like sugar in large rivers or tobacco on hills). @@ -1024,6 +1014,7 @@ public class TerrainGenerator { } } + // Final cleanups map.resetContiguity(); map.resetHighSeasCount(); return map; From 9f0b19cbf91a6c29cbe4e69b35dff7347e4e100c Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sun, 2 Aug 2015 11:36:56 +0930 Subject: [PATCH 040/323] Withdraw 0.11.4 on website. --- www.freecol.org/download.html | 48 +++++++++---------- .../news/freecol-0.11.4-released.html | 21 ++------ www.freecol.org/news/index.html | 34 +++++-------- www.freecol.org/news/releases.html | 33 +++++-------- 4 files changed, 51 insertions(+), 85 deletions(-) diff --git a/www.freecol.org/download.html b/www.freecol.org/download.html index b06faeff7..c2f382c58 100644 --- a/www.freecol.org/download.html +++ b/www.freecol.org/download.html @@ -72,13 +72,13 @@ - + JAVA INSTALLER - - freecol-0.11.4-installer.jar + + freecol-0.11.3-installer.jar @@ -92,52 +92,52 @@ - + WINDOWS INSTALLER - - freecol-0.11.4-installer.exe + + freecol-0.11.3-installer.exe Windows Installer - + MACOSX - - freecol-0.11.4-mac.tar.bz2 + + freecol-0.11.3-mac.tar.bz2 Package for MacOSX - + JAVA INSTALLER - - freecol-0.11.4-installer.jar + + freecol-0.11.3-installer.jar Platform independent installer - + .ZIP - - freecol-0.11.4.zip + + freecol-0.11.3.zip Precompiled .zip @@ -152,12 +152,12 @@ - + JAVA INSTALLER WITH SOURCES - + freecol-...-with-sources.jar @@ -165,13 +165,13 @@ - + SOURCE .ZIP - - freecol-0.11.4-src.zip + + freecol-0.11.3-src.zip Precompiled .zip with source code included @@ -190,14 +190,14 @@

    Instructions:

    Windows users should download - freecol-0.11.4-installer.exe. + freecol-0.11.3-installer.exe. You can run the file directly or save it to disk. If you choose the latter then just double-click the file once it's downloaded.

    Mac OS X users should download - freecol-0.11.4-mac.tar.bz2. + freecol-0.11.3-mac.tar.bz2. Just double click the downloaded file and copy the resulting 'FreeCol' to some place (e.g. your Application folder). FreeCol has some problems running on Mac OS X, so you should save your game frequently.

    - Users that know how to start a java program can download freecol-0.11.4-installer.jar. Start the installation program by running the command: "java -jar freecol-0.11.4-installer.jar". This installer is recommended for Linux users.

    - If you don't need a desktop icon and you know how to start a java program then you can download freecol-0.11.4.zip. The same applies for freecol-0.11.4-src.zip, but the source files are included as well in these two packages. In that case you might want to take a look at the README file to get information on how to compile and run FreeCol. + Users that know how to start a java program can download freecol-0.11.3-installer.jar. Start the installation program by running the command: "java -jar freecol-0.11.3-installer.jar". This installer is recommended for Linux users.

    + If you don't need a desktop icon and you know how to start a java program then you can download freecol-0.11.3.zip. The same applies for freecol-0.11.3-src.zip, but the source files are included as well in these two packages. In that case you might want to take a look at the README file to get information on how to compile and run FreeCol.

    Note 1: You may ignore the message "The music files could not be loaded by FreeCol. Disabling music.". There is no music available yet in this release of FreeCol.

    diff --git a/www.freecol.org/news/freecol-0.11.4-released.html b/www.freecol.org/news/freecol-0.11.4-released.html index aa9b3be1b..5f622c2ec 100644 --- a/www.freecol.org/news/freecol-0.11.4-released.html +++ b/www.freecol.org/news/freecol-0.11.4-released.html @@ -101,30 +101,19 @@
    - FreeCol 0.11.4 released + FreeCol 0.11.4 released, and withdrawn
    - Sunday, ? July 2015 + Sunday, 2 August 2015
    FreeCol 0.11.4
     
    - The FreeCol team are relieved to announce - the release of FreeCol 0.11.4. While many - bugs were fixed in this release, there has - also been progress in completing the - required feature set for the 1.0 release. - See the - release notes for - more detail. All 0.10.x and 0.11.x games - should continue to work with 0.11.4.
      -
    -
    We hope you enjoy FreeCol - 0.11.4.  Onward to 1.0. -

    The FreeCol Team + FreeCol 0.11.4 was released on Friday, but found + to generate broken maps. It has been withdrawn. + 0.11.5 will be released soon.
     
    - FreeCol 0.11.4 released + FreeCol 0.11.4 released and withdrawn
    - Sunday, ? July 2015 + Sunday, 2 August 2015
    FreeCol 0.11.4
     
    - The FreeCol team are relieved to announce - the release of FreeCol 0.11.4. While many - bugs were fixed in this release, there has - also been progress in completing the - required feature set for the 1.0 release. - See the - release notes for - more detail. All 0.10.x and 0.11.x games - should continue to work with 0.11.4.
      -
    -
    We hope you enjoy FreeCol - 0.11.4.  Onward to 1.0. -

    The FreeCol Team -
    + FreeCol 0.11.4 was released on Friday, but found + to generate broken maps. It has been withdrawn. + 0.11.5 will be released soon.
     
    - -
    - Download FreeCol 0.11.3 -
    -
      @@ -161,6 +143,12 @@

    The FreeCol Team
     
    + +
    + Download FreeCol 0.11.3 +
    +
      diff --git a/www.freecol.org/news/releases.html b/www.freecol.org/news/releases.html index d2426931e..9a1fc7210 100644 --- a/www.freecol.org/news/releases.html +++ b/www.freecol.org/news/releases.html @@ -97,38 +97,21 @@
    - FreeCol 0.11.4 released + FreeCol 0.11.4 released, and withdrawn
    - Sunday, ? July 2015 + Sunday, 2 August 2015
    FreeCol 0.11.4
     
    - The FreeCol team are relieved to announce - the release of FreeCol 0.11.4. While many - bugs were fixed in this release, there has - also been progress in completing the - required feature set for the 1.0 release. - See the - release notes for - more detail. All 0.10.x and 0.11.x games - should continue to work with 0.11.4.
      -
    -
    We hope you enjoy FreeCol - 0.11.4.  Onward to 1.0. -

    The FreeCol Team + FreeCol 0.11.4 was released on Friday, but found + to generate broken maps. It has been withdrawn. + 0.11.5 will be released soon.
     
    - -
    - Download FreeCol 0.11.3 -
    -
      @@ -161,6 +144,12 @@

    The FreeCol Team
     
    + +
    + Download FreeCol 0.11.3 +
    +   From fa00b09352184283e4b5b94851dfdeeccd9bbca6 Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sun, 2 Aug 2015 11:54:55 +0930 Subject: [PATCH 041/323] Download link was broken in several places. --- www.freecol.org/news/Page-2.html | 4 ++-- www.freecol.org/news/freecol-0.10.0-alpha-released.html | 4 ++-- www.freecol.org/news/freecol-0.10.3-released.html | 4 ++-- www.freecol.org/news/freecol-0.11.1-released.html | 4 ++-- www.freecol.org/news/freecol-0.11.2-released.html | 2 +- www.freecol.org/news/freecol-0.11.3-released.html | 2 +- www.freecol.org/news/freecol-0.11.4-released.html | 2 +- www.freecol.org/news/freecol-0.8.4-released.html | 6 +++--- www.freecol.org/news/freecol-0.9.2-released.html | 4 ++-- www.freecol.org/news/index.html | 2 +- www.freecol.org/news/releases.html | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/www.freecol.org/news/Page-2.html b/www.freecol.org/news/Page-2.html index 7d71881e6..b4c5db819 100644 --- a/www.freecol.org/news/Page-2.html +++ b/www.freecol.org/news/Page-2.html @@ -135,7 +135,7 @@ -
    FreeCol 0.10.3 has been released. This is a bug-fix release which does not add any new features.
     
     
     
    +
    FreeCol 0.10.3 has been released. This is a bug-fix release which does not add any new features.
     
     
     
    @@ -238,4 +238,4 @@ - \ No newline at end of file + diff --git a/www.freecol.org/news/freecol-0.10.0-alpha-released.html b/www.freecol.org/news/freecol-0.10.0-alpha-released.html index ab51c6ff3..47a14682c 100644 --- a/www.freecol.org/news/freecol-0.10.0-alpha-released.html +++ b/www.freecol.org/news/freecol-0.10.0-alpha-released.html @@ -161,7 +161,7 @@ - + @@ -201,4 +201,4 @@ - \ No newline at end of file + diff --git a/www.freecol.org/news/freecol-0.10.3-released.html b/www.freecol.org/news/freecol-0.10.3-released.html index 1304cf9b8..739eb363f 100644 --- a/www.freecol.org/news/freecol-0.10.3-released.html +++ b/www.freecol.org/news/freecol-0.10.3-released.html @@ -113,7 +113,7 @@ -
    FreeCol 0.10.3 has been released. This is a bug-fix release which does not add any new features.
     
     
     
    +
    FreeCol 0.10.3 has been released. This is a bug-fix release which does not add any new features.
     
     
     
    @@ -155,4 +155,4 @@ - \ No newline at end of file + diff --git a/www.freecol.org/news/freecol-0.11.1-released.html b/www.freecol.org/news/freecol-0.11.1-released.html index ebd61740f..0ee869134 100644 --- a/www.freecol.org/news/freecol-0.11.1-released.html +++ b/www.freecol.org/news/freecol-0.11.1-released.html @@ -113,7 +113,7 @@ -
    FreeCol 0.11.1
     
    The FreeCol team are sort-of pleased to announce the release of FreeCol 0.11.1.  This is a bug fix release to clean up some annoying problems in version 0.11.0. All 0.10.x and 0.11.0 games should continue to work with 0.11.1.
     
    We hope you enjoy FreeCol 0.11.1.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.1
    +
    FreeCol 0.11.1
     
    The FreeCol team are sort-of pleased to announce the release of FreeCol 0.11.1.  This is a bug fix release to clean up some annoying problems in version 0.11.0. All 0.10.x and 0.11.0 games should continue to work with 0.11.1.
     
    We hope you enjoy FreeCol 0.11.1.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.1
    @@ -148,4 +148,4 @@ - \ No newline at end of file + diff --git a/www.freecol.org/news/freecol-0.11.2-released.html b/www.freecol.org/news/freecol-0.11.2-released.html index 5e41a6625..1488f180e 100644 --- a/www.freecol.org/news/freecol-0.11.2-released.html +++ b/www.freecol.org/news/freecol-0.11.2-released.html @@ -113,7 +113,7 @@ -
    FreeCol 0.11.2
     
    The FreeCol team are mostly pleased to announce the release of FreeCol 0.11.2. This is a bug fix release to clean up yet more annoying problems in version 0.11.0/1. See the release notes for more detail. All 0.10.x and 0.11.x games should continue to work with 0.11.2.
     
    We hope you enjoy FreeCol 0.11.2.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.2
    +
    FreeCol 0.11.2
     
    The FreeCol team are mostly pleased to announce the release of FreeCol 0.11.2. This is a bug fix release to clean up yet more annoying problems in version 0.11.0/1. See the release notes for more detail. All 0.10.x and 0.11.x games should continue to work with 0.11.2.
     
    We hope you enjoy FreeCol 0.11.2.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.2
    diff --git a/www.freecol.org/news/freecol-0.11.3-released.html b/www.freecol.org/news/freecol-0.11.3-released.html index ec634791c..9b9bf9937 100644 --- a/www.freecol.org/news/freecol-0.11.3-released.html +++ b/www.freecol.org/news/freecol-0.11.3-released.html @@ -110,7 +110,7 @@
    FreeCol 0.11.3
     
    The FreeCol team are vaguely pleased to announce the release of -FreeCol 0.11.3. This is a bug fix release to clean up yet more annoying problems in version 0.11.0/1/2. See the release notes for more detail. All 0.10.x and 0.11.x games should continue to work with 0.11.3.
     
    We hope you enjoy FreeCol 0.11.3.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.3
    +FreeCol 0.11.3. This is a bug fix release to clean up yet more annoying problems in version 0.11.0/1/2. See the release notes for more detail. All 0.10.x and 0.11.x games should continue to work with 0.11.3.
     
    We hope you enjoy FreeCol 0.11.3.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.3
    diff --git a/www.freecol.org/news/freecol-0.11.4-released.html b/www.freecol.org/news/freecol-0.11.4-released.html index 5f622c2ec..2daa29819 100644 --- a/www.freecol.org/news/freecol-0.11.4-released.html +++ b/www.freecol.org/news/freecol-0.11.4-released.html @@ -119,7 +119,7 @@
    - Download FreeCol 0.11.3 + Download FreeCol 0.11.3
    diff --git a/www.freecol.org/news/freecol-0.8.4-released.html b/www.freecol.org/news/freecol-0.8.4-released.html index 37c31c43c..fe4ff7997 100644 --- a/www.freecol.org/news/freecol-0.8.4-released.html +++ b/www.freecol.org/news/freecol-0.8.4-released.html @@ -118,10 +118,10 @@
    - + - Download FreeCol 0.8.4 + Download FreeCol 0.8.4
    @@ -167,4 +167,4 @@ - \ No newline at end of file + diff --git a/www.freecol.org/news/freecol-0.9.2-released.html b/www.freecol.org/news/freecol-0.9.2-released.html index 236074844..6bddd37a5 100644 --- a/www.freecol.org/news/freecol-0.9.2-released.html +++ b/www.freecol.org/news/freecol-0.9.2-released.html @@ -115,7 +115,7 @@
    FreeCol 0.9.2 has been released.
    -
    This is a bug/feature-fix release, the main changes being:
    • The increased native land claims in 0.9.1 have been reverted to the more moderate 0.9.0 behaviour, following comment that this made the game too difficult.  This feature will be back in a later release, but only after implementing the feature that at least exempts your first colony from having to buy its land (as was the case with the original Colonization).
    • Fixed a serious bug in privateer combat.
    No new features were introduced with this release, and saved games from previous 0.9.x versions should remain compatible.  We hope this release will provide a stable, playable and enjoyable version of FreeCol.

    +
    This is a bug/feature-fix release, the main changes being:
    • The increased native land claims in 0.9.1 have been reverted to the more moderate 0.9.0 behaviour, following comment that this made the game too difficult.  This feature will be back in a later release, but only after implementing the feature that at least exempts your first colony from having to buy its land (as was the case with the original Colonization).
    • Fixed a serious bug in privateer combat.
    No new features were introduced with this release, and saved games from previous 0.9.x versions should remain compatible.  We hope this release will provide a stable, playable and enjoyable version of FreeCol.

    @@ -155,4 +155,4 @@ - \ No newline at end of file + diff --git a/www.freecol.org/news/index.html b/www.freecol.org/news/index.html index c34e34ed6..471af34fc 100644 --- a/www.freecol.org/news/index.html +++ b/www.freecol.org/news/index.html @@ -146,7 +146,7 @@
    - Download FreeCol 0.11.3 + Download FreeCol 0.11.3
    diff --git a/www.freecol.org/news/releases.html b/www.freecol.org/news/releases.html index 9a1fc7210..b92c4badf 100644 --- a/www.freecol.org/news/releases.html +++ b/www.freecol.org/news/releases.html @@ -147,7 +147,7 @@
    - Download FreeCol 0.11.3 + Download FreeCol 0.11.3
    From 67e79229a902b9986fb9c9c8f74519e17aa7ef26 Mon Sep 17 00:00:00 2001 From: Mike Pope Date: Sun, 2 Aug 2015 12:19:36 +0930 Subject: [PATCH 042/323] Fix some more download links. --- www.freecol.org/news/freecol-0.11.1-released.html | 2 +- www.freecol.org/news/freecol-0.11.2-released.html | 2 +- www.freecol.org/news/freecol-0.11.3-released.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/www.freecol.org/news/freecol-0.11.1-released.html b/www.freecol.org/news/freecol-0.11.1-released.html index 0ee869134..1b1ffd8e0 100644 --- a/www.freecol.org/news/freecol-0.11.1-released.html +++ b/www.freecol.org/news/freecol-0.11.1-released.html @@ -113,7 +113,7 @@ -
    FreeCol 0.11.1
     
    The FreeCol team are sort-of pleased to announce the release of FreeCol 0.11.1.  This is a bug fix release to clean up some annoying problems in version 0.11.0. All 0.10.x and 0.11.0 games should continue to work with 0.11.1.
     
    We hope you enjoy FreeCol 0.11.1.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.1
    +
    FreeCol 0.11.1
     
    The FreeCol team are sort-of pleased to announce the release of FreeCol 0.11.1.  This is a bug fix release to clean up some annoying problems in version 0.11.0. All 0.10.x and 0.11.0 games should continue to work with 0.11.1.
     
    We hope you enjoy FreeCol 0.11.1.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.1
    diff --git a/www.freecol.org/news/freecol-0.11.2-released.html b/www.freecol.org/news/freecol-0.11.2-released.html index 1488f180e..fd070467b 100644 --- a/www.freecol.org/news/freecol-0.11.2-released.html +++ b/www.freecol.org/news/freecol-0.11.2-released.html @@ -113,7 +113,7 @@ -
    FreeCol 0.11.2
     
    The FreeCol team are mostly pleased to announce the release of FreeCol 0.11.2. This is a bug fix release to clean up yet more annoying problems in version 0.11.0/1. See the release notes for more detail. All 0.10.x and 0.11.x games should continue to work with 0.11.2.
     
    We hope you enjoy FreeCol 0.11.2.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.2
    +
    FreeCol 0.11.2
     
    The FreeCol team are mostly pleased to announce the release of FreeCol 0.11.2. This is a bug fix release to clean up yet more annoying problems in version 0.11.0/1. See the release notes for more detail. All 0.10.x and 0.11.x games should continue to work with 0.11.2.
     
    We hope you enjoy FreeCol 0.11.2.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.2
    diff --git a/www.freecol.org/news/freecol-0.11.3-released.html b/www.freecol.org/news/freecol-0.11.3-released.html index 9b9bf9937..444969f55 100644 --- a/www.freecol.org/news/freecol-0.11.3-released.html +++ b/www.freecol.org/news/freecol-0.11.3-released.html @@ -110,7 +110,7 @@
    FreeCol 0.11.3
     
    The FreeCol team are vaguely pleased to announce the release of -FreeCol 0.11.3. This is a bug fix release to clean up yet more annoying problems in version 0.11.0/1/2. See the release notes for more detail. All 0.10.x and 0.11.x games should continue to work with 0.11.3.
     
    We hope you enjoy FreeCol 0.11.3.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.3
    +FreeCol 0.11.3. This is a bug fix release to clean up yet more annoying problems in version 0.11.0/1/2. See the release notes for more detail. All 0.10.x and 0.11.x games should continue to work with 0.11.3.
     
    We hope you enjoy FreeCol 0.11.3.  Onward to 1.0.

    The FreeCol Team
     
    Download FreeCol 0.11.3
    From 4d706113201207272d95bd6c9c110d081311101f Mon Sep 17 00:00:00 2001 From: Fenyo Date: Fri, 31 Jul 2015 22:44:37 +0200 Subject: [PATCH 043/323] New hotkey: Move all cargo with Control key pressed down. --- .../client/gui/panel/AbstractGoodsLabel.java | 20 +++++++++++++++++++ .../gui/panel/DefaultTransferHandler.java | 1 + .../client/gui/panel/DragListener.java | 2 ++ 3 files changed, 23 insertions(+) diff --git a/src/net/sf/freecol/client/gui/panel/AbstractGoodsLabel.java b/src/net/sf/freecol/client/gui/panel/AbstractGoodsLabel.java index 8699a22af..ae67389b4 100644 --- a/src/net/sf/freecol/client/gui/panel/AbstractGoodsLabel.java +++ b/src/net/sf/freecol/client/gui/panel/AbstractGoodsLabel.java @@ -38,6 +38,8 @@ public class AbstractGoodsLabel extends JLabel { private boolean partialChosen = false; + private boolean fullChosen = false; + /** * Initializes this JLabel with the given goods data. @@ -72,6 +74,24 @@ public class AbstractGoodsLabel extends JLabel { this.partialChosen = partialChosen; } + /** + * Has full amount been selected? + * + * @return True if a full amount has been selected. + */ + public boolean isFullChosen() { + return fullChosen; + } + + /** + * Set the full amount state. + * + * @param fullChosen The new full amount state. + */ + public void setFullChosen(boolean fullChosen) { + this.fullChosen = fullChosen; + } + /** * Get the goods data. * diff --git a/src/net/sf/freecol/client/gui/panel/DefaultTransferHandler.java b/src/net/sf/freecol/client/gui/panel/DefaultTransferHandler.java index 7441a93ac..dbca942c4 100644 --- a/src/net/sf/freecol/client/gui/panel/DefaultTransferHandler.java +++ b/src/net/sf/freecol/client/gui/panel/DefaultTransferHandler.java @@ -393,6 +393,7 @@ public final class DefaultTransferHandler extends TransferHandler { defaultAmount, false); if (amount <= 0) return false; goods.setAmount(amount); + } else if (label.isFullChosen()) { } else if (goods.getAmount() > GoodsContainer.CARGO_SIZE) { goods.setAmount(GoodsContainer.CARGO_SIZE); } diff --git a/src/net/sf/freecol/client/gui/panel/DragListener.java b/src/net/sf/freecol/client/gui/panel/DragListener.java index d9ead3167..2175ae25d 100644 --- a/src/net/sf/freecol/client/gui/panel/DragListener.java +++ b/src/net/sf/freecol/client/gui/panel/DragListener.java @@ -112,6 +112,8 @@ public final class DragListener extends MouseAdapter { AbstractGoodsLabel label = (AbstractGoodsLabel)comp; if (e.isShiftDown()) { label.setPartialChosen(true); + } else if (e.isControlDown()) { + label.setFullChosen(true); } else { label.setPartialChosen(false); label.setDefaultAmount(); From 234239b2353751d35e8962ea7dd0d17187190d15 Mon Sep 17 00:00:00 2001 From: calebrw Date: Sun, 2 Aug 2015 14:24:57 -0500 Subject: [PATCH 044/323] FreeCol 0.11.5 release news update. --- www.freecol.org/download.html | 48 +++--- www.freecol.org/index.html | 15 +- .../news/freecol-0.11.4-released.html | 21 ++- .../news/freecol-0.11.5-released.html | 158 ++++++++++++++++++ www.freecol.org/news/index.html | 51 ++++-- www.freecol.org/news/releases.html | 65 ++++--- www.freecol.org/sitemap.html | 2 + 7 files changed, 290 insertions(+), 70 deletions(-) create mode 100644 www.freecol.org/news/freecol-0.11.5-released.html diff --git a/www.freecol.org/download.html b/www.freecol.org/download.html index c2f382c58..694354d15 100644 --- a/www.freecol.org/download.html +++ b/www.freecol.org/download.html @@ -72,13 +72,13 @@ - + JAVA INSTALLER - - freecol-0.11.3-installer.jar + + freecol-0.11.5-installer.jar @@ -92,52 +92,52 @@ - + WINDOWS INSTALLER - - freecol-0.11.3-installer.exe + + freecol-0.11.5-installer.exe Windows Installer - + MACOSX - - freecol-0.11.3-mac.tar.bz2 + + freecol-0.11.5-mac.tar.bz2 Package for MacOSX - + JAVA INSTALLER - - freecol-0.11.3-installer.jar + + freecol-0.11.5-installer.jar Platform independent installer - + .ZIP - - freecol-0.11.3.zip + + freecol-0.11.5.zip Precompiled .zip @@ -152,12 +152,12 @@ - + JAVA INSTALLER WITH SOURCES - + freecol-...-with-sources.jar @@ -165,13 +165,13 @@ - + SOURCE .ZIP - - freecol-0.11.3-src.zip + + freecol-0.11.5-src.zip Precompiled .zip with source code included @@ -190,14 +190,14 @@

    Instructions:

    Windows users should download - freecol-0.11.3-installer.exe. + freecol-0.11.5-installer.exe. You can run the file directly or save it to disk. If you choose the latter then just double-click the file once it's downloaded.

    Mac OS X users should download - freecol-0.11.3-mac.tar.bz2. + freecol-0.11.5-mac.tar.bz2. Just double click the downloaded file and copy the resulting 'FreeCol' to some place (e.g. your Application folder). FreeCol has some problems running on Mac OS X, so you should save your game frequently.

    - Users that know how to start a java program can download freecol-0.11.3-installer.jar. Start the installation program by running the command: "java -jar freecol-0.11.3-installer.jar". This installer is recommended for Linux users.

    - If you don't need a desktop icon and you know how to start a java program then you can download freecol-0.11.3.zip. The same applies for freecol-0.11.3-src.zip, but the source files are included as well in these two packages. In that case you might want to take a look at the README file to get information on how to compile and run FreeCol. + Users that know how to start a java program can download freecol-0.11.5-installer.jar. Start the installation program by running the command: "java -jar freecol-0.11.5-installer.jar". This installer is recommended for Linux users.

    + If you don't need a desktop icon and you know how to start a java program then you can download freecol-0.11.5.zip. The same applies for freecol-0.11.5-src.zip, but the source files are included as well in these two packages. In that case you might want to take a look at the README file to get information on how to compile and run FreeCol.

    Note 1: You may ignore the message "The music files could not be loaded by FreeCol. Disabling music.". There is no music available yet in this release of FreeCol.

    diff --git a/www.freecol.org/index.html b/www.freecol.org/index.html index be6c00cc8..8fe907d9b 100644 --- a/www.freecol.org/index.html +++ b/www.freecol.org/index.html @@ -94,17 +94,20 @@ diff --git a/www.freecol.org/news/freecol-0.11.4-released.html b/www.freecol.org/news/freecol-0.11.4-released.html index 2daa29819..2bcf3cef2 100644 --- a/www.freecol.org/news/freecol-0.11.4-released.html +++ b/www.freecol.org/news/freecol-0.11.4-released.html @@ -126,13 +126,20 @@   - - - - +
    - - Next > -
    + + + + +
    + + < Prev +   + + + + Next > +
    diff --git a/www.freecol.org/news/freecol-0.11.5-released.html b/www.freecol.org/news/freecol-0.11.5-released.html new file mode 100644 index 000000000..481274cdb --- /dev/null +++ b/www.freecol.org/news/freecol-0.11.5-released.html @@ -0,0 +1,158 @@ + + + + + + + FreeCol - FreeCol 0.11.5 released + + + + + + + + + + + + +
    + +
    +
    + Home + arrow + News + arrow + FreeCol 0.11.5 released + + + SITEMAP + +
    +
    + +
    + +
    +
    +
    +
    +
    +

    Syndicate

    +
    + + RSS 0.91 +
    +
    + + RSS 1.0 +
    +
    + + RSS 2.0 +
    +
    + + ATOM 0.3 +
    +
    + + OPML +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + FreeCol 0.11.5 released +
    + + +
    + Monday, 3 August 2015 +
    +
    FreeCol 0.11.5
    +
     
    +
    + FreeCol 0.11.5 has been released to fix + file corruption in 0.11.4. All users of + FreeCol 0.11.4 are encouraged to upgrade + as soon as possible. +
    +
     
    + +
    + Download FreeCol 0.11.5 +
    + +
    + +   + + + + + + +
    + + Next > + +   +
    + +
    +
    +
    +
    + + +
    + + diff --git a/www.freecol.org/news/index.html b/www.freecol.org/news/index.html index 471af34fc..ff78667b0 100644 --- a/www.freecol.org/news/index.html +++ b/www.freecol.org/news/index.html @@ -95,6 +95,35 @@ + +
    + FreeCol 0.11.5 released +
    + + +
    + Monday, 3 August 2015 +
    +
    FreeCol 0.11.3
    +
     
    +
    + FreeCol 0.11.5 has been released to fix + file corruption in 0.11.4. All users of + FreeCol 0.11.4 are encouraged to upgrade + as soon as possible. +
     
    + + +
    + Download FreeCol 0.11.5 +
    + +
    +
    + +   +
    FreeCol 0.11.4 released and withdrawn @@ -107,10 +136,11 @@
    FreeCol 0.11.4
     
    - FreeCol 0.11.4 was released on Friday, but found - to generate broken maps. It has been withdrawn. - 0.11.5 will be released soon. -
     
    + FreeCol 0.11.4 was released on Friday, but found + to generate broken maps. It has been withdrawn. + 0.11.5 will be released soon. +
     
    +
      @@ -143,12 +173,8 @@

    The FreeCol Team
     
    - -
    - Download FreeCol 0.11.3 -
    - + +   @@ -501,8 +527,8 @@ 8 9 10 - Next > - End >> + Next > + End >>

    @@ -531,4 +557,3 @@ - diff --git a/www.freecol.org/news/releases.html b/www.freecol.org/news/releases.html index b92c4badf..622845aae 100644 --- a/www.freecol.org/news/releases.html +++ b/www.freecol.org/news/releases.html @@ -95,34 +95,63 @@ - +
    - FreeCol 0.11.4 released, and withdrawn + FreeCol 0.11.5 released
    + Monday, 3 August 2015 + + +
    - Sunday, 2 August 2015 -
    +
    FreeCol 0.11.3
    +
     
    +
    + FreeCol 0.11.5 has been released to fix + file corruption in 0.11.4. All users of + FreeCol 0.11.4 are encouraged to upgrade + as soon as possible. +
     
    + + +
    + Download FreeCol 0.11.5 +
    + +
    +
    + +   + + +
    + FreeCol 0.11.4 released and withdrawn +
    +
    + Sunday, 2 August 2015 +
    FreeCol 0.11.4
     
    - FreeCol 0.11.4 was released on Friday, but found - to generate broken maps. It has been withdrawn. - 0.11.5 will be released soon. + FreeCol 0.11.4 was released on Friday, but found + to generate broken maps. It has been withdrawn. + 0.11.5 will be released soon. +
     
    -
     
    -
    - + +  
    - FreeCol 0.11.3 released + FreeCol 0.11.3 released
    + Sunday, 8 March 2015 +
    - Sunday, 8 March 2015 -
    FreeCol 0.11.3
    @@ -144,13 +173,9 @@

    The FreeCol Team
     
    - -
    - Download FreeCol 0.11.3 -
    - -
    + + +   diff --git a/www.freecol.org/sitemap.html b/www.freecol.org/sitemap.html index 24932c785..449c29096 100644 --- a/www.freecol.org/sitemap.html +++ b/www.freecol.org/sitemap.html @@ -63,6 +63,8 @@
  • Home
  • News