diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index a449c6db1d7..3707b9dd494 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -187,6 +187,8 @@ AdvancedOptions.PlanetaryConditionsShowLabels.name=Planetary Conditions Show Lab AdvancedOptions.PlanetaryConditionsShowValues.name=Planetary Conditions Show Values AdvancedOptions.PlanetaryConditionsShowIndicators.name=Planetary Conditions Show Indicators AdvancedOptions.UnitToolTipSeenByResolution.name=UnitToolTip - Seen By Resolution [1=Someone,2=Team,3=Player] +AdvancedOptions.DockOnLeft.name=Dock on left side of the board +AdvancedOptions.DockMultipleOnYAxis.name=Dock multiple panels using the y axis #Board Editor BoardEditor.BridgeBuildingElevError=Bridge/Building Elevation is an offset from the surface of a hex and hence must be a positive value! @@ -771,6 +773,7 @@ ChatLounge.SearchlightToggleOff=Remove searchlight(s) ChatLounge.SearchlightToggleOn=Add searchlight(s) ChatLounge.SelectBo=Please select a bot you control from the player list. ChatLounge.SelectBotOrPlayer=Please select a bot you control or your player from the player list. +ChatLounge.map.SetupXMLfiles=Map Setup XML files ChatLounge.SPACE=SPACE ChatLounge.spaceMap=Space Map ChatLounge.TechLevel=Tech Level: @@ -848,6 +851,7 @@ ClientGUI.errorLoadingFile=Error Loading File ClientGUI.errorOpeningFileToSave=Error opening file to save! ClientGUI.errorSavingFile=Error Saving File ClientGUI.errorSelectingPlayer=Error selecting player +ClientGUI.failedToLoadAudioFile=Failed to load audio file named ClientGUI.FatalError.message=Could not initialise:\n ClientGUI.FatalError.message1=Could not initialise minimap:\n ClientGUI.FatalError.title=Fatal Error @@ -856,6 +860,8 @@ ClientGUI.FileSaveServerDialog.title=Select file to save to... ClientGUI.FileSaveServerDialog.message=Please enter the filename under which the game will be saved to in the server's savegames directory. ClientGUI.gameSaveDialogMessage=Do you want to save the game before quitting MegaMek? ClientGUI.gameSaveFirst=Save First? +ClientGUI.Hide=Hide +ClientGUI.Manual=Manual ClientGUI.MechDisplay=Mech Display ClientGUI.mechSelectorDialog=Mech Selector Dialog ClientGUI.Minimap=Minimap @@ -872,6 +878,7 @@ ClientGUI.selectMenuItem=Select ClientGUI.skinningHelpPath=docs/help/en/skinning/skinningHowTo.html ClientGUI.skinningHelpPath.title=How To: Skinning ClientGUI.StartingScenario=Starting scenario... +ClientGUI.Show=Show ClientGUI.targetMenuItem=Target ClientGUI.title=MegaMek Client ClientGUI.TransmittingData=Transmitting game data... @@ -1156,7 +1163,15 @@ CommonSettingsDialog.useSoftCenter=Use smooth transitioning when selecting units CommonSettingsDialog.useSoftCenterTip=Instead of an instant snap, the view is smoothly transitioned CommonSettingsDialog.showIPAddressesInChat=Show IP Addresses in Chat (WARNING: Security Sensitive) CommonSettingsDialog.showIPAddressesInChat.tooltip=If enabled, all server and client IP addresses will be logged in the public chat box.
Enabling this can allow information disclosure, such as private IP addresses of the server. - +CommonSettingsDialog.Main=Main +CommonSettingsDialog.Graphics=Graphics +CommonSettingsDialog.KeyBinds=Key Binds +CommonSettingsDialog.ButtonOrder=Button Order +CommonSettingsDialog.UnitDisplayOrder=Unit Display Order +CommonSettingsDialog.AutoDisplay=Auto Display +CommonSettingsDialog.Advanced=Advanced +CommonSettingsDialog.ReportPhases=Report Phases +CommonSettingsDialog.NonReportPhases=Non-Report Phases #Nag Suppression Dialog ConfirmDialog.dontBother=Do not bother me again @@ -2028,6 +2043,7 @@ MiniReportDisplay.Round=Round MiniReportDisplay.Phase=Phase MiniReportDisplay.ArrowUp=\u25B2 MiniReportDisplay.ArrowDown=\u25BC +MiniReportDisplay.SwitchLocation=switch location #Assorted Movement Phase Display Text for buttons, nags, dialogs... MovementDisplay.AbandonDialog.message=Do you want to abandon this unit? @@ -3091,11 +3107,10 @@ RandomNameDialog.lblHistoricalEthnicity.toolTipText=This will generate a random #Report Display ReportDisplay.Done=Done -ReportDisplay.Reroll=Reroll -ReportDisplay.Details=Details -ReportDisplay.Round=Round -ReportDisplay.Phase=Phase - +ReportDisplay.reportReport=Report +ReportDisplay.reportPlayerList=Player List +ReportDisplay.reportRerollInitiative=Reroll Initiative +ReportDisplay.reportRerollInitiative.tooltip=Pilot with Tactical Genius can reroll initiative in the Initiative Phase #Ruler Ruler.Close=Close Ruler.Distance=Distance: @@ -3159,6 +3174,9 @@ TriggerBPodDialog.title=Trigger ABA Pods TriggerBPodDialog.ChooseTargetDialog.message=Hex {0} contains the following targets.\n\nWhich target do you want to attack?" TriggerBPodDialog.ChooseTargetDialog.title=Choose Target +UnitDisplay.SwitchLocation=switch location +UnitDisplay.SwitchView=switch view + #Unit Editor Dialog UnitEditorDialog.avionics=Avionics UnitEditorDialog.bayCrit=%s Bay # %d diff --git a/megamek/src/megamek/client/bot/BotClient.java b/megamek/src/megamek/client/bot/BotClient.java index e9e495f1a8f..d8a960e8156 100644 --- a/megamek/src/megamek/client/bot/BotClient.java +++ b/megamek/src/megamek/client/bot/BotClient.java @@ -1132,7 +1132,7 @@ private void toggleStealth() { */ public void doAlertDialog(String title, String message) { JTextPane textArea = new JTextPane(); - ReportDisplay.setupStylesheet(textArea); + Report.setupStylesheet(textArea); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea, diff --git a/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java b/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java new file mode 100644 index 00000000000..95541fb0c70 --- /dev/null +++ b/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 - The MegaMek Team. All Rights Reserved. + * + * This file is part of MegaMek. + * + * MegaMek is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MegaMek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MegaMek. If not, see . + */ +package megamek.client.ui.dialogs; + +import megamek.client.ui.Messages; +import megamek.client.ui.swing.ClientGUI; +import megamek.client.ui.swing.GUIPreferences; +import megamek.client.ui.swing.util.UIUtil; + +import javax.swing.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +public class MiniReportDisplayDialog extends JDialog { + //region Variable Declarations + private final ClientGUI clientGUI; + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + private static final String MSG_TITLE = Messages.getString("MiniReportDisplay.title"); + //endregion Variable Declarations + + //region Constructors + public MiniReportDisplayDialog(final JFrame frame, final ClientGUI clientGUI) { + super(frame, "", false); + this.setTitle(MSG_TITLE); + + this.setLocation(GUIP.getMiniReportPosX(), GUIP.getMiniReportPosY()); + this.setSize(GUIP.getMiniReportSizeWidth(), GUIP.getMiniReportSizeHeight()); + + UIUtil.updateWindowBounds(this); + this.setResizable(true); + this.setFocusable(false); + this.setFocusableWindowState(false); + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent evt) { + GUIP.setMiniReportEnabled(false); + } + }); + + this.clientGUI = clientGUI; + } + //endregion Constructors + + @Override + protected void processWindowEvent(WindowEvent e) { + super.processWindowEvent(e); + if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { + GUIP.setMiniReportSizeWidth(getSize().width); + GUIP.setMiniReportSizeHeight(getSize().height); + GUIP.setMiniReportPosX(getLocation().x); + GUIP.setMiniReportPosY(getLocation().y); + } + } + + /** + * In addition to the default Dialog processKeyEvent, this method + * dispatches a KeyEvent to the client gui. + * This enables all the gui hotkeys. + */ + @Override + protected void processKeyEvent(KeyEvent evt) { + evt.setSource(clientGUI); + clientGUI.getMenuBar().dispatchEvent(evt); + // Make the source be the ClientGUI and not the dialog + // This prevents a ClassCastException in ToolTipManager + clientGUI.getCurrentPanel().dispatchEvent(evt); + if (!evt.isConsumed()) { + super.processKeyEvent(evt); + } + } +} diff --git a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java index 3970a66b345..71fcf92a7e8 100644 --- a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java +++ b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java @@ -20,36 +20,72 @@ import megamek.client.ui.Messages; import megamek.client.ui.swing.ClientGUI; +import megamek.client.ui.swing.GUIPreferences; import megamek.client.ui.swing.unitDisplay.UnitDisplay; +import megamek.client.ui.swing.util.UIUtil; import javax.swing.*; import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; public class UnitDisplayDialog extends JDialog { //region Variable Declarations - private UnitDisplay unitDisplay; - private final ClientGUI clientGUI; + private static final String MSG_TITLE = Messages.getString("ClientGUI.MechDisplay"); + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); //endregion Variable Declarations //region Constructors - public UnitDisplayDialog(final JFrame frame, final UnitDisplay unitDisplay, - final ClientGUI clientGUI) { - super(frame, Messages.getString("ClientGUI.MechDisplay"), false); - setUnitDisplay(unitDisplay); + public UnitDisplayDialog(final JFrame frame, final ClientGUI clientGUI) { + super(frame, "", false); + this.setTitle(MSG_TITLE); + + if (GUIP.getUnitDisplayStartTabbed()) { + this.setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY()); + this.setSize(GUIP.getUnitDisplaySizeWidth(), GUIP.getUnitDisplaySizeHeight()); + } + else { + this.setLocation(GUIP.getUnitDisplayNontabbedPosX(), GUIP.getUnitDisplayNontabbedPosY()); + this.setSize(GUIP.getUnitDisplayNonTabbedSizeWidth(), GUIP.getUnitDisplayNonTabbedSizeHeight()); + } + + UIUtil.updateWindowBounds(this); + this.setResizable(true); + this.setFocusable(false); + this.setFocusableWindowState(false); + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent evt) { + GUIP.setUnitDisplayEnabled(false); + } + }); + this.clientGUI = clientGUI; } //endregion Constructors - //region Getters/Setters - public UnitDisplay getUnitDisplay() { - return unitDisplay; - } - - public void setUnitDisplay(final UnitDisplay unitDisplay) { - this.unitDisplay = unitDisplay; + @Override + protected void processWindowEvent(WindowEvent e) { + super.processWindowEvent(e); + if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { + if ((getSize().width * getSize().height) > 0) { + if (GUIP.getUnitDisplayStartTabbed()) { + GUIP.setUnitDisplayPosX(getLocation().x); + GUIP.setUnitDisplayPosY(getLocation().y); + GUIP.setUnitDisplaySizeWidth(getSize().width); + GUIP.setUnitDisplaySizeHeight(getSize().height); + } else { + GUIP.setUnitDisplayNontabbedPosX(getLocation().x); + GUIP.setUnitDisplayNontabbedPosY(getLocation().y); + GUIP.setUnitDisplayNonTabbedSizeWidth(getSize().width); + GUIP.setUnitDisplayNonTabbedSizeHeight(getSize().height); + clientGUI.getUnitDisplay().saveSplitterLoc(); + } + } + } } - //endregion Getters/Setters /** * In addition to the default Dialog processKeyEvent, this method diff --git a/megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java b/megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java index 69c0250571e..eeba2eb5f55 100644 --- a/megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java +++ b/megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java @@ -86,8 +86,9 @@ public void actionPerformed(ActionEvent e) { if (isIgnoringEvents()) { return; } - if (clientgui.getClient().isMyTurn() - || (clientgui.getClient().getGame().getTurn() == null)) { + if ((clientgui.getClient().isMyTurn()) + || (clientgui.getClient().getGame().getTurn() == null) + || (clientgui.getClient().getGame().getPhase().isReport())) { ready(); // When the turn is ended, we could miss a key release // event diff --git a/megamek/src/megamek/client/ui/swing/ChatterBox.java b/megamek/src/megamek/client/ui/swing/ChatterBox.java index d4844363885..7323bf50dc3 100644 --- a/megamek/src/megamek/client/ui/swing/ChatterBox.java +++ b/megamek/src/megamek/client/ui/swing/ChatterBox.java @@ -60,28 +60,44 @@ public ChatterBox(ClientGUI clientgui) { @Override public void gamePlayerChat(GamePlayerChatEvent e) { chatArea.append('\n' + e.getMessage()); - PlayerListDialog.refreshPlayerList(playerList, client); + PlayerListDialog pld = clientgui.getPlayerListDialog(); + if (pld != null) { + pld.refreshPlayerList(playerList, client); + } moveToEnd(); } @Override public void gamePlayerChange(GamePlayerChangeEvent e) { - PlayerListDialog.refreshPlayerList(playerList, client); + PlayerListDialog pld = clientgui.getPlayerListDialog(); + if (pld != null) { + pld.refreshPlayerList(playerList, client); + } } @Override public void gameTurnChange(GameTurnChangeEvent e) { - PlayerListDialog.refreshPlayerList(playerList, client); + PlayerListDialog pld = clientgui.getPlayerListDialog(); + if (pld != null) { + pld.refreshPlayerList(playerList, client); + } } @Override public void gamePhaseChange(GamePhaseChangeEvent e) { - PlayerListDialog.refreshPlayerList(playerList, client); + PlayerListDialog pld = clientgui.getPlayerListDialog(); + if (pld != null) { + pld.refreshPlayerList(playerList, client); + } } @Override public void gameEntityNew(GameEntityNewEvent e) { - PlayerListDialog.refreshPlayerList(playerList, client); + PlayerListDialog pld = clientgui.getPlayerListDialog(); + if (pld != null) { + pld.refreshPlayerList(playerList, client); + } + if (PreferenceManager.getClientPreferences() .getPrintEntityChange()) { systemMessage(e.getNumberOfEntities() + " " + MSG_ENTITIESADDED); @@ -90,7 +106,10 @@ public void gameEntityNew(GameEntityNewEvent e) { @Override public void gameEntityRemove(GameEntityRemoveEvent e) { - PlayerListDialog.refreshPlayerList(playerList, client); + PlayerListDialog pld = clientgui.getPlayerListDialog(); + if (pld != null) { + pld.refreshPlayerList(playerList, client); + } } @Override diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index a2108ee4632..c97f7287af6 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -24,6 +24,7 @@ import megamek.client.event.BoardViewEvent; import megamek.client.event.BoardViewListener; import megamek.client.ui.Messages; +import megamek.client.ui.dialogs.MiniReportDisplayDialog; import megamek.client.ui.dialogs.UnitDisplayDialog; import megamek.client.ui.dialogs.helpDialogs.AbstractHelpDialog; import megamek.client.ui.dialogs.helpDialogs.MMReadMeHelpDialog; @@ -45,6 +46,7 @@ import megamek.common.enums.GamePhase; import megamek.common.event.*; import megamek.common.icons.Camouflage; +import megamek.common.preference.ClientPreferences; import megamek.common.preference.IPreferenceChangeListener; import megamek.common.preference.PreferenceChangeEvent; import megamek.common.preference.PreferenceManager; @@ -69,6 +71,7 @@ import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URL; +import java.text.MessageFormat; import java.util.List; import java.util.*; import java.util.stream.Collectors; @@ -79,6 +82,7 @@ public class ClientGUI extends JPanel implements BoardViewListener, private static final long serialVersionUID = 3913466735610109147L; private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + private static final ClientPreferences CP = PreferenceManager.getClientPreferences(); private static final String FILENAME_ICON_16X16 = "megamek-icon-16x16.png"; private static final String FILENAME_ICON_32X32 = "megamek-icon-32x32.png"; @@ -218,6 +222,7 @@ public class ClientGUI extends JPanel implements BoardViewListener, private static final String MSG_FATALERRORMSG = Messages.getString("ClientGUI.FatalError.message"); private static final String MSG_SKINNINGHELPPATH = Messages.getString("ClientGUI.skinningHelpPath"); private static final String MSG_SKINNINGHELPPATHTITLE = Messages.getString("ClientGUI.skinningHelpPath.title"); + private static final String MSG_FAILEDTOLOADAUDIFILE = Messages.getString("ClientGUI.failedToLoadAudioFile"); private static final String MSG_FILESAVESERVERDIALOGMSG = Messages.getString("ClientGUI.FileSaveServerDialog.message"); private static final String MSG_FILESAVESERVERDIALOGTITTLE = Messages.getString("ClientGUI.FileSaveServerDialog.title"); private static final String MSG_OPENUNITLISTFILEDIALOGNOREINFORCETITILE = Messages.getString("ClientGUI.openUnitListFileDialog.noReinforceTitle"); @@ -272,6 +277,7 @@ public class ClientGUI extends JPanel implements BoardViewListener, private static final String MSG_TELEMISSILETARGETDIALOGTARGET = Messages.getString("TeleMissileTargetDialog.target"); private static final String MSG_TELEMISSILETARGETDIALOGMSG = Messages.getString("TeleMissileTargetDialog.message"); private static final String MSG_TELEMISSILETARGETDIALOGTITLE = Messages.getString("TeleMissileTargetDialog.title"); + // a frame, to show stuff in public JFrame frame; @@ -287,8 +293,13 @@ public class ClientGUI extends JPanel implements BoardViewListener, public ChatterBox2 cb2; private BoardView bv; private Component bvc; + private JPanel panTop; + private JSplitPane splitPaneA; + private JPanel panA1; + private JPanel panA2; + public UnitDisplay unitDisplay; - private JDialog unitDisplayDialog; + private UnitDisplayDialog unitDisplayDialog; public JDialog minimapW; private MapMenu popup; private UnitOverview uo; @@ -324,6 +335,7 @@ public class ClientGUI extends JPanel implements BoardViewListener, private Map mainNames = new HashMap<>(); private MiniReportDisplay miniReportDisplay; + private MiniReportDisplayDialog miniReportDisplayDialog; /** * The JPanel containing the main display area. @@ -344,7 +356,9 @@ public class ClientGUI extends JPanel implements BoardViewListener, * The JPanel containing the secondary display area. */ private JPanel panSecondary = new JPanel(); - + + private ReportDisplay reportDisply; + private StatusBarPhaseDisplay currPhaseDisplay; /** @@ -407,7 +421,7 @@ public void setUnitDisplay(final UnitDisplay unitDisplay) { this.unitDisplay = unitDisplay; } - public JDialog getUnitDisplayDialog() { + public UnitDisplayDialog getUnitDisplayDialog() { return unitDisplayDialog; } @@ -415,16 +429,36 @@ public void setUnitDisplayDialog(final UnitDisplayDialog unitDisplayDialog) { this.unitDisplayDialog = unitDisplayDialog; } + public MiniReportDisplay getMiniReportDisplay() { + return miniReportDisplay; + } + + public void setMiniReportDisplay(final MiniReportDisplay miniReportDisplay) { + this.miniReportDisplay = miniReportDisplay; + } + + public MiniReportDisplayDialog getMiniReportDisplayDialog() { + return miniReportDisplayDialog; + } + + public PlayerListDialog getPlayerListDialog() { + return playerListDialog; + } + + public void setMiniReportDisplayDialog(final MiniReportDisplayDialog miniReportDisplayDialog) { + this.miniReportDisplayDialog = miniReportDisplayDialog; + } + /** * Try to load the "bing" sound clip. */ private void loadSoundClip() { - if (GUIPreferences.getInstance().getSoundBingFilename() == null) { + if (GUIP.getSoundBingFilename() == null) { return; } - final File file = new File(GUIPreferences.getInstance().getSoundBingFilename()); + final File file = new File(GUIP.getSoundBingFilename()); if (!file.exists()) { - LogManager.getLogger().error("Failed to load audio file named " + GUIPreferences.getInstance().getSoundBingFilename()); + LogManager.getLogger().error(MSG_FAILEDTOLOADAUDIFILE + " " + GUIP.getSoundBingFilename()); return; } @@ -459,15 +493,9 @@ private void initializeFrame() { frame = new JFrame(MSG_TITLE); frame.setJMenuBar(menuBar); - if (GUIPreferences.getInstance().getWindowSizeHeight() != 0) { - frame.setLocation( - GUIPreferences.getInstance().getWindowPosX(), - GUIPreferences.getInstance().getWindowPosY() - ); - frame.setSize( - GUIPreferences.getInstance().getWindowSizeWidth(), - GUIPreferences.getInstance().getWindowSizeHeight() - ); + if (GUIP.getWindowSizeHeight() != 0) { + frame.setLocation(GUIP.getWindowPosX(), GUIP.getWindowPosY()); + frame.setSize(GUIP.getWindowSizeWidth(), GUIP.getWindowSizeHeight()); } else { frame.setSize(800, 600); } @@ -522,6 +550,23 @@ public void initialize() { bv.setPreferredSize(getSize()); bvc = bv.getComponent(); bvc.setName(CG_BOARDVIEW); + + panTop = new JPanel(new BorderLayout()); + panA1 = new JPanel(); + panA1.setVisible(false); + panA2 = new JPanel(); + panA2.setVisible(false); + + splitPaneA = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + + splitPaneA.setDividerSize(10); + splitPaneA.setResizeWeight(0.5); + + splitPaneA.setLeftComponent(panA1); + splitPaneA.setRightComponent(panA2); + + panTop.add(splitPaneA, BorderLayout.CENTER); + bv.addBoardViewListener(this); client.setBoardView(bv); } catch (Exception ex) { @@ -537,7 +582,7 @@ public void initialize() { frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - if (!GUIPreferences.getInstance().getBoolean(GUIPreferences.ADVANCED_NO_SAVE_NAG)) { + if (!GUIP.getBoolean(GUIPreferences.ADVANCED_NO_SAVE_NAG)) { ignoreHotKeys = true; int savePrompt = JOptionPane.showConfirmDialog(null, MSG_GAMESAVEDIALOGMSG, @@ -580,41 +625,18 @@ public void windowClosing(WindowEvent e) { setUnitDisplay(new UnitDisplay(this, controller)); getUnitDisplay().addMechDisplayListener(bv); + setUnitDisplayDialog(new UnitDisplayDialog(getFrame(), this)); + getUnitDisplayDialog().setVisible(false); - setUnitDisplayDialog(new UnitDisplayDialog(getFrame(), getUnitDisplay(), this)); - - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { - getUnitDisplayDialog().setLocation(GUIPreferences.getInstance().getDisplayPosX(), GUIPreferences.getInstance().getDisplayPosY()); - getUnitDisplayDialog().setSize(GUIPreferences.getInstance().getDisplaySizeWidth(), GUIPreferences.getInstance().getDisplaySizeHeight()); - } - else { - getUnitDisplayDialog().setLocation(GUIPreferences.getInstance().getDisplayNontabbedPosX(), GUIPreferences.getInstance().getDisplayNontabbedPosY()); - getUnitDisplayDialog().setSize(GUIPreferences.getInstance().getDisplayNonTabbedSizeWidth(), GUIPreferences.getInstance().getDisplayNonTabbedSizeHeight()); - } - - UIUtil.updateWindowBounds(getUnitDisplayDialog()); - getUnitDisplayDialog().setResizable(true); - getUnitDisplayDialog().setFocusable(false); - getUnitDisplayDialog().setFocusableWindowState(false); - getUnitDisplayDialog().add(getUnitDisplay()); - getUnitDisplayDialog().addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent evt) { - GUIPreferences.getInstance().hideUnitDisplay(); - } - }); + setMiniReportDisplay(new MiniReportDisplay(this)); + setMiniReportDisplayDialog(new MiniReportDisplayDialog(getFrame(), this)); + getMiniReportDisplayDialog().setVisible(false); - Ruler.color1 = GUIPreferences.getInstance().getRulerColor1(); - Ruler.color2 = GUIPreferences.getInstance().getRulerColor2(); + Ruler.color1 = GUIP.getRulerColor1(); + Ruler.color2 = GUIP.getRulerColor2(); ruler = new Ruler(frame, client, bv); - ruler.setLocation( - GUIPreferences.getInstance().getRulerPosX(), - GUIPreferences.getInstance().getRulerPosY() - ); - ruler.setSize( - GUIPreferences.getInstance().getRulerSizeHeight(), - GUIPreferences.getInstance().getRulerSizeWidth() - ); + ruler.setLocation(GUIP.getRulerPosX(), GUIP.getRulerPosY()); + ruler.setSize(GUIP.getRulerSizeHeight(), GUIP.getRulerSizeWidth()); UIUtil.updateWindowBounds(ruler); minimapW = Minimap.createMinimap(frame, getBoardView(), getClient().getGame(), this); @@ -720,26 +742,56 @@ public void customizePlayer() { /** * Called when the user selects the "View->Player List" menu item. */ - private void showPlayerList() { + public void showPlayerList() { if (playerListDialog == null) { - playerListDialog = new PlayerListDialog(frame, client); + playerListDialog = new PlayerListDialog(frame, client, false); } playerListDialog.setVisible(true); } - /** - * Called when the user selects the "View->Round Report" menu item. - */ - private void showRoundReport() { + public void miniReportDisplayAddReportPages() { ignoreHotKeys = true; - if (miniReportDisplay == null) { - miniReportDisplay = new MiniReportDisplay(frame, this); + if (miniReportDisplay != null) { + miniReportDisplay.addReportPages(); } - - miniReportDisplay.setVisible(true); ignoreHotKeys = false; } + public void reportDisplayResetDone() { + if ((reportDisply != null ) && (!getClient().getLocalPlayer().isDone())) { + reportDisply.setDoneEnabled(true); + } + } + + public void reportDisplayResetRerollInitiative() { + if ((reportDisply != null ) + && (!getClient().getLocalPlayer().isDone()) + && (getClient().getGame().hasTacticalGenius(getClient().getLocalPlayer()))) { + reportDisply.resetRerollInitiativeEnabled(); + } + } + + public void resetWindowPositions() { + if (minimapW != null) { + minimapW.setBounds(0, 0, minimapW.getWidth(), minimapW.getHeight()); + } + if (getUnitDisplayDialog() != null) { + getUnitDisplayDialog().setBounds(0, 0, getUnitDisplay().getWidth(), getUnitDisplay().getHeight()); + } + if (miniReportDisplayDialog!= null) { + miniReportDisplayDialog.setBounds(0, 0, miniReportDisplayDialog.getWidth(), miniReportDisplayDialog.getHeight()); + } + if (playerListDialog != null) { + playerListDialog.setBounds(0, 0, playerListDialog.getWidth(), playerListDialog.getHeight()); + } + if (gameOptionsDialog!= null) { + gameOptionsDialog.setBounds(0, 0, gameOptionsDialog.getWidth(), gameOptionsDialog.getHeight()); + } + if (setdlg != null) { + setdlg.setBounds(0, 0, setdlg.getWidth(), setdlg.getHeight()); + } + } + /** * Implement the ActionListener interface. */ @@ -747,8 +799,7 @@ private void showRoundReport() { public void actionPerformed(ActionEvent event) { switch (event.getActionCommand()) { case VIEW_RESET_WINDOW_POSITIONS: - minimapW.setBounds(0, 0, minimapW.getWidth(), minimapW.getHeight()); - getUnitDisplayDialog().setBounds(0, 0, getUnitDisplay().getWidth(), getUnitDisplay().getHeight()); + resetWindowPositions(); break; case FILE_GAME_SAVE: saveGame(); @@ -803,10 +854,9 @@ public void actionPerformed(ActionEvent event) { break; case FILE_UNITS_REINFORCE: ignoreHotKeys = true; - PlayerListDialog playerListDialog = new PlayerListDialog(frame, client); - playerListDialog.setModal(true); - playerListDialog.setVisible(true); - loadListFile(playerListDialog.getSelected(), true); + PlayerListDialog pld = new PlayerListDialog(frame, client, true); + pld.setVisible(true); + loadListFile(pld.getSelected(), true); ignoreHotKeys = false; break; case FILE_UNITS_REINFORCE_RAT: @@ -832,10 +882,22 @@ public void actionPerformed(ActionEvent event) { customizePlayer(); break; case VIEW_PLAYER_LIST: - showPlayerList(); + GUIP.togglePlayerListEnabled(); break; case VIEW_ROUND_REPORT: - showRoundReport(); + GUIP.toggleRoundReportEnabled(); + break; + case VIEW_UNIT_DISPLAY: + GUIP.toggleUnitDisplay(); + break; + case VIEW_MINI_MAP: + GUIP.toggleMinimapEnabled(); + break; + case VIEW_KEYBINDS_OVERLAY: + GUIP.toggleKeybindsOverlay(); + break; + case VIEW_TOGGLE_HEXCOORDS: + GUIP.toggleCoords(); break; case BOARD_SAVE: ignoreHotKeys = true; @@ -876,31 +938,29 @@ public void actionPerformed(ActionEvent event) { bv.zoomOut(); break; case VIEW_TOGGLE_ISOMETRIC: - GUIPreferences.getInstance().setIsometricEnabled(bv.toggleIsometric()); + GUIP.setIsometricEnabled(bv.toggleIsometric()); break; case VIEW_TOGGLE_FOV_HIGHLIGHT: - GUIPreferences.getInstance().setFovHighlight(!GUIPreferences.getInstance().getFovHighlight()); + GUIP.setFovHighlight(!GUIP.getFovHighlight()); bv.refreshDisplayables(); if (client.getGame().getPhase().isMovement()) { bv.clearHexImageCache(); } break; case VIEW_TOGGLE_FIELD_OF_FIRE: - GUIPreferences.getInstance().setShowFieldOfFire( - !GUIPreferences.getInstance().getShowFieldOfFire()); + GUIP.setShowFieldOfFire(!GUIP.getShowFieldOfFire()); bv.repaint(); break; case VIEW_TOGGLE_FOV_DARKEN: - GUIPreferences.getInstance().setFovDarken(!GUIPreferences.getInstance().getFovDarken()); + GUIP.setFovDarken(!GUIP.getFovDarken()); bv.refreshDisplayables(); if (client.getGame().getPhase().isMovement()) { bv.clearHexImageCache(); } break; case VIEW_TOGGLE_FIRING_SOLUTIONS: - GUIPreferences.getInstance().setFiringSolutions( - !GUIPreferences.getInstance().getFiringSolutions()); - if (!GUIPreferences.getInstance().getFiringSolutions()) { + GUIP.setFiringSolutions(!GUIP.getFiringSolutions()); + if (!GUIP.getFiringSolutions()) { bv.clearFiringSolutionData(); } else { if (curPanel instanceof FiringDisplay) { @@ -911,8 +971,7 @@ public void actionPerformed(ActionEvent event) { break; case VIEW_MOVE_ENV: if (curPanel instanceof MovementDisplay) { - GUIPreferences.getInstance().setMoveEnvelope( - !GUIPreferences.getInstance().getMoveEnvelope()); + GUIP.setMoveEnvelope(!GUIP.getMoveEnvelope()); ((MovementDisplay) curPanel).computeMovementEnvelope(getUnitDisplay().getCurrentEntity()); } break; @@ -966,13 +1025,13 @@ public void doSaveUnit() { } if (!destroyed.isEmpty()) { - String sLogDir = PreferenceManager.getClientPreferences().getLogDirectory(); + String sLogDir = CP.getLogDirectory(); File logDir = new File(sLogDir); if (!logDir.exists()) { logDir.mkdir(); } String fileName = CG_FILENAMESALVAGE + CG_FILEEXTENTIONMUL; - if (PreferenceManager.getClientPreferences().stampFilenames()) { + if (CP.stampFilenames()) { fileName = StringUtil.addDateTimeStamp(fileName); } File unitFile = new File(sLogDir + File.separator + fileName); @@ -991,41 +1050,43 @@ public void doSaveUnit() { */ void saveSettings() { // Frame location - GUIPreferences.getInstance().setWindowPosX(frame.getLocation().x); - GUIPreferences.getInstance().setWindowPosY(frame.getLocation().y); - GUIPreferences.getInstance().setWindowSizeWidth(frame.getSize().width); - GUIPreferences.getInstance().setWindowSizeHeight(frame.getSize().height); + GUIP.setWindowPosX(frame.getLocation().x); + GUIP.setWindowPosY(frame.getLocation().y); + GUIP.setWindowSizeWidth(frame.getSize().width); + GUIP.setWindowSizeHeight(frame.getSize().height); // Minimap if ((minimapW != null) && ((minimapW.getSize().width * minimapW.getSize().height) > 0)) { - GUIPreferences.getInstance().setMinimapPosX(minimapW.getLocation().x); - GUIPreferences.getInstance().setMinimapPosY(minimapW.getLocation().y); + GUIP.setMinimapPosX(minimapW.getLocation().x); + GUIP.setMinimapPosY(minimapW.getLocation().y); } // Mek display if ((getUnitDisplayDialog() != null) && ((getUnitDisplayDialog().getSize().width * getUnitDisplayDialog().getSize().height) > 0)) { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { - GUIPreferences.getInstance().setDisplayPosX(getUnitDisplayDialog().getLocation().x); - GUIPreferences.getInstance().setDisplayPosY(getUnitDisplayDialog().getLocation().y); - GUIPreferences.getInstance().setDisplaySizeWidth(getUnitDisplayDialog().getSize().width); - GUIPreferences.getInstance().setDisplaySizeHeight(getUnitDisplayDialog().getSize().height); + if (GUIP.getUnitDisplayStartTabbed()) { + GUIP.setUnitDisplayPosX(getUnitDisplayDialog().getLocation().x); + GUIP.setUnitDisplayPosY(getUnitDisplayDialog().getLocation().y); + GUIP.setUnitDisplaySizeWidth(getUnitDisplayDialog().getSize().width); + GUIP.setUnitDisplaySizeHeight(getUnitDisplayDialog().getSize().height); } else { - GUIPreferences.getInstance().setDisplayNontabbedPosX(getUnitDisplayDialog().getLocation().x); - GUIPreferences.getInstance().setDisplayNontabbedPosY(getUnitDisplayDialog().getLocation().y); - GUIPreferences.getInstance().setDisplayNonTabbedSizeWidth(getUnitDisplayDialog().getSize().width); - GUIPreferences.getInstance().setDisplayNonTabbedSizeHeight(getUnitDisplayDialog().getSize().height); + GUIP.setUnitDisplayNontabbedPosX(getUnitDisplayDialog().getLocation().x); + GUIP.setUnitDisplayNontabbedPosY(getUnitDisplayDialog().getLocation().y); + GUIP.setUnitDisplayNonTabbedSizeWidth(getUnitDisplayDialog().getSize().width); + GUIP.setUnitDisplayNonTabbedSizeHeight(getUnitDisplayDialog().getSize().height); unitDisplay.saveSplitterLoc(); } + + saveSplitPaneLocations(); } // Ruler display if ((ruler != null) && (ruler.getSize().width != 0) && (ruler.getSize().height != 0)) { - GUIPreferences.getInstance().setRulerPosX(ruler.getLocation().x); - GUIPreferences.getInstance().setRulerPosY(ruler.getLocation().y); - GUIPreferences.getInstance().setRulerSizeWidth(ruler.getSize().width); - GUIPreferences.getInstance().setRulerSizeHeight(ruler.getSize().height); + GUIP.setRulerPosX(ruler.getLocation().x); + GUIP.setRulerPosY(ruler.getLocation().y); + GUIP.setRulerSizeWidth(ruler.getSize().width); + GUIP.setRulerSizeHeight(ruler.getSize().height); } } @@ -1129,16 +1190,10 @@ void switchPanel(GamePhase phase) { switch (phase) { case LOUNGE: // reset old report tabs and images, if any - ReportDisplay rD = (ReportDisplay) phaseComponents.get(String.valueOf(GamePhase.INITIATIVE_REPORT)); - if (rD != null) { - rD.resetTabs(); - } ChatLounge cl = (ChatLounge) phaseComponents.get(String.valueOf(GamePhase.LOUNGE)); cb.setDoneButton(cl.butDone); cl.setBottom(cb.getComponent()); getBoardView().getTilesetManager().reset(); - getUnitDisplayDialog().setVisible(false); - setMapVisible(false); break; case POINTBLANK_SHOT: case SET_ARTILLERY_AUTOHIT_HEXES: @@ -1151,11 +1206,6 @@ void switchPanel(GamePhase phase) { case PREFIRING: case FIRING: case PHYSICAL: - if (frame.isShowing()) { - maybeShowMinimap(); - maybeShowUnitDisplay(); - } - break; case INITIATIVE_REPORT: case TARGETING_REPORT: case MOVEMENT_REPORT: @@ -1164,16 +1214,15 @@ void switchPanel(GamePhase phase) { case PHYSICAL_REPORT: case END_REPORT: case VICTORY: - rD = (ReportDisplay) phaseComponents.get(String.valueOf(GamePhase.INITIATIVE_REPORT)); - cb.setDoneButton(rD.butDone); - rD.setBottom(cb.getComponent()); - setMapVisible(false); - setUnitDisplayVisible(false); - break; default: break; } + maybeShowMinimap(); + maybeShowUnitDisplay(); + maybeShowMiniReport(); + maybeShowPlayerList(); + cardsMain.show(panMain, mainNames.get(name)); String secondaryToShow = secondaryNames.get(name); // only show the secondary component if there is one to show @@ -1199,7 +1248,7 @@ void switchPanel(GamePhase phase) { } // Make the new panel the focus, if the Client option says so - if (GUIPreferences.getInstance().getFocus() && !(client instanceof TestBot)) { + if (GUIP.getFocus() && !(client instanceof TestBot)) { curPanel.requestFocus(); } } @@ -1245,7 +1294,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_SELECTARTYAUTOHITHEXDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1256,7 +1305,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_DEPLOYMINEFIELDDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1267,7 +1316,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_DEPLOYMENTDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1279,7 +1328,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_TARGETINGPHASEDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1292,7 +1341,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_PREMOVEMENTDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1303,7 +1352,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_MOVEMENTDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1315,7 +1364,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_OFFBOARDDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1327,7 +1376,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_PREFIRING; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1338,7 +1387,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_FIRINGDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1349,7 +1398,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_POINTBLANKSHOTDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); @@ -1360,17 +1409,12 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_PHYSICALDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; panSecondary.add(component, secondary); break; case INITIATIVE_REPORT: - component = new ReportDisplay(this); - main = CG_REPORTDISPLAY; - component.setName(main); - panMain.add(main, component); - break; case TARGETING_REPORT: case MOVEMENT_REPORT: case OFFBOARD_REPORT: @@ -1378,13 +1422,20 @@ private JComponent initializePanel(GamePhase phase) { case PHYSICAL_REPORT: case END_REPORT: case VICTORY: - // Try to reuse the ReportDisplay for other phases... - component = phaseComponents.get(String.valueOf(GamePhase.INITIATIVE_REPORT)); - if (component == null) { - // no ReportDisplay to reuse - get a new one - component = initializePanel(GamePhase.INITIATIVE_REPORT); + main = CG_BOARDVIEW; + secondary = CG_REPORTDISPLAY; + if (reportDisply == null) { + reportDisply = new ReportDisplay(this); + reportDisply.setName(secondary); + } + if (!mainNames.containsValue(main)) { + panMain.add(panTop, main); + } + currPhaseDisplay = reportDisply; + component = reportDisply; + if (!secondaryNames.containsValue(secondary)) { + panSecondary.add(reportDisply, secondary); } - main = CG_REPORTDISPLAY; break; default: component = new JLabel(MSG_WAITINGONTHESERVER); @@ -1415,7 +1466,7 @@ protected void showBoardPopup(Coords c) { */ public void toggleMMUDDisplays() { GUIP.toggleUnitDisplay(); - GUIP.setMinimapEnabled(GUIP.getBoolean(GUIPreferences.SHOW_UNIT_DISPLAY)); + GUIP.setMinimapEnabled(GUIP.getUnitDisplayEnabled()); } /** @@ -1430,13 +1481,69 @@ private void toggleAccessibilityWindow() { private void toggleUnitOverview() { uo.setVisible(!uo.isVisible()); - GUIPreferences.getInstance().setShowUnitOverview(uo.isVisible()); + GUIP.setShowUnitOverview(uo.isVisible()); bv.refreshDisplayables(); } /** Shows or hides the minimap based on the current menu setting. */ private void maybeShowMinimap() { - setMapVisible(GUIP.getMinimapEnabled()); + GamePhase phase = getClient().getGame().getPhase(); + + if (phase.isReport()) { + int action = GUIP.getMinimapAutoDisplayReportPhase(); + if (action == GUIPreferences.SHOW) { + GUIP.setMinimapEnabled(true); + } else if (action == GUIPreferences.HIDE) { + GUIP.setMinimapEnabled(false); + } + } else if (phase.isOnMap()) { + int action = GUIP.getMinimapAutoDisplayNonReportPhase(); + if (action == GUIPreferences.SHOW) { + GUIP.setMinimapEnabled(true); + } else if (action == GUIPreferences.HIDE) { + GUIP.setMinimapEnabled(false); + } + } + } + + private void maybeShowMiniReport() { + GamePhase phase = getClient().getGame().getPhase(); + + if (phase.isReport()) { + int action = GUIP.getMiniReportAutoDisplayReportPhase(); + if (action == GUIPreferences.SHOW) { + GUIP.setMiniReportEnabled(true); + } else if (action == GUIPreferences.HIDE) { + GUIP.setMiniReportEnabled(false); + } + } else if (phase.isOnMap()) { + int action = GUIP.getMiniReportAutoDisplayNonReportPhase(); + if (action == GUIPreferences.SHOW) { + GUIP.setMiniReportEnabled(true); + } else if (action == GUIPreferences.HIDE) { + GUIP.setMiniReportEnabled(false); + } + } + } + + private void maybeShowPlayerList() { + GamePhase phase = getClient().getGame().getPhase(); + + if (phase.isReport()) { + int action = GUIP.getPlayerListAutoDisplayReportPhase(); + if (action == GUIPreferences.SHOW) { + GUIP.setPlayerListEnabled(true); + } else if (action == GUIPreferences.HIDE) { + GUIP.setPlayerListEnabled(false); + } + } else if (phase.isOnMap()) { + int action = GUIP.getPlayerListAutoDisplayNonReportPhase(); + if (action == GUIPreferences.SHOW) { + GUIP.setPlayerListEnabled(true); + } else if (action == GUIPreferences.HIDE) { + GUIP.setPlayerListEnabled(false); + } + } } /** @@ -1447,12 +1554,46 @@ private void maybeShowMinimap() { * Does not change the menu setting. */ void setMapVisible(boolean visible) { - minimapW.setVisible(visible); + if (minimapW != null) { + minimapW.setVisible(visible); + } + } + + void setMiniReportVisible(boolean visible) { + if (getMiniReportDisplayDialog() != null) { + setMiniReportLocation(visible); + } + } + + void setPlayerListVisible(boolean visible) { + if (visible) { + showPlayerList(); + } else { + if (playerListDialog != null) { + playerListDialog.setVisible(visible); + } + } } /** Shows or hides the Unit Display based on the current menu setting. */ public void maybeShowUnitDisplay() { - setUnitDisplayVisible(GUIP.getBoolean(GUIPreferences.SHOW_UNIT_DISPLAY)); + GamePhase phase = getClient().getGame().getPhase(); + + if (phase.isReport()) { + int action = GUIP.getUnitDisplayAutoDisplayReportPhase(); + if (action == GUIPreferences.SHOW) { + GUIP.setUnitDisplayEnabled(true); + } else if (action == GUIPreferences.HIDE) { + GUIP.setUnitDisplayEnabled(false); + } + } else if (phase.isOnMap()) { + int action = GUIP.getUnitDisplayAutoDisplayNonReportPhase(); + if (action == GUIPreferences.SHOW) { + GUIP.setUnitDisplayEnabled(true); + } else if (action == GUIPreferences.HIDE) { + GUIP.setUnitDisplayEnabled(false); + } + } } /** @@ -1473,7 +1614,161 @@ public void setUnitDisplayVisible(boolean visible) { } } - getUnitDisplayDialog().setVisible(visible); + if (getUnitDisplayDialog() != null) { + setUnitDisplayLocation(visible); + } + } + + private void saveSplitPaneLocations() { + if ((panA1.isVisible()) && (panA2.isVisible())) { + GUIP.setSplitPaneALocation(splitPaneA.getDividerLocation()); + } + } + + private void setsetDividerLocations() { + splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); + } + + private void hideEmptyPanel(JPanel p, JSplitPane sp, Double d) { + boolean b = false; + + for (Component comp : p.getComponents()) { + if (comp.isVisible()) { + b = true; + break; + } + } + + if (!b) { + p.setVisible(false); + sp.setDividerLocation(d); + } else { + p.setVisible(true); + } + } + + private void revalidatePanels() { + getUnitDisplay().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); + getUnitDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); + getMiniReportDisplay().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); + getMiniReportDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); + + getUnitDisplayDialog().revalidate(); + getUnitDisplayDialog().repaint(); + panA1.revalidate(); + panA1.repaint(); + panA2.revalidate(); + panA2.repaint(); + } + + private void setDockAxis() { + if (GUIP.getAdvancedDockMultipleOnYAxis()) { + panA1.setLayout(new BoxLayout(panA1, BoxLayout.Y_AXIS)); + panA2.setLayout(new BoxLayout(panA2, BoxLayout.Y_AXIS)); + } else { + panA1.setLayout(new BoxLayout(panA1, BoxLayout.X_AXIS)); + panA2.setLayout(new BoxLayout(panA2, BoxLayout.X_AXIS)); + } + } + + public void setUnitDisplayLocation(boolean visible) { + saveSplitPaneLocations(); + setDockAxis(); + + if (GUIP.getAdvancedDockOnLeft()) { + switch (GUIP.getUnitDisplayLocaton()) { + case 0: + panA2.add(bvc); + panA2.setVisible(true); + getUnitDisplayDialog().add(getUnitDisplay(), BorderLayout.CENTER); + getUnitDisplayDialog().setVisible(visible); + getUnitDisplay().setVisible(visible); + getUnitDisplay().setTitleVisible(false); + hideEmptyPanel(panA1, splitPaneA, 0.0); + break; + case 1: + panA2.add(bvc); + panA2.setVisible(true); + panA1.add(getUnitDisplay()); + getUnitDisplayDialog().setVisible(false); + getUnitDisplay().setVisible(visible); + getUnitDisplay().setTitleVisible(true); + hideEmptyPanel(panA1, splitPaneA, 0.0); + break; + } + } else { + switch (GUIP.getUnitDisplayLocaton()) { + case 0: + panA1.add(bvc); + panA1.setVisible(true); + getUnitDisplayDialog().add(getUnitDisplay(), BorderLayout.CENTER); + getUnitDisplayDialog().setVisible(visible); + getUnitDisplay().setVisible(visible); + getUnitDisplay().setTitleVisible(false); + hideEmptyPanel(panA2, splitPaneA, 1.0); + break; + case 1: + panA1.add(bvc); + panA1.setVisible(true); + panA2.add(getUnitDisplay()); + getUnitDisplayDialog().setVisible(false); + getUnitDisplay().setVisible(visible); + getUnitDisplay().setTitleVisible(true); + hideEmptyPanel(panA2, splitPaneA, 1.0); + break; + } + } + + setsetDividerLocations(); + revalidatePanels(); + } + + public void setMiniReportLocation(boolean visible) { + saveSplitPaneLocations(); + setDockAxis(); + + if (GUIP.getAdvancedDockOnLeft()) { + switch (GUIP.getMiniReportLocaton()) { + case 0: + panA2.add(bvc); + panA2.setVisible(true); + getMiniReportDisplayDialog().add(getMiniReportDisplay(), BorderLayout.CENTER); + getMiniReportDisplayDialog().setVisible(visible); + getMiniReportDisplay().setVisible(visible); + hideEmptyPanel(panA1, splitPaneA, 0.0); + break; + case 1: + panA2.add(bvc); + panA2.setVisible(true); + panA1.add(getMiniReportDisplay()); + getMiniReportDisplayDialog().setVisible(false); + getMiniReportDisplay().setVisible(visible); + hideEmptyPanel(panA1, splitPaneA, 0.0); + break; + } + } else { + switch (GUIP.getMiniReportLocaton()) { + case 0: + panA1.add(bvc); + panA1.setVisible(true); + getMiniReportDisplayDialog().add(getMiniReportDisplay(), BorderLayout.CENTER); + getMiniReportDisplayDialog().setVisible(visible); + getMiniReportDisplay().setVisible(visible); + hideEmptyPanel(panA2, splitPaneA, 1.0); + break; + case 1: + panA1.add(bvc); + panA1.setVisible(true); + panA2.add(getMiniReportDisplay()); + getMiniReportDisplayDialog().setVisible(false); + getMiniReportDisplay().setVisible(visible); + hideEmptyPanel(panA2, splitPaneA, 1.0); + break; + } + } + + revalidatePanels(); + setsetDividerLocations(); } private boolean fillPopup(Coords coords) { @@ -1510,7 +1805,7 @@ public void doAlertDialog(String title, String message) { public void doAlertDialog(String title, String message, int msgTyoe) { JTextPane textArea = new JTextPane(); - ReportDisplay.setupStylesheet(textArea); + Report.setupStylesheet(textArea); BASE64ToolKit toolKit = new BASE64ToolKit(); textArea.setEditorKit(toolKit); textArea.setEditable(false); @@ -1830,12 +2125,11 @@ public JFrame getFrame() { * used in the LOS tool. */ private void showLOSSettingDialog() { - GUIPreferences gp = GUIPreferences.getInstance(); - LOSDialog ld = new LOSDialog(frame, gp.getMechInFirst(), gp.getMechInSecond()); + LOSDialog ld = new LOSDialog(frame, GUIP.getMechInFirst(), GUIP.getMechInSecond()); ignoreHotKeys = true; if (ld.showDialog().isConfirmed()) { - gp.setMechInFirst(ld.getMechInFirst()); - gp.setMechInSecond(ld.getMechInSecond()); + GUIP.setMechInFirst(ld.getMechInFirst()); + GUIP.setMechInSecond(ld.getMechInSecond()); } ignoreHotKeys = false; } @@ -1861,7 +2155,7 @@ public void loadPreviewImage(JLabel bp, Entity entity, Player player) { * Make a "bing" sound. */ void bing() { - if (!GUIPreferences.getInstance().getSoundMute() && (bingClip != null)) { + if (!GUIP.getSoundMute() && (bingClip != null)) { bingClip.setFramePosition(0); bingClip.start(); } @@ -1885,10 +2179,6 @@ public void gamePlayerChange(GamePlayerChangeEvent evt) { if (playerListDialog != null) { playerListDialog.refreshPlayerList(); } - - if ((curPanel instanceof ReportDisplay) && !client.getLocalPlayer().isDone()) { - ((ReportDisplay) curPanel).resetReadyButton(); - } } @Override @@ -1932,9 +2222,7 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { @Override public void gamePlayerConnected(GamePlayerConnectedEvent e) { - if (curPanel instanceof ReportDisplay) { - ((ReportDisplay) curPanel).resetReadyButton(); - } + } @Override @@ -1944,19 +2232,14 @@ public void gameReport(GameReportEvent e) { // This update is for reports that get sent at odd times, // currently Tactical Genius reroll requests and when // a player wishes to continue moving after a fall. - if (curPanel instanceof ReportDisplay) { - // Tactical Genius - ((ReportDisplay) curPanel).appendReportTab(getClient().phaseReport); - ((ReportDisplay) curPanel).resetReadyButton(); + if (getClient().getGame().getPhase().isInitiativeReport()) { + miniReportDisplayAddReportPages(); + reportDisplayResetDone(); // Check if the player deserves an active reroll button // (possible, if he gets one which he didn't use, and his // opponent got and used one) and if so activates it. - if (getClient().getGame().hasTacticalGenius(getClient().getLocalPlayer())) { - if (!((ReportDisplay) curPanel).hasRerolled()) { - ((ReportDisplay) curPanel).resetRerollButton(); - } - } - // Show a popup to the players so that we know whats up! + reportDisplayResetRerollInitiative(); + if (!(getClient() instanceof TestBot)) { doAlertDialog(MSG_DIALOGTACTICALGENIUSREPORT, e.getReport()); } @@ -2006,13 +2289,13 @@ public void gameEnd(GameEndEvent e) { } if (!destroyed.isEmpty()) { - String sLogDir = PreferenceManager.getClientPreferences().getLogDirectory(); + String sLogDir = CP.getLogDirectory(); File logDir = new File(sLogDir); if (!logDir.exists()) { logDir.mkdir(); } String fileName = CG_FILENAMESALVAGE + CG_FILEEXTENTIONMUL; - if (PreferenceManager.getClientPreferences().stampFilenames()) { + if (CP.stampFilenames()) { fileName = StringUtil.addDateTimeStamp(fileName); } File unitFile = new File(sLogDir + File.separator + fileName); @@ -2063,9 +2346,10 @@ public void gameClientFeedbackRequest(GameCFREvent evt) { stepBackward.addStep(MoveStepType.BACKWARDS); stepForward.compile(client.getGame(), e, false); stepBackward.compile(client.getGame(), e, false); - + String title = MSG_CFRDOMINOTITLE; - String msg = Messages.getFormattedString(MSG_CFRDOMINOMSG, e.getDisplayName()); + String msg = MessageFormat.format(MSG_CFRDOMINOMSG, e.getDisplayName()); + int choice; Object[] options; MovePath[] paths; @@ -2073,9 +2357,11 @@ public void gameClientFeedbackRequest(GameCFREvent evt) { if (stepForward.isMoveLegal() && stepBackward.isMoveLegal()) { options = new Object[3]; paths = new MovePath[3]; - options[0] = Messages.getFormattedString(MSG_CFRDOMINOFORWARD, stepForward.getMpUsed()); - options[1] = Messages.getFormattedString(MSG_CFRDOMINOFBACKWARD, stepForward.getMpUsed()); + + options[0] = MessageFormat.format(MSG_CFRDOMINOFORWARD, stepForward.getMpUsed()); + options[1] = MessageFormat.format(MSG_CFRDOMINOFBACKWARD, stepForward.getMpUsed()); options[2] = MSG_CFRDOMINONOACTION; + paths[0] = stepForward; paths[1] = stepBackward; paths[2] = null; @@ -2083,17 +2369,20 @@ public void gameClientFeedbackRequest(GameCFREvent evt) { } else if (stepForward.isMoveLegal()) { options = new Object[2]; paths = new MovePath[2]; - options[0] = Messages.getFormattedString(MSG_CFRDOMINOFORWARD, stepForward.getMpUsed()); + + options[0] = MessageFormat.format(MSG_CFRDOMINOFORWARD, stepForward.getMpUsed()); options[1] = MSG_CFRDOMINONOACTION; + paths[0] = stepForward; paths[1] = null; optionType = JOptionPane.YES_NO_OPTION; } else { // No request is sent if both moves are illegal options = new Object[2]; paths = new MovePath[2]; - options[0] = Messages.getFormattedString(MSG_CFRDOMINOFBACKWARD, - new Object[] { stepForward.getMpUsed() }); + + options[0] = MessageFormat.format(MSG_CFRDOMINOFBACKWARD, new Object[] { stepForward.getMpUsed() }); options[1] = MSG_CFRDOMINONOACTION; + paths[0] = stepBackward; paths[1] = null; optionType = JOptionPane.YES_NO_OPTION; @@ -2123,8 +2412,10 @@ public void gameClientFeedbackRequest(GameCFREvent evt) { } optionType = JOptionPane.OK_CANCEL_OPTION; - title = Messages.getFormattedString(MSG_CFRAMASSIGNTITLE, new Object[] { e.getDisplayName() }); - msg = Messages.getFormattedString(MSG_CFRAMASSIGNMSG, new Object[] { e.getDisplayName() }); + + title = MessageFormat.format(MSG_CFRAMASSIGNTITLE, new Object[] { e.getDisplayName() }); + msg = MessageFormat.format(MSG_CFRAMASSIGNMSG, new Object[] { e.getDisplayName() }); + result = JOptionPane.showInputDialog(frame, msg, title, JOptionPane.QUESTION_MESSAGE, null, amsOptions.toArray(), null); @@ -2156,8 +2447,10 @@ public void gameClientFeedbackRequest(GameCFREvent evt) { } optionType = JOptionPane.OK_CANCEL_OPTION; - title = Messages.getFormattedString(MSG_CFAPDSASSIGNTITLE, new Object[] { e.getDisplayName() }); - msg = Messages.getFormattedString(MSG_CFAPDSASSIGNMSG, new Object[] { e.getDisplayName() }); + + title = MessageFormat.format(MSG_CFAPDSASSIGNTITLE, new Object[] { e.getDisplayName() }); + msg = MessageFormat.format(MSG_CFAPDSASSIGNMSG, new Object[] { e.getDisplayName() }); + result = JOptionPane.showInputDialog(frame, msg, title, JOptionPane.QUESTION_MESSAGE, null, apdsOptions.toArray(), null); @@ -2187,9 +2480,10 @@ public void gameClientFeedbackRequest(GameCFREvent evt) { bv.highlight(attacker.getPosition()); bv.select(target.getPosition()); bv.cursor(target.getPosition()); - msg = Messages.getFormattedString(MSG_POINTBLANKSHOTMSG, - target.getShortName(), attacker.getShortName()); + + msg = MessageFormat.format(MSG_POINTBLANKSHOTMSG, target.getShortName(), attacker.getShortName()); title = MSG_POINTBLANKSHOTTITLE; + // Ask whether the player wants to take a PBS or not int pbsChoice = JOptionPane.showConfirmDialog(frame, msg, title, JOptionPane.YES_NO_OPTION, @@ -2561,17 +2855,29 @@ private void adaptToGUIScale() { @Override public void preferenceChange(PreferenceChangeEvent e) { - if (e.getName().equals(GUIPreferences.MINIMAP_ENABLED)) { - maybeShowMinimap(); - } else if (e.getName().equals(GUIPreferences.SHOW_UNIT_DISPLAY)) { - maybeShowUnitDisplay(); + if (e.getName().equals(GUIPreferences.MINI_MAP_ENABLED)) { + setMapVisible(GUIP.getMinimapEnabled()); + } else if (e.getName().equals(GUIPreferences.PLAYER_LIST_ENABLED)) { + setPlayerListVisible(GUIP.getPlayerListEnabled()); + } else if (e.getName().equals(GUIPreferences.UNIT_DISPLAY_ENABLED)) { + setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); + } else if (e.getName().equals(GUIPreferences.UNIT_DISPLAY_LOCATION)) { + setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); + } else if (e.getName().equals(GUIPreferences.MINI_REPORT_ENABLED)) { + setMiniReportVisible(GUIP.getMiniReportEnabled()); + } else if (e.getName().equals(GUIPreferences.MINI_REPORT_LOCATION)) { + setMiniReportVisible(GUIP.getMiniReportEnabled()); + } else if (e.getName().equals(GUIPreferences.ADVANCED_DOCK_ON_LEFT)) { + setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); + setMiniReportVisible(GUIP.getMiniReportEnabled()); + } else if (e.getName().equals(GUIPreferences.ADVANCED_DOCK_MULTIPLE_ON_Y_AXIS)) { + setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); + setMiniReportVisible(GUIP.getMiniReportEnabled()); } else if (e.getName().equals(GUIPreferences.GUI_SCALE)) { adaptToGUIScale(); } else if (e.getName().equals(GUIPreferences.DEFAULT_WEAPON_SORT_ORDER)) { setWeaponOrderPrefs(true); getUnitDisplay().displayEntity(getUnitDisplay().getCurrentEntity()); } - } - } diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 1b748f3a1c8..cec536e7f1c 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -25,6 +25,7 @@ import javax.swing.*; import megamek.client.Client; +import megamek.client.ui.Messages; import megamek.client.ui.swing.util.KeyCommandBind; import megamek.client.ui.swing.util.UIUtil; @@ -60,9 +61,9 @@ public class CommonMenuBar extends JMenuBar implements ActionListener, IPreferen private JMenuItem gameQSave = new JMenuItem(getString("CommonMenuBar.fileGameQuickSave")); private JMenuItem gameQLoad = new JMenuItem(getString("CommonMenuBar.fileGameQuickLoad")); private JMenuItem gameSaveServer = new JMenuItem(getString("CommonMenuBar.fileGameSaveServer")); - private JMenuItem gameRoundReport = new JMenuItem(getString("CommonMenuBar.viewRoundReport")); + private JCheckBoxMenuItem gameRoundReport = new JCheckBoxMenuItem(getString("CommonMenuBar.viewRoundReport")); private JMenuItem gameReplacePlayer = new JMenuItem(getString("CommonMenuBar.replacePlayer")); - private JMenuItem gamePlayerList = new JMenuItem(getString("CommonMenuBar.viewPlayerList")); + private JCheckBoxMenuItem gamePlayerList = new JCheckBoxMenuItem(getString("CommonMenuBar.viewPlayerList")); private JMenuItem gameGameOptions = new JMenuItem(getString("CommonMenuBar.viewGameOptions")); private JMenuItem gamePlayerSettings = new JMenuItem(getString("CommonMenuBar.viewPlayerSettings")); @@ -136,6 +137,18 @@ public class CommonMenuBar extends JMenuBar implements ActionListener, IPreferen /** Maps the Action Command to the respective MenuItem. */ private final Map itemMap = new HashMap<>(); + private static final String MSG_FILEMENU = Messages.getString("CommonMenuBar.FileMenu"); + private static final String MSG_GAMEMENU = Messages.getString("CommonMenuBar.GameMenu"); + private static final String MSG_BOARDMENU = Messages.getString("CommonMenuBar.BoardMenu"); + private static final String MSG_FILEBOARDSAVEASIMAGE_TOOLTIP = Messages.getString("CommonMenuBar.fileBoardSaveAsImage.tooltip"); + private static final String MSG_FILEBOARDSAVEASIMAGEUNITS_TOOLTIP = Messages.getString("CommonMenuBar.fileBoardSaveAsImageUnits.tooltip"); + private static final String MSG_BOARDREMOVE = Messages.getString("CommonMenuBar.boardRemove"); + private static final String MSG_VIEWMENU = Messages.getString("CommonMenuBar.ViewMenu"); + private static final String MSG_VIEWTOGGLEFOVDARKENTOOLTIP = Messages.getString("CommonMenuBar.viewToggleFovDarkenTooltip"); + private static final String MSG_VIEWTOGGLEFIELDOFFIRETOOLTIP = Messages.getString("CommonMenuBar.viewToggleFieldOfFireToolTip"); + private static final String MSG_VIEWTOGGLEFIRINGSOLUTIONSTOOLTIP = Messages.getString("CommonMenuBar.viewToggleFiringSolutionsToolTip"); + private static final String MSG_HELPMENU = Messages.getString("CommonMenuBar.HelpMenu"); + /** Creates a MegaMek menu bar for the given client (for the lobby or ingame). */ public CommonMenuBar(Client parent) { this(); @@ -160,7 +173,7 @@ public CommonMenuBar(MegaMekGUI mmg) { /** Creates the common MegaMek menu bar. */ public CommonMenuBar() { // Create the Game menu - JMenu menu = new JMenu(getString("CommonMenuBar.FileMenu")); + JMenu menu = new JMenu(MSG_FILEMENU); menu.setMnemonic(VK_F); add(menu); initMenuItem(gameLoad, menu, FILE_GAME_LOAD, VK_L); @@ -170,20 +183,15 @@ public CommonMenuBar() { initMenuItem(gameSaveServer, menu, FILE_GAME_SAVE_SERVER); // Create the Unit List sub-menu. - menu = new JMenu(getString("CommonMenuBar.GameMenu")); + menu = new JMenu(MSG_GAMEMENU); add(menu); menu.setMnemonic(VK_G); - initMenuItem(gameRoundReport, menu, VIEW_ROUND_REPORT); - menu.addSeparator(); - initMenuItem(gameReplacePlayer, menu, FILE_GAME_REPLACE_PLAYER, VK_R); - initMenuItem(gamePlayerList, menu, VIEW_PLAYER_LIST); menu.addSeparator(); initMenuItem(gameGameOptions, menu, VIEW_GAME_OPTIONS, VK_O); initMenuItem(gamePlayerSettings, menu, VIEW_PLAYER_SETTINGS); - menu.addSeparator(); initMenuItem(fileUnitsCopy, menu, FILE_UNITS_COPY); fileUnitsCopy.setAccelerator(KeyStroke.getKeyStroke(VK_C, CTRL_DOWN_MASK)); initMenuItem(fileUnitsPaste, menu, FILE_UNITS_PASTE); @@ -200,7 +208,7 @@ public CommonMenuBar() { initMenuItem(fireSaveWeaponOrder, menu, FIRE_SAVE_WEAPON_ORDER); // Create the Board sub-menu. - menu = new JMenu(getString("CommonMenuBar.BoardMenu")); + menu = new JMenu(MSG_BOARDMENU); menu.setMnemonic(VK_B); add(menu); initMenuItem(boardNew, menu, BOARD_NEW); @@ -212,9 +220,9 @@ public CommonMenuBar() { menu.addSeparator(); initMenuItem(boardSaveAsImage, menu, BOARD_SAVE_AS_IMAGE); - boardSaveAsImage.setToolTipText(getString("CommonMenuBar.fileBoardSaveAsImage.tooltip")); + boardSaveAsImage.setToolTipText(MSG_FILEBOARDSAVEASIMAGE_TOOLTIP); initMenuItem(boardSaveAsImageUnits, menu, BOARD_SAVE_AS_IMAGE_UNITS); - boardSaveAsImageUnits.setToolTipText(getString("CommonMenuBar.fileBoardSaveAsImageUnits.tooltip")); + boardSaveAsImageUnits.setToolTipText(MSG_FILEBOARDSAVEASIMAGEUNITS_TOOLTIP); menu.addSeparator(); initMenuItem(boardUndo, menu, BOARD_UNDO); @@ -227,7 +235,7 @@ public CommonMenuBar() { initMenuItem(boardClear, menu, BOARD_CLEAR); initMenuItem(boardFlatten, menu, BOARD_FLATTEN); initMenuItem(boardFlood, menu, BOARD_FLOOD); - boardRemove = new JMenu(getString("CommonMenuBar.boardRemove")); + boardRemove = new JMenu(MSG_BOARDREMOVE); menu.add(boardRemove); initMenuItem(boardRemoveForests, boardRemove, BOARD_REMOVE_FORESTS); initMenuItem(boardRemoveWater, boardRemove, BOARD_REMOVE_WATER); @@ -235,26 +243,40 @@ public CommonMenuBar() { initMenuItem(boardRemoveBuildings, boardRemove, BOARD_REMOVE_BUILDINGS); // Create the view menu. - menu = new JMenu(getString("CommonMenuBar.ViewMenu")); + menu = new JMenu(MSG_VIEWMENU); menu.setMnemonic(VK_V); add(menu); initMenuItem(viewClientSettings, menu, VIEW_CLIENT_SETTINGS, VK_S); initMenuItem(viewIncGUIScale, menu, VIEW_INCGUISCALE); initMenuItem(viewDecGUIScale, menu, VIEW_DECGUISCALE); menu.addSeparator(); - - initMenuItem(viewResetWindowPositions, menu, VIEW_RESET_WINDOW_POSITIONS); - initMenuItem(viewAccessibilityWindow, menu, VIEW_ACCESSIBILITY_WINDOW, VK_A); - viewAccessibilityWindow.setMnemonic(KeyEvent.VK_A); + + initMenuItem(viewMekDisplay, menu, VIEW_UNIT_DISPLAY, VK_D); + GUIP.setUnitDisplayEnabled(false); + viewMekDisplay.setSelected(false); + initMenuItem(viewMinimap, menu, VIEW_MINI_MAP, VK_M); + GUIP.setMinimapEnabled(false); + viewMinimap.setSelected(false); + initMenuItem(gameRoundReport, menu, VIEW_ROUND_REPORT); + GUIP.setMiniReportEnabled(false); + gameRoundReport.setSelected(false); + initMenuItem(gamePlayerList, menu, VIEW_PLAYER_LIST); + GUIP.setPlayerListEnabled(false); + gamePlayerList.setSelected(false); menu.addSeparator(); - + initMenuItem(viewKeybindsOverlay, menu, VIEW_KEYBINDS_OVERLAY); viewKeybindsOverlay.setSelected(GUIP.getBoolean(GUIPreferences.SHOW_KEYBINDS_OVERLAY)); - initMenuItem(viewPlanetaryConditionsOverlay, menu, VIEW_PLANETARYCONDITIONS_OVERLAY); viewPlanetaryConditionsOverlay.setSelected(GUIP.getBoolean(GUIPreferences.SHOW_PLANETARYCONDITIONS_OVERLAY)); - initMenuItem(viewUnitOverview, menu, VIEW_UNIT_OVERVIEW); + menu.addSeparator(); + + initMenuItem(viewResetWindowPositions, menu, VIEW_RESET_WINDOW_POSITIONS); + initMenuItem(viewAccessibilityWindow, menu, VIEW_ACCESSIBILITY_WINDOW, VK_A); + viewAccessibilityWindow.setMnemonic(KeyEvent.VK_A); + menu.addSeparator(); + viewUnitOverview.setSelected(GUIP.getShowUnitOverview()); initMenuItem(viewZoomIn, menu, VIEW_ZOOM_IN); initMenuItem(viewZoomOut, menu, VIEW_ZOOM_OUT); @@ -264,15 +286,9 @@ public CommonMenuBar() { initMenuItem(viewLabels, menu, VIEW_LABELS); menu.addSeparator(); - initMenuItem(viewMekDisplay, menu, VIEW_UNIT_DISPLAY, VK_D); - viewMekDisplay.setSelected(GUIP.getBoolean(GUIPreferences.SHOW_UNIT_DISPLAY)); - initMenuItem(viewMinimap, menu, VIEW_MINI_MAP, VK_M); - viewMinimap.setSelected(GUIP.getMinimapEnabled()); - menu.addSeparator(); - initMenuItem(toggleFovDarken, menu, VIEW_TOGGLE_FOV_DARKEN); toggleFovDarken.setSelected(GUIP.getFovDarken()); - toggleFovDarken.setToolTipText(getString("CommonMenuBar.viewToggleFovDarkenTooltip")); + toggleFovDarken.setToolTipText(MSG_VIEWTOGGLEFOVDARKENTOOLTIP); initMenuItem(viewLOSSetting, menu, VIEW_LOS_SETTING); initMenuItem(toggleFovHighlight, menu, VIEW_TOGGLE_FOV_HIGHLIGHT); toggleFovHighlight.setSelected(GUIP.getFovHighlight()); @@ -283,15 +299,15 @@ public CommonMenuBar() { initMenuItem(toggleFieldOfFire, menu, VIEW_TOGGLE_FIELD_OF_FIRE); toggleFieldOfFire.setSelected(GUIP.getShowFieldOfFire()); - toggleFieldOfFire.setToolTipText(getString("CommonMenuBar.viewToggleFieldOfFireToolTip")); + toggleFieldOfFire.setToolTipText(MSG_VIEWTOGGLEFIELDOFFIRETOOLTIP); initMenuItem(toggleFiringSolutions, menu, VIEW_TOGGLE_FIRING_SOLUTIONS); - toggleFiringSolutions.setToolTipText(getString("CommonMenuBar.viewToggleFiringSolutionsToolTip")); + toggleFiringSolutions.setToolTipText(MSG_VIEWTOGGLEFIRINGSOLUTIONSTOOLTIP); toggleFiringSolutions.setSelected(GUIP.getFiringSolutions()); /* TODO: moveTraitor = createMenuItem(menu, getString("CommonMenuBar.moveTraitor"), MovementDisplay.MOVE_TRAITOR); */ // Create the Help menu - menu = new JMenu(getString("CommonMenuBar.HelpMenu")); + menu = new JMenu(MSG_HELPMENU); menu.setMnemonic(VK_H); add(menu); initMenuItem(helpContents, menu, HELP_CONTENTS); @@ -349,22 +365,12 @@ public void actionPerformed(ActionEvent event) { if (guiScale > ClientGUI.MIN_GUISCALE) { GUIP.setValue(GUIPreferences.GUI_SCALE, guiScale - 0.1); } - } else if (event.getActionCommand().equals(ClientGUI.VIEW_MINI_MAP)) { - GUIP.setMinimapEnabled(!GUIP.getMinimapEnabled()); - - } else if (event.getActionCommand().equals(ClientGUI.VIEW_UNIT_DISPLAY)) { - GUIP.toggleUnitDisplay(); - - } else if (event.getActionCommand().equals(ClientGUI.VIEW_KEYBINDS_OVERLAY)) { - GUIP.toggleKeybindsOverlay(); - } else if (event.getActionCommand().equals(ClientGUI.VIEW_PLANETARYCONDITIONS_OVERLAY)) { GUIP.togglePlanetaryConditionsOverlay(); } else if (event.getActionCommand().equals(ClientGUI.VIEW_TOGGLE_HEXCOORDS)) { boolean coordsShown = GUIP.getBoolean(GUIPreferences.SHOW_COORDS); GUIP.setValue(GUIPreferences.SHOW_COORDS, !coordsShown); - } else if (event.getActionCommand().equals(ClientGUI.VIEW_LABELS)) { GUIP.setUnitLabelStyle(GUIP.getUnitLabelStyle().next()); } @@ -405,6 +411,7 @@ private synchronized void updateEnabledStates() { boolean isBoardView = isInGameBoardView || isBoardEditor; boolean canSave = !phase.isUnknown() && !phase.isSelection() && !phase.isExchange() && !phase.isVictory() && !phase.isStartingScenario(); + boolean isNotVictory = !phase.isVictory(); viewAccessibilityWindow.setEnabled(false); @@ -437,8 +444,8 @@ private synchronized void updateEnabledStates() { boardOpen.setEnabled(isBoardEditor || isMainMenu); fileUnitsPaste.setEnabled(isLobby); fileUnitsCopy.setEnabled(isLobby); - fileUnitsReinforce.setEnabled(isLobby || isInGame); - fileUnitsReinforceRAT.setEnabled(isLobby || isInGame); + fileUnitsReinforce.setEnabled((isLobby || isInGame) && isNotVictory); + fileUnitsReinforceRAT.setEnabled((isLobby || isInGame) && isNotVictory); fileUnitsSave.setEnabled(isLobby || (isInGame && canSave)); fileUnitsBrowse.setEnabled(isMainMenu); boardSaveAsImageUnits.setEnabled(isInGame); @@ -464,7 +471,7 @@ private synchronized void updateEnabledStates() { toggleFiringSolutions.setEnabled(isInGameBoardView); viewMovementEnvelope.setEnabled(isInGameBoardView); viewMovModEnvelope.setEnabled(isInGameBoardView); - gameRoundReport.setEnabled((isInGame && canSave)); + gameRoundReport.setEnabled((isInGame)); viewMekDisplay.setEnabled(isInGameBoardView); fireSaveWeaponOrder.setEnabled(isInGameBoardView); } @@ -502,14 +509,18 @@ public void preferenceChange(PreferenceChangeEvent e) { viewUnitOverview.setSelected((Boolean) e.getNewValue()); } else if (e.getName().equals(GUIPreferences.GUI_SCALE)) { adaptToGUIScale(); - } else if (e.getName().equals(GUIPreferences.MINIMAP_ENABLED)) { + } else if (e.getName().equals(GUIPreferences.MINI_MAP_ENABLED)) { viewMinimap.setSelected(GUIP.getMinimapEnabled()); } else if (e.getName().equals(GUIPreferences.SHOW_COORDS)) { toggleHexCoords.setSelected(GUIP.getBoolean(GUIPreferences.SHOW_COORDS)); } else if (e.getName().equals(KeyBindParser.KEYBINDS_CHANGED)) { setKeyBinds(); - } else if (e.getName().equals(GUIPreferences.SHOW_UNIT_DISPLAY)) { - viewMekDisplay.setSelected(GUIP.getBoolean(GUIPreferences.SHOW_UNIT_DISPLAY)); + } else if (e.getName().equals(GUIPreferences.UNIT_DISPLAY_ENABLED)) { + viewMekDisplay.setSelected(GUIP.getUnitDisplayEnabled()); + } else if (e.getName().equals(GUIPreferences.MINI_REPORT_ENABLED)) { + gameRoundReport.setSelected(GUIP.getMiniReportEnabled()); + } else if (e.getName().equals(GUIPreferences.PLAYER_LIST_ENABLED)) { + gamePlayerList.setSelected(GUIP.getPlayerListEnabled()); } } @@ -535,6 +546,4 @@ private void initMenuItem(JMenuItem item, JMenu menu, String command, int mnemon initMenuItem(item, menu, command); item.setMnemonic(mnemonic); } - - } diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index eb4ce2a3c88..e9f1270a15f 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -35,6 +35,7 @@ import megamek.common.enums.WeaponSortOrder; import megamek.common.preference.ClientPreferences; import megamek.common.preference.PreferenceManager; +import org.apache.logging.log4j.LogManager; import javax.swing.*; import javax.swing.UIManager.LookAndFeelInfo; @@ -222,9 +223,17 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg private JComboBox tileSetChoice; private List tileSets; - private final MMToggleButton choiceToggle = new MMToggleButton("Enable tabbing through this dialog page"); + private JComboBox unitDisplayAutoDisplayReportCombo; + private JComboBox unitDisplayAutoDisplayNonReportCombo; + private JComboBox miniMapAutoDisplayReportCombo; + private JComboBox miniMapAutoDisplayNonReportCombo; + private JComboBox miniReportAutoDisplayReportCombo; + private JComboBox miniReportAutoDisplayNonReportCombo; + private JComboBox playerListAutoDisplayReportCombo; + private JComboBox playerListAutoDisplayNonReportCombo; + /** Maps command strings to a JTextField for updating the modifier for the command. */ private Map cmdModifierMap; @@ -236,6 +245,11 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg private ClientGUI clientgui = null; + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + private static final ClientPreferences CP = PreferenceManager.getClientPreferences(); + private static final UnitDisplayOrderPreferences UDOP = UnitDisplayOrderPreferences.getInstance(); + private static final ButtonOrderPreferences BOP = ButtonOrderPreferences.getInstance(); + private static final String[] LOCALE_CHOICES = { "en", "de", "ru", "es" }; private static final Dimension LABEL_SPACER = new Dimension(5, 0); @@ -262,8 +276,25 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg private int savedFovDarkenAlpha; private int savedNumStripesSlider; - private static final String MSG_REPORTKEYWORDS = Messages.getString("CommonSettingsDialog.ReportKeywords"); HashMap savedAdvancedOpt = new HashMap<>(); + + private static final String MSG_REPORTKEYWORDS = Messages.getString("CommonSettingsDialog.ReportKeywords"); + private static final String MSG_UNITDISPLAY = Messages.getString("CommonMenuBar.viewMekDisplay"); + private static final String MSG_MINIMAP = Messages.getString("CommonMenuBar.viewMinimap"); + private static final String MSG_MINIREPORT = Messages.getString("CommonMenuBar.viewRoundReport"); + private static final String MSG_PLAYERLIST = Messages.getString("CommonMenuBar.viewPlayerList"); + private static final String MSG_SHOW = Messages.getString("ClientGUI.Show"); + private static final String MSG_HIDE = Messages.getString("ClientGUI.Hide"); + private static final String MSG_MANUAL = Messages.getString("ClientGUI.Manual"); + private static final String MSG_REPORTPHASES = Messages.getString("CommonSettingsDialog.ReportPhases"); + private static final String MSG_NONREPORTPHASES = Messages.getString("CommonSettingsDialog.NonReportPhases"); + private static final String MSG_MAIN = Messages.getString("CommonSettingsDialog.Main"); + private static final String MSG_GRAPHICS = Messages.getString("CommonSettingsDialog.Graphics"); + private static final String MSG_KEYBINDS = Messages.getString("CommonSettingsDialog.KeyBinds"); + private static final String MSG_BUTTONORDER = Messages.getString("CommonSettingsDialog.ButtonOrder"); + private static final String MSG_UNITDISPLAYORDER = Messages.getString("CommonSettingsDialog.UnitDisplayOrder"); + private static final String MSG_AUTODISPLAY = Messages.getString("CommonSettingsDialog.AutoDisplay"); + private static final String MSG_ADVANCED = Messages.getString("CommonSettingsDialog.Advanced"); /** Constructs the Client Settings Dialog with a clientgui (used within the client, i.e. in lobby and game). */ public CommonSettingsDialog(JFrame owner, ClientGUI cg) { @@ -297,14 +328,16 @@ public void windowClosing(WindowEvent e) { advancedSettingsPane.getVerticalScrollBar().setUnitIncrement(16); JScrollPane unitDisplayPane = new JScrollPane(getUnitDisplayPanel()); unitDisplayPane.getVerticalScrollBar().setUnitIncrement(16); + JScrollPane autoDisplayPane = new JScrollPane(getPhasePanel()); + autoDisplayPane.getVerticalScrollBar().setUnitIncrement(16); - - panTabs.add("Main", settingsPane); - panTabs.add("Graphics", graphicsPane); - panTabs.add("Key Binds", keyBindPane); - panTabs.add("Button Order", getButtonOrderPanel()); - panTabs.add("Advanced", advancedSettingsPane); - panTabs.add("Unit Display Order", unitDisplayPane); + panTabs.add(MSG_MAIN, settingsPane); + panTabs.add(MSG_GRAPHICS, graphicsPane); + panTabs.add(MSG_KEYBINDS, keyBindPane); + panTabs.add(MSG_BUTTONORDER, getButtonOrderPanel()); + panTabs.add(MSG_UNITDISPLAYORDER, unitDisplayPane); + panTabs.add(MSG_AUTODISPLAY, autoDisplayPane); + panTabs.add(MSG_ADVANCED, advancedSettingsPane); adaptToGUIScale(); @@ -325,12 +358,12 @@ private JPanel getUnitDisplayPanel() { private JScrollPane getUnitDisplayPane() { JPanel panel = new JPanel(); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A1)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B1)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C1)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A2)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B2)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C2)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_A1)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_B1)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_C1)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_A2)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_B2)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_C2)); JList listUnitDisplayNonTabbed = new JList<>(unitDisplayNonTabbed); listUnitDisplayNonTabbed.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); @@ -552,80 +585,74 @@ private void addSpacer(List> comps, int height) { public void setVisible(boolean visible) { // Initialize the dialog when it's being shown if (visible) { - GUIPreferences gs = GUIPreferences.getInstance(); - ClientPreferences cs = PreferenceManager.getClientPreferences(); - - guiScale.setValue((int) (gs.getGUIScale() * 10)); - autoEndFiring.setSelected(gs.getAutoEndFiring()); - autoDeclareSearchlight.setSelected(gs.getAutoDeclareSearchlight()); - nagForMASC.setSelected(gs.getNagForMASC()); - nagForPSR.setSelected(gs.getNagForPSR()); - nagForWiGELanding.setSelected(gs.getNagForWiGELanding()); - nagForNoAction.setSelected(gs.getNagForNoAction()); - nagForNoUnJamRAC.setSelected(gs.getNagForNoUnJamRAC()); - animateMove.setSelected(gs.getShowMoveStep()); - showWrecks.setSelected(gs.getShowWrecks()); - soundMute.setSelected(gs.getSoundMute()); - tooltipDelay.setText(Integer.toString(gs.getTooltipDelay())); - tooltipDismissDelay.setText(Integer.toString(gs.getTooltipDismissDelay())); - tooltipDistSupression.setText(Integer.toString(gs.getTooltipDistSuppression())); - showWpsinTT.setSelected(gs.getShowWpsinTT()); - showArmorMiniVisTT.setSelected(gs.getshowArmorMiniVisTT()); - showPilotPortraitTT.setSelected(gs.getshowPilotPortraitTT()); - comboDefaultWeaponSortOrder.setSelectedItem(gs.getDefaultWeaponSortOrder()); - mouseWheelZoom.setSelected(gs.getMouseWheelZoom()); - mouseWheelZoomFlip.setSelected(gs.getMouseWheelZoomFlip()); + guiScale.setValue((int) (GUIP.getGUIScale() * 10)); + autoEndFiring.setSelected(GUIP.getAutoEndFiring()); + autoDeclareSearchlight.setSelected(GUIP.getAutoDeclareSearchlight()); + nagForMASC.setSelected(GUIP.getNagForMASC()); + nagForPSR.setSelected(GUIP.getNagForPSR()); + nagForWiGELanding.setSelected(GUIP.getNagForWiGELanding()); + nagForNoAction.setSelected(GUIP.getNagForNoAction()); + nagForNoUnJamRAC.setSelected(GUIP.getNagForNoUnJamRAC()); + animateMove.setSelected(GUIP.getShowMoveStep()); + showWrecks.setSelected(GUIP.getShowWrecks()); + soundMute.setSelected(GUIP.getSoundMute()); + tooltipDelay.setText(Integer.toString(GUIP.getTooltipDelay())); + tooltipDismissDelay.setText(Integer.toString(GUIP.getTooltipDismissDelay())); + tooltipDistSupression.setText(Integer.toString(GUIP.getTooltipDistSuppression())); + showWpsinTT.setSelected(GUIP.getShowWpsinTT()); + showArmorMiniVisTT.setSelected(GUIP.getshowArmorMiniVisTT()); + showPilotPortraitTT.setSelected(GUIP.getshowPilotPortraitTT()); + comboDefaultWeaponSortOrder.setSelectedItem(GUIP.getDefaultWeaponSortOrder()); + mouseWheelZoom.setSelected(GUIP.getMouseWheelZoom()); + mouseWheelZoomFlip.setSelected(GUIP.getMouseWheelZoomFlip()); // Select the correct char set (give a nice default to start). unitStartChar.setSelectedIndex(0); for (int loop = 0; loop < unitStartChar.getItemCount(); loop++) { - if (unitStartChar.getItemAt(loop).charAt(0) == PreferenceManager - .getClientPreferences().getUnitStartChar()) { + if (unitStartChar.getItemAt(loop).charAt(0) == CP.getUnitStartChar()) { unitStartChar.setSelectedIndex(loop); break; } } - maxPathfinderTime.setText(Integer.toString(cs.getMaxPathfinderTime())); + maxPathfinderTime.setText(Integer.toString(CP.getMaxPathfinderTime())); - keepGameLog.setSelected(cs.keepGameLog()); + keepGameLog.setSelected(CP.keepGameLog()); gameLogFilename.setEnabled(keepGameLog.isSelected()); - gameLogFilename.setText(cs.getGameLogFilename()); - // gameLogMaxSize.setEnabled(keepGameLog.isSelected()); - // gameLogMaxSize.setText( Integer.toString(cs.getGameLogMaxSize()) ); - stampFilenames.setSelected(cs.stampFilenames()); + gameLogFilename.setText(CP.getGameLogFilename()); + stampFilenames.setSelected(CP.stampFilenames()); stampFormat.setEnabled(stampFilenames.isSelected()); - stampFormat.setText(cs.getStampFormat()); - reportKeywordsTextPane.setText(cs.getReportKeywords()); - showIPAddressesInChat.setSelected(cs.getShowIPAddressesInChat()); + stampFormat.setText(CP.getStampFormat()); + reportKeywordsTextPane.setText(CP.getReportKeywords()); + showIPAddressesInChat.setSelected(CP.getShowIPAddressesInChat()); - defaultAutoejectDisabled.setSelected(cs.defaultAutoejectDisabled()); - useAverageSkills.setSelected(cs.useAverageSkills()); - generateNames.setSelected(cs.generateNames()); - showUnitId.setSelected(cs.getShowUnitId()); + defaultAutoejectDisabled.setSelected(CP.defaultAutoejectDisabled()); + useAverageSkills.setSelected(CP.useAverageSkills()); + generateNames.setSelected(CP.generateNames()); + showUnitId.setSelected(CP.getShowUnitId()); int index = 0; - if (cs.getLocaleString().startsWith("de")) { + if (CP.getLocaleString().startsWith("de")) { index = 1; } - if (cs.getLocaleString().startsWith("ru")) { + if (CP.getLocaleString().startsWith("ru")) { index = 2; } displayLocale.setSelectedIndex(index); - showMapsheets.setSelected(gs.getShowMapsheets()); - chkAntiAliasing.setSelected(gs.getAntiAliasing()); - showDamageLevel.setSelected(gs.getShowDamageLevel()); - showDamageDecal.setSelected(gs.getShowDamageDecal()); - aOHexShadows.setSelected(gs.getAOHexShadows()); - floatingIso.setSelected(gs.getFloatingIso()); - mmSymbol.setSelected(gs.getMmSymbol()); - levelhighlight.setSelected(gs.getLevelHighlight()); - shadowMap.setSelected(gs.getShadowMap()); - hexInclines.setSelected(gs.getHexInclines()); - useSoftCenter.setSelected(gs.getBoolean("SOFTCENTER")); - entityOwnerColor.setSelected(gs.getUnitLabelBorder()); - teamColoring.setSelected(gs.getTeamColoring()); + showMapsheets.setSelected(GUIP.getShowMapsheets()); + chkAntiAliasing.setSelected(GUIP.getAntiAliasing()); + showDamageLevel.setSelected(GUIP.getShowDamageLevel()); + showDamageDecal.setSelected(GUIP.getShowDamageDecal()); + aOHexShadows.setSelected(GUIP.getAOHexShadows()); + floatingIso.setSelected(GUIP.getFloatingIso()); + mmSymbol.setSelected(GUIP.getMmSymbol()); + levelhighlight.setSelected(GUIP.getLevelHighlight()); + shadowMap.setSelected(GUIP.getShadowMap()); + hexInclines.setSelected(GUIP.getHexInclines()); + useSoftCenter.setSelected(GUIP.getBoolean("SOFTCENTER")); + entityOwnerColor.setSelected(GUIP.getUnitLabelBorder()); + teamColoring.setSelected(GUIP.getTeamColoring()); File dir = Configuration.hexesDir(); tileSets = new ArrayList<>(Arrays.asList(dir.list((direc, name) -> name.endsWith(".tileset")))); @@ -634,13 +661,13 @@ public void setVisible(boolean visible) { for (int i = 0; i < tileSets.size(); i++) { String name = tileSets.get(i); tileSetChoice.addItem(name.substring(0, name.length() - 8)); - if (name.equals(cs.getMapTileset())) { + if (name.equals(CP.getMapTileset())) { tileSetChoice.setSelectedIndex(i); } } - gameSummaryBV.setSelected(gs.getGameSummaryBoardView()); - gameSummaryMM.setSelected(gs.getGameSummaryMinimap()); + gameSummaryBV.setSelected(GUIP.getGameSummaryBoardView()); + gameSummaryMM.setSelected(GUIP.getGameSummaryMinimap()); skinFiles.removeAllItems(); List xmlFiles = new ArrayList<>(Arrays @@ -655,22 +682,22 @@ public void setVisible(boolean visible) { // Select the default file first skinFiles.setSelectedItem(SkinXMLHandler.defaultSkinXML); // If this select fails, the default skin will be selected - skinFiles.setSelectedItem(GUIPreferences.getInstance().getSkinFile()); + skinFiles.setSelectedItem(GUIP.getSkinFile()); uiThemes.removeAllItems(); for (LookAndFeelInfo lafInfo : UIManager.getInstalledLookAndFeels()) { uiThemes.addItem(new UITheme(lafInfo.getClassName(), lafInfo.getName())); } - uiThemes.setSelectedItem(new UITheme(GUIPreferences.getInstance().getUITheme())); + uiThemes.setSelectedItem(new UITheme(GUIP.getUITheme())); - fovInsideEnabled.setSelected(gs.getFovHighlight()); - fovHighlightAlpha.setValue(gs.getFovHighlightAlpha()); - fovHighlightRingsRadii.setText( gs.getFovHighlightRingsRadii()); - fovHighlightRingsColors.setText( gs.getFovHighlightRingsColorsHsb() ); - fovOutsideEnabled.setSelected(gs.getFovDarken()); - fovDarkenAlpha.setValue(gs.getFovDarkenAlpha()); - numStripesSlider.setValue(gs.getFovStripes()); - fovGrayscaleEnabled.setSelected(gs.getFovGrayscale()); + fovInsideEnabled.setSelected(GUIP.getFovHighlight()); + fovHighlightAlpha.setValue(GUIP.getFovHighlightAlpha()); + fovHighlightRingsRadii.setText(GUIP.getFovHighlightRingsRadii()); + fovHighlightRingsColors.setText(GUIP.getFovHighlightRingsColorsHsb() ); + fovOutsideEnabled.setSelected(GUIP.getFovDarken()); + fovDarkenAlpha.setValue(GUIP.getFovDarkenAlpha()); + numStripesSlider.setValue(GUIP.getFovStripes()); + fovGrayscaleEnabled.setSelected(GUIP.getFovGrayscale()); fovHighlightAlpha.setEnabled(fovInsideEnabled.isSelected()); fovHighlightRingsRadii.setEnabled(fovInsideEnabled.isSelected()); @@ -688,27 +715,27 @@ public void setVisible(boolean visible) { stampFormatLabel.setEnabled(stampFilenames.isSelected()); gameLogFilenameLabel.setEnabled(keepGameLog.isSelected()); - getFocus.setSelected(gs.getFocus()); + getFocus.setSelected(GUIP.getFocus()); - savedFovHighlight = gs.getFovHighlight(); - savedFovDarken = gs.getFovDarken(); - savedFovGrayscale = gs.getFovGrayscale(); - savedAOHexShadows = gs.getAOHexShadows(); - savedShadowMap = gs.getShadowMap(); - savedHexInclines = gs.getHexInclines(); - savedLevelhighlight = gs.getLevelHighlight(); - savedFloatingIso = gs.getFloatingIso(); - savedMmSymbol = gs.getMmSymbol(); - savedTeamColoring = gs.getTeamColoring(); - savedUnitLabelBorder = gs.getUnitLabelBorder(); - savedShowDamageDecal = gs.getShowDamageDecal(); - savedShowDamageLabel = gs.getShowDamageLevel(); - savedFovHighlightRingsRadii = gs.getFovHighlightRingsRadii(); - savedFovHighlightRingsColors = gs.getFovHighlightRingsColorsHsb(); - savedFovHighlightAlpha = gs.getFovHighlightAlpha(); - savedFovDarkenAlpha = gs.getFovDarkenAlpha(); - savedNumStripesSlider = gs.getFovStripes(); - savedAntiAlias = gs.getAntiAliasing(); + savedFovHighlight = GUIP.getFovHighlight(); + savedFovDarken = GUIP.getFovDarken(); + savedFovGrayscale = GUIP.getFovGrayscale(); + savedAOHexShadows = GUIP.getAOHexShadows(); + savedShadowMap = GUIP.getShadowMap(); + savedHexInclines = GUIP.getHexInclines(); + savedLevelhighlight = GUIP.getLevelHighlight(); + savedFloatingIso = GUIP.getFloatingIso(); + savedMmSymbol = GUIP.getMmSymbol(); + savedTeamColoring = GUIP.getTeamColoring(); + savedUnitLabelBorder = GUIP.getUnitLabelBorder(); + savedShowDamageDecal = GUIP.getShowDamageDecal(); + savedShowDamageLabel = GUIP.getShowDamageLevel(); + savedFovHighlightRingsRadii = GUIP.getFovHighlightRingsRadii(); + savedFovHighlightRingsColors = GUIP.getFovHighlightRingsColorsHsb(); + savedFovHighlightAlpha = GUIP.getFovHighlightAlpha(); + savedFovDarkenAlpha = GUIP.getFovDarkenAlpha(); + savedNumStripesSlider = GUIP.getFovStripes(); + savedAntiAlias = GUIP.getAntiAliasing(); savedAdvancedOpt.clear(); advancedKeys.clearSelection(); @@ -728,38 +755,46 @@ public void setVisible(boolean visible) { /** Cancels any updates made in this dialog and closes it. */ @Override protected void cancelAction() { - GUIPreferences guip = GUIPreferences.getInstance(); - guip.setFovHighlight(savedFovHighlight); - guip.setFovDarken(savedFovDarken); - guip.setFovGrayscale(savedFovGrayscale); - guip.setAOHexShadows(savedAOHexShadows); - guip.setShadowMap(savedShadowMap); - guip.setHexInclines(savedHexInclines); - guip.setLevelHighlight(savedLevelhighlight); - guip.setFloatingIso(savedFloatingIso); - guip.setMmSymbol(savedMmSymbol); - guip.setTeamColoring(savedTeamColoring); - guip.setUnitLabelBorder(savedUnitLabelBorder); - guip.setShowDamageDecal(savedShowDamageDecal); - guip.setShowDamageLevel(savedShowDamageLabel); - guip.setFovHighlightRingsRadii(savedFovHighlightRingsRadii); - guip.setFovHighlightRingsColorsHsb(savedFovHighlightRingsColors); - guip.setFovHighlightAlpha(savedFovHighlightAlpha); - guip.setFovDarkenAlpha(savedFovDarkenAlpha); - guip.setFovStripes(savedNumStripesSlider); - guip.setAntiAliasing(savedAntiAlias); + GUIP.setFovHighlight(savedFovHighlight); + GUIP.setFovDarken(savedFovDarken); + GUIP.setFovGrayscale(savedFovGrayscale); + GUIP.setAOHexShadows(savedAOHexShadows); + GUIP.setShadowMap(savedShadowMap); + GUIP.setHexInclines(savedHexInclines); + GUIP.setLevelHighlight(savedLevelhighlight); + GUIP.setFloatingIso(savedFloatingIso); + GUIP.setMmSymbol(savedMmSymbol); + GUIP.setTeamColoring(savedTeamColoring); + GUIP.setUnitLabelBorder(savedUnitLabelBorder); + GUIP.setShowDamageDecal(savedShowDamageDecal); + GUIP.setShowDamageLevel(savedShowDamageLabel); + GUIP.setFovHighlightRingsRadii(savedFovHighlightRingsRadii); + GUIP.setFovHighlightRingsColorsHsb(savedFovHighlightRingsColors); + GUIP.setFovHighlightAlpha(savedFovHighlightAlpha); + GUIP.setFovDarkenAlpha(savedFovDarkenAlpha); + GUIP.setFovStripes(savedNumStripesSlider); + GUIP.setAntiAliasing(savedAntiAlias); for (String option: savedAdvancedOpt.keySet()) { - GUIPreferences.getInstance().setValue(option, savedAdvancedOpt.get(option)); + GUIP.setValue(option, savedAdvancedOpt.get(option)); } unitDisplayNonTabbed.clear(); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A1)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B1)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C1)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A2)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B2)); - unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C2)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_A1)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_B1)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_C1)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_A2)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_B2)); + unitDisplayNonTabbed.addElement(UDOP.getString(UnitDisplay.NON_TABBED_C2)); + + unitDisplayAutoDisplayReportCombo.setSelectedItem(GUIP.getUnitDisplayAutoDisplayReportPhase()); + unitDisplayAutoDisplayNonReportCombo.setSelectedItem(GUIP.getUnitDisplayAutoDisplayNonReportPhase()); + miniMapAutoDisplayReportCombo.setSelectedItem(GUIP.getMinimapAutoDisplayReportPhase()); + miniMapAutoDisplayNonReportCombo.setSelectedItem(GUIP.getMinimapAutoDisplayNonReportPhase()); + miniReportAutoDisplayReportCombo.setSelectedItem(GUIP.getMiniReportAutoDisplayReportPhase()); + miniReportAutoDisplayNonReportCombo.setSelectedItem(GUIP.getMiniReportAutoDisplayNonReportPhase()); + playerListAutoDisplayReportCombo.setSelectedItem(GUIP.getPlayerListAutoDisplayReportPhase()); + playerListAutoDisplayNonReportCombo.setSelectedItem(GUIP.getPlayerListAutoDisplayNonReportPhase()); setVisible(false); } @@ -767,77 +802,89 @@ protected void cancelAction() { /** Update the settings from this dialog's values, then close it. */ @Override protected void okAction() { - GUIPreferences gs = GUIPreferences.getInstance(); - ClientPreferences cs = PreferenceManager.getClientPreferences(); - - gs.setShowDamageLevel(showDamageLevel.isSelected()); - gs.setShowDamageDecal(showDamageDecal.isSelected()); - gs.setUnitLabelBorder(entityOwnerColor.isSelected()); - gs.setTeamColoring(teamColoring.isSelected()); - gs.setAutoEndFiring(autoEndFiring.isSelected()); - gs.setAutoDeclareSearchlight(autoDeclareSearchlight.isSelected()); - gs.setDefaultWeaponSortOrder(Objects.requireNonNull(comboDefaultWeaponSortOrder.getSelectedItem())); - gs.setNagForMASC(nagForMASC.isSelected()); - gs.setNagForPSR(nagForPSR.isSelected()); - gs.setNagForWiGELanding(nagForWiGELanding.isSelected()); - gs.setNagForNoAction(nagForNoAction.isSelected()); - gs.setNagForNoUnJamRAC(nagForNoUnJamRAC.isSelected()); - gs.setShowMoveStep(animateMove.isSelected()); - gs.setShowWrecks(showWrecks.isSelected()); - gs.setSoundMute(soundMute.isSelected()); - gs.setShowWpsinTT(showWpsinTT.isSelected()); - gs.setshowArmorMiniVisTT(showArmorMiniVisTT.isSelected()); - gs.setshowPilotPortraitTT(showPilotPortraitTT.isSelected()); - gs.setTooltipDelay(Integer.parseInt(tooltipDelay.getText())); - gs.setTooltipDismissDelay(Integer.parseInt(tooltipDismissDelay.getText())); - gs.setTooltipDistSuppression(Integer.parseInt(tooltipDistSupression.getText())); - gs.setValue(GUIPreferences.GUI_SCALE, (float) (guiScale.getValue()) / 10); - cs.setUnitStartChar(((String) unitStartChar.getSelectedItem()).charAt(0)); - - gs.setMouseWheelZoom(mouseWheelZoom.isSelected()); - gs.setMouseWheelZoomFlip(mouseWheelZoomFlip.isSelected()); + GUIP.setShowDamageLevel(showDamageLevel.isSelected()); + GUIP.setShowDamageDecal(showDamageDecal.isSelected()); + GUIP.setUnitLabelBorder(entityOwnerColor.isSelected()); + GUIP.setTeamColoring(teamColoring.isSelected()); + GUIP.setAutoEndFiring(autoEndFiring.isSelected()); + GUIP.setAutoDeclareSearchlight(autoDeclareSearchlight.isSelected()); + GUIP.setDefaultWeaponSortOrder(Objects.requireNonNull(comboDefaultWeaponSortOrder.getSelectedItem())); + GUIP.setNagForMASC(nagForMASC.isSelected()); + GUIP.setNagForPSR(nagForPSR.isSelected()); + GUIP.setNagForWiGELanding(nagForWiGELanding.isSelected()); + GUIP.setNagForNoAction(nagForNoAction.isSelected()); + GUIP.setNagForNoUnJamRAC(nagForNoUnJamRAC.isSelected()); + GUIP.setShowMoveStep(animateMove.isSelected()); + GUIP.setShowWrecks(showWrecks.isSelected()); + GUIP.setSoundMute(soundMute.isSelected()); + GUIP.setShowWpsinTT(showWpsinTT.isSelected()); + GUIP.setshowArmorMiniVisTT(showArmorMiniVisTT.isSelected()); + GUIP.setshowPilotPortraitTT(showPilotPortraitTT.isSelected()); + try { + GUIP.setTooltipDelay(Integer.parseInt(tooltipDelay.getText())); + } catch (Exception ex) { + LogManager.getLogger().error("", ex); + } + try { + GUIP.setTooltipDismissDelay(Integer.parseInt(tooltipDismissDelay.getText())); + } catch (Exception ex) { + LogManager.getLogger().error("", ex); + } + try { + GUIP.setTooltipDistSuppression(Integer.parseInt(tooltipDistSupression.getText())); + } catch (Exception ex) { + LogManager.getLogger().error("", ex); + } + GUIP.setValue(GUIPreferences.GUI_SCALE, (float) (guiScale.getValue()) / 10); + CP.setUnitStartChar(((String) unitStartChar.getSelectedItem()).charAt(0)); + + GUIP.setMouseWheelZoom(mouseWheelZoom.isSelected()); + GUIP.setMouseWheelZoomFlip(mouseWheelZoomFlip.isSelected()); - cs.setMaxPathfinderTime(Integer.parseInt(maxPathfinderTime.getText())); + try { + CP.setMaxPathfinderTime(Integer.parseInt(maxPathfinderTime.getText())); + } catch (Exception ex) { + LogManager.getLogger().error("", ex); + } - gs.setGetFocus(getFocus.isSelected()); + GUIP.setGetFocus(getFocus.isSelected()); - cs.setKeepGameLog(keepGameLog.isSelected()); - cs.setGameLogFilename(gameLogFilename.getText()); - // cs.setGameLogMaxSize(Integer.parseInt(gameLogMaxSize.getText())); - cs.setStampFilenames(stampFilenames.isSelected()); - cs.setStampFormat(stampFormat.getText()); - cs.setReportKeywords(reportKeywordsTextPane.getText()); - cs.setShowIPAddressesInChat(showIPAddressesInChat.isSelected()); + CP.setKeepGameLog(keepGameLog.isSelected()); + CP.setGameLogFilename(gameLogFilename.getText()); + CP.setStampFilenames(stampFilenames.isSelected()); + CP.setStampFormat(stampFormat.getText()); + CP.setReportKeywords(reportKeywordsTextPane.getText()); + CP.setShowIPAddressesInChat(showIPAddressesInChat.isSelected()); - cs.setDefaultAutoejectDisabled(defaultAutoejectDisabled.isSelected()); - cs.setUseAverageSkills(useAverageSkills.isSelected()); - cs.setGenerateNames(generateNames.isSelected()); - cs.setShowUnitId(showUnitId.isSelected()); + CP.setDefaultAutoejectDisabled(defaultAutoejectDisabled.isSelected()); + CP.setUseAverageSkills(useAverageSkills.isSelected()); + CP.setGenerateNames(generateNames.isSelected()); + CP.setShowUnitId(showUnitId.isSelected()); if ((clientgui != null) && (clientgui.getBoardView() != null)) { clientgui.getBoardView().updateEntityLabels(); } - cs.setLocale(CommonSettingsDialog.LOCALE_CHOICES[displayLocale.getSelectedIndex()]); + CP.setLocale(CommonSettingsDialog.LOCALE_CHOICES[displayLocale.getSelectedIndex()]); - gs.setShowMapsheets(showMapsheets.isSelected()); - gs.setAOHexShadows(aOHexShadows.isSelected()); - gs.setFloatingIso(floatingIso.isSelected()); - gs.setMmSymbol(mmSymbol.isSelected()); - gs.setLevelHighlight(levelhighlight.isSelected()); - gs.setShadowMap(shadowMap.isSelected()); - gs.setHexInclines(hexInclines.isSelected()); - gs.setValue("SOFTCENTER", useSoftCenter.isSelected()); - gs.setGameSummaryBoardView(gameSummaryBV.isSelected()); - gs.setGameSummaryMinimap(gameSummaryMM.isSelected()); + GUIP.setShowMapsheets(showMapsheets.isSelected()); + GUIP.setAOHexShadows(aOHexShadows.isSelected()); + GUIP.setFloatingIso(floatingIso.isSelected()); + GUIP.setMmSymbol(mmSymbol.isSelected()); + GUIP.setLevelHighlight(levelhighlight.isSelected()); + GUIP.setShadowMap(shadowMap.isSelected()); + GUIP.setHexInclines(hexInclines.isSelected()); + GUIP.setValue("SOFTCENTER", useSoftCenter.isSelected()); + GUIP.setGameSummaryBoardView(gameSummaryBV.isSelected()); + GUIP.setGameSummaryMinimap(gameSummaryMM.isSelected()); UITheme newUITheme = (UITheme) uiThemes.getSelectedItem(); - String oldUITheme = gs.getUITheme(); + String oldUITheme = GUIP.getUITheme(); if (!oldUITheme.equals(newUITheme.getClassName())) { - gs.setUITheme(newUITheme.getClassName()); + GUIP.setUITheme(newUITheme.getClassName()); } String newSkinFile = (String) skinFiles.getSelectedItem(); - String oldSkinFile = gs.getSkinFile(); + String oldSkinFile = GUIP.getSkinFile(); if (!oldSkinFile.equals(newSkinFile)) { boolean success = SkinXMLHandler.initSkinXMLHandler(newSkinFile); if (!success) { @@ -846,22 +893,22 @@ protected void okAction() { String msg = Messages.getString("CommonSettingsDialog.skinFileFail.msg"); JOptionPane.showMessageDialog(getFrame(), msg, title, JOptionPane.ERROR_MESSAGE); } else { - gs.setSkinFile(newSkinFile); + GUIP.setSkinFile(newSkinFile); } } if (tileSetChoice.getSelectedIndex() >= 0) { String tileSetFileName = tileSets.get(tileSetChoice.getSelectedIndex()); - if (!cs.getMapTileset().equals(tileSetFileName) && + if (!CP.getMapTileset().equals(tileSetFileName) && (clientgui != null) && (clientgui.getBoardView() != null)) { clientgui.getBoardView().clearShadowMap(); } - cs.setMapTileset(tileSetFileName); + CP.setMapTileset(tileSetFileName); } - ToolTipManager.sharedInstance().setInitialDelay(gs.getTooltipDelay()); - if (gs.getTooltipDismissDelay() > 0) { - ToolTipManager.sharedInstance().setDismissDelay(gs.getTooltipDismissDelay()); + ToolTipManager.sharedInstance().setInitialDelay(GUIP.getTooltipDelay()); + if (GUIP.getTooltipDismissDelay() > 0) { + ToolTipManager.sharedInstance().setDismissDelay(GUIP.getTooltipDismissDelay()); } // Check if any keybinds have changed and, if so, save them @@ -880,13 +927,12 @@ protected void okAction() { // Button Order // Movement - ButtonOrderPreferences bop = ButtonOrderPreferences.getInstance(); boolean buttonOrderChanged = false; for (int i = 0; i < movePhaseCommands.getSize(); i++) { StatusBarPhaseDisplay.PhaseCommand cmd = movePhaseCommands.get(i); if (cmd.getPriority() != i) { cmd.setPriority(i); - bop.setValue(cmd.getCmd(), i); + BOP.setValue(cmd.getCmd(), i); buttonOrderChanged = true; } } @@ -902,7 +948,7 @@ protected void okAction() { StatusBarPhaseDisplay.PhaseCommand cmd = deployPhaseCommands.get(i); if (cmd.getPriority() != i) { cmd.setPriority(i); - bop.setValue(cmd.getCmd(), i); + BOP.setValue(cmd.getCmd(), i); buttonOrderChanged = true; } } @@ -918,7 +964,7 @@ protected void okAction() { StatusBarPhaseDisplay.PhaseCommand cmd = firingPhaseCommands.get(i); if (cmd.getPriority() != i) { cmd.setPriority(i); - bop.setValue(cmd.getCmd(), i); + BOP.setValue(cmd.getCmd(), i); buttonOrderChanged = true; } } @@ -934,7 +980,7 @@ protected void okAction() { StatusBarPhaseDisplay.PhaseCommand cmd = physicalPhaseCommands.get(i); if (cmd.getPriority() != i) { cmd.setPriority(i); - bop.setValue(cmd.getCmd(), i); + BOP.setValue(cmd.getCmd(), i); buttonOrderChanged = true; } } @@ -950,7 +996,7 @@ protected void okAction() { StatusBarPhaseDisplay.PhaseCommand cmd = targetingPhaseCommands.get(i); if (cmd.getPriority() != i) { cmd.setPriority(i); - bop.setValue(cmd.getCmd(), i); + BOP.setValue(cmd.getCmd(), i); buttonOrderChanged = true; } } @@ -961,33 +1007,33 @@ protected void okAction() { } // unit display non tabbed - if (!GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (!GUIP.getUnitDisplayStartTabbed()) { boolean unitDisplayNonTabbedChanged = false; int s = unitDisplayNonTabbed.getSize(); - if ((s > UnitDisplay.NON_TABBED_ZERO_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_ZERO_INDEX).equals(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A1)))) { + if ((s > UnitDisplay.NON_TABBED_ZERO_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_ZERO_INDEX).equals(UDOP.getString(UnitDisplay.NON_TABBED_A1)))) { unitDisplayNonTabbedChanged = true; - UnitDisplayOrderPreferences.getInstance().setValue(UnitDisplay.NON_TABBED_A1, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_ZERO_INDEX)); + UDOP.setValue(UnitDisplay.NON_TABBED_A1, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_ZERO_INDEX)); } - if ((s > UnitDisplay.NON_TABBED_ONE_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_ONE_INDEX).equals(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B1)))) { + if ((s > UnitDisplay.NON_TABBED_ONE_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_ONE_INDEX).equals(UDOP.getString(UnitDisplay.NON_TABBED_B1)))) { unitDisplayNonTabbedChanged = true; - UnitDisplayOrderPreferences.getInstance().setValue(UnitDisplay.NON_TABBED_B1, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_ONE_INDEX)); + UDOP.setValue(UnitDisplay.NON_TABBED_B1, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_ONE_INDEX)); } - if ((s > UnitDisplay.NON_TABBED_TWO_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_TWO_INDEX).equals( UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C1)))) { + if ((s > UnitDisplay.NON_TABBED_TWO_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_TWO_INDEX).equals( UDOP.getString(UnitDisplay.NON_TABBED_C1)))) { unitDisplayNonTabbedChanged = true; - UnitDisplayOrderPreferences.getInstance().setValue(UnitDisplay.NON_TABBED_C1, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_TWO_INDEX)); + UDOP.setValue(UnitDisplay.NON_TABBED_C1, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_TWO_INDEX)); } - if ((s > UnitDisplay.NON_TABBED_THREE_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_THREE_INDEX).equals(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A2)))) { + if ((s > UnitDisplay.NON_TABBED_THREE_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_THREE_INDEX).equals(UDOP.getString(UnitDisplay.NON_TABBED_A2)))) { unitDisplayNonTabbedChanged = true; - UnitDisplayOrderPreferences.getInstance().setValue(UnitDisplay.NON_TABBED_A2, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_THREE_INDEX)); + UDOP.setValue(UnitDisplay.NON_TABBED_A2, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_THREE_INDEX)); } - if ((s > UnitDisplay.NON_TABBED_FOUR_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_FOUR_INDEX).equals(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B2)))) { + if ((s > UnitDisplay.NON_TABBED_FOUR_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_FOUR_INDEX).equals(UDOP.getString(UnitDisplay.NON_TABBED_B2)))) { unitDisplayNonTabbedChanged = true; - UnitDisplayOrderPreferences.getInstance().setValue(UnitDisplay.NON_TABBED_B2, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_FOUR_INDEX)); + UDOP.setValue(UnitDisplay.NON_TABBED_B2, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_FOUR_INDEX)); } - if ((s > UnitDisplay.NON_TABBED_FIVE_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_FIVE_INDEX).equals( UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C2)))) { + if ((s > UnitDisplay.NON_TABBED_FIVE_INDEX) && (!unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_FIVE_INDEX).equals( UDOP.getString(UnitDisplay.NON_TABBED_C2)))) { unitDisplayNonTabbedChanged = true; - UnitDisplayOrderPreferences.getInstance().setValue(UnitDisplay.NON_TABBED_C2, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_FIVE_INDEX)); + UDOP.setValue(UnitDisplay.NON_TABBED_C2, unitDisplayNonTabbed.get(UnitDisplay.NON_TABBED_FIVE_INDEX)); } if ((unitDisplayNonTabbedChanged) && (clientgui != null)) { @@ -995,6 +1041,15 @@ protected void okAction() { } } + GUIP.setUnitDisplayAutoDisplayReportPhase(unitDisplayAutoDisplayReportCombo.getSelectedIndex()); + GUIP.setUnitDisplayAutoDisplayNonReportPhase(unitDisplayAutoDisplayNonReportCombo.getSelectedIndex()); + GUIP.setMinimapAutoDisplayReportPhase(miniMapAutoDisplayReportCombo.getSelectedIndex()); + GUIP.setMinimapAutoDisplayNonReportPhase(miniMapAutoDisplayNonReportCombo.getSelectedIndex()); + GUIP.setMiniReportAutoDisplayReportPhase(miniReportAutoDisplayReportCombo.getSelectedIndex()); + GUIP.setMiniReportAutoDisplayNonReportPhase(miniReportAutoDisplayNonReportCombo.getSelectedIndex()); + GUIP.setPlayerListAutoDisplayReportPhase(playerListAutoDisplayReportCombo.getSelectedIndex()); + GUIP.setPlayerListAutoDisplayNonReportPhase(playerListAutoDisplayNonReportCombo.getSelectedIndex()); + setVisible(false); } @@ -1002,7 +1057,6 @@ protected void okAction() { @Override public void itemStateChanged(ItemEvent event) { Object source = event.getItemSelectable(); - GUIPreferences guip = GUIPreferences.getInstance(); if (source.equals(keepGameLog)) { gameLogFilename.setEnabled(keepGameLog.isSelected()); stampFormatLabel.setEnabled(stampFilenames.isSelected()); @@ -1012,7 +1066,7 @@ public void itemStateChanged(ItemEvent event) { stampFormat.setEnabled(stampFilenames.isSelected()); stampFormatLabel.setEnabled(stampFilenames.isSelected()); } else if (source.equals(fovInsideEnabled)) { - guip.setFovHighlight(fovInsideEnabled.isSelected()); + GUIP.setFovHighlight(fovInsideEnabled.isSelected()); fovHighlightAlpha.setEnabled(fovInsideEnabled.isSelected()); fovHighlightRingsRadii.setEnabled(fovInsideEnabled.isSelected()); fovHighlightRingsColors.setEnabled(fovInsideEnabled.isSelected()); @@ -1020,36 +1074,36 @@ public void itemStateChanged(ItemEvent event) { fovHighlightRingsRadiiLabel.setEnabled(fovInsideEnabled.isSelected()); highlightAlphaLabel.setEnabled(fovInsideEnabled.isSelected()); } else if (source.equals(fovOutsideEnabled)) { - guip.setFovDarken(fovOutsideEnabled.isSelected()); + GUIP.setFovDarken(fovOutsideEnabled.isSelected()); fovDarkenAlpha.setEnabled(fovOutsideEnabled.isSelected()); numStripesSlider.setEnabled(fovOutsideEnabled.isSelected()); darkenAlphaLabel.setEnabled(fovOutsideEnabled.isSelected()); numStripesLabel.setEnabled(fovOutsideEnabled.isSelected()); fovGrayscaleEnabled.setEnabled(fovOutsideEnabled.isSelected()); } else if (source.equals(fovGrayscaleEnabled)) { - guip.setFovGrayscale(fovGrayscaleEnabled.isSelected()); + GUIP.setFovGrayscale(fovGrayscaleEnabled.isSelected()); } else if (source.equals(aOHexShadows)) { - guip.setAOHexShadows(aOHexShadows.isSelected()); + GUIP.setAOHexShadows(aOHexShadows.isSelected()); } else if (source.equals(shadowMap)) { - guip.setShadowMap(shadowMap.isSelected()); + GUIP.setShadowMap(shadowMap.isSelected()); } else if (source.equals(hexInclines)) { - guip.setHexInclines(hexInclines.isSelected()); + GUIP.setHexInclines(hexInclines.isSelected()); } else if (source.equals(levelhighlight)) { - guip.setLevelHighlight(levelhighlight.isSelected()); + GUIP.setLevelHighlight(levelhighlight.isSelected()); } else if (source.equals(floatingIso)) { - guip.setFloatingIso(floatingIso.isSelected()); + GUIP.setFloatingIso(floatingIso.isSelected()); } else if (source.equals(mmSymbol)) { - guip.setMmSymbol(mmSymbol.isSelected()); + GUIP.setMmSymbol(mmSymbol.isSelected()); } else if (source.equals(teamColoring)) { - guip.setTeamColoring(teamColoring.isSelected()); + GUIP.setTeamColoring(teamColoring.isSelected()); } else if (source.equals(entityOwnerColor)) { - guip.setUnitLabelBorder(entityOwnerColor.isSelected()); + GUIP.setUnitLabelBorder(entityOwnerColor.isSelected()); } else if (source.equals(showDamageDecal)) { - guip.setShowDamageDecal(showDamageDecal.isSelected()); + GUIP.setShowDamageDecal(showDamageDecal.isSelected()); } else if (source.equals(showDamageLevel)) { - guip.setShowDamageLevel(showDamageLevel.isSelected()); + GUIP.setShowDamageLevel(showDamageLevel.isSelected()); } else if (source.equals(chkAntiAliasing)) { - guip.setAntiAliasing(chkAntiAliasing.isSelected()); + GUIP.setAntiAliasing(chkAntiAliasing.isSelected()); } } @@ -1059,7 +1113,7 @@ public void focusGained(FocusEvent e) { } @Override public void focusLost(FocusEvent e) { Object src = e.getSource(); - GUIPreferences guip = GUIPreferences.getInstance(); + GUIPreferences guip = GUIP; if (src.equals(fovHighlightRingsRadii)) { guip.setFovHighlightRingsRadii(fovHighlightRingsRadii.getText()); return; @@ -1417,6 +1471,137 @@ public void keyTyped(KeyEvent evt) { markDuplicateBinds(); return outer; } + + private JPanel getPhasePanel() { + List> comps = new ArrayList<>(); + ArrayList row; + JPanel outer = new JPanel(); + outer.setLayout(new BoxLayout(outer, BoxLayout.PAGE_AXIS)); + + JLabel unitDisplayLabel = new JLabel(MSG_UNITDISPLAY); + row = new ArrayList<>(); + row.add(unitDisplayLabel); + comps.add(row); + + JLabel phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); + unitDisplayAutoDisplayReportCombo = new JComboBox<>(); + unitDisplayAutoDisplayReportCombo.addItem(MSG_HIDE); + unitDisplayAutoDisplayReportCombo.addItem(MSG_SHOW); + unitDisplayAutoDisplayReportCombo.addItem(MSG_MANUAL); + unitDisplayAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + unitDisplayAutoDisplayReportCombo.setSelectedIndex(GUIP.getUnitDisplayAutoDisplayReportPhase()); + row.add(phaseLabel); + row.add(unitDisplayAutoDisplayReportCombo); + comps.add(row); + + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + unitDisplayAutoDisplayNonReportCombo = new JComboBox<>(); + unitDisplayAutoDisplayNonReportCombo.addItem(MSG_HIDE); + unitDisplayAutoDisplayNonReportCombo.addItem(MSG_SHOW); + unitDisplayAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + unitDisplayAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + unitDisplayAutoDisplayNonReportCombo.setSelectedIndex(GUIP.getUnitDisplayAutoDisplayNonReportPhase()); + row.add(phaseLabel); + row.add(unitDisplayAutoDisplayNonReportCombo); + comps.add(row); + + addLineSpacer(comps); + + JLabel miniMapLabel = new JLabel(MSG_MINIMAP); + row = new ArrayList<>(); + row.add(miniMapLabel); + comps.add(row); + + phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); + miniMapAutoDisplayReportCombo = new JComboBox<>(); + miniMapAutoDisplayReportCombo.addItem(MSG_HIDE); + miniMapAutoDisplayReportCombo.addItem(MSG_SHOW); + miniMapAutoDisplayReportCombo.addItem(MSG_MANUAL); + miniMapAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + miniMapAutoDisplayReportCombo.setSelectedIndex(GUIP.getMinimapAutoDisplayReportPhase()); + row.add(phaseLabel); + row.add(miniMapAutoDisplayReportCombo); + comps.add(row); + + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + miniMapAutoDisplayNonReportCombo = new JComboBox<>(); + miniMapAutoDisplayNonReportCombo.addItem(MSG_HIDE); + miniMapAutoDisplayNonReportCombo.addItem(MSG_SHOW); + miniMapAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + miniMapAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + miniMapAutoDisplayNonReportCombo.setSelectedIndex(GUIP.getMinimapAutoDisplayNonReportPhase()); + row.add(phaseLabel); + row.add(miniMapAutoDisplayNonReportCombo); + comps.add(row); + + addLineSpacer(comps); + + JLabel miniReportLabel = new JLabel(MSG_MINIREPORT); + row = new ArrayList<>(); + row.add(miniReportLabel); + comps.add(row); + + phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); + miniReportAutoDisplayReportCombo = new JComboBox<>(); + miniReportAutoDisplayReportCombo.addItem(MSG_HIDE); + miniReportAutoDisplayReportCombo.addItem(MSG_SHOW); + miniReportAutoDisplayReportCombo.addItem(MSG_MANUAL); + miniReportAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + miniReportAutoDisplayReportCombo.setSelectedIndex(GUIP.getMiniReportAutoDisplayReportPhase()); + row.add(phaseLabel); + row.add(miniReportAutoDisplayReportCombo); + comps.add(row); + + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + miniReportAutoDisplayNonReportCombo = new JComboBox<>(); + miniReportAutoDisplayNonReportCombo.addItem(MSG_HIDE); + miniReportAutoDisplayNonReportCombo.addItem(MSG_SHOW); + miniReportAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + miniReportAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + miniReportAutoDisplayNonReportCombo.setSelectedIndex(GUIP.getMiniReportAutoDisplayNonReportPhase()); + row.add(phaseLabel); + row.add(miniReportAutoDisplayNonReportCombo); + comps.add(row); + + addLineSpacer(comps); + + JLabel playerListLabel = new JLabel(MSG_PLAYERLIST); + row = new ArrayList<>(); + row.add(playerListLabel); + comps.add(row); + + phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); + playerListAutoDisplayReportCombo = new JComboBox<>(); + playerListAutoDisplayReportCombo.addItem(MSG_HIDE); + playerListAutoDisplayReportCombo.addItem(MSG_SHOW); + playerListAutoDisplayReportCombo.addItem(MSG_MANUAL); + playerListAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + playerListAutoDisplayReportCombo.setSelectedIndex(GUIP.getPlayerListAutoDisplayReportPhase()); + row.add(phaseLabel); + row.add(playerListAutoDisplayReportCombo); + comps.add(row); + + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + playerListAutoDisplayNonReportCombo = new JComboBox<>(); + playerListAutoDisplayNonReportCombo.addItem(MSG_HIDE); + playerListAutoDisplayNonReportCombo.addItem(MSG_SHOW); + playerListAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + playerListAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + playerListAutoDisplayNonReportCombo.setSelectedIndex(GUIP.getPlayerListAutoDisplayNonReportPhase()); + row.add(phaseLabel); + row.add(playerListAutoDisplayNonReportCombo); + comps.add(row); + + return createSettingsPanel(comps); + } private void updateKeybindsFocusTraversal() { for (KeyCommandBind kcb : KeyCommandBind.values()) { @@ -1476,7 +1661,7 @@ private void markDuplicateBinds() { } private void markTextfield(JTextField field, String errorMsg) { - field.setForeground(errorMsg != null ? GUIPreferences.getInstance().getWarningColor() : null); + field.setForeground(errorMsg != null ? GUIP.getWarningColor() : null); field.setToolTipText(errorMsg); } @@ -1581,7 +1766,7 @@ private JPanel createSettingsPanel(List> comps) { private JPanel getAdvancedSettingsPanel() { JPanel p = new JPanel(); - String[] s = GUIPreferences.getInstance().getAdvancedProperties(); + String[] s = GUIP.getAdvancedProperties(); AdvancedOptionData[] opts = new AdvancedOptionData[s.length]; for (int i = 0; i < s.length; i++) { s[i] = s[i].substring(s[i].indexOf("Advanced") + 8); @@ -1618,7 +1803,7 @@ public void valueChanged(ListSelectionEvent event) { return; } if (event.getSource().equals(advancedKeys) && !advancedKeys.isSelectionEmpty()) { - advancedValue.setText(GUIPreferences.getInstance().getString( + advancedValue.setText(GUIP.getString( "Advanced" + advancedKeys.getSelectedValue().option)); advancedKeyIndex = advancedKeys.getSelectedIndex(); } @@ -1626,13 +1811,12 @@ public void valueChanged(ListSelectionEvent event) { @Override public void stateChanged(ChangeEvent evt) { - GUIPreferences guip = GUIPreferences.getInstance(); if (evt.getSource().equals(fovHighlightAlpha)) { - guip.setFovHighlightAlpha(Math.max(0, Math.min(255, fovHighlightAlpha.getValue()))); + GUIP.setFovHighlightAlpha(Math.max(0, Math.min(255, fovHighlightAlpha.getValue()))); } else if (evt.getSource().equals(fovDarkenAlpha)) { - guip.setFovDarkenAlpha(Math.max(0, Math.min(255, fovDarkenAlpha.getValue()))); + GUIP.setFovDarkenAlpha(Math.max(0, Math.min(255, fovDarkenAlpha.getValue()))); } else if (evt.getSource().equals(numStripesSlider)) { - guip.setFovStripes(numStripesSlider.getValue()); + GUIP.setFovStripes(numStripesSlider.getValue()); } } diff --git a/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java b/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java index af28a50f2cd..c4ae6933937 100644 --- a/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java +++ b/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java @@ -93,6 +93,8 @@ public String toString() { private boolean turnMode = false; private boolean assaultDropPreference = false; + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + /** Creates and lays out a new deployment phase display for the specified client. */ public DeploymentDisplay(ClientGUI clientgui) { super(clientgui); @@ -226,7 +228,7 @@ private void endMyTurn() { Entity next = game.getNextEntity(game.getTurnIndex()); if (game.getPhase().isDeployment() && (null != next) && (null != ce()) && (next.getOwnerId() != ce().getOwnerId())) { - clientgui.setUnitDisplayVisible(false); + clientgui.maybeShowUnitDisplay(); } cen = Entity.NONE; clientgui.getBoardView().select(null); @@ -285,12 +287,12 @@ public void ready() { // Check nag for doomed planetary conditions String reason = game.getPlanetaryConditions().whyDoomed(en, game); - if ((reason != null) && GUIPreferences.getInstance().getNagForDoomed()) { + if ((reason != null) && GUIP.getNagForDoomed()) { String title = Messages.getString("DeploymentDisplay.ConfirmDoomed.title"); String body = Messages.getString("DeploymentDisplay.ConfirmDoomed.message", new Object[] {reason}); ConfirmDialog response = clientgui.doYesNoBotherDialog(title, body); if (!response.getShowAgain()) { - GUIPreferences.getInstance().setNagForDoomed(false); + GUIP.setNagForDoomed(false); } if (!response.getAnswer()) { return; diff --git a/megamek/src/megamek/client/ui/swing/FiringDisplay.java b/megamek/src/megamek/client/ui/swing/FiringDisplay.java index 439c119da0d..0b41bfd8cdf 100644 --- a/megamek/src/megamek/client/ui/swing/FiringDisplay.java +++ b/megamek/src/megamek/client/ui/swing/FiringDisplay.java @@ -72,6 +72,8 @@ public static enum FiringCommand implements PhaseCommand { String cmd; + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + /** * Priority that determines this buttons order */ @@ -778,7 +780,7 @@ public void selectEntity(int en) { LogManager.getLogger().error("Tried to select non-existent entity " + en); } - if (GUIPreferences.getInstance().getBoolean("FiringSolutions")) { + if (GUIP.getBoolean("FiringSolutions")) { setFiringSolutions(); } else { clientgui.getBoardView().clearFiringSolutionData(); @@ -793,7 +795,7 @@ public void setFiringSolutions() { Game game = clientgui.getClient().getGame(); Player localPlayer = clientgui.getClient().getLocalPlayer(); - if (!GUIPreferences.getInstance().getFiringSolutions()) { + if (!GUIP.getFiringSolutions()) { return; } @@ -884,7 +886,8 @@ protected void endMyTurn() { Entity next = game.getNextEntity(game.getTurnIndex()); if (game.getPhase().isFiring() && (next != null) && (ce() != null) && (next.getOwnerId() != ce().getOwnerId())) { - clientgui.setUnitDisplayVisible(false); + clientgui.maybeShowUnitDisplay(); + } cen = Entity.NONE; target(null); @@ -1118,13 +1121,13 @@ private void jumpToTarget(boolean nextTarg, boolean onlyValid, boolean ignoreAll */ @Override public void ready() { - if (attacks.isEmpty() && GUIPreferences.getInstance().getNagForNoAction()) { + if (attacks.isEmpty() && GUIP.getNagForNoAction()) { // confirm this action String title = Messages.getString("FiringDisplay.DontFireDialog.title"); String body = Messages.getString("FiringDisplay.DontFireDialog.message"); ConfirmDialog response = clientgui.doYesNoBotherDialog(title, body); if (!response.getShowAgain()) { - GUIPreferences.getInstance().setNagForNoAction(false); + GUIP.setNagForNoAction(false); } if (!response.getAnswer()) { @@ -1133,8 +1136,7 @@ public void ready() { } // We need to nag for overheat on capital fighters - if ((ce() != null) && ce().isCapitalFighter() - && GUIPreferences.getInstance().getNagForOverheat()) { + if ((ce() != null) && ce().isCapitalFighter() && GUIP.getNagForOverheat()) { int totalheat = 0; for (EntityAction action : attacks) { if (action instanceof WeaponAttackAction) { @@ -1149,7 +1151,7 @@ public void ready() { String body = Messages.getString("FiringDisplay.OverheatNag.message"); ConfirmDialog response = clientgui.doYesNoBotherDialog(title, body); if (!response.getShowAgain()) { - GUIPreferences.getInstance().setNagForOverheat(false); + GUIP.setNagForOverheat(false); } if (!response.getAnswer()) { @@ -1508,7 +1510,7 @@ void fire() { } // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight() && ce().isUsingSearchlight()) { + if (GUIP.getAutoDeclareSearchlight() && ce().isUsingSearchlight()) { doSearchlight(); } @@ -1608,8 +1610,7 @@ void fire() { updateClearWeaponJam(); // check; if there are no ready weapons, you're done. - if ((nextWeapon == -1) - && GUIPreferences.getInstance().getAutoEndFiring()) { + if ((nextWeapon == -1) && GUIP.getAutoEndFiring()) { ready(); return; } diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 40f31f4db0f..fdf2c662c92 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -13,6 +13,7 @@ */ package megamek.client.ui.swing; +import megamek.client.ui.Messages; import megamek.client.ui.swing.boardview.BoardView; import megamek.client.ui.swing.boardview.LabelDisplayStyle; import megamek.client.ui.swing.util.PlayerColour; @@ -112,6 +113,8 @@ public class GUIPreferences extends PreferenceStoreProxy { public static final String ADVANCED_PLANETARY_CONDITIONS_SHOW_VALUES = "AdvancedPlanetaryConditionsShowValues"; public static final String ADVANCED_PLANETARY_CONDITIONS_SHOW_INDICATORS = "AdvancedPlanetaryConditionsShowIndicators"; public static final String ADVANCED_UNITTOOLTIP_SEENBYRESOLUTION = "AdvancedUnitToolTipSeenByResolution"; + public static final String ADVANCED_DOCK_ON_LEFT = "AdvancedDockOnLeft"; + public static final String ADVANCED_DOCK_MULTIPLE_ON_Y_AXIS = "AdvancedDockMultipleOnYAxis"; /* --End advanced settings-- */ @@ -128,20 +131,25 @@ public class GUIPreferences extends PreferenceStoreProxy { public static final String AUTO_DECLARE_SEARCHLIGHT = "AutoDeclareSearchlight"; public static final String CUSTOM_UNIT_HEIGHT = "CustomUnitDialogSizeHeight"; public static final String CUSTOM_UNIT_WIDTH = "CustomUnitDialogSizeWidth"; - public static final String DISPLAY_POS_X = "DisplayPosX"; - public static final String DISPLAY_POS_Y = "DisplayPosY"; - public static final String DISPLAY_NONTABBED_POS_X = "DisplayNontabbedPosX"; - public static final String DISPLAY_NONTABBED_POS_Y = "DisplayNontabbedPosY"; - public static final String DISPLAY_START_TABBED = "DisplayStartTabbed"; - public static final String DISPLAY_SPLIT_ABC_LOC = "DisplaySplitABCLoc"; - public static final String DISPLAY_SPLIT_BC_LOC = "DisplaySplitBCLoc"; - public static final String DISPLAY_SPLIT_A1_LOC = "DisplaySplitA1Loc"; - public static final String DISPLAY_SPLIT_B1_LOC = "DisplaySplitB1Loc"; - public static final String DISPLAY_SPLIT_C1_LOC = "DisplaySplitC2Loc"; - public static final String DISPLAY_SIZE_HEIGHT = "DisplaySizeHeight"; - public static final String DISPLAY_SIZE_WIDTH = "DisplaySizeWidth"; - public static final String DISPLAY_NONTABBED_SIZE_HEIGHT = "DisplayNonTabbedSizeHeight"; - public static final String DISPLAY_NONTABBED_SIZE_WIDTH = "DisplayNontabbedSizeWidth"; + public static final String UNIT_DISPLAY_POS_X = "UnitDisplayPosX"; + public static final String UNIT_DISPLAY_POS_Y = "UnitDisplayPosY"; + public static final String UNIT_DISPLAY_NONTABBED_POS_X = "UnitDisplayNontabbedPosX"; + public static final String UNIT_DISPLAY_NONTABBED_POS_Y = "UnitDisplayNontabbedPosY"; + public static final String UNIT_DISPLAY_START_TABBED = "UnitDisplayStartTabbed"; + public static final String UNIT_DISPLAY_SPLIT_ABC_LOC = "UnitDisplaySplitABCLoc"; + public static final String UNIT_DISPLAY_SPLIT_BC_LOC = "UnitDisplaySplitBCLoc"; + public static final String UNIT_DISPLAY_SPLIT_A1_LOC = "UnitDisplaySplitA1Loc"; + public static final String UNIT_DISPLAY_SPLIT_B1_LOC = "UnitDisplaySplitB1Loc"; + public static final String UNIT_DISPLAY_SPLIT_C1_LOC = "UnitDisplaySplitC2Loc"; + public static final String UNIT_DISPLAY_SIZE_HEIGHT = "UnitDisplaySizeHeight"; + public static final String UNIT_DISPLAY_SIZE_WIDTH = "UnitDisplaySizeWidth"; + public static final String UNIT_DISPLAY_NONTABBED_SIZE_HEIGHT = "UnitDisplayNonTabbedSizeHeight"; + public static final String UNIT_DISPLAY_NONTABBED_SIZE_WIDTH = "UnitDisplayNontabbedSizeWidth"; + public static final String UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE = "UnitDisplayAutoDiplayReportPhase"; + public static final String UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE = "UnitDisplayAutoDiplayNonReportPhase"; + public static final String UNIT_DISPLAY_ENABLED = "UnitDisplayEnabled"; + public static final String UNIT_DISPLAY_LOCATION = "UnitDisplayLocation"; + public static final String SPLIT_PANE_A_DIVIDER_LOCATION = "SplitPaneADividerLocation"; public static final String GAME_SUMMARY_BOARD_VIEW = "GameSummaryBoardView"; public static final String GAME_SUMMARY_MINIMAP = "GameSummaryMinimap"; public static final String ENTITY_OWNER_LABEL_COLOR = "EntityOwnerLabelColor"; @@ -189,14 +197,24 @@ public class GUIPreferences extends PreferenceStoreProxy { public static final String MINI_REPORT_POS_Y = "MiniReportPosY"; public static final String MINI_REPORT_SIZE_HEIGHT = "MiniReportSizeHeight"; public static final String MINI_REPORT_SIZE_WIDTH = "MiniReportSizeWidth"; - public static final String MINIMAP_COLOURS = "MinimapColours"; - public static final String MINIMAP_ENABLED = "MinimapEnabled"; - public static final String MINIMAP_POS_X = "MinimapPosX"; - public static final String MINIMAP_POS_Y = "MinimapPosY"; - public static final String MINIMAP_ZOOM = "MinimapZoom"; + public static final String MINI_REPORT_ENABLED = "MiniReportEnabled"; + public static final String MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE = "MiniReportAutoDiplayReportPhase"; + public static final String MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE = "MiniReportAutoDiplayNonReportPhase"; + public static final String MINI_REPORT_LOCATION = "MiniReportLocation"; + public static final String PLAYER_LIST_POS_X = "PlayerListPosX"; + public static final String PLAYER_LIST_POS_Y = "PlayerListPosY"; + public static final String PLAYER_LIST_ENABLED = "PlayerListEnabled"; + public static final String PLAYER_LIST_AUTO_DISPLAY_REPORT_PHASE = "PlayerListAutoDiplayReportPhase"; + public static final String PLAYER_LIST_AUTO_DISPLAY_NONREPORT_PHASE = "PlayerListAutoDiplayNonReportPhase"; + public static final String MINI_MAP_COLOURS = "MinimapColours"; + public static final String MINI_MAP_ENABLED = "MinimapEnabled"; + public static final String MINI_MAP_POS_X = "MinimapPosX"; + public static final String MINI_MAP_POS_Y = "MinimapPosY"; + public static final String MINI_MAP_ZOOM = "MinimapZoom"; + public static final String MINI_MAP_AUTO_DISPLAY_REPORT_PHASE = "MinimapAutoDiplayReportPhase"; + public static final String MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE = "MinimapAutoDiplayNonReportPhase"; public static final String MINIMUM_SIZE_HEIGHT = "MinimumSizeHeight"; public static final String MINIMUM_SIZE_WIDTH = "MinimumSizeWidth"; - public static final String SHOW_UNIT_DISPLAY = "ShowUnitDisplay"; public static final String MOUSE_WHEEL_ZOOM = "MouseWheelZoom"; public static final String MOUSE_WHEEL_ZOOM_FLIP = "MouseWheelZoomFlip"; public static final String NAG_FOR_BOT_README = "NagForBotReadme"; @@ -326,6 +344,10 @@ public class GUIPreferences extends PreferenceStoreProxy { protected static GUIPreferences instance = new GUIPreferences(); + public static final int HIDE = 0; + public static final int SHOW = 1; + public static final int MAUNAL = 2; + public static GUIPreferences getInstance() { return instance; } @@ -352,10 +374,10 @@ protected GUIPreferences() { setDefault(ADVANCED_FIRE_SOLN_CANSEE_COLOR, DEFAULT_CYAN); setDefault(ADVANCED_FIRE_SOLN_NOSEE_COLOR, DEFAULT_RED); setDefault(ADVANCED_ARMORMINI_UNITS_PER_BLOCK, 10); - setDefault(ADVANCED_ARMORMINI_ARMOR_CHAR, "\u2B1B"); // Centered Filled Square + setDefault(ADVANCED_ARMORMINI_ARMOR_CHAR, "\u2B1B"); // Centered Filled Square setDefault(ADVANCED_ARMORMINI_CAP_ARMOR_CHAR, "\u26CA"); // Shield - setDefault(ADVANCED_ARMORMINI_IS_CHAR, "\u25A3"); // Centered Square with Dot - setDefault(ADVANCED_ARMORMINI_DESTROYED_CHAR, "\u2715"); // Centered x + setDefault(ADVANCED_ARMORMINI_IS_CHAR, "\u25A3"); // Centered Square with Dot + setDefault(ADVANCED_ARMORMINI_DESTROYED_CHAR, "\u2715"); // Centered x setDefault(ADVANCED_ARMORMINI_COLOR_INTACT, DEFAULT_MEDIUM_GREEN); setDefault(ADVANCED_ARMORMINI_COLOR_PARTIAL_DMG, DEFAULT_MEDIUM_YELLOW); setDefault(ADVANCED_ARMORMINI_COLOR_DAMAGED, DEFAULT_MEDIUM_DARK_RED); @@ -384,7 +406,7 @@ protected GUIPreferences() { store.setDefault(ADVANCED_KEY_REPEAT_RATE, 20); store.setDefault(ADVANCED_SHOW_FPS, false); store.setDefault(SHOW_COORDS, true); - store.setDefault(ADVANCED_BUTTONS_PER_ROW, 5); + store.setDefault(ADVANCED_BUTTONS_PER_ROW, 12); store.setDefault(ADVANCED_ROUND_REPORT_SPRITES, true); setDefault(ADVANCED_HEAT_COLOR_5, DEFAULT_HEAT_5_COLOR); @@ -408,6 +430,8 @@ protected GUIPreferences() { setDefault(ADVANCED_REPORT_COLOR_LINK, DEFAULT_REPORT_LINK_COLOR); setDefault(ADVANCED_UNITTOOLTIP_SEENBYRESOLUTION, 3); + setDefault(ADVANCED_DOCK_ON_LEFT, true); + setDefault(ADVANCED_DOCK_MULTIPLE_ON_Y_AXIS, true); store.setDefault(FOV_HIGHLIGHT_RINGS_RADII, "5 10 15 20 25"); store.setDefault(FOV_HIGHLIGHT_RINGS_COLORS_HSB, "0.3 1.0 1.0 ; 0.45 1.0 1.0 ; 0.6 1.0 1.0 ; 0.75 1.0 1.0 ; 0.9 1.0 1.0 ; 1.05 1.0 1.0 "); @@ -429,23 +453,29 @@ protected GUIPreferences() { store.setDefault(AUTO_DECLARE_SEARCHLIGHT, true); store.setDefault(CUSTOM_UNIT_HEIGHT, 400); store.setDefault(CUSTOM_UNIT_WIDTH, 600); - store.setDefault(DISPLAY_SIZE_HEIGHT, 500); - store.setDefault(DISPLAY_SIZE_WIDTH, 300); - store.setDefault(DISPLAY_NONTABBED_SIZE_HEIGHT, 900); - store.setDefault(DISPLAY_NONTABBED_SIZE_WIDTH, 900); - store.setDefault(DISPLAY_START_TABBED, true); - store.setDefault(DISPLAY_SPLIT_ABC_LOC, 300); - store.setDefault(DISPLAY_SPLIT_BC_LOC, 300); - store.setDefault(DISPLAY_SPLIT_A1_LOC, 900); - store.setDefault(DISPLAY_SPLIT_B1_LOC, 500); - store.setDefault(DISPLAY_SPLIT_C1_LOC, 500); + + store.setDefault(UNIT_DISPLAY_SIZE_HEIGHT, 500); + store.setDefault(UNIT_DISPLAY_SIZE_WIDTH, 300); + store.setDefault(UNIT_DISPLAY_NONTABBED_SIZE_HEIGHT, 900); + store.setDefault(UNIT_DISPLAY_NONTABBED_SIZE_WIDTH, 900); + store.setDefault(UNIT_DISPLAY_START_TABBED, true); + store.setDefault(UNIT_DISPLAY_SPLIT_ABC_LOC, 300); + store.setDefault(UNIT_DISPLAY_SPLIT_BC_LOC, 300); + store.setDefault(UNIT_DISPLAY_SPLIT_A1_LOC, 900); + store.setDefault(UNIT_DISPLAY_SPLIT_B1_LOC, 500); + store.setDefault(UNIT_DISPLAY_SPLIT_C1_LOC, 500); + store.setDefault(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE, 0); + store.setDefault(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, 1); + store.setDefault(UNIT_DISPLAY_ENABLED, true); + store.setDefault(UNIT_DISPLAY_LOCATION, 0); + store.setDefault(SPLIT_PANE_A_DIVIDER_LOCATION, 300); + store.setDefault(GAME_SUMMARY_BOARD_VIEW, false); store.setDefault(ENTITY_OWNER_LABEL_COLOR, true); store.setDefault(UNIT_LABEL_BORDER, true); store.setDefault(UNIT_LABEL_STYLE, LabelDisplayStyle.NICKNAME.name()); store.setDefault(FIRING_SOLUTIONS, true); store.setDefault(GUI_SCALE, 1); - store.setDefault(SHOW_UNIT_DISPLAY, true); store.setDefault(LOBBY_MEKTABLE_UNIT_WIDTH, 170); store.setDefault(LOBBY_MEKTABLE_PILOT_WIDTH, 80); store.setDefault(LOBBY_MEKTABLE_PLAYER_WIDTH, 50); @@ -476,8 +506,11 @@ protected GUIPreferences() { store.setDefault(RND_ARMY_POS_Y, 200); store.setDefault(RND_ARMY_SPLIT_POS, 300); - store.setDefault(MINIMAP_COLOURS, "defaultminimap.txt"); - store.setDefault(MINIMAP_ENABLED, true); + store.setDefault(MINI_MAP_COLOURS, "defaultminimap.txt"); + store.setDefault(MINI_MAP_ENABLED, true); + store.setDefault(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE, 0); + store.setDefault(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE, 1); + store.setDefault(MMSYMBOL, true); store.setDefault(MINIMUM_SIZE_HEIGHT, 200); store.setDefault(MINIMUM_SIZE_WIDTH, 120); @@ -486,6 +519,16 @@ protected GUIPreferences() { store.setDefault(MINI_REPORT_POS_Y, 150); store.setDefault(MINI_REPORT_SIZE_HEIGHT, 300); store.setDefault(MINI_REPORT_SIZE_WIDTH, 400); + store.setDefault(MINI_REPORT_ENABLED, true); + store.setDefault(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE, 1); + store.setDefault(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE, 0); + store.setDefault(MINI_REPORT_LOCATION, 0); + + store.setDefault(PLAYER_LIST_ENABLED, true); + store.setDefault(PLAYER_LIST_POS_X, 200); + store.setDefault(PLAYER_LIST_POS_Y, 150); + store.setDefault(PLAYER_LIST_AUTO_DISPLAY_REPORT_PHASE, 1); + store.setDefault(PLAYER_LIST_AUTO_DISPLAY_NONREPORT_PHASE, 0); store.setDefault(MOUSE_WHEEL_ZOOM, true); store.setDefault(MOUSE_WHEEL_ZOOM_FLIP, true); @@ -631,60 +674,84 @@ public int getCustomUnitWidth() { return store.getInt(CUSTOM_UNIT_WIDTH); } - public int getDisplayPosX() { - return store.getInt(DISPLAY_POS_X); + public int getUnitDisplayPosX() { + return store.getInt(UNIT_DISPLAY_POS_X); + } + + public int getUnitDisplayPosY() { + return store.getInt(UNIT_DISPLAY_POS_Y); + } + + public int getUnitDisplayNontabbedPosX() { + return store.getInt(UNIT_DISPLAY_NONTABBED_POS_X); + } + + public int getUnitDisplayNontabbedPosY() { + return store.getInt(UNIT_DISPLAY_NONTABBED_POS_Y); + } + + public boolean getUnitDisplayStartTabbed() { + return store.getBoolean(UNIT_DISPLAY_START_TABBED); } - public int getDisplayPosY() { - return store.getInt(DISPLAY_POS_Y); + public int getUnitDisplaySplitABCLoc() { + return store.getInt(UNIT_DISPLAY_SPLIT_ABC_LOC); } - public int getDisplayNontabbedPosX() { - return store.getInt(DISPLAY_NONTABBED_POS_X); + public int getUnitDisplaySplitBCLoc() { + return store.getInt(UNIT_DISPLAY_SPLIT_BC_LOC); } - public int getDisplayNontabbedPosY() { - return store.getInt(DISPLAY_NONTABBED_POS_Y); + public int getUnitDisplaySplitA1Loc() { + return store.getInt(UNIT_DISPLAY_SPLIT_A1_LOC); } - public boolean getDisplayStartTabbed() { - return store.getBoolean(DISPLAY_START_TABBED); + public int getUnitDisplaySplitB1Loc() { + return store.getInt(UNIT_DISPLAY_SPLIT_B1_LOC); } - public int getDisplaySplitABCLoc() { - return store.getInt(DISPLAY_SPLIT_ABC_LOC); + public int getUnitDisplaySplitC1Loc() { + return store.getInt(UNIT_DISPLAY_SPLIT_C1_LOC); } - public int getDisplaySplitBCLoc() { - return store.getInt(DISPLAY_SPLIT_BC_LOC); + public int getUnitDisplaySizeHeight() { + return store.getInt(UNIT_DISPLAY_SIZE_HEIGHT); } - public int getDisplaySplitA1Loc() { - return store.getInt(DISPLAY_SPLIT_A1_LOC); + public int getUnitDisplaySizeWidth() { + return store.getInt(UNIT_DISPLAY_SIZE_WIDTH); } - public int getDisplaySplitB1Loc() { - return store.getInt(DISPLAY_SPLIT_B1_LOC); + public int getUnitDisplayNonTabbedSizeHeight() { + return store.getInt(UNIT_DISPLAY_NONTABBED_SIZE_HEIGHT); } - public int getDisplaySplitC1Loc() { - return store.getInt(DISPLAY_SPLIT_C1_LOC); + public int getUnitDisplayNonTabbedSizeWidth() { + return store.getInt(UNIT_DISPLAY_NONTABBED_SIZE_WIDTH); } - public int getDisplaySizeHeight() { - return store.getInt(DISPLAY_SIZE_HEIGHT); + public int getUnitDisplayAutoDisplayReportPhase() { + return store.getInt(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE); } - public int getDisplaySizeWidth() { - return store.getInt(DISPLAY_SIZE_WIDTH); + public int getUnitDisplayAutoDisplayNonReportPhase() { + return store.getInt(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE); } - public int getDisplayNonTabbedSizeHeight() { - return store.getInt(DISPLAY_NONTABBED_SIZE_HEIGHT); + public boolean getUnitDisplayEnabled() { + return store.getBoolean(UNIT_DISPLAY_ENABLED); } - public int getDisplayNonTabbedSizeWidth() { - return store.getInt(DISPLAY_NONTABBED_SIZE_WIDTH); + public int getUnitDisplayLocaton() { + return store.getInt(UNIT_DISPLAY_LOCATION); + } + + public int getSplitPaneADividerLocaton() { + return store.getInt(SPLIT_PANE_A_DIVIDER_LOCATION); + } + + public boolean getCoordsEnabled() { + return store.getBoolean(SHOW_COORDS); } public boolean getGameSummaryBoardView() { @@ -856,27 +923,71 @@ public int getRndArmySplitPos() { } public String getMinimapColours() { - return store.getString(MINIMAP_COLOURS); + return store.getString(MINI_MAP_COLOURS); } public boolean getMinimapEnabled() { - return store.getBoolean(MINIMAP_ENABLED); + return store.getBoolean(MINI_MAP_ENABLED); } - public boolean getIsometricEnabled() { - return store.getBoolean(USE_ISOMETRIC); + public int getMinimapAutoDisplayReportPhase() { + return store.getInt(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE); + } + + public int getMinimapAutoDisplayNonReportPhase() { + return store.getInt(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE); } public int getMinimapPosX() { - return store.getInt(MINIMAP_POS_X); + return store.getInt(MINI_MAP_POS_X); } public int getMinimapPosY() { - return store.getInt(MINIMAP_POS_Y); + return store.getInt(MINI_MAP_POS_Y); } public int getMinimapZoom() { - return store.getInt(MINIMAP_ZOOM); + return store.getInt(MINI_MAP_ZOOM); + } + + public boolean getMiniReportEnabled() { + return store.getBoolean(MINI_REPORT_ENABLED); + } + + public int getMiniReportAutoDisplayReportPhase() { + return store.getInt(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE); + } + + public int getMiniReportAutoDisplayNonReportPhase() { + return store.getInt(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE); + } + + public int getMiniReportLocaton() { + return store.getInt(MINI_REPORT_LOCATION); + } + + public boolean getPlayerListEnabled() { + return store.getBoolean(PLAYER_LIST_ENABLED); + } + + public int getPlayerListPosX() { + return store.getInt(PLAYER_LIST_POS_X); + } + + public int getPlayerListPosY() { + return store.getInt(PLAYER_LIST_POS_Y); + } + + public int getPlayerListAutoDisplayReportPhase() { + return store.getInt(PLAYER_LIST_AUTO_DISPLAY_REPORT_PHASE); + } + + public int getPlayerListAutoDisplayNonReportPhase() { + return store.getInt(PLAYER_LIST_AUTO_DISPLAY_NONREPORT_PHASE); + } + + public boolean getIsometricEnabled() { + return store.getBoolean(USE_ISOMETRIC); } public int getMinimumSizeHeight() { @@ -1167,59 +1278,95 @@ public void setCustomUnitWidth(int state) { store.setValue(CUSTOM_UNIT_WIDTH, state); } - public void setDisplayPosX(int i) { - store.setValue(DISPLAY_POS_X, i); + public void setUnitDisplayPosX(int i) { + store.setValue(UNIT_DISPLAY_POS_X, i); + } + + public void setUnitDisplayPosY(int i) { + store.setValue(UNIT_DISPLAY_POS_Y, i); + } + + public void setUnitDisplayNontabbedPosX(int i) { + store.setValue(UNIT_DISPLAY_NONTABBED_POS_X, i); + } + + public void setUnitDisplayNontabbedPosY(int i) { + store.setValue(UNIT_DISPLAY_NONTABBED_POS_Y, i); + } + public void setUnitDisplayStartTabbed(boolean state) { + store.setValue(UNIT_DISPLAY_START_TABBED, state); + } + + public void setUnitDisplaySplitABCLoc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_ABC_LOC, i); } - public void setDisplayPosY(int i) { - store.setValue(DISPLAY_POS_Y, i); + public void setUnitDisplaySplitBCLoc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_BC_LOC, i); } - public void setDisplayNontabbedPosX(int i) { - store.setValue(DISPLAY_NONTABBED_POS_X, i); + public void setUnitDisplaySplitA1Loc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_A1_LOC, i); } - public void setDisplayNontabbedPosY(int i) { - store.setValue(DISPLAY_NONTABBED_POS_Y, i); + public void setUnitDisplaySplitB1Loc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_B1_LOC, i); } - public void setDisplayStartTabbed(boolean state) { - store.setValue(DISPLAY_START_TABBED, state); + + public void setUnitDisplaySplitC2Loc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_C1_LOC, i); + } + + public void setUnitDisplaySizeHeight(int i) { + store.setValue(UNIT_DISPLAY_SIZE_HEIGHT, i); } - public void setDisplaySplitABCLoc(int i) { - store.setValue(DISPLAY_SPLIT_ABC_LOC, i); + public void setUnitDisplaySizeWidth(int i) { + store.setValue(UNIT_DISPLAY_SIZE_WIDTH, i); } - public void setDisplaySplitBCLoc(int i) { - store.setValue(DISPLAY_SPLIT_BC_LOC, i); + public void setUnitDisplayNonTabbedSizeHeight(int i) { + store.setValue(UNIT_DISPLAY_NONTABBED_SIZE_HEIGHT, i); } - public void setDisplaySplitA1Loc(int i) { - store.setValue(DISPLAY_SPLIT_A1_LOC, i); + public void setUnitDisplayNonTabbedSizeWidth(int i) { + store.setValue(UNIT_DISPLAY_NONTABBED_SIZE_WIDTH, i); } - public void setDisplaySplitB1Loc(int i) { - store.setValue(DISPLAY_SPLIT_B1_LOC, i); + public void setUnitDisplayAutoDisplayReportPhase(int i) { + store.setValue(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE, i); } - public void setDisplaySplitC2Loc(int i) { - store.setValue(DISPLAY_SPLIT_C1_LOC, i); + public void setUnitDisplayAutoDisplayNonReportPhase(int i) { + store.setValue(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, i); } - public void setDisplaySizeHeight(int i) { - store.setValue(DISPLAY_SIZE_HEIGHT, i); + public void toggleUnitDisplay() { + store.setValue(UNIT_DISPLAY_ENABLED, !getBoolean(UNIT_DISPLAY_ENABLED)); } - public void setDisplaySizeWidth(int i) { - store.setValue(DISPLAY_SIZE_WIDTH, i); + public void setUnitDisplayEnabled(boolean b) { + store.setValue(UNIT_DISPLAY_ENABLED, b); } - public void setDisplayNonTabbedSizeHeight(int i) { - store.setValue(DISPLAY_NONTABBED_SIZE_HEIGHT, i); + public void toggleUnitDisplayLocation() { + store.setValue(UNIT_DISPLAY_LOCATION, ((getInt(UNIT_DISPLAY_LOCATION)+1)%2)); } - public void setDisplayNonTabbedSizeWidth(int i) { - store.setValue(DISPLAY_NONTABBED_SIZE_WIDTH, i); + public void setUnitDisplayLocation(int i) { + store.setValue(UNIT_DISPLAY_LOCATION, i); + } + + public void setSplitPaneALocation(int i) { + store.setValue(SPLIT_PANE_A_DIVIDER_LOCATION, i); + } + + public void toggleCoords() { + store.setValue(SHOW_COORDS, !getBoolean(SHOW_COORDS)); + } + + public void setCoordsEnabled(boolean b) { + store.setValue(SHOW_COORDS, b); } public void setGameSummaryBoardView(boolean state) { @@ -1379,19 +1526,39 @@ public void setRndArmyPosY(int i) { } public void setMinimapEnabled(boolean b) { - store.setValue(MINIMAP_ENABLED, b); + store.setValue(MINI_MAP_ENABLED, b); + } + + public void toggleMinimapEnabled() { + setMinimapEnabled(!getMinimapEnabled()); } public void setMinimapPosX(int i) { - store.setValue(MINIMAP_POS_X, i); + store.setValue(MINI_MAP_POS_X, i); } public void setMinimapPosY(int i) { - store.setValue(MINIMAP_POS_Y, i); + store.setValue(MINI_MAP_POS_Y, i); } public void setMinimapZoom(int zoom) { - store.setValue(MINIMAP_ZOOM, zoom); + store.setValue(MINI_MAP_ZOOM, zoom); + } + + public void setMinimapAutoDisplayReportPhase(int i) { + store.setValue(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE, i); + } + + public void setMinimapAutoDisplayNonReportPhase(int i) { + store.setValue(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE, i); + } + + public void setMiniReportEnabled(boolean b) { + store.setValue(MINI_REPORT_ENABLED, b); + } + + public void toggleRoundReportEnabled() { + setMiniReportEnabled(!getMiniReportEnabled()); } public void setMiniReportPosX(int i) { @@ -1402,6 +1569,46 @@ public void setMiniReportPosY(int i) { store.setValue(MINI_REPORT_POS_Y, i); } + public void setMiniReportAutoDisplayReportPhase(int i) { + store.setValue(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE, i); + } + + public void setMiniReportAutoDisplayNonReportPhase(int i) { + store.setValue(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE, i); + } + + public void toggleMiniReportLocation() { + store.setValue(MINI_REPORT_LOCATION, ((getInt(MINI_REPORT_LOCATION)+1)%2)); + } + + public void setMiniReportLocation(int i) { + store.setValue(MINI_REPORT_LOCATION, i); + } + + public void setPlayerListEnabled(boolean b) { + store.setValue(PLAYER_LIST_ENABLED, b); + } + + public void togglePlayerListEnabled() { + setPlayerListEnabled(!getPlayerListEnabled()); + } + + public void setPlayerListPosX(int i) { + store.setValue(PLAYER_LIST_POS_X, i); + } + + public void setPlayerListPosY(int i) { + store.setValue(PLAYER_LIST_POS_Y, i); + } + + public void setPlayerListAutoDisplayReportPhase(int i) { + store.setValue(PLAYER_LIST_AUTO_DISPLAY_REPORT_PHASE, i); + } + + public void setPlayerListAutoDisplayNonReportPhase(int i) { + store.setValue(PLAYER_LIST_AUTO_DISPLAY_NONREPORT_PHASE, i); + } + public void setBoardEditLoadHeight(int i) { store.setValue(BOARDEDIT_LOAD_SIZE_HEIGHT, i); } @@ -1751,6 +1958,13 @@ public int getAdvancedUnitToolTipSeenByResolution() { return getInt(ADVANCED_UNITTOOLTIP_SEENBYRESOLUTION); } + public boolean getAdvancedDockOnLeft() { + return getBoolean(ADVANCED_DOCK_ON_LEFT); + } + + public boolean getAdvancedDockMultipleOnYAxis() { + return getBoolean(ADVANCED_DOCK_MULTIPLE_ON_Y_AXIS); + } public void setReportLinkColor(Color color) { store.setValue(ADVANCED_REPORT_COLOR_LINK, getColorString(color)); @@ -1840,25 +2054,12 @@ public void setAdvancedUnitToolTipSeenByResolution(int i) { store.setValue(ADVANCED_UNITTOOLTIP_SEENBYRESOLUTION, i); } - /** - * Sets the user preference for the Unit Display window to active. - */ - public void showUnitDisplay() { - store.setValue(SHOW_UNIT_DISPLAY, true); + public void setAdvancedDockOnLeft(Boolean state) { + store.setValue(ADVANCED_DOCK_ON_LEFT, state); } - /** - * Sets the user preference for the Unit Display window to inactive. - */ - public void hideUnitDisplay() { - store.setValue(SHOW_UNIT_DISPLAY, false); - } - - /** - * Toggles the state of the user preference for the Unit Display. - */ - public void toggleUnitDisplay() { - store.setValue(SHOW_UNIT_DISPLAY, !getBoolean(SHOW_UNIT_DISPLAY)); + public void setAdvancedDockMultipleOnYAxis(Boolean state) { + store.setValue(ADVANCED_DOCK_MULTIPLE_ON_Y_AXIS, state); } /** diff --git a/megamek/src/megamek/client/ui/swing/MapMenu.java b/megamek/src/megamek/client/ui/swing/MapMenu.java index b806be37473..0e3c0c05ea3 100644 --- a/megamek/src/megamek/client/ui/swing/MapMenu.java +++ b/megamek/src/megamek/client/ui/swing/MapMenu.java @@ -311,7 +311,7 @@ private JMenuItem viewJMenuItem(Entity en) { item.addActionListener(evt -> { try { selectedEntity = game.getEntity(Integer.parseInt(evt.getActionCommand())); - GUIPreferences.getInstance().showUnitDisplay(); + GUIPreferences.getInstance().setUnitDisplayEnabled(true); gui.getUnitDisplay().displayEntity(selectedEntity); } catch (Exception ex) { LogManager.getLogger().error("", ex); diff --git a/megamek/src/megamek/client/ui/swing/MechViewPanel.java b/megamek/src/megamek/client/ui/swing/MechViewPanel.java index 46cc3057b71..5d1918d8943 100644 --- a/megamek/src/megamek/client/ui/swing/MechViewPanel.java +++ b/megamek/src/megamek/client/ui/swing/MechViewPanel.java @@ -23,6 +23,7 @@ import megamek.client.ui.swing.util.UIUtil.FixedXPanel; import megamek.common.Entity; import megamek.common.MechView; +import megamek.common.Report; import megamek.common.templates.TROView; import org.apache.logging.log4j.LogManager; @@ -53,7 +54,7 @@ public MechViewPanel() { } public MechViewPanel(int width, int height, boolean noBorder) { - ReportDisplay.setupStylesheet(txtMek); + Report.setupStylesheet(txtMek); txtMek.setEditable(false); txtMek.setBorder(new EmptyBorder(5, 10, 0, 0)); txtMek.setMinimumSize(new Dimension(width, height)); diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index eeed62cf150..16ae0d01c68 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -39,8 +39,8 @@ /** * Shows reports, with an Okay JButton */ -public class MiniReportDisplay extends JDialog implements ActionListener, HyperlinkListener, IPreferenceChangeListener { - private JButton butOkay; +public class MiniReportDisplay extends JPanel implements ActionListener, HyperlinkListener, IPreferenceChangeListener { + private JButton butSwitchLocation; private JTabbedPane tabs; private JButton butPlayerSearchUp; private JButton butPlayerSearchDown; @@ -53,6 +53,8 @@ public class MiniReportDisplay extends JDialog implements ActionListener, Hyperl private JComboBox comboQuick = new JComboBox<>(); private ClientGUI currentClientgui; private Client currentClient; + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + private static final ClientPreferences CP = PreferenceManager.getClientPreferences(); private static final String MSG_TITLE = Messages.getString("MiniReportDisplay.title"); private static final String MSG_ROUND = Messages.getString("MiniReportDisplay.Round"); @@ -61,12 +63,11 @@ public class MiniReportDisplay extends JDialog implements ActionListener, Hyperl private static final String MSG_ARROWUP = Messages.getString("MiniReportDisplay.ArrowUp"); private static final String MSG_ARROWDOWN = Messages.getString("MiniReportDisplay.ArrowDown"); private static final String MSG_DETAILS = Messages.getString("MiniReportDisplay.Details"); - private static final String MSG_OKAY= Messages.getString("Okay"); + private static final String MSG_SWITCHLOCATION = Messages.getString("MiniReportDisplay.SwitchLocation"); private static final int MRD_MAXNAMELENGHT = 60; - public MiniReportDisplay(JFrame parent, ClientGUI clientgui) { - super(parent, MSG_TITLE, false); + public MiniReportDisplay(ClientGUI clientgui) { if (clientgui == null) { return; @@ -76,8 +77,8 @@ public MiniReportDisplay(JFrame parent, ClientGUI clientgui) { currentClient = clientgui.getClient(); currentClient.getGame().addGameListener(gameListener); - butOkay = new JButton(MSG_OKAY); - butOkay.addActionListener(this); + butSwitchLocation = new JButton(MSG_SWITCHLOCATION); + butSwitchLocation.addActionListener(this); butPlayerSearchUp = new JButton(MSG_ARROWUP); butPlayerSearchUp.addActionListener(this); butPlayerSearchDown = new JButton(MSG_ARROWDOWN); @@ -94,41 +95,32 @@ public MiniReportDisplay(JFrame parent, ClientGUI clientgui) { setLayout(new BorderLayout()); JPanel p = new JPanel(); - p.add(BorderLayout.EAST, comboPlayer); - p.add(BorderLayout.EAST, butPlayerSearchUp); - p.add(BorderLayout.EAST, butPlayerSearchDown); - p.add(BorderLayout.EAST, comboEntity); - p.add(BorderLayout.EAST, butEntitySearchUp); - p.add(BorderLayout.EAST, butEntitySearchDown); - p.add(BorderLayout.EAST, comboQuick); - p.add(BorderLayout.EAST, butQuickSearchUp); - p.add(BorderLayout.EAST, butQuickSearchDown); - - p.add(BorderLayout.WEST, butOkay); + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.add(comboPlayer); + p.add(butPlayerSearchUp); + p.add(butPlayerSearchDown); + p.add(comboEntity); + p.add(butEntitySearchUp); + p.add(butEntitySearchDown); + p.add(comboQuick); + p.add(butQuickSearchUp); + p.add(butQuickSearchDown); + p.add(butSwitchLocation); + JScrollPane sp = new JScrollPane(p); - add(BorderLayout.SOUTH, sp); - - setupReportTabs(); - - setSize(GUIPreferences.getInstance().getMiniReportSizeWidth(), - GUIPreferences.getInstance().getMiniReportSizeHeight()); - doLayout(); - setLocation(GUIPreferences.getInstance().getMiniReportPosX(), - GUIPreferences.getInstance().getMiniReportPosY()); - - // closing the window is the same as hitting butOkay - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - actionPerformed(new ActionEvent(butOkay, - ActionEvent.ACTION_PERFORMED, butOkay.getText())); - } - }); + JPanel panelMain = new JPanel(new BorderLayout()); + + tabs = new JTabbedPane(); + panelMain.add(tabs, BorderLayout.CENTER); + panelMain.add(sp, BorderLayout.SOUTH); + panelMain.setMinimumSize(new Dimension(0, 0)); + add(panelMain, BorderLayout.CENTER); + doLayout(); adaptToGUIScale(); - GUIPreferences.getInstance().addPreferenceChangeListener(this); - PreferenceManager.getClientPreferences().addPreferenceChangeListener(this); - butOkay.requestFocus(); + + GUIP.addPreferenceChangeListener(this); + CP.addPreferenceChangeListener(this); } private void searchTextPane(String searchPattern, Boolean searchDown) { @@ -196,11 +188,10 @@ private void updatePlayerChoice() { String playerDisplay = String.format("%-12s", player.getName()); comboPlayer.addItem(playerDisplay); } - if (comboPlayer.getItemCount() == 1) { - comboPlayer.setEnabled(false); - } comboPlayer.setSelectedItem(lastChoice); - if (comboPlayer.getSelectedIndex() < 0) { + if (comboPlayer.getItemCount() <= 1) { + comboPlayer.setEnabled(false); + } else if (comboPlayer.getSelectedIndex() < 0) { comboPlayer.setSelectedIndex(0); } } @@ -247,7 +238,7 @@ private void updateQuickChoice() { lastChoice = (lastChoice != null ? lastChoice : MSG_DAMAGE); comboQuick.removeAllItems(); comboQuick.setEnabled(true); - String[] keywords = PreferenceManager.getClientPreferences().getReportKeywords().split("\n"); + String[] keywords = CP.getReportKeywords().split("\n"); for (String keyword : keywords) { comboQuick.addItem(keyword); } @@ -271,9 +262,8 @@ public void setVisible(boolean visible) { @Override public void actionPerformed(ActionEvent ae) { - if (ae.getSource().equals(butOkay)) { - savePref(); - setVisible(false); + if (ae.getSource().equals(butSwitchLocation)) { + GUIP.toggleMiniReportLocation(); } else if (ae.getSource().equals(butPlayerSearchDown)) { String searchPattern = comboPlayer.getSelectedItem().toString().trim(); searchTextPane(searchPattern, true); @@ -295,28 +285,17 @@ public void actionPerformed(ActionEvent ae) { } } - @Override - protected void processWindowEvent(WindowEvent e) { - super.processWindowEvent(e); - if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { - savePref(); - } - } - - - private void setupReportTabs() { - tabs = new JTabbedPane(); - - addReportPages(); - - add(BorderLayout.CENTER, tabs); - } - - private void savePref() { - GUIPreferences.getInstance().setMiniReportSizeWidth(getSize().width); - GUIPreferences.getInstance().setMiniReportSizeHeight(getSize().height); - GUIPreferences.getInstance().setMiniReportPosX(getLocation().x); - GUIPreferences.getInstance().setMiniReportPosY(getLocation().y); + private JScrollPane loadHtmlScrollPane(String t) { + JTextPane ta = new JTextPane(); + Report.setupStylesheet(ta); + ta.addHyperlinkListener(this); + BASE64ToolKit toolKit = new BASE64ToolKit(); + ta.setEditorKit(toolKit); + ta.setText("
" + t + "
"); + ta.setEditable(false); + ta.setOpaque(false); + ta.setCaretPosition(0); + return new JScrollPane(ta); } public void addReportPages() { @@ -325,35 +304,14 @@ public void addReportPages() { for (int round = 1; round <= numRounds; round++) { String text = currentClient.receiveReport(currentClient.getGame().getReports(round)); - JTextPane ta = new JTextPane(); - ReportDisplay.setupStylesheet(ta); - ta.addHyperlinkListener(this); - BASE64ToolKit toolKit = new BASE64ToolKit(); - ta.setEditorKit(toolKit); - ta.setText("
" + text + "
"); - ta.setEditable(false); - ta.setOpaque(false); - ta.setCaretPosition(0); - JScrollPane sp = new JScrollPane(ta); - tabs.add(MSG_ROUND + " " + round, sp); + tabs.add(MSG_ROUND + " " + round, loadHtmlScrollPane(text)); } // add the new current phase tab - JTextPane ta = new JTextPane(); - ReportDisplay.setupStylesheet(ta); - ta.addHyperlinkListener(this); - - BASE64ToolKit toolKit = new BASE64ToolKit(); - ta.setEditorKit(toolKit); - ta.setText("
" + currentClient.phaseReport + "
"); - ta.setEditable(false); - ta.setOpaque(false); - ta.setCaretPosition(0); - - JScrollPane sp = new JScrollPane(ta); - tabs.add(MSG_PHASE, sp); + tabs.add(MSG_PHASE, loadHtmlScrollPane(currentClient.phaseReport)); tabs.setSelectedIndex(tabs.getTabCount() - 1); + tabs.setMinimumSize(new Dimension(0, 0)); } private JComponent activePane() { @@ -375,7 +333,7 @@ public void hyperlinkUpdate(HyperlinkEvent evt) { Entity ent = currentClientgui.getClient().getGame().getEntity(id); if (ent != null) { currentClientgui.getUnitDisplay().displayEntity(ent); - currentClientgui.setUnitDisplayVisible(true); + GUIP.setUnitDisplayEnabled(true); } } else if (evtDesc.startsWith(Report.TOOLTIP_LINK)) { String desc = evtDesc.substring(Report.TOOLTIP_LINK.length()); @@ -397,11 +355,11 @@ public void hyperlinkUpdate(HyperlinkEvent evt) { public void gamePhaseChange(GamePhaseChangeEvent e) { switch (e.getOldPhase()) { case VICTORY: - savePref(); setVisible(false); break; default: - if (!e.getNewPhase().equals((e.getOldPhase()))) { + if ((!e.getNewPhase().equals((e.getOldPhase()))) + && ((e.getNewPhase().isReport()) || ((e.getNewPhase().isOnMap()) && (tabs.getTabCount() == 0)))){ addReportPages(); updatePlayerChoice(); updateEntityChoice(); @@ -411,7 +369,7 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { }; private void adaptToGUIScale() { - UIUtil.adjustDialog(this, UIUtil.FONT_SCALE1); + UIUtil.adjustContainer(this, UIUtil.FONT_SCALE1); for (int i = 0; i < tabs.getTabCount(); i++) { Component cp = tabs.getComponentAt(i); @@ -419,7 +377,7 @@ private void adaptToGUIScale() { Component pane = ((JScrollPane) cp).getViewport().getView(); if (pane instanceof JTextPane) { JTextPane tp = (JTextPane) pane; - ReportDisplay.setupStylesheet(tp); + Report.setupStylesheet(tp); tp.setText(tp.getText()); } } diff --git a/megamek/src/megamek/client/ui/swing/MovementDisplay.java b/megamek/src/megamek/client/ui/swing/MovementDisplay.java index 0e5bf954b55..cab424c8c1b 100644 --- a/megamek/src/megamek/client/ui/swing/MovementDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MovementDisplay.java @@ -188,6 +188,8 @@ public enum MoveCommand implements PhaseCommand { */ public int priority; + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + MoveCommand(String c, int f) { cmd = c; flag = f; @@ -534,19 +536,16 @@ public void performAction() { cmd.addStep(MoveStepType.START_JUMP); } gear = MovementDisplay.GEAR_JUMP; - Color jumpColor = GUIPreferences.getInstance().getColor( - GUIPreferences.ADVANCED_MOVE_JUMP_COLOR); + Color jumpColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_JUMP_COLOR); clientgui.getBoardView().setHighlightColor(jumpColor); } else { - Color walkColor = GUIPreferences.getInstance().getColor( - GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); + Color walkColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); clientgui.getBoardView().setHighlightColor(walkColor); gear = MovementDisplay.GEAR_LAND; clear(); } } else { - Color walkColor = GUIPreferences.getInstance().getColor( - GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); + Color walkColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); clientgui.getBoardView().setHighlightColor(walkColor); gear = MovementDisplay.GEAR_LAND; clear(); @@ -707,7 +706,7 @@ public synchronized void selectEntity(int en) { cen = en; clientgui.setSelectedEntityNum(en); gear = MovementDisplay.GEAR_LAND; - Color walkColor = GUIPreferences.getInstance().getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); + Color walkColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); clientgui.getBoardView().setHighlightColor(walkColor); clear(); @@ -964,7 +963,7 @@ private synchronized void endMyTurn() { && (null != next) && (null != ce) && (next.getOwnerId() != ce.getOwnerId())) { - clientgui.setUnitDisplayVisible(false); + clientgui.maybeShowUnitDisplay(); } cen = Entity.NONE; clientgui.getBoardView().select(null); @@ -1070,7 +1069,7 @@ public void clear() { ce.setCarefulStand(false); ce.setIsJumpingNow(false); ce.setConvertingNow(false); - ce.setClimbMode(GUIPreferences.getInstance().getBoolean(GUIPreferences.ADVANCED_MOVE_DEFAULT_CLIMB_MODE)); + ce.setClimbMode(GUIP.getBoolean(GUIPreferences.ADVANCED_MOVE_DEFAULT_CLIMB_MODE)); // switch back from swimming to normal mode. if (ce.getMovementMode() == EntityMovementMode.BIPED_SWIM) { @@ -1086,8 +1085,7 @@ public void clear() { // set to "walk," or the equivalent if (gear != MovementDisplay.GEAR_JUMP) { gear = MovementDisplay.GEAR_LAND; - Color walkColor = GUIPreferences.getInstance().getColor( - GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); + Color walkColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); clientgui.getBoardView().setHighlightColor(walkColor); } else if (!cmd.isJumping()) { cmd.addStep(MoveStepType.START_JUMP); @@ -1212,21 +1210,20 @@ public synchronized void ready() { } cmd.clipToPossible(); - if ((cmd.length() == 0) && !ce().isAirborne() - && GUIPreferences.getInstance().getNagForNoAction()) { + if ((cmd.length() == 0) && !ce().isAirborne() && GUIP.getNagForNoAction()) { // Hmm... no movement steps, confirm this action String title = Messages.getString("MovementDisplay.ConfirmNoMoveDlg.title"); String body = Messages.getString("MovementDisplay.ConfirmNoMoveDlg.message"); ConfirmDialog response = clientgui.doYesNoBotherDialog(title, body); if (!response.getShowAgain()) { - GUIPreferences.getInstance().setNagForNoAction(false); + GUIP.setNagForNoAction(false); } if (!response.getAnswer()) { return; } } - if (GUIPreferences.getInstance().getNagForMASC() && cmd.hasActiveMASC()) { + if (GUIP.getNagForMASC() && cmd.hasActiveMASC()) { // pop up are you sure dialog ConfirmDialog nag = new ConfirmDialog(clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), @@ -1236,15 +1233,14 @@ public synchronized void ready() { if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForMASC(false); + GUIP.setNagForMASC(false); } } else { return; } } - if (GUIPreferences.getInstance().getNagForMASC() && !(ce() instanceof VTOL) - && cmd.hasActiveSupercharger()) { + if (GUIP.getNagForMASC() && !(ce() instanceof VTOL) && cmd.hasActiveSupercharger()) { ConfirmDialog nag = new ConfirmDialog(clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), Messages.getString("MovementDisplay.ConfirmSuperchargerRoll", ce().getSuperchargerTarget()), @@ -1253,7 +1249,7 @@ public synchronized void ready() { if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForMASC(false); + GUIP.setNagForMASC(false); } } else { return; @@ -1262,12 +1258,12 @@ public synchronized void ready() { if ((cmd.getLastStepMovementType() == EntityMovementType.MOVE_SPRINT || cmd.getLastStepMovementType() == EntityMovementType.MOVE_VTOL_SPRINT) - && GUIPreferences.getInstance().getNagForSprint() + && GUIP.getNagForSprint() // no need to nag for vehicles using overdrive if they already get a PSR nag && !((cmd.getEntity() instanceof Tank || (cmd.getEntity() instanceof QuadVee && cmd.getEntity().getConversionMode() == QuadVee.CONV_MODE_VEHICLE) - && GUIPreferences.getInstance().getNagForPSR()))) { + && GUIP.getNagForPSR()))) { ConfirmDialog nag = new ConfirmDialog(clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), Messages.getString("MovementDisplay.ConfirmSprint"), true); @@ -1275,14 +1271,14 @@ public synchronized void ready() { if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForSprint(false); + GUIP.setNagForSprint(false); } } else { return; } } String check = SharedUtility.doPSRCheck(cmd); - if (!check.isBlank() && GUIPreferences.getInstance().getNagForPSR()) { + if (!check.isBlank() && GUIP.getNagForPSR()) { ConfirmDialog nag = new ConfirmDialog(clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), Messages.getString("MovementDisplay.ConfirmPilotingRoll") + @@ -1291,7 +1287,7 @@ public synchronized void ready() { if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForPSR(false); + GUIP.setNagForPSR(false); } } else { return; @@ -1299,8 +1295,7 @@ public synchronized void ready() { } // Should we nag about taking fall damage with mechanical jump boosters? - if (cmd.shouldMechanicalJumpCauseFallDamage() - && GUIPreferences.getInstance().getNagForMechanicalJumpFallDamage()) { + if (cmd.shouldMechanicalJumpCauseFallDamage() && GUIP.getNagForMechanicalJumpFallDamage()) { ConfirmDialog nag = new ConfirmDialog(clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), Messages.getString("MovementDisplay.ConfirmMechanicalJumpFallDamage", @@ -1310,7 +1305,7 @@ public synchronized void ready() { if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForMechanicalJumpFallDamage(false); + GUIP.setNagForMechanicalJumpFallDamage(false); } } else { return; @@ -1319,7 +1314,7 @@ public synchronized void ready() { // check for G-forces check = SharedUtility.doThrustCheck(cmd, clientgui.getClient()); - if (!check.isBlank() && GUIPreferences.getInstance().getNagForPSR()) { + if (!check.isBlank() && GUIP.getNagForPSR()) { ConfirmDialog nag = new ConfirmDialog(clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), Messages.getString("MovementDisplay.ConfirmPilotingRoll") + check, @@ -1328,7 +1323,7 @@ public synchronized void ready() { if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForPSR(false); + GUIP.setNagForPSR(false); } } else { return; @@ -1353,7 +1348,7 @@ public synchronized void ready() { if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForPSR(false); + GUIP.setNagForPSR(false); } } else { return; @@ -1377,7 +1372,7 @@ public synchronized void ready() { if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForPSR(false); + GUIP.setNagForPSR(false); } } else { return; @@ -1426,8 +1421,7 @@ public synchronized void ready() { cmd = SharedUtility.moveAero(cmd, clientgui.getClient()); } - if (cmd.willCrushBuildings() - && GUIPreferences.getInstance().getNagForCrushingBuildings()) { + if (cmd.willCrushBuildings() && GUIP.getNagForCrushingBuildings()) { ConfirmDialog nag = new ConfirmDialog( clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), @@ -1437,7 +1431,7 @@ public synchronized void ready() { if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForCrushingBuildings(false); + GUIP.setNagForCrushingBuildings(false); } } else { return; @@ -1471,8 +1465,7 @@ && ce().getGame().getBoard().getHex(cmd.getFinalCoords()) return; } - if (cmd.automaticWiGELanding(true) - && GUIPreferences.getInstance().getNagForWiGELanding()) { + if (cmd.automaticWiGELanding(true) && GUIP.getNagForWiGELanding()) { ConfirmDialog nag = new ConfirmDialog( clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), @@ -1482,7 +1475,7 @@ && ce().getGame().getBoard().getHex(cmd.getFinalCoords()) if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForWiGELanding(false); + GUIP.setNagForWiGELanding(false); } } else { return; @@ -3452,8 +3445,7 @@ private TreeMap> getLaunchedUnits() { continue; } int numChoices = choiceDialog.getChoices().length; - if ((numChoices > currentBay.getSafeLaunchRate()) - && GUIPreferences.getInstance().getNagForLaunchDoors()) { + if ((numChoices > currentBay.getSafeLaunchRate()) && GUIP.getNagForLaunchDoors()) { int aerosPerDoor = numChoices / doors; int remainder = numChoices % doors; // Determine PSRs @@ -3475,7 +3467,7 @@ private TreeMap> getLaunchedUnits() { nag.setVisible(true); doIt = nag.getAnswer(); if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForLaunchDoors(false); + GUIP.setNagForLaunchDoors(false); } } else { doIt = true; @@ -4179,8 +4171,7 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { */ public void computeMovementEnvelope(Entity suggestion) { // do nothing if deactivated in the settings - if (!GUIPreferences.getInstance() - .getBoolean(GUIPreferences.MOVE_ENVELOPE)) { + if (!GUIP.getBoolean(GUIPreferences.MOVE_ENVELOPE)) { clientgui.getBoardView().clearMovementEnvelope(); return; } @@ -4337,7 +4328,7 @@ public synchronized void actionPerformed(ActionEvent ev) { gear = MovementDisplay.GEAR_LAND; clear(); } - Color walkColor = GUIPreferences.getInstance().getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); + Color walkColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); clientgui.getBoardView().setHighlightColor(walkColor); gear = MovementDisplay.GEAR_LAND; computeMovementEnvelope(ce); @@ -4352,7 +4343,7 @@ public synchronized void actionPerformed(ActionEvent ev) { cmd.addStep(MoveStepType.START_JUMP); } gear = MovementDisplay.GEAR_JUMP; - Color jumpColor = GUIPreferences.getInstance().getColor(GUIPreferences.ADVANCED_MOVE_JUMP_COLOR); + Color jumpColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_JUMP_COLOR); clientgui.getBoardView().setHighlightColor(jumpColor); computeMovementEnvelope(ce); } else if (actionCmd.equals(MoveCommand.MOVE_SWIM.getCmd())) { @@ -4409,8 +4400,7 @@ public synchronized void actionPerformed(ActionEvent ev) { clear(); } gear = MovementDisplay.GEAR_BACKUP; // on purpose... - Color backColor = GUIPreferences.getInstance().getColor( - GUIPreferences.ADVANCED_MOVE_BACK_COLOR); + Color backColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_BACK_COLOR); clientgui.getBoardView().setHighlightColor(backColor); computeMovementEnvelope(ce); } else if (actionCmd.equals(MoveCommand.MOVE_LONGEST_RUN.getCmd())) { @@ -4731,8 +4721,7 @@ public synchronized void actionPerformed(ActionEvent ev) { && ce.getMovementMode().equals(EntityMovementMode.INF_JUMP)) { cmd.addStep(MoveStepType.START_JUMP); gear = GEAR_JUMP; - Color jumpColor = GUIPreferences.getInstance().getColor( - GUIPreferences.ADVANCED_MOVE_JUMP_COLOR); + Color jumpColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_JUMP_COLOR); clientgui.getBoardView().setHighlightColor(jumpColor); computeMovementEnvelope(ce); } diff --git a/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java b/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java index dbd601ac550..b3eec7e15f1 100644 --- a/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java +++ b/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java @@ -61,6 +61,8 @@ public enum PhysicalCommand implements PhaseCommand { String cmd; + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + /** * Priority that determines this buttons order */ @@ -273,7 +275,7 @@ private void endMyTurn() { .getNextEntity(clientgui.getClient().getGame().getTurnIndex()); if (clientgui.getClient().getGame().getPhase().isPhysical() && (null != next) && (null != ce()) && (next.getOwnerId() != ce().getOwnerId())) { - clientgui.setUnitDisplayVisible(false); + clientgui.maybeShowUnitDisplay(); } cen = Entity.NONE; target(null); @@ -311,13 +313,13 @@ private void disableButtons() { */ @Override public void ready() { - if (attacks.isEmpty() && GUIPreferences.getInstance().getNagForNoAction()) { + if (attacks.isEmpty() && GUIP.getNagForNoAction()) { // confirm this action ConfirmDialog response = clientgui.doYesNoBotherDialog( Messages.getString("PhysicalDisplay.DontPhysicalAttackDialog.title"), Messages.getString("PhysicalDisplay.DontPhysicalAttackDialog.message")); if (!response.getShowAgain()) { - GUIPreferences.getInstance().setNagForNoAction(false); + GUIP.setNagForNoAction(false); } if (!response.getAnswer()) { return; @@ -457,7 +459,7 @@ void punch() { disableButtons(); // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { + if (GUIP.getAutoDeclareSearchlight()) { doSearchlight(); } @@ -591,7 +593,7 @@ void kick() { if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { + if (GUIP.getAutoDeclareSearchlight()) { doSearchlight(); } @@ -619,7 +621,7 @@ void push() { if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { + if (GUIP.getAutoDeclareSearchlight()) { doSearchlight(); } @@ -643,7 +645,7 @@ void trip() { if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { + if (GUIP.getAutoDeclareSearchlight()) { doSearchlight(); } @@ -681,7 +683,7 @@ private void grapple(boolean counter) { if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { + if (GUIP.getAutoDeclareSearchlight()) { doSearchlight(); } @@ -701,7 +703,7 @@ private void breakGrapple() { if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { + if (GUIP.getAutoDeclareSearchlight()) { doSearchlight(); } @@ -777,7 +779,7 @@ void jumpjetatt() { if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { + if (GUIP.getAutoDeclareSearchlight()) { doSearchlight(); } @@ -891,7 +893,7 @@ void club(Mounted club) { disableButtons(); // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { + if (GUIP.getAutoDeclareSearchlight()) { doSearchlight(); } @@ -923,7 +925,7 @@ private void proto() { if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { + if (GUIP.getAutoDeclareSearchlight()) { doSearchlight(); } diff --git a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java index 61e04334116..37830ad17e3 100644 --- a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java +++ b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java @@ -19,45 +19,92 @@ import megamek.client.ui.swing.util.UIUtil; import megamek.common.Player; import megamek.common.Team; +import megamek.common.event.GameListener; +import megamek.common.event.GameListenerAdapter; +import megamek.common.event.GamePhaseChangeEvent; import megamek.common.preference.IPreferenceChangeListener; import megamek.common.preference.PreferenceChangeEvent; import javax.swing.*; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.text.MessageFormat; -public class PlayerListDialog extends JDialog implements IPreferenceChangeListener { +public class PlayerListDialog extends JDialog implements ActionListener, IPreferenceChangeListener { private static final long serialVersionUID = 7270469195373150106L; private JList playerList = new JList<>(new DefaultListModel<>()); private Client client; - - public PlayerListDialog(JFrame parent, Client client) { - super(parent, Messages.getString("PlayerListDialog.title"), false); + private JButton butOkay; + private boolean modal; + + private static final String MSG_OKAY = Messages.getString("Okay"); + private static final String MSG_TITLE = Messages.getString("PlayerListDialog.title"); + private static final String MSG_NOTEAM = Messages.getString("PlayerListDialog.NoTeam"); + private static final String MSG_TEAM = Messages.getString("PlayerListDialog.Team"); + private static final String MSG_TEAMLESS = Messages.getString("PlayerListDialog.TeamLess"); + private static final String MSG_PLAYER_GM = Messages.getString("PlayerListDialog.player_gm"); + private static final String MSG_PLAYER_GHOST = Messages.getString("PlayerListDialog.player_ghost"); + private static final String MSG_PLAYER_BOT = Messages.getString("PlayerListDialog.player_bot"); + private static final String MSG_PLAYER_HUMAN = Messages.getString("PlayerListDialog.player_human"); + private static final String MSG_PLAYER_OBSERVER = Messages.getString("PlayerListDialog.player_observer"); + private static final String MSG_PLAYER_DONE = Messages.getString("PlayerListDialog.player_done"); + private static final String MSG_PLAYER_SEEALL = Messages.getString("PlayerListDialog.player_seeall"); + private static final String MSG_PLAYER_SINGLEBLIND = Messages.getString("PlayerListDialog.player_singleblind"); + private static final String MSG_PLAYER_IGNOREDOUBLEBLIND = Messages.getString("PlayerListDialog.player_ignoreDoubleBlind"); + + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + + public PlayerListDialog(JFrame parent, Client client, boolean modal) { + super(parent, "", false); + this.setTitle(MSG_TITLE); this.client = client; + this.modal = modal; + + client.getGame().addGameListener(gameListener); add(playerList, BorderLayout.CENTER); add(Box.createHorizontalStrut(20), BorderLayout.LINE_START); add(Box.createHorizontalStrut(20), BorderLayout.LINE_END); - add(new JButton(new CloseAction(this)), BorderLayout.PAGE_END); + + butOkay = new JButton(MSG_OKAY); + butOkay.addActionListener(this); + add(butOkay, BorderLayout.PAGE_END); + + // closing the window is the same as hitting butOkay + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + actionPerformed(new ActionEvent(butOkay, + ActionEvent.ACTION_PERFORMED, butOkay.getText())); + } + }); refreshPlayerList(); setMinimumSize(new Dimension(300, 260)); adaptToGUIScale(); - GUIPreferences.getInstance().addPreferenceChangeListener(this); + GUIP.addPreferenceChangeListener(this); pack(); setResizable(false); - setLocation(parent.getLocation().x + (parent.getSize().width / 2) - - (getSize().width / 2), - parent.getLocation().y + (parent.getSize().height / 2) - - (getSize().height / 2)); - + + if (modal) { + setModal(true); + setLocation(parent.getLocation().x + (parent.getSize().width / 2) - (getSize().width / 2), + parent.getLocation().y + (parent.getSize().height / 2) - (getSize().height / 2)); + } else { + setModal(false); + setLocation(GUIP.getPlayerListPosX(), GUIP.getPlayerListPosY()); + } } - public static void refreshPlayerList(JList playerList, + public void refreshPlayerList(JList playerList, Client client) { refreshPlayerList(playerList, client, false); } @@ -66,7 +113,7 @@ public static void refreshPlayerList(JList playerList, * Refreshes the player list component with information from the game * object. */ - public static void refreshPlayerList(JList playerList, + public void refreshPlayerList(JList playerList, Client client, boolean displayTeam) { ((DefaultListModel) playerList.getModel()).removeAllElements(); @@ -78,46 +125,46 @@ public static void refreshPlayerList(JList playerList, Team team = client.getGame().getTeamForPlayer(player); if (team != null) { if (team.getId() == Player.TEAM_NONE) { - playerDisplay.append(Messages.getString("PlayerListDialog.NoTeam")); + playerDisplay.append(MSG_NOTEAM); } else { - playerDisplay.append(Messages.getString("PlayerListDialog.Team", team.getId())); + playerDisplay.append(MessageFormat.format(MSG_TEAM, team.getId())); } } else { - playerDisplay.append(Messages.getString("PlayerListDialog.TeamLess")); + playerDisplay.append(MSG_TEAMLESS); } } if (player.isGameMaster()) { - playerDisplay.append(Messages.getString("PlayerListDialog.player_gm")); + playerDisplay.append(MSG_PLAYER_GM); } if (player.isGhost()) { - playerDisplay.append(Messages.getString("PlayerListDialog.player_ghost")); + playerDisplay.append(MSG_PLAYER_GHOST); } else { if (player.isBot()) { - playerDisplay.append(Messages.getString("PlayerListDialog.player_bot")); + playerDisplay.append(MSG_PLAYER_BOT); } else { - playerDisplay.append(Messages.getString("PlayerListDialog.player_human")); + playerDisplay.append(MSG_PLAYER_HUMAN); } if (player.isObserver()) { - playerDisplay.append(Messages.getString("PlayerListDialog.player_observer")); + playerDisplay.append(MSG_PLAYER_OBSERVER); } else if (player.isDone()) { - playerDisplay.append(Messages.getString("PlayerListDialog.player_done")); + playerDisplay.append(MSG_PLAYER_DONE); } } // this may be too much detail long term, but is useful for understanding the modes // during testing if (player.getSeeAll()) { - playerDisplay.append(Messages.getString("PlayerListDialog.player_seeall")); + playerDisplay.append(MSG_PLAYER_SEEALL); } if (player.getSingleBlind()) { - playerDisplay.append(Messages.getString("PlayerListDialog.player_singleblind")); + playerDisplay.append(MSG_PLAYER_SINGLEBLIND); } if (player.canIgnoreDoubleBlind()) { - playerDisplay.append(Messages.getString("PlayerListDialog.player_ignoreDoubleBlind")); + playerDisplay.append(MSG_PLAYER_IGNOREDOUBLEBLIND); } ((DefaultListModel) playerList.getModel()).addElement(playerDisplay.toString()); @@ -137,6 +184,39 @@ public Player getSelected() { return null; } + @Override + public void actionPerformed(ActionEvent ae) { + if (ae.getSource().equals(butOkay)) { + setVisible(false); + if (!modal) { + GUIP.setPlayerListEnabled(false); + } + } + } + + private GameListener gameListener = new GameListenerAdapter() { + @Override + public void gamePhaseChange(GamePhaseChangeEvent e) { + switch (e.getOldPhase()) { + case VICTORY: + break; + default: + break; + } + } + }; + + @Override + protected void processWindowEvent(WindowEvent e) { + super.processWindowEvent(e); + if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { + if (!modal) { + GUIP.setPlayerListPosX(getLocation().x); + GUIP.setPlayerListPosY(getLocation().y); + } + } + } + private void adaptToGUIScale() { UIUtil.adjustDialog(this, UIUtil.FONT_SCALE1); setMinimumSize(new Dimension(UIUtil.scaleForGUI(300), UIUtil.scaleForGUI(260))); diff --git a/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java b/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java index f1a476808c0..5be59ffad17 100644 --- a/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java +++ b/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java @@ -481,7 +481,7 @@ protected void endMyTurn() { Entity next = game.getNextEntity(game.getTurnIndex()); if (game.getPhase().isFiring() && (next != null) && (ce() != null) && (next.getOwnerId() != ce().getOwnerId())) { - clientgui.setUnitDisplayVisible(false); + clientgui.maybeShowUnitDisplay(); } cen = Entity.NONE; target(null); diff --git a/megamek/src/megamek/client/ui/swing/PrephaseDisplay.java b/megamek/src/megamek/client/ui/swing/PrephaseDisplay.java index 79fc0f89621..7492fa8076c 100644 --- a/megamek/src/megamek/client/ui/swing/PrephaseDisplay.java +++ b/megamek/src/megamek/client/ui/swing/PrephaseDisplay.java @@ -350,7 +350,7 @@ private void endMyTurn() { if ((phase == clientgui.getClient().getGame().getPhase()) && (null != next) && (null != ce()) && (next.getOwnerId() != ce().getOwnerId())) { - clientgui.setUnitDisplayVisible(false); + clientgui.maybeShowUnitDisplay(); } cen = Entity.NONE; diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index 12c58afa408..e787eda4bb4 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -13,119 +13,124 @@ */ package megamek.client.ui.swing; -import megamek.client.Client; -import megamek.client.ui.GBC; import megamek.client.ui.Messages; -import megamek.client.ui.swing.util.BASE64ToolKit; -import megamek.client.ui.swing.util.UIUtil; import megamek.client.ui.swing.widget.MegamekButton; import megamek.client.ui.swing.widget.SkinSpecification; -import megamek.common.Entity; -import megamek.common.Report; +import megamek.common.enums.GamePhase; import megamek.common.event.GamePhaseChangeEvent; -import megamek.common.preference.IPreferenceChangeListener; -import megamek.common.preference.PreferenceChangeEvent; - -import javax.swing.*; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; -import javax.swing.text.html.HTMLEditorKit; -import javax.swing.text.html.StyleSheet; -import java.awt.*; + import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; -public class ReportDisplay extends AbstractPhaseDisplay implements - ActionListener, HyperlinkListener, IPreferenceChangeListener { +public class ReportDisplay extends StatusBarPhaseDisplay { private static final long serialVersionUID = 6185643976857892270L; - // displays - private JTabbedPane tabs; + public static enum ReportCommand implements PhaseCommand { + REPORT_REPORT("reportReport"), + REPORT_PLAYERLIST("reportPlayerList"), + REPORT_REROLLINITIATIVE("reportRerollInitiative"); - // buttons - private JButton rerollInitiativeB; - private JSplitPane splitPaneMain; - JPanel panelTop; + String cmd; - private static final String RD_ACTIONCOMMAND_DONEBUTTON = "doneButton"; - private static final String RD_ACTIONCOMMAND_REROLLINITIATIVE = "reroll_initiative"; + /** + * Priority that determines this buttons order + */ + public int priority; - private static final String MSG_DONE = Messages.getString("ReportDisplay.Done"); - private static final String MSG_REROLL = Messages.getString("ReportDisplay.Reroll"); - private static final String MSG_ROUND = Messages.getString("ReportDisplay.Round"); - private static final String MSG_PHASE = Messages.getString("ReportDisplay.Phase"); - private static final String MSG_DETAILS =Messages.getString("ReportDisplay.Details"); + private ReportCommand(String c) { + cmd = c; + } + + @Override + public String getCmd() { + return cmd; + } + @Override + public int getPriority() { + return priority; + } + + @Override + public void setPriority(int p) { + priority = p; + } + + @Override + public String toString() { + return Messages.getString("ReportDisplay." + getCmd()); + } + } + + // buttons + private Map buttons; private boolean rerolled; // have we rerolled an init? + private static final String RD_REPORTDIPLAY = "ReportDisplay."; + private static final String RD_TOOLTIP = ".tooltip"; + + private static final String MSG_DONE = Messages.getString("ReportDisplay.Done"); + /** * Creates and lays out a new movement phase display for the specified * clientgui.getClient(). */ public ReportDisplay(ClientGUI clientgui) { super(clientgui); - butDone = new MegamekButton("", - SkinSpecification.UIComponents.PhaseDisplayDoneButton.getComp()); - butDone.setActionCommand(RD_ACTIONCOMMAND_DONEBUTTON); - butDone.addActionListener(new AbstractAction() { - private static final long serialVersionUID = -5034474968902280850L; - - @Override - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals(RD_ACTIONCOMMAND_DONEBUTTON)) { - ready(); - } - } - }); - clientgui.getClient().getGame().addGameListener(this); - // Create a tabbed panel to hold our reports. - tabs = new JTabbedPane(); + if (clientgui == null) { + return; + } - resetTabs(); + setupStatusBar(""); + + buttons = new HashMap<>((int) (ReportCommand.values().length * 1.25 + 0.5)); + for (ReportCommand cmd : ReportCommand.values()) { + String title = Messages.getString(RD_REPORTDIPLAY + cmd.getCmd()); + MegamekButton newButton = new MegamekButton(title, + SkinSpecification.UIComponents.PhaseDisplayButton.getComp()); + String ttKey = RD_REPORTDIPLAY + cmd.getCmd() + RD_TOOLTIP; + if (Messages.keyExists(ttKey)) { + newButton.setToolTipText(Messages.getString(ttKey)); + } + newButton.addActionListener(this); + newButton.setActionCommand(cmd.getCmd()); + newButton.setEnabled(false); + buttons.put(cmd, newButton); + } + numButtonGroups = (int) Math.ceil((buttons.size() + 0.0) / buttonsPerGroup); butDone.setText(MSG_DONE); + butDone.setEnabled(false); - rerollInitiativeB = new JButton(MSG_REROLL); - rerollInitiativeB.setActionCommand(RD_ACTIONCOMMAND_REROLLINITIATIVE); - rerollInitiativeB.addActionListener(this); - - // layout screen - setLayout(new BorderLayout()); - splitPaneMain = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - splitPaneMain.setDividerSize(15); - splitPaneMain.setResizeWeight(0.95); - panelTop = new JPanel(new GridBagLayout()); - panelTop.add(tabs, GBC.eol().fill(GridBagConstraints.BOTH)); - - JPanel panButtons = new JPanel(); - panButtons.setLayout(new GridLayout(1, 8)); - panButtons.add(rerollInitiativeB); - for (int padding = 0; padding < 6; padding++) { - panButtons.add(new JLabel("")); - } - panelTop.add(panButtons, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); - panelTop.setMinimumSize(new Dimension(0, 0)); - splitPaneMain.setTopComponent(panelTop); - add(splitPaneMain); + setupButtonPanel(); - adaptToGUIScale(); - GUIPreferences.getInstance().addPreferenceChangeListener(this); + clientgui.getClient().getGame().addGameListener(this); + clientgui.getBoardView().addBoardViewListener(this); + clientgui.getBoardView().addKeyListener(this); } - public void setBottom(JComponent comp) { - splitPaneMain.setBottomComponent(comp); + @Override + protected ArrayList getButtonList() { + ArrayList buttonList = new ArrayList<>(); + ReportCommand[] commands = ReportCommand.values(); + CommandComparator comparator = new CommandComparator(); + Arrays.sort(commands, comparator); + for (ReportCommand cmd : commands) { + buttonList.add(buttons.get(cmd)); + } + return buttonList; } /** - * Show or hide the "reroll inititiative" button in this report display. - * - * @param show - * a boolean that indicates that the button should - * be shown in this report display. + * Clears all current actions */ - public void showRerollButton(boolean show) { - rerollInitiativeB.setVisible(show); + @Override + public void clear() { + } /** @@ -133,136 +138,46 @@ public void showRerollButton(boolean show) { */ @Override public void ready() { - rerollInitiativeB.setEnabled(false); + if (!clientgui.getBoardView().isTileImagesLoaded()) { + return; + } + butDone.setEnabled(false); + setReportEnabled(false); + setPlayerListEnabled(false); + setRerollInitiativeEnabled(false); clientgui.getClient().sendDone(true); } - /** - * Requests an initiative reroll and disables the ready button. - */ - public void rerollInitiative() { - rerolled = true; - rerollInitiativeB.setEnabled(false); - // butDone.setEnabled(false); - clientgui.getClient().sendRerollInitiativeRequest(); + public void setReportEnabled(boolean enabled) { + buttons.get(ReportCommand.REPORT_REPORT).setEnabled(enabled); } - /** - * have we rerolled init this round? - */ - public boolean hasRerolled() { - return rerolled; + public void setPlayerListEnabled(boolean enabled) { + buttons.get(ReportCommand.REPORT_PLAYERLIST).setEnabled(enabled); } - public void resetButtons() { - resetReadyButton(); - if (clientgui.getClient().getGame().getPhase().isInitiativeReport() - && clientgui.getClient().getGame().hasTacticalGenius(clientgui.getClient().getLocalPlayer())) { - showRerollButton(true); - } else { - showRerollButton(false); - } - rerollInitiativeB.setEnabled(true); + public void setRerollInitiativeEnabled(boolean enabled) { + buttons.get(ReportCommand.REPORT_REROLLINITIATIVE).setEnabled(enabled); } - public void resetReadyButton() { - butDone.setEnabled(true); - } - - public void resetRerollButton() { - rerollInitiativeB.setEnabled(true); - } - - public void setReportTab(int round, String roundText, String phaseText) { - if (round == 0) { - // The deployment reports (round 0) are combined with round one's - // report. - round = 1; - } - if (tabs.indexOfTab(MSG_ROUND + " " + round) == -1) { - // Need a new tab for the new round. - - // get rid of phase tab - int phaseTab = tabs.indexOfTab(MSG_PHASE); - if (phaseTab >= 0) { - tabs.removeTabAt(phaseTab); - } - if (phaseTab == -1) { - phaseTab += 1; // special handling for round 0 - } - - // add as many round tabs as necessary to catch us up - JTextPane ta; - // TODO: we should remove the use of client - final Client client = clientgui.getClient(); - for (int catchup = phaseTab + 1; catchup <= round; catchup++) { - if (tabs.indexOfTab(MSG_ROUND + " " + catchup) != -1) { - ((JTextPane) ((JScrollPane) tabs.getComponentAt(tabs - .indexOfTab(MSG_ROUND + " " + catchup))).getViewport() - .getView()).setText("
"
-                            + client.receiveReport(client.getGame().getReports(
-                                    catchup)) + "
"); - continue; - } - String text = roundText; - if (catchup != round) { - text = client.receiveReport(client.getGame().getReports(catchup)); - } - ta = new JTextPane(); - ta.addHyperlinkListener(this); - setupStylesheet(ta); - BASE64ToolKit toolKit = new BASE64ToolKit(); - ta.setEditorKit(toolKit); - ta.setText("
" + text + "
"); - ta.setEditable(false); - ta.setOpaque(false); - tabs.add(MSG_ROUND + " " + catchup, new JScrollPane(ta)); - } - - // add the new current phase tab - ta = new JTextPane(); - ta.addHyperlinkListener(this); - setupStylesheet(ta); - BASE64ToolKit toolKit = new BASE64ToolKit(); - ta.setEditorKit(toolKit); - ta.setText("
" + phaseText + "
"); - ta.setEditable(false); - ta.setOpaque(false); - - - JScrollPane sp = new JScrollPane(ta); - tabs.add(MSG_PHASE, sp); - tabs.setSelectedComponent(sp); - } else { - // Update the existing round tab and the phase tab. - ((JTextPane) ((JScrollPane) tabs.getComponentAt(tabs.indexOfTab(MSG_ROUND + " " + round))).getViewport().getView()).setText("
" + roundText + "
"); - ((JTextPane) ((JScrollPane) tabs.getComponentAt(tabs.indexOfTab(MSG_PHASE))).getViewport().getView()).setText("
" + phaseText + "
"); + public void resetRerollInitiativeEnabled() { + if (!rerolled) { + setRerollInitiativeEnabled(true); } } - public static void setupStylesheet(JTextPane pane) { - pane.setContentType("text/html"); - StyleSheet styleSheet = ((HTMLEditorKit) pane.getEditorKit()).getStyleSheet(); - Report.setupStylesheet(styleSheet); - } - - public void appendReportTab(String additionalText) { - int phaseTab = tabs.indexOfTab(MSG_PHASE); - if (phaseTab > 0) { - JTextPane pane = ((JTextPane) ((JScrollPane) tabs.getComponentAt(phaseTab - 1)).getViewport().getView()); - BASE64ToolKit toolKit = new BASE64ToolKit(); - pane.setEditorKit(toolKit); - pane.setText(pane.getText() + "
"+additionalText+"
"); - } - JTextPane pane = ((JTextPane) ((JScrollPane) tabs.getComponentAt(phaseTab)).getViewport().getView()); - BASE64ToolKit toolKit = new BASE64ToolKit(); - pane.setEditorKit(toolKit); - pane.setText(pane.getText() + "
"+additionalText+"
"); + public void setDoneEnabled(boolean enabled) { + butDone.setEnabled(enabled); } - public void resetTabs() { - tabs.removeAll(); + /** + * Requests an initiative reroll and disables the ready button. + */ + public void rerollInitiative() { + rerolled = true; + setRerollInitiativeEnabled(false); + clientgui.getClient().sendRerollInitiativeRequest(); } // @@ -270,36 +185,52 @@ public void resetTabs() { // @Override public void actionPerformed(ActionEvent ev) { - if (ev.getActionCommand().equalsIgnoreCase(RD_ACTIONCOMMAND_REROLLINITIATIVE)) { + if (ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_REROLLINITIATIVE.getCmd())) { rerollInitiative(); + } else if ((ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_REPORT.getCmd()))) { + GUIP.toggleRoundReportEnabled(); + } else if ((ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_PLAYERLIST.getCmd()))) { + GUIP.togglePlayerListEnabled(); + } + } + + private void resetButtons() { + butDone.setEnabled(true); + setReportEnabled(true); + setPlayerListEnabled(true); + + if ((clientgui.getClient().getGame().getPhase() == GamePhase.INITIATIVE_REPORT) && clientgui.getClient().getGame().hasTacticalGenius(clientgui.getClient().getLocalPlayer())) { + setRerollInitiativeEnabled(true); } } @Override public void gamePhaseChange(GamePhaseChangeEvent e) { - // Are we ignoring events? if (isIgnoringEvents()) { return; } - setReportTab(clientgui.getClient().getGame().getRoundCount(), clientgui.getClient().roundReport, clientgui.getClient().phaseReport); - resetButtons(); rerolled = false; - SwingUtilities.invokeLater(() -> { - int phaseTab = tabs.indexOfTab(MSG_PHASE); - if (phaseTab > 0) { - JViewport vp = ((JScrollPane) tabs.getComponentAt(phaseTab - 1)).getViewport(); - vp.setViewPosition(new Point()); - } - JViewport vp = ((JScrollPane) tabs.getComponentAt(phaseTab)).getViewport(); - vp.setViewPosition(new Point()); - }); - } - - public void clear() { - // move along, move along, nothing to see here + GamePhase phase = clientgui.getClient().getGame().getPhase(); + + switch (phase) { + case INITIATIVE_REPORT: + case TARGETING_REPORT: + case MOVEMENT_REPORT: + case OFFBOARD_REPORT: + case FIRING_REPORT: + case PHYSICAL_REPORT: + case END_REPORT: + case VICTORY: + resetButtons(); + setStatusBarText(phase.toString()); + break; + default: + setStatusBarText(phase.toString()); + break; + } } /** @@ -308,67 +239,7 @@ public void clear() { @Override public void removeAllListeners() { clientgui.getClient().getGame().removeGameListener(this); - GUIPreferences.getInstance().removePreferenceChangeListener(this); - } - - private JComponent activePane() { - return (JComponent) ((JScrollPane) tabs.getSelectedComponent()).getViewport().getView(); - } - - @Override - public void hyperlinkUpdate(HyperlinkEvent evt) { - String evtDesc = evt.getDescription(); - if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - if (evtDesc.startsWith(Report.ENTITY_LINK)) { - String idString = evtDesc.substring(Report.ENTITY_LINK.length()); - int id; - try { - id = Integer.parseInt(idString); - } catch (Exception ex) { - id = -1; - } - Entity ent = clientgui.getClient().getGame().getEntity(id); - if (ent != null) { - clientgui.getUnitDisplay().displayEntity(ent); - clientgui.setUnitDisplayVisible(true); - } - } else if (evtDesc.startsWith(Report.TOOLTIP_LINK)) { - String desc = evtDesc.substring(Report.TOOLTIP_LINK.length()); - JOptionPane.showMessageDialog(clientgui, desc, Messages.getString(MSG_DETAILS), - JOptionPane.PLAIN_MESSAGE); - } - } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { - if (evtDesc.startsWith(Report.TOOLTIP_LINK)) { - String desc = evtDesc.substring(Report.TOOLTIP_LINK.length()); - activePane().setToolTipText(desc); - } - } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { - activePane().setToolTipText(null); - } + clientgui.getBoardView().removeBoardViewListener(this); + clientgui.getBoardView().removeKeyListener(this); } - private void adaptToGUIScale() { - UIUtil.adjustContainer(panelTop, UIUtil.FONT_SCALE1); - UIUtil.scaleComp(butDone, UIUtil.FONT_SCALE2); - - for (int i = 0; i < tabs.getTabCount(); i++) { - Component cp = tabs.getComponentAt(i); - if (cp instanceof JScrollPane) { - Component pane = ((JScrollPane) cp).getViewport().getView(); - if (pane instanceof JTextPane) { - JTextPane tp = (JTextPane) pane; - setupStylesheet(tp); - tp.setText(tp.getText()); - } - } - } - } - - @Override - public void preferenceChange(PreferenceChangeEvent e) { - // Update the text size when the GUI scaling changes - if (e.getName().equals(GUIPreferences.GUI_SCALE)) { - adaptToGUIScale(); - } - } - } diff --git a/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java b/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java index 1beb65d5f2d..ced68cd775f 100644 --- a/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java +++ b/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java @@ -609,7 +609,7 @@ private void endMyTurn() { if ((phase == clientgui.getClient().getGame().getPhase()) && (null != next) && (null != ce()) && (next.getOwnerId() != ce().getOwnerId())) { - clientgui.setUnitDisplayVisible(false); + clientgui.maybeShowUnitDisplay(); } cen = Entity.NONE; target(null); diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index b4855242b5e..32d667306c2 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -411,6 +411,8 @@ public class BoardView extends JPanel implements Scrollable, BoardListener, Mous /** The coords where the mouse was last. */ Coords lastCoords; + private GUIPreferences GUIP = GUIPreferences.getInstance(); + /** * Construct a new board view for the specified game */ @@ -419,6 +421,10 @@ public BoardView(final Game game, final MegaMekController controller, ClientGUI this.game = game; this.clientgui = clientgui; + if (GUIP == null) { + GUIP = GUIPreferences.getInstance(); + } + hexImageCache = new ImageCache<>(); tileManager = new TilesetManager(this); @@ -480,8 +486,8 @@ public BoardView(final Game game, final MegaMekController controller, ClientGUI double ihdy = ((double) inhexDelta.y) / ((double) HEX_H) / scale; int oldzoomIndex = zoomIndex; - boolean ZoomNoCtrl = GUIPreferences.getInstance().getMouseWheelZoom(); - boolean wheelFlip = GUIPreferences.getInstance().getMouseWheelZoomFlip(); + boolean ZoomNoCtrl = GUIP.getMouseWheelZoom(); + boolean wheelFlip = GUIP.getMouseWheelZoomFlip(); boolean zoomIn = (we.getWheelRotation() > 0) ^ wheelFlip; // = XOR boolean doZoom = ZoomNoCtrl ^ we.isControlDown(); // = XOR boolean horizontalScroll = !doZoom && we.isShiftDown(); @@ -535,7 +541,7 @@ public void mouseMoved(MouseEvent e) { int deltaX = point.x - prevTipX; int deltaY = point.y - prevTipY; double deltaMagnitude = Math.sqrt(deltaX * deltaX + deltaY * deltaY); - if (deltaMagnitude > GUIPreferences.getInstance().getTooltipDistSuppression()) { + if (deltaMagnitude > GUIP.getTooltipDistSuppression()) { prevTipX = -1; prevTipY = -1; // Set the dismissal delay to 0 so that the tooltip // goes away and does not reappear until the mouse @@ -622,7 +628,7 @@ public void mouseDragged(MouseEvent e) { secondLOSSprite = new CursorSprite(this, Color.red); PreferenceManager.getClientPreferences().addPreferenceChangeListener(this); - GUIPreferences.getInstance().addPreferenceChangeListener(this); + GUIP.addPreferenceChangeListener(this); KeyBindParser.addPreferenceChangeListener(this); SpecialHexDisplay.Type.ARTILLERY_HIT.init(); @@ -871,7 +877,7 @@ public void preferenceChange(PreferenceChangeEvent e) { break; case GUIPreferences.UNIT_LABEL_STYLE: - clientgui.systemMessage("Label style changed to " + GUIPreferences.getInstance().getUnitLabelStyle().description); + clientgui.systemMessage("Label style changed to " + GUIP.getUnitLabelStyle().description); case GUIPreferences.UNIT_LABEL_BORDER: case GUIPreferences.TEAM_COLORING: case GUIPreferences.SHOW_DAMAGE_DECAL: @@ -1018,18 +1024,23 @@ public void removeDisplayable(IDisplayable disp) { */ @Override public synchronized void paintComponent(Graphics g) { - GUIPreferences guip = GUIPreferences.getInstance(); - - if (guip.getBoolean(GUIPreferences.ADVANCED_SHOW_FPS)) { + if (GUIP.getBoolean(GUIPreferences.ADVANCED_SHOW_FPS)) { paintCompsStartTime = System.nanoTime(); } - if (guip.getAntiAliasing()) { + if (GUIP.getAntiAliasing()) { ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } + Rectangle viewRect = scrollpane.getVisibleRect(); + if (!isTileImagesLoaded()) { + MetalTheme theme = new DefaultMetalTheme(); + g.setColor(theme.getControl()); + g.fillRect(-getX(), -getY(), (int) viewRect.getWidth(), + (int) viewRect.getHeight()); + g.setColor(theme.getControlTextColor()); g.drawString(Messages.getString("BoardView1.loadingImages"), 20, 50); if (!tileManager.isStarted()) { LogManager.getLogger().info("Loading images for board"); @@ -1040,7 +1051,6 @@ public synchronized void paintComponent(Graphics g) { return; } - Rectangle viewRect = scrollpane.getVisibleRect(); if (bvBgShouldTile && (bvBgImage != null)) { Rectangle clipping = g.getClipBounds(); int x = 0; @@ -1100,12 +1110,12 @@ public synchronized void paintComponent(Graphics g) { drawHexes(g, g.getClipBounds()); // draw wrecks - if (guip.getShowWrecks() && !useIsometric()) { + if (GUIP.getShowWrecks() && !useIsometric()) { drawSprites(g, wreckSprites); } // Field of Fire - if (!useIsometric() && GUIPreferences.getInstance().getShowFieldOfFire()) { + if (!useIsometric() && GUIP.getShowFieldOfFire()) { drawSprites(g, fieldofFireSprites); } @@ -1215,7 +1225,7 @@ public synchronized void paintComponent(Graphics g) { disp.draw(g, displayablesRect); } - if (guip.getBoolean(GUIPreferences.ADVANCED_SHOW_FPS)) { + if (GUIP.getBoolean(GUIPreferences.ADVANCED_SHOW_FPS)) { if (frameCount == FRAMES) { averageTime = totalTime / FRAMES; totalTime = 0; @@ -1396,7 +1406,7 @@ private void updateShadowMap() { // this seems to need a lot of additional copying (paint shadow on a clean map for this level alone; soften up; copy to real shadow // map with clipping area active; get new clean shadow map for next shadowed level; // too much hassle currently; it works so beautifully - if (!GUIPreferences.getInstance().getShadowMap()) { + if (!GUIP.getShadowMap()) { return; } @@ -1536,7 +1546,7 @@ private void updateShadowMap() { Transparency.TRANSLUCENT); Graphics gS = elevShadow.getGraphics(); Point2D p1 = new Point2D.Double(eSize.width / 2, eSize.height / 2); - if (GUIPreferences.getInstance().getHexInclines()) { + if (GUIP.getHexInclines()) { // With inclines, the level 1 shadows are only very slight int beg = 4; p1.setLocation(p1.getX() + deltaX * beg, p1.getY() + deltaY * beg); @@ -1891,7 +1901,7 @@ private void drawHexLayer(Point p, Graphics g, Color col, boolean outOfFOV, // create stripe effect for FOV darkening but not for colored weapon // ranges - int fogStripes = GUIPreferences.getInstance().getFovStripes(); + int fogStripes = GUIP.getFovStripes(); if (outOfFOV && (fogStripes > 0) && (g instanceof Graphics2D)) { float lineSpacing = fogStripes; // totally transparent here hurts the eyes @@ -2150,7 +2160,7 @@ public BufferedImage getEntireBoardImage(boolean ignoreUnits, boolean useBaseZoo Image entireBoard = createImage(boardSize.width, boardSize.height); Graphics2D boardGraph = (Graphics2D) entireBoard.getGraphics(); boardGraph.setClip(0, 0, boardSize.width, boardSize.height); - if (GUIPreferences.getInstance().getAntiAliasing()) { + if (GUIP.getAntiAliasing()) { boardGraph.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } @@ -2164,12 +2174,12 @@ public BufferedImage getEntireBoardImage(boolean ignoreUnits, boolean useBaseZoo // If we aren't ignoring units, draw everything else if (!ignoreUnits) { // draw wrecks - if (GUIPreferences.getInstance().getShowWrecks() && !useIsometric()) { + if (GUIP.getShowWrecks() && !useIsometric()) { drawSprites(boardGraph, wreckSprites); } // Field of Fire - if (!useIsometric() && GUIPreferences.getInstance().getShowFieldOfFire()) { + if (!useIsometric() && GUIP.getShowFieldOfFire()) { drawSprites(boardGraph, fieldofFireSprites); } @@ -2288,8 +2298,7 @@ private void drawHexes(Graphics g, Rectangle view, boolean saveBoardImage) { if ((hex != null)) { drawHex(c, g, saveBoardImage); drawOrthograph(c, g); - if (GUIPreferences.getInstance() - .getShowFieldOfFire()) { + if (GUIP.getShowFieldOfFire()) { drawHexSpritesForHex(c, g, fieldofFireSprites); } drawHexSpritesForHex(c, g, moveEnvSprites); @@ -2308,7 +2317,7 @@ private void drawHexes(Graphics g, Rectangle view, boolean saveBoardImage) { Hex hex = board.getHex(c); if (hex != null) { if (!saveBoardImage) { - if (GUIPreferences.getInstance().getShowWrecks()) { + if (GUIP.getShowWrecks()) { drawIsometricWreckSpritesForHex(c, g, isometricWreckSprites); } drawIsometricSpritesForHex(c, g, isometricSprites); @@ -2342,7 +2351,6 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { return; } - final GUIPreferences guip = GUIPreferences.getInstance(); final Hex hex = game.getBoard().getHex(c); final Point hexLoc = getHexLocation(c); @@ -2491,7 +2499,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { } // Add the terrain & building shadows - if (guip.getBoolean(GUIPreferences.SHADOWMAP) && (shadowMap != null)) { + if (GUIP.getBoolean(GUIPreferences.SHADOWMAP) && (shadowMap != null)) { Point p1SRC = getHexLocationLargeTile(c.getX(), c.getY(), 1); Point p2SRC = new Point(p1SRC.x + HEX_W, p1SRC.y + HEX_H); Point p2DST = new Point(hex_size.width, hex_size.height); @@ -2531,7 +2539,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { } // AO Hex Shadow in this hex when a higher one is adjacent - if (guip.getBoolean(GUIPreferences.AOHEXSHADOWS)) { + if (GUIP.getBoolean(GUIPreferences.AOHEXSHADOWS)) { for (int dir : allDirections) { Shape ShadowShape = getElevationShadowArea(c, dir); GradientPaint gpl = getElevationShadowGP(c, dir); @@ -2600,7 +2608,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { } // Darken the hex for nighttime, if applicable - if (guip.getBoolean(GUIPreferences.ADVANCED_DARKEN_MAP_AT_NIGHT) + if (GUIP.getBoolean(GUIPreferences.ADVANCED_DARKEN_MAP_AT_NIGHT) && IlluminationLevel.determineIlluminationLevel(game, c).isNone() && (game.getPlanetaryConditions().getLight() > PlanetaryConditions.L_DAY)) { for (int x = 0; x < hexImage.getWidth(); ++x) { @@ -2611,7 +2619,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { } // Set the text color according to Preferences or Light Gray in space - g.setColor(guip.getMapTextColor()); + g.setColor(GUIP.getMapTextColor()); if (game.getBoard().inSpace()) { g.setColor(Color.LIGHT_GRAY); } @@ -2634,7 +2642,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { } // write hex coordinate unless deactivated or scale factor too small - if (guip.getBoolean(GUIPreferences.SHOW_COORDS) && (scale >= 0.5)) { + if (GUIP.getCoordsEnabled() && (scale >= 0.5)) { drawCenteredString(c.getBoardNum(), 0, (int) (12 * scale), font_hexnum, g); } @@ -2658,13 +2666,13 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { ypos -= 10; } if (height > 0) { - g.setColor(GUIPreferences.getInstance().getColor("AdvancedBuildingTextColor")); + g.setColor(GUIP.getColor("AdvancedBuildingTextColor")); drawCenteredString(Messages.getString("BoardView1.HEIGHT") + height, 0, (int) (ypos * scale), font_elev, g); ypos -= 10; } if (hex.terrainLevel(Terrains.FOLIAGE_ELEV) == 1) { - g.setColor(GUIPreferences.getInstance().getColor( + g.setColor(GUIP.getColor( GUIPreferences.ADVANCED_LOW_FOLIAGE_COLOR)); drawCenteredString(Messages.getString("BoardView1.LowFoliage"), 0, (int) (ypos * scale), font_elev, g); @@ -2695,42 +2703,42 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { // draw elevation borders if (drawElevationLine(c, 0)) { drawIsometricElevation(c, Color.GRAY, p1, p2, 0, g); - if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { + if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { g.drawLine(s21, 0, s62, 0); } } if (drawElevationLine(c, 1)) { drawIsometricElevation(c, Color.DARK_GRAY, p3, p1, 1, g); - if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { + if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { g.drawLine(s62, 0, s83, s35); } } if (drawElevationLine(c, 2)) { drawIsometricElevation(c, Color.LIGHT_GRAY, p4, p5, 2, g); - if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { + if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { g.drawLine(s83, s36, s62, s71); } } if (drawElevationLine(c, 3)) { drawIsometricElevation(c, Color.GRAY, p6, p5, 3, g); - if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { + if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { g.drawLine(s62, s71, s21, s71); } } if (drawElevationLine(c, 4)) { drawIsometricElevation(c, Color.DARK_GRAY, p7, p6, 4, g); - if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { + if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { g.drawLine(s21, s71, 0, s36); } } if (drawElevationLine(c, 5)) { drawIsometricElevation(c, Color.LIGHT_GRAY, p8, p2, 5, g); - if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { + if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) { g.drawLine(0, s35, s21, 0); } @@ -2739,8 +2747,8 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { boolean hasLoS = fovHighlightingAndDarkening.draw(g, c, 0, 0, saveBoardImage); // draw mapsheet borders - if (GUIPreferences.getInstance().getShowMapsheets()) { - g.setColor(GUIPreferences.getInstance().getColor(GUIPreferences.ADVANCED_MAPSHEET_COLOR)); + if (GUIP.getShowMapsheets()) { + g.setColor(GUIP.getColor(GUIPreferences.ADVANCED_MAPSHEET_COLOR)); if ((c.getX() % 16) == 0) { // left edge of sheet (edge 4 & 5) g.drawLine(s21, s71, 0, s36); @@ -2768,7 +2776,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { } } - if (!hasLoS && guip.getFovGrayscale()) { + if (!hasLoS && GUIP.getFovGrayscale()) { // rework the pixels to grayscale for (int x = 0; x < hexImage.getWidth(); x++) { for (int y = 0; y < hexImage.getHeight(); y++) { @@ -2816,7 +2824,7 @@ private void drawOrthograph(Coords c, Graphics boardGraph) { BufferedImage scaledImage = ImageUtil.createAcceleratedImage(getScaledImage(image, true)); // Darken the hex for nighttime, if applicable - if (GUIPreferences.getInstance().getBoolean(GUIPreferences.ADVANCED_DARKEN_MAP_AT_NIGHT) + if (GUIP.getBoolean(GUIPreferences.ADVANCED_DARKEN_MAP_AT_NIGHT) && IlluminationLevel.determineIlluminationLevel(game, c).isNone() && (game.getPlanetaryConditions().getLight() > PlanetaryConditions.L_DAY)) { for (int x = 0; x < scaledImage.getWidth(null); ++x) { @@ -2864,7 +2872,7 @@ private final void drawIsometricElevation(Coords c, Color color, Point p1, Point final Hex dest = game.getBoard().getHexInDir(c, dir); final Hex src = game.getBoard().getHex(c); - if (!useIsometric() || GUIPreferences.getInstance().getBoolean(GUIPreferences.FLOATINGISO)) { + if (!useIsometric() || GUIP.getBoolean(GUIPreferences.FLOATINGISO)) { return; } @@ -3025,7 +3033,7 @@ public int getNightDarkenedColor(int rgb) { // no shadow area when the current hex is not lower than the next hex in direction if (srcHex.getLevel() >= destHex.getLevel()) { return null; - } else if (GUIPreferences.getInstance().getHexInclines() + } else if (GUIP.getHexInclines() && (destHex.getLevel() - srcHex.getLevel() < 2) && !destHex.hasCliffTopTowards(srcHex)) { return null; @@ -3580,7 +3588,7 @@ public void centerOnHex(@Nullable Coords c) { return; } - if (GUIPreferences.getInstance().getBoolean("SOFTCENTER")) { + if (GUIP.getBoolean("SOFTCENTER")) { // Soft Centering: // set the target point Point p = getCentreHexLocation(c); @@ -3752,20 +3760,20 @@ public void drawMovementData(Entity entity, MovePath md) { case MOVE_RUN: case MOVE_VTOL_RUN: case MOVE_OVER_THRUST: - col = GUIPreferences.getInstance().getColor("AdvancedMoveRunColor"); + col = GUIP.getColor("AdvancedMoveRunColor"); break; case MOVE_SPRINT: case MOVE_VTOL_SPRINT: - col = GUIPreferences.getInstance().getColor("AdvancedMoveSprintColor"); + col = GUIP.getColor("AdvancedMoveSprintColor"); break; case MOVE_JUMP: - col = GUIPreferences.getInstance().getColor("AdvancedMoveJumpColor"); + col = GUIP.getColor("AdvancedMoveJumpColor"); break; case MOVE_ILLEGAL: - col = GUIPreferences.getInstance().getColor("AdvancedMoveIllegalColor"); + col = GUIP.getColor("AdvancedMoveIllegalColor"); break; default: - col = GUIPreferences.getInstance().getColor("AdvancedMoveDefaultColor"); + col = GUIP.getColor("AdvancedMoveDefaultColor"); break; } movementTarget = md.getLastStep().getPosition(); @@ -3851,24 +3859,23 @@ public void setMovementEnvelope(Map mvEnvData, int walk, int ru return; } - GUIPreferences guip = GUIPreferences.getInstance(); for (Coords loc : mvEnvData.keySet()) { Color spriteColor = null; int mvType = -1; if (gear == MovementDisplay.GEAR_JUMP || gear == MovementDisplay.GEAR_DFA) { if (mvEnvData.get(loc) <= jump) { - spriteColor = guip.getColor(GUIPreferences.ADVANCED_MOVE_JUMP_COLOR); + spriteColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_JUMP_COLOR); mvType = 1; } } else { if (mvEnvData.get(loc) <= walk) { - spriteColor = guip.getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); + spriteColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR); mvType = 2; } else if (mvEnvData.get(loc) <= run) { - spriteColor = guip.getColor(GUIPreferences.ADVANCED_MOVE_RUN_COLOR); + spriteColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_RUN_COLOR); mvType = 3; } else { - spriteColor = guip.getColor(GUIPreferences.ADVANCED_MOVE_SPRINT_COLOR); + spriteColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_SPRINT_COLOR); mvType = 4; } } @@ -4342,8 +4349,8 @@ protected void secondLOSHex(Coords c2, Coords c1) { StringBuffer message = new StringBuffer(); LosEffects le; if ((ae == null) || (te == null)) { - boolean mechInFirst = GUIPreferences.getInstance().getMechInFirst(); - boolean mechInSecond = GUIPreferences.getInstance().getMechInSecond(); + boolean mechInFirst = GUIP.getMechInFirst(); + boolean mechInSecond = GUIP.getMechInSecond(); LosEffects.AttackInfo ai = new LosEffects.AttackInfo(); ai.attackPos = c1; ai.targetPos = c2; @@ -4487,7 +4494,7 @@ synchronized boolean doMoveUnits(long idleTime) { if (!movingUnits.isEmpty()) { moveWait += idleTime; - if (moveWait > GUIPreferences.getInstance().getInt("AdvancedMoveStepDelay")) { + if (moveWait > GUIP.getInt("AdvancedMoveStepDelay")) { ArrayList spent = new ArrayList<>(); for (MovingUnit move : movingUnits) { @@ -4617,9 +4624,9 @@ public void mouseExited(MouseEvent me) { // Reset the tooltip dismissal delay to the preference // value so that elements outside the boardview can // use tooltips - if (GUIPreferences.getInstance().getTooltipDismissDelay() >= 0) { + if (GUIP.getTooltipDismissDelay() >= 0) { ToolTipManager.sharedInstance().setDismissDelay( - GUIPreferences.getInstance().getTooltipDismissDelay()); + GUIP.getTooltipDismissDelay()); } else { ToolTipManager.sharedInstance().setDismissDelay(dismissDelay); } @@ -4890,7 +4897,7 @@ public void mouseAction(Coords coords, int mtype, int modifiers, int mouseButton @Override public void boardNewBoard(BoardEvent b) { updateBoard(); - game.getBoard().initializeAllAutomaticTerrain(GUIPreferences.getInstance().getHexInclines()); + game.getBoard().initializeAllAutomaticTerrain(GUIP.getHexInclines()); clearHexImageCache(); clearShadowMap(); repaint(); @@ -4951,7 +4958,6 @@ public void gameEntityChange(GameEntityChangeEvent e) { final Vector mp = e.getMovePath(); final Entity en = e.getEntity(); final GameOptions gopts = game.getOptions(); - GUIPreferences guip = GUIPreferences.getInstance(); updateEcmList(); @@ -4972,7 +4978,7 @@ public void gameEntityChange(GameEntityChangeEvent e) { if (game.getPhase().isMovement()) { refreshMoveVectors(); } - if ((mp != null) && !mp.isEmpty() && guip.getShowMoveStep() + if ((mp != null) && !mp.isEmpty() && GUIP.getShowMoveStep() && !gopts.booleanOption(OptionsConstants.INIT_SIMULTANEOUS_MOVEMENT)) { if ((localPlayer == null) || !game.getOptions().booleanOption(OptionsConstants.ADVANCED_DOUBLE_BLIND) @@ -5029,7 +5035,7 @@ public void gameBoardNew(GameBoardNewEvent e) { } } } - game.getBoard().initializeAllAutomaticTerrain(GUIPreferences.getInstance().getHexInclines()); + game.getBoard().initializeAllAutomaticTerrain(GUIP.getHexInclines()); clearHexImageCache(); updateBoard(); clearShadowMap(); @@ -5043,7 +5049,7 @@ public void gameBoardChanged(GameBoardChangeEvent e) { @Override public void gamePhaseChange(GamePhaseChangeEvent e) { - if (GUIPreferences.getInstance().getGameSummaryBoardView() + if (GUIP.getGameSummaryBoardView() && (e.getOldPhase().isDeployment() || e.getOldPhase().isMovement() || e.getOldPhase().isTargeting() || e.getOldPhase().isFiring() || e.getOldPhase().isPhysical())) { @@ -5451,7 +5457,7 @@ public String getHexTooltip(MouseEvent e) { StringBuffer txt = new StringBuffer(HTML_BEGIN); // Hex Terrain - if (GUIPreferences.getInstance().getShowMapHexPopup() && (mhex != null)) { + if (GUIP.getShowMapHexPopup() && (mhex != null)) { appendTerrainTooltip(txt, mhex); // Distance from the selected unit and a planned movement end point @@ -5687,9 +5693,9 @@ public String getHexTooltip(MouseEvent e) { // Now that a valid tooltip text seems to be present, // (re)set the tooltip dismissal delay time to the preference // value so that the tooltip actually appears - if (GUIPreferences.getInstance().getTooltipDismissDelay() >= 0) { + if (GUIP.getTooltipDismissDelay() >= 0) { ToolTipManager.sharedInstance().setDismissDelay( - GUIPreferences.getInstance().getTooltipDismissDelay()); + GUIP.getTooltipDismissDelay()); } else { ToolTipManager.sharedInstance().setDismissDelay(dismissDelay); } @@ -6041,7 +6047,7 @@ private void zoom() { checkZoomIndex(); stopSoftCentering(); scale = ZOOM_FACTORS[zoomIndex]; - GUIPreferences.getInstance().setMapZoomIndex(zoomIndex); + GUIP.setMapZoomIndex(zoomIndex); hex_size = new Dimension((int) (HEX_W * scale), (int) (HEX_H * scale)); @@ -6233,7 +6239,7 @@ public void die() { ourTask.cancel(); fovHighlightingAndDarkening.die(); KeyBindParser.removePreferenceChangeListener(this); - GUIPreferences.getInstance().removePreferenceChangeListener(this); + GUIP.removePreferenceChangeListener(this); PreferenceManager.getClientPreferences().removePreferenceChangeListener(this); } @@ -6287,8 +6293,8 @@ public void clearHexImageCache(Set coords) { * Check to see if the HexImageCache should be cleared because of field-of-view changes. */ public void checkFoVHexImageCacheClear() { - boolean darken = GUIPreferences.getInstance().getBoolean(GUIPreferences.FOV_DARKEN); - boolean highlight = GUIPreferences.getInstance().getBoolean(GUIPreferences.FOV_HIGHLIGHT); + boolean darken = GUIP.getBoolean(GUIPreferences.FOV_DARKEN); + boolean highlight = GUIP.getBoolean(GUIPreferences.FOV_HIGHLIGHT); if (game.getPhase().isMovement() && (darken || highlight)) { clearHexImageCache(); } diff --git a/megamek/src/megamek/client/ui/swing/boardview/PlanetaryConditionsOverlay.java b/megamek/src/megamek/client/ui/swing/boardview/PlanetaryConditionsOverlay.java index 747a3abc4d6..52f90bd920b 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/PlanetaryConditionsOverlay.java +++ b/megamek/src/megamek/client/ui/swing/boardview/PlanetaryConditionsOverlay.java @@ -153,7 +153,7 @@ public void draw(Graphics graph, Rectangle clipBounds) { } } - distSide = clientGui.getWidth() - (overlayWidth + 100); + distSide = clipBounds.width - (overlayWidth + 100); // draw the cached image to the boardview // uses Composite to draw the image with variable transparency diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index d488719e034..fcc4d3dc5af 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -84,6 +84,7 @@ import java.awt.image.ImageFilter; import java.awt.image.ImageProducer; import java.io.*; +import java.text.MessageFormat; import java.text.NumberFormat; import java.util.List; import java.util.*; @@ -110,7 +111,7 @@ public class ChatLounge extends AbstractPhaseDisplay implements static final int MEKTREE_ROWHEIGHT_FULL = 40; private final static int TEAMOVERVIEW_BORDER = 45; private final static int MAP_POPUP_OFFSET = -2; // a slight offset so cursor sits inside popup - + private JTabbedPane panTabs = new JTabbedPane(); private JPanel panUnits = new JPanel(); private JPanel panMap = new JPanel(); @@ -345,6 +346,8 @@ public class ChatLounge extends AbstractPhaseDisplay implements private static final String MSG_VIEWGAMEBOARD = Messages.getString("BoardSelectionDialog.ViewGameBoard"); private static final String MSG_FIGHTERSQUADRONBOMBERROR = Messages.getString("FighterSquadron.bomberror"); + private static final String MSG_MAPSETUPXMLFILES = Messages.getString("ChatLounge.map.SetupXMLfiles"); + /** Creates a new chat lounge for the clientgui.getClient(). */ public ChatLounge(ClientGUI clientgui) { super(clientgui, SkinSpecification.UIComponents.ChatLounge.getComp(), @@ -2077,7 +2080,7 @@ private void saveMapSetup() { selectedFile = new File(selectedFile.getPath() + CL_KEY_FILEEXTENTION_XML); } if (selectedFile.exists()) { - String msg = Messages.getFormattedString(MSG_MAPSAVESETUPREPLACE, selectedFile.getName()); + String msg = MessageFormat.format(MSG_MAPSAVESETUPREPLACE, selectedFile.getName()); if (!MMConfirmDialog.confirm(clientgui.frame, MSG_MAPCONFIRMREPLACE, msg)) { return; } @@ -2154,7 +2157,7 @@ public boolean accept(File f) { @Override public String getDescription() { - return "Map Setup XML files"; + return MSG_MAPSETUPXMLFILES; } }; diff --git a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java index 59bdb212b50..cd89192d035 100644 --- a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java +++ b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java @@ -162,7 +162,7 @@ public void windowClosing(WindowEvent e) { GUIP.setMinimapEnabled(false); } }); - + result.add(new Minimap(result, game, bv, cg)); result.pack(); return result; @@ -510,7 +510,7 @@ private synchronized void drawMap(boolean forceDraw) { addRoadElements(h, j, k); // Color invalid hexes red when in the Map Editor if ((game != null) && game.getPhase().isUnknown() && !h.isValid(null)) { - gg.setColor(GUIPreferences.getInstance().getWarningColor()); + gg.setColor(GUIP.getWarningColor()); paintCoord(gg, j, k, true); } } @@ -1342,11 +1342,12 @@ public void boardChangedHex(BoardEvent b) { private final GameListener gameListener = new GameListenerAdapter() { @Override public void gamePhaseChange(GamePhaseChangeEvent e) { - if (GUIPreferences.getInstance().getGameSummaryMinimap() + if (GUIP.getGameSummaryMinimap() && (e.getOldPhase().isDeployment() || e.getOldPhase().isMovement() || e.getOldPhase().isTargeting() || e.getOldPhase().isPremovement() || e.getOldPhase().isPrefiring() || e.getOldPhase().isFiring() || e.getOldPhase().isPhysical())) { + File dir = new File(Configuration.gameSummaryImagesMMDir(), game.getUUIDString()); if (!dir.exists()) { dir.mkdirs(); diff --git a/megamek/src/megamek/client/ui/swing/skinEditor/SkinEditorMainGUI.java b/megamek/src/megamek/client/ui/swing/skinEditor/SkinEditorMainGUI.java index eb33a4898c8..80e55ac29a3 100644 --- a/megamek/src/megamek/client/ui/swing/skinEditor/SkinEditorMainGUI.java +++ b/megamek/src/megamek/client/ui/swing/skinEditor/SkinEditorMainGUI.java @@ -409,16 +409,6 @@ public void switchPanel(GamePhase phase) { // Handle phase-specific items. switch (phase) { case LOUNGE: - // reset old report tabs and images, if any - ReportDisplay rD = (ReportDisplay) phaseComponents.get(String - .valueOf(GamePhase.INITIATIVE_REPORT)); - if (rD != null) { - rD.resetTabs(); - } - //ChatLounge cl = (ChatLounge) phaseComponents.get( - // String.valueOf(Game.Phase.LOUNGE)); - // cb.setDoneButton(cl.butDone); - // cl.add(cb.getComponent(), BorderLayout.SOUTH); getBoardView().getTilesetManager().reset(); break; case DEPLOY_MINEFIELDS: @@ -437,11 +427,6 @@ public void switchPanel(GamePhase phase) { case PHYSICAL_REPORT: case END_REPORT: case VICTORY: - rD = (ReportDisplay) phaseComponents.get(String - .valueOf(GamePhase.INITIATIVE_REPORT)); - // cb.setDoneButton(rD.butDone); - //rD.add(cb.getComponent(), GBC.eol().fill( - // GridBagConstraints.HORIZONTAL)); break; default: break; @@ -674,7 +659,7 @@ public int[] doChoiceDialog(String title, String question, String[] choices) { */ public void doAlertDialog(String title, String message) { JTextPane textArea = new JTextPane(); - ReportDisplay.setupStylesheet(textArea); + Report.setupStylesheet(textArea); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea, diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index e2f53fb5c73..33b95904d8a 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -16,15 +16,20 @@ import megamek.client.event.MechDisplayEvent; import megamek.client.event.MechDisplayListener; +import megamek.client.ui.Messages; +import megamek.client.ui.dialogs.UnitDisplayDialog; import megamek.client.ui.swing.ClientGUI; import megamek.client.ui.swing.GUIPreferences; import megamek.client.ui.swing.UnitDisplayOrderPreferences; import megamek.client.ui.swing.util.CommandAction; import megamek.client.ui.swing.util.KeyCommandBind; import megamek.client.ui.swing.util.MegaMekController; +import megamek.client.ui.swing.util.UIUtil; import megamek.client.ui.swing.widget.MechPanelTabStrip; import megamek.common.Entity; import megamek.common.annotations.Nullable; +import megamek.common.preference.IPreferenceChangeListener; +import megamek.common.preference.PreferenceChangeEvent; import org.apache.logging.log4j.LogManager; import javax.swing.*; @@ -38,10 +43,11 @@ * Displays the info for a mech. This is also a sort of interface for special * movement and firing actions. */ -public class UnitDisplay extends JPanel { +public class UnitDisplay extends JPanel implements IPreferenceChangeListener { // buttons & gizmos for top level private static final long serialVersionUID = -2060993542227677984L; private JButton butSwitchView; + private JButton butSwitchLocation; private JPanel panA1; private JPanel panA2; private JPanel panB1; @@ -63,6 +69,7 @@ public class UnitDisplay extends JPanel { private ExtraPanel ePan; private ClientGUI clientgui; private Entity currentlyDisplaying; + private JLabel labTitle; private ArrayList eventListeners = new ArrayList<>(); public static final String NON_TABBED_GENERAL = "General"; @@ -86,6 +93,12 @@ public class UnitDisplay extends JPanel { public static final int NON_TABBED_FOUR_INDEX = 4; public static final int NON_TABBED_FIVE_INDEX = 5; + private static final String MSG_SWITCHLOCATION = Messages.getString("UnitDisplay.SwitchLocation"); + private static final String MSG_SWITCHVIEW = Messages.getString("UnitDisplay.SwitchView"); + + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + private static final UnitDisplayOrderPreferences UDOP = UnitDisplayOrderPreferences.getInstance(); + /** * Creates and lays out a new mech display. * @@ -103,6 +116,8 @@ public UnitDisplay(@Nullable ClientGUI clientgui, super(new GridBagLayout()); this.clientgui = clientgui; + labTitle = new JLabel("Title"); + tabStrip = new MechPanelTabStrip(this); displayP = new JPanel(new CardLayout()); mPan = new SummaryPanel(this); @@ -120,6 +135,9 @@ public UnitDisplay(@Nullable ClientGUI clientgui, c.weighty = 0.0; c.gridwidth = GridBagConstraints.REMAINDER; + ((GridBagLayout) getLayout()).setConstraints(labTitle, c); + add(labTitle); + ((GridBagLayout) getLayout()).setConstraints(tabStrip, c); add(tabStrip); @@ -144,7 +162,8 @@ public UnitDisplay(@Nullable ClientGUI clientgui, splitA1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitB1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitC1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - butSwitchView = new JButton("switch view"); + butSwitchView = new JButton(MSG_SWITCHVIEW); + butSwitchLocation = new JButton(MSG_SWITCHLOCATION); splitABC.setOneTouchExpandable(true); splitBC.setOneTouchExpandable(true); @@ -173,55 +192,71 @@ public UnitDisplay(@Nullable ClientGUI clientgui, splitABC.setLeftComponent(splitA1); splitABC.setRightComponent(splitBC); - splitABC.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitABCLoc()); - splitBC.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitBCLoc()); - splitA1.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitA1Loc()); - splitB1.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitB1Loc()); - splitC1.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitC1Loc()); - - butSwitchView.setPreferredSize(new Dimension(500,20)); + splitABC.setDividerLocation(GUIP.getUnitDisplaySplitABCLoc()); + splitBC.setDividerLocation(GUIP.getUnitDisplaySplitBCLoc()); + splitA1.setDividerLocation(GUIP.getUnitDisplaySplitA1Loc()); + splitB1.setDividerLocation(GUIP.getUnitDisplaySplitB1Loc()); + splitC1.setDividerLocation(GUIP.getUnitDisplaySplitC1Loc()); c.fill = GridBagConstraints.BOTH; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1.0; c.weighty = 0.0; - c.gridwidth = GridBagConstraints.REMAINDER; + c.gridwidth = 1; + c.anchor = GridBagConstraints.WEST; ((GridBagLayout) getLayout()).setConstraints(butSwitchView, c); add(butSwitchView); + c.weightx = 1.0; + c.anchor = GridBagConstraints.EAST; + c.gridwidth = GridBagConstraints.REMAINDER; + ((GridBagLayout) getLayout()).setConstraints(butSwitchLocation, c); + add(butSwitchLocation); + butSwitchView.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (clientgui != null) { - if (!(GUIPreferences.getInstance().getDisplayStartTabbed())) { + UnitDisplayDialog unitDisplayDialog = clientgui.getUnitDisplayDialog(); + if (!(GUIP.getUnitDisplayStartTabbed())) { saveSplitterLoc(); - GUIPreferences.getInstance().setDisplayNontabbedPosX(clientgui.unitDisplay.getRootPane().getParent().getLocation().x); - GUIPreferences.getInstance().setDisplayNontabbedPosY(clientgui.unitDisplay.getRootPane().getParent().getLocation().y); - GUIPreferences.getInstance().setDisplayNonTabbedSizeWidth(clientgui.unitDisplay.getRootPane().getParent().getSize().width); - GUIPreferences.getInstance().setDisplayNonTabbedSizeHeight(clientgui.unitDisplay.getRootPane().getParent().getSize().height); - clientgui.unitDisplay.getRootPane().getParent().setLocation(GUIPreferences.getInstance().getDisplayPosX(), GUIPreferences.getInstance().getDisplayPosY()); - clientgui.unitDisplay.getRootPane().getParent().setSize(GUIPreferences.getInstance().getDisplaySizeWidth(), GUIPreferences.getInstance().getDisplaySizeHeight()); + GUIP.setUnitDisplayNontabbedPosX(unitDisplayDialog.getLocation().x); + GUIP.setUnitDisplayNontabbedPosY(unitDisplayDialog.getLocation().y); + GUIP.setUnitDisplayNonTabbedSizeWidth(unitDisplayDialog.getSize().width); + GUIP.setUnitDisplayNonTabbedSizeHeight(unitDisplayDialog.getSize().height); + unitDisplayDialog.setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY()); + unitDisplayDialog.setSize(GUIP.getUnitDisplaySizeWidth(), GUIP.getUnitDisplaySizeHeight()); setDisplayTabbed(); } else { - GUIPreferences.getInstance().setDisplayPosX(clientgui.unitDisplay.getRootPane().getParent().getLocation().x); - GUIPreferences.getInstance().setDisplayPosY(clientgui.unitDisplay.getRootPane().getParent().getLocation().y); - GUIPreferences.getInstance().setDisplaySizeWidth(clientgui.unitDisplay.getRootPane().getParent().getSize().width); - GUIPreferences.getInstance().setDisplaySizeHeight(clientgui.unitDisplay.getRootPane().getParent().getSize().height); - clientgui.unitDisplay.getRootPane().getParent().setLocation(GUIPreferences.getInstance().getDisplayNontabbedPosX(), GUIPreferences.getInstance().getDisplayNontabbedPosY()); - clientgui.unitDisplay.getRootPane().getParent().setSize(GUIPreferences.getInstance().getDisplayNonTabbedSizeWidth(), GUIPreferences.getInstance().getDisplayNonTabbedSizeHeight()); + GUIP.setUnitDisplayPosX(unitDisplayDialog.getLocation().x); + GUIP.setUnitDisplayPosY(unitDisplayDialog.getLocation().y); + GUIP.setUnitDisplaySizeWidth(unitDisplayDialog.getSize().width); + GUIP.setUnitDisplaySizeHeight(unitDisplayDialog.getSize().height); + unitDisplayDialog.setLocation(GUIP.getUnitDisplayNontabbedPosX(), GUIP.getUnitDisplayNontabbedPosY()); + unitDisplayDialog.setSize(GUIP.getUnitDisplayNonTabbedSizeWidth(), GUIP.getUnitDisplayNonTabbedSizeHeight()); setDisplayNonTabbed(); } } } }); - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + butSwitchLocation.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + GUIP.toggleUnitDisplayLocation(); + } + }); + + if (GUIP.getUnitDisplayStartTabbed()) { setDisplayTabbed(); } else { setDisplayNonTabbed(); } + + adaptToGUIScale(); + GUIP.addPreferenceChangeListener(this); } /** @@ -229,7 +264,6 @@ public void actionPerformed(ActionEvent e) { * */ private void setDisplayTabbed() { - tabStrip.setVisible(true); displayP.removeAll(); @@ -252,7 +286,7 @@ private void setDisplayTabbed() { displayP.revalidate(); displayP.repaint(); - GUIPreferences.getInstance().setDisplayStartTabbed(true); + GUIP.setUnitDisplayStartTabbed(true); } /** @@ -277,19 +311,19 @@ public void setDisplayNonTabbed() { sPan.setVisible(true); ePan.setVisible(true); - linkParentChild(UnitDisplay.NON_TABBED_A1, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A1)); - linkParentChild(UnitDisplay.NON_TABBED_B1, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B1)); - linkParentChild(UnitDisplay.NON_TABBED_C1, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C1)); - linkParentChild(UnitDisplay.NON_TABBED_A2, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A2)); - linkParentChild(UnitDisplay.NON_TABBED_B2, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B2)); - linkParentChild(UnitDisplay.NON_TABBED_C2, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C2)); + linkParentChild(UnitDisplay.NON_TABBED_A1, UDOP.getString(UnitDisplay.NON_TABBED_A1)); + linkParentChild(UnitDisplay.NON_TABBED_B1, UDOP.getString(UnitDisplay.NON_TABBED_B1)); + linkParentChild(UnitDisplay.NON_TABBED_C1, UDOP.getString(UnitDisplay.NON_TABBED_C1)); + linkParentChild(UnitDisplay.NON_TABBED_A2, UDOP.getString(UnitDisplay.NON_TABBED_A2)); + linkParentChild(UnitDisplay.NON_TABBED_B2, UDOP.getString(UnitDisplay.NON_TABBED_B2)); + linkParentChild(UnitDisplay.NON_TABBED_C2, UDOP.getString(UnitDisplay.NON_TABBED_C2)); displayP.add(splitABC); displayP.revalidate(); displayP.repaint(); - GUIPreferences.getInstance().setDisplayStartTabbed(false); + GUIP.setUnitDisplayStartTabbed(false); } /** @@ -297,11 +331,11 @@ public void setDisplayNonTabbed() { * */ public void saveSplitterLoc() { - GUIPreferences.getInstance().setDisplaySplitABCLoc(splitABC.getDividerLocation()); - GUIPreferences.getInstance().setDisplaySplitBCLoc(splitBC.getDividerLocation()); - GUIPreferences.getInstance().setDisplaySplitA1Loc(splitA1.getDividerLocation()); - GUIPreferences.getInstance().setDisplaySplitB1Loc(splitB1.getDividerLocation()); - GUIPreferences.getInstance().setDisplaySplitC2Loc(splitC1.getDividerLocation()); + GUIP.setUnitDisplaySplitABCLoc(splitABC.getDividerLocation()); + GUIP.setUnitDisplaySplitBCLoc(splitBC.getDividerLocation()); + GUIP.setUnitDisplaySplitA1Loc(splitA1.getDividerLocation()); + GUIP.setUnitDisplaySplitB1Loc(splitB1.getDividerLocation()); + GUIP.setUnitDisplaySplitC2Loc(splitC1.getDividerLocation()); } /** @@ -358,6 +392,10 @@ private void addChildPanel(JPanel p, String v) { } } + public void setTitleVisible(boolean b) { + labTitle.setVisible(b); + } + /** * Register the keyboard commands that the UnitDisplay should process * @@ -381,7 +419,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SUMMARY); } @@ -405,7 +443,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.PILOT); } @@ -429,7 +467,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.ARMOR); } @@ -453,7 +491,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SYSTEMS); } @@ -477,7 +515,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.WEAPONS); } @@ -501,7 +539,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.EXTRAS); } @@ -547,6 +585,7 @@ public void displayEntity(Entity en) { if (clientgui != null) { clientgui.getUnitDisplayDialog().setTitle(enName); + labTitle.setText(enName); } currentlyDisplaying = en; @@ -570,7 +609,7 @@ public Entity getCurrentEntity() { * Changes to the specified panel. */ public void showPanel(String s) { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, s); } @@ -594,7 +633,7 @@ public void showPanel(String s) { * @param loc */ public void showSpecificSystem(int loc) { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SYSTEMS); } @@ -639,4 +678,16 @@ void processMechDisplayEvent(MechDisplayEvent event) { public ClientGUI getClientGUI() { return clientgui; } -} \ No newline at end of file + + private void adaptToGUIScale() { + UIUtil.adjustContainer(this, UIUtil.FONT_SCALE1); + } + + @Override + public void preferenceChange(PreferenceChangeEvent e) { + // Update the text size when the GUI scaling changes + if (e.getName().equals(GUIPreferences.GUI_SCALE)) { + adaptToGUIScale(); + } + } +} diff --git a/megamek/src/megamek/common/Report.java b/megamek/src/megamek/common/Report.java index d3cec3d650a..a294bc36e68 100755 --- a/megamek/src/megamek/common/Report.java +++ b/megamek/src/megamek/common/Report.java @@ -19,6 +19,7 @@ import org.apache.logging.log4j.LogManager; import javax.swing.*; +import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; import java.awt.*; import java.io.Serializable; @@ -561,6 +562,12 @@ public static void addNewline(Vector v) { } } + public static void setupStylesheet(JTextPane pane) { + pane.setContentType("text/html"); + StyleSheet styleSheet = ((HTMLEditorKit) pane.getEditorKit()).getStyleSheet(); + Report.setupStylesheet(styleSheet); + } + public static void setupStylesheet(StyleSheet styleSheet) { Font font = UIManager.getFont("Label.font"); int size = UIUtil.scaleForGUI(UIUtil.FONT_SCALE1); diff --git a/megamek/src/megamek/common/enums/GamePhase.java b/megamek/src/megamek/common/enums/GamePhase.java index 09ff7afc137..c10d74087e4 100644 --- a/megamek/src/megamek/common/enums/GamePhase.java +++ b/megamek/src/megamek/common/enums/GamePhase.java @@ -181,6 +181,7 @@ public boolean isReport() { case FIRING_REPORT: case PHYSICAL_REPORT: case END_REPORT: + case VICTORY: return true; default: return false; @@ -202,6 +203,14 @@ public boolean isOnMap() { case PHYSICAL: case DEPLOY_MINEFIELDS: case SET_ARTILLERY_AUTOHIT_HEXES: + case INITIATIVE_REPORT: + case TARGETING_REPORT: + case MOVEMENT_REPORT: + case OFFBOARD_REPORT: + case FIRING_REPORT: + case PHYSICAL_REPORT: + case END_REPORT: + case VICTORY: return true; default: return false; diff --git a/megamek/src/megamek/server/GameManager.java b/megamek/src/megamek/server/GameManager.java index 7ae22b61b7f..f405349b16a 100644 --- a/megamek/src/megamek/server/GameManager.java +++ b/megamek/src/megamek/server/GameManager.java @@ -1130,7 +1130,7 @@ public void decrementASEWTurns() { * Called at the beginning of certain phases to make every player not ready. */ private void resetPlayersDone() { - if (getGame().getPhase().isReport()) { + if ((getGame().getPhase().isReport()) && (!getGame().getPhase().isVictory())) { return; } @@ -1833,6 +1833,7 @@ public boolean accept(Entity entity) { case END_REPORT: resetActivePlayersDone(); sendReport(); + entityAllUpdate(); if (game.getOptions().booleanOption(OptionsConstants.BASE_PARANOID_AUTOSAVE)) { autoSave(); }