Package net.sf.freecol.client.gui
Class GUI
- java.lang.Object
-
- net.sf.freecol.client.control.FreeColClientHolder
-
- net.sf.freecol.client.gui.GUI
-
- Direct Known Subclasses:
SwingGUI
public class GUI extends FreeColClientHolder
The API and common reusable functionality for the overall GUI.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GUI.ViewMode
View modes.
-
Constructor Summary
Constructors Constructor Description GUI(FreeColClient freeColClient)
Create the GUI.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateGotoPath()
Start/stop the goto path display.void
animateUnitAttack(Unit attacker, Unit defender, Tile attackerTile, Tile defenderTile, boolean success)
Animate a unit attack.void
animateUnitMove(Unit unit, Tile srcTile, Tile dstTile)
Animate a unit move.boolean
canZoomInMap()
Can the map be zoomed in? Used by: ZoomInActionboolean
canZoomInMapControls()
Is the map able to zoom in further? Used by: MiniMapZoomInActionboolean
canZoomOutMap()
Can the map be zoomed out? Used by: ZoomOutActionboolean
canZoomOutMapControls()
Is the map able to zoom out further? Used by: MiniMapZoomOutActionvoid
changeView()
Change to end turn mode.void
changeView(MapTransform transform)
Change to map transform mode, and select a transform.void
changeView(Tile tile)
Change to terrain mode and select a tile.void
changeView(Unit unit, boolean force)
Change to move units mode, and select a unit.void
changeWindowedMode()
Change the windowed mode (really a toggle).void
clearGotoPath()
Stop the goto path display.void
clickAt(int count, int x, int y)
Handle a click on the canvas.void
closeMainPanel()
Close the main panel if present.void
closeMenus()
Close any open menus.void
closePanel(java.lang.String panel)
Close a panel.void
closeStatusPanel()
Close the status panel if present.boolean
confirm(java.lang.String textKey, java.lang.String okKey, java.lang.String cancelKey)
Simple modal confirmation dialog.boolean
confirm(StringTemplate template, java.lang.String okKey, java.lang.String cancelKey)
Primitive modal confirmation dialog.boolean
confirm(Tile tile, StringTemplate template, javax.swing.ImageIcon icon, java.lang.String okKey, java.lang.String cancelKey)
General modal confirmation dialog.boolean
confirm(Tile tile, StringTemplate template, GoodsType goodsType, java.lang.String okKey, java.lang.String cancelKey)
GoodsType-specific modal confirmation dialog.boolean
confirm(Tile tile, StringTemplate template, Settlement settlement, java.lang.String okKey, java.lang.String cancelKey)
Settlement-specific modal confirmation dialog.boolean
confirm(Tile tile, StringTemplate template, Unit unit, java.lang.String okKey, java.lang.String cancelKey)
Unit-specific modal confirmation dialog.boolean
confirmAbandonEducation(Unit unit, boolean leaveColony)
Confirm that a unit should abandon its educational activity.boolean
confirmClearTradeRoute(Unit unit)
If a unit has a trade route, get confirmation that it is ok to clear it and set a destination.int
confirmEuropeanTribute(Unit attacker, Colony colony, NationSummary ns)
Confirm whether the player wants to demand tribute from a colony.boolean
confirmHostileAction(Unit attacker, Tile target)
Check if an attack results in a transition from peace or cease fire to war and, if so, warn the player.boolean
confirmLeaveColony(Unit unit)
Confirm that a unit can leave its colony.int
confirmNativeTribute(Unit attacker, IndianSettlement is)
Confirm whether the player wants to demand tribute from a native settlement.boolean
confirmPreCombat(Unit attacker, Tile tile)
Shows the pre-combat dialog if enabled, allowing the user to view the odds and possibly cancel the attack.boolean
confirmStopGame()
Confirm whether to stop the current game.java.awt.image.BufferedImage
createColonyTileImage(Tile tile, Colony colony)
java.awt.image.BufferedImage
createTileImage(Tile tile, Player player)
java.awt.image.BufferedImage
createTileImageWithBeachBorderAndItems(Tile tile)
void
displayChat(java.lang.String sender, java.lang.String message, java.awt.Color color, boolean privateChat)
Update with a new chat message.void
displayColonyTiles(java.awt.Graphics2D g2d, Tile[][] tiles, Colony colony)
Display the ColonyTiles of a Colony.void
displayObject(FreeColObject fco)
Show the appropriate panel for an object.void
displayStartChat(java.lang.String sender, java.lang.String message, boolean privateChat)
A chat message was received during the pre-game setup.void
enableMapControls(boolean enable)
Enable the map controls.Unit
getActiveUnit()
Get the active unit.Constants.ArmedUnitSettlementAction
getArmedUnitSettlementChoice(Settlement settlement)
Get the choice of what a user wants to do with an armed unit at a foreign settlement.Constants.BoycottAction
getBoycottChoice(Goods goods, Europe europe)
Get the user choice of whether to pay arrears for boycotted goods or to dump them instead.Constants.TradeBuyAction
getBuyChoice(Unit unit, Settlement settlement, Goods goods, int gold, boolean canBuy)
Gets the user choice when negotiating a purchase from a settlement.<T> T
getChoice(StringTemplate explain, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
General modal choice dialog.protected <T> T
getChoice(Tile tile, StringTemplate template, javax.swing.ImageIcon icon, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
General modal choice dialog.private <T> T
getChoice(Tile tile, StringTemplate template, GoodsType goodsType, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
Goods-specific modal choice dialog.private <T> T
getChoice(Tile tile, StringTemplate template, Nation nation, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
Nation-specific modal choice dialog.<T> T
getChoice(Tile tile, StringTemplate template, Settlement settlement, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
Settlement-specific modal choice dialog.<T> T
getChoice(Tile tile, StringTemplate template, Unit unit, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
Unit-specific modal choice dialog.Constants.ClaimAction
getClaimChoice(Tile tile, Player player, int price, Player owner)
Gets the user choice for claiming a tile.ImageLibrary
getFixedImageLibrary()
Get the fixed image library for use on panels.Tile
getFocus()
Get the current focus tile.Constants.TradeAction
getIndianSettlementTradeChoice(Settlement settlement, StringTemplate template, boolean canBuy, boolean canSell, boolean canGift)
Get the user choice when trading with a native settlement.java.lang.String
getInput(Tile tile, StringTemplate template, java.lang.String defaultValue, java.lang.String okKey, java.lang.String cancelKey)
General modal string input dialog.java.awt.Dimension
getMapViewDimension()
Constants.MissionaryAction
getMissionaryChoice(Unit unit, IndianSettlement is, boolean canEstablish, boolean canDenounce)
Get the user choice of what to do with a missionary at a native settlement.java.lang.String
getNewColonyName(Player player, Tile tile)
Get a name for a new colony for a player.ImageLibrary
getScaledImageLibrary()
Get the scaled image library for use on the map.Constants.ScoutColonyAction
getScoutForeignColonyChoice(Colony colony, Unit unit, boolean neg)
Get the user choice for what to do with a scout at a foreign colony.Constants.ScoutIndianSettlementAction
getScoutIndianSettlementChoice(IndianSettlement is, java.lang.String numberString)
Get the user choice for what to do at a native settlement.Direction
getScrollDirection(int x, int y, int scrollSpace, boolean ignoreTop)
Work out what direction to scroll the map if a coordinate is close to an edge.Tile
getSelectedTile()
Get the selected tile.Constants.TradeSellAction
getSellChoice(Unit unit, Settlement settlement, Goods goods, int gold)
Get the user choice for negotiating a sale to a settlement.java.lang.String
getSoundMixerLabelText()
Get the label text for the sound player mixer.GUI.ViewMode
getViewMode()
Get the current view mode.void
installLookAndFeel(java.lang.String fontName)
Swing system and look-and-feel initialization.void
invokeNowOrLater(java.lang.Runnable runnable)
Run in the EDT, either immediately if in it or later when it wakes up.void
invokeNowOrWait(java.lang.Runnable runnable)
Run in the EDT, either immediately or wait for it.boolean
isClientOptionsDialogShowing()
Checks if a client options dialog is present.boolean
isGotoStarted()
Check if the user has GoTo mode enabled.boolean
isPanelShowing()
Is another panel being displayed.boolean
isWindowed()
Is this GUI in windowed mode? Used by: DragListener for a nasty workaround that should go awayvoid
miniMapToggleFogOfWarControls()
Toggle the fog of war control.void
miniMapToggleViewControls()
Toggle the view control.void
performGoto(int x, int y)
Perform an immediate goto to a point on the map.void
performGoto(Tile tile)
Perform an immediate goto to a tile with the active unit.void
playSound(java.lang.String sound)
Play a sound.void
prepareDrag(int x, int y)
Prepare a drag from the given coordinates.void
prepareShowingMainMenu()
Prepares showing the main menu by removing almost everything from the view.void
quitGUI()
Quit the GUI.void
reconnectGUI(Unit active, Tile tile)
Reset the GUI on reconnect.void
refresh()
Refresh the whole GUI.void
refreshGuiUsingClientOptions()
Refreshes the GUI with settings from the client options.void
refreshPlayersTable()
Refresh the players table in the StartGamePanel.void
refreshTile(Tile tile)
void
reloadResources()
Reloads all images managed byResourceManager
.void
removeComponent(java.awt.Component component)
Remove a component from the GUI.void
removeDialog(FreeColDialog<?> fcd)
Remove a dialog from the GUI.void
removeInGameComponents()
Remove all in-game components (i.e.void
removeTradeRoutePanel(FreeColPanel panel)
Remove a trade route panel and associated input on an associated TradeRouteInputPanel.void
repaint()
Repaints the entire screen, but uses image caches to avoid unnecessary painting of the map.void
restoreSavedSize(java.awt.Component comp, java.awt.Dimension d)
Set dialog preferred size to saved size or to the givenDimension
if no saved size was found.boolean
scrollMap(Direction direction)
Scroll the map in a given direction.void
setFocus(Tile tile)
Set the current focus tile.void
setUnitPath(PathNode path)
Set the path for the active unit.FreeColPanel
showAboutPanel()
Show the AboutPanel.FreeColPanel
showBuildQueuePanel(Colony colony)
Show the build queue for a colony.void
showCaptureGoodsDialog(Unit unit, java.util.List<Goods> gl, DialogHandler<java.util.List<Goods>> handler)
Show the dialog to select captured goods.FreeColPanel
showChatPanel()
Show the chat panel.void
showChooseFoundingFatherDialog(java.util.List<FoundingFather> ffs, DialogHandler<FoundingFather> handler)
Show the founding father choice panel.void
showClientOptionsDialog()
Show the client options dialog.FreeColPanel
showColonyPanel(Colony colony, Unit unit)
Show the colony panelFreeColPanel
showColopediaPanel(java.lang.String nodeId)
Show a colopedia panel.FreeColPanel
showColorChooserPanel(java.awt.event.ActionListener al)
Show a color chooser panel.FreeColPanel
showCompactLabourReport()
Show the compact labour report panel.FreeColPanel
showCompactLabourReport(LabourData.UnitData unitData)
Show the compact labour report for the specified unit data.java.util.List<java.lang.String>
showConfirmDeclarationDialog()
Confirm declaration of independence.void
showDeclarationPanel(java.lang.Runnable afterClosing)
Show the declaration panel with the declaration of independence and an animated signature.OptionGroup
showDifficultyDialog()
Get the option group that defines a difficulty level.OptionGroup
showDifficultyDialog(Specification spec, OptionGroup group, boolean editable)
Show a dialog for a difficulty option group.void
showDumpCargoDialog(Unit unit, DialogHandler<java.util.List<Goods>> handler)
Show a dialog to choose what goods to dump.boolean
showEditOptionDialog(Option option)
Show a dialog for editing an individual option.IndianSettlement
showEditSettlementDialog(IndianSettlement is)
Show a dialog for editing a settlmeent.void
showEmigrationDialog(Player player, boolean fountainOfYouth, DialogHandler<java.lang.Integer> handler)
Show a dialog to handle emigration.void
showEndTurnDialog(java.util.List<Unit> units, DialogHandler<java.lang.Boolean> handler)
Show a dialog for the end of turn.void
showErrorPanel(java.lang.Exception ex, StringTemplate template)
Show a serious error message with an exception and return to the main panel when done.FreeColPanel
showErrorPanel(java.lang.String message, java.lang.Runnable callback)
Show an error panel.FreeColPanel
showErrorPanel(StringTemplate template)
Show an i18n compliant error message derived from a template.FreeColPanel
showErrorPanel(StringTemplate template, java.lang.String message)
Show an i18n compliant error message derived from a template, with optional extra debug information.FreeColPanel
showErrorPanel(StringTemplate template, java.lang.String message, java.lang.Runnable callback)
Show an i18n compliant error message derived from a template, with optional extra debug information and an optional callback.FreeColPanel
showEuropePanel()
Show the Europe panel.FreeColPanel
showEventPanel(java.lang.String header, java.lang.String image, java.lang.String footer)
Show an event panel.FreeColPanel
showFindSettlementPanel()
Show the FindSettlement panel.void
showFirstContactDialog(Player player, Player other, Tile tile, int settlementCount, DialogHandler<java.lang.Boolean> handler)
Show a first contact dialog.OptionGroup
showGameOptionsDialog(boolean editable)
Show the Game options dialog.FreeColPanel
showHighScoresPanel(java.lang.String messageId, java.util.List<HighScore> scores)
Show the high scores panel.FreeColPanel
showIndianSettlementPanel(IndianSettlement is)
Show a panel for a native settlement.FreeColPanel
showInformationPanel(java.lang.String messageId)
Show an information message.FreeColPanel
showInformationPanel(FreeColObject displayObject, java.lang.String messageId)
Show an information message.FreeColPanel
showInformationPanel(FreeColObject displayObject, StringTemplate template)
Show an information message.FreeColPanel
showInformationPanel(StringTemplate template)
Show an information message.java.io.File
showLoadDialog(java.io.File directory, java.lang.String extension)
Show a dialog where the user may choose a file.LoadingSavegameInfo
showLoadingSavegameDialog(boolean publicServer, boolean singlePlayer)
Show the LoadingSavegameDialog.java.io.File
showLoadSaveFileDialog(java.io.File root, java.lang.String extension)
Show a save file dialog, selecting one to load.FreeColPanel
showLogFilePanel()
Show the log file panel.FreeColPanel
showMainPanel(java.lang.String userMsg)
Show the main panel.void
showMainTitle()
Complete reset back to the main panel.OptionGroup
showMapGeneratorOptionsDialog(boolean editable)
Show the map generator options.java.awt.Dimension
showMapSizeDialog()
Show the map size dialog.FreeColPanel
showModelMessages(java.util.List<ModelMessage> modelMessages)
Show model messages.void
showMonarchDialog(Monarch.MonarchAction action, StringTemplate template, java.lang.String monarchKey, DialogHandler<java.lang.Boolean> handler)
Show the monarch dialog.void
showNamingDialog(StringTemplate template, java.lang.String defaultName, Unit unit, DialogHandler<java.lang.String> handler)
Show the naming dialog.void
showNativeDemandDialog(Unit unit, Colony colony, GoodsType type, int amount, DialogHandler<java.lang.Boolean> handler)
Show the native demand dialog.DiplomaticTrade
showNegotiationDialog(FreeColGameObject our, FreeColGameObject other, DiplomaticTrade agreement, StringTemplate comment)
Show the negotiation dialog.void
showNewPanel()
Show the NewPanel.FreeColPanel
showNewPanel(Specification spec)
Show the NewPanel.void
showOpeningVideo(java.lang.String userMsg, java.lang.Runnable callback)
Shows theVideoPanel
.Parameters
showParametersDialog()
Show the parameter choice dialog.void
showPopupMenu(javax.swing.JPopupMenu menu, int x, int y)
Display a popup menu.boolean
showPreCombatDialog(Unit attacker, FreeColGameObject defender, Tile tile)
Show the pre-combat dialog.FreeColPanel
showPurchasePanel()
Displays the purchase panel.FreeColPanel
showRecruitPanel()
Displays the recruit panel.FreeColPanel
showReportCargoPanel()
Show the Cargo Report.FreeColPanel
showReportColonyPanel()
Show the Colony Report.FreeColPanel
showReportContinentalCongressPanel()
Show the Continental Congress Report.FreeColPanel
showReportEducationPanel()
Show the Education Report.FreeColPanel
showReportExplorationPanel()
Show the Exploration Report.FreeColPanel
showReportForeignAffairPanel()
Show the Foreign Affairs Report.FreeColPanel
showReportHistoryPanel()
Show the History Report.FreeColPanel
showReportIndianPanel()
Show the Native Affairs Report.FreeColPanel
showReportLabourDetailPanel(UnitType unitType, java.util.Map<UnitType,java.util.Map<Location,java.lang.Integer>> data, TypeCountMap<UnitType> unitCount, java.util.List<Colony> colonies)
Display the labour detail panel.FreeColPanel
showReportLabourPanel()
Show the Labour Report.FreeColPanel
showReportMilitaryPanel()
Show the Military Report.FreeColPanel
showReportNavalPanel()
Show the Naval Report.FreeColPanel
showReportProductionPanel()
Show the Production Report.FreeColPanel
showReportReligiousPanel()
Show the Religion Report.FreeColPanel
showReportRequirementsPanel()
Show the Requirements Report.FreeColPanel
showReportTradePanel()
Show the Trade Report.FreeColPanel
showReportTurnPanel(java.util.List<ModelMessage> messages)
Show the Turn Report.java.lang.String
showRiverStyleDialog(java.util.List<java.lang.String> styles)
Show the river style dialog.java.io.File
showSaveDialog(java.io.File directory, java.lang.String defaultName)
Show the save dialog.java.awt.Dimension
showScaleMapSizeDialog()
Show the map scale dialog.int
showSelectAmountDialog(GoodsType goodsType, int available, int defaultAmount, boolean needToPay)
Show a dialog allowing selecting an amount of goods.Location
showSelectDestinationDialog(Unit unit)
Show a dialog allowing the user to select a destination for a given unit.int
showSelectTributeAmountDialog(StringTemplate question, int maximum)
Show the select-tribute-amount dialog.FreeColPanel
showServerListPanel(java.util.List<ServerInfo> serverList)
Show theServerListPanel
.FreeColPanel
showStartGamePanel(Game game, Player player, boolean singlePlayerMode)
Show the StartGamePanel.FreeColPanel
showStatisticsPanel(java.util.Map<java.lang.String,java.lang.String> serverStats, java.util.Map<java.lang.String,java.lang.String> clientStats)
Show the statistics panel.FreeColPanel
showStatusPanel(java.lang.String message)
Shows a status message which goes away when a new component is added.FreeColPanel
showTilePanel(Tile tile)
Show the tile panel for a given tile.void
showTilePopup(Tile tile)
Shows a tile popup for a given tile.FreeColPanel
showTradeRouteInputPanel(TradeRoute tr)
Show the trade route input panel for a given trade route.FreeColPanel
showTradeRoutePanel(Unit unit)
Show a panel to select a trade route for a unit.FreeColPanel
showTrainPanel()
Show the training panel.void
showVictoryDialog(DialogHandler<java.lang.Boolean> handler)
Show the victory dialog.boolean
showWarehouseDialog(Colony colony)
Show the warehouse dialog for a colony.FreeColPanel
showWorkProductionPanel(Unit unit)
Show the production of a unit.void
startGUI(java.awt.Dimension desiredWindowSize)
Starts the GUI by creating and displaying the GUI-objects.void
startMapEditorGUI()
Start the GUI for the map editor.Tile
tileAt(int x, int y)
Get the tile at given coordinate.void
traverseGotoPath()
Send the active unit along the current goto path as far as possible.void
updateEuropeanSubpanels()
Update all panels derived from the EuropePanel.void
updateGoto(int x, int y, boolean start)
Update the goto path to a new position on the map.void
updateMapControls()
Update the map controls, including the InfoPanel according to the view mode.void
updateMenuBar()
Update the menu bar.void
zoomInMap()
Zoom the map in.void
zoomInMapControls()
Zoom in the map controls.void
zoomOutMap()
Zoom the map out.void
zoomOutMapControls()
Zoom out the map controls.-
Methods inherited from class net.sf.freecol.client.control.FreeColClientHolder
askServer, currentPlayerIsMyPlayer, getClientOptions, getConnectController, getFreeColClient, getFreeColServer, getGame, getGUI, getMap, getMyPlayer, getSpecification, igc, pgc
-
-
-
-
Constructor Detail
-
GUI
public GUI(FreeColClient freeColClient)
Create the GUI.- Parameters:
freeColClient
- TheFreeColClient
for the game.
-
-
Method Detail
-
confirm
public final boolean confirm(java.lang.String textKey, java.lang.String okKey, java.lang.String cancelKey)
Simple modal confirmation dialog.- Parameters:
textKey
- A string to use as the message key.okKey
- A key for the message on the "ok" button.cancelKey
- A key for the message on the "cancel" button.- Returns:
- True if the "ok" button was selected.
-
confirm
public final boolean confirm(StringTemplate template, java.lang.String okKey, java.lang.String cancelKey)
Primitive modal confirmation dialog.- Parameters:
template
- TheStringTemplate
explaining the choice.okKey
- A key for the "ok" button.cancelKey
- A key for the "cancel" button.- Returns:
- True if the "ok" button was selected.
-
confirm
public final boolean confirm(Tile tile, StringTemplate template, GoodsType goodsType, java.lang.String okKey, java.lang.String cancelKey)
GoodsType-specific modal confirmation dialog.- Parameters:
tile
- An optionalTile
to expose.template
- TheStringTemplate
explaining the choice.goodsType
- A goods type to make an icon for the dialog from.okKey
- A key for the "ok" button.cancelKey
- A key for the "cancel" button.- Returns:
- True if the "ok" button was selected.
-
confirm
public final boolean confirm(Tile tile, StringTemplate template, Settlement settlement, java.lang.String okKey, java.lang.String cancelKey)
Settlement-specific modal confirmation dialog.- Parameters:
tile
- An optionalTile
to expose.template
- TheStringTemplate
explaining the choice.settlement
- A settlement to make an icon for the dialog from.okKey
- A key for the "ok" button.cancelKey
- A key for the "cancel" button.- Returns:
- True if the "ok" button was selected.
-
confirm
public final boolean confirm(Tile tile, StringTemplate template, Unit unit, java.lang.String okKey, java.lang.String cancelKey)
Unit-specific modal confirmation dialog.- Parameters:
tile
- An optionalTile
to expose.template
- TheStringTemplate
explaining the choice.unit
- A unit to make an icon for the dialog from.okKey
- A key for the "ok" button.cancelKey
- A key for the "cancel" button.- Returns:
- True if the "ok" button was selected.
-
confirmAbandonEducation
public boolean confirmAbandonEducation(Unit unit, boolean leaveColony)
Confirm that a unit should abandon its educational activity.- Parameters:
unit
- TheUnit
to check.leaveColony
- True if the unit is about to leave the colony, not just the education building.- Returns:
- True if the unit can proceed.
-
confirmClearTradeRoute
public boolean confirmClearTradeRoute(Unit unit)
If a unit has a trade route, get confirmation that it is ok to clear it and set a destination.- Parameters:
unit
- TheUnit
to check.- Returns:
- Whether it is acceptable to set a destination for this unit.
-
confirmEuropeanTribute
public int confirmEuropeanTribute(Unit attacker, Colony colony, NationSummary ns)
Confirm whether the player wants to demand tribute from a colony.- Parameters:
attacker
- The potential attackingUnit
.colony
- The targetColony
.ns
- ANationSummary
of the other nation.- Returns:
- The amount of tribute to demand, positive if the demand should proceed.
-
confirmHostileAction
public boolean confirmHostileAction(Unit attacker, Tile target)
Check if an attack results in a transition from peace or cease fire to war and, if so, warn the player.- Parameters:
attacker
- The potential attackingUnit
.target
- The targetTile
.- Returns:
- True to attack, false to abort.
-
confirmLeaveColony
public boolean confirmLeaveColony(Unit unit)
Confirm that a unit can leave its colony. - Check for population limit. - Query if education should be abandoned.- Parameters:
unit
- TheUnit
that is leaving the colony.- Returns:
- True if the unit is allowed to leave.
-
confirmNativeTribute
public int confirmNativeTribute(Unit attacker, IndianSettlement is)
Confirm whether the player wants to demand tribute from a native settlement.- Parameters:
attacker
- The potential attackingUnit
.is
- The targetIndianSettlement
.- Returns:
- The amount of tribute to demand, positive if the demand should proceed.
-
confirmPreCombat
public boolean confirmPreCombat(Unit attacker, Tile tile)
Shows the pre-combat dialog if enabled, allowing the user to view the odds and possibly cancel the attack.- Parameters:
attacker
- The attackingUnit
.tile
- The targetTile
.- Returns:
- True to attack, false to abort.
-
confirmStopGame
public boolean confirmStopGame()
Confirm whether to stop the current game.- Returns:
- True if confirmation was given.
-
getArmedUnitSettlementChoice
public Constants.ArmedUnitSettlementAction getArmedUnitSettlementChoice(Settlement settlement)
Get the choice of what a user wants to do with an armed unit at a foreign settlement.- Parameters:
settlement
- TheSettlement
to consider.- Returns:
- The chosen action, tribute, attack or cancel.
-
getBoycottChoice
public Constants.BoycottAction getBoycottChoice(Goods goods, Europe europe)
Get the user choice of whether to pay arrears for boycotted goods or to dump them instead.- Parameters:
goods
- TheGoods
to possibly dump.europe
- The playerEurope
where the boycott is in force.- Returns:
- The chosen
BoycottAction
.
-
getBuyChoice
public Constants.TradeBuyAction getBuyChoice(Unit unit, Settlement settlement, Goods goods, int gold, boolean canBuy)
Gets the user choice when negotiating a purchase from a settlement.- Parameters:
unit
- TheUnit
that is buying.settlement
- TheSettlement
to buy from.goods
- TheGoods
to buy.gold
- The current negotiated price.canBuy
- True if buy is a valid option.- Returns:
- The chosen action, buy, haggle, or cancel.
-
getChoice
public final <T> T getChoice(StringTemplate explain, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
General modal choice dialog.- Type Parameters:
T
- The choice type.- Parameters:
explain
- AStringTemplate
explaining the choice.cancelKey
- A key for the "cancel" button.choices
- A list aChoiceItem
s to choose from.- Returns:
- The selected value of the selected
ChoiceItem
, or null if cancelled.
-
getChoice
private final <T> T getChoice(Tile tile, StringTemplate template, GoodsType goodsType, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
Goods-specific modal choice dialog.- Type Parameters:
T
- The choice type.- Parameters:
tile
- An optionalTile
to expose.template
- AStringTemplate
explaining the choice.goodsType
- AGoodsType
to display in dialog.cancelKey
- A key for the "cancel" button.choices
- A list aChoiceItem
s to choose from.- Returns:
- The selected value of the selected
ChoiceItem
, or null if cancelled.
-
getChoice
private final <T> T getChoice(Tile tile, StringTemplate template, Nation nation, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
Nation-specific modal choice dialog.- Type Parameters:
T
- The choice type.- Parameters:
tile
- An optionalTile
to expose.template
- AStringTemplate
explaining the choice.nation
- ANation
to display in dialog.cancelKey
- A key for the "cancel" button.choices
- A list aChoiceItem
s to choose from.- Returns:
- The selected value of the selected
ChoiceItem
, or null if cancelled.
-
getChoice
public final <T> T getChoice(Tile tile, StringTemplate template, Settlement settlement, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
Settlement-specific modal choice dialog.- Type Parameters:
T
- The choice type.- Parameters:
tile
- An optionalTile
to expose.template
- AStringTemplate
explaining the choice.settlement
- ASettlement
to display in dialog.cancelKey
- A key for the "cancel" button.choices
- A list aChoiceItem
s to choose from.- Returns:
- The selected value of the selected
ChoiceItem
, or null if cancelled.
-
getChoice
public final <T> T getChoice(Tile tile, StringTemplate template, Unit unit, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
Unit-specific modal choice dialog.- Type Parameters:
T
- The choice type.- Parameters:
tile
- An optionalTile
to expose.template
- AStringTemplate
explaining the choice.unit
- AUnit
to display in dialog.cancelKey
- A key for the "cancel" button.choices
- A list aChoiceItem
s to choose from.- Returns:
- The selected value of the selected
ChoiceItem
, or null if cancelled.
-
getClaimChoice
public Constants.ClaimAction getClaimChoice(Tile tile, Player player, int price, Player owner)
Gets the user choice for claiming a tile.- Parameters:
tile
- TheTile
to claim.player
- ThePlayer
that is claiming.price
- An asking price, if any.owner
- ThePlayer
that owns the land.- Returns:
- The chosen action, accept, steal or cancel.
-
getIndianSettlementTradeChoice
public Constants.TradeAction getIndianSettlementTradeChoice(Settlement settlement, StringTemplate template, boolean canBuy, boolean canSell, boolean canGift)
Get the user choice when trading with a native settlement.- Parameters:
settlement
- The native settlement to trade with.template
- AStringTemplate
containing the message to display.canBuy
- Show a "buy" option.canSell
- Show a "sell" option.canGift
- Show a "gift" option.- Returns:
- The chosen action, buy, sell, gift or cancel.
-
getMissionaryChoice
public Constants.MissionaryAction getMissionaryChoice(Unit unit, IndianSettlement is, boolean canEstablish, boolean canDenounce)
Get the user choice of what to do with a missionary at a native settlement.- Parameters:
unit
- TheUnit
speaking to the settlement.is
- TheIndianSettlement
being visited.canEstablish
- Is establish a valid option.canDenounce
- Is denounce a valid option.- Returns:
- The chosen action, establish mission, denounce, incite or cancel.
-
getNewColonyName
public java.lang.String getNewColonyName(Player player, Tile tile)
Get a name for a new colony for a player.- Parameters:
player
- ThePlayer
to get the colony name for.tile
- TheTile
for the new colony.- Returns:
- A colony name, or null if the user has reconsidered.
-
getScoutForeignColonyChoice
public Constants.ScoutColonyAction getScoutForeignColonyChoice(Colony colony, Unit unit, boolean neg)
Get the user choice for what to do with a scout at a foreign colony.- Parameters:
colony
- TheColony
to be scouted.unit
- TheUnit
that is scouting.neg
- True if negotation is a valid choice.- Returns:
- The selected action, either negotiate, spy, attack or cancel.
-
getScoutIndianSettlementChoice
public Constants.ScoutIndianSettlementAction getScoutIndianSettlementChoice(IndianSettlement is, java.lang.String numberString)
Get the user choice for what to do at a native settlement.- Parameters:
is
- TheIndianSettlement
to be scouted.numberString
- The number of settlements in the settlement owner nation.- Returns:
- The chosen action, speak, tribute, attack or cancel.
-
getSellChoice
public Constants.TradeSellAction getSellChoice(Unit unit, Settlement settlement, Goods goods, int gold)
Get the user choice for negotiating a sale to a settlement.- Parameters:
unit
- TheUnit
that is selling.settlement
- TheSettlement
to sell to.goods
- TheGoods
to sell.gold
- The current negotiated price.- Returns:
- The chosen action, sell, gift or haggle, or null.
-
showDifficultyDialog
public final OptionGroup showDifficultyDialog()
Get the option group that defines a difficulty level.- Returns:
- The
OptionGroup
selected.
-
showErrorPanel
public final FreeColPanel showErrorPanel(StringTemplate template)
Show an i18n compliant error message derived from a template.- Parameters:
template
- TheStringTemplate
containing the message.- Returns:
- The panel shown.
-
showErrorPanel
public final FreeColPanel showErrorPanel(StringTemplate template, java.lang.String message)
Show an i18n compliant error message derived from a template, with optional extra debug information.- Parameters:
template
- TheStringTemplate
containing the message.message
- Optional extra debug information.- Returns:
- The panel shown.
-
showErrorPanel
public final FreeColPanel showErrorPanel(StringTemplate template, java.lang.String message, java.lang.Runnable callback)
Show an i18n compliant error message derived from a template, with optional extra debug information and an optional callback.- Parameters:
template
- TheStringTemplate
containing the message.message
- Optional extra debug information.callback
- Optional routine to run when the error panel is closed.- Returns:
- The panel shown.
-
showErrorPanel
public final void showErrorPanel(java.lang.Exception ex, StringTemplate template)
Show a serious error message with an exception and return to the main panel when done. This time, do not return the panel as we have already defined a callback.- Parameters:
ex
- An optionalException
to display.template
- AStringTemplate
for the message.
-
showInformationPanel
public final FreeColPanel showInformationPanel(java.lang.String messageId)
Show an information message.- Parameters:
messageId
- The message key.- Returns:
- The panel shown.
-
showInformationPanel
public final FreeColPanel showInformationPanel(StringTemplate template)
Show an information message.- Parameters:
template
- The message template.- Returns:
- The panel shown.
-
showInformationPanel
public final FreeColPanel showInformationPanel(FreeColObject displayObject, java.lang.String messageId)
Show an information message.- Parameters:
displayObject
- An optional object to display as an icon.messageId
- The message key.- Returns:
- The panel shown.
-
showLoadSaveFileDialog
public final java.io.File showLoadSaveFileDialog(java.io.File root, java.lang.String extension)
Show a save file dialog, selecting one to load.- Parameters:
root
- The root directory to look in.extension
- The file extension to look for.- Returns:
- The
File
selected, or null on error.
-
showNewPanel
public final void showNewPanel()
Show the NewPanel.
-
playSound
public void playSound(java.lang.String sound)
Play a sound.- Parameters:
sound
- The sound resource to play, or if null stop playing.
-
getSoundMixerLabelText
public java.lang.String getSoundMixerLabelText()
Get the label text for the sound player mixer. Used by: AudioMixerOptionUI- Returns:
- The text.
-
getFixedImageLibrary
public ImageLibrary getFixedImageLibrary()
Get the fixed image library for use on panels. Used by: ColonyPanel, ConstructionPanel, InfoPanel, certain UnitLabels.- Returns:
- Null here, real implementations will override.
-
getScaledImageLibrary
public ImageLibrary getScaledImageLibrary()
Get the scaled image library for use on the map.- Returns:
- Null here, real implementations will override.
-
isWindowed
public boolean isWindowed()
Is this GUI in windowed mode? Used by: DragListener for a nasty workaround that should go away- Returns:
- True by default, real implementations will override.
-
invokeNowOrLater
public void invokeNowOrLater(java.lang.Runnable runnable)
Run in the EDT, either immediately if in it or later when it wakes up.- Parameters:
runnable
- ARunnable
to run.
-
invokeNowOrWait
public void invokeNowOrWait(java.lang.Runnable runnable)
Run in the EDT, either immediately or wait for it.- Parameters:
runnable
- ARunnable
to run.
-
changeWindowedMode
public void changeWindowedMode()
Change the windowed mode (really a toggle). Used by: ChangeWindowedModeAction
-
installLookAndFeel
public void installLookAndFeel(java.lang.String fontName) throws FreeColException
Swing system and look-and-feel initialization. Used by: FreeColClient- Parameters:
fontName
- An optional font name to be used.- Throws:
FreeColException
- if the LAF is incompatible with the GUI.
-
quitGUI
public void quitGUI()
Quit the GUI. All that is required is to exit the full screen. Used by: FreeColClient.quit
-
reconnectGUI
public void reconnectGUI(Unit active, Tile tile)
Reset the GUI on reconnect. Used by: FreeColClient.restoreGUI- Parameters:
active
- An optional activeUnit
.tile
- An optionalTile
to focus on if there is no active unit.
-
removeInGameComponents
public void removeInGameComponents()
Remove all in-game components (i.e. all the Listeners). Used by: ContinueAction, ConnectController.{mainTitle,newGame} InGameController.loadGame, MapEditorController.newMap, StartMapAction
-
showOpeningVideo
public void showOpeningVideo(java.lang.String userMsg, java.lang.Runnable callback)
Shows theVideoPanel
. Used by: FreeColClient- Parameters:
userMsg
- An optional user message.callback
- ARunnable
to run when the video completes.
-
startGUI
public void startGUI(java.awt.Dimension desiredWindowSize)
Starts the GUI by creating and displaying the GUI-objects. Used by: FreeColClient- Parameters:
desiredWindowSize
- The desired size of the GUI window.
-
getMapViewDimension
public java.awt.Dimension getMapViewDimension()
-
startMapEditorGUI
public void startMapEditorGUI()
Start the GUI for the map editor. Used by: NewPanel
-
animateUnitAttack
public void animateUnitAttack(Unit attacker, Unit defender, Tile attackerTile, Tile defenderTile, boolean success)
Animate a unit attack. Used by: client InGameController- Parameters:
attacker
- The attackingUnit
.defender
- The defendingUnit
.attackerTile
- TheTile
to show the attacker on.defenderTile
- TheTile
to show the defender on.success
- Did the attack succeed?
-
animateUnitMove
public void animateUnitMove(Unit unit, Tile srcTile, Tile dstTile)
Animate a unit move. Used by: client InGameController- Parameters:
unit
- TheUnit
that is moving.srcTile
- TheTile
the unit starts at.dstTile
- TheTile
the unit moves to.
-
confirm
public boolean confirm(Tile tile, StringTemplate template, javax.swing.ImageIcon icon, java.lang.String okKey, java.lang.String cancelKey)
General modal confirmation dialog.- Parameters:
tile
- An optionalTile
to expose.template
- TheStringTemplate
explaining the choice.icon
- AnImageIcon
to display in dialog.okKey
- A key for the message on the "ok" button.cancelKey
- A key for the message on the "cancel" button.- Returns:
- True if the "ok" button was selected.
-
getChoice
protected <T> T getChoice(Tile tile, StringTemplate template, javax.swing.ImageIcon icon, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
General modal choice dialog.- Type Parameters:
T
- The choice type.- Parameters:
tile
- An optionalTile
to expose.template
- AStringTemplate
explaining the choice.icon
- An optionalImageIcon
to display in dialog.cancelKey
- A key for the message on the "cancel" button.choices
- A list aChoiceItem
s to choose from.- Returns:
- The selected value of the selected
ChoiceItem
, or null if cancelled.
-
getInput
public java.lang.String getInput(Tile tile, StringTemplate template, java.lang.String defaultValue, java.lang.String okKey, java.lang.String cancelKey)
General modal string input dialog.- Parameters:
tile
- An optionalTile
to expose.template
- AStringTemplate
explaining the choice.defaultValue
- The default value to show initially.okKey
- A key for the message on the "ok" button.cancelKey
- A key for the message on the "cancel" button.- Returns:
- The chosen value.
-
getFocus
public Tile getFocus()
Get the current focus tile. Used by: MiniMap.paintMap- Returns:
- The focus
Tile
.
-
setFocus
public void setFocus(Tile tile)
Set the current focus tile. Used by: CanvasMapEditorMouseListener, CenterAction, FindSettlementPanel, InfoPanel, MiniMap.focus, MapEditorController, SelectDestinationDialog.recenter- Parameters:
tile
- The new focusTile
.
-
setUnitPath
public void setUnitPath(PathNode path)
Set the path for the active unit. Used by: TilePopup- Parameters:
path
- The new unit path.
-
activateGotoPath
public void activateGotoPath()
Start/stop the goto path display. Used by: GotoTileAction
-
clearGotoPath
public void clearGotoPath()
Stop the goto path display. Used by: client InGameController.askClearGotoOrders
-
isGotoStarted
public boolean isGotoStarted()
Check if the user has GoTo mode enabled. Used by: CanvasMouseListener- Returns:
- True if the user has toggled GoTo mode.
-
performGoto
public void performGoto(Tile tile)
Perform an immediate goto to a tile with the active unit. Used by: TilePopup- Parameters:
tile
- TheTile
to go to.
-
performGoto
public void performGoto(int x, int y)
Perform an immediate goto to a point on the map. Used by: CanvasMouseListener- Parameters:
x
- The x coordinate of the goto destination (pixels).y
- The x coordinate of the goto destination (pixels).
-
traverseGotoPath
public void traverseGotoPath()
Send the active unit along the current goto path as far as possible. Used by: CanvasMouseListener
-
updateGoto
public void updateGoto(int x, int y, boolean start)
Update the goto path to a new position on the map. Used by: CanvasMouseMotionListener- Parameters:
x
- The x coordinate for the new goto path destination (pixels).y
- The y coordinate for the new goto path destination (pixels).start
- If true start a new goto if one is not underway.
-
prepareDrag
public void prepareDrag(int x, int y)
Prepare a drag from the given coordinates. This may turn into a goto if further drag motion is detected. Used by: CanvasMouseListener- Parameters:
x
- Drag x coordinate (pixels).y
- Drag x coordinate (pixels).
-
canZoomInMapControls
public boolean canZoomInMapControls()
Is the map able to zoom in further? Used by: MiniMapZoomInAction- Returns:
- True if the map can zoom in.
-
canZoomOutMapControls
public boolean canZoomOutMapControls()
Is the map able to zoom out further? Used by: MiniMapZoomOutAction- Returns:
- True if the map can zoom out.
-
enableMapControls
public void enableMapControls(boolean enable)
Enable the map controls. Used by: MapControlsAction.- Parameters:
enable
- If true then enable.
-
miniMapToggleFogOfWarControls
public void miniMapToggleFogOfWarControls()
Toggle the fog of war control. Used by: MiniMapToggleFogOfWarAction
-
miniMapToggleViewControls
public void miniMapToggleViewControls()
Toggle the view control. Used by: MiniMapToggleFogOfWarAction
-
updateMapControls
public void updateMapControls()
Update the map controls, including the InfoPanel according to the view mode. Used by: client InGameController.updateGUI, MapEditorController
-
zoomInMapControls
public void zoomInMapControls()
Zoom in the map controls. Used by: MiniMapZoomInAction
-
zoomOutMapControls
public void zoomOutMapControls()
Zoom out the map controls. Used by: MiniMapZoomOutAction
-
closeMenus
public void closeMenus()
Close any open menus. Used by: FreeColClient.skipTurns, client InGameController.{endTurn,setCurrentPlayer} MapEditorController, PreGameController
-
updateMenuBar
public void updateMenuBar()
Update the menu bar. Used by: InGameController.updateGUI, MapEditorController, NewEmptyMapAction
-
showPopupMenu
public void showPopupMenu(javax.swing.JPopupMenu menu, int x, int y)
Display a popup menu. Used by: ColonyPanel, DragListener- Parameters:
menu
- TheJPopupMenu
to display.x
- The menu x coordinate.y
- The menu y coordinate.
-
getScrollDirection
public Direction getScrollDirection(int x, int y, int scrollSpace, boolean ignoreTop)
Work out what direction to scroll the map if a coordinate is close to an edge.- Parameters:
x
- The x coordinate.y
- The y coordinate.scrollSpace
- The clearance from the relevant edgeignoreTop
- If the top should be ignored- Returns:
- The
Direction
to scroll, or null if not.
-
scrollMap
public boolean scrollMap(Direction direction)
Scroll the map in a given direction.- Parameters:
direction
- TheDirection
to scroll.- Returns:
- True if scrolling can continue.
-
createTileImageWithBeachBorderAndItems
public java.awt.image.BufferedImage createTileImageWithBeachBorderAndItems(Tile tile)
-
createColonyTileImage
public java.awt.image.BufferedImage createColonyTileImage(Tile tile, Colony colony)
-
displayColonyTiles
public void displayColonyTiles(java.awt.Graphics2D g2d, Tile[][] tiles, Colony colony)
Display the ColonyTiles of a Colony. Used by: ColonyPanel.TilesPanel- Parameters:
g2d
- AGraphics2D
to draw to.tiles
- TheTile
s to display.colony
- The enclosingColony
.
-
getViewMode
public GUI.ViewMode getViewMode()
Get the current view mode. Used by: MoveAction, ToggleViewModeAction- Returns:
- One of the view mode constants, or negative on error.
-
getActiveUnit
public Unit getActiveUnit()
Get the active unit. Used by: many- Returns:
- The current active
Unit
.
-
getSelectedTile
public Tile getSelectedTile()
Get the selected tile. Used by: MoveAction, TilePopupAction, ToggleViewModeAction- Returns:
- The selected
Tile
.
-
changeView
public void changeView(Tile tile)
Change to terrain mode and select a tile. Used by: CanvasMapEditorMouseListener, client InGameController.{updateActiveUnit,moveTileCursor}- Parameters:
tile
- TheTile
to select.
-
changeView
public void changeView(Unit unit, boolean force)
Change to move units mode, and select a unit. Used by: ChangeAction, DebugUtils, EndTurnDialog, client InGameController (several) MapEditorController, TilePopup, QuickActionMenu, UnitLabel- Parameters:
unit
- TheUnit
to select.force
- Set true if the unit is the same, but *has* changed in some way (e.g. moves left).
-
changeView
public void changeView(MapTransform transform)
Change to map transform mode, and select a transform. Used by: MapEditorController- Parameters:
transform
- TheMapTransform
to select.
-
changeView
public void changeView()
Change to end turn mode. Used by: client InGameController.updateActiveUnit
-
canZoomInMap
public boolean canZoomInMap()
Can the map be zoomed in? Used by: ZoomInAction- Returns:
- True if the map can zoom in.
-
canZoomOutMap
public boolean canZoomOutMap()
Can the map be zoomed out? Used by: ZoomOutAction- Returns:
- True if the map can zoom out.
-
zoomInMap
public void zoomInMap()
Zoom the map in. Used by: ZoomInAction
-
zoomOutMap
public void zoomOutMap()
Zoom the map out. Used by: ZoomOutAction
-
clickAt
public void clickAt(int count, int x, int y)
Handle a click on the canvas. Used by: CanvasMouseListener- Parameters:
count
- The click count.x
- The x coordinate of the click.y
- The y coordinate of the click.
-
closePanel
public void closePanel(java.lang.String panel)
Close a panel. Used by: client InGameController.closehandler- Parameters:
panel
- The identifier for the panel to close.
-
closeMainPanel
public void closeMainPanel()
Close the main panel if present. Used by: MapEditorController, PreGameController
-
closeStatusPanel
public void closeStatusPanel()
Close the status panel if present. Used by: FreeColClient, MapEditorController, client InGameController, PreGameController
-
displayChat
public void displayChat(java.lang.String sender, java.lang.String message, java.awt.Color color, boolean privateChat)
Update with a new chat message. Used by: client InGameController.{chat,chatHandler}- Parameters:
sender
- The message sender.message
- The chat message.color
- The message color.privateChat
- True if the message is private.
-
displayObject
public void displayObject(FreeColObject fco)
Show the appropriate panel for an object.- Parameters:
fco
- TheFreeColObject
to display.
-
displayStartChat
public void displayStartChat(java.lang.String sender, java.lang.String message, boolean privateChat)
A chat message was received during the pre-game setup. Used by: PreGameController.chatHandler- Parameters:
sender
- The player who sent the chat message.message
- The chat message.privateChat
- True if the message is private.
-
isClientOptionsDialogShowing
public boolean isClientOptionsDialogShowing()
Checks if a client options dialog is present. Used by: FreeColAction.shouldBeEnabled- Returns:
- True if the client options are showing.
-
isPanelShowing
public boolean isPanelShowing()
Is another panel being displayed. Used by: many Actions- Returns:
- True if there is another panel present.
-
refresh
public void refresh()
Refresh the whole GUI. This is done by invalidating any cached rendering and then repainting the entire screen. Please use only when the entire map should be fully updated. Please useMapViewerRepaintManager.markAsDirty(Tile)
andrepaint()
instead, if only parts of the map need to be updated.
-
repaint
public void repaint()
Repaints the entire screen, but uses image caches to avoid unnecessary painting of the map. Please useMapViewerRepaintManager.markAsDirty(Tile)
in order to invalidate the caches for a given tile.- See Also:
refresh()
-
refreshTile
public void refreshTile(Tile tile)
-
refreshPlayersTable
public void refreshPlayersTable()
Refresh the players table in the StartGamePanel. Used by: SetNationMessage.clientHandler
-
removeComponent
public void removeComponent(java.awt.Component component)
Remove a component from the GUI. Used by: Many panels to close themselves. TODO: is this right?- Parameters:
component
- TheComponent
to remove.
-
removeDialog
public void removeDialog(FreeColDialog<?> fcd)
Remove a dialog from the GUI. Used by: FreeColDialog.removeNotify- Parameters:
fcd
- TheFreeColDialog
to remove.
-
removeTradeRoutePanel
public void removeTradeRoutePanel(FreeColPanel panel)
Remove a trade route panel and associated input on an associated TradeRouteInputPanel. Used by: TradeRoutePanel- Parameters:
panel
- TheFreeColPanel
to remove.
-
restoreSavedSize
public void restoreSavedSize(java.awt.Component comp, java.awt.Dimension d)
Set dialog preferred size to saved size or to the givenDimension
if no saved size was found. Call this method in the constructor of a FreeColPanel in order to remember its size and position. Used by: *Panel- Parameters:
comp
- TheComponent
to use.d
- TheDimension
to use as default.
-
showTilePopup
public void showTilePopup(Tile tile)
Shows a tile popup for a given tile.- Parameters:
tile
- TheTile
where the popup occurred.
-
tileAt
public Tile tileAt(int x, int y)
Get the tile at given coordinate.- Parameters:
x
- The x coordinate.y
- The y coordinate.- Returns:
- The
Tile
found.
-
updateEuropeanSubpanels
public void updateEuropeanSubpanels()
Update all panels derived from the EuropePanel. Used by: NewUnitPanel, RecruitUnitPanel
-
showAboutPanel
public FreeColPanel showAboutPanel()
Show the AboutPanel.- Returns:
- The panel shown.
-
showBuildQueuePanel
public FreeColPanel showBuildQueuePanel(Colony colony)
Show the build queue for a colony.- Parameters:
colony
- TheColony
to show a panel for.- Returns:
- The build queue panel.
-
showCaptureGoodsDialog
public void showCaptureGoodsDialog(Unit unit, java.util.List<Goods> gl, DialogHandler<java.util.List<Goods>> handler)
Show the dialog to select captured goods.- Parameters:
unit
- TheUnit
capturing goods.gl
- The list ofGoods
to choose from.handler
- ADialogHandler
for the dialog response.
-
showChatPanel
public FreeColPanel showChatPanel()
Show the chat panel.- Returns:
- The panel shown.
-
showChooseFoundingFatherDialog
public void showChooseFoundingFatherDialog(java.util.List<FoundingFather> ffs, DialogHandler<FoundingFather> handler)
Show the founding father choice panel.- Parameters:
ffs
- The list ofFoundingFather
s to choose from.handler
- The callback to pass the choice to.
-
showClientOptionsDialog
public void showClientOptionsDialog()
Show the client options dialog.
-
refreshGuiUsingClientOptions
public void refreshGuiUsingClientOptions()
Refreshes the GUI with settings from the client options.
-
showColonyPanel
public FreeColPanel showColonyPanel(Colony colony, Unit unit)
Show the colony panel- Parameters:
colony
- TheColony
to display.unit
- An optionalUnit
to select within the panel.- Returns:
- The panel shown.
-
showColopediaPanel
public FreeColPanel showColopediaPanel(java.lang.String nodeId)
Show a colopedia panel.- Parameters:
nodeId
- The identifier for the colopedia node to show.- Returns:
- The panel shown.
-
showColorChooserPanel
public FreeColPanel showColorChooserPanel(java.awt.event.ActionListener al)
Show a color chooser panel.- Parameters:
al
- AnActionListener
to handle panel button presses.- Returns:
- The panel shown.
-
showCompactLabourReport
public FreeColPanel showCompactLabourReport()
Show the compact labour report panel.- Returns:
- The panel shown.
-
showCompactLabourReport
public FreeColPanel showCompactLabourReport(LabourData.UnitData unitData)
Show the compact labour report for the specified unit data.- Parameters:
unitData
- TheUnitData
to display.- Returns:
- The panel shown.
-
showConfirmDeclarationDialog
public java.util.List<java.lang.String> showConfirmDeclarationDialog()
Confirm declaration of independence.- Returns:
- A list of new nation and country names.
-
showDeclarationPanel
public void showDeclarationPanel(java.lang.Runnable afterClosing)
Show the declaration panel with the declaration of independence and an animated signature.- Parameters:
afterClosing
- A callback that is executed after the panel closes.
-
showDifficultyDialog
public OptionGroup showDifficultyDialog(Specification spec, OptionGroup group, boolean editable)
Show a dialog for a difficulty option group.- Parameters:
spec
- The enclosingSpecification
.group
- TheOptionGroup
to show.editable
- If true, the option group can be edited.- Returns:
- The (possibly modified)
OptionGroup
.
-
showDumpCargoDialog
public void showDumpCargoDialog(Unit unit, DialogHandler<java.util.List<Goods>> handler)
Show a dialog to choose what goods to dump.- Parameters:
unit
- TheUnit
that is dumping goods.handler
- A callback to pass the dumped goods list to.
-
showEditOptionDialog
public boolean showEditOptionDialog(Option option)
Show a dialog for editing an individual option.- Parameters:
option
- TheOption
to edit.- Returns:
- True if the option edit was accepted.
-
showEditSettlementDialog
public IndianSettlement showEditSettlementDialog(IndianSettlement is)
Show a dialog for editing a settlmeent.- Parameters:
is
- TheIndianSettlement
to edit.- Returns:
- The settlement post-edit.
-
showEmigrationDialog
public void showEmigrationDialog(Player player, boolean fountainOfYouth, DialogHandler<java.lang.Integer> handler)
Show a dialog to handle emigration.- Parameters:
player
- ThePlayer
whose emigration state needs work.fountainOfYouth
- True if a Fountain of Youth event occurred.handler
- A callback to pass a selected emigration index to.
-
showEndTurnDialog
public void showEndTurnDialog(java.util.List<Unit> units, DialogHandler<java.lang.Boolean> handler)
Show a dialog for the end of turn.- Parameters:
units
- A list ofUnit
s that can still move.handler
- A callback to handle the user selected end turn state.
-
showErrorPanel
public FreeColPanel showErrorPanel(java.lang.String message, java.lang.Runnable callback)
Show an error panel.- Parameters:
message
- The error message to display.callback
- An optionalRunnable
to run on close.- Returns:
- The panel shown.
-
showEuropePanel
public FreeColPanel showEuropePanel()
Show the Europe panel.- Returns:
- The panel shown.
-
showEventPanel
public FreeColPanel showEventPanel(java.lang.String header, java.lang.String image, java.lang.String footer)
Show an event panel.- Parameters:
header
- The title.image
- A resource key for the image to display.footer
- Optional footer text.- Returns:
- The panel shown.
-
showFindSettlementPanel
public FreeColPanel showFindSettlementPanel()
Show the FindSettlement panel.- Returns:
- The panel shown.
-
showFirstContactDialog
public void showFirstContactDialog(Player player, Player other, Tile tile, int settlementCount, DialogHandler<java.lang.Boolean> handler)
Show a first contact dialog.- Parameters:
player
- ThePlayer
making contact.other
- ThePlayer
being contacted.tile
- TheTile
where the contact occurs.settlementCount
- A count of settlements described by the other player.handler
- A callback to handle the player decision to be friendly.
-
showGameOptionsDialog
public OptionGroup showGameOptionsDialog(boolean editable)
Show the Game options dialog.- Parameters:
editable
- True if the options can be edited.- Returns:
- The game options
OptionGroup
.
-
showHighScoresPanel
public FreeColPanel showHighScoresPanel(java.lang.String messageId, java.util.List<HighScore> scores)
Show the high scores panel.- Parameters:
messageId
- The message identifier.scores
- TheHighScore
s to display.- Returns:
- The panel shown.
-
showIndianSettlementPanel
public FreeColPanel showIndianSettlementPanel(IndianSettlement is)
Show a panel for a native settlement.- Parameters:
is
- TheIndianSettlement
to display.- Returns:
- The panel shown.
-
showInformationPanel
public FreeColPanel showInformationPanel(FreeColObject displayObject, StringTemplate template)
Show an information message.- Parameters:
displayObject
- Optional object for displaying as an icon.template
- TheStringTemplate
to display.- Returns:
- The panel shown.
-
showLoadDialog
public java.io.File showLoadDialog(java.io.File directory, java.lang.String extension)
Show a dialog where the user may choose a file.- Parameters:
directory
- The directory containing the files.extension
- An extension to select with.- Returns:
- The selected
File
.
-
showLoadingSavegameDialog
public LoadingSavegameInfo showLoadingSavegameDialog(boolean publicServer, boolean singlePlayer)
Show the LoadingSavegameDialog.- Parameters:
publicServer
- FIXMEsinglePlayer
- FIXME- Returns:
- The
LoadingSavegameInfo
from the dialog.
-
showLogFilePanel
public FreeColPanel showLogFilePanel()
Show the log file panel.- Returns:
- The panel shown.
-
showMainPanel
public FreeColPanel showMainPanel(java.lang.String userMsg)
Show the main panel.- Parameters:
userMsg
- An optional user message to display.- Returns:
- The panel shown.
-
showMainTitle
public void showMainTitle()
Complete reset back to the main panel.
-
showMapGeneratorOptionsDialog
public OptionGroup showMapGeneratorOptionsDialog(boolean editable)
Show the map generator options.- Parameters:
editable
- If true, allow edits.- Returns:
- The map generator
OptionGroup
.
-
showMapSizeDialog
public java.awt.Dimension showMapSizeDialog()
Show the map size dialog.- Returns:
- The selected map size as a
Dimension
.
-
showModelMessages
public FreeColPanel showModelMessages(java.util.List<ModelMessage> modelMessages)
Show model messages.- Parameters:
modelMessages
- A list ofModelMessage
s to display.- Returns:
- The panel shown.
-
showMonarchDialog
public void showMonarchDialog(Monarch.MonarchAction action, StringTemplate template, java.lang.String monarchKey, DialogHandler<java.lang.Boolean> handler)
Show the monarch dialog.- Parameters:
action
- The action the monarch is taking.template
- A message template.monarchKey
- The identifier for the monarch.handler
- A callback to handle the user response to the monarch action.
-
showNamingDialog
public void showNamingDialog(StringTemplate template, java.lang.String defaultName, Unit unit, DialogHandler<java.lang.String> handler)
Show the naming dialog.- Parameters:
template
- A message template.defaultName
- The default name for the object.unit
- TheUnit
that is naming.handler
- A callback to handle the user response.
-
showNativeDemandDialog
public void showNativeDemandDialog(Unit unit, Colony colony, GoodsType type, int amount, DialogHandler<java.lang.Boolean> handler)
Show the native demand dialog.- Parameters:
unit
- The demandingUnit
.colony
- TheColony
being demanded of.type
- TheGoodsType
demanded (null for gold).amount
- The amount of goods or gold demanded.handler
- A callback to handle the user response.
-
showNegotiationDialog
public DiplomaticTrade showNegotiationDialog(FreeColGameObject our, FreeColGameObject other, DiplomaticTrade agreement, StringTemplate comment)
Show the negotiation dialog.- Parameters:
our
- OurFreeColGameObject
that is negotiating.other
- The otherFreeColGameObject
.agreement
- The currentDiplomaticTrade
agreement.comment
- An optionalStringTemplate
containing a commentary message.- Returns:
- The negotiated
DiplomaticTrade
agreement.
-
showNewPanel
public FreeColPanel showNewPanel(Specification spec)
Show the NewPanel.- Parameters:
spec
- TheSpecification
to use.- Returns:
- The panel shown.
-
showParametersDialog
public Parameters showParametersDialog()
Show the parameter choice dialog.- Returns:
- The chosen parameters.
-
showPreCombatDialog
public boolean showPreCombatDialog(Unit attacker, FreeColGameObject defender, Tile tile)
Show the pre-combat dialog.- Parameters:
attacker
- TheUnit
that is attacking.defender
- TheFreeColObject
that is defending.tile
- TheTile
where the attack occurs.- Returns:
- True if the player decided to attack.
-
showPurchasePanel
public FreeColPanel showPurchasePanel()
Displays the purchase panel.- Returns:
- The panel shown.
-
showRecruitPanel
public FreeColPanel showRecruitPanel()
Displays the recruit panel.- Returns:
- The panel shown.
-
showReportCargoPanel
public FreeColPanel showReportCargoPanel()
Show the Cargo Report.- Returns:
- The panel shown.
-
showReportColonyPanel
public FreeColPanel showReportColonyPanel()
Show the Colony Report.- Returns:
- The panel shown.
-
showReportContinentalCongressPanel
public FreeColPanel showReportContinentalCongressPanel()
Show the Continental Congress Report.- Returns:
- The panel shown.
-
showReportEducationPanel
public FreeColPanel showReportEducationPanel()
Show the Education Report.- Returns:
- The panel shown.
-
showReportExplorationPanel
public FreeColPanel showReportExplorationPanel()
Show the Exploration Report.- Returns:
- The panel shown.
-
showReportForeignAffairPanel
public FreeColPanel showReportForeignAffairPanel()
Show the Foreign Affairs Report.- Returns:
- The panel shown.
-
showReportHistoryPanel
public FreeColPanel showReportHistoryPanel()
Show the History Report.- Returns:
- The panel shown.
-
showReportIndianPanel
public FreeColPanel showReportIndianPanel()
Show the Native Affairs Report.- Returns:
- The panel shown.
-
showReportLabourPanel
public FreeColPanel showReportLabourPanel()
Show the Labour Report.- Returns:
- The panel shown.
-
showReportLabourDetailPanel
public FreeColPanel showReportLabourDetailPanel(UnitType unitType, java.util.Map<UnitType,java.util.Map<Location,java.lang.Integer>> data, TypeCountMap<UnitType> unitCount, java.util.List<Colony> colonies)
Display the labour detail panel.- Parameters:
unitType
- TheUnitType
to display.data
- The labour data.unitCount
- A map of unit distribution.colonies
- The list of playerColony
s.- Returns:
- The panel shown.
-
showReportMilitaryPanel
public FreeColPanel showReportMilitaryPanel()
Show the Military Report.- Returns:
- The panel shown.
-
showReportNavalPanel
public FreeColPanel showReportNavalPanel()
Show the Naval Report.- Returns:
- The panel shown.
-
showReportProductionPanel
public FreeColPanel showReportProductionPanel()
Show the Production Report.- Returns:
- The panel shown.
-
showReportReligiousPanel
public FreeColPanel showReportReligiousPanel()
Show the Religion Report.- Returns:
- The panel shown.
-
showReportRequirementsPanel
public FreeColPanel showReportRequirementsPanel()
Show the Requirements Report.- Returns:
- The panel shown.
-
showReportTradePanel
public FreeColPanel showReportTradePanel()
Show the Trade Report.- Returns:
- The panel shown.
-
showReportTurnPanel
public FreeColPanel showReportTurnPanel(java.util.List<ModelMessage> messages)
Show the Turn Report.- Parameters:
messages
- TheModelMessage
s that make up the report.- Returns:
- The panel shown.
-
showRiverStyleDialog
public java.lang.String showRiverStyleDialog(java.util.List<java.lang.String> styles)
Show the river style dialog.- Parameters:
styles
- The river styles a choice is made from.- Returns:
- The response returned by the dialog.
-
showSaveDialog
public java.io.File showSaveDialog(java.io.File directory, java.lang.String defaultName)
Show the save dialog.- Parameters:
directory
- The directory containing the files.defaultName
- The default game to save.- Returns:
- The selected file.
-
showScaleMapSizeDialog
public java.awt.Dimension showScaleMapSizeDialog()
Show the map scale dialog.- Returns:
- The map scale as a
Dimension
.
-
showSelectAmountDialog
public int showSelectAmountDialog(GoodsType goodsType, int available, int defaultAmount, boolean needToPay)
Show a dialog allowing selecting an amount of goods.- Parameters:
goodsType
- TheGoodsType
to select an amount of.available
- The amount of goods available.defaultAmount
- The amount to select to start with.needToPay
- If true, check the player has sufficient funds.- Returns:
- The amount selected.
-
showSelectDestinationDialog
public Location showSelectDestinationDialog(Unit unit)
Show a dialog allowing the user to select a destination for a given unit.- Parameters:
unit
- TheUnit
to select a destination for.- Returns:
- A destination for the unit, or null.
-
showSelectTributeAmountDialog
public int showSelectTributeAmountDialog(StringTemplate question, int maximum)
Show the select-tribute-amount dialog.- Parameters:
question
- aStringTemplate
describing the amount of tribute to demand.maximum
- The maximum amount available.- Returns:
- The amount selected.
-
showServerListPanel
public FreeColPanel showServerListPanel(java.util.List<ServerInfo> serverList)
Show theServerListPanel
.- Parameters:
serverList
- The list containing the servers retrieved from the metaserver.- Returns:
- The panel shown.
-
showStartGamePanel
public FreeColPanel showStartGamePanel(Game game, Player player, boolean singlePlayerMode)
Show the StartGamePanel.- Parameters:
game
- TheGame
that is about to start.player
- ThePlayer
using this client.singlePlayerMode
- True to start a single player game.- Returns:
- The panel shown.
-
showStatisticsPanel
public FreeColPanel showStatisticsPanel(java.util.Map<java.lang.String,java.lang.String> serverStats, java.util.Map<java.lang.String,java.lang.String> clientStats)
Show the statistics panel.- Parameters:
serverStats
- A map of server statistics key,value pairs.clientStats
- A map of client statistics key,value pairs.- Returns:
- The panel shown.
-
showStatusPanel
public FreeColPanel showStatusPanel(java.lang.String message)
Shows a status message which goes away when a new component is added.- Parameters:
message
- The text message to display on the status panel.- Returns:
- The panel shown.
-
showTilePanel
public FreeColPanel showTilePanel(Tile tile)
Show the tile panel for a given tile.- Parameters:
tile
- TheTile
to display.- Returns:
- The panel shown.
-
showTradeRouteInputPanel
public FreeColPanel showTradeRouteInputPanel(TradeRoute tr)
Show the trade route input panel for a given trade route.- Parameters:
tr
- TheTradeRoute
to display.- Returns:
- The panel shown.
-
showTradeRoutePanel
public FreeColPanel showTradeRoutePanel(Unit unit)
Show a panel to select a trade route for a unit.- Parameters:
unit
- An optionalUnit
to select a trade route for.- Returns:
- The panel shown.
-
showTrainPanel
public FreeColPanel showTrainPanel()
Show the training panel.- Returns:
- The panel shown.
-
showVictoryDialog
public void showVictoryDialog(DialogHandler<java.lang.Boolean> handler)
Show the victory dialog.- Parameters:
handler
- A callback to handle the continuation decision.
-
showWarehouseDialog
public boolean showWarehouseDialog(Colony colony)
Show the warehouse dialog for a colony. Run out of ColonyPanel, so the tile is already displayed.- Parameters:
colony
- TheColony
to display.- Returns:
- The response returned by the dialog.
-
showWorkProductionPanel
public FreeColPanel showWorkProductionPanel(Unit unit)
Show the production of a unit.- Parameters:
unit
- TheUnit
to display.- Returns:
- The panel shown.
-
reloadResources
public void reloadResources()
Reloads all images managed byResourceManager
.
-
prepareShowingMainMenu
public void prepareShowingMainMenu()
Prepares showing the main menu by removing almost everything from the view.
-
-