Package net.sf.freecol.client.gui
Class SwingGUI
- java.lang.Object
-
- net.sf.freecol.client.control.FreeColClientHolder
-
- net.sf.freecol.client.gui.GUI
-
- net.sf.freecol.client.gui.SwingGUI
-
public class SwingGUI extends GUI
A wrapper providing functionality for the overall GUI using Java Swing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSwingGUI.PopupPositionA rough position to place dialogs and panels on the canvas.-
Nested classes/interfaces inherited from class net.sf.freecol.client.gui.GUI
GUI.ViewMode
-
-
Field Summary
Fields Modifier and Type Field Description private CanvascanvasThe canvas that implements much of the functionality.private static intDRAG_THRESHOLDNumber of pixels that must be moved before a goto is enabled.private java.awt.PointdragPointWhere the map was drag-clicked.private static java.util.List<java.lang.Class<? extends FreeColPanel>>EUROPE_CLASSESEuropean subpanel classes.private ImageLibraryfixedImageLibraryThe fixed/unscaled image library used by panels et al.private booleangotoStartedHas a goto operation started?private java.awt.GraphicsDevicegraphicsDeviceThe graphics device to display to.private ImageCacheimageCacheA persistent image cache.private MapControlsmapControlsThe various sorts of map controls.private MapViewermapViewerThe MapViewer instance used by canvas to paint the main map.private ImageLibraryscaledImageLibraryThe scaled image library used by the map.private TileViewertileViewerThis is the TileViewer instance used for tiles in panels.private WidgetswidgetsThe widgets wrapper that handles specific panels and dialogs.
-
Constructor Summary
Constructors Constructor Description SwingGUI(FreeColClient freeColClient)Create the GUI.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateGotoPath()Start/stop the goto path display.private voidanimate(Animation a, javax.swing.JLabel unitLabel)Perform a single animation.voidanimateUnitAttack(Unit attacker, Unit defender, Tile attackerTile, Tile defenderTile, boolean success)Animate a unit attack.voidanimateUnitMove(Unit unit, Tile srcTile, Tile dstTile)Animate a unit move.private voidanimations(java.util.List<Animation> animations)Perform some animations.booleancanZoomInMap()Can the map be zoomed in? Used by: ZoomInActionbooleancanZoomInMapControls()Is the map able to zoom in further? Used by: MiniMapZoomInActionbooleancanZoomOutMap()Can the map be zoomed out? Used by: ZoomOutActionbooleancanZoomOutMapControls()Is the map able to zoom out further? Used by: MiniMapZoomOutActionprivate booleanchangeActiveUnit(Unit newUnit)Change the active unit.private voidchangeDone(boolean update)Finish a view mode change.private voidchangeMapScale(float newScale)private booleanchangeSelectedTile(Tile newTile, boolean refocus)Change the selected tile.voidchangeView()Change to end turn mode.voidchangeView(MapTransform mt)Change to map transform mode, and select a transform.voidchangeView(Tile tile)Change to terrain mode and select a tile.voidchangeView(Unit unit, boolean force)Change to move units mode, and select a unit.private booleanchangeViewMode(GUI.ViewMode newViewMode)Change the view mode.voidchangeWindowedMode()Change the windowed mode (really a toggle).voidclearGotoPath()Stop the goto path display.voidclickAt(int count, int x, int y)Handle a click on the canvas.voidcloseMainPanel()Close the main panel if present.voidcloseMenus()Close any open menus.voidclosePanel(java.lang.String panel)Close a panel.voidcloseStatusPanel()Close the status panel if present.booleanconfirm(Tile tile, StringTemplate tmpl, javax.swing.ImageIcon icon, java.lang.String okKey, java.lang.String cancelKey)General modal confirmation dialog.java.awt.image.BufferedImagecreateColonyTileImage(Tile tile, Colony colony)java.awt.image.BufferedImagecreateTileImage(Tile tile, Player player)java.awt.image.BufferedImagecreateTileImageWithBeachBorderAndItems(Tile tile)private intdetermineMainFontSizeUsingClientOptions(int dpi)private floatdetermineScaleFactorUsingClientOptions(int dpi)voiddisplayChat(java.lang.String sender, java.lang.String message, java.awt.Color color, boolean privateChat)Update with a new chat message.voiddisplayColonyTiles(java.awt.Graphics2D g2d, Tile[][] tiles, Colony colony)Display the ColonyTiles of a Colony.voiddisplayObject(FreeColObject fco)Show the appropriate panel for an object.voiddisplayStartChat(java.lang.String sender, java.lang.String message, boolean privateChat)A chat message was received during the pre-game setup.voidenableMapControls(boolean enable)Enable the map controls.UnitgetActiveUnit()Get the active unit.protected <T> TgetChoice(Tile tile, StringTemplate tmpl, javax.swing.ImageIcon icon, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)General modal choice dialog.private java.awt.PointgetDragPoint()Gets the point at which the map was clicked for a drag.ImageLibrarygetFixedImageLibrary()Get the fixed image library for use on panels.TilegetFocus()Get the current focus tile.java.lang.StringgetInput(Tile tile, StringTemplate tmpl, java.lang.String defaultValue, java.lang.String okKey, java.lang.String cancelKey)General modal string input dialog.private floatgetMapScale()Get the map scale.java.awt.DimensiongetMapViewDimension()private SwingGUI.PopupPositiongetPopupPosition(Tile tile)Get a rough position to place a dialog given a tile which we wish to remain visible.ImageLibrarygetScaledImageLibrary()Get the scaled image library for use on the map.DirectiongetScrollDirection(int x, int y, int scrollSpace, boolean ignoreTop)Work out what direction to scroll the map if a coordinate is close to an edge.TilegetSelectedTile()Get the selected tile.GUI.ViewModegetViewMode()Get the current view mode.voidinstallLookAndFeel(java.lang.String fontName)Swing system and look-and-feel initialization.voidinvokeNowOrLater(java.lang.Runnable runnable)Run in the EDT, either immediately if in it or later when it wakes up.voidinvokeNowOrWait(java.lang.Runnable runnable)Run in the EDT, either immediately or wait for it.booleanisClientOptionsDialogShowing()Checks if a client options dialog is present.booleanisDrag(int x, int y)Is mouse movement differnce above the drag threshold?booleanisGotoStarted()Check if the user has GoTo mode enabled.booleanisPanelShowing()Is another panel being displayed.booleanisWindowed()Is this GUI in windowed mode? Used by: DragListener for a nasty workaround that should go awayvoidminiMapToggleFogOfWarControls()Toggle the fog of war control.voidminiMapToggleViewControls()Toggle the view control.voidpaintImmediately()Paint the whole canvas now.voidperformGoto(int x, int y)Perform an immediate goto to a point on the map.voidperformGoto(Tile tile)Perform an immediate goto to a tile with the active unit.voidprepareDrag(int x, int y)Prepare a drag from the given coordinates.voidprepareResources()voidprepareShowingMainMenu()Prepares showing the main menu by removing almost everything from the view.private java.util.List<javax.swing.JLabel>prepareUnitLabelsForAnimation(java.util.List<Animation> animations)voidquitGUI()Quit the GUI.voidreconnectGUI(Unit active, Tile tile)Reset the GUI on reconnect.voidrefresh()Refresh the whole GUI.voidrefreshGuiUsingClientOptions()Refreshes the GUI with settings from the client options.voidrefreshPlayersTable()Refresh the players table in the StartGamePanel.voidrefreshTile(Tile tile)Schedule a tile to be repainted.private voidrefreshTilesForUnit(Unit unit, Tile srcTile, Tile dstTile)Refreshes and repaints the unit and tiles.private voidreleaseUnitOutForAnimation(Unit unit, javax.swing.JLabel unitLabel)voidreloadResources()Reloads all images managed byResourceManager.voidremoveComponent(java.awt.Component component)Remove a component from the GUI.voidremoveDialog(FreeColDialog<?> fcd)Remove a dialog from the GUI.voidremoveInGameComponents()Remove all in-game components (i.e.voidremoveTradeRoutePanel(FreeColPanel panel)Remove a trade route panel and associated input on an associated TradeRouteInputPanel.voidrepaint()Repaints the entire screen, but uses image caches to avoid unnecessary painting of the map.private voidresetMapZoom()Reset the map zoom and refresh the canvas.voidrestoreSavedSize(java.awt.Component comp, java.awt.Dimension size)Set dialog preferred size to saved size or to the givenDimensionif no saved size was found.booleanscrollMap(Direction direction)Scroll the map in a given direction.private voidsetDragPoint(int x, int y)Sets the point at which the map was clicked for a drag.voidsetFocus(Tile tileToFocus)Set the current focus tile.voidsetUnitPath(PathNode path)Set the path for the active unit.FreeColPanelshowAboutPanel()Show the AboutPanel.FreeColPanelshowBuildQueuePanel(Colony colony)Show the build queue for a colony.voidshowCaptureGoodsDialog(Unit unit, java.util.List<Goods> gl, DialogHandler<java.util.List<Goods>> handler)Show the dialog to select captured goods.FreeColPanelshowChatPanel()Show the chat panel.voidshowChooseFoundingFatherDialog(java.util.List<FoundingFather> ffs, DialogHandler<FoundingFather> handler)Show the founding father choice panel.voidshowClientOptionsDialog()Show the client options dialog.FreeColPanelshowColonyPanel(Colony colony, Unit unit)Show the colony panelFreeColPanelshowColopediaPanel(java.lang.String nodeId)Show a colopedia panel.FreeColPanelshowColorChooserPanel(java.awt.event.ActionListener al)Show a color chooser panel.FreeColPanelshowCompactLabourReport()Show the compact labour report panel.FreeColPanelshowCompactLabourReport(LabourData.UnitData unitData)Show the compact labour report for the specified unit data.java.util.List<java.lang.String>showConfirmDeclarationDialog()Confirm declaration of independence.voidshowDeclarationPanel(java.lang.Runnable afterClosing)Show the declaration panel with the declaration of independence and an animated signature.OptionGroupshowDifficultyDialog(Specification spec, OptionGroup group, boolean editable)Show a dialog for a difficulty option group.voidshowDumpCargoDialog(Unit unit, DialogHandler<java.util.List<Goods>> handler)Show a dialog to choose what goods to dump.booleanshowEditOptionDialog(Option option)Show a dialog for editing an individual option.IndianSettlementshowEditSettlementDialog(IndianSettlement is)Show a dialog for editing a settlmeent.voidshowEmigrationDialog(Player player, boolean fountainOfYouth, DialogHandler<java.lang.Integer> handler)Show a dialog to handle emigration.voidshowEndTurnDialog(java.util.List<Unit> units, DialogHandler<java.lang.Boolean> handler)Show a dialog for the end of turn.FreeColPanelshowErrorPanel(java.lang.String message, java.lang.Runnable callback)Show an error panel.FreeColPanelshowEuropePanel()Show the Europe panel.FreeColPanelshowEventPanel(java.lang.String header, java.lang.String image, java.lang.String footer)Show an event panel.FreeColPanelshowFindSettlementPanel()Show the FindSettlement panel.voidshowFirstContactDialog(Player player, Player other, Tile tile, int settlementCount, DialogHandler<java.lang.Boolean> handler)Show a first contact dialog.OptionGroupshowGameOptionsDialog(boolean editable)Show the Game options dialog.FreeColPanelshowHighScoresPanel(java.lang.String messageId, java.util.List<HighScore> scores)Show the high scores panel.FreeColPanelshowIndianSettlementPanel(IndianSettlement is)Show a panel for a native settlement.FreeColPanelshowInformationPanel(FreeColObject displayObject, StringTemplate template)Show an information message.java.io.FileshowLoadDialog(java.io.File directory, java.lang.String extension)Show a dialog where the user may choose a file.LoadingSavegameInfoshowLoadingSavegameDialog(boolean publicServer, boolean singlePlayer)Show the LoadingSavegameDialog.FreeColPanelshowLogFilePanel()Show the log file panel.FreeColPanelshowMainPanel(java.lang.String userMsg)Show the main panel.voidshowMainTitle()Complete reset back to the main panel.OptionGroupshowMapGeneratorOptionsDialog(boolean editable)Show the map generator options.java.awt.DimensionshowMapSizeDialog()Show the map size dialog.FreeColPanelshowModelMessages(java.util.List<ModelMessage> modelMessages)Show model messages.voidshowMonarchDialog(Monarch.MonarchAction action, StringTemplate template, java.lang.String monarchKey, DialogHandler<java.lang.Boolean> handler)Show the monarch dialog.voidshowNamingDialog(StringTemplate template, java.lang.String defaultName, Unit unit, DialogHandler<java.lang.String> handler)Show the naming dialog.voidshowNativeDemandDialog(Unit unit, Colony colony, GoodsType type, int amount, DialogHandler<java.lang.Boolean> handler)Show the native demand dialog.DiplomaticTradeshowNegotiationDialog(FreeColGameObject our, FreeColGameObject other, DiplomaticTrade agreement, StringTemplate comment)Show the negotiation dialog.FreeColPanelshowNewPanel(Specification spec)Show the NewPanel.voidshowOpeningVideo(java.lang.String userMsg, java.lang.Runnable callback)Shows theVideoPanel.ParametersshowParametersDialog()Show the parameter choice dialog.voidshowPopupMenu(javax.swing.JPopupMenu menu, int x, int y)Display a popup menu.booleanshowPreCombatDialog(Unit attacker, FreeColGameObject defender, Tile tile)Show the pre-combat dialog.FreeColPanelshowPurchasePanel()Displays the purchase panel.FreeColPanelshowRecruitPanel()Displays the recruit panel.FreeColPanelshowReportCargoPanel()Show the Cargo Report.FreeColPanelshowReportColonyPanel()Show the Colony Report.FreeColPanelshowReportContinentalCongressPanel()Show the Continental Congress Report.FreeColPanelshowReportEducationPanel()Show the Education Report.FreeColPanelshowReportExplorationPanel()Show the Exploration Report.FreeColPanelshowReportForeignAffairPanel()Show the Foreign Affairs Report.FreeColPanelshowReportHistoryPanel()Show the History Report.FreeColPanelshowReportIndianPanel()Show the Native Affairs Report.FreeColPanelshowReportLabourDetailPanel(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.FreeColPanelshowReportLabourPanel()Show the Labour Report.FreeColPanelshowReportMilitaryPanel()Show the Military Report.FreeColPanelshowReportNavalPanel()Show the Naval Report.FreeColPanelshowReportProductionPanel()Show the Production Report.FreeColPanelshowReportReligiousPanel()Show the Religion Report.FreeColPanelshowReportRequirementsPanel()Show the Requirements Report.FreeColPanelshowReportTradePanel()Show the Trade Report.FreeColPanelshowReportTurnPanel(java.util.List<ModelMessage> messages)Show the Turn Report.java.lang.StringshowRiverStyleDialog(java.util.List<java.lang.String> styles)Show the river style dialog.java.io.FileshowSaveDialog(java.io.File directory, java.lang.String defaultName)Show the save dialog.java.awt.DimensionshowScaleMapSizeDialog()Show the map scale dialog.intshowSelectAmountDialog(GoodsType goodsType, int available, int defaultAmount, boolean needToPay)Show a dialog allowing selecting an amount of goods.LocationshowSelectDestinationDialog(Unit unit)Show a dialog allowing the user to select a destination for a given unit.intshowSelectTributeAmountDialog(StringTemplate question, int maximum)Show the select-tribute-amount dialog.FreeColPanelshowServerListPanel(java.util.List<ServerInfo> serverList)Show theServerListPanel.FreeColPanelshowStartGamePanel(Game game, Player player, boolean singlePlayerMode)Show the StartGamePanel.FreeColPanelshowStatisticsPanel(java.util.Map<java.lang.String,java.lang.String> serverStats, java.util.Map<java.lang.String,java.lang.String> clientStats)Show the statistics panel.FreeColPanelshowStatusPanel(java.lang.String message)Shows a status message which goes away when a new component is added.FreeColPanelshowTilePanel(Tile tile)Show the tile panel for a given tile.voidshowTilePopup(Tile tile)Shows a tile popup for a given tile.FreeColPanelshowTradeRouteInputPanel(TradeRoute newRoute)Show the trade route input panel for a given trade route.FreeColPanelshowTradeRoutePanel(Unit unit)Show a panel to select a trade route for a unit.FreeColPanelshowTrainPanel()Show the training panel.voidshowVictoryDialog(DialogHandler<java.lang.Boolean> handler)Show the victory dialog.booleanshowWarehouseDialog(Colony colony)Show the warehouse dialog for a colony.FreeColPanelshowWorkProductionPanel(Unit unit)Show the production of a unit.private voidstartGoto()Starts a goto operation.voidstartGUI(java.awt.Dimension desiredWindowSize)Starts the GUI by creating and displaying the GUI-objects.voidstartMapEditorGUI()Start the GUI for the map editor.private PathNodestopGoto()Stops any ongoing goto operation.TiletileAt(int x, int y)Get the tile at given coordinate.voidtraverseGotoPath()Send the active unit along the current goto path as far as possible.voidupdateEuropeanSubpanels()Update all panels derived from the EuropePanel.voidupdateGoto(int x, int y, boolean start)Update the goto path to a new position on the map.private voidupdateGotoTile(Tile tile)Update the current goto to a given tile.voidupdateMapControls()Update the map controls, including the InfoPanel according to the view mode.voidupdateMenuBar()Update the menu bar.private voidupdateUnitPath()Update the path for the active unit.voidzoomInMap()Zoom the map in.voidzoomInMapControls()Zoom in the map controls.voidzoomOutMap()Zoom the map out.voidzoomOutMapControls()Zoom out the map controls.-
Methods inherited from class net.sf.freecol.client.gui.GUI
confirm, confirm, confirm, confirm, confirm, confirmAbandonEducation, confirmClearTradeRoute, confirmEuropeanTribute, confirmHostileAction, confirmLeaveColony, confirmNativeTribute, confirmPreCombat, confirmStopGame, getArmedUnitSettlementChoice, getBoycottChoice, getBuyChoice, getChoice, getChoice, getChoice, getClaimChoice, getIndianSettlementTradeChoice, getMissionaryChoice, getNewColonyName, getScoutForeignColonyChoice, getScoutIndianSettlementChoice, getSellChoice, getSoundMixerLabelText, playSound, showDifficultyDialog, showErrorPanel, showErrorPanel, showErrorPanel, showErrorPanel, showInformationPanel, showInformationPanel, showInformationPanel, showLoadSaveFileDialog, showNewPanel
-
Methods inherited from class net.sf.freecol.client.control.FreeColClientHolder
askServer, currentPlayerIsMyPlayer, getClientOptions, getConnectController, getFreeColClient, getFreeColServer, getGame, getGUI, getMap, getMyPlayer, getSpecification, igc, pgc
-
-
-
-
Field Detail
-
EUROPE_CLASSES
private static final java.util.List<java.lang.Class<? extends FreeColPanel>> EUROPE_CLASSES
European subpanel classes.
-
DRAG_THRESHOLD
private static final int DRAG_THRESHOLD
Number of pixels that must be moved before a goto is enabled.- See Also:
- Constant Field Values
-
graphicsDevice
private final java.awt.GraphicsDevice graphicsDevice
The graphics device to display to.
-
imageCache
private final ImageCache imageCache
A persistent image cache.
-
fixedImageLibrary
private ImageLibrary fixedImageLibrary
The fixed/unscaled image library used by panels et al.
-
scaledImageLibrary
private ImageLibrary scaledImageLibrary
The scaled image library used by the map.
-
tileViewer
private TileViewer tileViewer
This is the TileViewer instance used for tiles in panels. It uses the fixed ImageLibrary.
-
mapViewer
private MapViewer mapViewer
The MapViewer instance used by canvas to paint the main map. This does need to be scaled.
-
mapControls
private MapControls mapControls
The various sorts of map controls.
-
canvas
private Canvas canvas
The canvas that implements much of the functionality.
-
widgets
private Widgets widgets
The widgets wrapper that handles specific panels and dialogs.
-
dragPoint
private java.awt.Point dragPoint
Where the map was drag-clicked.
-
gotoStarted
private boolean gotoStarted
Has a goto operation started?
-
-
Constructor Detail
-
SwingGUI
public SwingGUI(FreeColClient freeColClient)
Create the GUI.- Parameters:
freeColClient- TheFreeColClientfor the game.
-
-
Method Detail
-
animate
private void animate(Animation a, javax.swing.JLabel unitLabel)
Perform a single animation.- Parameters:
a- TheAnimationto perform.unitLabel- The unit label to animate.
-
animations
private void animations(java.util.List<Animation> animations)
Perform some animations.- Parameters:
animations- TheAnimations to perform.
-
releaseUnitOutForAnimation
private void releaseUnitOutForAnimation(Unit unit, javax.swing.JLabel unitLabel)
-
prepareUnitLabelsForAnimation
private java.util.List<javax.swing.JLabel> prepareUnitLabelsForAnimation(java.util.List<Animation> animations)
-
getDragPoint
private java.awt.Point getDragPoint()
Gets the point at which the map was clicked for a drag.- Returns:
- The Point where the mouse was initially clicked.
-
setDragPoint
private void setDragPoint(int x, int y)Sets the point at which the map was clicked for a drag.- Parameters:
x- The mouse x position.y- The mouse y position.
-
isDrag
public boolean isDrag(int x, int y)Is mouse movement differnce above the drag threshold?- Parameters:
x- The new mouse x position.y- The new mouse y position.- Returns:
- True if the mouse has been dragged.
-
changeViewMode
private boolean changeViewMode(GUI.ViewMode newViewMode)
Change the view mode. Always stop the blinking cursor if leaving MOVE_UNITS mode, but leave turning it on to changeActiveUnit, as there is no point enabling it if the active unit is null.- Parameters:
newViewMode- The newViewMode.- Returns:
- True if the view mode changed.
-
changeActiveUnit
private boolean changeActiveUnit(Unit newUnit)
Change the active unit. If the unit changes, cancel any current gotos.- Parameters:
newUnit- The new activeUnit.- Returns:
- True if the active unit changed.
-
changeSelectedTile
private boolean changeSelectedTile(Tile newTile, boolean refocus)
Change the selected tile. Also moves the focus tile to the selected tile if it differs and either is not on screen, or with the focus override. When the selected tile moves, the cursor needs to be redrawn, so a refresh of the old (if any) and new (if any) tile occurs.- Parameters:
newTile- The newTileto select.refocus- If true force a refocus on all tile changes.- Returns:
- True if the tile was changed.
-
changeDone
private void changeDone(boolean update)
Finish a view mode change.- Parameters:
update- Update the map controls if true.
-
getMapScale
private final float getMapScale()
Get the map scale. Used by:- Returns:
- The scale for the (rescalable) map.
-
getPopupPosition
private SwingGUI.PopupPosition getPopupPosition(Tile tile)
Get a rough position to place a dialog given a tile which we wish to remain visible.- Parameters:
tile- TheTileto expose.- Returns:
- A suitable
PopupPosition.
-
updateUnitPath
private void updateUnitPath()
Update the path for the active unit.
-
startGoto
private void startGoto()
Starts a goto operation.
-
stopGoto
private PathNode stopGoto()
Stops any ongoing goto operation.- Returns:
- The old goto path if any.
-
updateGotoTile
private void updateGotoTile(Tile tile)
Update the current goto to a given tile.- Parameters:
tile- The new gotoTile.
-
paintImmediately
public void paintImmediately()
Paint the whole canvas now.
-
refreshTile
public void refreshTile(Tile tile)
Schedule a tile to be repainted.- Overrides:
refreshTilein classGUI- Parameters:
tile- Thetileto paint.
-
resetMapZoom
private void resetMapZoom()
Reset the map zoom and refresh the canvas.
-
getFixedImageLibrary
public ImageLibrary getFixedImageLibrary()
Get the fixed image library for use on panels. Used by: ColonyPanel, ConstructionPanel, InfoPanel, certain UnitLabels.- Overrides:
getFixedImageLibraryin classGUI- Returns:
- Null here, real implementations will override.
-
getScaledImageLibrary
public ImageLibrary getScaledImageLibrary()
Get the scaled image library for use on the map.- Overrides:
getScaledImageLibraryin classGUI- 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- Overrides:
isWindowedin classGUI- 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.- Overrides:
invokeNowOrLaterin classGUI- Parameters:
runnable- ARunnableto run.
-
invokeNowOrWait
public void invokeNowOrWait(java.lang.Runnable runnable)
Run in the EDT, either immediately or wait for it.- Overrides:
invokeNowOrWaitin classGUI- Parameters:
runnable- ARunnableto run.
-
changeWindowedMode
public void changeWindowedMode()
Change the windowed mode (really a toggle). Used by: ChangeWindowedModeAction- Overrides:
changeWindowedModein classGUI
-
installLookAndFeel
public void installLookAndFeel(java.lang.String fontName) throws FreeColExceptionSwing system and look-and-feel initialization. Used by: FreeColClient- Overrides:
installLookAndFeelin classGUI- 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- Overrides:
reconnectGUIin classGUI- Parameters:
active- An optional activeUnit.tile- An optionalTileto 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- Overrides:
removeInGameComponentsin classGUI
-
showOpeningVideo
public void showOpeningVideo(java.lang.String userMsg, java.lang.Runnable callback)Shows theVideoPanel. Used by: FreeColClient- Overrides:
showOpeningVideoin classGUI- Parameters:
userMsg- An optional user message.callback- ARunnableto 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
-
getMapViewDimension
public java.awt.Dimension getMapViewDimension()
- Overrides:
getMapViewDimensionin classGUI
-
startMapEditorGUI
public void startMapEditorGUI()
Start the GUI for the map editor. Used by: NewPanel- Overrides:
startMapEditorGUIin classGUI
-
animateUnitAttack
public void animateUnitAttack(Unit attacker, Unit defender, Tile attackerTile, Tile defenderTile, boolean success)
Animate a unit attack. Used by: client InGameController- Overrides:
animateUnitAttackin classGUI- Parameters:
attacker- The attackingUnit.defender- The defendingUnit.attackerTile- TheTileto show the attacker on.defenderTile- TheTileto 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- Overrides:
animateUnitMovein classGUI- Parameters:
unit- TheUnitthat is moving.srcTile- TheTilethe unit starts at.dstTile- TheTilethe unit moves to.
-
refreshTilesForUnit
private void refreshTilesForUnit(Unit unit, Tile srcTile, Tile dstTile)
Refreshes and repaints the unit and tiles.- Parameters:
unit- TheUnitthat may have moved, and which we should use the line-of-sight for invalidating tiles.srcTile- The source for the unit.dstTile- The destination tile for the unit.
-
confirm
public boolean confirm(Tile tile, StringTemplate tmpl, javax.swing.ImageIcon icon, java.lang.String okKey, java.lang.String cancelKey)
General modal confirmation dialog.- Overrides:
confirmin classGUI- Parameters:
tile- An optionalTileto expose.tmpl- TheStringTemplateexplaining the choice.icon- AnImageIconto 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 tmpl, javax.swing.ImageIcon icon, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
General modal choice dialog.- Overrides:
getChoicein classGUI- Type Parameters:
T- The choice type.- Parameters:
tile- An optionalTileto expose.tmpl- AStringTemplateexplaining the choice.icon- An optionalImageIconto display in dialog.cancelKey- A key for the message on the "cancel" button.choices- A list aChoiceItems to choose from.- Returns:
- The selected value of the selected
ChoiceItem, or null if cancelled.
-
getInput
public java.lang.String getInput(Tile tile, StringTemplate tmpl, java.lang.String defaultValue, java.lang.String okKey, java.lang.String cancelKey)
General modal string input dialog.- Overrides:
getInputin classGUI- Parameters:
tile- An optionalTileto expose.tmpl- AStringTemplateexplaining 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
-
setFocus
public void setFocus(Tile tileToFocus)
Set the current focus tile. Used by: CanvasMapEditorMouseListener, CenterAction, FindSettlementPanel, InfoPanel, MiniMap.focus, MapEditorController, SelectDestinationDialog.recenter
-
canZoomInMapControls
public boolean canZoomInMapControls()
Is the map able to zoom in further? Used by: MiniMapZoomInAction- Overrides:
canZoomInMapControlsin classGUI- Returns:
- True if the map can zoom in.
-
canZoomOutMapControls
public boolean canZoomOutMapControls()
Is the map able to zoom out further? Used by: MiniMapZoomOutAction- Overrides:
canZoomOutMapControlsin classGUI- Returns:
- True if the map can zoom out.
-
enableMapControls
public void enableMapControls(boolean enable)
Enable the map controls. Used by: MapControlsAction.- Overrides:
enableMapControlsin classGUI- Parameters:
enable- If true then enable.
-
miniMapToggleViewControls
public void miniMapToggleViewControls()
Toggle the view control. Used by: MiniMapToggleFogOfWarAction- Overrides:
miniMapToggleViewControlsin classGUI
-
miniMapToggleFogOfWarControls
public void miniMapToggleFogOfWarControls()
Toggle the fog of war control. Used by: MiniMapToggleFogOfWarAction- Overrides:
miniMapToggleFogOfWarControlsin classGUI
-
updateMapControls
public void updateMapControls()
Update the map controls, including the InfoPanel according to the view mode. Used by: client InGameController.updateGUI, MapEditorController- Overrides:
updateMapControlsin classGUI
-
zoomInMapControls
public void zoomInMapControls()
Zoom in the map controls. Used by: MiniMapZoomInAction- Overrides:
zoomInMapControlsin classGUI
-
zoomOutMapControls
public void zoomOutMapControls()
Zoom out the map controls. Used by: MiniMapZoomOutAction- Overrides:
zoomOutMapControlsin classGUI
-
closeMenus
public void closeMenus()
Close any open menus. Used by: FreeColClient.skipTurns, client InGameController.{endTurn,setCurrentPlayer} MapEditorController, PreGameController- Overrides:
closeMenusin classGUI
-
updateMenuBar
public void updateMenuBar()
Update the menu bar. Used by: InGameController.updateGUI, MapEditorController, NewEmptyMapAction- Overrides:
updateMenuBarin classGUI
-
showPopupMenu
public void showPopupMenu(javax.swing.JPopupMenu menu, int x, int y)Display a popup menu. Used by: ColonyPanel, DragListener- Overrides:
showPopupMenuin classGUI- Parameters:
menu- TheJPopupMenuto display.x- The menu x coordinate.y- The menu y coordinate.
-
setUnitPath
public void setUnitPath(PathNode path)
Set the path for the active unit. Used by: TilePopup- Overrides:
setUnitPathin classGUI- Parameters:
path- The new unit path.
-
activateGotoPath
public void activateGotoPath()
Start/stop the goto path display. Used by: GotoTileAction- Overrides:
activateGotoPathin classGUI
-
clearGotoPath
public void clearGotoPath()
Stop the goto path display. Used by: client InGameController.askClearGotoOrders- Overrides:
clearGotoPathin classGUI
-
isGotoStarted
public boolean isGotoStarted()
Check if the user has GoTo mode enabled. Used by: CanvasMouseListener- Overrides:
isGotoStartedin classGUI- 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- Overrides:
performGotoin classGUI- Parameters:
tile- TheTileto go to.
-
performGoto
public void performGoto(int x, int y)Perform an immediate goto to a point on the map. Used by: CanvasMouseListener- Overrides:
performGotoin classGUI- 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- Overrides:
traverseGotoPathin classGUI
-
updateGoto
public void updateGoto(int x, int y, boolean start)Update the goto path to a new position on the map. Used by: CanvasMouseMotionListener- Overrides:
updateGotoin classGUI- 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- Overrides:
prepareDragin classGUI- Parameters:
x- Drag x coordinate (pixels).y- Drag x coordinate (pixels).
-
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.- Overrides:
getScrollDirectionin classGUI- Parameters:
x- The x coordinate.y- The y coordinate.scrollSpace- The clearance from the relevant edgeignoreTop- If the top should be ignored- Returns:
- The
Directionto scroll, or null if not.
-
scrollMap
public boolean scrollMap(Direction direction)
Scroll the map in a given direction.
-
createTileImageWithBeachBorderAndItems
public java.awt.image.BufferedImage createTileImageWithBeachBorderAndItems(Tile tile)
- Overrides:
createTileImageWithBeachBorderAndItemsin classGUI
-
createTileImage
public java.awt.image.BufferedImage createTileImage(Tile tile, Player player)
- Overrides:
createTileImagein classGUI
-
createColonyTileImage
public java.awt.image.BufferedImage createColonyTileImage(Tile tile, Colony colony)
- Overrides:
createColonyTileImagein classGUI
-
displayColonyTiles
public void displayColonyTiles(java.awt.Graphics2D g2d, Tile[][] tiles, Colony colony)Display the ColonyTiles of a Colony. Used by: ColonyPanel.TilesPanel- Overrides:
displayColonyTilesin classGUI- Parameters:
g2d- AGraphics2Dto draw to.tiles- TheTiles to display.colony- The enclosingColony.
-
getViewMode
public GUI.ViewMode getViewMode()
Get the current view mode. Used by: MoveAction, ToggleViewModeAction- Overrides:
getViewModein classGUI- Returns:
- One of the view mode constants, or negative on error.
-
getActiveUnit
public Unit getActiveUnit()
Get the active unit. Used by: many- Overrides:
getActiveUnitin classGUI- Returns:
- The current active
Unit.
-
getSelectedTile
public Tile getSelectedTile()
Get the selected tile. Used by: MoveAction, TilePopupAction, ToggleViewModeAction- Overrides:
getSelectedTilein classGUI- 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}- Overrides:
changeViewin classGUI- Parameters:
tile- TheTileto 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- Overrides:
changeViewin classGUI- Parameters:
unit- TheUnitto 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 mt)
Change to map transform mode, and select a transform. Used by: MapEditorController- Overrides:
changeViewin classGUI- Parameters:
mt- TheMapTransformto select.
-
changeView
public void changeView()
Change to end turn mode. Used by: client InGameController.updateActiveUnit- Overrides:
changeViewin classGUI
-
canZoomInMap
public boolean canZoomInMap()
Can the map be zoomed in? Used by: ZoomInAction- Overrides:
canZoomInMapin classGUI- Returns:
- True if the map can zoom in.
-
canZoomOutMap
public boolean canZoomOutMap()
Can the map be zoomed out? Used by: ZoomOutAction- Overrides:
canZoomOutMapin classGUI- 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- Overrides:
zoomOutMapin classGUI
-
changeMapScale
private void changeMapScale(float newScale)
-
reloadResources
public void reloadResources()
Reloads all images managed byResourceManager.- Overrides:
reloadResourcesin classGUI
-
prepareResources
public void prepareResources()
-
clickAt
public void clickAt(int count, int x, int y)Handle a click on the canvas. Used by: CanvasMouseListener
-
closePanel
public void closePanel(java.lang.String panel)
Close a panel. Used by: client InGameController.closehandler- Overrides:
closePanelin classGUI- Parameters:
panel- The identifier for the panel to close.
-
closeMainPanel
public void closeMainPanel()
Close the main panel if present. Used by: MapEditorController, PreGameController- Overrides:
closeMainPanelin classGUI
-
closeStatusPanel
public void closeStatusPanel()
Close the status panel if present. Used by: FreeColClient, MapEditorController, client InGameController, PreGameController- Overrides:
closeStatusPanelin classGUI
-
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}- Overrides:
displayChatin classGUI- 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.- Overrides:
displayObjectin classGUI- Parameters:
fco- TheFreeColObjectto 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- Overrides:
displayStartChatin classGUI- 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- Overrides:
isClientOptionsDialogShowingin classGUI- Returns:
- True if the client options are showing.
-
isPanelShowing
public boolean isPanelShowing()
Is another panel being displayed. Used by: many Actions- Overrides:
isPanelShowingin classGUI- 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)andGUI.repaint()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.- Overrides:
repaintin classGUI- See Also:
GUI.refresh()
-
refreshPlayersTable
public void refreshPlayersTable()
Refresh the players table in the StartGamePanel. Used by: SetNationMessage.clientHandler- Overrides:
refreshPlayersTablein classGUI
-
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?- Overrides:
removeComponentin classGUI- Parameters:
component- TheComponentto remove.
-
removeDialog
public void removeDialog(FreeColDialog<?> fcd)
Remove a dialog from the GUI. Used by: FreeColDialog.removeNotify- Overrides:
removeDialogin classGUI- Parameters:
fcd- TheFreeColDialogto remove.
-
removeTradeRoutePanel
public void removeTradeRoutePanel(FreeColPanel panel)
Remove a trade route panel and associated input on an associated TradeRouteInputPanel. Used by: TradeRoutePanel- Overrides:
removeTradeRoutePanelin classGUI- Parameters:
panel- TheFreeColPanelto remove.
-
restoreSavedSize
public void restoreSavedSize(java.awt.Component comp, java.awt.Dimension size)Set dialog preferred size to saved size or to the givenDimensionif 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- Overrides:
restoreSavedSizein classGUI- Parameters:
comp- TheComponentto use.size- TheDimensionto use as default.
-
showTilePopup
public void showTilePopup(Tile tile)
Shows a tile popup for a given tile.- Overrides:
showTilePopupin classGUI- Parameters:
tile- TheTilewhere the popup occurred.
-
tileAt
public Tile tileAt(int x, int y)
Get the tile at given coordinate.
-
updateEuropeanSubpanels
public void updateEuropeanSubpanels()
Update all panels derived from the EuropePanel. Used by: NewUnitPanel, RecruitUnitPanel- Overrides:
updateEuropeanSubpanelsin classGUI
-
showAboutPanel
public FreeColPanel showAboutPanel()
Show the AboutPanel.- Overrides:
showAboutPanelin classGUI- Returns:
- The panel shown.
-
showBuildQueuePanel
public FreeColPanel showBuildQueuePanel(Colony colony)
Show the build queue for a colony.- Overrides:
showBuildQueuePanelin classGUI- Parameters:
colony- TheColonyto 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.- Overrides:
showCaptureGoodsDialogin classGUI- Parameters:
unit- TheUnitcapturing goods.gl- The list ofGoodsto choose from.handler- ADialogHandlerfor the dialog response.
-
showChatPanel
public FreeColPanel showChatPanel()
Show the chat panel.- Overrides:
showChatPanelin classGUI- Returns:
- The panel shown.
-
showChooseFoundingFatherDialog
public void showChooseFoundingFatherDialog(java.util.List<FoundingFather> ffs, DialogHandler<FoundingFather> handler)
Show the founding father choice panel.- Overrides:
showChooseFoundingFatherDialogin classGUI- Parameters:
ffs- The list ofFoundingFathers to choose from.handler- The callback to pass the choice to.
-
showClientOptionsDialog
public void showClientOptionsDialog()
Show the client options dialog.- Overrides:
showClientOptionsDialogin classGUI
-
refreshGuiUsingClientOptions
public void refreshGuiUsingClientOptions()
Refreshes the GUI with settings from the client options.- Overrides:
refreshGuiUsingClientOptionsin classGUI
-
determineMainFontSizeUsingClientOptions
private int determineMainFontSizeUsingClientOptions(int dpi)
-
determineScaleFactorUsingClientOptions
private float determineScaleFactorUsingClientOptions(int dpi)
-
showColonyPanel
public FreeColPanel showColonyPanel(Colony colony, Unit unit)
Show the colony panel- Overrides:
showColonyPanelin classGUI- Parameters:
colony- TheColonyto display.unit- An optionalUnitto select within the panel.- Returns:
- The panel shown.
-
showColopediaPanel
public FreeColPanel showColopediaPanel(java.lang.String nodeId)
Show a colopedia panel.- Overrides:
showColopediaPanelin classGUI- 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.- Overrides:
showColorChooserPanelin classGUI- Parameters:
al- AnActionListenerto handle panel button presses.- Returns:
- The panel shown.
-
showCompactLabourReport
public FreeColPanel showCompactLabourReport()
Show the compact labour report panel.- Overrides:
showCompactLabourReportin classGUI- Returns:
- The panel shown.
-
showCompactLabourReport
public FreeColPanel showCompactLabourReport(LabourData.UnitData unitData)
Show the compact labour report for the specified unit data.- Overrides:
showCompactLabourReportin classGUI- Parameters:
unitData- TheUnitDatato display.- Returns:
- The panel shown.
-
showConfirmDeclarationDialog
public java.util.List<java.lang.String> showConfirmDeclarationDialog()
Confirm declaration of independence.- Overrides:
showConfirmDeclarationDialogin classGUI- 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.- Overrides:
showDeclarationPanelin classGUI- 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.- Overrides:
showDifficultyDialogin classGUI- Parameters:
spec- The enclosingSpecification.group- TheOptionGroupto 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.- Overrides:
showDumpCargoDialogin classGUI- Parameters:
unit- TheUnitthat 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.- Overrides:
showEditOptionDialogin classGUI- Parameters:
option- TheOptionto edit.- Returns:
- True if the option edit was accepted.
-
showEditSettlementDialog
public IndianSettlement showEditSettlementDialog(IndianSettlement is)
Show a dialog for editing a settlmeent.- Overrides:
showEditSettlementDialogin classGUI- Parameters:
is- TheIndianSettlementto 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.- Overrides:
showEmigrationDialogin classGUI- Parameters:
player- ThePlayerwhose 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.- Overrides:
showEndTurnDialogin classGUI- Parameters:
units- A list ofUnits 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.- Overrides:
showErrorPanelin classGUI- Parameters:
message- The error message to display.callback- An optionalRunnableto run on close.- Returns:
- The panel shown.
-
showEuropePanel
public FreeColPanel showEuropePanel()
Show the Europe panel.- Overrides:
showEuropePanelin classGUI- Returns:
- The panel shown.
-
showEventPanel
public FreeColPanel showEventPanel(java.lang.String header, java.lang.String image, java.lang.String footer)
Show an event panel.- Overrides:
showEventPanelin classGUI- 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.- Overrides:
showFindSettlementPanelin classGUI- 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.- Overrides:
showFirstContactDialogin classGUI- Parameters:
player- ThePlayermaking contact.other- ThePlayerbeing contacted.tile- TheTilewhere 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.- Overrides:
showGameOptionsDialogin classGUI- 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.- Overrides:
showHighScoresPanelin classGUI- Parameters:
messageId- The message identifier.scores- TheHighScores to display.- Returns:
- The panel shown.
-
showIndianSettlementPanel
public FreeColPanel showIndianSettlementPanel(IndianSettlement is)
Show a panel for a native settlement.- Overrides:
showIndianSettlementPanelin classGUI- Parameters:
is- TheIndianSettlementto display.- Returns:
- The panel shown.
-
showInformationPanel
public FreeColPanel showInformationPanel(FreeColObject displayObject, StringTemplate template)
Show an information message.- Overrides:
showInformationPanelin classGUI- Parameters:
displayObject- Optional object for displaying as an icon.template- TheStringTemplateto 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.- Overrides:
showLoadDialogin classGUI- 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.- Overrides:
showLoadingSavegameDialogin classGUI- Parameters:
publicServer- FIXMEsinglePlayer- FIXME- Returns:
- The
LoadingSavegameInfofrom the dialog.
-
showLogFilePanel
public FreeColPanel showLogFilePanel()
Show the log file panel.- Overrides:
showLogFilePanelin classGUI- Returns:
- The panel shown.
-
showMainPanel
public FreeColPanel showMainPanel(java.lang.String userMsg)
Show the main panel.- Overrides:
showMainPanelin classGUI- Parameters:
userMsg- An optional user message to display.- Returns:
- The panel shown.
-
showMainTitle
public void showMainTitle()
Complete reset back to the main panel.- Overrides:
showMainTitlein classGUI
-
showMapGeneratorOptionsDialog
public OptionGroup showMapGeneratorOptionsDialog(boolean editable)
Show the map generator options.- Overrides:
showMapGeneratorOptionsDialogin classGUI- Parameters:
editable- If true, allow edits.- Returns:
- The map generator
OptionGroup.
-
showMapSizeDialog
public java.awt.Dimension showMapSizeDialog()
Show the map size dialog.- Overrides:
showMapSizeDialogin classGUI- Returns:
- The selected map size as a
Dimension.
-
showModelMessages
public FreeColPanel showModelMessages(java.util.List<ModelMessage> modelMessages)
Show model messages.- Overrides:
showModelMessagesin classGUI- Parameters:
modelMessages- A list ofModelMessages 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.- Overrides:
showMonarchDialogin classGUI- 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.- Overrides:
showNamingDialogin classGUI- Parameters:
template- A message template.defaultName- The default name for the object.unit- TheUnitthat 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.- Overrides:
showNativeDemandDialogin classGUI- Parameters:
unit- The demandingUnit.colony- TheColonybeing demanded of.type- TheGoodsTypedemanded (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.- Overrides:
showNegotiationDialogin classGUI- Parameters:
our- OurFreeColGameObjectthat is negotiating.other- The otherFreeColGameObject.agreement- The currentDiplomaticTradeagreement.comment- An optionalStringTemplatecontaining a commentary message.- Returns:
- The negotiated
DiplomaticTradeagreement.
-
showNewPanel
public FreeColPanel showNewPanel(Specification spec)
Show the NewPanel.- Overrides:
showNewPanelin classGUI- Parameters:
spec- TheSpecificationto use.- Returns:
- The panel shown.
-
showParametersDialog
public Parameters showParametersDialog()
Show the parameter choice dialog.- Overrides:
showParametersDialogin classGUI- Returns:
- The chosen parameters.
-
showPreCombatDialog
public boolean showPreCombatDialog(Unit attacker, FreeColGameObject defender, Tile tile)
Show the pre-combat dialog.- Overrides:
showPreCombatDialogin classGUI- Parameters:
attacker- TheUnitthat is attacking.defender- TheFreeColObjectthat is defending.tile- TheTilewhere the attack occurs.- Returns:
- True if the player decided to attack.
-
showPurchasePanel
public FreeColPanel showPurchasePanel()
Displays the purchase panel.- Overrides:
showPurchasePanelin classGUI- Returns:
- The panel shown.
-
showRecruitPanel
public FreeColPanel showRecruitPanel()
Displays the recruit panel.- Overrides:
showRecruitPanelin classGUI- Returns:
- The panel shown.
-
showReportCargoPanel
public FreeColPanel showReportCargoPanel()
Show the Cargo Report.- Overrides:
showReportCargoPanelin classGUI- Returns:
- The panel shown.
-
showReportColonyPanel
public FreeColPanel showReportColonyPanel()
Show the Colony Report.- Overrides:
showReportColonyPanelin classGUI- Returns:
- The panel shown.
-
showReportContinentalCongressPanel
public FreeColPanel showReportContinentalCongressPanel()
Show the Continental Congress Report.- Overrides:
showReportContinentalCongressPanelin classGUI- Returns:
- The panel shown.
-
showReportEducationPanel
public FreeColPanel showReportEducationPanel()
Show the Education Report.- Overrides:
showReportEducationPanelin classGUI- Returns:
- The panel shown.
-
showReportExplorationPanel
public FreeColPanel showReportExplorationPanel()
Show the Exploration Report.- Overrides:
showReportExplorationPanelin classGUI- Returns:
- The panel shown.
-
showReportForeignAffairPanel
public FreeColPanel showReportForeignAffairPanel()
Show the Foreign Affairs Report.- Overrides:
showReportForeignAffairPanelin classGUI- Returns:
- The panel shown.
-
showReportHistoryPanel
public FreeColPanel showReportHistoryPanel()
Show the History Report.- Overrides:
showReportHistoryPanelin classGUI- Returns:
- The panel shown.
-
showReportIndianPanel
public FreeColPanel showReportIndianPanel()
Show the Native Affairs Report.- Overrides:
showReportIndianPanelin classGUI- Returns:
- The panel shown.
-
showReportLabourPanel
public FreeColPanel showReportLabourPanel()
Show the Labour Report.- Overrides:
showReportLabourPanelin classGUI- 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.- Overrides:
showReportLabourDetailPanelin classGUI- Parameters:
unitType- TheUnitTypeto display.data- The labour data.unitCount- A map of unit distribution.colonies- The list of playerColonys.- Returns:
- The panel shown.
-
showReportMilitaryPanel
public FreeColPanel showReportMilitaryPanel()
Show the Military Report.- Overrides:
showReportMilitaryPanelin classGUI- Returns:
- The panel shown.
-
showReportNavalPanel
public FreeColPanel showReportNavalPanel()
Show the Naval Report.- Overrides:
showReportNavalPanelin classGUI- Returns:
- The panel shown.
-
showReportProductionPanel
public FreeColPanel showReportProductionPanel()
Show the Production Report.- Overrides:
showReportProductionPanelin classGUI- Returns:
- The panel shown.
-
showReportReligiousPanel
public FreeColPanel showReportReligiousPanel()
Show the Religion Report.- Overrides:
showReportReligiousPanelin classGUI- Returns:
- The panel shown.
-
showReportRequirementsPanel
public FreeColPanel showReportRequirementsPanel()
Show the Requirements Report.- Overrides:
showReportRequirementsPanelin classGUI- Returns:
- The panel shown.
-
showReportTradePanel
public FreeColPanel showReportTradePanel()
Show the Trade Report.- Overrides:
showReportTradePanelin classGUI- Returns:
- The panel shown.
-
showReportTurnPanel
public FreeColPanel showReportTurnPanel(java.util.List<ModelMessage> messages)
Show the Turn Report.- Overrides:
showReportTurnPanelin classGUI- Parameters:
messages- TheModelMessages 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.- Overrides:
showRiverStyleDialogin classGUI- 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.- Overrides:
showSaveDialogin classGUI- 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.- Overrides:
showScaleMapSizeDialogin classGUI- 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.- Overrides:
showSelectAmountDialogin classGUI- Parameters:
goodsType- TheGoodsTypeto 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.- Overrides:
showSelectDestinationDialogin classGUI- Parameters:
unit- TheUnitto 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.- Overrides:
showSelectTributeAmountDialogin classGUI- Parameters:
question- aStringTemplatedescribing 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.- Overrides:
showServerListPanelin classGUI- 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.- Overrides:
showStartGamePanelin classGUI- Parameters:
game- TheGamethat is about to start.player- ThePlayerusing 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.- Overrides:
showStatisticsPanelin classGUI- 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.- Overrides:
showStatusPanelin classGUI- 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.- Overrides:
showTilePanelin classGUI- Parameters:
tile- TheTileto display.- Returns:
- The panel shown.
-
showTradeRouteInputPanel
public FreeColPanel showTradeRouteInputPanel(TradeRoute newRoute)
Show the trade route input panel for a given trade route.- Overrides:
showTradeRouteInputPanelin classGUI- Parameters:
newRoute- TheTradeRouteto display.- Returns:
- The panel shown.
-
showTradeRoutePanel
public FreeColPanel showTradeRoutePanel(Unit unit)
Show a panel to select a trade route for a unit.- Overrides:
showTradeRoutePanelin classGUI- Parameters:
unit- An optionalUnitto select a trade route for.- Returns:
- The panel shown.
-
showTrainPanel
public FreeColPanel showTrainPanel()
Show the training panel.- Overrides:
showTrainPanelin classGUI- Returns:
- The panel shown.
-
showVictoryDialog
public void showVictoryDialog(DialogHandler<java.lang.Boolean> handler)
Show the victory dialog.- Overrides:
showVictoryDialogin classGUI- 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.- Overrides:
showWarehouseDialogin classGUI- Parameters:
colony- TheColonyto display.- Returns:
- The response returned by the dialog.
-
showWorkProductionPanel
public FreeColPanel showWorkProductionPanel(Unit unit)
Show the production of a unit.- Overrides:
showWorkProductionPanelin classGUI- Parameters:
unit- TheUnitto display.- Returns:
- The panel shown.
-
prepareShowingMainMenu
public void prepareShowingMainMenu()
Description copied from class:GUIPrepares showing the main menu by removing almost everything from the view.- Overrides:
prepareShowingMainMenuin classGUI
-
-