From 2fd0a028a93f34a6000c14ec62eb9eafdd7710c7 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 9 Dec 2022 18:33:28 -0500 Subject: [PATCH 01/47] show game board in all the game phases --- .../i18n/megamek/client/messages.properties | 9 +- megamek/src/megamek/client/bot/BotClient.java | 2 +- .../client/ui/swing/AbstractPhaseDisplay.java | 5 +- .../megamek/client/ui/swing/ClientGUI.java | 95 ++-- .../client/ui/swing/MechViewPanel.java | 3 +- .../client/ui/swing/MiniReportDisplay.java | 6 +- .../client/ui/swing/ReportDisplay.java | 408 ++++++------------ .../swing/skinEditor/SkinEditorMainGUI.java | 17 +- megamek/src/megamek/common/Report.java | 7 + 9 files changed, 186 insertions(+), 366 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 272747b8bbc..fc43de55294 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -3002,11 +3002,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: diff --git a/megamek/src/megamek/client/bot/BotClient.java b/megamek/src/megamek/client/bot/BotClient.java index 1b93f4ccc3b..74060b1a337 100644 --- a/megamek/src/megamek/client/bot/BotClient.java +++ b/megamek/src/megamek/client/bot/BotClient.java @@ -1135,7 +1135,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/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/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index e4a3832ef43..67d21b302f3 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -712,7 +712,7 @@ 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); } @@ -722,16 +722,23 @@ private void showPlayerList() { /** * Called when the user selects the "View->Round Report" menu item. */ - private void showRoundReport() { + public void showRoundReport() { ignoreHotKeys = true; if (miniReportDisplay == null) { miniReportDisplay = new MiniReportDisplay(frame, this); } - miniReportDisplay.setVisible(true); ignoreHotKeys = false; } + public void addReportPages() { + ignoreHotKeys = true; + if (miniReportDisplay != null) { + miniReportDisplay.addReportPages(); + } + ignoreHotKeys = false; + } + /** * Implement the ActionListener interface. */ @@ -1122,10 +1129,6 @@ 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()); @@ -1157,11 +1160,7 @@ 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); + showRoundReport(); break; default: break; @@ -1359,11 +1358,6 @@ private JComponent initializePanel(GamePhase phase) { 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: @@ -1371,13 +1365,27 @@ 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)); + component = null; + for (String s : phaseComponents.keySet()) { + JComponent comp = phaseComponents.get(s); + if (comp instanceof ReportDisplay) { + component = comp; + break; + } + } if (component == null) { - // no ReportDisplay to reuse - get a new one - component = initializePanel(GamePhase.INITIATIVE_REPORT); + component = new ReportDisplay(this); + } + main = CG_BOARDVIEW; + secondary = CG_REPORTDISPLAY; + component.setName(secondary); + if (!mainNames.containsValue(main)) { + panMain.add(bvc, main); + } + currPhaseDisplay = (StatusBarPhaseDisplay) component; + if (!secondaryNames.containsValue(secondary)) { + panSecondary.add(component, secondary); } - main = CG_REPORTDISPLAY; break; default: component = new JLabel(MSG_WAITINGONTHESERVER); @@ -1503,7 +1511,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); @@ -1865,10 +1873,6 @@ public void gamePlayerChange(GamePlayerChangeEvent evt) { if (playerListDialog != null) { playerListDialog.refreshPlayerList(); } - - if ((curPanel instanceof ReportDisplay) && !client.getLocalPlayer().isDone()) { - ((ReportDisplay) curPanel).resetReadyButton(); - } } @Override @@ -1907,39 +1911,18 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { @Override public void gamePlayerConnected(GamePlayerConnectedEvent e) { - if (curPanel instanceof ReportDisplay) { - ((ReportDisplay) curPanel).resetReadyButton(); - } + } @Override public void gameReport(GameReportEvent e) { - // Normally the Report Display is updated when the panel is - // switched during a phase change. - // 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(); - // 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! - if (!(getClient() instanceof TestBot)) { - doAlertDialog(MSG_DIALOGTACTICALGENIUSREPORT, e.getReport()); - } - } else { - // Continued movement after getting up - if (!(getClient() instanceof TestBot)) { - doAlertDialog(MSG_DIALOGDIALOGMOVEMENTREPORT, e.getReport()); - } + if ((getClient().getGame().getPhase() == GamePhase.INITIATIVE_REPORT) && getClient().getGame().hasTacticalGenius(getClient().getLocalPlayer())) { + addReportPages(); + } + + // Continued movement after getting up + if (!(getClient() instanceof TestBot)) { + doAlertDialog(MSG_DIALOGDIALOGMOVEMENTREPORT, e.getReport()); } } 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 1128865274e..b6f42c8a970 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -326,7 +326,7 @@ 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); + Report.setupStylesheet(ta); ta.addHyperlinkListener(this); BASE64ToolKit toolKit = new BASE64ToolKit(); ta.setEditorKit(toolKit); @@ -340,7 +340,7 @@ public void addReportPages() { // add the new current phase tab JTextPane ta = new JTextPane(); - ReportDisplay.setupStylesheet(ta); + Report.setupStylesheet(ta); ta.addHyperlinkListener(this); BASE64ToolKit toolKit = new BASE64ToolKit(); @@ -419,7 +419,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/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index 0f9e233c9f4..325eefb1fe1 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -13,51 +13,60 @@ */ 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; + + /** + * Priority that determines this buttons order + */ + public int priority; - private static final String RD_ACTIONCOMMAND_DONEBUTTON = "doneButton"; - private static final String RD_ACTIONCOMMAND_REROLLINITIATIVE = "reroll_initiative"; + private ReportCommand(String c) { + cmd = c; + } + + @Override + public String getCmd() { + return cmd; + } - 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"); + @Override + public int getPriority() { + return priority; + } + + @Override + public void setPriority(int p) { + priority = p; + } + + @Override + public String toString() { + return Messages.getString("ReportDisplay." + getCmd()); + } + } - private boolean rerolled; // have we rerolled an init? + // buttons + private Map buttons; /** * Creates and lays out a new movement phase display for the specified @@ -65,67 +74,53 @@ public class ReportDisplay extends AbstractPhaseDisplay implements */ 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(); - - resetTabs(); - butDone.setText(MSG_DONE); + setupStatusBar(Messages.getString("ReportDisplay.waitingForReportPhase")); - rerollInitiativeB = new JButton(MSG_REROLL); - rerollInitiativeB.setActionCommand(RD_ACTIONCOMMAND_REROLLINITIATIVE); - rerollInitiativeB.addActionListener(this); + buttons = new HashMap<>((int) (ReportCommand.values().length * 1.25 + 0.5)); + for (ReportCommand cmd : ReportCommand.values()) { + String title = Messages.getString("ReportDisplay." + cmd.getCmd()); + MegamekButton newButton = new MegamekButton(title, + SkinSpecification.UIComponents.PhaseDisplayButton.getComp()); + String ttKey = "ReportDisplay." + cmd.getCmd() + ".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); - // 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)); + butDone.setText("" + Messages.getString("ReportDisplay.Done") + ""); + butDone.setEnabled(false); - 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)); - 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,135 +128,31 @@ public void showRerollButton(boolean show) { */ @Override public void ready() { - rerollInitiativeB.setEnabled(false); 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(); - } - - /** - * have we rerolled init this round? - */ - public boolean hasRerolled() { - return rerolled; - } - - public void resetButtons() { - resetReadyButton(); - if ((clientgui.getClient().getGame().getPhase() == GamePhase.INITIATIVE_REPORT) && clientgui.getClient().getGame().hasTacticalGenius(clientgui.getClient().getLocalPlayer())) { - showRerollButton(true); - } else { - showRerollButton(false); - } - rerollInitiativeB.setEnabled(true); - } - - public void resetReadyButton() { - butDone.setEnabled(true); - } - - public void resetRerollButton() { - rerollInitiativeB.setEnabled(true); + public void setReportEnabled(boolean enabled) { + buttons.get(ReportCommand.REPORT_REPORT).setEnabled(enabled); } - 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 setPlayerListEnabled(boolean enabled) { + buttons.get(ReportCommand.REPORT_PLAYERLIST).setEnabled(enabled); } - 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 setRerollInitiativeEnabled(boolean enabled) { + buttons.get(ReportCommand.REPORT_REROLLINITIATIVE).setEnabled(enabled); } - public void resetTabs() { - tabs.removeAll(); + /** + * Requests an initiative reroll and disables the ready button. + */ + public void rerollInitiative() { + setRerollInitiativeEnabled(false); + clientgui.getClient().sendRerollInitiativeRequest(); } // @@ -269,36 +160,49 @@ 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()))) { + clientgui.showRoundReport(); + } else if ((ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_PLAYERLIST.getCmd()))) { + clientgui.showPlayerList(); + } + } + + 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 + switch (clientgui.getClient().getGame().getPhase()) { + 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(clientgui.getClient().getGame().getPhase().toString()); + + break; + default: + setStatusBarText(clientgui.getClient().getGame().getPhase().toString()); + break; + }; } /** @@ -307,67 +211,7 @@ public void clear() { @Override public void removeAllListeners() { clientgui.getClient().getGame().removeGameListener(this); - GUIPreferences.getInstance().removePreferenceChangeListener(this); + clientgui.getBoardView().removeBoardViewListener(this); + clientgui.getBoardView().removeKeyListener(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); - } - } - 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/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/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); From 308b55af3773e6b3c38b02c749a3c5b4bad0aada Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 9 Dec 2022 19:00:03 -0500 Subject: [PATCH 02/47] show game board in all the game phases 2 --- megamek/src/megamek/client/ui/swing/ReportDisplay.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index 325eefb1fe1..d9cbbf3f140 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -75,6 +75,10 @@ public String toString() { public ReportDisplay(ClientGUI clientgui) { super(clientgui); + if (clientgui == null) { + return; + } + setupStatusBar(Messages.getString("ReportDisplay.waitingForReportPhase")); buttons = new HashMap<>((int) (ReportCommand.values().length * 1.25 + 0.5)); From d0165cc2a44264a00c589bdd394059f23f845d6f Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Dec 2022 09:11:40 -0500 Subject: [PATCH 03/47] show game board in all the game phases 3 --- megamek/src/megamek/client/ui/swing/ReportDisplay.java | 5 ++--- megamek/src/megamek/common/enums/GamePhase.java | 7 +++++++ megamek/src/megamek/server/GameManager.java | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index d9cbbf3f140..efc9e205231 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -79,7 +79,7 @@ public ReportDisplay(ClientGUI clientgui) { return; } - setupStatusBar(Messages.getString("ReportDisplay.waitingForReportPhase")); + setupStatusBar(""); buttons = new HashMap<>((int) (ReportCommand.values().length * 1.25 + 0.5)); for (ReportCommand cmd : ReportCommand.values()) { @@ -201,12 +201,11 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { case VICTORY: resetButtons(); setStatusBarText(clientgui.getClient().getGame().getPhase().toString()); - break; default: setStatusBarText(clientgui.getClient().getGame().getPhase().toString()); break; - }; + } } /** diff --git a/megamek/src/megamek/common/enums/GamePhase.java b/megamek/src/megamek/common/enums/GamePhase.java index c697be6142f..19ef405aebc 100644 --- a/megamek/src/megamek/common/enums/GamePhase.java +++ b/megamek/src/megamek/common/enums/GamePhase.java @@ -203,6 +203,13 @@ 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: return true; default: return false; diff --git a/megamek/src/megamek/server/GameManager.java b/megamek/src/megamek/server/GameManager.java index f29bb5c805d..1785c089d0d 100644 --- a/megamek/src/megamek/server/GameManager.java +++ b/megamek/src/megamek/server/GameManager.java @@ -1849,6 +1849,7 @@ public boolean accept(Entity entity) { case END_REPORT: resetActivePlayersDone(); sendReport(); + entityAllUpdate(); if (game.getOptions().booleanOption(OptionsConstants.BASE_PARANOID_AUTOSAVE)) { autoSave(); } From f41c9b0e77b14ca47051ceb82d72521cf4830a9e Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Dec 2022 11:55:38 -0500 Subject: [PATCH 04/47] show game board in all the game phases 4 --- .../megamek/client/ui/swing/ClientGUI.java | 38 +++++++++++++++---- .../client/ui/swing/ReportDisplay.java | 4 ++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 67d21b302f3..d893fdae51c 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -731,7 +731,7 @@ public void showRoundReport() { ignoreHotKeys = false; } - public void addReportPages() { + public void miniReportDisplayAddReportPages() { ignoreHotKeys = true; if (miniReportDisplay != null) { miniReportDisplay.addReportPages(); @@ -739,6 +739,18 @@ public void addReportPages() { ignoreHotKeys = false; } + public void reportDisplayResetDone() { + if (!getClient().getLocalPlayer().isDone()) { + for (String s : phaseComponents.keySet()) { + JComponent comp = phaseComponents.get(s); + if (comp instanceof ReportDisplay) { + ((ReportDisplay) comp).setDoneEnabled(true); + break; + } + } + } + } + /** * Implement the ActionListener interface. */ @@ -1916,13 +1928,23 @@ public void gamePlayerConnected(GamePlayerConnectedEvent e) { @Override public void gameReport(GameReportEvent e) { - if ((getClient().getGame().getPhase() == GamePhase.INITIATIVE_REPORT) && getClient().getGame().hasTacticalGenius(getClient().getLocalPlayer())) { - addReportPages(); - } - - // Continued movement after getting up - if (!(getClient() instanceof TestBot)) { - doAlertDialog(MSG_DIALOGDIALOGMOVEMENTREPORT, e.getReport()); + // Normally the Report Display is updated when the panel is + // switched during a phase change. + // 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 (getClient().getGame().getPhase() == GamePhase.INITIATIVE_REPORT) { + miniReportDisplayAddReportPages(); + reportDisplayResetDone(); + + if (!(getClient() instanceof TestBot)) { + doAlertDialog(MSG_DIALOGTACTICALGENIUSREPORT, e.getReport()); + } + } else { + // Continued movement after getting up + if (!(getClient() instanceof TestBot)) { + doAlertDialog(MSG_DIALOGDIALOGMOVEMENTREPORT, e.getReport()); + } } } diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index efc9e205231..7e7f72eae62 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -151,6 +151,10 @@ public void setRerollInitiativeEnabled(boolean enabled) { buttons.get(ReportCommand.REPORT_REROLLINITIATIVE).setEnabled(enabled); } + public void setDoneEnabled(boolean enabled) { + butDone.setEnabled(enabled); + } + /** * Requests an initiative reroll and disables the ready button. */ From 3cb284b0a9fc478c5a9f8ee78f3a1594555a0a3d Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Dec 2022 12:19:30 -0500 Subject: [PATCH 05/47] show game board in all the game phases 5 --- .../src/megamek/client/ui/swing/ClientGUI.java | 17 +++++++++++++++++ .../megamek/client/ui/swing/ReportDisplay.java | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index d893fdae51c..23da14e3447 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -751,6 +751,19 @@ public void reportDisplayResetDone() { } } + public void reportDisplayResetRerollInitiative() { + if ((!getClient().getLocalPlayer().isDone()) && (getClient().getGame().hasTacticalGenius(getClient().getLocalPlayer()))) { + for (String s : phaseComponents.keySet()) { + JComponent comp = phaseComponents.get(s); + if (comp instanceof ReportDisplay) { + ((ReportDisplay) comp).resetRerollInitiativeEnabled(); + break; + } + } + } + } + + /** * Implement the ActionListener interface. */ @@ -1936,6 +1949,10 @@ public void gameReport(GameReportEvent e) { if (getClient().getGame().getPhase() == GamePhase.INITIATIVE_REPORT) { 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. + reportDisplayResetRerollInitiative(); if (!(getClient() instanceof TestBot)) { doAlertDialog(MSG_DIALOGTACTICALGENIUSREPORT, e.getReport()); diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index 7e7f72eae62..e1468076be0 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -67,6 +67,7 @@ public String toString() { // buttons private Map buttons; + private boolean rerolled; // have we rerolled an init? /** * Creates and lays out a new movement phase display for the specified @@ -151,6 +152,12 @@ public void setRerollInitiativeEnabled(boolean enabled) { buttons.get(ReportCommand.REPORT_REROLLINITIATIVE).setEnabled(enabled); } + public void resetRerollInitiativeEnabled() { + if (!rerolled) { + setRerollInitiativeEnabled(true); + } + } + public void setDoneEnabled(boolean enabled) { butDone.setEnabled(enabled); } @@ -159,6 +166,7 @@ public void setDoneEnabled(boolean enabled) { * Requests an initiative reroll and disables the ready button. */ public void rerollInitiative() { + rerolled = true; setRerollInitiativeEnabled(false); clientgui.getClient().sendRerollInitiativeRequest(); } @@ -194,6 +202,8 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { return; } + rerolled = false; + switch (clientgui.getClient().getGame().getPhase()) { case INITIATIVE_REPORT: case TARGETING_REPORT: From 5dbc13b1e6cf49c1177156dec4fe846e379ae10b Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Dec 2022 16:05:10 -0500 Subject: [PATCH 06/47] show game board in all the game phases 6 --- .../megamek/client/ui/swing/ClientGUI.java | 29 ++++++++++++++++++- .../client/ui/swing/CommonMenuBar.java | 14 +++++++-- .../client/ui/swing/GUIPreferences.java | 21 ++++++++++++++ 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 23da14e3447..ca817d3492d 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -1185,7 +1185,10 @@ void switchPanel(GamePhase phase) { case PHYSICAL_REPORT: case END_REPORT: case VICTORY: - showRoundReport(); + if (frame.isShowing()) { + maybeShowMiniReport(); + maybeShowPlayerList(); + } break; default: break; @@ -1465,6 +1468,14 @@ private void maybeShowMinimap() { setMapVisible(GUIP.getMinimapEnabled()); } + private void maybeShowMiniReport() { + setMiniReportVisible(GUIP.getMiniReportEnabled()); + } + + private void maybeShowPlayerList() { + setPlayerListVisible(GUIP.getPlayerListEnabled()); + } + /** * Shows or hides the Minimap based on the given visible. This works independently * of the current menu setting, so it should be used only when the Minimap is to @@ -1475,6 +1486,22 @@ private void maybeShowMinimap() { void setMapVisible(boolean visible) { minimapW.setVisible(visible); } + + void setMiniReportVisible(boolean visible) { + if (visible) { + showRoundReport(); + } else { + miniReportDisplay.setVisible(visible); + } + } + + void setPlayerListVisible(boolean visible) { + if (visible) { + showPlayerList(); + } else { + playerListDialog.setVisible(visible); + } + } /** Shows or hides the Unit Display based on the current menu setting. */ public void maybeShowUnitDisplay() { diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index a9d7deddf9a..0d401c02ed7 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -60,9 +60,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")); @@ -174,10 +174,12 @@ public CommonMenuBar() { menu.setMnemonic(VK_G); initMenuItem(gameRoundReport, menu, VIEW_ROUND_REPORT); + gameRoundReport.setSelected(GUIP.getMiniReportEnabled()); menu.addSeparator(); initMenuItem(gameReplacePlayer, menu, FILE_GAME_REPLACE_PLAYER, VK_R); initMenuItem(gamePlayerList, menu, VIEW_PLAYER_LIST); + gamePlayerList.setSelected(GUIP.getPlayerListEnabled()); menu.addSeparator(); initMenuItem(gameGameOptions, menu, VIEW_GAME_OPTIONS, VK_O); @@ -358,6 +360,10 @@ public void actionPerformed(ActionEvent event) { } else if (event.getActionCommand().equals(ClientGUI.VIEW_LABELS)) { GUIP.setUnitLabelStyle(GUIP.getUnitLabelStyle().next()); + } else if (event.getActionCommand().equals(VIEW_ROUND_REPORT)) { + GUIP.setMiniReportEnabled(!GUIP.getMiniReportEnabled()); + } else if (event.getActionCommand().equals(VIEW_PLAYER_LIST)) { + GUIP.setPlayerListEnabled(!GUIP.getPlayerListEnabled()); } // Pass the action on to each of our listeners. @@ -499,6 +505,10 @@ public void preferenceChange(PreferenceChangeEvent e) { setKeyBinds(); } else if (e.getName().equals(GUIPreferences.SHOW_UNIT_DISPLAY)) { viewMekDisplay.setSelected(GUIP.getBoolean(GUIPreferences.SHOW_UNIT_DISPLAY)); + } 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()); } } diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index c70fbfe0dd5..ac2db2b9be4 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -178,6 +178,8 @@ 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 MINI_REPORT_ENABLED = "MiniReportEnabled"; + public static final String PLAYER_lIST_ENABLED = "PlayerListEnabled"; public static final String MINIMAP_COLOURS = "MinimapColours"; public static final String MINIMAP_ENABLED = "MinimapEnabled"; public static final String MINIMAP_POS_X = "MinimapPosX"; @@ -457,6 +459,9 @@ 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(PLAYER_lIST_ENABLED, true); store.setDefault(MOUSE_WHEEL_ZOOM, true); store.setDefault(MOUSE_WHEEL_ZOOM_FLIP, true); @@ -832,6 +837,14 @@ public boolean getMinimapEnabled() { return store.getBoolean(MINIMAP_ENABLED); } + public boolean getMiniReportEnabled() { + return store.getBoolean(MINI_REPORT_ENABLED); + } + + public boolean getPlayerListEnabled() { + return store.getBoolean(PLAYER_lIST_ENABLED); + } + public boolean getIsometricEnabled() { return store.getBoolean(USE_ISOMETRIC); } @@ -1348,6 +1361,10 @@ public void setMinimapEnabled(boolean b) { store.setValue(MINIMAP_ENABLED, b); } + public void setMiniReportEnabled(boolean b) { + store.setValue(MINI_REPORT_ENABLED, b); + } + public void setMinimapPosX(int i) { store.setValue(MINIMAP_POS_X, i); } @@ -1368,6 +1385,10 @@ public void setMiniReportPosY(int i) { store.setValue(MINI_REPORT_POS_Y, i); } + public void setPlayerListEnabled(boolean b) { + store.setValue(PLAYER_lIST_ENABLED, b); + } + public void setBoardEditLoadHeight(int i) { store.setValue(BOARDEDIT_LOAD_SIZE_HEIGHT, i); } From 35b95b84806a39ca7010520d8bb72ce80e064559 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Dec 2022 17:19:41 -0500 Subject: [PATCH 07/47] show game board in all the game phases 7 --- .../megamek/client/ui/swing/ClientGUI.java | 2 + .../client/ui/swing/GUIPreferences.java | 20 ++++++ .../client/ui/swing/PlayerListDialog.java | 69 +++++++++++++++++-- 3 files changed, 84 insertions(+), 7 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index ca817d3492d..a722676295a 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -773,6 +773,8 @@ public void actionPerformed(ActionEvent event) { case VIEW_RESET_WINDOW_POSITIONS: minimapW.setBounds(0, 0, minimapW.getWidth(), minimapW.getHeight()); getUnitDisplayDialog().setBounds(0, 0, getUnitDisplay().getWidth(), getUnitDisplay().getHeight()); + miniReportDisplay.setBounds(0, 0, miniReportDisplay.getWidth(), miniReportDisplay.getHeight()); + playerListDialog.setBounds(0, 0, playerListDialog.getWidth(), playerListDialog.getHeight()); break; case FILE_GAME_SAVE: saveGame(); diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index ac2db2b9be4..b8c2c76afc2 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -179,6 +179,8 @@ public class GUIPreferences extends PreferenceStoreProxy { public static final String MINI_REPORT_SIZE_HEIGHT = "MiniReportSizeHeight"; public static final String MINI_REPORT_SIZE_WIDTH = "MiniReportSizeWidth"; public static final String MINI_REPORT_ENABLED = "MiniReportEnabled"; + 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 MINIMAP_COLOURS = "MinimapColours"; public static final String MINIMAP_ENABLED = "MinimapEnabled"; @@ -462,6 +464,8 @@ protected GUIPreferences() { store.setDefault(MINI_REPORT_ENABLED, true); store.setDefault(PLAYER_lIST_ENABLED, true); + store.setDefault(PLAYER_lIST_POS_X, 200); + store.setDefault(PLAYER_lIST_POS_Y, 150); store.setDefault(MOUSE_WHEEL_ZOOM, true); store.setDefault(MOUSE_WHEEL_ZOOM_FLIP, true); @@ -845,6 +849,14 @@ 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 boolean getIsometricEnabled() { return store.getBoolean(USE_ISOMETRIC); } @@ -1389,6 +1401,14 @@ public void setPlayerListEnabled(boolean b) { store.setValue(PLAYER_lIST_ENABLED, b); } + 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 setBoardEditLoadHeight(int i) { store.setValue(BOARDEDIT_LOAD_SIZE_HEIGHT, i); } diff --git a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java index 61e04334116..2373cbf1272 100644 --- a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java +++ b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java @@ -19,28 +19,52 @@ 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; -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; + private JButton butOkay; + + private static final String MSG_OKAY= Messages.getString("Okay"); public PlayerListDialog(JFrame parent, Client client) { super(parent, Messages.getString("PlayerListDialog.title"), false); this.client = client; + 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)); @@ -50,11 +74,8 @@ public PlayerListDialog(JFrame parent, Client client) { pack(); setResizable(false); - setLocation(parent.getLocation().x + (parent.getSize().width / 2) - - (getSize().width / 2), - parent.getLocation().y + (parent.getSize().height / 2) - - (getSize().height / 2)); - + setLocation(GUIPreferences.getInstance().getPlayerListPosX(), + GUIPreferences.getInstance().getPlayerListPosY()); } public static void refreshPlayerList(JList playerList, @@ -137,6 +158,40 @@ public Player getSelected() { return null; } + @Override + public void actionPerformed(ActionEvent ae) { + if (ae.getSource().equals(butOkay)) { + savePref(); + setVisible(false); + } + } + + private GameListener gameListener = new GameListenerAdapter() { + @Override + public void gamePhaseChange(GamePhaseChangeEvent e) { + switch (e.getOldPhase()) { + case VICTORY: + savePref(); + setVisible(false); + break; + default: + break; + } + } + }; + + @Override + protected void processWindowEvent(WindowEvent e) { + super.processWindowEvent(e); + if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { + savePref(); + } + } + private void savePref() { + GUIPreferences.getInstance().setPlayerListPosX(getLocation().x); + GUIPreferences.getInstance().setPlayerListPosY(getLocation().y); + } + private void adaptToGUIScale() { UIUtil.adjustDialog(this, UIUtil.FONT_SCALE1); setMinimumSize(new Dimension(UIUtil.scaleForGUI(300), UIUtil.scaleForGUI(260))); From 1590d6a87e4806d82fd226a4065b092a08c7c26a Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Dec 2022 18:21:48 -0500 Subject: [PATCH 08/47] show game board in all the game phases 8 --- .../megamek/client/ui/swing/ClientGUI.java | 22 ++++++++++--------- .../client/ui/swing/minimap/Minimap.java | 8 +------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index a722676295a..1e14f1812fb 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -589,12 +589,6 @@ public void windowClosing(WindowEvent e) { getUnitDisplayDialog().setFocusable(false); getUnitDisplayDialog().setFocusableWindowState(false); getUnitDisplayDialog().add(getUnitDisplay()); - getUnitDisplayDialog().addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent evt) { - GUIPreferences.getInstance().hideUnitDisplay(); - } - }); Ruler.color1 = GUIPreferences.getInstance().getRulerColor1(); Ruler.color2 = GUIPreferences.getInstance().getRulerColor2(); @@ -1486,14 +1480,18 @@ private void maybeShowPlayerList() { * Does not change the menu setting. */ void setMapVisible(boolean visible) { - minimapW.setVisible(visible); + if (minimapW != null) { + minimapW.setVisible(visible); + } } void setMiniReportVisible(boolean visible) { if (visible) { showRoundReport(); } else { - miniReportDisplay.setVisible(visible); + if (miniReportDisplay != null) { + miniReportDisplay.setVisible(visible); + } } } @@ -1501,7 +1499,9 @@ void setPlayerListVisible(boolean visible) { if (visible) { showPlayerList(); } else { - playerListDialog.setVisible(visible); + if (miniReportDisplay != null) { + playerListDialog.setVisible(visible); + } } } @@ -1528,7 +1528,9 @@ public void setUnitDisplayVisible(boolean visible) { } } - getUnitDisplayDialog().setVisible(visible); + if (getUnitDisplayDialog() != null) { + getUnitDisplayDialog().setVisible(visible); + } } private boolean fillPopup(Coords coords) { diff --git a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java index 5f1abcea3f6..620cb09e2cb 100644 --- a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java +++ b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java @@ -157,13 +157,7 @@ public static JDialog createMinimap(JFrame parent, @Nullable BoardView bv, Game result.setFocusableWindowState(false); result.setLocation(GUIP.getMinimapPosX(), GUIP.getMinimapPosY()); result.setResizable(false); - result.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - GUIP.setMinimapEnabled(false); - } - }); - + result.add(new Minimap(result, game, bv, cg)); result.pack(); return result; From 951ca7bce2ec4e4fbd253a6456a95240e1c2a249 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Dec 2022 17:03:56 -0500 Subject: [PATCH 09/47] show game board in all the game phases 9 --- .../i18n/megamek/client/messages.properties | 13 +- .../megamek/client/ui/swing/ClientGUI.java | 99 +++++++-- .../client/ui/swing/CommonMenuBar.java | 24 +-- .../client/ui/swing/CommonSettingsDialog.java | 193 +++++++++++++++++- .../client/ui/swing/GUIPreferences.java | 90 +++++++- 5 files changed, 370 insertions(+), 49 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index fc43de55294..f82e50acd4b 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -784,6 +784,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 @@ -800,6 +802,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... @@ -1081,7 +1084,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 diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 1e14f1812fb..40784b86c56 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -249,6 +249,9 @@ public class ClientGUI extends JPanel implements BoardViewListener, private static final String MSG_DISTANCE = Messages.getString("ClientGUI.distance"); private static final String MSG_NOGHOSTPLAYERSTOREPLACE = Messages.getString("ClientGUI.noGhostPlayersToReplace"); private static final String MSG_NOGHOSTS = Messages.getString("ClientGUI.noGhosts"); + 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_BOARDEDITORWAITDIALOGTITLE = Messages.getString("BoardEditor.waitDialog.title"); private static final String MSG_BOARDEDITORWAITDIALOGMSG = Messages.getString("BoardEditor.waitDialog.message"); private static final String MSG_BOARDEDITORSAVEBOARDAS = Messages.getString("BoardEditor.saveBoardAs"); @@ -271,6 +274,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; @@ -1168,11 +1172,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: @@ -1181,11 +1180,6 @@ void switchPanel(GamePhase phase) { case PHYSICAL_REPORT: case END_REPORT: case VICTORY: - if (frame.isShowing()) { - maybeShowMiniReport(); - maybeShowPlayerList(); - } - break; default: break; } @@ -1196,6 +1190,11 @@ void switchPanel(GamePhase phase) { if (secondaryToShow != null) { panSecondary.setVisible(true); cardsSecondary.show(panSecondary, secondaryNames.get(name)); + + maybeShowMinimap(); + maybeShowUnitDisplay(); + maybeShowMiniReport(); + maybeShowPlayerList(); } else { // otherwise, hide the panel panSecondary.setVisible(false); @@ -1434,7 +1433,7 @@ protected void showBoardPopup(Coords c) { } } - /** + /** * Switches the Minimap and the UnitDisplay an and off together. * If the UnitDisplay is active, both will be hidden, else both will be shown. */ @@ -1461,15 +1460,63 @@ private void toggleUnitOverview() { /** 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()) { + String action = GUIP.getMinimapAutoDisplayReportPhase(); + if (action.equals(MSG_SHOW)) { + setMapVisible(true); + } else if (action.equals(MSG_HIDE)) { + setMapVisible(false); + } + } else if (phase.isOnMap()) { + String action = GUIP.getMinimapAutoDisplayNonReportPhase(); + if (action.equals(MSG_SHOW)) { + setMapVisible(true); + } else if (action.equals(MSG_HIDE)) { + setMapVisible(false); + } + } } private void maybeShowMiniReport() { - setMiniReportVisible(GUIP.getMiniReportEnabled()); + GamePhase phase = getClient().getGame().getPhase(); + + if (phase.isReport()) { + String action = GUIP.getMiniReportAutoDisplayReportPhase(); + if (action.equals(MSG_SHOW)) { + setMiniReportVisible(true); + } else if (action.equals(MSG_HIDE)) { + setMiniReportVisible(false); + } + } else if (phase.isOnMap()) { + String action = GUIP.getMiniReportAutoDisplayNonReportPhase(); + if (action.equals(MSG_SHOW)) { + setMiniReportVisible(true); + } else if (action.equals(MSG_HIDE)) { + setMiniReportVisible(false); + } + } } private void maybeShowPlayerList() { - setPlayerListVisible(GUIP.getPlayerListEnabled()); + GamePhase phase = getClient().getGame().getPhase(); + + if (phase.isReport()) { + String action = GUIP.getPlayerListAutoDisplayReportPhase(); + if (action.equals(MSG_SHOW)) { + setPlayerListVisible(true); + } else if (action.equals(MSG_HIDE)) { + setPlayerListVisible(false); + } + } else if (phase.isOnMap()) { + String action = GUIP.getPlayerListAutoDisplayNonReportPhase(); + if (action.equals(MSG_SHOW)) { + setPlayerListVisible(true); + } else if (action.equals(MSG_HIDE)) { + setPlayerListVisible(false); + } + } } /** @@ -1507,7 +1554,23 @@ void setPlayerListVisible(boolean 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()) { + String action = GUIP.getDisplayAutoDisplayReportPhase(); + if (action.equals(MSG_SHOW)) { + setUnitDisplayVisible(true); + } else if (action.equals(MSG_HIDE)) { + setUnitDisplayVisible(false); + } + } else if (phase.isOnMap()) { + String action = GUIP.getDisplayAutoDisplayNonReportPhase(); + if (action.equals(MSG_SHOW)) { + setUnitDisplayVisible(true); + } else if (action.equals(MSG_HIDE)) { + setUnitDisplayVisible(false); + } + } } /** @@ -2590,13 +2653,11 @@ private void adaptToGUIScale() { @Override public void preferenceChange(PreferenceChangeEvent e) { if (e.getName().equals(GUIPreferences.MINIMAP_ENABLED)) { - maybeShowMinimap(); + setMapVisible(GUIP.getMinimapEnabled()); } else if (e.getName().equals(GUIPreferences.SHOW_UNIT_DISPLAY)) { - maybeShowUnitDisplay(); + setUnitDisplayVisible(GUIP.getBoolean(GUIPreferences.SHOW_UNIT_DISPLAY)); } else if (e.getName().equals(GUIPreferences.GUI_SCALE)) { adaptToGUIScale(); } - } - } diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 0d401c02ed7..668b2a5360a 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -60,9 +60,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 JCheckBoxMenuItem gameRoundReport = new JCheckBoxMenuItem(getString("CommonMenuBar.viewRoundReport")); + private JMenuItem gameRoundReport = new JMenuItem(getString("CommonMenuBar.viewRoundReport")); private JMenuItem gameReplacePlayer = new JMenuItem(getString("CommonMenuBar.replacePlayer")); - private JCheckBoxMenuItem gamePlayerList = new JCheckBoxMenuItem(getString("CommonMenuBar.viewPlayerList")); + private JMenuItem gamePlayerList = new JMenuItem(getString("CommonMenuBar.viewPlayerList")); private JMenuItem gameGameOptions = new JMenuItem(getString("CommonMenuBar.viewGameOptions")); private JMenuItem gamePlayerSettings = new JMenuItem(getString("CommonMenuBar.viewPlayerSettings")); @@ -99,8 +99,8 @@ public class CommonMenuBar extends JMenuBar implements ActionListener, IPreferen private JMenuItem boardRemoveBuildings = new JMenuItem(getString("CommonMenuBar.boardRemoveBuildings")); // The View menu - private JCheckBoxMenuItem viewMinimap = new JCheckBoxMenuItem(getString("CommonMenuBar.viewMinimap")); - private JCheckBoxMenuItem viewMekDisplay = new JCheckBoxMenuItem(getString("CommonMenuBar.viewMekDisplay")); + private JMenuItem viewMinimap = new JMenuItem(getString("CommonMenuBar.viewMinimap")); + private JMenuItem viewMekDisplay = new JMenuItem(getString("CommonMenuBar.viewMekDisplay")); private JMenuItem viewAccessibilityWindow = new JMenuItem(getString("CommonMenuBar.viewAccessibilityWindow")); private JCheckBoxMenuItem viewKeybindsOverlay = new JCheckBoxMenuItem(getString("CommonMenuBar.viewKeyboardShortcuts")); private JMenuItem viewZoomIn = new JMenuItem(getString("CommonMenuBar.viewZoomIn")); @@ -174,12 +174,10 @@ public CommonMenuBar() { menu.setMnemonic(VK_G); initMenuItem(gameRoundReport, menu, VIEW_ROUND_REPORT); - gameRoundReport.setSelected(GUIP.getMiniReportEnabled()); menu.addSeparator(); initMenuItem(gameReplacePlayer, menu, FILE_GAME_REPLACE_PLAYER, VK_R); initMenuItem(gamePlayerList, menu, VIEW_PLAYER_LIST); - gamePlayerList.setSelected(GUIP.getPlayerListEnabled()); menu.addSeparator(); initMenuItem(gameGameOptions, menu, VIEW_GAME_OPTIONS, VK_O); @@ -262,9 +260,7 @@ public CommonMenuBar() { 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); @@ -347,17 +343,13 @@ public void actionPerformed(ActionEvent event) { } } 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_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()); } else if (event.getActionCommand().equals(VIEW_ROUND_REPORT)) { @@ -497,18 +489,10 @@ 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)) { - 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.MINI_REPORT_ENABLED)) { - gameRoundReport.setSelected(GUIP.getMiniReportEnabled()); - } else if (e.getName().equals(GUIPreferences.PLAYER_lIST_ENABLED)) { - gamePlayerList.setSelected(GUIP.getPlayerListEnabled()); } } diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index b799d84ba8a..1b7b7d2205d 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -221,9 +221,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; @@ -262,6 +270,23 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg private int savedNumStripesSlider; HashMap savedAdvancedOpt = new HashMap<>(); + 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) { this(owner); @@ -294,14 +319,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(); @@ -497,6 +524,7 @@ private JPanel getSettingsPanel() { comps.add(row); addLineSpacer(comps); + comps.add(checkboxEntry(showIPAddressesInChat, Messages.getString("CommonSettingsDialog.showIPAddressesInChat.tooltip"))); return createSettingsPanel(comps); } @@ -745,6 +773,15 @@ protected void cancelAction() { unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B2)); unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C2)); + unitDisplayAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getDisplayAutoDisplayReportPhase()); + unitDisplayAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getDisplayAutoDisplayNonReportPhase()); + miniMapAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getMinimapAutoDisplayReportPhase()); + miniMapAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getMinimapAutoDisplayNonReportPhase()); + miniReportAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getMiniReportAutoDisplayReportPhase()); + miniReportAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getMiniReportAutoDisplayNonReportPhase()); + playerListAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getPlayerListAutoDisplayReportPhase()); + playerListAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getPlayerListAutoDisplayNonReportPhase()); + setVisible(false); } @@ -977,6 +1014,15 @@ protected void okAction() { } } + GUIPreferences.getInstance().setDisplayAutoDisplayReportPhase((String) unitDisplayAutoDisplayReportCombo.getSelectedItem()); + GUIPreferences.getInstance().setDisplayAutoDisplayNonReportPhase((String) unitDisplayAutoDisplayNonReportCombo.getSelectedItem()); + GUIPreferences.getInstance().setMinimapAutoDisplayReportPhase((String) miniMapAutoDisplayReportCombo.getSelectedItem()); + GUIPreferences.getInstance().setMinimapAutoDisplayNonReportPhase((String) miniMapAutoDisplayNonReportCombo.getSelectedItem()); + GUIPreferences.getInstance().setMiniReportAutoDisplayReportPhase((String) miniReportAutoDisplayReportCombo.getSelectedItem()); + GUIPreferences.getInstance().setMiniReportAutoDisplayNonReportPhase((String) miniReportAutoDisplayNonReportCombo.getSelectedItem()); + GUIPreferences.getInstance().setPlayerListAutoDisplayReportPhase((String) playerListAutoDisplayReportCombo.getSelectedItem()); + GUIPreferences.getInstance().setPlayerListAutoDisplayNonReportPhase((String) playerListAutoDisplayNonReportCombo.getSelectedItem()); + setVisible(false); } @@ -1399,6 +1445,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_SHOW); + unitDisplayAutoDisplayReportCombo.addItem(MSG_HIDE); + unitDisplayAutoDisplayReportCombo.addItem(MSG_MANUAL); + unitDisplayAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + unitDisplayAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getDisplayAutoDisplayReportPhase()); + row.add(phaseLabel); + row.add(unitDisplayAutoDisplayReportCombo); + comps.add(row); + + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + unitDisplayAutoDisplayNonReportCombo = new JComboBox<>(); + unitDisplayAutoDisplayNonReportCombo.addItem(MSG_SHOW); + unitDisplayAutoDisplayNonReportCombo.addItem(MSG_HIDE); + unitDisplayAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + unitDisplayAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + unitDisplayAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getDisplayAutoDisplayNonReportPhase()); + 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_SHOW); + miniMapAutoDisplayReportCombo.addItem(MSG_HIDE); + miniMapAutoDisplayReportCombo.addItem(MSG_MANUAL); + miniMapAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + miniMapAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getMinimapAutoDisplayReportPhase()); + row.add(phaseLabel); + row.add(miniMapAutoDisplayReportCombo); + comps.add(row); + + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + miniMapAutoDisplayNonReportCombo = new JComboBox<>(); + miniMapAutoDisplayNonReportCombo.addItem(MSG_SHOW); + miniMapAutoDisplayNonReportCombo.addItem(MSG_HIDE); + miniMapAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + miniMapAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + miniMapAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().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_SHOW); + miniReportAutoDisplayReportCombo.addItem(MSG_HIDE); + miniReportAutoDisplayReportCombo.addItem(MSG_MANUAL); + miniReportAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + miniReportAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getMiniReportAutoDisplayReportPhase()); + row.add(phaseLabel); + row.add(miniReportAutoDisplayReportCombo); + comps.add(row); + + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + miniReportAutoDisplayNonReportCombo = new JComboBox<>(); + miniReportAutoDisplayNonReportCombo.addItem(MSG_SHOW); + miniReportAutoDisplayNonReportCombo.addItem(MSG_HIDE); + miniReportAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + miniReportAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + miniReportAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().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_SHOW); + playerListAutoDisplayReportCombo.addItem(MSG_HIDE); + playerListAutoDisplayReportCombo.addItem(MSG_MANUAL); + playerListAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + playerListAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getPlayerListAutoDisplayReportPhase()); + row.add(phaseLabel); + row.add(playerListAutoDisplayReportCombo); + comps.add(row); + + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + playerListAutoDisplayNonReportCombo = new JComboBox<>(); + playerListAutoDisplayNonReportCombo.addItem(MSG_SHOW); + playerListAutoDisplayNonReportCombo.addItem(MSG_HIDE); + playerListAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + playerListAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); + row = new ArrayList<>(); + playerListAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getPlayerListAutoDisplayNonReportPhase()); + row.add(phaseLabel); + row.add(playerListAutoDisplayNonReportCombo); + comps.add(row); + + return createSettingsPanel(comps); + } private void updateKeybindsFocusTraversal() { for (KeyCommandBind kcb : KeyCommandBind.values()) { diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index b8c2c76afc2..6894d66189a 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; @@ -131,6 +132,9 @@ public class GUIPreferences extends PreferenceStoreProxy { 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 DISPLAY_AUTO_DISPLAY_REPORT_PHASE = "DisplayAutoDiplayReportPhase"; + public static final String DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE = "DisplayAutoDiplayNonReportPhase"; + public static final String SHOW_UNIT_DISPLAY = "ShowUnitDisplay"; 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"; @@ -179,17 +183,22 @@ public class GUIPreferences extends PreferenceStoreProxy { public static final String MINI_REPORT_SIZE_HEIGHT = "MiniReportSizeHeight"; public static final String MINI_REPORT_SIZE_WIDTH = "MiniReportSizeWidth"; 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 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 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 MINIMAP_AUTO_DISPLAY_REPORT_PHASE = "MinimapAutoDiplayReportPhase"; + public static final String MINIMAP_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"; @@ -272,6 +281,10 @@ public class GUIPreferences extends PreferenceStoreProxy { public static String RAT_PAD_BV = "RATPadBV"; public static String RAT_SELECTED_RAT = "RATSelectedRAT"; + 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"); + // common colors public static final Color DEFAULT_WHITE = Color.WHITE; public static final Color DEFAULT_BLACK = Color.BLACK; @@ -404,6 +417,7 @@ 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); @@ -414,6 +428,9 @@ protected GUIPreferences() { store.setDefault(DISPLAY_SPLIT_A1_LOC, 900); store.setDefault(DISPLAY_SPLIT_B1_LOC, 500); store.setDefault(DISPLAY_SPLIT_C1_LOC, 500); + store.setDefault(DISPLAY_AUTO_DISPLAY_REPORT_PHASE, MSG_HIDE); + store.setDefault(DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, MSG_SHOW); + store.setDefault(GAME_SUMMARY_BOARD_VIEW, false); store.setDefault(ENTITY_OWNER_LABEL_COLOR, true); store.setDefault(UNIT_LABEL_BORDER, true); @@ -453,6 +470,9 @@ protected GUIPreferences() { store.setDefault(MINIMAP_COLOURS, "defaultminimap.txt"); store.setDefault(MINIMAP_ENABLED, true); + store.setDefault(MINIMAP_AUTO_DISPLAY_REPORT_PHASE, MSG_HIDE); + store.setDefault(MINIMAP_AUTO_DISPLAY_NONREPORT_PHASE, MSG_SHOW); + store.setDefault(MMSYMBOL, true); store.setDefault(MINIMUM_SIZE_HEIGHT, 200); store.setDefault(MINIMUM_SIZE_WIDTH, 120); @@ -462,10 +482,14 @@ protected GUIPreferences() { 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, MSG_SHOW); + store.setDefault(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE, MSG_HIDE); 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, MSG_SHOW); + store.setDefault(PLAYER_lIST_AUTO_DISPLAY_NONREPORT_PHASE, MSG_HIDE); store.setDefault(MOUSE_WHEEL_ZOOM, true); store.setDefault(MOUSE_WHEEL_ZOOM_FLIP, true); @@ -665,6 +689,14 @@ public int getDisplayNonTabbedSizeWidth() { return store.getInt(DISPLAY_NONTABBED_SIZE_WIDTH); } + public String getDisplayAutoDisplayReportPhase() { + return store.getString(DISPLAY_AUTO_DISPLAY_REPORT_PHASE); + } + + public String getDisplayAutoDisplayNonReportPhase() { + return store.getString(DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE); + } + public boolean getGameSummaryBoardView() { return store.getBoolean(GAME_SUMMARY_BOARD_VIEW); } @@ -841,10 +873,26 @@ public boolean getMinimapEnabled() { return store.getBoolean(MINIMAP_ENABLED); } + public String getMinimapAutoDisplayReportPhase() { + return store.getString(MINIMAP_AUTO_DISPLAY_REPORT_PHASE); + } + + public String getMinimapAutoDisplayNonReportPhase() { + return store.getString(MINIMAP_AUTO_DISPLAY_NONREPORT_PHASE); + } + public boolean getMiniReportEnabled() { return store.getBoolean(MINI_REPORT_ENABLED); } + public String getMiniReportAutoDisplayReportPhase() { + return store.getString(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE); + } + + public String getMiniReportAutoDisplayNonReportPhase() { + return store.getString(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE); + } + public boolean getPlayerListEnabled() { return store.getBoolean(PLAYER_lIST_ENABLED); } @@ -857,6 +905,14 @@ public int getPlayerListPosY() { return store.getInt(PLAYER_lIST_POS_Y); } + public String getPlayerListAutoDisplayReportPhase() { + return store.getString(PLAYER_lIST_AUTO_DISPLAY_REPORT_PHASE); + } + + public String getPlayerListAutoDisplayNonReportPhase() { + return store.getString(PLAYER_lIST_AUTO_DISPLAY_NONREPORT_PHASE); + } + public boolean getIsometricEnabled() { return store.getBoolean(USE_ISOMETRIC); } @@ -1213,6 +1269,14 @@ public void setDisplayNonTabbedSizeWidth(int i) { store.setValue(DISPLAY_NONTABBED_SIZE_WIDTH, i); } + public void setDisplayAutoDisplayReportPhase(String s) { + store.setValue(DISPLAY_AUTO_DISPLAY_REPORT_PHASE, s); + } + + public void setDisplayAutoDisplayNonReportPhase(String s) { + store.setValue(DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, s); + } + public void setGameSummaryBoardView(boolean state) { store.setValue(GAME_SUMMARY_BOARD_VIEW, state); } @@ -1389,6 +1453,14 @@ public void setMinimapZoom(int zoom) { store.setValue(MINIMAP_ZOOM, zoom); } + public void setMinimapAutoDisplayReportPhase(String s) { + store.setValue(MINIMAP_AUTO_DISPLAY_REPORT_PHASE, s); + } + + public void setMinimapAutoDisplayNonReportPhase(String s) { + store.setValue(MINIMAP_AUTO_DISPLAY_REPORT_PHASE, s); + } + public void setMiniReportPosX(int i) { store.setValue(MINI_REPORT_POS_X, i); } @@ -1397,6 +1469,14 @@ public void setMiniReportPosY(int i) { store.setValue(MINI_REPORT_POS_Y, i); } + public void setMiniReportAutoDisplayReportPhase(String s) { + store.setValue(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE, s); + } + + public void setMiniReportAutoDisplayNonReportPhase(String s) { + store.setValue(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE, s); + } + public void setPlayerListEnabled(boolean b) { store.setValue(PLAYER_lIST_ENABLED, b); } @@ -1409,6 +1489,14 @@ public void setPlayerListPosY(int i) { store.setValue(PLAYER_lIST_POS_Y, i); } + public void setPlayerListAutoDisplayReportPhase(String s) { + store.setValue(PLAYER_lIST_AUTO_DISPLAY_REPORT_PHASE, s); + } + + public void setPlayerListAutoDisplayNonReportPhase(String s) { + store.setValue(PLAYER_lIST_AUTO_DISPLAY_NONREPORT_PHASE, s); + } + public void setBoardEditLoadHeight(int i) { store.setValue(BOARDEDIT_LOAD_SIZE_HEIGHT, i); } From 887067f55f418700f6eaac501c901a081fb76c78 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Dec 2022 17:37:40 -0500 Subject: [PATCH 10/47] show game board in all the game phases 10 --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 40784b86c56..ba5d083ebb3 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -1191,10 +1191,12 @@ void switchPanel(GamePhase phase) { panSecondary.setVisible(true); cardsSecondary.show(panSecondary, secondaryNames.get(name)); - maybeShowMinimap(); - maybeShowUnitDisplay(); - maybeShowMiniReport(); - maybeShowPlayerList(); + if (!getClient().getGame().getTurnVector().isEmpty()) { + maybeShowMinimap(); + maybeShowUnitDisplay(); + maybeShowMiniReport(); + maybeShowPlayerList(); + } } else { // otherwise, hide the panel panSecondary.setVisible(false); From 9d62d498d6f6349e2fdc0cb600b3f897a063ddeb Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Dec 2022 18:02:07 -0500 Subject: [PATCH 11/47] show game board in all the game phases 11 --- megamek/src/megamek/client/ui/swing/GUIPreferences.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 6894d66189a..4970851439f 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -1458,7 +1458,7 @@ public void setMinimapAutoDisplayReportPhase(String s) { } public void setMinimapAutoDisplayNonReportPhase(String s) { - store.setValue(MINIMAP_AUTO_DISPLAY_REPORT_PHASE, s); + store.setValue(MINIMAP_AUTO_DISPLAY_NONREPORT_PHASE, s); } public void setMiniReportPosX(int i) { From 93acf9cc386f31dcbbc4beba4c10c816b16ab632 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Dec 2022 18:29:35 -0500 Subject: [PATCH 12/47] show game board in all the game phases 12 --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 6 ++++++ .../src/megamek/client/ui/swing/CommonMenuBar.java | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index ba5d083ebb3..4f598f651b1 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -593,6 +593,12 @@ public void windowClosing(WindowEvent e) { getUnitDisplayDialog().setFocusable(false); getUnitDisplayDialog().setFocusableWindowState(false); getUnitDisplayDialog().add(getUnitDisplay()); + getUnitDisplayDialog().addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent evt) { + GUIPreferences.getInstance().hideUnitDisplay(); + } + }); Ruler.color1 = GUIPreferences.getInstance().getRulerColor1(); Ruler.color2 = GUIPreferences.getInstance().getRulerColor2(); diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 668b2a5360a..cb4e5bdfe00 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -99,8 +99,8 @@ public class CommonMenuBar extends JMenuBar implements ActionListener, IPreferen private JMenuItem boardRemoveBuildings = new JMenuItem(getString("CommonMenuBar.boardRemoveBuildings")); // The View menu - private JMenuItem viewMinimap = new JMenuItem(getString("CommonMenuBar.viewMinimap")); - private JMenuItem viewMekDisplay = new JMenuItem(getString("CommonMenuBar.viewMekDisplay")); + private JCheckBoxMenuItem viewMinimap = new JCheckBoxMenuItem (getString("CommonMenuBar.viewMinimap")); + private JCheckBoxMenuItem viewMekDisplay = new JCheckBoxMenuItem (getString("CommonMenuBar.viewMekDisplay")); private JMenuItem viewAccessibilityWindow = new JMenuItem(getString("CommonMenuBar.viewAccessibilityWindow")); private JCheckBoxMenuItem viewKeybindsOverlay = new JCheckBoxMenuItem(getString("CommonMenuBar.viewKeyboardShortcuts")); private JMenuItem viewZoomIn = new JMenuItem(getString("CommonMenuBar.viewZoomIn")); @@ -260,7 +260,9 @@ public CommonMenuBar() { 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); @@ -352,10 +354,6 @@ public void actionPerformed(ActionEvent event) { GUIP.setValue(GUIPreferences.SHOW_COORDS, !coordsShown); } else if (event.getActionCommand().equals(ClientGUI.VIEW_LABELS)) { GUIP.setUnitLabelStyle(GUIP.getUnitLabelStyle().next()); - } else if (event.getActionCommand().equals(VIEW_ROUND_REPORT)) { - GUIP.setMiniReportEnabled(!GUIP.getMiniReportEnabled()); - } else if (event.getActionCommand().equals(VIEW_PLAYER_LIST)) { - GUIP.setPlayerListEnabled(!GUIP.getPlayerListEnabled()); } // Pass the action on to each of our listeners. @@ -489,10 +487,14 @@ 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)) { + 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)); } } From c8de7483301cfdefe6fbbfdec5cff77d8cfeb15d Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Dec 2022 18:44:21 -0500 Subject: [PATCH 13/47] show game board in all the game phases 13 --- megamek/src/megamek/client/ui/swing/CommonMenuBar.java | 4 ++-- megamek/src/megamek/client/ui/swing/minimap/Minimap.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index cb4e5bdfe00..082aaaccaa1 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -99,8 +99,8 @@ public class CommonMenuBar extends JMenuBar implements ActionListener, IPreferen private JMenuItem boardRemoveBuildings = new JMenuItem(getString("CommonMenuBar.boardRemoveBuildings")); // The View menu - private JCheckBoxMenuItem viewMinimap = new JCheckBoxMenuItem (getString("CommonMenuBar.viewMinimap")); - private JCheckBoxMenuItem viewMekDisplay = new JCheckBoxMenuItem (getString("CommonMenuBar.viewMekDisplay")); + private JCheckBoxMenuItem viewMinimap = new JCheckBoxMenuItem(getString("CommonMenuBar.viewMinimap")); + private JCheckBoxMenuItem viewMekDisplay = new JCheckBoxMenuItem(getString("CommonMenuBar.viewMekDisplay")); private JMenuItem viewAccessibilityWindow = new JMenuItem(getString("CommonMenuBar.viewAccessibilityWindow")); private JCheckBoxMenuItem viewKeybindsOverlay = new JCheckBoxMenuItem(getString("CommonMenuBar.viewKeyboardShortcuts")); private JMenuItem viewZoomIn = new JMenuItem(getString("CommonMenuBar.viewZoomIn")); diff --git a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java index 620cb09e2cb..3eadb52a53a 100644 --- a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java +++ b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java @@ -157,6 +157,12 @@ public static JDialog createMinimap(JFrame parent, @Nullable BoardView bv, Game result.setFocusableWindowState(false); result.setLocation(GUIP.getMinimapPosX(), GUIP.getMinimapPosY()); result.setResizable(false); + result.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + GUIP.setMinimapEnabled(false); + } + }); result.add(new Minimap(result, game, bv, cg)); result.pack(); From f44a2418760925e4a69fba0c333b2feb4f38ebf5 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Dec 2022 19:14:28 -0500 Subject: [PATCH 14/47] show game board in all the game phases 14 --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 4f598f651b1..ffa4c12f6c3 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -1190,19 +1190,19 @@ void switchPanel(GamePhase phase) { break; } + if (frame.isShowing()) { + 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 if (secondaryToShow != null) { panSecondary.setVisible(true); cardsSecondary.show(panSecondary, secondaryNames.get(name)); - - if (!getClient().getGame().getTurnVector().isEmpty()) { - maybeShowMinimap(); - maybeShowUnitDisplay(); - maybeShowMiniReport(); - maybeShowPlayerList(); - } } else { // otherwise, hide the panel panSecondary.setVisible(false); From 213f97a33b1b58852b619e653b948b6ef20c3b18 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Dec 2022 19:34:55 -0500 Subject: [PATCH 15/47] show game board in all the game phases 15 --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 4 +++- megamek/src/megamek/client/ui/swing/CommonMenuBar.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index ffa4c12f6c3..dc35928f033 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -1190,7 +1190,9 @@ void switchPanel(GamePhase phase) { break; } - if (frame.isShowing()) { + if ((getClient().isMyTurn()) + || (getClient().getGame().getTurn() != null) + || (getClient().getGame().getPhase().isReport())) { maybeShowMinimap(); maybeShowUnitDisplay(); maybeShowMiniReport(); diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 082aaaccaa1..5110060f714 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -99,8 +99,8 @@ public class CommonMenuBar extends JMenuBar implements ActionListener, IPreferen private JMenuItem boardRemoveBuildings = new JMenuItem(getString("CommonMenuBar.boardRemoveBuildings")); // The View menu - private JCheckBoxMenuItem viewMinimap = new JCheckBoxMenuItem(getString("CommonMenuBar.viewMinimap")); - private JCheckBoxMenuItem viewMekDisplay = new JCheckBoxMenuItem(getString("CommonMenuBar.viewMekDisplay")); + private JCheckBoxMenuItem viewMinimap = new JCheckBoxMenuItem(getString("CommonMenuBar.viewMinimap")); + private JCheckBoxMenuItem viewMekDisplay = new JCheckBoxMenuItem(getString("CommonMenuBar.viewMekDisplay")); private JMenuItem viewAccessibilityWindow = new JMenuItem(getString("CommonMenuBar.viewAccessibilityWindow")); private JCheckBoxMenuItem viewKeybindsOverlay = new JCheckBoxMenuItem(getString("CommonMenuBar.viewKeyboardShortcuts")); private JMenuItem viewZoomIn = new JMenuItem(getString("CommonMenuBar.viewZoomIn")); From 5fc905672888e270dfc204f29fc5a040a2c80c29 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 13 Dec 2022 08:32:29 -0500 Subject: [PATCH 16/47] show game board in all the game phases 16 --- .../megamek/client/ui/swing/ClientGUI.java | 30 ++++++++----------- .../client/ui/swing/CommonMenuBar.java | 6 ++-- .../client/ui/swing/DeploymentDisplay.java | 2 +- .../client/ui/swing/FiringDisplay.java | 2 +- .../client/ui/swing/GUIPreferences.java | 4 +++ .../client/ui/swing/MiniReportDisplay.java | 2 +- .../client/ui/swing/MovementDisplay.java | 2 +- .../client/ui/swing/PhysicalDisplay.java | 2 +- .../ui/swing/PointblankShotDisplay.java | 2 +- .../client/ui/swing/PrephaseDisplay.java | 2 +- .../ui/swing/TargetingPhaseDisplay.java | 2 +- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index dc35928f033..ccfb5c3dbb7 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -1164,8 +1164,6 @@ void switchPanel(GamePhase phase) { 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: @@ -1190,14 +1188,10 @@ void switchPanel(GamePhase phase) { break; } - if ((getClient().isMyTurn()) - || (getClient().getGame().getTurn() != null) - || (getClient().getGame().getPhase().isReport())) { - maybeShowMinimap(); - maybeShowUnitDisplay(); - maybeShowMiniReport(); - maybeShowPlayerList(); - } + maybeShowMinimap(); + maybeShowUnitDisplay(); + maybeShowMiniReport(); + maybeShowPlayerList(); cardsMain.show(panMain, mainNames.get(name)); String secondaryToShow = secondaryNames.get(name); @@ -1475,16 +1469,16 @@ private void maybeShowMinimap() { if (phase.isReport()) { String action = GUIP.getMinimapAutoDisplayReportPhase(); if (action.equals(MSG_SHOW)) { - setMapVisible(true); + GUIP.setMinimapEnabled(true); } else if (action.equals(MSG_HIDE)) { - setMapVisible(false); + GUIP.setMinimapEnabled(false); } } else if (phase.isOnMap()) { String action = GUIP.getMinimapAutoDisplayNonReportPhase(); if (action.equals(MSG_SHOW)) { - setMapVisible(true); + GUIP.setMinimapEnabled(true); } else if (action.equals(MSG_HIDE)) { - setMapVisible(false); + GUIP.setMinimapEnabled(false); } } } @@ -1569,16 +1563,16 @@ public void maybeShowUnitDisplay() { if (phase.isReport()) { String action = GUIP.getDisplayAutoDisplayReportPhase(); if (action.equals(MSG_SHOW)) { - setUnitDisplayVisible(true); + GUIP.setUnitDisplayEnabled(true); } else if (action.equals(MSG_HIDE)) { - setUnitDisplayVisible(false); + GUIP.setUnitDisplayEnabled(false); } } else if (phase.isOnMap()) { String action = GUIP.getDisplayAutoDisplayNonReportPhase(); if (action.equals(MSG_SHOW)) { - setUnitDisplayVisible(true); + GUIP.setUnitDisplayEnabled(true); } else if (action.equals(MSG_HIDE)) { - setUnitDisplayVisible(false); + GUIP.setUnitDisplayEnabled(false); } } } diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 5110060f714..57dd3219ed3 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -260,9 +260,11 @@ public CommonMenuBar() { menu.addSeparator(); initMenuItem(viewMekDisplay, menu, VIEW_UNIT_DISPLAY, VK_D); - viewMekDisplay.setSelected(GUIP.getBoolean(GUIPreferences.SHOW_UNIT_DISPLAY)); + GUIP.setUnitDisplayEnabled(false); + viewMekDisplay.setSelected(false); initMenuItem(viewMinimap, menu, VIEW_MINI_MAP, VK_M); - viewMinimap.setSelected(GUIP.getMinimapEnabled()); + GUIP.setMinimapEnabled(false); + viewMinimap.setSelected(false); menu.addSeparator(); initMenuItem(toggleFovDarken, menu, VIEW_TOGGLE_FOV_DARKEN); diff --git a/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java b/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java index dc7ae1e579f..fd874aa03ab 100644 --- a/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java +++ b/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java @@ -229,7 +229,7 @@ private void endMyTurn() { && (null != next) && (null != ce()) && (next.getOwnerId() != ce().getOwnerId())) { - clientgui.setUnitDisplayVisible(false); + clientgui.maybeShowUnitDisplay(); } cen = Entity.NONE; clientgui.getBoardView().select(null); diff --git a/megamek/src/megamek/client/ui/swing/FiringDisplay.java b/megamek/src/megamek/client/ui/swing/FiringDisplay.java index dbfa4f2b3ff..35d125bae1c 100644 --- a/megamek/src/megamek/client/ui/swing/FiringDisplay.java +++ b/megamek/src/megamek/client/ui/swing/FiringDisplay.java @@ -887,7 +887,7 @@ protected void endMyTurn() { if ((game.getPhase() == GamePhase.FIRING) && (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/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 4970851439f..b242d9ef384 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -1872,6 +1872,10 @@ public void toggleUnitDisplay() { store.setValue(SHOW_UNIT_DISPLAY, !getBoolean(SHOW_UNIT_DISPLAY)); } + public void setUnitDisplayEnabled(boolean b) { + store.setValue(SHOW_UNIT_DISPLAY, b); + } + /** * Toggles the state of the user preference for the Keybinds overlay. */ diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index b6f42c8a970..5966858fb23 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -375,7 +375,7 @@ public void hyperlinkUpdate(HyperlinkEvent evt) { Entity ent = currentClientgui.getClient().getGame().getEntity(id); if (ent != null) { currentClientgui.getUnitDisplay().displayEntity(ent); - currentClientgui.setUnitDisplayVisible(true); + GUIPreferences.getInstance().showUnitDisplay(); } } else if (evtDesc.startsWith(Report.TOOLTIP_LINK)) { String desc = evtDesc.substring(Report.TOOLTIP_LINK.length()); diff --git a/megamek/src/megamek/client/ui/swing/MovementDisplay.java b/megamek/src/megamek/client/ui/swing/MovementDisplay.java index 917ffcf1b47..2c4deff8082 100644 --- a/megamek/src/megamek/client/ui/swing/MovementDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MovementDisplay.java @@ -958,7 +958,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); diff --git a/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java b/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java index 5673b542260..574b24ed4a7 100644 --- a/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java +++ b/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java @@ -274,7 +274,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); diff --git a/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java b/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java index 3bc67fd80d9..16473531078 100644 --- a/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java +++ b/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java @@ -482,7 +482,7 @@ protected void endMyTurn() { if ((game.getPhase() == GamePhase.FIRING) && (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 757482ebb19..a68f339fabb 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/TargetingPhaseDisplay.java b/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java index 07e413c766e..d2a3e6eb91c 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); From f0fe43898507069052b5c2bb59afc5bcc101e115 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 14 Dec 2022 11:22:00 -0500 Subject: [PATCH 17/47] show game board in all the game phases 17 --- .../client/ui/dialogs/UnitDisplayDialog.java | 12 ++ .../megamek/client/ui/swing/ClientGUI.java | 143 +++++++++--------- .../client/ui/swing/CommonMenuBar.java | 14 +- .../client/ui/swing/GUIPreferences.java | 26 ++-- .../src/megamek/client/ui/swing/MapMenu.java | 2 +- .../client/ui/swing/MiniReportDisplay.java | 22 +-- .../client/ui/swing/PlayerListDialog.java | 13 +- .../client/ui/swing/minimap/Minimap.java | 4 +- .../ui/swing/unitDisplay/UnitDisplay.java | 71 ++++----- 9 files changed, 163 insertions(+), 144 deletions(-) diff --git a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java index 3970a66b345..d84a1f7e403 100644 --- a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java +++ b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java @@ -20,16 +20,20 @@ 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 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 GUIPreferences GUIP = GUIPreferences.getInstance(); //endregion Variable Declarations //region Constructors @@ -37,6 +41,14 @@ public UnitDisplayDialog(final JFrame frame, final UnitDisplay unitDisplay, final ClientGUI clientGUI) { super(frame, Messages.getString("ClientGUI.MechDisplay"), false); setUnitDisplay(unitDisplay); + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent evt) { + GUIP.setUnitDisplayEnabled(false); + } + }); + this.clientGUI = clientGUI; } //endregion Constructors diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index ccfb5c3dbb7..54e10612148 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -422,14 +422,14 @@ public void setUnitDisplayDialog(final UnitDisplayDialog unitDisplayDialog) { * Try to load the "bing" sound clip. */ private void loadSoundClip() { - if (GUIPreferences.getInstance().getSoundBingFilename() == null) { + if (GUIP.getSoundBingFilename() == null) { return; } try { - File file = new File(GUIPreferences.getInstance().getSoundBingFilename()); + File file = new File(GUIP.getSoundBingFilename()); if (!file.exists()) { - LogManager.getLogger().error(MSG_FAILEDTOLOADAUDIFILE + " " + GUIPreferences.getInstance().getSoundBingFilename()); + LogManager.getLogger().error(MSG_FAILEDTOLOADAUDIFILE + " " + GUIP.getSoundBingFilename()); return; } bingClip = Applet.newAudioClip(file.toURI().toURL()); @@ -455,14 +455,14 @@ private void initializeFrame() { frame = new JFrame(MSG_TITLE); frame.setJMenuBar(menuBar); - if (GUIPreferences.getInstance().getWindowSizeHeight() != 0) { + if (GUIP.getWindowSizeHeight() != 0) { frame.setLocation( - GUIPreferences.getInstance().getWindowPosX(), - GUIPreferences.getInstance().getWindowPosY() + GUIP.getWindowPosX(), + GUIP.getWindowPosY() ); frame.setSize( - GUIPreferences.getInstance().getWindowSizeWidth(), - GUIPreferences.getInstance().getWindowSizeHeight() + GUIP.getWindowSizeWidth(), + GUIP.getWindowSizeHeight() ); } else { frame.setSize(800, 600); @@ -533,7 +533,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, @@ -579,13 +579,13 @@ public void windowClosing(WindowEvent e) { 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()); + if (GUIP.getDisplayStartTabbed()) { + getUnitDisplayDialog().setLocation(GUIP.getDisplayPosX(), GUIP.getDisplayPosY()); + getUnitDisplayDialog().setSize(GUIP.getDisplaySizeWidth(), GUIP.getDisplaySizeHeight()); } else { - getUnitDisplayDialog().setLocation(GUIPreferences.getInstance().getDisplayNontabbedPosX(), GUIPreferences.getInstance().getDisplayNontabbedPosY()); - getUnitDisplayDialog().setSize(GUIPreferences.getInstance().getDisplayNonTabbedSizeWidth(), GUIPreferences.getInstance().getDisplayNonTabbedSizeHeight()); + getUnitDisplayDialog().setLocation(GUIP.getDisplayNontabbedPosX(), GUIP.getDisplayNontabbedPosY()); + getUnitDisplayDialog().setSize(GUIP.getDisplayNonTabbedSizeWidth(), GUIP.getDisplayNonTabbedSizeHeight()); } UIUtil.updateWindowBounds(getUnitDisplayDialog()); @@ -593,23 +593,17 @@ public void windowClosing(WindowEvent e) { getUnitDisplayDialog().setFocusable(false); getUnitDisplayDialog().setFocusableWindowState(false); getUnitDisplayDialog().add(getUnitDisplay()); - getUnitDisplayDialog().addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent evt) { - GUIPreferences.getInstance().hideUnitDisplay(); - } - }); - 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() + GUIP.getRulerPosX(), + GUIP.getRulerPosY() ); ruler.setSize( - GUIPreferences.getInstance().getRulerSizeHeight(), - GUIPreferences.getInstance().getRulerSizeWidth() + GUIP.getRulerSizeHeight(), + GUIP.getRulerSizeWidth() ); UIUtil.updateWindowBounds(ruler); @@ -862,10 +856,10 @@ public void actionPerformed(ActionEvent event) { customizePlayer(); break; case VIEW_PLAYER_LIST: - showPlayerList(); + GUIP.togglePlayerListEnabled(); break; case VIEW_ROUND_REPORT: - showRoundReport(); + GUIP.toggleRoundReportEnabled(); break; case BOARD_SAVE: ignoreHotKeys = true; @@ -906,32 +900,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() == GamePhase.MOVEMENT) { 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() == GamePhase.MOVEMENT) { 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) { @@ -942,8 +933,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; @@ -1022,41 +1012,41 @@ 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.getDisplayStartTabbed()) { + GUIP.setDisplayPosX(getUnitDisplayDialog().getLocation().x); + GUIP.setDisplayPosY(getUnitDisplayDialog().getLocation().y); + GUIP.setDisplaySizeWidth(getUnitDisplayDialog().getSize().width); + GUIP.setDisplaySizeHeight(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.setDisplayNontabbedPosX(getUnitDisplayDialog().getLocation().x); + GUIP.setDisplayNontabbedPosY(getUnitDisplayDialog().getLocation().y); + GUIP.setDisplayNonTabbedSizeWidth(getUnitDisplayDialog().getSize().width); + GUIP.setDisplayNonTabbedSizeHeight(getUnitDisplayDialog().getSize().height); unitDisplay.saveSplitterLoc(); } } // 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); } } @@ -1218,7 +1208,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(); } } @@ -1443,7 +1433,7 @@ protected void showBoardPopup(Coords c) { */ public void toggleMMUDDisplays() { GUIP.toggleUnitDisplay(); - GUIP.setMinimapEnabled(GUIP.getBoolean(GUIPreferences.SHOW_UNIT_DISPLAY)); + GUIP.setMinimapEnabled(GUIP.getUnitDisplayEnabled()); } /** @@ -1458,7 +1448,7 @@ private void toggleAccessibilityWindow() { private void toggleUnitOverview() { uo.setVisible(!uo.isVisible()); - GUIPreferences.getInstance().setShowUnitOverview(uo.isVisible()); + GUIP.setShowUnitOverview(uo.isVisible()); bv.refreshDisplayables(); } @@ -1489,16 +1479,16 @@ private void maybeShowMiniReport() { if (phase.isReport()) { String action = GUIP.getMiniReportAutoDisplayReportPhase(); if (action.equals(MSG_SHOW)) { - setMiniReportVisible(true); + GUIP.setMiniReportEnabled(true); } else if (action.equals(MSG_HIDE)) { - setMiniReportVisible(false); + GUIP.setMiniReportEnabled(false); } } else if (phase.isOnMap()) { String action = GUIP.getMiniReportAutoDisplayNonReportPhase(); if (action.equals(MSG_SHOW)) { - setMiniReportVisible(true); + GUIP.setMiniReportEnabled(true); } else if (action.equals(MSG_HIDE)) { - setMiniReportVisible(false); + GUIP.setMiniReportEnabled(false); } } } @@ -1509,16 +1499,16 @@ private void maybeShowPlayerList() { if (phase.isReport()) { String action = GUIP.getPlayerListAutoDisplayReportPhase(); if (action.equals(MSG_SHOW)) { - setPlayerListVisible(true); + GUIP.setPlayerListEnabled(true); } else if (action.equals(MSG_HIDE)) { - setPlayerListVisible(false); + GUIP.setPlayerListEnabled(false); } } else if (phase.isOnMap()) { String action = GUIP.getPlayerListAutoDisplayNonReportPhase(); if (action.equals(MSG_SHOW)) { - setPlayerListVisible(true); + GUIP.setPlayerListEnabled(true); } else if (action.equals(MSG_HIDE)) { - setPlayerListVisible(false); + GUIP.setPlayerListEnabled(false); } } } @@ -1954,12 +1944,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; } @@ -1985,7 +1974,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.play(); } } @@ -2659,7 +2648,11 @@ public void preferenceChange(PreferenceChangeEvent e) { if (e.getName().equals(GUIPreferences.MINIMAP_ENABLED)) { setMapVisible(GUIP.getMinimapEnabled()); } else if (e.getName().equals(GUIPreferences.SHOW_UNIT_DISPLAY)) { - setUnitDisplayVisible(GUIP.getBoolean(GUIPreferences.SHOW_UNIT_DISPLAY)); + setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); + } else if (e.getName().equals(GUIPreferences.MINI_REPORT_ENABLED)) { + setMiniReportVisible(GUIP.getMiniReportEnabled()); + } else if (e.getName().equals(GUIPreferences.PLAYER_lIST_ENABLED)) { + setPlayerListVisible(GUIP.getPlayerListEnabled()); } else if (e.getName().equals(GUIPreferences.GUI_SCALE)) { adaptToGUIScale(); } diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 57dd3219ed3..0649f9b6d60 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -60,9 +60,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")); @@ -174,10 +174,14 @@ public CommonMenuBar() { menu.setMnemonic(VK_G); initMenuItem(gameRoundReport, menu, VIEW_ROUND_REPORT); + GUIP.setMiniReportEnabled(false); + gameRoundReport.setSelected(false); menu.addSeparator(); initMenuItem(gameReplacePlayer, menu, FILE_GAME_REPLACE_PLAYER, VK_R); initMenuItem(gamePlayerList, menu, VIEW_PLAYER_LIST); + GUIP.setMinimapEnabled(false); + gamePlayerList.setSelected(false); menu.addSeparator(); initMenuItem(gameGameOptions, menu, VIEW_GAME_OPTIONS, VK_O); @@ -496,7 +500,11 @@ public void preferenceChange(PreferenceChangeEvent e) { } 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)); + 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()); } } diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index b242d9ef384..507064c40f6 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -1441,6 +1441,10 @@ public void setMiniReportEnabled(boolean b) { store.setValue(MINI_REPORT_ENABLED, b); } + public void toggleRoundReportEnabled() { + setMiniReportEnabled(!getMiniReportEnabled()); + } + public void setMinimapPosX(int i) { store.setValue(MINIMAP_POS_X, i); } @@ -1481,6 +1485,10 @@ 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); } @@ -1851,20 +1859,6 @@ 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); - } - - /** - * 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. */ @@ -1876,6 +1870,10 @@ public void setUnitDisplayEnabled(boolean b) { store.setValue(SHOW_UNIT_DISPLAY, b); } + public boolean getUnitDisplayEnabled() { + return store.getBoolean(SHOW_UNIT_DISPLAY); + } + /** * Toggles the state of the user preference for the Keybinds overlay. */ diff --git a/megamek/src/megamek/client/ui/swing/MapMenu.java b/megamek/src/megamek/client/ui/swing/MapMenu.java index 208881cdcb0..b815d37304a 100644 --- a/megamek/src/megamek/client/ui/swing/MapMenu.java +++ b/megamek/src/megamek/client/ui/swing/MapMenu.java @@ -312,7 +312,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/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index 5966858fb23..50c11030cf0 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -51,6 +51,7 @@ 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 String MSG_TITLE = Messages.getString("MiniReportDisplay.title"); private static final String MSG_ROUND = Messages.getString("MiniReportDisplay.Round"); @@ -109,11 +110,11 @@ public MiniReportDisplay(JFrame parent, ClientGUI clientgui) { setupReportTabs(); - setSize(GUIPreferences.getInstance().getMiniReportSizeWidth(), - GUIPreferences.getInstance().getMiniReportSizeHeight()); + setSize(GUIP.getMiniReportSizeWidth(), + GUIP.getMiniReportSizeHeight()); doLayout(); - setLocation(GUIPreferences.getInstance().getMiniReportPosX(), - GUIPreferences.getInstance().getMiniReportPosY()); + setLocation(GUIP.getMiniReportPosX(), + GUIP.getMiniReportPosY()); // closing the window is the same as hitting butOkay addWindowListener(new WindowAdapter() { @@ -125,7 +126,7 @@ public void windowClosing(WindowEvent e) { }); adaptToGUIScale(); - GUIPreferences.getInstance().addPreferenceChangeListener(this); + GUIP.addPreferenceChangeListener(this); butOkay.requestFocus(); } @@ -274,6 +275,7 @@ public void actionPerformed(ActionEvent ae) { if (ae.getSource().equals(butOkay)) { savePref(); setVisible(false); + GUIP.setMiniReportEnabled(false); } else if (ae.getSource().equals(butPlayerSearchDown)) { String searchPattern = comboPlayer.getSelectedItem().toString().trim(); searchTextPane(searchPattern, true); @@ -313,10 +315,10 @@ private void setupReportTabs() { } private void savePref() { - GUIPreferences.getInstance().setMiniReportSizeWidth(getSize().width); - GUIPreferences.getInstance().setMiniReportSizeHeight(getSize().height); - GUIPreferences.getInstance().setMiniReportPosX(getLocation().x); - GUIPreferences.getInstance().setMiniReportPosY(getLocation().y); + GUIP.setMiniReportSizeWidth(getSize().width); + GUIP.setMiniReportSizeHeight(getSize().height); + GUIP.setMiniReportPosX(getLocation().x); + GUIP.setMiniReportPosY(getLocation().y); } public void addReportPages() { @@ -375,7 +377,7 @@ public void hyperlinkUpdate(HyperlinkEvent evt) { Entity ent = currentClientgui.getClient().getGame().getEntity(id); if (ent != null) { currentClientgui.getUnitDisplay().displayEntity(ent); - GUIPreferences.getInstance().showUnitDisplay(); + GUIP.setUnitDisplayEnabled(true); } } else if (evtDesc.startsWith(Report.TOOLTIP_LINK)) { String desc = evtDesc.substring(Report.TOOLTIP_LINK.length()); diff --git a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java index 2373cbf1272..cc3980d96db 100644 --- a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java +++ b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java @@ -43,6 +43,8 @@ public class PlayerListDialog extends JDialog implements ActionListener, IPrefer private static final String MSG_OKAY= Messages.getString("Okay"); + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + public PlayerListDialog(JFrame parent, Client client) { super(parent, Messages.getString("PlayerListDialog.title"), false); this.client = client; @@ -70,12 +72,12 @@ public void windowClosing(WindowEvent e) { setMinimumSize(new Dimension(300, 260)); adaptToGUIScale(); - GUIPreferences.getInstance().addPreferenceChangeListener(this); + GUIP.addPreferenceChangeListener(this); pack(); setResizable(false); - setLocation(GUIPreferences.getInstance().getPlayerListPosX(), - GUIPreferences.getInstance().getPlayerListPosY()); + setLocation(GUIP.getPlayerListPosX(), + GUIP.getPlayerListPosY()); } public static void refreshPlayerList(JList playerList, @@ -163,6 +165,7 @@ public void actionPerformed(ActionEvent ae) { if (ae.getSource().equals(butOkay)) { savePref(); setVisible(false); + GUIP.setPlayerListEnabled(false); } } @@ -188,8 +191,8 @@ protected void processWindowEvent(WindowEvent e) { } } private void savePref() { - GUIPreferences.getInstance().setPlayerListPosX(getLocation().x); - GUIPreferences.getInstance().setPlayerListPosY(getLocation().y); + GUIP.setPlayerListPosX(getLocation().x); + GUIP.setPlayerListPosY(getLocation().y); } private void adaptToGUIScale() { diff --git a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java index 3eadb52a53a..6f287b0a14a 100644 --- a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java +++ b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java @@ -511,7 +511,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() == GamePhase.UNKNOWN) && !h.isValid(null)) { - gg.setColor(GUIPreferences.getInstance().getWarningColor()); + gg.setColor(GUIP.getWarningColor()); paintCoord(gg, j, k, true); } } @@ -1344,7 +1344,7 @@ public void boardChangedHex(BoardEvent b) { private final GameListener gameListener = new GameListenerAdapter() { @Override public void gamePhaseChange(GamePhaseChangeEvent e) { - if (GUIPreferences.getInstance().getGameSummaryMinimap() && ((e.getOldPhase() == GamePhase.DEPLOYMENT) + if (GUIP.getGameSummaryMinimap() && ((e.getOldPhase() == GamePhase.DEPLOYMENT) || (e.getOldPhase() == GamePhase.MOVEMENT) || (e.getOldPhase() == GamePhase.TARGETING) || (e.getOldPhase() == GamePhase.PREMOVEMENT) || (e.getOldPhase() == GamePhase.PREFIRING) || (e.getOldPhase() == GamePhase.FIRING) || (e.getOldPhase() == GamePhase.PHYSICAL))) { diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index 33db52e2906..2b2de9aa409 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -86,6 +86,8 @@ 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 GUIPreferences GUIP = GUIPreferences.getInstance(); + /** * Creates and lays out a new mech display. * @@ -173,11 +175,11 @@ 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()); + splitABC.setDividerLocation(GUIP.getDisplaySplitABCLoc()); + splitBC.setDividerLocation(GUIP.getDisplaySplitBCLoc()); + splitA1.setDividerLocation(GUIP.getDisplaySplitA1Loc()); + splitB1.setDividerLocation(GUIP.getDisplaySplitB1Loc()); + splitC1.setDividerLocation(GUIP.getDisplaySplitC1Loc()); butSwitchView.setPreferredSize(new Dimension(500,20)); @@ -194,29 +196,30 @@ public UnitDisplay(@Nullable ClientGUI clientgui, @Override public void actionPerformed(ActionEvent e) { if (clientgui != null) { - if (!(GUIPreferences.getInstance().getDisplayStartTabbed())) { + Container unitDisplayContainer = clientgui.unitDisplay.getRootPane().getParent(); + if (!(GUIP.getDisplayStartTabbed())) { 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.setDisplayNontabbedPosX(unitDisplayContainer.getLocation().x); + GUIP.setDisplayNontabbedPosY(unitDisplayContainer.getLocation().y); + GUIP.setDisplayNonTabbedSizeWidth(unitDisplayContainer.getSize().width); + GUIP.setDisplayNonTabbedSizeHeight(unitDisplayContainer.getSize().height); + unitDisplayContainer.setLocation(GUIP.getDisplayPosX(), GUIP.getDisplayPosY()); + unitDisplayContainer.setSize(GUIP.getDisplaySizeWidth(), GUIP.getDisplaySizeHeight()); 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.setDisplayPosX(unitDisplayContainer.getLocation().x); + GUIP.setDisplayPosY(unitDisplayContainer.getLocation().y); + GUIP.setDisplaySizeWidth(unitDisplayContainer.getSize().width); + GUIP.setDisplaySizeHeight(unitDisplayContainer.getSize().height); + unitDisplayContainer.setLocation(GUIP.getDisplayNontabbedPosX(), GUIP.getDisplayNontabbedPosY()); + unitDisplayContainer.setSize(GUIP.getDisplayNonTabbedSizeWidth(), GUIP.getDisplayNonTabbedSizeHeight()); setDisplayNonTabbed(); } } } }); - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getDisplayStartTabbed()) { setDisplayTabbed(); } else { @@ -252,7 +255,7 @@ private void setDisplayTabbed() { displayP.revalidate(); displayP.repaint(); - GUIPreferences.getInstance().setDisplayStartTabbed(true); + GUIP.setDisplayStartTabbed(true); } /** @@ -289,7 +292,7 @@ public void setDisplayNonTabbed() { displayP.revalidate(); displayP.repaint(); - GUIPreferences.getInstance().setDisplayStartTabbed(false); + GUIP.setDisplayStartTabbed(false); } /** @@ -297,11 +300,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.setDisplaySplitABCLoc(splitABC.getDividerLocation()); + GUIP.setDisplaySplitBCLoc(splitBC.getDividerLocation()); + GUIP.setDisplaySplitA1Loc(splitA1.getDividerLocation()); + GUIP.setDisplaySplitB1Loc(splitB1.getDividerLocation()); + GUIP.setDisplaySplitC2Loc(splitC1.getDividerLocation()); } /** @@ -381,7 +384,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SUMMARY); } @@ -405,7 +408,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.PILOT); } @@ -429,7 +432,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.ARMOR); } @@ -453,7 +456,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SYSTEMS); } @@ -477,7 +480,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.WEAPONS); } @@ -501,7 +504,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.EXTRAS); } @@ -567,7 +570,7 @@ public Entity getCurrentEntity() { * Changes to the specified panel. */ public void showPanel(String s) { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, s); } @@ -591,7 +594,7 @@ public void showPanel(String s) { * @param loc */ public void showSpecificSystem(int loc) { - if (GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (GUIP.getDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SYSTEMS); } From cd1cf19f38db863ad5117e4c4257a3d4da6e5a62 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 14 Dec 2022 12:44:11 -0500 Subject: [PATCH 18/47] show game board in all the game phases 18 --- .../megamek/client/ui/swing/ClientGUI.java | 36 +- .../client/ui/swing/CommonMenuBar.java | 10 +- .../client/ui/swing/CommonSettingsDialog.java | 351 +++++++++--------- .../client/ui/swing/GUIPreferences.java | 305 +++++++-------- .../src/megamek/client/ui/swing/MapMenu.java | 2 +- .../client/ui/swing/MiniReportDisplay.java | 6 +- .../ui/swing/unitDisplay/UnitDisplay.java | 68 ++-- 7 files changed, 389 insertions(+), 389 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 54e10612148..6732488f16e 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -579,13 +579,13 @@ public void windowClosing(WindowEvent e) { setUnitDisplayDialog(new UnitDisplayDialog(getFrame(), getUnitDisplay(), this)); - if (GUIP.getDisplayStartTabbed()) { - getUnitDisplayDialog().setLocation(GUIP.getDisplayPosX(), GUIP.getDisplayPosY()); - getUnitDisplayDialog().setSize(GUIP.getDisplaySizeWidth(), GUIP.getDisplaySizeHeight()); + if (GUIP.getUnitDisplayStartTabbed()) { + getUnitDisplayDialog().setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY()); + getUnitDisplayDialog().setSize(GUIP.getUnitDisplaySizeWidth(), GUIP.getUnitDisplaySizeHeight()); } else { - getUnitDisplayDialog().setLocation(GUIP.getDisplayNontabbedPosX(), GUIP.getDisplayNontabbedPosY()); - getUnitDisplayDialog().setSize(GUIP.getDisplayNonTabbedSizeWidth(), GUIP.getDisplayNonTabbedSizeHeight()); + getUnitDisplayDialog().setLocation(GUIP.getUnitDisplayNontabbedPosX(), GUIP.getUnitDisplayNontabbedPosY()); + getUnitDisplayDialog().setSize(GUIP.getUnitDisplayNonTabbedSizeWidth(), GUIP.getUnitDisplayNonTabbedSizeHeight()); } UIUtil.updateWindowBounds(getUnitDisplayDialog()); @@ -1026,17 +1026,17 @@ void saveSettings() { // Mek display if ((getUnitDisplayDialog() != null) && ((getUnitDisplayDialog().getSize().width * getUnitDisplayDialog().getSize().height) > 0)) { - if (GUIP.getDisplayStartTabbed()) { - GUIP.setDisplayPosX(getUnitDisplayDialog().getLocation().x); - GUIP.setDisplayPosY(getUnitDisplayDialog().getLocation().y); - GUIP.setDisplaySizeWidth(getUnitDisplayDialog().getSize().width); - GUIP.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 { - GUIP.setDisplayNontabbedPosX(getUnitDisplayDialog().getLocation().x); - GUIP.setDisplayNontabbedPosY(getUnitDisplayDialog().getLocation().y); - GUIP.setDisplayNonTabbedSizeWidth(getUnitDisplayDialog().getSize().width); - GUIP.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(); } } @@ -1551,14 +1551,14 @@ public void maybeShowUnitDisplay() { GamePhase phase = getClient().getGame().getPhase(); if (phase.isReport()) { - String action = GUIP.getDisplayAutoDisplayReportPhase(); + String action = GUIP.getUnitDisplayAutoDisplayReportPhase(); if (action.equals(MSG_SHOW)) { GUIP.setUnitDisplayEnabled(true); } else if (action.equals(MSG_HIDE)) { GUIP.setUnitDisplayEnabled(false); } } else if (phase.isOnMap()) { - String action = GUIP.getDisplayAutoDisplayNonReportPhase(); + String action = GUIP.getUnitDisplayAutoDisplayNonReportPhase(); if (action.equals(MSG_SHOW)) { GUIP.setUnitDisplayEnabled(true); } else if (action.equals(MSG_HIDE)) { @@ -2645,9 +2645,9 @@ private void adaptToGUIScale() { @Override public void preferenceChange(PreferenceChangeEvent e) { - if (e.getName().equals(GUIPreferences.MINIMAP_ENABLED)) { + if (e.getName().equals(GUIPreferences.MINI_MAP_ENABLED)) { setMapVisible(GUIP.getMinimapEnabled()); - } else if (e.getName().equals(GUIPreferences.SHOW_UNIT_DISPLAY)) { + } else if (e.getName().equals(GUIPreferences.UNIT_DISPLAY_ENABLED)) { setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); } else if (e.getName().equals(GUIPreferences.MINI_REPORT_ENABLED)) { setMiniReportVisible(GUIP.getMiniReportEnabled()); diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 0649f9b6d60..158d08cf3e2 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -350,9 +350,13 @@ public void actionPerformed(ActionEvent event) { GUIP.setValue(GUIPreferences.GUI_SCALE, guiScale - 0.1); } } else if (event.getActionCommand().equals(ClientGUI.VIEW_MINI_MAP)) { - GUIP.setMinimapEnabled(!GUIP.getMinimapEnabled()); + GUIP.toggleMinimapEnabled(); } else if (event.getActionCommand().equals(ClientGUI.VIEW_UNIT_DISPLAY)) { GUIP.toggleUnitDisplay(); + } else if (event.getActionCommand().equals(VIEW_ROUND_REPORT)) { + GUIP.toggleRoundReportEnabled(); + } else if (event.getActionCommand().equals(VIEW_PLAYER_LIST)) { + GUIP.togglePlayerListEnabled(); } else if (event.getActionCommand().equals(ClientGUI.VIEW_KEYBINDS_OVERLAY)) { GUIP.toggleKeybindsOverlay(); } else if (event.getActionCommand().equals(ClientGUI.VIEW_TOGGLE_HEXCOORDS)) { @@ -493,13 +497,13 @@ 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)) { + } 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()); diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index 1b7b7d2205d..507852a953b 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -243,6 +243,8 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg private ClientGUI clientgui = null; + private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + private static final String[] LOCALE_CHOICES = { "en", "de", "ru", "es" }; private static final Dimension LABEL_SPACER = new Dimension(5, 0); @@ -566,28 +568,27 @@ 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()); - 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()); + 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); @@ -625,19 +626,19 @@ public void setVisible(boolean visible) { } 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")))); @@ -651,8 +652,8 @@ public void setVisible(boolean visible) { } } - gameSummaryBV.setSelected(gs.getGameSummaryBoardView()); - gameSummaryMM.setSelected(gs.getGameSummaryMinimap()); + gameSummaryBV.setSelected(GUIP.getGameSummaryBoardView()); + gameSummaryMM.setSelected(GUIP.getGameSummaryMinimap()); skinFiles.removeAllItems(); List xmlFiles = new ArrayList<>(Arrays @@ -667,22 +668,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()); @@ -700,27 +701,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(); @@ -740,29 +741,28 @@ 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(); @@ -773,14 +773,14 @@ protected void cancelAction() { unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B2)); unitDisplayNonTabbed.addElement(UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C2)); - unitDisplayAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getDisplayAutoDisplayReportPhase()); - unitDisplayAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getDisplayAutoDisplayNonReportPhase()); - miniMapAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getMinimapAutoDisplayReportPhase()); - miniMapAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getMinimapAutoDisplayNonReportPhase()); - miniReportAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getMiniReportAutoDisplayReportPhase()); - miniReportAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getMiniReportAutoDisplayNonReportPhase()); - playerListAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getPlayerListAutoDisplayReportPhase()); - playerListAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getPlayerListAutoDisplayNonReportPhase()); + 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); } @@ -788,38 +788,37 @@ 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.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); + 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.setShowMoveStep(animateMove.isSelected()); + GUIP.setShowWrecks(showWrecks.isSelected()); + GUIP.setSoundMute(soundMute.isSelected()); + GUIP.setShowWpsinTT(showWpsinTT.isSelected()); + GUIP.setshowArmorMiniVisTT(showArmorMiniVisTT.isSelected()); + GUIP.setshowPilotPortraitTT(showPilotPortraitTT.isSelected()); + GUIP.setTooltipDelay(Integer.parseInt(tooltipDelay.getText())); + GUIP.setTooltipDismissDelay(Integer.parseInt(tooltipDismissDelay.getText())); + GUIP.setTooltipDistSuppression(Integer.parseInt(tooltipDistSupression.getText())); + GUIP.setValue(GUIPreferences.GUI_SCALE, (float) (guiScale.getValue()) / 10); cs.setUnitStartChar(((String) unitStartChar.getSelectedItem()).charAt(0)); - - gs.setMouseWheelZoom(mouseWheelZoom.isSelected()); - gs.setMouseWheelZoomFlip(mouseWheelZoomFlip.isSelected()); + + GUIP.setMouseWheelZoom(mouseWheelZoom.isSelected()); + GUIP.setMouseWheelZoomFlip(mouseWheelZoomFlip.isSelected()); cs.setMaxPathfinderTime(Integer.parseInt(maxPathfinderTime.getText())); - gs.setGetFocus(getFocus.isSelected()); + GUIP.setGetFocus(getFocus.isSelected()); cs.setKeepGameLog(keepGameLog.isSelected()); cs.setGameLogFilename(gameLogFilename.getText()); @@ -838,25 +837,25 @@ protected void okAction() { cs.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) { @@ -865,7 +864,7 @@ 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); } } @@ -878,9 +877,9 @@ protected void okAction() { cs.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 @@ -980,7 +979,7 @@ protected void okAction() { } // unit display non tabbed - if (!GUIPreferences.getInstance().getDisplayStartTabbed()) { + if (!GUIP.getUnitDisplayStartTabbed()) { boolean unitDisplayNonTabbedChanged = false; int s = unitDisplayNonTabbed.getSize(); @@ -1014,14 +1013,14 @@ protected void okAction() { } } - GUIPreferences.getInstance().setDisplayAutoDisplayReportPhase((String) unitDisplayAutoDisplayReportCombo.getSelectedItem()); - GUIPreferences.getInstance().setDisplayAutoDisplayNonReportPhase((String) unitDisplayAutoDisplayNonReportCombo.getSelectedItem()); - GUIPreferences.getInstance().setMinimapAutoDisplayReportPhase((String) miniMapAutoDisplayReportCombo.getSelectedItem()); - GUIPreferences.getInstance().setMinimapAutoDisplayNonReportPhase((String) miniMapAutoDisplayNonReportCombo.getSelectedItem()); - GUIPreferences.getInstance().setMiniReportAutoDisplayReportPhase((String) miniReportAutoDisplayReportCombo.getSelectedItem()); - GUIPreferences.getInstance().setMiniReportAutoDisplayNonReportPhase((String) miniReportAutoDisplayNonReportCombo.getSelectedItem()); - GUIPreferences.getInstance().setPlayerListAutoDisplayReportPhase((String) playerListAutoDisplayReportCombo.getSelectedItem()); - GUIPreferences.getInstance().setPlayerListAutoDisplayNonReportPhase((String) playerListAutoDisplayNonReportCombo.getSelectedItem()); + GUIP.setUnitDisplayAutoDisplayReportPhase((String) unitDisplayAutoDisplayReportCombo.getSelectedItem()); + GUIP.setUnitDisplayAutoDisplayNonReportPhase((String) unitDisplayAutoDisplayNonReportCombo.getSelectedItem()); + GUIP.setMinimapAutoDisplayReportPhase((String) miniMapAutoDisplayReportCombo.getSelectedItem()); + GUIP.setMinimapAutoDisplayNonReportPhase((String) miniMapAutoDisplayNonReportCombo.getSelectedItem()); + GUIP.setMiniReportAutoDisplayReportPhase((String) miniReportAutoDisplayReportCombo.getSelectedItem()); + GUIP.setMiniReportAutoDisplayNonReportPhase((String) miniReportAutoDisplayNonReportCombo.getSelectedItem()); + GUIP.setPlayerListAutoDisplayReportPhase((String) playerListAutoDisplayReportCombo.getSelectedItem()); + GUIP.setPlayerListAutoDisplayNonReportPhase((String) playerListAutoDisplayNonReportCombo.getSelectedItem()); setVisible(false); } @@ -1030,7 +1029,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()); @@ -1040,7 +1038,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()); @@ -1048,36 +1046,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()); } } @@ -1087,7 +1085,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; @@ -1464,7 +1462,7 @@ private JPanel getPhasePanel() { unitDisplayAutoDisplayReportCombo.addItem(MSG_MANUAL); unitDisplayAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - unitDisplayAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getDisplayAutoDisplayReportPhase()); + unitDisplayAutoDisplayReportCombo.setSelectedItem(GUIP.getUnitDisplayAutoDisplayReportPhase()); row.add(phaseLabel); row.add(unitDisplayAutoDisplayReportCombo); comps.add(row); @@ -1476,7 +1474,7 @@ private JPanel getPhasePanel() { unitDisplayAutoDisplayNonReportCombo.addItem(MSG_MANUAL); unitDisplayAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - unitDisplayAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getDisplayAutoDisplayNonReportPhase()); + unitDisplayAutoDisplayNonReportCombo.setSelectedItem(GUIP.getUnitDisplayAutoDisplayNonReportPhase()); row.add(phaseLabel); row.add(unitDisplayAutoDisplayNonReportCombo); comps.add(row); @@ -1495,7 +1493,7 @@ private JPanel getPhasePanel() { miniMapAutoDisplayReportCombo.addItem(MSG_MANUAL); miniMapAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - miniMapAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getMinimapAutoDisplayReportPhase()); + miniMapAutoDisplayReportCombo.setSelectedItem(GUIP.getMinimapAutoDisplayReportPhase()); row.add(phaseLabel); row.add(miniMapAutoDisplayReportCombo); comps.add(row); @@ -1507,7 +1505,7 @@ private JPanel getPhasePanel() { miniMapAutoDisplayNonReportCombo.addItem(MSG_MANUAL); miniMapAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - miniMapAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getMinimapAutoDisplayNonReportPhase()); + miniMapAutoDisplayNonReportCombo.setSelectedItem(GUIP.getMinimapAutoDisplayNonReportPhase()); row.add(phaseLabel); row.add(miniMapAutoDisplayNonReportCombo); comps.add(row); @@ -1526,7 +1524,7 @@ private JPanel getPhasePanel() { miniReportAutoDisplayReportCombo.addItem(MSG_MANUAL); miniReportAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - miniReportAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getMiniReportAutoDisplayReportPhase()); + miniReportAutoDisplayReportCombo.setSelectedItem(GUIP.getMiniReportAutoDisplayReportPhase()); row.add(phaseLabel); row.add(miniReportAutoDisplayReportCombo); comps.add(row); @@ -1538,7 +1536,7 @@ private JPanel getPhasePanel() { miniReportAutoDisplayNonReportCombo.addItem(MSG_MANUAL); miniReportAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - miniReportAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getMiniReportAutoDisplayNonReportPhase()); + miniReportAutoDisplayNonReportCombo.setSelectedItem(GUIP.getMiniReportAutoDisplayNonReportPhase()); row.add(phaseLabel); row.add(miniReportAutoDisplayNonReportCombo); comps.add(row); @@ -1557,7 +1555,7 @@ private JPanel getPhasePanel() { playerListAutoDisplayReportCombo.addItem(MSG_MANUAL); playerListAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - playerListAutoDisplayReportCombo.setSelectedItem(GUIPreferences.getInstance().getPlayerListAutoDisplayReportPhase()); + playerListAutoDisplayReportCombo.setSelectedItem(GUIP.getPlayerListAutoDisplayReportPhase()); row.add(phaseLabel); row.add(playerListAutoDisplayReportCombo); comps.add(row); @@ -1569,7 +1567,7 @@ private JPanel getPhasePanel() { playerListAutoDisplayNonReportCombo.addItem(MSG_MANUAL); playerListAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - playerListAutoDisplayNonReportCombo.setSelectedItem(GUIPreferences.getInstance().getPlayerListAutoDisplayNonReportPhase()); + playerListAutoDisplayNonReportCombo.setSelectedItem(GUIP.getPlayerListAutoDisplayNonReportPhase()); row.add(phaseLabel); row.add(playerListAutoDisplayNonReportCombo); comps.add(row); @@ -1635,7 +1633,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); } @@ -1740,7 +1738,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); @@ -1777,7 +1775,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(); } @@ -1785,13 +1783,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/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 507064c40f6..6dca072e9ee 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -118,23 +118,23 @@ 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 DISPLAY_AUTO_DISPLAY_REPORT_PHASE = "DisplayAutoDiplayReportPhase"; - public static final String DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE = "DisplayAutoDiplayNonReportPhase"; - public static final String SHOW_UNIT_DISPLAY = "ShowUnitDisplay"; + 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 GAME_SUMMARY_BOARD_VIEW = "GameSummaryBoardView"; public static final String GAME_SUMMARY_MINIMAP = "GameSummaryMinimap"; public static final String ENTITY_OWNER_LABEL_COLOR = "EntityOwnerLabelColor"; @@ -190,13 +190,13 @@ public class GUIPreferences extends PreferenceStoreProxy { 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 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 MINIMAP_AUTO_DISPLAY_REPORT_PHASE = "MinimapAutoDiplayReportPhase"; - public static final String MINIMAP_AUTO_DISPLAY_NONREPORT_PHASE = "MinimapAutoDiplayNonReportPhase"; + 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 MOUSE_WHEEL_ZOOM = "MouseWheelZoom"; @@ -351,10 +351,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); @@ -418,18 +418,19 @@ protected GUIPreferences() { 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(DISPLAY_AUTO_DISPLAY_REPORT_PHASE, MSG_HIDE); - store.setDefault(DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, MSG_SHOW); + 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, MSG_HIDE); + store.setDefault(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, MSG_SHOW); + store.setDefault(UNIT_DISPLAY_ENABLED, true); store.setDefault(GAME_SUMMARY_BOARD_VIEW, false); store.setDefault(ENTITY_OWNER_LABEL_COLOR, true); @@ -437,7 +438,6 @@ protected GUIPreferences() { 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); @@ -468,10 +468,10 @@ 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(MINIMAP_AUTO_DISPLAY_REPORT_PHASE, MSG_HIDE); - store.setDefault(MINIMAP_AUTO_DISPLAY_NONREPORT_PHASE, MSG_SHOW); + store.setDefault(MINI_MAP_COLOURS, "defaultminimap.txt"); + store.setDefault(MINI_MAP_ENABLED, true); + store.setDefault(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE, MSG_HIDE); + store.setDefault(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE, MSG_SHOW); store.setDefault(MMSYMBOL, true); store.setDefault(MINIMUM_SIZE_HEIGHT, 200); @@ -633,68 +633,72 @@ 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 getDisplayPosY() { - return store.getInt(DISPLAY_POS_Y); + public int getUnitDisplayPosY() { + return store.getInt(UNIT_DISPLAY_POS_Y); } - public int getDisplayNontabbedPosX() { - return store.getInt(DISPLAY_NONTABBED_POS_X); + public int getUnitDisplayNontabbedPosX() { + return store.getInt(UNIT_DISPLAY_NONTABBED_POS_X); } - public int getDisplayNontabbedPosY() { - return store.getInt(DISPLAY_NONTABBED_POS_Y); + public int getUnitDisplayNontabbedPosY() { + return store.getInt(UNIT_DISPLAY_NONTABBED_POS_Y); } - public boolean getDisplayStartTabbed() { - return store.getBoolean(DISPLAY_START_TABBED); + public boolean getUnitDisplayStartTabbed() { + return store.getBoolean(UNIT_DISPLAY_START_TABBED); } - public int getDisplaySplitABCLoc() { - return store.getInt(DISPLAY_SPLIT_ABC_LOC); + public int getUnitDisplaySplitABCLoc() { + return store.getInt(UNIT_DISPLAY_SPLIT_ABC_LOC); } - public int getDisplaySplitBCLoc() { - return store.getInt(DISPLAY_SPLIT_BC_LOC); + public int getUnitDisplaySplitBCLoc() { + return store.getInt(UNIT_DISPLAY_SPLIT_BC_LOC); } - public int getDisplaySplitA1Loc() { - return store.getInt(DISPLAY_SPLIT_A1_LOC); + public int getUnitDisplaySplitA1Loc() { + return store.getInt(UNIT_DISPLAY_SPLIT_A1_LOC); } - public int getDisplaySplitB1Loc() { - return store.getInt(DISPLAY_SPLIT_B1_LOC); + public int getUnitDisplaySplitB1Loc() { + return store.getInt(UNIT_DISPLAY_SPLIT_B1_LOC); } - public int getDisplaySplitC1Loc() { - return store.getInt(DISPLAY_SPLIT_C1_LOC); + public int getUnitDisplaySplitC1Loc() { + return store.getInt(UNIT_DISPLAY_SPLIT_C1_LOC); } - public int getDisplaySizeHeight() { - return store.getInt(DISPLAY_SIZE_HEIGHT); + public int getUnitDisplaySizeHeight() { + return store.getInt(UNIT_DISPLAY_SIZE_HEIGHT); } - public int getDisplaySizeWidth() { - return store.getInt(DISPLAY_SIZE_WIDTH); + public int getUnitDisplaySizeWidth() { + return store.getInt(UNIT_DISPLAY_SIZE_WIDTH); } - public int getDisplayNonTabbedSizeHeight() { - return store.getInt(DISPLAY_NONTABBED_SIZE_HEIGHT); + public int getUnitDisplayNonTabbedSizeHeight() { + return store.getInt(UNIT_DISPLAY_NONTABBED_SIZE_HEIGHT); } - public int getDisplayNonTabbedSizeWidth() { - return store.getInt(DISPLAY_NONTABBED_SIZE_WIDTH); + public int getUnitDisplayNonTabbedSizeWidth() { + return store.getInt(UNIT_DISPLAY_NONTABBED_SIZE_WIDTH); } - public String getDisplayAutoDisplayReportPhase() { - return store.getString(DISPLAY_AUTO_DISPLAY_REPORT_PHASE); + public String getUnitDisplayAutoDisplayReportPhase() { + return store.getString(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE); } - public String getDisplayAutoDisplayNonReportPhase() { - return store.getString(DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE); + public String getUnitDisplayAutoDisplayNonReportPhase() { + return store.getString(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE); + } + + public boolean getUnitDisplayEnabled() { + return store.getBoolean(UNIT_DISPLAY_ENABLED); } public boolean getGameSummaryBoardView() { @@ -866,19 +870,31 @@ 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 String getMinimapAutoDisplayReportPhase() { - return store.getString(MINIMAP_AUTO_DISPLAY_REPORT_PHASE); + public String getMinimapAutoDisplayReportPhase() { + return store.getString(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE); } public String getMinimapAutoDisplayNonReportPhase() { - return store.getString(MINIMAP_AUTO_DISPLAY_NONREPORT_PHASE); + return store.getString(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE); + } + + public int getMinimapPosX() { + return store.getInt(MINI_MAP_POS_X); + } + + public int getMinimapPosY() { + return store.getInt(MINI_MAP_POS_Y); + } + + public int getMinimapZoom() { + return store.getInt(MINI_MAP_ZOOM); } public boolean getMiniReportEnabled() { @@ -917,18 +933,6 @@ public boolean getIsometricEnabled() { return store.getBoolean(USE_ISOMETRIC); } - public int getMinimapPosX() { - return store.getInt(MINIMAP_POS_X); - } - - public int getMinimapPosY() { - return store.getInt(MINIMAP_POS_Y); - } - - public int getMinimapZoom() { - return store.getInt(MINIMAP_ZOOM); - } - public int getMinimumSizeHeight() { return store.getInt(MINIMUM_SIZE_HEIGHT); } @@ -1214,67 +1218,75 @@ 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 setDisplayPosY(int i) { - store.setValue(DISPLAY_POS_Y, i); + public void setUnitDisplayNontabbedPosX(int i) { + store.setValue(UNIT_DISPLAY_NONTABBED_POS_X, i); } - public void setDisplayNontabbedPosX(int i) { - store.setValue(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 setDisplayNontabbedPosY(int i) { - store.setValue(DISPLAY_NONTABBED_POS_Y, i); + public void setUnitDisplaySplitABCLoc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_ABC_LOC, i); } - public void setDisplayStartTabbed(boolean state) { - store.setValue(DISPLAY_START_TABBED, state); + + public void setUnitDisplaySplitBCLoc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_BC_LOC, i); } - public void setDisplaySplitABCLoc(int i) { - store.setValue(DISPLAY_SPLIT_ABC_LOC, i); + public void setUnitDisplaySplitA1Loc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_A1_LOC, i); } - public void setDisplaySplitBCLoc(int i) { - store.setValue(DISPLAY_SPLIT_BC_LOC, i); + public void setUnitDisplaySplitB1Loc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_B1_LOC, i); } - public void setDisplaySplitA1Loc(int i) { - store.setValue(DISPLAY_SPLIT_A1_LOC, i); + public void setUnitDisplaySplitC2Loc(int i) { + store.setValue(UNIT_DISPLAY_SPLIT_C1_LOC, i); } - public void setDisplaySplitB1Loc(int i) { - store.setValue(DISPLAY_SPLIT_B1_LOC, i); + public void setUnitDisplaySizeHeight(int i) { + store.setValue(UNIT_DISPLAY_SIZE_HEIGHT, i); } - public void setDisplaySplitC2Loc(int i) { - store.setValue(DISPLAY_SPLIT_C1_LOC, i); + public void setUnitDisplaySizeWidth(int i) { + store.setValue(UNIT_DISPLAY_SIZE_WIDTH, i); } - public void setDisplaySizeHeight(int i) { - store.setValue(DISPLAY_SIZE_HEIGHT, i); + public void setUnitDisplayNonTabbedSizeHeight(int i) { + store.setValue(UNIT_DISPLAY_NONTABBED_SIZE_HEIGHT, i); } - public void setDisplaySizeWidth(int i) { - store.setValue(DISPLAY_SIZE_WIDTH, i); + public void setUnitDisplayNonTabbedSizeWidth(int i) { + store.setValue(UNIT_DISPLAY_NONTABBED_SIZE_WIDTH, i); } - public void setDisplayNonTabbedSizeHeight(int i) { - store.setValue(DISPLAY_NONTABBED_SIZE_HEIGHT, i); + public void setUnitDisplayAutoDisplayReportPhase(String s) { + store.setValue(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE, s); } - public void setDisplayNonTabbedSizeWidth(int i) { - store.setValue(DISPLAY_NONTABBED_SIZE_WIDTH, i); + public void setUnitDisplayAutoDisplayNonReportPhase(String s) { + store.setValue(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, s); } - public void setDisplayAutoDisplayReportPhase(String s) { - store.setValue(DISPLAY_AUTO_DISPLAY_REPORT_PHASE, s); + public void toggleUnitDisplay() { + store.setValue(UNIT_DISPLAY_ENABLED, !getBoolean(UNIT_DISPLAY_ENABLED)); } - public void setDisplayAutoDisplayNonReportPhase(String s) { - store.setValue(DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, s); + public void setUnitDisplayEnabled(boolean b) { + store.setValue(UNIT_DISPLAY_ENABLED, b); } public void setGameSummaryBoardView(boolean state) { @@ -1434,35 +1446,39 @@ public void setRndArmyPosY(int i) { } public void setMinimapEnabled(boolean b) { - store.setValue(MINIMAP_ENABLED, b); + store.setValue(MINI_MAP_ENABLED, b); } - public void setMiniReportEnabled(boolean b) { - store.setValue(MINI_REPORT_ENABLED, b); - } - - public void toggleRoundReportEnabled() { - setMiniReportEnabled(!getMiniReportEnabled()); + 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(String s) { - store.setValue(MINIMAP_AUTO_DISPLAY_REPORT_PHASE, s); + store.setValue(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE, s); } public void setMinimapAutoDisplayNonReportPhase(String s) { - store.setValue(MINIMAP_AUTO_DISPLAY_NONREPORT_PHASE, s); + store.setValue(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE, s); + } + + public void setMiniReportEnabled(boolean b) { + store.setValue(MINI_REPORT_ENABLED, b); + } + + public void toggleRoundReportEnabled() { + setMiniReportEnabled(!getMiniReportEnabled()); } public void setMiniReportPosX(int i) { @@ -1859,21 +1875,6 @@ public void setAdvancedUnitToolTipSeenByResolution(int i) { store.setValue(ADVANCED_UNITTOOLTIP_SEENBYRESOLUTION, i); } - /** - * 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 setUnitDisplayEnabled(boolean b) { - store.setValue(SHOW_UNIT_DISPLAY, b); - } - - public boolean getUnitDisplayEnabled() { - return store.getBoolean(SHOW_UNIT_DISPLAY); - } - /** * Toggles the state of the user preference for the Keybinds overlay. */ diff --git a/megamek/src/megamek/client/ui/swing/MapMenu.java b/megamek/src/megamek/client/ui/swing/MapMenu.java index b815d37304a..ddffe50a08c 100644 --- a/megamek/src/megamek/client/ui/swing/MapMenu.java +++ b/megamek/src/megamek/client/ui/swing/MapMenu.java @@ -312,7 +312,7 @@ private JMenuItem viewJMenuItem(Entity en) { item.addActionListener(evt -> { try { selectedEntity = game.getEntity(Integer.parseInt(evt.getActionCommand())); - GUIPreferences.getInstance(). setUnitDisplayEnabled(true); + GUIPreferences.getInstance().setUnitDisplayEnabled(true); gui.getUnitDisplay().displayEntity(selectedEntity); } catch (Exception ex) { LogManager.getLogger().error("", ex); diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index 50c11030cf0..3af325fbd43 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -110,11 +110,9 @@ public MiniReportDisplay(JFrame parent, ClientGUI clientgui) { setupReportTabs(); - setSize(GUIP.getMiniReportSizeWidth(), - GUIP.getMiniReportSizeHeight()); + setSize(GUIP.getMiniReportSizeWidth(), GUIP.getMiniReportSizeHeight()); doLayout(); - setLocation(GUIP.getMiniReportPosX(), - GUIP.getMiniReportPosY()); + setLocation(GUIP.getMiniReportPosX(), GUIP.getMiniReportPosY()); // closing the window is the same as hitting butOkay addWindowListener(new WindowAdapter() { diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index 2b2de9aa409..de1861d2bb6 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -175,11 +175,11 @@ public UnitDisplay(@Nullable ClientGUI clientgui, splitABC.setLeftComponent(splitA1); splitABC.setRightComponent(splitBC); - splitABC.setDividerLocation(GUIP.getDisplaySplitABCLoc()); - splitBC.setDividerLocation(GUIP.getDisplaySplitBCLoc()); - splitA1.setDividerLocation(GUIP.getDisplaySplitA1Loc()); - splitB1.setDividerLocation(GUIP.getDisplaySplitB1Loc()); - splitC1.setDividerLocation(GUIP.getDisplaySplitC1Loc()); + splitABC.setDividerLocation(GUIP.getUnitDisplaySplitABCLoc()); + splitBC.setDividerLocation(GUIP.getUnitDisplaySplitBCLoc()); + splitA1.setDividerLocation(GUIP.getUnitDisplaySplitA1Loc()); + splitB1.setDividerLocation(GUIP.getUnitDisplaySplitB1Loc()); + splitC1.setDividerLocation(GUIP.getUnitDisplaySplitC1Loc()); butSwitchView.setPreferredSize(new Dimension(500,20)); @@ -197,29 +197,29 @@ public UnitDisplay(@Nullable ClientGUI clientgui, public void actionPerformed(ActionEvent e) { if (clientgui != null) { Container unitDisplayContainer = clientgui.unitDisplay.getRootPane().getParent(); - if (!(GUIP.getDisplayStartTabbed())) { + if (!(GUIP.getUnitDisplayStartTabbed())) { saveSplitterLoc(); - GUIP.setDisplayNontabbedPosX(unitDisplayContainer.getLocation().x); - GUIP.setDisplayNontabbedPosY(unitDisplayContainer.getLocation().y); - GUIP.setDisplayNonTabbedSizeWidth(unitDisplayContainer.getSize().width); - GUIP.setDisplayNonTabbedSizeHeight(unitDisplayContainer.getSize().height); - unitDisplayContainer.setLocation(GUIP.getDisplayPosX(), GUIP.getDisplayPosY()); - unitDisplayContainer.setSize(GUIP.getDisplaySizeWidth(), GUIP.getDisplaySizeHeight()); + GUIP.setUnitDisplayNontabbedPosX(unitDisplayContainer.getLocation().x); + GUIP.setUnitDisplayNontabbedPosY(unitDisplayContainer.getLocation().y); + GUIP.setUnitDisplayNonTabbedSizeWidth(unitDisplayContainer.getSize().width); + GUIP.setUnitDisplayNonTabbedSizeHeight(unitDisplayContainer.getSize().height); + unitDisplayContainer.setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY()); + unitDisplayContainer.setSize(GUIP.getUnitDisplaySizeWidth(), GUIP.getUnitDisplaySizeHeight()); setDisplayTabbed(); } else { - GUIP.setDisplayPosX(unitDisplayContainer.getLocation().x); - GUIP.setDisplayPosY(unitDisplayContainer.getLocation().y); - GUIP.setDisplaySizeWidth(unitDisplayContainer.getSize().width); - GUIP.setDisplaySizeHeight(unitDisplayContainer.getSize().height); - unitDisplayContainer.setLocation(GUIP.getDisplayNontabbedPosX(), GUIP.getDisplayNontabbedPosY()); - unitDisplayContainer.setSize(GUIP.getDisplayNonTabbedSizeWidth(), GUIP.getDisplayNonTabbedSizeHeight()); + GUIP.setUnitDisplayPosX(unitDisplayContainer.getLocation().x); + GUIP.setUnitDisplayPosY(unitDisplayContainer.getLocation().y); + GUIP.setUnitDisplaySizeWidth(unitDisplayContainer.getSize().width); + GUIP.setUnitDisplaySizeHeight(unitDisplayContainer.getSize().height); + unitDisplayContainer.setLocation(GUIP.getUnitDisplayNontabbedPosX(), GUIP.getUnitDisplayNontabbedPosY()); + unitDisplayContainer.setSize(GUIP.getUnitDisplayNonTabbedSizeWidth(), GUIP.getUnitDisplayNonTabbedSizeHeight()); setDisplayNonTabbed(); } } } }); - if (GUIP.getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { setDisplayTabbed(); } else { @@ -255,7 +255,7 @@ private void setDisplayTabbed() { displayP.revalidate(); displayP.repaint(); - GUIP.setDisplayStartTabbed(true); + GUIP.setUnitDisplayStartTabbed(true); } /** @@ -292,7 +292,7 @@ public void setDisplayNonTabbed() { displayP.revalidate(); displayP.repaint(); - GUIP.setDisplayStartTabbed(false); + GUIP.setUnitDisplayStartTabbed(false); } /** @@ -300,11 +300,11 @@ public void setDisplayNonTabbed() { * */ public void saveSplitterLoc() { - GUIP.setDisplaySplitABCLoc(splitABC.getDividerLocation()); - GUIP.setDisplaySplitBCLoc(splitBC.getDividerLocation()); - GUIP.setDisplaySplitA1Loc(splitA1.getDividerLocation()); - GUIP.setDisplaySplitB1Loc(splitB1.getDividerLocation()); - GUIP.setDisplaySplitC2Loc(splitC1.getDividerLocation()); + GUIP.setUnitDisplaySplitABCLoc(splitABC.getDividerLocation()); + GUIP.setUnitDisplaySplitBCLoc(splitBC.getDividerLocation()); + GUIP.setUnitDisplaySplitA1Loc(splitA1.getDividerLocation()); + GUIP.setUnitDisplaySplitB1Loc(splitB1.getDividerLocation()); + GUIP.setUnitDisplaySplitC2Loc(splitC1.getDividerLocation()); } /** @@ -384,7 +384,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIP.getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SUMMARY); } @@ -408,7 +408,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIP.getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.PILOT); } @@ -432,7 +432,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIP.getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.ARMOR); } @@ -456,7 +456,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIP.getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SYSTEMS); } @@ -480,7 +480,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIP.getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.WEAPONS); } @@ -504,7 +504,7 @@ public boolean shouldPerformAction() { @Override public void performAction() { - if (GUIP.getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.EXTRAS); } @@ -570,7 +570,7 @@ public Entity getCurrentEntity() { * Changes to the specified panel. */ public void showPanel(String s) { - if (GUIP.getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, s); } @@ -594,7 +594,7 @@ public void showPanel(String s) { * @param loc */ public void showSpecificSystem(int loc) { - if (GUIP.getDisplayStartTabbed()) { + if (GUIP.getUnitDisplayStartTabbed()) { ((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SYSTEMS); } From 5899fcda900716892ef6e34c265a756b094e1429 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 14 Dec 2022 15:50:08 -0500 Subject: [PATCH 19/47] show game board in all the game phases 19 --- .../megamek/client/ui/swing/ClientGUI.java | 50 ++++-- .../client/ui/swing/CommonMenuBar.java | 13 -- .../client/ui/swing/CommonSettingsDialog.java | 151 ++++++++++-------- .../client/ui/swing/GUIPreferences.java | 12 ++ .../client/ui/swing/boardview/BoardView.java | 2 +- .../ui/swing/unitDisplay/UnitDisplay.java | 13 +- 6 files changed, 136 insertions(+), 105 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 6732488f16e..59ae851e235 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -45,6 +45,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; @@ -78,6 +79,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"; @@ -251,7 +253,6 @@ public class ClientGUI extends JPanel implements BoardViewListener, private static final String MSG_NOGHOSTS = Messages.getString("ClientGUI.noGhosts"); 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_BOARDEDITORWAITDIALOGTITLE = Messages.getString("BoardEditor.waitDialog.title"); private static final String MSG_BOARDEDITORWAITDIALOGMSG = Messages.getString("BoardEditor.waitDialog.message"); private static final String MSG_BOARDEDITORSAVEBOARDAS = Messages.getString("BoardEditor.saveBoardAs"); @@ -861,6 +862,18 @@ public void actionPerformed(ActionEvent event) { case VIEW_ROUND_REPORT: 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; boardSave(); @@ -987,13 +1000,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); @@ -2090,13 +2103,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); @@ -2645,16 +2658,23 @@ private void adaptToGUIScale() { @Override public void preferenceChange(PreferenceChangeEvent e) { - if (e.getName().equals(GUIPreferences.MINI_MAP_ENABLED)) { - setMapVisible(GUIP.getMinimapEnabled()); - } else if (e.getName().equals(GUIPreferences.UNIT_DISPLAY_ENABLED)) { - setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); - } else if (e.getName().equals(GUIPreferences.MINI_REPORT_ENABLED)) { - setMiniReportVisible(GUIP.getMiniReportEnabled()); - } else if (e.getName().equals(GUIPreferences.PLAYER_lIST_ENABLED)) { - setPlayerListVisible(GUIP.getPlayerListEnabled()); - } else if (e.getName().equals(GUIPreferences.GUI_SCALE)) { - adaptToGUIScale(); + switch (e.getName()) { + case GUIPreferences.MINI_MAP_ENABLED: + setMapVisible(GUIP.getMinimapEnabled()); + break; + case GUIPreferences.UNIT_DISPLAY_ENABLED: + setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); + break; + case GUIPreferences.MINI_REPORT_ENABLED: + setMiniReportVisible(GUIP.getMiniReportEnabled()); + break; + case GUIPreferences.PLAYER_lIST_ENABLED: + setPlayerListVisible(GUIP.getPlayerListEnabled()); + break; + case GUIPreferences.GUI_SCALE: + adaptToGUIScale(); + break; + default: } } } diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 158d08cf3e2..752ca728733 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -349,19 +349,6 @@ 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.toggleMinimapEnabled(); - } else if (event.getActionCommand().equals(ClientGUI.VIEW_UNIT_DISPLAY)) { - GUIP.toggleUnitDisplay(); - } else if (event.getActionCommand().equals(VIEW_ROUND_REPORT)) { - GUIP.toggleRoundReportEnabled(); - } else if (event.getActionCommand().equals(VIEW_PLAYER_LIST)) { - GUIP.togglePlayerListEnabled(); - } else if (event.getActionCommand().equals(ClientGUI.VIEW_KEYBINDS_OVERLAY)) { - GUIP.toggleKeybindsOverlay(); - } 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()); } diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index 507852a953b..7e536b7c56b 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; @@ -244,6 +245,9 @@ 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" }; @@ -351,12 +355,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); @@ -568,8 +572,6 @@ private void addSpacer(List> comps, int height) { public void setVisible(boolean visible) { // Initialize the dialog when it's being shown if (visible) { - ClientPreferences cs = PreferenceManager.getClientPreferences(); - guiScale.setValue((int) (GUIP.getGUIScale() * 10)); autoEndFiring.setSelected(GUIP.getAutoEndFiring()); autoDeclareSearchlight.setSelected(GUIP.getAutoDeclareSearchlight()); @@ -593,35 +595,32 @@ public void setVisible(boolean visible) { // 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()); - showIPAddressesInChat.setSelected(cs.getShowIPAddressesInChat()); + stampFormat.setText(CP.getStampFormat()); + 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); @@ -647,7 +646,7 @@ 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); } } @@ -766,12 +765,12 @@ protected void cancelAction() { } 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()); @@ -788,8 +787,6 @@ protected void cancelAction() { /** Update the settings from this dialog's values, then close it. */ @Override protected void okAction() { - ClientPreferences cs = PreferenceManager.getClientPreferences(); - GUIP.setShowDamageLevel(showDamageLevel.isSelected()); GUIP.setShowDamageDecal(showDamageDecal.isSelected()); GUIP.setUnitLabelBorder(entityOwnerColor.isSelected()); @@ -807,35 +804,50 @@ protected void okAction() { GUIP.setShowWpsinTT(showWpsinTT.isSelected()); GUIP.setshowArmorMiniVisTT(showArmorMiniVisTT.isSelected()); GUIP.setshowPilotPortraitTT(showPilotPortraitTT.isSelected()); - GUIP.setTooltipDelay(Integer.parseInt(tooltipDelay.getText())); - GUIP.setTooltipDismissDelay(Integer.parseInt(tooltipDismissDelay.getText())); - GUIP.setTooltipDistSuppression(Integer.parseInt(tooltipDistSupression.getText())); + 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); - cs.setUnitStartChar(((String) unitStartChar.getSelectedItem()).charAt(0)); + 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); + } 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.setShowIPAddressesInChat(showIPAddressesInChat.isSelected()); - - cs.setDefaultAutoejectDisabled(defaultAutoejectDisabled.isSelected()); - cs.setUseAverageSkills(useAverageSkills.isSelected()); - cs.setGenerateNames(generateNames.isSelected()); - cs.setShowUnitId(showUnitId.isSelected()); + CP.setKeepGameLog(keepGameLog.isSelected()); + CP.setGameLogFilename(gameLogFilename.getText()); + CP.setStampFilenames(stampFilenames.isSelected()); + CP.setStampFormat(stampFormat.getText()); + CP.setShowIPAddressesInChat(showIPAddressesInChat.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()]); GUIP.setShowMapsheets(showMapsheets.isSelected()); GUIP.setAOHexShadows(aOHexShadows.isSelected()); @@ -870,11 +882,11 @@ protected void okAction() { 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(GUIP.getTooltipDelay()); @@ -898,13 +910,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; } } @@ -920,7 +931,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; } } @@ -936,7 +947,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; } } @@ -952,7 +963,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; } } @@ -968,7 +979,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; } } @@ -983,29 +994,29 @@ protected void okAction() { 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)) { diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 6dca072e9ee..51e79b6a9ad 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -701,6 +701,10 @@ public boolean getUnitDisplayEnabled() { return store.getBoolean(UNIT_DISPLAY_ENABLED); } + public boolean getCoordsEnabled() { + return store.getBoolean(SHOW_COORDS); + } + public boolean getGameSummaryBoardView() { return store.getBoolean(GAME_SUMMARY_BOARD_VIEW); } @@ -1289,6 +1293,14 @@ public void setUnitDisplayEnabled(boolean b) { store.setValue(UNIT_DISPLAY_ENABLED, b); } + 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) { store.setValue(GAME_SUMMARY_BOARD_VIEW, state); } diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 7cfab62fd7d..1ecf6080cbe 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -2623,7 +2623,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); } diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index de1861d2bb6..57e055d50b5 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -87,6 +87,7 @@ public class UnitDisplay extends JPanel { public static final int NON_TABBED_FIVE_INDEX = 5; private static final GUIPreferences GUIP = GUIPreferences.getInstance(); + private static final UnitDisplayOrderPreferences UDOP = UnitDisplayOrderPreferences.getInstance(); /** * Creates and lays out a new mech display. @@ -280,12 +281,12 @@ 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); From f7d670827970b4a21fdb0a828a6e09bd4d3b0385 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Thu, 22 Dec 2022 15:23:29 -0500 Subject: [PATCH 20/47] show game board in all the game phases --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 2 +- megamek/src/megamek/client/ui/swing/CommonMenuBar.java | 2 +- .../megamek/client/ui/swing/CommonSettingsDialog.java | 10 +++++----- .../src/megamek/client/ui/swing/MiniReportDisplay.java | 5 +++-- megamek/src/megamek/client/ui/swing/ReportDisplay.java | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 07ea54d5958..8ea655516cc 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -1554,7 +1554,7 @@ void setPlayerListVisible(boolean visible) { if (visible) { showPlayerList(); } else { - if (miniReportDisplay != null) { + if (playerListDialog != null) { playerListDialog.setVisible(visible); } } diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 90b3ed1b763..cb1fa7ba568 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -356,7 +356,7 @@ public void actionPerformed(ActionEvent event) { GUIP.setValue(GUIPreferences.GUI_SCALE, guiScale - 0.1); } } else if (event.getActionCommand().equals(ClientGUI.VIEW_MINI_MAP)) { - GUIP.setMinimapEnabled(!GUIP.getMinimapEnabled()); + GUIP.toggleMinimapEnabled(); } else if (event.getActionCommand().equals(ClientGUI.VIEW_UNIT_DISPLAY)) { GUIP.toggleUnitDisplay(); diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index 7069d97902a..d4e109e8435 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -619,9 +619,9 @@ public void setVisible(boolean visible) { 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(CP.defaultAutoejectDisabled()); useAverageSkills.setSelected(CP.useAverageSkills()); @@ -849,8 +849,8 @@ protected void okAction() { CP.setGameLogFilename(gameLogFilename.getText()); CP.setStampFilenames(stampFilenames.isSelected()); CP.setStampFormat(stampFormat.getText()); - cs.setReportKeywords(reportKeywordsTextPane.getText()); - cs.setShowIPAddressesInChat(showIPAddressesInChat.isSelected()); + CP.setReportKeywords(reportKeywordsTextPane.getText()); + CP.setShowIPAddressesInChat(showIPAddressesInChat.isSelected()); CP.setDefaultAutoejectDisabled(defaultAutoejectDisabled.isSelected()); CP.setUseAverageSkills(useAverageSkills.isSelected()); diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index 449dd220854..b4c5e2e2c23 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -54,6 +54,7 @@ public class MiniReportDisplay extends JDialog implements ActionListener, Hyperl 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"); @@ -127,7 +128,7 @@ public void windowClosing(WindowEvent e) { adaptToGUIScale(); GUIP.addPreferenceChangeListener(this); - PreferenceManager.getClientPreferences().addPreferenceChangeListener(this); + CP.addPreferenceChangeListener(this); butOkay.requestFocus(); } @@ -248,7 +249,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); } diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index e1468076be0..33cb73db069 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -179,9 +179,9 @@ public void actionPerformed(ActionEvent ev) { if (ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_REROLLINITIATIVE.getCmd())) { rerollInitiative(); } else if ((ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_REPORT.getCmd()))) { - clientgui.showRoundReport(); + GUIP.toggleRoundReportEnabled(); } else if ((ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_PLAYERLIST.getCmd()))) { - clientgui.showPlayerList(); + GUIP.togglePlayerListEnabled(); } } From adc12eeff4c6c04adfef4fc5ab8d86e6c6f376e1 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 23 Dec 2022 13:10:26 -0500 Subject: [PATCH 21/47] show game board in all the game phases 21 --- megamek/i18n/megamek/client/messages.properties | 1 + megamek/src/megamek/client/ui/swing/ClientGUI.java | 3 ++- megamek/src/megamek/client/ui/swing/ReportDisplay.java | 6 ++++-- .../src/megamek/client/ui/swing/boardview/BoardView.java | 8 +++++++- .../common/weapons/infantry/InfantryWeaponHandler.java | 5 ++--- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 1ea3af3aafd..09e426e9c6e 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -785,6 +785,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 diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index c4f1f248ba8..2bcbe3bf493 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -239,6 +239,7 @@ public class ClientGUI extends JPanel implements BoardViewListener, private static final String MSG_POINTBLANKSHOTMSG = Messages.getString("ClientGUI.PointBlankShot.Message"); private static final String MSG_POINTBLANKSHOTTITLE = Messages.getString("ClientGUI.PointBlankShot.Title"); private static final String MSG_CLIENTTITLESUFFIX = Messages.getString("ClientGUI.clientTitleSuffix"); + private static final String MSG_FAILEDTOLOADAUDIFILE = Messages.getString("ClientGUI.failedToLoadAudioFile"); private static final String MSG_CHATTERBOXMEGAMEK = Messages.getString("ChatterBox.Megamek"); private static final String MSG_GAMESAVEDIALOGMSG = Messages.getString("ClientGUI.gameSaveDialogMessage"); private static final String MSG_GAMESAVEFIRST = Messages.getString("ClientGUI.gameSaveFirst"); @@ -429,7 +430,7 @@ private void loadSoundClip() { } final File file = new File(GUIPreferences.getInstance().getSoundBingFilename()); if (!file.exists()) { - LogManager.getLogger().error("Failed to load audio file named " + GUIP.getSoundBingFilename()); + LogManager.getLogger().error(MSG_FAILEDTOLOADAUDIFILE + " " + GUIP.getSoundBingFilename()); return; } diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index 28f11ed0ca6..d6d9abdeb41 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -17,8 +17,6 @@ import megamek.client.ui.swing.widget.MegamekButton; import megamek.client.ui.swing.widget.SkinSpecification; import megamek.common.enums.GamePhase; -import megamek.common.Entity; -import megamek.common.Report; import megamek.common.event.GamePhaseChangeEvent; import java.awt.event.ActionEvent; @@ -135,6 +133,10 @@ public void clear() { */ @Override public void ready() { + if (!clientgui.getBoardView().isTileImagesLoaded()) { + return; + } + butDone.setEnabled(false); setReportEnabled(false); setPlayerListEnabled(false); diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 0923682715b..a165b5e0ea5 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -1029,7 +1029,14 @@ public synchronized void paintComponent(Graphics g) { 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 +1047,6 @@ public synchronized void paintComponent(Graphics g) { return; } - Rectangle viewRect = scrollpane.getVisibleRect(); if (bvBgShouldTile && (bvBgImage != null)) { Rectangle clipping = g.getClipBounds(); int x = 0; diff --git a/megamek/src/megamek/common/weapons/infantry/InfantryWeaponHandler.java b/megamek/src/megamek/common/weapons/infantry/InfantryWeaponHandler.java index 853984ca552..f629e4a244f 100644 --- a/megamek/src/megamek/common/weapons/infantry/InfantryWeaponHandler.java +++ b/megamek/src/megamek/common/weapons/infantry/InfantryWeaponHandler.java @@ -211,9 +211,8 @@ public static double calculateBaseDamage(Entity ae, Mounted weapon, WeaponType w protected void initHit(Entity entityTarget) { if ((entityTarget instanceof BattleArmor) && ae.isConventionalInfantry()) { // TacOps crits against BA do not happen for infantry weapon attacks - hit = ((BattleArmor) entityTarget).rollHitLocation(toHit.getHitTable(), - toHit.getSideTable(), waa.getAimedLocation(), - waa.getAimingMode(), toHit.getCover(), true); + hit = ((BattleArmor) entityTarget).rollHitLocation(toHit.getSideTable(), + waa.getAimedLocation(), waa.getAimingMode(), true); hit.setGeneralDamageType(generalDamageType); hit.setCapital(wtype.isCapital()); hit.setBoxCars(roll == 12); From b8d8806252580dcd5f158d4f8ef74b2e4e896d7d Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 23 Dec 2022 13:44:00 -0500 Subject: [PATCH 22/47] show game board in all the game phases 22 --- megamek/src/megamek/client/ui/swing/CommonMenuBar.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index daf20b838ff..0258d6b7aa1 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -355,15 +355,6 @@ 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.toggleMinimapEnabled(); - - } 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(); From 59cd52bf54a7dbba434a7e07f8e347bb669b9a72 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 23 Dec 2022 19:51:35 -0500 Subject: [PATCH 23/47] show game board in all the game phases 23 --- .../client/ui/dialogs/UnitDisplayDialog.java | 29 ++-- .../megamek/client/ui/swing/ClientGUI.java | 147 +++++++++++++----- .../client/ui/swing/GUIPreferences.java | 36 ++++- .../boardview/PlanetaryConditionsOverlay.java | 2 +- .../ui/swing/unitDisplay/UnitDisplay.java | 48 ++++-- 5 files changed, 192 insertions(+), 70 deletions(-) diff --git a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java index d84a1f7e403..b08d08784b9 100644 --- a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java +++ b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java @@ -22,6 +22,7 @@ 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; @@ -37,10 +38,22 @@ public class UnitDisplayDialog extends JDialog { //endregion Variable Declarations //region Constructors - public UnitDisplayDialog(final JFrame frame, final UnitDisplay unitDisplay, - final ClientGUI clientGUI) { + public UnitDisplayDialog(final JFrame frame, final ClientGUI clientGUI) { super(frame, Messages.getString("ClientGUI.MechDisplay"), false); - setUnitDisplay(unitDisplay); + + 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 @@ -53,16 +66,6 @@ public void windowClosing(WindowEvent evt) { } //endregion Constructors - //region Getters/Setters - public UnitDisplay getUnitDisplay() { - return unitDisplay; - } - - public void setUnitDisplay(final UnitDisplay unitDisplay) { - this.unitDisplay = unitDisplay; - } - //endregion Getters/Setters - /** * In addition to the default Dialog processKeyEvent, this method * dispatches a KeyEvent to the client gui. diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 2bcbe3bf493..e96199dc150 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -293,8 +293,15 @@ public class ClientGUI extends JPanel implements BoardViewListener, public ChatterBox2 cb2; private BoardView bv; private Component bvc; + private JPanel panTop; + private JSplitPane splitPaneA; + private JSplitPane splitPaneB; + private JPanel panA1; + private JPanel panB1; + private JPanel panB2; + public UnitDisplay unitDisplay; - private JDialog unitDisplayDialog; + private UnitDisplayDialog unitDisplayDialog; public JDialog minimapW; private MapMenu popup; private UnitOverview uo; @@ -413,7 +420,7 @@ public void setUnitDisplay(final UnitDisplay unitDisplay) { this.unitDisplay = unitDisplay; } - public JDialog getUnitDisplayDialog() { + public UnitDisplayDialog getUnitDisplayDialog() { return unitDisplayDialog; } @@ -428,7 +435,7 @@ private void loadSoundClip() { 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(MSG_FAILEDTOLOADAUDIFILE + " " + GUIP.getSoundBingFilename()); return; @@ -528,6 +535,27 @@ public void initialize() { bv.setPreferredSize(getSize()); bvc = bv.getComponent(); bvc.setName(CG_BOARDVIEW); + + panTop = new JPanel(new BorderLayout()); + panA1 = new JPanel(new BorderLayout()); + panB1 = new JPanel(new BorderLayout()); + panB2 = new JPanel(new BorderLayout()); + splitPaneA = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + splitPaneB = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + + splitPaneA.setDividerSize(10); + splitPaneB.setDividerSize(10); + splitPaneA.setResizeWeight(0.5); + splitPaneB.setResizeWeight(0.5); + + splitPaneA.setLeftComponent(panA1); + splitPaneA.setRightComponent(splitPaneB); + splitPaneB.setLeftComponent(panB1); + splitPaneB.setRightComponent(panB2); + + panB1.add(bvc); + panTop.add(splitPaneA); + bv.addBoardViewListener(this); client.setBoardView(bv); } catch (Exception ex) { @@ -587,34 +615,14 @@ public void windowClosing(WindowEvent e) { setUnitDisplay(new UnitDisplay(this, controller)); getUnitDisplay().addMechDisplayListener(bv); - setUnitDisplayDialog(new UnitDisplayDialog(getFrame(), getUnitDisplay(), this)); - - if (GUIP.getUnitDisplayStartTabbed()) { - getUnitDisplayDialog().setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY()); - getUnitDisplayDialog().setSize(GUIP.getUnitDisplaySizeWidth(), GUIP.getUnitDisplaySizeHeight()); - } - else { - getUnitDisplayDialog().setLocation(GUIP.getUnitDisplayNontabbedPosX(), GUIP.getUnitDisplayNontabbedPosY()); - getUnitDisplayDialog().setSize(GUIP.getUnitDisplayNonTabbedSizeWidth(), GUIP.getUnitDisplayNonTabbedSizeHeight()); - } - - UIUtil.updateWindowBounds(getUnitDisplayDialog()); - getUnitDisplayDialog().setResizable(true); - getUnitDisplayDialog().setFocusable(false); - getUnitDisplayDialog().setFocusableWindowState(false); - getUnitDisplayDialog().add(getUnitDisplay()); + setUnitDisplayDialog(new UnitDisplayDialog(getFrame(), this)); + getUnitDisplayDialog().setVisible(false); Ruler.color1 = GUIP.getRulerColor1(); Ruler.color2 = GUIP.getRulerColor2(); ruler = new Ruler(frame, client, bv); - ruler.setLocation( - GUIP.getRulerPosX(), - GUIP.getRulerPosY() - ); - ruler.setSize( - GUIP.getRulerSizeHeight(), - GUIP.getRulerSizeWidth() - ); + ruler.setLocation(GUIP.getRulerPosX(), GUIP.getRulerPosY()); + ruler.setSize(GUIP.getRulerSizeHeight(), GUIP.getRulerSizeWidth()); UIUtil.updateWindowBounds(ruler); minimapW = Minimap.createMinimap(frame, getBoardView(), getClient().getGame(), this); @@ -1061,6 +1069,14 @@ void saveSettings() { GUIP.setUnitDisplayNonTabbedSizeHeight(getUnitDisplayDialog().getSize().height); unitDisplay.saveSplitterLoc(); } + + if ((panA1.isVisible()) && (panA1.getComponents().length > 0)) { + GUIP.setSplitPaneALocation(splitPaneA.getDividerLocation()); + } + + if ((panB2.isVisible()) && (panB2.getComponents().length > 0)) { + GUIP.setSplitPaneBLocation(splitPaneB.getDividerLocation()); + } } // Ruler display @@ -1276,7 +1292,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); @@ -1287,7 +1303,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); @@ -1298,7 +1314,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); @@ -1310,7 +1326,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); @@ -1323,7 +1339,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); @@ -1334,7 +1350,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); @@ -1346,7 +1362,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); @@ -1358,7 +1374,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); @@ -1369,7 +1385,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); @@ -1380,7 +1396,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); @@ -1391,7 +1407,7 @@ 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); @@ -1419,7 +1435,7 @@ private JComponent initializePanel(GamePhase phase) { secondary = CG_REPORTDISPLAY; component.setName(secondary); if (!mainNames.containsValue(main)) { - panMain.add(bvc, main); + panMain.add(panTop, main); } currPhaseDisplay = (StatusBarPhaseDisplay) component; if (!secondaryNames.containsValue(secondary)) { @@ -1608,8 +1624,56 @@ public void setUnitDisplayVisible(boolean visible) { } if (getUnitDisplayDialog() != null) { - getUnitDisplayDialog().setVisible(visible); + setUnitDisplayLocation(visible); + } + } + + public void setUnitDisplayLocation(boolean visible) { + if ((panA1.isVisible()) && (panA1.getComponents().length > 0)) { + GUIP.setSplitPaneALocation(splitPaneA.getDividerLocation()); + } + + if ((panB2.isVisible()) && (panB2.getComponents().length > 0)) { + GUIP.setSplitPaneBLocation(splitPaneB.getDividerLocation()); + } + + switch (GUIP.getUnitDisplayLocaton()) { + case 0: + getUnitDisplayDialog().add(getUnitDisplay()); + getUnitDisplayDialog().setVisible(visible); + break; + case 1: + panA1.add(getUnitDisplay()); + getUnitDisplayDialog().setVisible(false); + panA1.setVisible(visible); + panA1.revalidate(); + splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); + break; + case 2: + panB2.add(getUnitDisplay()); + getUnitDisplayDialog().setVisible(false); + panB2.setVisible(visible); + panB2.revalidate(); + splitPaneB.setDividerLocation(GUIP.getSplitPaneBDividerLocaton()); + break; + } + + if (panA1.getComponents().length <= 0) { + panA1.setVisible(false); + splitPaneA.setDividerLocation(0.0); + } + + if (panB2.getComponents().length <= 0) { + panB2.setVisible(false); + splitPaneB.setDividerLocation(1.0); } + + getUnitDisplayDialog().revalidate(); + getUnitDisplayDialog().repaint(); + panA1.revalidate(); + panA1.repaint(); + panB2.revalidate(); + panB2.repaint(); } private boolean fillPopup(Coords coords) { @@ -2684,6 +2748,9 @@ public void preferenceChange(PreferenceChangeEvent e) { case GUIPreferences.GUI_SCALE: adaptToGUIScale(); break; + case GUIPreferences.UNIT_DISPLAY_LOCATION: + setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); + break; default: } } diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 13e10ef3fdb..55e3a127cc2 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -146,6 +146,9 @@ public class GUIPreferences extends PreferenceStoreProxy { 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 SPLIT_PANE_B_DIVIDER_LOCATION = "SplitPaneBDividerLocation"; 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"; @@ -400,7 +403,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); @@ -459,6 +462,9 @@ protected GUIPreferences() { store.setDefault(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE, MSG_HIDE); store.setDefault(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, MSG_SHOW); store.setDefault(UNIT_DISPLAY_ENABLED, true); + store.setDefault(UNIT_DISPLAY_LOCATION, 0); + store.setDefault(SPLIT_PANE_A_DIVIDER_LOCATION, 300); + store.setDefault(SPLIT_PANE_B_DIVIDER_LOCATION, 300); store.setDefault(GAME_SUMMARY_BOARD_VIEW, false); store.setDefault(ENTITY_OWNER_LABEL_COLOR, true); @@ -730,6 +736,18 @@ public boolean getUnitDisplayEnabled() { return store.getBoolean(UNIT_DISPLAY_ENABLED); } + public int getUnitDisplayLocaton() { + return store.getInt(UNIT_DISPLAY_LOCATION); + } + + public int getSplitPaneADividerLocaton() { + return store.getInt(SPLIT_PANE_A_DIVIDER_LOCATION); + } + + public int getSplitPaneBDividerLocaton() { + return store.getInt(SPLIT_PANE_B_DIVIDER_LOCATION); + } + public boolean getCoordsEnabled() { return store.getBoolean(SHOW_COORDS); } @@ -1322,6 +1340,22 @@ public void setUnitDisplayEnabled(boolean b) { store.setValue(UNIT_DISPLAY_ENABLED, b); } + public void toggleUnitDisplayLocation() { + store.setValue(UNIT_DISPLAY_LOCATION, ((getInt(UNIT_DISPLAY_LOCATION)+1)%3)); + } + + 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 setSplitPaneBLocation(int i) { + store.setValue(SPLIT_PANE_B_DIVIDER_LOCATION, i); + } + public void toggleCoords() { store.setValue(SHOW_COORDS, !getBoolean(SHOW_COORDS)); } 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/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index 57e055d50b5..2a7e360e738 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -16,6 +16,7 @@ import megamek.client.event.MechDisplayEvent; import megamek.client.event.MechDisplayListener; +import megamek.client.ui.dialogs.UnitDisplayDialog; import megamek.client.ui.swing.ClientGUI; import megamek.client.ui.swing.GUIPreferences; import megamek.client.ui.swing.UnitDisplayOrderPreferences; @@ -42,6 +43,7 @@ public class UnitDisplay extends JPanel { // 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; @@ -148,6 +150,7 @@ public UnitDisplay(@Nullable ClientGUI clientgui, splitB1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitC1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); butSwitchView = new JButton("switch view"); + butSwitchLocation = new JButton("switch location"); splitABC.setOneTouchExpandable(true); splitBC.setOneTouchExpandable(true); @@ -182,44 +185,59 @@ public UnitDisplay(@Nullable ClientGUI clientgui, splitB1.setDividerLocation(GUIP.getUnitDisplaySplitB1Loc()); splitC1.setDividerLocation(GUIP.getUnitDisplaySplitC1Loc()); - butSwitchView.setPreferredSize(new Dimension(500,20)); + butSwitchView.setPreferredSize(new Dimension(250,20)); + butSwitchLocation.setPreferredSize(new Dimension(250,20)); 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) { - Container unitDisplayContainer = clientgui.unitDisplay.getRootPane().getParent(); + UnitDisplayDialog unitDisplayDialog = clientgui.getUnitDisplayDialog(); if (!(GUIP.getUnitDisplayStartTabbed())) { saveSplitterLoc(); - GUIP.setUnitDisplayNontabbedPosX(unitDisplayContainer.getLocation().x); - GUIP.setUnitDisplayNontabbedPosY(unitDisplayContainer.getLocation().y); - GUIP.setUnitDisplayNonTabbedSizeWidth(unitDisplayContainer.getSize().width); - GUIP.setUnitDisplayNonTabbedSizeHeight(unitDisplayContainer.getSize().height); - unitDisplayContainer.setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY()); - unitDisplayContainer.setSize(GUIP.getUnitDisplaySizeWidth(), GUIP.getUnitDisplaySizeHeight()); + 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 { - GUIP.setUnitDisplayPosX(unitDisplayContainer.getLocation().x); - GUIP.setUnitDisplayPosY(unitDisplayContainer.getLocation().y); - GUIP.setUnitDisplaySizeWidth(unitDisplayContainer.getSize().width); - GUIP.setUnitDisplaySizeHeight(unitDisplayContainer.getSize().height); - unitDisplayContainer.setLocation(GUIP.getUnitDisplayNontabbedPosX(), GUIP.getUnitDisplayNontabbedPosY()); - unitDisplayContainer.setSize(GUIP.getUnitDisplayNonTabbedSizeWidth(), GUIP.getUnitDisplayNonTabbedSizeHeight()); + 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(); } } } }); + butSwitchLocation.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + GUIP.toggleUnitDisplayLocation(); + } + }); + if (GUIP.getUnitDisplayStartTabbed()) { setDisplayTabbed(); } From 5e216c2c5b19574cc134cb0c1e9946036ba090a1 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 24 Dec 2022 09:59:16 -0500 Subject: [PATCH 24/47] show game board in all the game phases 24 --- .../megamek/client/ui/swing/ClientGUI.java | 55 ++++++++++--------- .../ui/swing/unitDisplay/UnitDisplay.java | 11 ++++ 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index e96199dc150..efd6161f692 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -1070,13 +1070,7 @@ void saveSettings() { unitDisplay.saveSplitterLoc(); } - if ((panA1.isVisible()) && (panA1.getComponents().length > 0)) { - GUIP.setSplitPaneALocation(splitPaneA.getDividerLocation()); - } - - if ((panB2.isVisible()) && (panB2.getComponents().length > 0)) { - GUIP.setSplitPaneBLocation(splitPaneB.getDividerLocation()); - } + saveSplitPaneLocations(); } // Ruler display @@ -1628,7 +1622,7 @@ public void setUnitDisplayVisible(boolean visible) { } } - public void setUnitDisplayLocation(boolean visible) { + private void saveSplitPaneLocations() { if ((panA1.isVisible()) && (panA1.getComponents().length > 0)) { GUIP.setSplitPaneALocation(splitPaneA.getDividerLocation()); } @@ -1636,11 +1630,35 @@ public void setUnitDisplayLocation(boolean visible) { if ((panB2.isVisible()) && (panB2.getComponents().length > 0)) { GUIP.setSplitPaneBLocation(splitPaneB.getDividerLocation()); } + } + + private void hideEmptyPaneRefresh() { + if (panA1.getComponents().length <= 0) { + panA1.setVisible(false); + splitPaneA.setDividerLocation(0.0); + } + + if (panB2.getComponents().length <= 0) { + panB2.setVisible(false); + splitPaneB.setDividerLocation(1.0); + } + + getUnitDisplayDialog().revalidate(); + getUnitDisplayDialog().repaint(); + panA1.revalidate(); + panA1.repaint(); + panB2.revalidate(); + panB2.repaint(); + } + + public void setUnitDisplayLocation(boolean visible) { + saveSplitPaneLocations(); switch (GUIP.getUnitDisplayLocaton()) { case 0: getUnitDisplayDialog().add(getUnitDisplay()); getUnitDisplayDialog().setVisible(visible); + getUnitDisplay().setTitleVisible(false); break; case 1: panA1.add(getUnitDisplay()); @@ -1648,6 +1666,7 @@ public void setUnitDisplayLocation(boolean visible) { panA1.setVisible(visible); panA1.revalidate(); splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); + getUnitDisplay().setTitleVisible(true); break; case 2: panB2.add(getUnitDisplay()); @@ -1655,25 +1674,11 @@ public void setUnitDisplayLocation(boolean visible) { panB2.setVisible(visible); panB2.revalidate(); splitPaneB.setDividerLocation(GUIP.getSplitPaneBDividerLocaton()); + getUnitDisplay().setTitleVisible(true); break; } - if (panA1.getComponents().length <= 0) { - panA1.setVisible(false); - splitPaneA.setDividerLocation(0.0); - } - - if (panB2.getComponents().length <= 0) { - panB2.setVisible(false); - splitPaneB.setDividerLocation(1.0); - } - - getUnitDisplayDialog().revalidate(); - getUnitDisplayDialog().repaint(); - panA1.revalidate(); - panA1.repaint(); - panB2.revalidate(); - panB2.repaint(); + hideEmptyPaneRefresh(); } private boolean fillPopup(Coords coords) { @@ -2120,7 +2125,7 @@ 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 (getClient().getGame().getPhase() == GamePhase.INITIATIVE_REPORT) { + if (getClient().getGame().getPhase().isInitiativeReport()) { miniReportDisplayAddReportPages(); reportDisplayResetDone(); // Check if the player deserves an active reroll button diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index 2a7e360e738..f3ad2534dd8 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -65,6 +65,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"; @@ -108,6 +109,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); @@ -125,6 +128,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); @@ -380,6 +386,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 * @@ -566,6 +576,7 @@ public void displayEntity(Entity en) { if (clientgui != null) { clientgui.getUnitDisplayDialog().setTitle(enName); + labTitle.setText(enName); } currentlyDisplaying = en; From 859475c191d4733e86e7313e7e8f6e3fce44603a Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 24 Dec 2022 13:00:02 -0500 Subject: [PATCH 25/47] show game board in all the game phases 25 --- .../client/ui/dialogs/UnitDisplayDialog.java | 30 +++- .../megamek/client/ui/swing/ClientGUI.java | 141 ++++++++++++++---- .../client/ui/swing/GUIPreferences.java | 14 ++ .../client/ui/swing/MiniReportDisplay.java | 98 ++++-------- 4 files changed, 180 insertions(+), 103 deletions(-) diff --git a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java index b08d08784b9..a0eca07fdce 100644 --- a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java +++ b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java @@ -31,15 +31,14 @@ 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 ClientGUI clientGUI) { - super(frame, Messages.getString("ClientGUI.MechDisplay"), false); + super(frame, MSG_TITLE, false); if (GUIP.getUnitDisplayStartTabbed()) { this.setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY()); @@ -66,6 +65,31 @@ public void windowClosing(WindowEvent evt) { } //endregion Constructors + private void savePref() { + if ((this.getSize().width * this.getSize().height) > 0) { + if (GUIP.getUnitDisplayStartTabbed()) { + GUIP.setUnitDisplayPosX(this.getLocation().x); + GUIP.setUnitDisplayPosY(this.getLocation().y); + GUIP.setUnitDisplaySizeWidth(this.getSize().width); + GUIP.setUnitDisplaySizeHeight(this.getSize().height); + } else { + GUIP.setUnitDisplayNontabbedPosX(this.getLocation().x); + GUIP.setUnitDisplayNontabbedPosY(this.getLocation().y); + GUIP.setUnitDisplayNonTabbedSizeWidth(this.getSize().width); + GUIP.setUnitDisplayNonTabbedSizeHeight(this.getSize().height); + clientGUI.getUnitDisplay().saveSplitterLoc(); + } + } + } + + @Override + protected void processWindowEvent(WindowEvent e) { + super.processWindowEvent(e); + if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { + savePref(); + } + } + /** * In addition to the default Dialog processKeyEvent, this method * dispatches a KeyEvent to the client gui. diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index efd6161f692..f5dd7c14dca 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; @@ -337,6 +338,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. @@ -428,6 +430,22 @@ 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 void setMiniReportDisplayDialog(final MiniReportDisplayDialog miniReportDisplayDialog) { + this.miniReportDisplayDialog = miniReportDisplayDialog; + } + /** * Try to load the "bing" sound clip. */ @@ -537,9 +555,11 @@ public void initialize() { bvc.setName(CG_BOARDVIEW); panTop = new JPanel(new BorderLayout()); - panA1 = new JPanel(new BorderLayout()); + panA1 = new JPanel(); + panA1.setLayout(new BoxLayout(panA1, BoxLayout.Y_AXIS)); panB1 = new JPanel(new BorderLayout()); - panB2 = new JPanel(new BorderLayout()); + panB2 = new JPanel(); + panB2.setLayout(new BoxLayout(panB2, BoxLayout.Y_AXIS)); splitPaneA = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPaneB = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); @@ -553,8 +573,8 @@ public void initialize() { splitPaneB.setLeftComponent(panB1); splitPaneB.setRightComponent(panB2); - panB1.add(bvc); - panTop.add(splitPaneA); + panB1.add(bvc, BorderLayout.CENTER); + panTop.add(splitPaneA, BorderLayout.CENTER); bv.addBoardViewListener(this); client.setBoardView(bv); @@ -614,10 +634,13 @@ public void windowClosing(WindowEvent e) { setUnitDisplay(new UnitDisplay(this, controller)); getUnitDisplay().addMechDisplayListener(bv); - setUnitDisplayDialog(new UnitDisplayDialog(getFrame(), this)); getUnitDisplayDialog().setVisible(false); + setMiniReportDisplay(new MiniReportDisplay(this)); + setMiniReportDisplayDialog(new MiniReportDisplayDialog(getFrame(), this)); + getMiniReportDisplayDialog().setVisible(false); + Ruler.color1 = GUIP.getRulerColor1(); Ruler.color2 = GUIP.getRulerColor2(); ruler = new Ruler(frame, client, bv); @@ -735,18 +758,6 @@ public void showPlayerList() { playerListDialog.setVisible(true); } - /** - * Called when the user selects the "View->Round Report" menu item. - */ - public void showRoundReport() { - ignoreHotKeys = true; - if (miniReportDisplay == null) { - miniReportDisplay = new MiniReportDisplay(frame, this); - } - miniReportDisplay.setVisible(true); - ignoreHotKeys = false; - } - public void miniReportDisplayAddReportPages() { ignoreHotKeys = true; if (miniReportDisplay != null) { @@ -1559,12 +1570,8 @@ void setMapVisible(boolean visible) { } void setMiniReportVisible(boolean visible) { - if (visible) { - showRoundReport(); - } else { - if (miniReportDisplay != null) { - miniReportDisplay.setVisible(visible); - } + if (getMiniReportDisplayDialog() != null) { + setMiniReportLocation(visible); } } @@ -1632,17 +1639,41 @@ private void saveSplitPaneLocations() { } } - private void hideEmptyPaneRefresh() { - if (panA1.getComponents().length <= 0) { + private void hideEmptyPannels() { + Boolean b = false; + + for (Component comp : panA1.getComponents()) { + if (comp.isVisible()) { + b = true; + break; + } + } + + if (!b) { panA1.setVisible(false); splitPaneA.setDividerLocation(0.0); + } else { + panA1.setVisible(true); + } + + b = false; + + for (Component comp : panB2.getComponents()) { + if (comp.isVisible()) { + b = true; + break; + } } - if (panB2.getComponents().length <= 0) { + if (!b) { panB2.setVisible(false); splitPaneB.setDividerLocation(1.0); + } else { + panB2.setVisible(true); } + } + private void revalidatePanels() { getUnitDisplayDialog().revalidate(); getUnitDisplayDialog().repaint(); panA1.revalidate(); @@ -1656,29 +1687,70 @@ public void setUnitDisplayLocation(boolean visible) { switch (GUIP.getUnitDisplayLocaton()) { case 0: - getUnitDisplayDialog().add(getUnitDisplay()); + getUnitDisplayDialog().add(getUnitDisplay(), BorderLayout.CENTER); getUnitDisplayDialog().setVisible(visible); + getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(false); + hideEmptyPannels(); break; case 1: panA1.add(getUnitDisplay()); getUnitDisplayDialog().setVisible(false); - panA1.setVisible(visible); - panA1.revalidate(); - splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); + getUnitDisplay().setMinimumSize(new Dimension(0, (int)(getHeight() * 0.6))); + getUnitDisplay().setPreferredSize(new Dimension(0, (int)(getHeight() * 0.6))); + getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(true); + hideEmptyPannels(); + splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); break; case 2: panB2.add(getUnitDisplay()); getUnitDisplayDialog().setVisible(false); - panB2.setVisible(visible); + getUnitDisplay().setMinimumSize(new Dimension(0, (int)(getHeight() * 0.6))); + getUnitDisplay().setPreferredSize(new Dimension(0, (int)(getHeight() * 0.6))); + getUnitDisplay().setVisible(visible); + getUnitDisplay().setTitleVisible(true); + hideEmptyPannels(); + splitPaneB.setDividerLocation(GUIP.getSplitPaneBDividerLocaton()); + break; + } + + revalidatePanels(); + } + + public void setMiniReportLocation(boolean visible) { + saveSplitPaneLocations(); + + switch (GUIP.getMiniReportLocaton()) { + case 0: + getMiniReportDisplayDialog().add(getMiniReportDisplay(), BorderLayout.CENTER); + getMiniReportDisplayDialog().setVisible(visible); + getMiniReportDisplay().setVisible(visible); + hideEmptyPannels(); + break; + case 1: + panA1.add(getMiniReportDisplay()); + getMiniReportDisplayDialog().setVisible(false); + panA1.revalidate(); + getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(getHeight() * 0.3))); + getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(getHeight() * 0.3))); + getMiniReportDisplay().setVisible(visible); + hideEmptyPannels(); + splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); + break; + case 2: + panB2.add(getMiniReportDisplay()); + getUnitDisplayDialog().setVisible(false); panB2.revalidate(); + getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(getHeight() * 0.3))); + getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(getHeight() * 0.3))); + getMiniReportDisplay().setVisible(visible); + hideEmptyPannels(); splitPaneB.setDividerLocation(GUIP.getSplitPaneBDividerLocaton()); - getUnitDisplay().setTitleVisible(true); break; } - hideEmptyPaneRefresh(); + revalidatePanels(); } private boolean fillPopup(Coords coords) { @@ -2756,6 +2828,9 @@ public void preferenceChange(PreferenceChangeEvent e) { case GUIPreferences.UNIT_DISPLAY_LOCATION: setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); break; + case GUIPreferences.MINI_REPORT_LOCATION: + setMiniReportVisible(GUIP.getMiniReportEnabled()); + break; default: } } diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 55e3a127cc2..eaa81a63f86 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -199,6 +199,7 @@ public class GUIPreferences extends PreferenceStoreProxy { 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"; @@ -518,6 +519,7 @@ protected GUIPreferences() { store.setDefault(MINI_REPORT_ENABLED, true); store.setDefault(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE, MSG_SHOW); store.setDefault(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE, MSG_HIDE); + store.setDefault(MINI_REPORT_LOCATION, 0); store.setDefault(PLAYER_lIST_ENABLED, true); store.setDefault(PLAYER_lIST_POS_X, 200); @@ -960,6 +962,10 @@ public String getMiniReportAutoDisplayNonReportPhase() { return store.getString(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE); } + public int getMiniReportLocaton() { + return store.getInt(MINI_REPORT_LOCATION); + } + public boolean getPlayerListEnabled() { return store.getBoolean(PLAYER_lIST_ENABLED); } @@ -1572,6 +1578,14 @@ public void setMiniReportAutoDisplayNonReportPhase(String s) { store.setValue(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE, s); } + public void toggleMiniReportLocation() { + store.setValue(MINI_REPORT_LOCATION, ((getInt(MINI_REPORT_LOCATION)+1)%3)); + } + + public void setMiniReportLocation(int i) { + store.setValue(MINI_REPORT_LOCATION, i); + } + public void setPlayerListEnabled(boolean b) { store.setValue(PLAYER_lIST_ENABLED, b); } diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index b4c5e2e2c23..3f19dcc1566 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; @@ -56,7 +56,6 @@ public class MiniReportDisplay extends JDialog implements ActionListener, Hyperl 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"); private static final String MSG_PHASE = Messages.getString("MiniReportDisplay.Phase"); private static final String MSG_DAMAGE = Messages.getString("MiniReportDisplay.Damage"); @@ -67,9 +66,7 @@ public class MiniReportDisplay extends JDialog implements ActionListener, Hyperl 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; } @@ -78,8 +75,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("switch location"); + butSwitchLocation.addActionListener(this); butPlayerSearchUp = new JButton(MSG_ARROWUP); butPlayerSearchUp.addActionListener(this); butPlayerSearchDown = new JButton(MSG_ARROWDOWN); @@ -96,41 +93,33 @@ 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(GUIP.getMiniReportSizeWidth(), GUIP.getMiniReportSizeHeight()); - doLayout(); - setLocation(GUIP.getMiniReportPosX(), GUIP.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(); + addReportPages(); + panelMain.add(tabs, BorderLayout.CENTER); + panelMain.add(sp, BorderLayout.SOUTH); + panelMain.setMinimumSize(new Dimension(0, 0)); + add(panelMain, BorderLayout.CENTER); + + doLayout(); adaptToGUIScale(); GUIP.addPreferenceChangeListener(this); CP.addPreferenceChangeListener(this); - - butOkay.requestFocus(); } private void searchTextPane(String searchPattern, Boolean searchDown) { @@ -273,10 +262,8 @@ public void setVisible(boolean visible) { @Override public void actionPerformed(ActionEvent ae) { - if (ae.getSource().equals(butOkay)) { - savePref(); - setVisible(false); - GUIP.setMiniReportEnabled(false); + if (ae.getSource().equals(butSwitchLocation)) { + GUIP.toggleMiniReportLocation(); } else if (ae.getSource().equals(butPlayerSearchDown)) { String searchPattern = comboPlayer.getSelectedItem().toString().trim(); searchTextPane(searchPattern, true); @@ -298,30 +285,6 @@ 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() { - GUIP.setMiniReportSizeWidth(getSize().width); - GUIP.setMiniReportSizeHeight(getSize().height); - GUIP.setMiniReportPosX(getLocation().x); - GUIP.setMiniReportPosY(getLocation().y); - } - public void addReportPages() { int numRounds = currentClient.getGame().getRoundCount(); tabs.removeAll(); @@ -357,6 +320,7 @@ public void addReportPages() { tabs.add(MSG_PHASE, sp); tabs.setSelectedIndex(tabs.getTabCount() - 1); + tabs.setMinimumSize(new Dimension(0, 0)); } private JComponent activePane() { @@ -400,7 +364,7 @@ public void hyperlinkUpdate(HyperlinkEvent evt) { public void gamePhaseChange(GamePhaseChangeEvent e) { switch (e.getOldPhase()) { case VICTORY: - savePref(); + currentClientgui.getMiniReportDisplayDialog().savePref(); setVisible(false); break; default: @@ -414,7 +378,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); From 47a9d3491f2193ebfd3c09f020b879372d4ca439 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 24 Dec 2022 13:00:55 -0500 Subject: [PATCH 26/47] show game board in all the game phases 26 --- .../ui/dialogs/MiniReportDisplayDialog.java | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java 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..0ea6c053346 --- /dev/null +++ b/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java @@ -0,0 +1,92 @@ +/* + * 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, MSG_TITLE, false); + + 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 + + public void savePref() { + GUIP.setMiniReportSizeWidth(getSize().width); + GUIP.setMiniReportSizeHeight(getSize().height); + GUIP.setMiniReportPosX(getLocation().x); + GUIP.setMiniReportPosY(getLocation().y); + } + + @Override + protected void processWindowEvent(WindowEvent e) { + super.processWindowEvent(e); + if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { + savePref(); + } + } + + /** + * 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); + } + } +} From b8825307be248fa1ec6c2f57fe62ab22e9ea1991 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 24 Dec 2022 13:43:50 -0500 Subject: [PATCH 27/47] show game board in all the game phases 27 --- .../megamek/client/ui/swing/ClientGUI.java | 16 ++++++------ .../ui/swing/unitDisplay/UnitDisplay.java | 25 ++++++++++++++++--- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index f5dd7c14dca..653ed8e8f63 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -1696,8 +1696,8 @@ public void setUnitDisplayLocation(boolean visible) { case 1: panA1.add(getUnitDisplay()); getUnitDisplayDialog().setVisible(false); - getUnitDisplay().setMinimumSize(new Dimension(0, (int)(getHeight() * 0.6))); - getUnitDisplay().setPreferredSize(new Dimension(0, (int)(getHeight() * 0.6))); + getUnitDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); + getUnitDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(true); hideEmptyPannels(); @@ -1706,8 +1706,8 @@ public void setUnitDisplayLocation(boolean visible) { case 2: panB2.add(getUnitDisplay()); getUnitDisplayDialog().setVisible(false); - getUnitDisplay().setMinimumSize(new Dimension(0, (int)(getHeight() * 0.6))); - getUnitDisplay().setPreferredSize(new Dimension(0, (int)(getHeight() * 0.6))); + getUnitDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); + getUnitDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(true); hideEmptyPannels(); @@ -1732,8 +1732,8 @@ public void setMiniReportLocation(boolean visible) { panA1.add(getMiniReportDisplay()); getMiniReportDisplayDialog().setVisible(false); panA1.revalidate(); - getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(getHeight() * 0.3))); - getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(getHeight() * 0.3))); + getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); + getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); getMiniReportDisplay().setVisible(visible); hideEmptyPannels(); splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); @@ -1742,8 +1742,8 @@ public void setMiniReportLocation(boolean visible) { panB2.add(getMiniReportDisplay()); getUnitDisplayDialog().setVisible(false); panB2.revalidate(); - getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(getHeight() * 0.3))); - getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(getHeight() * 0.3))); + getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); + getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); getMiniReportDisplay().setVisible(visible); hideEmptyPannels(); splitPaneB.setDividerLocation(GUIP.getSplitPaneBDividerLocaton()); diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index f3ad2534dd8..f075d55e686 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -23,9 +23,14 @@ 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.Report; import megamek.common.annotations.Nullable; +import megamek.common.preference.ClientPreferences; +import megamek.common.preference.IPreferenceChangeListener; +import megamek.common.preference.PreferenceChangeEvent; import org.apache.logging.log4j.LogManager; import javax.swing.*; @@ -39,7 +44,7 @@ * 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; @@ -191,9 +196,6 @@ public UnitDisplay(@Nullable ClientGUI clientgui, splitB1.setDividerLocation(GUIP.getUnitDisplaySplitB1Loc()); splitC1.setDividerLocation(GUIP.getUnitDisplaySplitC1Loc()); - butSwitchView.setPreferredSize(new Dimension(250,20)); - butSwitchLocation.setPreferredSize(new Dimension(250,20)); - c.fill = GridBagConstraints.BOTH; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1.0; @@ -250,6 +252,9 @@ public void actionPerformed(ActionEvent e) { else { setDisplayNonTabbed(); } + + adaptToGUIScale(); + GUIP.addPreferenceChangeListener(this); } /** @@ -669,4 +674,16 @@ void processMechDisplayEvent(MechDisplayEvent event) { public ClientGUI getClientGUI() { return clientgui; } + + 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(); + } + } } \ No newline at end of file From 4f6339aa3604b84d13e18ff10064fae5e5af0156 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 25 Dec 2022 16:27:43 -0500 Subject: [PATCH 28/47] show game board in all the game phases 28 --- .../i18n/megamek/client/messages.properties | 4 ++ .../megamek/client/ui/swing/ClientGUI.java | 30 ++++---- .../client/ui/swing/CommonMenuBar.java | 7 +- .../client/ui/swing/MiniReportDisplay.java | 4 +- .../client/ui/swing/PlayerListDialog.java | 70 +++++++++++++------ .../client/ui/swing/lobby/ChatLounge.java | 3 +- .../ui/swing/unitDisplay/UnitDisplay.java | 11 +-- .../src/megamek/common/enums/GamePhase.java | 2 + megamek/src/megamek/server/GameManager.java | 2 +- 9 files changed, 83 insertions(+), 50 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 09e426e9c6e..1cbe5e12df1 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -1976,6 +1976,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? @@ -3104,6 +3105,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/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 653ed8e8f63..56fba845ab1 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -71,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; @@ -263,7 +264,7 @@ public class ClientGUI extends JPanel implements BoardViewListener, private static final String MSG_CFRDOMINOTITLE = Messages.getString("CFRDomino.Title"); private static final String MSG_CFRDOMINOMSG = Messages.getString("CFRDomino.Message"); private static final String MSG_CFRDOMINOFORWARD = Messages.getString("CFRDomino.Forward"); - private static final String MSG_CFRDOMINOFBACKWARD = Messages.getFormattedString("CFRDomino.Backward"); + private static final String MSG_CFRDOMINOFBACKWARD = Messages.getString("CFRDomino.Backward"); private static final String MSG_CFRDOMINONOACTION = Messages.getString("CFRDomino.NoAction"); private static final String MSG_CFRAMASSIGNTITLE = Messages.getString("CFRAMSAssign.Title"); private static final String MSG_CFRAMASSIGNMSG = Messages.getString("CFRAMSAssign.Message"); @@ -753,7 +754,7 @@ public void customizePlayer() { */ public void showPlayerList() { if (playerListDialog == null) { - playerListDialog = new PlayerListDialog(frame, client); + playerListDialog = new PlayerListDialog(frame, client, false); } playerListDialog.setVisible(true); } @@ -856,8 +857,7 @@ public void actionPerformed(ActionEvent event) { break; case FILE_UNITS_REINFORCE: ignoreHotKeys = true; - PlayerListDialog playerListDialog = new PlayerListDialog(frame, client); - playerListDialog.setModal(true); + PlayerListDialog playerListDialog = new PlayerListDialog(frame, client, true); playerListDialog.setVisible(true); loadListFile(playerListDialog.getSelected(), true); ignoreHotKeys = false; @@ -2313,7 +2313,7 @@ public void gameClientFeedbackRequest(GameCFREvent evt) { 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; @@ -2321,8 +2321,8 @@ 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; @@ -2331,7 +2331,7 @@ 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; @@ -2339,8 +2339,7 @@ public void gameClientFeedbackRequest(GameCFREvent evt) { } 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; @@ -2371,8 +2370,8 @@ 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); @@ -2404,8 +2403,8 @@ 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); @@ -2435,8 +2434,7 @@ 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, diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 0258d6b7aa1..9a975a3b78b 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -401,6 +401,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); @@ -433,8 +434,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); @@ -460,7 +461,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); } diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index 3f19dcc1566..94f9ad2260c 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -62,7 +62,7 @@ public class MiniReportDisplay extends JPanel implements ActionListener, Hyperli 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; @@ -75,7 +75,7 @@ public MiniReportDisplay(ClientGUI clientgui) { currentClient = clientgui.getClient(); currentClient.getGame().addGameListener(gameListener); - butSwitchLocation = new JButton("switch location"); + butSwitchLocation = new JButton(MSG_SWITCHLOCATION); butSwitchLocation.addActionListener(this); butPlayerSearchUp = new JButton(MSG_ARROWUP); butPlayerSearchUp.addActionListener(this); diff --git a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java index cc3980d96db..016b7524826 100644 --- a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java +++ b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java @@ -31,6 +31,7 @@ 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 ActionListener, IPreferenceChangeListener { @@ -40,14 +41,29 @@ public class PlayerListDialog extends JDialog implements ActionListener, IPrefer private Client client; private JButton butOkay; - - private static final String MSG_OKAY= Messages.getString("Okay"); + private boolean model; + + 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) { - super(parent, Messages.getString("PlayerListDialog.title"), false); + public PlayerListDialog(JFrame parent, Client client, boolean model) { + super(parent, MSG_TITLE, false); this.client = client; + this.model = model; client.getGame().addGameListener(gameListener); @@ -76,8 +92,15 @@ public void windowClosing(WindowEvent e) { pack(); setResizable(false); - setLocation(GUIP.getPlayerListPosX(), - GUIP.getPlayerListPosY()); + + if (model) { + 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, @@ -101,46 +124,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()); @@ -165,7 +188,9 @@ public void actionPerformed(ActionEvent ae) { if (ae.getSource().equals(butOkay)) { savePref(); setVisible(false); - GUIP.setPlayerListEnabled(false); + if (!model) { + GUIP.setPlayerListEnabled(false); + } } } @@ -175,7 +200,6 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { switch (e.getOldPhase()) { case VICTORY: savePref(); - setVisible(false); break; default: break; @@ -191,8 +215,10 @@ protected void processWindowEvent(WindowEvent e) { } } private void savePref() { - GUIP.setPlayerListPosX(getLocation().x); - GUIP.setPlayerListPosY(getLocation().y); + if (!model) { + GUIP.setPlayerListPosX(getLocation().x); + GUIP.setPlayerListPosY(getLocation().y); + } } private void adaptToGUIScale() { diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index d488719e034..cd484bf34cf 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.*; @@ -2077,7 +2078,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; } diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index f075d55e686..08a2d4a7467 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -16,6 +16,7 @@ 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; @@ -26,9 +27,7 @@ import megamek.client.ui.swing.util.UIUtil; import megamek.client.ui.swing.widget.MechPanelTabStrip; import megamek.common.Entity; -import megamek.common.Report; import megamek.common.annotations.Nullable; -import megamek.common.preference.ClientPreferences; import megamek.common.preference.IPreferenceChangeListener; import megamek.common.preference.PreferenceChangeEvent; import org.apache.logging.log4j.LogManager; @@ -94,6 +93,9 @@ public class UnitDisplay extends JPanel implements IPreferenceChangeListener { 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(); @@ -160,8 +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"); - butSwitchLocation = new JButton("switch location"); + butSwitchView = new JButton(MSG_SWITCHVIEW); + butSwitchLocation = new JButton(MSG_SWITCHLOCATION); splitABC.setOneTouchExpandable(true); splitBC.setOneTouchExpandable(true); @@ -262,7 +264,6 @@ public void actionPerformed(ActionEvent e) { * */ private void setDisplayTabbed() { - tabStrip.setVisible(true); displayP.removeAll(); diff --git a/megamek/src/megamek/common/enums/GamePhase.java b/megamek/src/megamek/common/enums/GamePhase.java index 5bbdffafebc..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; @@ -209,6 +210,7 @@ public boolean isOnMap() { 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 9d23927ad37..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; } From b92c7f722d01a4b8c36295d1b4a32e634f971c35 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 25 Dec 2022 17:22:13 -0500 Subject: [PATCH 29/47] show game board in all the game phases 29 --- .../i18n/megamek/client/messages.properties | 1 + .../client/ui/swing/CommonMenuBar.java | 35 +++-- .../client/ui/swing/DeploymentDisplay.java | 6 +- .../client/ui/swing/FiringDisplay.java | 20 +-- .../client/ui/swing/MovementDisplay.java | 83 +++++------ .../client/ui/swing/PhysicalDisplay.java | 24 +-- .../client/ui/swing/boardview/BoardView.java | 138 +++++++++--------- .../client/ui/swing/lobby/ChatLounge.java | 5 +- 8 files changed, 161 insertions(+), 151 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 1cbe5e12df1..404a267376c 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -708,6 +708,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: diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 9a975a3b78b..c607286f98e 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; @@ -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,7 +183,7 @@ 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); @@ -204,7 +217,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); @@ -216,9 +229,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); @@ -231,7 +244,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); @@ -239,7 +252,7 @@ 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); @@ -278,7 +291,7 @@ public CommonMenuBar() { 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()); @@ -289,15 +302,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); diff --git a/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java b/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java index 10bc41d9dbf..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); @@ -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 4496cdf1bb6..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; } @@ -1119,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()) { @@ -1134,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) { @@ -1150,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()) { @@ -1509,7 +1510,7 @@ void fire() { } // declare searchlight, if possible - if (GUIPreferences.getInstance().getAutoDeclareSearchlight() && ce().isUsingSearchlight()) { + if (GUIP.getAutoDeclareSearchlight() && ce().isUsingSearchlight()) { doSearchlight(); } @@ -1609,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/MovementDisplay.java b/megamek/src/megamek/client/ui/swing/MovementDisplay.java index 6ee70922ed9..fbf199aa6a6 100644 --- a/megamek/src/megamek/client/ui/swing/MovementDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MovementDisplay.java @@ -186,6 +186,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; @@ -527,19 +529,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(); @@ -700,7 +699,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(); @@ -1063,7 +1062,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) { @@ -1079,8 +1078,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); @@ -1191,21 +1189,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"), @@ -1215,15 +1212,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()), @@ -1232,7 +1228,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; @@ -1241,12 +1237,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); @@ -1254,14 +1250,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") + @@ -1270,7 +1266,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; @@ -1278,8 +1274,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", @@ -1289,7 +1284,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; @@ -1298,7 +1293,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, @@ -1307,7 +1302,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; @@ -1332,7 +1327,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; @@ -1356,7 +1351,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; @@ -1405,8 +1400,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"), @@ -1416,7 +1410,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; @@ -1450,8 +1444,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"), @@ -1461,7 +1454,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; @@ -3430,8 +3423,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 @@ -3453,7 +3445,7 @@ private TreeMap> getLaunchedUnits() { nag.setVisible(true); doIt = nag.getAnswer(); if (!nag.getShowAgain()) { - GUIPreferences.getInstance().setNagForLaunchDoors(false); + GUIP.setNagForLaunchDoors(false); } } else { doIt = true; @@ -4157,8 +4149,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; } @@ -4314,7 +4305,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); @@ -4329,7 +4320,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())) { @@ -4386,8 +4377,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())) { @@ -4708,8 +4698,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 bf72b02128d..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 */ @@ -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/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index a165b5e0ea5..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,13 +1024,11 @@ 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); } @@ -1106,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); } @@ -1221,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; @@ -1402,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; } @@ -1542,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); @@ -1897,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 @@ -2156,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); } @@ -2170,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); } @@ -2294,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); @@ -2314,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); @@ -2348,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); @@ -2497,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); @@ -2537,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); @@ -2606,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) { @@ -2617,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); } @@ -2640,7 +2642,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) { } // write hex coordinate unless deactivated or scale factor too small - if (guip.getCoordsEnabled() && (scale >= 0.5)) { + if (GUIP.getCoordsEnabled() && (scale >= 0.5)) { drawCenteredString(c.getBoardNum(), 0, (int) (12 * scale), font_hexnum, g); } @@ -2664,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); @@ -2701,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); } @@ -2745,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); @@ -2774,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++) { @@ -2822,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) { @@ -2870,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; } @@ -3031,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; @@ -3586,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); @@ -3758,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(); @@ -3857,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; } } @@ -4348,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; @@ -4493,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) { @@ -4623,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); } @@ -4896,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(); @@ -4957,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(); @@ -4978,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) @@ -5035,7 +5035,7 @@ public void gameBoardNew(GameBoardNewEvent e) { } } } - game.getBoard().initializeAllAutomaticTerrain(GUIPreferences.getInstance().getHexInclines()); + game.getBoard().initializeAllAutomaticTerrain(GUIP.getHexInclines()); clearHexImageCache(); updateBoard(); clearShadowMap(); @@ -5049,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())) { @@ -5457,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 @@ -5693,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); } @@ -6047,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)); @@ -6239,7 +6239,7 @@ public void die() { ourTask.cancel(); fovHighlightingAndDarkening.die(); KeyBindParser.removePreferenceChangeListener(this); - GUIPreferences.getInstance().removePreferenceChangeListener(this); + GUIP.removePreferenceChangeListener(this); PreferenceManager.getClientPreferences().removePreferenceChangeListener(this); } @@ -6293,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/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index cd484bf34cf..6093c08a68d 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -345,6 +345,9 @@ public class ChatLounge extends AbstractPhaseDisplay implements private static final String MSG_VIEWGAMEBOARDTOOLTIP = Messages.getString("BoardSelectionDialog.ViewGameBoardTooltip"); 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) { @@ -2155,7 +2158,7 @@ public boolean accept(File f) { @Override public String getDescription() { - return "Map Setup XML files"; + return MSG_MAPSETUPXMLFILES; } }; From 5ee4a51781b59c0cbabe58a40520c8faaa3f7926 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 25 Dec 2022 18:50:18 -0500 Subject: [PATCH 30/47] show game board in all the game phases 30 --- .../megamek/client/ui/swing/ClientGUI.java | 54 +++++++++---------- .../client/ui/swing/MiniReportDisplay.java | 39 ++++++-------- .../client/ui/swing/ReportDisplay.java | 18 ++++--- 3 files changed, 51 insertions(+), 60 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 56fba845ab1..5d78bbb9729 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -557,9 +557,11 @@ public void initialize() { panTop = new JPanel(new BorderLayout()); panA1 = new JPanel(); + panA1.setVisible(false); panA1.setLayout(new BoxLayout(panA1, BoxLayout.Y_AXIS)); panB1 = new JPanel(new BorderLayout()); panB2 = new JPanel(); + panB2.setVisible(false); panB2.setLayout(new BoxLayout(panB2, BoxLayout.Y_AXIS)); splitPaneA = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPaneB = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); @@ -1630,35 +1632,19 @@ public void setUnitDisplayVisible(boolean visible) { } private void saveSplitPaneLocations() { - if ((panA1.isVisible()) && (panA1.getComponents().length > 0)) { + if (panA1.isVisible()) { GUIP.setSplitPaneALocation(splitPaneA.getDividerLocation()); } - if ((panB2.isVisible()) && (panB2.getComponents().length > 0)) { + if (panB2.isVisible()) { GUIP.setSplitPaneBLocation(splitPaneB.getDividerLocation()); } } - private void hideEmptyPannels() { + private void hideEmptyPanel(JPanel p, JSplitPane sp, Double d) { Boolean b = false; - for (Component comp : panA1.getComponents()) { - if (comp.isVisible()) { - b = true; - break; - } - } - - if (!b) { - panA1.setVisible(false); - splitPaneA.setDividerLocation(0.0); - } else { - panA1.setVisible(true); - } - - b = false; - - for (Component comp : panB2.getComponents()) { + for (Component comp : p.getComponents()) { if (comp.isVisible()) { b = true; break; @@ -1666,10 +1652,10 @@ private void hideEmptyPannels() { } if (!b) { - panB2.setVisible(false); - splitPaneB.setDividerLocation(1.0); + p.setVisible(false); + sp.setDividerLocation(d); } else { - panB2.setVisible(true); + p.setVisible(true); } } @@ -1691,7 +1677,8 @@ public void setUnitDisplayLocation(boolean visible) { getUnitDisplayDialog().setVisible(visible); getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(false); - hideEmptyPannels(); + hideEmptyPanel(panA1, splitPaneA, 0.0); + hideEmptyPanel(panB2, splitPaneB, 1.0); break; case 1: panA1.add(getUnitDisplay()); @@ -1700,7 +1687,9 @@ public void setUnitDisplayLocation(boolean visible) { getUnitDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(true); - hideEmptyPannels(); + hideEmptyPanel(panA1, splitPaneA, 0.0); + hideEmptyPanel(panB2, splitPaneB, 1.0); + revalidatePanels(); splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); break; case 2: @@ -1710,7 +1699,9 @@ public void setUnitDisplayLocation(boolean visible) { getUnitDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(true); - hideEmptyPannels(); + hideEmptyPanel(panA1, splitPaneA, 0.0); + hideEmptyPanel(panB2, splitPaneB, 1.0); + revalidatePanels(); splitPaneB.setDividerLocation(GUIP.getSplitPaneBDividerLocaton()); break; } @@ -1726,7 +1717,8 @@ public void setMiniReportLocation(boolean visible) { getMiniReportDisplayDialog().add(getMiniReportDisplay(), BorderLayout.CENTER); getMiniReportDisplayDialog().setVisible(visible); getMiniReportDisplay().setVisible(visible); - hideEmptyPannels(); + hideEmptyPanel(panA1, splitPaneA, 0.0); + hideEmptyPanel(panB2, splitPaneB, 1.0); break; case 1: panA1.add(getMiniReportDisplay()); @@ -1735,17 +1727,19 @@ public void setMiniReportLocation(boolean visible) { getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); getMiniReportDisplay().setVisible(visible); - hideEmptyPannels(); + hideEmptyPanel(panA1, splitPaneA, 0.0); + hideEmptyPanel(panB2, splitPaneB, 1.0); splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); break; case 2: panB2.add(getMiniReportDisplay()); - getUnitDisplayDialog().setVisible(false); + getMiniReportDisplay().setVisible(false); panB2.revalidate(); getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); getMiniReportDisplay().setVisible(visible); - hideEmptyPannels(); + hideEmptyPanel(panA1, splitPaneA, 0.0); + hideEmptyPanel(panB2, splitPaneB, 1.0); splitPaneB.setDividerLocation(GUIP.getSplitPaneBDividerLocaton()); break; } diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index 94f9ad2260c..c628f8e789b 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -285,39 +285,30 @@ public void actionPerformed(ActionEvent ae) { } } - public void addReportPages() { - int numRounds = currentClient.getGame().getRoundCount(); - tabs.removeAll(); - - for (int round = 1; round <= numRounds; round++) { - String text = currentClient.receiveReport(currentClient.getGame().getReports(round)); - JTextPane ta = new JTextPane(); - Report.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); - } - - // add the new current phase tab + private JScrollPane loadHtmlScrollPane(String t) { JTextPane ta = new JTextPane(); Report.setupStylesheet(ta); ta.addHyperlinkListener(this); - BASE64ToolKit toolKit = new BASE64ToolKit(); ta.setEditorKit(toolKit); - ta.setText("
" + currentClient.phaseReport + "
"); + ta.setText("
" + t + "
"); ta.setEditable(false); ta.setOpaque(false); ta.setCaretPosition(0); + return new JScrollPane(ta); + } + + public void addReportPages() { + int numRounds = currentClient.getGame().getRoundCount(); + tabs.removeAll(); - JScrollPane sp = new JScrollPane(ta); - tabs.add(MSG_PHASE, sp); + for (int round = 1; round <= numRounds; round++) { + String text = currentClient.receiveReport(currentClient.getGame().getReports(round)); + tabs.add(MSG_ROUND + " " + round, loadHtmlScrollPane(text)); + } + + // add the new current phase tab + tabs.add(MSG_PHASE, loadHtmlScrollPane(currentClient.phaseReport)); tabs.setSelectedIndex(tabs.getTabCount() - 1); tabs.setMinimumSize(new Dimension(0, 0)); diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index d6d9abdeb41..b8fa50e502a 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -69,6 +69,11 @@ public String toString() { 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(). @@ -84,10 +89,10 @@ public ReportDisplay(ClientGUI clientgui) { buttons = new HashMap<>((int) (ReportCommand.values().length * 1.25 + 0.5)); for (ReportCommand cmd : ReportCommand.values()) { - String title = Messages.getString("ReportDisplay." + cmd.getCmd()); + String title = Messages.getString(RD_REPORTDIPLAY + cmd.getCmd()); MegamekButton newButton = new MegamekButton(title, SkinSpecification.UIComponents.PhaseDisplayButton.getComp()); - String ttKey = "ReportDisplay." + cmd.getCmd() + ".tooltip"; + String ttKey = RD_REPORTDIPLAY + cmd.getCmd() + RD_TOOLTIP; if (Messages.keyExists(ttKey)) { newButton.setToolTipText(Messages.getString(ttKey)); } @@ -98,7 +103,7 @@ public ReportDisplay(ClientGUI clientgui) { } numButtonGroups = (int) Math.ceil((buttons.size() + 0.0) / buttonsPerGroup); - butDone.setText("" + Messages.getString("ReportDisplay.Done") + ""); + butDone.setText(MSG_DONE); butDone.setEnabled(false); setupButtonPanel(); @@ -207,8 +212,9 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { } rerolled = false; + GamePhase phase = clientgui.getClient().getGame().getPhase(); - switch (clientgui.getClient().getGame().getPhase()) { + switch (phase) { case INITIATIVE_REPORT: case TARGETING_REPORT: case MOVEMENT_REPORT: @@ -218,10 +224,10 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { case END_REPORT: case VICTORY: resetButtons(); - setStatusBarText(clientgui.getClient().getGame().getPhase().toString()); + setStatusBarText(phase.toString()); break; default: - setStatusBarText(clientgui.getClient().getGame().getPhase().toString()); + setStatusBarText(phase.toString()); break; } } From a0b5a157e65d06e137372b9933c017888611eaa7 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 25 Dec 2022 21:23:42 -0500 Subject: [PATCH 31/47] show game board in all the game phases 31 --- .../i18n/megamek/client/messages.properties | 1 + .../megamek/client/ui/swing/ClientGUI.java | 188 ++++++++++-------- .../client/ui/swing/GUIPreferences.java | 13 +- 3 files changed, 117 insertions(+), 85 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 404a267376c..a02f820e605 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -187,6 +187,7 @@ 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 #Board Editor BoardEditor.BridgeBuildingElevError=Bridge/Building Elevation is an offset from the surface of a hex and hence must be a positive value! diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 5d78bbb9729..beda9c7ae5f 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -297,10 +297,8 @@ public class ClientGUI extends JPanel implements BoardViewListener, private Component bvc; private JPanel panTop; private JSplitPane splitPaneA; - private JSplitPane splitPaneB; private JPanel panA1; - private JPanel panB1; - private JPanel panB2; + private JPanel panA2; public UnitDisplay unitDisplay; private UnitDisplayDialog unitDisplayDialog; @@ -559,24 +557,18 @@ public void initialize() { panA1 = new JPanel(); panA1.setVisible(false); panA1.setLayout(new BoxLayout(panA1, BoxLayout.Y_AXIS)); - panB1 = new JPanel(new BorderLayout()); - panB2 = new JPanel(); - panB2.setVisible(false); - panB2.setLayout(new BoxLayout(panB2, BoxLayout.Y_AXIS)); + panA2 = new JPanel(); + panA2.setVisible(false); + panA2.setLayout(new BoxLayout(panA2, BoxLayout.Y_AXIS)); + splitPaneA = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); - splitPaneB = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPaneA.setDividerSize(10); - splitPaneB.setDividerSize(10); splitPaneA.setResizeWeight(0.5); - splitPaneB.setResizeWeight(0.5); splitPaneA.setLeftComponent(panA1); - splitPaneA.setRightComponent(splitPaneB); - splitPaneB.setLeftComponent(panB1); - splitPaneB.setRightComponent(panB2); + splitPaneA.setRightComponent(panA2); - panB1.add(bvc, BorderLayout.CENTER); panTop.add(splitPaneA, BorderLayout.CENTER); bv.addBoardViewListener(this); @@ -1632,13 +1624,13 @@ public void setUnitDisplayVisible(boolean visible) { } private void saveSplitPaneLocations() { - if (panA1.isVisible()) { + if ((panA1.isVisible()) && (panA2.isVisible())) { GUIP.setSplitPaneALocation(splitPaneA.getDividerLocation()); } + } - if (panB2.isVisible()) { - GUIP.setSplitPaneBLocation(splitPaneB.getDividerLocation()); - } + private void setsetDividerLocations() { + splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); } private void hideEmptyPanel(JPanel p, JSplitPane sp, Double d) { @@ -1664,87 +1656,113 @@ private void revalidatePanels() { getUnitDisplayDialog().repaint(); panA1.revalidate(); panA1.repaint(); - panB2.revalidate(); - panB2.repaint(); } public void setUnitDisplayLocation(boolean visible) { saveSplitPaneLocations(); - switch (GUIP.getUnitDisplayLocaton()) { - case 0: - getUnitDisplayDialog().add(getUnitDisplay(), BorderLayout.CENTER); - getUnitDisplayDialog().setVisible(visible); - getUnitDisplay().setVisible(visible); - getUnitDisplay().setTitleVisible(false); - hideEmptyPanel(panA1, splitPaneA, 0.0); - hideEmptyPanel(panB2, splitPaneB, 1.0); - break; - case 1: - panA1.add(getUnitDisplay()); - getUnitDisplayDialog().setVisible(false); - getUnitDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); - getUnitDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); - getUnitDisplay().setVisible(visible); - getUnitDisplay().setTitleVisible(true); - hideEmptyPanel(panA1, splitPaneA, 0.0); - hideEmptyPanel(panB2, splitPaneB, 1.0); - revalidatePanels(); - splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); - break; - case 2: - panB2.add(getUnitDisplay()); - getUnitDisplayDialog().setVisible(false); - getUnitDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); - getUnitDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.7))); - getUnitDisplay().setVisible(visible); - getUnitDisplay().setTitleVisible(true); - hideEmptyPanel(panA1, splitPaneA, 0.0); - hideEmptyPanel(panB2, splitPaneB, 1.0); - revalidatePanels(); - splitPaneB.setDividerLocation(GUIP.getSplitPaneBDividerLocaton()); - break; + + 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().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); + getUnitDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); + 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, 0.0); + break; + case 1: + panA1.add(bvc); + panA1.setVisible(true); + panA2.add(getUnitDisplay()); + getUnitDisplayDialog().setVisible(false); + getUnitDisplay().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); + getUnitDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); + getUnitDisplay().setVisible(visible); + getUnitDisplay().setTitleVisible(true); + hideEmptyPanel(panA2, splitPaneA, 0.0); + break; + } } + setsetDividerLocations(); revalidatePanels(); } public void setMiniReportLocation(boolean visible) { saveSplitPaneLocations(); - switch (GUIP.getMiniReportLocaton()) { - case 0: - getMiniReportDisplayDialog().add(getMiniReportDisplay(), BorderLayout.CENTER); - getMiniReportDisplayDialog().setVisible(visible); - getMiniReportDisplay().setVisible(visible); - hideEmptyPanel(panA1, splitPaneA, 0.0); - hideEmptyPanel(panB2, splitPaneB, 1.0); - break; - case 1: - panA1.add(getMiniReportDisplay()); - getMiniReportDisplayDialog().setVisible(false); - panA1.revalidate(); - getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); - getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); - getMiniReportDisplay().setVisible(visible); - hideEmptyPanel(panA1, splitPaneA, 0.0); - hideEmptyPanel(panB2, splitPaneB, 1.0); - splitPaneA.setDividerLocation(GUIP.getSplitPaneADividerLocaton()); - break; - case 2: - panB2.add(getMiniReportDisplay()); - getMiniReportDisplay().setVisible(false); - panB2.revalidate(); - getMiniReportDisplay().setMinimumSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); - getMiniReportDisplay().setPreferredSize(new Dimension(0, (int)(panTop.getHeight() * 0.3))); - getMiniReportDisplay().setVisible(visible); - hideEmptyPanel(panA1, splitPaneA, 0.0); - hideEmptyPanel(panB2, splitPaneB, 1.0); - splitPaneB.setDividerLocation(GUIP.getSplitPaneBDividerLocaton()); - break; + 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().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); + getMiniReportDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); + 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, 0.0); + break; + case 1: + panA1.add(bvc); + panA1.setVisible(true); + panA2.add(getMiniReportDisplay()); + getMiniReportDisplayDialog().setVisible(false); + getMiniReportDisplay().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); + getMiniReportDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); + getMiniReportDisplay().setVisible(visible); + hideEmptyPanel(panA2, splitPaneA, 0.0); + break; + } } revalidatePanels(); + setsetDividerLocations(); } private boolean fillPopup(Coords coords) { @@ -2823,6 +2841,10 @@ public void preferenceChange(PreferenceChangeEvent e) { case GUIPreferences.MINI_REPORT_LOCATION: setMiniReportVisible(GUIP.getMiniReportEnabled()); break; + case GUIPreferences.ADVANCED_DOCK_ON_LEFT: + setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); + setMiniReportVisible(GUIP.getMiniReportEnabled()); + break; default: } } diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index eaa81a63f86..4f121782eb6 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -113,6 +113,7 @@ 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"; /* --End advanced settings-- */ @@ -428,6 +429,7 @@ protected GUIPreferences() { setDefault(ADVANCED_REPORT_COLOR_LINK, DEFAULT_REPORT_LINK_COLOR); setDefault(ADVANCED_UNITTOOLTIP_SEENBYRESOLUTION, 3); + setDefault(ADVANCED_DOCK_ON_LEFT, 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 "); @@ -1347,7 +1349,7 @@ public void setUnitDisplayEnabled(boolean b) { } public void toggleUnitDisplayLocation() { - store.setValue(UNIT_DISPLAY_LOCATION, ((getInt(UNIT_DISPLAY_LOCATION)+1)%3)); + store.setValue(UNIT_DISPLAY_LOCATION, ((getInt(UNIT_DISPLAY_LOCATION)+1)%2)); } public void setUnitDisplayLocation(int i) { @@ -1579,7 +1581,7 @@ public void setMiniReportAutoDisplayNonReportPhase(String s) { } public void toggleMiniReportLocation() { - store.setValue(MINI_REPORT_LOCATION, ((getInt(MINI_REPORT_LOCATION)+1)%3)); + store.setValue(MINI_REPORT_LOCATION, ((getInt(MINI_REPORT_LOCATION)+1)%2)); } public void setMiniReportLocation(int i) { @@ -1955,6 +1957,9 @@ public int getAdvancedUnitToolTipSeenByResolution() { return getInt(ADVANCED_UNITTOOLTIP_SEENBYRESOLUTION); } + public boolean getAdvancedDockOnLeft() { + return getBoolean(ADVANCED_DOCK_ON_LEFT); + } public void setReportLinkColor(Color color) { store.setValue(ADVANCED_REPORT_COLOR_LINK, getColorString(color)); @@ -2044,6 +2049,10 @@ public void setAdvancedUnitToolTipSeenByResolution(int i) { store.setValue(ADVANCED_UNITTOOLTIP_SEENBYRESOLUTION, i); } + public void setAdvancedDockOnLeft(Boolean state) { + store.setValue(ADVANCED_DOCK_ON_LEFT, state); + } + /** * Toggles the state of the user preference for the Keybinds overlay. */ From b14b1327164a371dd52f6f8223e2b65d4b042a27 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 26 Dec 2022 10:25:24 -0500 Subject: [PATCH 32/47] show game board in all the game phasee 32 --- .../i18n/megamek/client/messages.properties | 1 + .../megamek/client/ui/swing/ClientGUI.java | 21 ++++++++++++++++--- .../client/ui/swing/GUIPreferences.java | 20 +++++++++--------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index a02f820e605..7300972cc02 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -188,6 +188,7 @@ AdvancedOptions.PlanetaryConditionsShowValues.name=Planetary Conditions Show Val 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! diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index beda9c7ae5f..1e8b97b33e2 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -556,10 +556,8 @@ public void initialize() { panTop = new JPanel(new BorderLayout()); panA1 = new JPanel(); panA1.setVisible(false); - panA1.setLayout(new BoxLayout(panA1, BoxLayout.Y_AXIS)); panA2 = new JPanel(); panA2.setVisible(false); - panA2.setLayout(new BoxLayout(panA2, BoxLayout.Y_AXIS)); splitPaneA = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); @@ -1656,11 +1654,23 @@ private void revalidatePanels() { 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()) { @@ -1716,6 +1726,7 @@ public void setUnitDisplayLocation(boolean visible) { public void setMiniReportLocation(boolean visible) { saveSplitPaneLocations(); + setDockAxis(); if (GUIP.getAdvancedDockOnLeft()) { switch (GUIP.getMiniReportLocaton()) { @@ -2845,6 +2856,10 @@ public void preferenceChange(PreferenceChangeEvent e) { setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); setMiniReportVisible(GUIP.getMiniReportEnabled()); break; + case GUIPreferences.ADVANCED_DOCK_MULTIPLE_ON_Y_AXIS: + setUnitDisplayVisible(GUIP.getUnitDisplayEnabled()); + setMiniReportVisible(GUIP.getMiniReportEnabled()); + break; default: } } diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 4f121782eb6..5218ef2c09b 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -114,6 +114,7 @@ public class GUIPreferences extends PreferenceStoreProxy { 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-- */ @@ -149,7 +150,6 @@ public class GUIPreferences extends PreferenceStoreProxy { 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 SPLIT_PANE_B_DIVIDER_LOCATION = "SplitPaneBDividerLocation"; 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"; @@ -430,6 +430,7 @@ 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 "); @@ -467,7 +468,6 @@ protected GUIPreferences() { store.setDefault(UNIT_DISPLAY_ENABLED, true); store.setDefault(UNIT_DISPLAY_LOCATION, 0); store.setDefault(SPLIT_PANE_A_DIVIDER_LOCATION, 300); - store.setDefault(SPLIT_PANE_B_DIVIDER_LOCATION, 300); store.setDefault(GAME_SUMMARY_BOARD_VIEW, false); store.setDefault(ENTITY_OWNER_LABEL_COLOR, true); @@ -748,10 +748,6 @@ public int getSplitPaneADividerLocaton() { return store.getInt(SPLIT_PANE_A_DIVIDER_LOCATION); } - public int getSplitPaneBDividerLocaton() { - return store.getInt(SPLIT_PANE_B_DIVIDER_LOCATION); - } - public boolean getCoordsEnabled() { return store.getBoolean(SHOW_COORDS); } @@ -1360,10 +1356,6 @@ public void setSplitPaneALocation(int i) { store.setValue(SPLIT_PANE_A_DIVIDER_LOCATION, i); } - public void setSplitPaneBLocation(int i) { - store.setValue(SPLIT_PANE_B_DIVIDER_LOCATION, i); - } - public void toggleCoords() { store.setValue(SHOW_COORDS, !getBoolean(SHOW_COORDS)); } @@ -1961,6 +1953,10 @@ 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)); } @@ -2053,6 +2049,10 @@ public void setAdvancedDockOnLeft(Boolean state) { store.setValue(ADVANCED_DOCK_ON_LEFT, state); } + public void setAdvancedDockMultipleOnYAxis(Boolean state) { + store.setValue(ADVANCED_DOCK_MULTIPLE_ON_Y_AXIS, state); + } + /** * Toggles the state of the user preference for the Keybinds overlay. */ From 1f6b3dd22f8ac9b1db68739b1f515a4a6402f41d Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 26 Dec 2022 15:20:49 -0500 Subject: [PATCH 33/47] show game board in all the game phasee 33 --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 1e8b97b33e2..a9be7e24934 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -1650,6 +1650,11 @@ private void hideEmptyPanel(JPanel p, JSplitPane sp, Double d) { } 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(); @@ -1688,8 +1693,6 @@ public void setUnitDisplayLocation(boolean visible) { panA2.setVisible(true); panA1.add(getUnitDisplay()); getUnitDisplayDialog().setVisible(false); - getUnitDisplay().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); - getUnitDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(true); hideEmptyPanel(panA1, splitPaneA, 0.0); @@ -1711,8 +1714,6 @@ public void setUnitDisplayLocation(boolean visible) { panA1.setVisible(true); panA2.add(getUnitDisplay()); getUnitDisplayDialog().setVisible(false); - getUnitDisplay().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); - getUnitDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.7))); getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(true); hideEmptyPanel(panA2, splitPaneA, 0.0); @@ -1743,8 +1744,6 @@ public void setMiniReportLocation(boolean visible) { panA2.setVisible(true); panA1.add(getMiniReportDisplay()); getMiniReportDisplayDialog().setVisible(false); - getMiniReportDisplay().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); - getMiniReportDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); getMiniReportDisplay().setVisible(visible); hideEmptyPanel(panA1, splitPaneA, 0.0); break; @@ -1764,8 +1763,6 @@ public void setMiniReportLocation(boolean visible) { panA1.setVisible(true); panA2.add(getMiniReportDisplay()); getMiniReportDisplayDialog().setVisible(false); - getMiniReportDisplay().setMinimumSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); - getMiniReportDisplay().setPreferredSize(new Dimension(0, (int) (panTop.getHeight() * 0.3))); getMiniReportDisplay().setVisible(visible); hideEmptyPanel(panA2, splitPaneA, 0.0); break; From a2a3523acc5d3b372a69bec345ff6768841c1e40 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 26 Dec 2022 15:36:36 -0500 Subject: [PATCH 34/47] show game board in all the game phasee 34 --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index a9be7e24934..5046c38638e 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -849,9 +849,9 @@ public void actionPerformed(ActionEvent event) { break; case FILE_UNITS_REINFORCE: ignoreHotKeys = true; - PlayerListDialog playerListDialog = new PlayerListDialog(frame, client, 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: @@ -1632,7 +1632,7 @@ private void setsetDividerLocations() { } private void hideEmptyPanel(JPanel p, JSplitPane sp, Double d) { - Boolean b = false; + boolean b = false; for (Component comp : p.getComponents()) { if (comp.isVisible()) { From 3dfde33b2ce5f9c8b080ba4384fade9918d719c9 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 26 Dec 2022 16:20:43 -0500 Subject: [PATCH 35/47] show game board in all the game phasee 35 --- .../src/megamek/client/ui/swing/ClientGUI.java | 18 ++++++------------ .../megamek/client/ui/swing/CommonMenuBar.java | 2 -- .../client/ui/swing/MiniReportDisplay.java | 7 +++---- .../ui/swing/unitDisplay/UnitDisplay.java | 2 +- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 5046c38638e..a2262103b93 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -490,14 +490,8 @@ private void initializeFrame() { frame.setJMenuBar(menuBar); if (GUIP.getWindowSizeHeight() != 0) { - frame.setLocation( - GUIP.getWindowPosX(), - GUIP.getWindowPosY() - ); - frame.setSize( - GUIP.getWindowSizeWidth(), - GUIP.getWindowSizeHeight() - ); + frame.setLocation(GUIP.getWindowPosX(), GUIP.getWindowPosY()); + frame.setSize(GUIP.getWindowSizeWidth(), GUIP.getWindowSizeHeight()); } else { frame.setSize(800, 600); } @@ -1707,7 +1701,7 @@ public void setUnitDisplayLocation(boolean visible) { getUnitDisplayDialog().setVisible(visible); getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(false); - hideEmptyPanel(panA2, splitPaneA, 0.0); + hideEmptyPanel(panA2, splitPaneA, 1.0); break; case 1: panA1.add(bvc); @@ -1716,7 +1710,7 @@ public void setUnitDisplayLocation(boolean visible) { getUnitDisplayDialog().setVisible(false); getUnitDisplay().setVisible(visible); getUnitDisplay().setTitleVisible(true); - hideEmptyPanel(panA2, splitPaneA, 0.0); + hideEmptyPanel(panA2, splitPaneA, 1.0); break; } } @@ -1756,7 +1750,7 @@ public void setMiniReportLocation(boolean visible) { getMiniReportDisplayDialog().add(getMiniReportDisplay(), BorderLayout.CENTER); getMiniReportDisplayDialog().setVisible(visible); getMiniReportDisplay().setVisible(visible); - hideEmptyPanel(panA2, splitPaneA, 0.0); + hideEmptyPanel(panA2, splitPaneA, 1.0); break; case 1: panA1.add(bvc); @@ -1764,7 +1758,7 @@ public void setMiniReportLocation(boolean visible) { panA2.add(getMiniReportDisplay()); getMiniReportDisplayDialog().setVisible(false); getMiniReportDisplay().setVisible(visible); - hideEmptyPanel(panA2, splitPaneA, 0.0); + hideEmptyPanel(panA2, splitPaneA, 1.0); break; } } diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index c607286f98e..44d5c93cb2a 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -549,6 +549,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/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index c628f8e789b..b18834a5150 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -187,11 +187,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); } } diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index 08a2d4a7467..1b282825bb8 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -687,4 +687,4 @@ public void preferenceChange(PreferenceChangeEvent e) { adaptToGUIScale(); } } -} \ No newline at end of file +} From ceb08e1febf3382ea9e762529472e766caf8d7b9 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 26 Dec 2022 21:31:57 -0500 Subject: [PATCH 36/47] show game board in all the game phasee 36 --- megamek/src/megamek/client/ui/swing/MiniReportDisplay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index b18834a5150..8b358455d74 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -358,7 +358,7 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { setVisible(false); break; default: - if (!e.getNewPhase().equals((e.getOldPhase()))) { + if ((!e.getNewPhase().equals((e.getOldPhase()))) && (e.getNewPhase().isReport())){ addReportPages(); updatePlayerChoice(); updateEntityChoice(); From 5dc380ef59c472059d39535a70da88839dde9598 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 27 Dec 2022 08:52:13 -0500 Subject: [PATCH 37/47] show game board in all the game phasee 37 --- megamek/src/megamek/client/ui/swing/MiniReportDisplay.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index 8b358455d74..0b94eb7c9c9 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -358,7 +358,8 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { setVisible(false); break; default: - if ((!e.getNewPhase().equals((e.getOldPhase()))) && (e.getNewPhase().isReport())){ + if ((!e.getNewPhase().equals((e.getOldPhase()))) + && ((e.getNewPhase().isReport()) || ((e.getNewPhase().isOnMap()) && (tabs.getTabCount() == 1)))){ addReportPages(); updatePlayerChoice(); updateEntityChoice(); From a80f96fc2777327babb7495da2b06fcc8d6967cc Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 27 Dec 2022 12:59:59 -0500 Subject: [PATCH 38/47] show game board in all the game phasee 38 --- megamek/src/megamek/client/ui/swing/MiniReportDisplay.java | 1 - 1 file changed, 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index 0b94eb7c9c9..76dbec945c4 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -109,7 +109,6 @@ public MiniReportDisplay(ClientGUI clientgui) { JPanel panelMain = new JPanel(new BorderLayout()); tabs = new JTabbedPane(); - addReportPages(); panelMain.add(tabs, BorderLayout.CENTER); panelMain.add(sp, BorderLayout.SOUTH); panelMain.setMinimumSize(new Dimension(0, 0)); From f42d22e8026636523a0424e4489a943282a944ad Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 27 Dec 2022 15:15:44 -0500 Subject: [PATCH 39/47] show game board in all the game phasee 39 --- .../client/ui/swing/CommonMenuBar.java | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 44d5c93cb2a..af7009ac450 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -187,20 +187,11 @@ public CommonMenuBar() { add(menu); menu.setMnemonic(VK_G); - initMenuItem(gameRoundReport, menu, VIEW_ROUND_REPORT); - GUIP.setMiniReportEnabled(false); - gameRoundReport.setSelected(false); - menu.addSeparator(); - initMenuItem(gameReplacePlayer, menu, FILE_GAME_REPLACE_PLAYER, VK_R); - initMenuItem(gamePlayerList, menu, VIEW_PLAYER_LIST); - GUIP.setMinimapEnabled(false); - gamePlayerList.setSelected(false); 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); @@ -259,19 +250,31 @@ public CommonMenuBar() { initMenuItem(viewIncGUIScale, menu, VIEW_INCGUISCALE); initMenuItem(viewDecGUIScale, menu, VIEW_DECGUISCALE); menu.addSeparator(); + + 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); + 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(); - - 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); viewUnitOverview.setSelected(GUIP.getShowUnitOverview()); initMenuItem(viewZoomIn, menu, VIEW_ZOOM_IN); initMenuItem(viewZoomOut, menu, VIEW_ZOOM_OUT); @@ -281,14 +284,6 @@ public CommonMenuBar() { initMenuItem(viewLabels, menu, VIEW_LABELS); menu.addSeparator(); - 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); - menu.addSeparator(); - initMenuItem(toggleFovDarken, menu, VIEW_TOGGLE_FOV_DARKEN); toggleFovDarken.setSelected(GUIP.getFovDarken()); toggleFovDarken.setToolTipText(MSG_VIEWTOGGLEFOVDARKENTOOLTIP); From 2a2a95f82954688e46a1a8ca71710ac544eb7d31 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 27 Dec 2022 15:31:04 -0500 Subject: [PATCH 40/47] show game board in all the game phasee 40 --- megamek/src/megamek/client/ui/swing/CommonMenuBar.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index af7009ac450..4a36ee57596 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -263,6 +263,8 @@ public CommonMenuBar() { 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); From b17e7a2cec67d36cf4df07647185fd4c89be4be8 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 27 Dec 2022 23:05:31 -0500 Subject: [PATCH 41/47] show game board in all the game phasee 41 --- megamek/src/megamek/client/ui/swing/MiniReportDisplay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index 76dbec945c4..31bf4695729 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -358,7 +358,7 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { break; default: if ((!e.getNewPhase().equals((e.getOldPhase()))) - && ((e.getNewPhase().isReport()) || ((e.getNewPhase().isOnMap()) && (tabs.getTabCount() == 1)))){ + && ((e.getNewPhase().isReport()) || ((e.getNewPhase().isOnMap()) && (tabs.getTabCount() == 0)))){ addReportPages(); updatePlayerChoice(); updateEntityChoice(); From f8c9686be5b21b309f09e4d15eceb79c89b827ec Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 6 Jan 2023 11:40:20 -0500 Subject: [PATCH 42/47] show game board in all the game phasee 42 --- .../megamek/client/ui/swing/ClientGUI.java | 40 +++++-------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index a2262103b93..b06f2871dcc 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -358,7 +358,8 @@ 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; /** @@ -755,25 +756,13 @@ public void miniReportDisplayAddReportPages() { public void reportDisplayResetDone() { if (!getClient().getLocalPlayer().isDone()) { - for (String s : phaseComponents.keySet()) { - JComponent comp = phaseComponents.get(s); - if (comp instanceof ReportDisplay) { - ((ReportDisplay) comp).setDoneEnabled(true); - break; - } - } + reportDisply.setDoneEnabled(true); } } public void reportDisplayResetRerollInitiative() { if ((!getClient().getLocalPlayer().isDone()) && (getClient().getGame().hasTacticalGenius(getClient().getLocalPlayer()))) { - for (String s : phaseComponents.keySet()) { - JComponent comp = phaseComponents.get(s); - if (comp instanceof ReportDisplay) { - ((ReportDisplay) comp).resetRerollInitiativeEnabled(); - break; - } - } + reportDisply.resetRerollInitiativeEnabled(); } } @@ -1411,26 +1400,19 @@ private JComponent initializePanel(GamePhase phase) { case PHYSICAL_REPORT: case END_REPORT: case VICTORY: - component = null; - for (String s : phaseComponents.keySet()) { - JComponent comp = phaseComponents.get(s); - if (comp instanceof ReportDisplay) { - component = comp; - break; - } - } - if (component == null) { - component = new ReportDisplay(this); - } main = CG_BOARDVIEW; secondary = CG_REPORTDISPLAY; - component.setName(secondary); + if (reportDisply == null) { + reportDisply = new ReportDisplay(this); + reportDisply.setName(secondary); + } if (!mainNames.containsValue(main)) { panMain.add(panTop, main); } - currPhaseDisplay = (StatusBarPhaseDisplay) component; + currPhaseDisplay = reportDisply; + component = reportDisply; if (!secondaryNames.containsValue(secondary)) { - panSecondary.add(component, secondary); + panSecondary.add(reportDisply, secondary); } break; default: From 60fda01dc58d12048008b424514cad95653c5ed0 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 6 Jan 2023 12:39:57 -0500 Subject: [PATCH 43/47] show game board in all the game phasee 43 --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index b06f2871dcc..c2fd4060051 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -755,13 +755,15 @@ public void miniReportDisplayAddReportPages() { } public void reportDisplayResetDone() { - if (!getClient().getLocalPlayer().isDone()) { + if ((reportDisply != null ) && (!getClient().getLocalPlayer().isDone())) { reportDisply.setDoneEnabled(true); } } public void reportDisplayResetRerollInitiative() { - if ((!getClient().getLocalPlayer().isDone()) && (getClient().getGame().hasTacticalGenius(getClient().getLocalPlayer()))) { + if ((reportDisply != null ) + && (!getClient().getLocalPlayer().isDone()) + && (getClient().getGame().hasTacticalGenius(getClient().getLocalPlayer()))) { reportDisply.resetRerollInitiativeEnabled(); } } From 9e93a1a7de8a84773a643bae33d0fa4d81d4d81c Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 6 Jan 2023 14:28:30 -0500 Subject: [PATCH 44/47] show game board in all the game phasee 44 --- .../megamek/client/ui/swing/ClientGUI.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index c2fd4060051..8b28cc546ce 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -768,6 +768,26 @@ public void reportDisplayResetRerollInitiative() { } } + 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. @@ -776,10 +796,7 @@ public void reportDisplayResetRerollInitiative() { 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()); - miniReportDisplay.setBounds(0, 0, miniReportDisplay.getWidth(), miniReportDisplay.getHeight()); - playerListDialog.setBounds(0, 0, playerListDialog.getWidth(), playerListDialog.getHeight()); + resetWindowPositions(); break; case FILE_GAME_SAVE: saveGame(); From fb6bdfac48cf64e4deae1a6b23512c4f2d29a267 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 10 Jan 2023 12:59:59 -0500 Subject: [PATCH 45/47] show game board in all the game phases 45 --- .../ui/dialogs/MiniReportDisplayDialog.java | 17 +- .../client/ui/dialogs/UnitDisplayDialog.java | 37 ++--- .../megamek/client/ui/swing/ChatterBox.java | 31 +++- .../megamek/client/ui/swing/ClientGUI.java | 56 +++---- .../client/ui/swing/CommonMenuBar.java | 46 +++--- .../client/ui/swing/CommonSettingsDialog.java | 152 +++++++++--------- .../client/ui/swing/GUIPreferences.java | 116 ++++++------- .../client/ui/swing/MiniReportDisplay.java | 10 +- .../client/ui/swing/PlayerListDialog.java | 86 +++++----- .../client/ui/swing/ReportDisplay.java | 4 +- .../client/ui/swing/lobby/ChatLounge.java | 5 +- .../ui/swing/unitDisplay/UnitDisplay.java | 8 +- 12 files changed, 287 insertions(+), 281 deletions(-) diff --git a/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java b/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java index 0ea6c053346..6452d6cc587 100644 --- a/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java +++ b/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java @@ -32,12 +32,13 @@ 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"); + private String msg_title = Messages.getString("MiniReportDisplay.title"); //endregion Variable Declarations //region Constructors public MiniReportDisplayDialog(final JFrame frame, final ClientGUI clientGUI) { - super(frame, MSG_TITLE, false); + super(frame, "", false); + this.setTitle(msg_title); this.setLocation(GUIP.getMiniReportPosX(), GUIP.getMiniReportPosY()); this.setSize(GUIP.getMiniReportSizeWidth(), GUIP.getMiniReportSizeHeight()); @@ -58,18 +59,14 @@ public void windowClosing(WindowEvent evt) { } //endregion Constructors - public void savePref() { - GUIP.setMiniReportSizeWidth(getSize().width); - GUIP.setMiniReportSizeHeight(getSize().height); - GUIP.setMiniReportPosX(getLocation().x); - GUIP.setMiniReportPosY(getLocation().y); - } - @Override protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { - savePref(); + GUIP.setMiniReportSizeWidth(getSize().width); + GUIP.setMiniReportSizeHeight(getSize().height); + GUIP.setMiniReportPosX(getLocation().x); + GUIP.setMiniReportPosY(getLocation().y); } } diff --git a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java index a0eca07fdce..87528dc1f03 100644 --- a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java +++ b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java @@ -32,13 +32,14 @@ public class UnitDisplayDialog extends JDialog { //region Variable Declarations private final ClientGUI clientGUI; - private static final String MSG_TITLE = Messages.getString("ClientGUI.MechDisplay"); + private 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 ClientGUI clientGUI) { - super(frame, MSG_TITLE, false); + super(frame, "", false); + this.setTitle(msg_title); if (GUIP.getUnitDisplayStartTabbed()) { this.setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY()); @@ -65,28 +66,24 @@ public void windowClosing(WindowEvent evt) { } //endregion Constructors - private void savePref() { - if ((this.getSize().width * this.getSize().height) > 0) { - if (GUIP.getUnitDisplayStartTabbed()) { - GUIP.setUnitDisplayPosX(this.getLocation().x); - GUIP.setUnitDisplayPosY(this.getLocation().y); - GUIP.setUnitDisplaySizeWidth(this.getSize().width); - GUIP.setUnitDisplaySizeHeight(this.getSize().height); - } else { - GUIP.setUnitDisplayNontabbedPosX(this.getLocation().x); - GUIP.setUnitDisplayNontabbedPosY(this.getLocation().y); - GUIP.setUnitDisplayNonTabbedSizeWidth(this.getSize().width); - GUIP.setUnitDisplayNonTabbedSizeHeight(this.getSize().height); - clientGUI.getUnitDisplay().saveSplitterLoc(); - } - } - } - @Override protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { - savePref(); + 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(); + } + } } } diff --git a/megamek/src/megamek/client/ui/swing/ChatterBox.java b/megamek/src/megamek/client/ui/swing/ChatterBox.java index 62fe103432d..fa7982861b7 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 4cef9b8987a..b03ec2d08b3 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -443,6 +443,10 @@ public MiniReportDisplayDialog getMiniReportDisplayDialog() { return miniReportDisplayDialog; } + public PlayerListDialog getPlayerListDialog() { + return playerListDialog; + } + public void setMiniReportDisplayDialog(final MiniReportDisplayDialog miniReportDisplayDialog) { this.miniReportDisplayDialog = miniReportDisplayDialog; } @@ -456,7 +460,7 @@ private void loadSoundClip() { } final File file = new File(GUIP.getSoundBingFilename()); if (!file.exists()) { - LogManager.getLogger().error(MSG_FAILEDTOLOADAUDIFILE + " " + GUIP.getSoundBingFilename()); + LogManager.getLogger().error(msg_failedtoloadaudifile + " " + GUIP.getSoundBingFilename()); return; } @@ -1487,17 +1491,17 @@ private void maybeShowMinimap() { GamePhase phase = getClient().getGame().getPhase(); if (phase.isReport()) { - String action = GUIP.getMinimapAutoDisplayReportPhase(); - if (action.equals(MSG_SHOW)) { + int action = GUIP.getMinimapAutoDisplayReportPhase(); + if (action == GUIPreferences.SHOW) { GUIP.setMinimapEnabled(true); - } else if (action.equals(MSG_HIDE)) { + } else if (action == GUIPreferences.HIDE) { GUIP.setMinimapEnabled(false); } } else if (phase.isOnMap()) { - String action = GUIP.getMinimapAutoDisplayNonReportPhase(); - if (action.equals(MSG_SHOW)) { + int action = GUIP.getMinimapAutoDisplayNonReportPhase(); + if (action == GUIPreferences.SHOW) { GUIP.setMinimapEnabled(true); - } else if (action.equals(MSG_HIDE)) { + } else if (action == GUIPreferences.HIDE) { GUIP.setMinimapEnabled(false); } } @@ -1507,17 +1511,17 @@ private void maybeShowMiniReport() { GamePhase phase = getClient().getGame().getPhase(); if (phase.isReport()) { - String action = GUIP.getMiniReportAutoDisplayReportPhase(); - if (action.equals(MSG_SHOW)) { + int action = GUIP.getMiniReportAutoDisplayReportPhase(); + if (action == GUIPreferences.SHOW) { GUIP.setMiniReportEnabled(true); - } else if (action.equals(MSG_HIDE)) { + } else if (action == GUIPreferences.HIDE) { GUIP.setMiniReportEnabled(false); } } else if (phase.isOnMap()) { - String action = GUIP.getMiniReportAutoDisplayNonReportPhase(); - if (action.equals(MSG_SHOW)) { + int action = GUIP.getMiniReportAutoDisplayNonReportPhase(); + if (action == GUIPreferences.SHOW) { GUIP.setMiniReportEnabled(true); - } else if (action.equals(MSG_HIDE)) { + } else if (action == GUIPreferences.HIDE) { GUIP.setMiniReportEnabled(false); } } @@ -1527,17 +1531,17 @@ private void maybeShowPlayerList() { GamePhase phase = getClient().getGame().getPhase(); if (phase.isReport()) { - String action = GUIP.getPlayerListAutoDisplayReportPhase(); - if (action.equals(MSG_SHOW)) { + int action = GUIP.getPlayerListAutoDisplayReportPhase(); + if (action == GUIPreferences.SHOW) { GUIP.setPlayerListEnabled(true); - } else if (action.equals(MSG_HIDE)) { + } else if (action == GUIPreferences.HIDE) { GUIP.setPlayerListEnabled(false); } } else if (phase.isOnMap()) { - String action = GUIP.getPlayerListAutoDisplayNonReportPhase(); - if (action.equals(MSG_SHOW)) { + int action = GUIP.getPlayerListAutoDisplayNonReportPhase(); + if (action == GUIPreferences.SHOW) { GUIP.setPlayerListEnabled(true); - } else if (action.equals(MSG_HIDE)) { + } else if (action == GUIPreferences.HIDE) { GUIP.setPlayerListEnabled(false); } } @@ -1577,17 +1581,17 @@ public void maybeShowUnitDisplay() { GamePhase phase = getClient().getGame().getPhase(); if (phase.isReport()) { - String action = GUIP.getUnitDisplayAutoDisplayReportPhase(); - if (action.equals(MSG_SHOW)) { + int action = GUIP.getUnitDisplayAutoDisplayReportPhase(); + if (action == GUIPreferences.SHOW) { GUIP.setUnitDisplayEnabled(true); - } else if (action.equals(MSG_HIDE)) { + } else if (action == GUIPreferences.HIDE) { GUIP.setUnitDisplayEnabled(false); } } else if (phase.isOnMap()) { - String action = GUIP.getUnitDisplayAutoDisplayNonReportPhase(); - if (action.equals(MSG_SHOW)) { + int action = GUIP.getUnitDisplayAutoDisplayNonReportPhase(); + if (action == GUIPreferences.SHOW) { GUIP.setUnitDisplayEnabled(true); - } else if (action.equals(MSG_HIDE)) { + } else if (action == GUIPreferences.HIDE) { GUIP.setUnitDisplayEnabled(false); } } @@ -2435,8 +2439,6 @@ public void gameClientFeedbackRequest(GameCFREvent evt) { } optionType = JOptionPane.OK_CANCEL_OPTION; - title = MessageFormat.format(MSG_CFAPDSASSIGNTITLE, new Object[] { e.getDisplayName() }); - msg = MessageFormat.format(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, diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 4a36ee57596..848abae1142 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -137,17 +137,17 @@ 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"); + private String msg_filemenu = Messages.getString("CommonMenuBar.FileMenu"); + private String msg_gamemenu = Messages.getString("CommonMenuBar.GameMenu"); + private String msg_boardmenu = Messages.getString("CommonMenuBar.BoardMenu"); + private String msg_fileboardsaveasimage_tooltip = Messages.getString("CommonMenuBar.fileBoardSaveAsImage.tooltip"); + private String msg_fileboardsaveasimageunits_tooltip = Messages.getString("CommonMenuBar.fileBoardSaveAsImageUnits.tooltip"); + private String msg_boardremove = Messages.getString("CommonMenuBar.boardRemove"); + private String msg_viewmenu = Messages.getString("CommonMenuBar.ViewMenu"); + private String msg_viewtogglefovdarkentooltip = Messages.getString("CommonMenuBar.viewToggleFovDarkenTooltip"); + private String msg_viewtogglefieldoffiretooltip = Messages.getString("CommonMenuBar.viewToggleFieldOfFireToolTip"); + private String msg_viewtogglefiringsolutionstooltip = Messages.getString("CommonMenuBar.viewToggleFiringSolutionsToolTip"); + private 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) { @@ -173,7 +173,7 @@ public CommonMenuBar(MegaMekGUI mmg) { /** Creates the common MegaMek menu bar. */ public CommonMenuBar() { // Create the Game menu - JMenu menu = new JMenu(MSG_FILEMENU); + JMenu menu = new JMenu(msg_filemenu); menu.setMnemonic(VK_F); add(menu); initMenuItem(gameLoad, menu, FILE_GAME_LOAD, VK_L); @@ -183,7 +183,7 @@ public CommonMenuBar() { initMenuItem(gameSaveServer, menu, FILE_GAME_SAVE_SERVER); // Create the Unit List sub-menu. - menu = new JMenu(MSG_GAMEMENU); + menu = new JMenu(msg_gamemenu); add(menu); menu.setMnemonic(VK_G); @@ -208,7 +208,7 @@ public CommonMenuBar() { initMenuItem(fireSaveWeaponOrder, menu, FIRE_SAVE_WEAPON_ORDER); // Create the Board sub-menu. - menu = new JMenu(MSG_BOARDMENU); + menu = new JMenu(msg_boardmenu); menu.setMnemonic(VK_B); add(menu); initMenuItem(boardNew, menu, BOARD_NEW); @@ -220,9 +220,9 @@ public CommonMenuBar() { menu.addSeparator(); initMenuItem(boardSaveAsImage, menu, BOARD_SAVE_AS_IMAGE); - boardSaveAsImage.setToolTipText(MSG_FILEBOARDSAVEASIMAGE_TOOLTIP); + boardSaveAsImage.setToolTipText(msg_fileboardsaveasimage_tooltip); initMenuItem(boardSaveAsImageUnits, menu, BOARD_SAVE_AS_IMAGE_UNITS); - boardSaveAsImageUnits.setToolTipText(MSG_FILEBOARDSAVEASIMAGEUNITS_TOOLTIP); + boardSaveAsImageUnits.setToolTipText(msg_fileboardsaveasimageunits_tooltip); menu.addSeparator(); initMenuItem(boardUndo, menu, BOARD_UNDO); @@ -235,7 +235,7 @@ public CommonMenuBar() { initMenuItem(boardClear, menu, BOARD_CLEAR); initMenuItem(boardFlatten, menu, BOARD_FLATTEN); initMenuItem(boardFlood, menu, BOARD_FLOOD); - boardRemove = new JMenu(MSG_BOARDREMOVE); + boardRemove = new JMenu(msg_boardremove); menu.add(boardRemove); initMenuItem(boardRemoveForests, boardRemove, BOARD_REMOVE_FORESTS); initMenuItem(boardRemoveWater, boardRemove, BOARD_REMOVE_WATER); @@ -243,7 +243,7 @@ public CommonMenuBar() { initMenuItem(boardRemoveBuildings, boardRemove, BOARD_REMOVE_BUILDINGS); // Create the view menu. - menu = new JMenu(MSG_VIEWMENU); + menu = new JMenu(msg_viewmenu); menu.setMnemonic(VK_V); add(menu); initMenuItem(viewClientSettings, menu, VIEW_CLIENT_SETTINGS, VK_S); @@ -288,7 +288,7 @@ public CommonMenuBar() { initMenuItem(toggleFovDarken, menu, VIEW_TOGGLE_FOV_DARKEN); toggleFovDarken.setSelected(GUIP.getFovDarken()); - toggleFovDarken.setToolTipText(MSG_VIEWTOGGLEFOVDARKENTOOLTIP); + toggleFovDarken.setToolTipText(msg_viewtogglefovdarkentooltip); initMenuItem(viewLOSSetting, menu, VIEW_LOS_SETTING); initMenuItem(toggleFovHighlight, menu, VIEW_TOGGLE_FOV_HIGHLIGHT); toggleFovHighlight.setSelected(GUIP.getFovHighlight()); @@ -299,15 +299,15 @@ public CommonMenuBar() { initMenuItem(toggleFieldOfFire, menu, VIEW_TOGGLE_FIELD_OF_FIRE); toggleFieldOfFire.setSelected(GUIP.getShowFieldOfFire()); - toggleFieldOfFire.setToolTipText(MSG_VIEWTOGGLEFIELDOFFIRETOOLTIP); + toggleFieldOfFire.setToolTipText(msg_viewtogglefieldoffiretooltip); initMenuItem(toggleFiringSolutions, menu, VIEW_TOGGLE_FIRING_SOLUTIONS); - toggleFiringSolutions.setToolTipText(MSG_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(MSG_HELPMENU); + menu = new JMenu(msg_helpmenu); menu.setMnemonic(VK_H); add(menu); initMenuItem(helpContents, menu, HELP_CONTENTS); @@ -519,7 +519,7 @@ public void preferenceChange(PreferenceChangeEvent e) { 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)) { + } else if (e.getName().equals(GUIPreferences.PLAYER_LIST_ENABLED)) { gamePlayerList.setSelected(GUIP.getPlayerListEnabled()); } } diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index bedd9629075..6b07b4c663c 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -275,25 +275,25 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg private int savedFovDarkenAlpha; private int savedNumStripesSlider; - private String msg_reportkeywords = Messages.getString("CommonSettingsDialog.ReportKeywords"); HashMap savedAdvancedOpt = new HashMap<>(); - 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"); + private String msg_reportkeywords = Messages.getString("CommonSettingsDialog.ReportKeywords"); + private String msg_unitdisplay = Messages.getString("CommonMenuBar.viewMekDisplay"); + private String msg_minimap = Messages.getString("CommonMenuBar.viewMinimap"); + private String msg_minireport = Messages.getString("CommonMenuBar.viewRoundReport"); + private String msg_playerlist = Messages.getString("CommonMenuBar.viewPlayerList"); + private String msg_show = Messages.getString("ClientGUI.Show"); + private String msg_hide = Messages.getString("ClientGUI.Hide"); + private String msg_manual = Messages.getString("ClientGUI.Manual"); + private String msg_reportphases = Messages.getString("CommonSettingsDialog.ReportPhases"); + private String msg_nonreportphases = Messages.getString("CommonSettingsDialog.NonReportPhases"); + private String msg_main = Messages.getString("CommonSettingsDialog.Main"); + private String msg_graphics = Messages.getString("CommonSettingsDialog.Graphics"); + private String msg_keybinds = Messages.getString("CommonSettingsDialog.KeyBinds"); + private String msg_buttonorder = Messages.getString("CommonSettingsDialog.ButtonOrder"); + private String msg_unitdisplayorder = Messages.getString("CommonSettingsDialog.UnitDisplayOrder"); + private String msg_autodisplay = Messages.getString("CommonSettingsDialog.AutoDisplay"); + private 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) { @@ -330,13 +330,13 @@ public void windowClosing(WindowEvent e) { JScrollPane autoDisplayPane = new JScrollPane(getPhasePanel()); autoDisplayPane.getVerticalScrollBar().setUnitIncrement(16); - 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); + 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(); @@ -1037,14 +1037,14 @@ protected void okAction() { } } - GUIP.setUnitDisplayAutoDisplayReportPhase((String) unitDisplayAutoDisplayReportCombo.getSelectedItem()); - GUIP.setUnitDisplayAutoDisplayNonReportPhase((String) unitDisplayAutoDisplayNonReportCombo.getSelectedItem()); - GUIP.setMinimapAutoDisplayReportPhase((String) miniMapAutoDisplayReportCombo.getSelectedItem()); - GUIP.setMinimapAutoDisplayNonReportPhase((String) miniMapAutoDisplayNonReportCombo.getSelectedItem()); - GUIP.setMiniReportAutoDisplayReportPhase((String) miniReportAutoDisplayReportCombo.getSelectedItem()); - GUIP.setMiniReportAutoDisplayNonReportPhase((String) miniReportAutoDisplayNonReportCombo.getSelectedItem()); - GUIP.setPlayerListAutoDisplayReportPhase((String) playerListAutoDisplayReportCombo.getSelectedItem()); - GUIP.setPlayerListAutoDisplayNonReportPhase((String) playerListAutoDisplayNonReportCombo.getSelectedItem()); + 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); } @@ -1474,124 +1474,124 @@ private JPanel getPhasePanel() { JPanel outer = new JPanel(); outer.setLayout(new BoxLayout(outer, BoxLayout.PAGE_AXIS)); - JLabel unitDisplayLabel = new JLabel(MSG_UNITDISPLAY); + JLabel unitDisplayLabel = new JLabel(msg_unitdisplay); row = new ArrayList<>(); row.add(unitDisplayLabel); comps.add(row); - JLabel phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); + JLabel phaseLabel = new JLabel(msg_reportphases + ": "); unitDisplayAutoDisplayReportCombo = new JComboBox<>(); - unitDisplayAutoDisplayReportCombo.addItem(MSG_SHOW); - unitDisplayAutoDisplayReportCombo.addItem(MSG_HIDE); - unitDisplayAutoDisplayReportCombo.addItem(MSG_MANUAL); + unitDisplayAutoDisplayReportCombo.addItem(msg_show); + unitDisplayAutoDisplayReportCombo.addItem(msg_hide); + unitDisplayAutoDisplayReportCombo.addItem(msg_manual); unitDisplayAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - unitDisplayAutoDisplayReportCombo.setSelectedItem(GUIP.getUnitDisplayAutoDisplayReportPhase()); + unitDisplayAutoDisplayReportCombo.setSelectedIndex(GUIP.getUnitDisplayAutoDisplayReportPhase()); row.add(phaseLabel); row.add(unitDisplayAutoDisplayReportCombo); comps.add(row); - phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + phaseLabel = new JLabel(msg_nonreportphases + ": "); unitDisplayAutoDisplayNonReportCombo = new JComboBox<>(); - unitDisplayAutoDisplayNonReportCombo.addItem(MSG_SHOW); - unitDisplayAutoDisplayNonReportCombo.addItem(MSG_HIDE); - unitDisplayAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + unitDisplayAutoDisplayNonReportCombo.addItem(msg_show); + unitDisplayAutoDisplayNonReportCombo.addItem(msg_hide); + unitDisplayAutoDisplayNonReportCombo.addItem(msg_manual); unitDisplayAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - unitDisplayAutoDisplayNonReportCombo.setSelectedItem(GUIP.getUnitDisplayAutoDisplayNonReportPhase()); + unitDisplayAutoDisplayNonReportCombo.setSelectedIndex(GUIP.getUnitDisplayAutoDisplayNonReportPhase()); row.add(phaseLabel); row.add(unitDisplayAutoDisplayNonReportCombo); comps.add(row); addLineSpacer(comps); - JLabel miniMapLabel = new JLabel(MSG_MINIMAP); + JLabel miniMapLabel = new JLabel(msg_minimap); row = new ArrayList<>(); row.add(miniMapLabel); comps.add(row); - phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); + phaseLabel = new JLabel(msg_reportphases + ": "); miniMapAutoDisplayReportCombo = new JComboBox<>(); - miniMapAutoDisplayReportCombo.addItem(MSG_SHOW); - miniMapAutoDisplayReportCombo.addItem(MSG_HIDE); - miniMapAutoDisplayReportCombo.addItem(MSG_MANUAL); + miniMapAutoDisplayReportCombo.addItem(msg_show); + miniMapAutoDisplayReportCombo.addItem(msg_hide); + miniMapAutoDisplayReportCombo.addItem(msg_manual); miniMapAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - miniMapAutoDisplayReportCombo.setSelectedItem(GUIP.getMinimapAutoDisplayReportPhase()); + miniMapAutoDisplayReportCombo.setSelectedIndex(GUIP.getMinimapAutoDisplayReportPhase()); row.add(phaseLabel); row.add(miniMapAutoDisplayReportCombo); comps.add(row); - phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + phaseLabel = new JLabel(msg_nonreportphases + ": "); miniMapAutoDisplayNonReportCombo = new JComboBox<>(); - miniMapAutoDisplayNonReportCombo.addItem(MSG_SHOW); - miniMapAutoDisplayNonReportCombo.addItem(MSG_HIDE); - miniMapAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + miniMapAutoDisplayNonReportCombo.addItem(msg_show); + miniMapAutoDisplayNonReportCombo.addItem(msg_hide); + miniMapAutoDisplayNonReportCombo.addItem(msg_manual); miniMapAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - miniMapAutoDisplayNonReportCombo.setSelectedItem(GUIP.getMinimapAutoDisplayNonReportPhase()); + miniMapAutoDisplayNonReportCombo.setSelectedIndex(GUIP.getMinimapAutoDisplayNonReportPhase()); row.add(phaseLabel); row.add(miniMapAutoDisplayNonReportCombo); comps.add(row); addLineSpacer(comps); - JLabel miniReportLabel = new JLabel(MSG_MINIREPORT); + JLabel miniReportLabel = new JLabel(msg_minireport); row = new ArrayList<>(); row.add(miniReportLabel); comps.add(row); - phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); + phaseLabel = new JLabel(msg_reportphases + ": "); miniReportAutoDisplayReportCombo = new JComboBox<>(); - miniReportAutoDisplayReportCombo.addItem(MSG_SHOW); - miniReportAutoDisplayReportCombo.addItem(MSG_HIDE); - miniReportAutoDisplayReportCombo.addItem(MSG_MANUAL); + miniReportAutoDisplayReportCombo.addItem(msg_show); + miniReportAutoDisplayReportCombo.addItem(msg_hide); + miniReportAutoDisplayReportCombo.addItem(msg_manual); miniReportAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - miniReportAutoDisplayReportCombo.setSelectedItem(GUIP.getMiniReportAutoDisplayReportPhase()); + miniReportAutoDisplayReportCombo.setSelectedIndex(GUIP.getMiniReportAutoDisplayReportPhase()); row.add(phaseLabel); row.add(miniReportAutoDisplayReportCombo); comps.add(row); - phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + phaseLabel = new JLabel(msg_nonreportphases + ": "); miniReportAutoDisplayNonReportCombo = new JComboBox<>(); - miniReportAutoDisplayNonReportCombo.addItem(MSG_SHOW); - miniReportAutoDisplayNonReportCombo.addItem(MSG_HIDE); - miniReportAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + miniReportAutoDisplayNonReportCombo.addItem(msg_show); + miniReportAutoDisplayNonReportCombo.addItem(msg_hide); + miniReportAutoDisplayNonReportCombo.addItem(msg_manual); miniReportAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - miniReportAutoDisplayNonReportCombo.setSelectedItem(GUIP.getMiniReportAutoDisplayNonReportPhase()); + miniReportAutoDisplayNonReportCombo.setSelectedIndex(GUIP.getMiniReportAutoDisplayNonReportPhase()); row.add(phaseLabel); row.add(miniReportAutoDisplayNonReportCombo); comps.add(row); addLineSpacer(comps); - JLabel playerListLabel = new JLabel(MSG_PLAYERLIST); + JLabel playerListLabel = new JLabel(msg_playerlist); row = new ArrayList<>(); row.add(playerListLabel); comps.add(row); - phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); + phaseLabel = new JLabel(msg_reportphases + ": "); playerListAutoDisplayReportCombo = new JComboBox<>(); - playerListAutoDisplayReportCombo.addItem(MSG_SHOW); - playerListAutoDisplayReportCombo.addItem(MSG_HIDE); - playerListAutoDisplayReportCombo.addItem(MSG_MANUAL); + playerListAutoDisplayReportCombo.addItem(msg_show); + playerListAutoDisplayReportCombo.addItem(msg_hide); + playerListAutoDisplayReportCombo.addItem(msg_manual); playerListAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - playerListAutoDisplayReportCombo.setSelectedItem(GUIP.getPlayerListAutoDisplayReportPhase()); + playerListAutoDisplayReportCombo.setSelectedIndex(GUIP.getPlayerListAutoDisplayReportPhase()); row.add(phaseLabel); row.add(playerListAutoDisplayReportCombo); comps.add(row); - phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); + phaseLabel = new JLabel(msg_nonreportphases + ": "); playerListAutoDisplayNonReportCombo = new JComboBox<>(); - playerListAutoDisplayNonReportCombo.addItem(MSG_SHOW); - playerListAutoDisplayNonReportCombo.addItem(MSG_HIDE); - playerListAutoDisplayNonReportCombo.addItem(MSG_MANUAL); + playerListAutoDisplayNonReportCombo.addItem(msg_show); + playerListAutoDisplayNonReportCombo.addItem(msg_hide); + playerListAutoDisplayNonReportCombo.addItem(msg_manual); playerListAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); - playerListAutoDisplayNonReportCombo.setSelectedItem(GUIP.getPlayerListAutoDisplayNonReportPhase()); + playerListAutoDisplayNonReportCombo.setSelectedIndex(GUIP.getPlayerListAutoDisplayNonReportPhase()); row.add(phaseLabel); row.add(playerListAutoDisplayNonReportCombo); comps.add(row); diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 5218ef2c09b..e81bbd68d59 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -201,11 +201,11 @@ public class GUIPreferences extends PreferenceStoreProxy { 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 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"; @@ -298,10 +298,6 @@ public class GUIPreferences extends PreferenceStoreProxy { public static String RAT_PAD_BV = "RATPadBV"; public static String RAT_SELECTED_RAT = "RATSelectedRAT"; - 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"); - // common colors public static final Color DEFAULT_WHITE = Color.WHITE; public static final Color DEFAULT_BLACK = Color.BLACK; @@ -347,6 +343,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; } @@ -463,8 +463,8 @@ protected GUIPreferences() { 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, MSG_HIDE); - store.setDefault(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, MSG_SHOW); + 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); @@ -507,8 +507,8 @@ protected GUIPreferences() { store.setDefault(MINI_MAP_COLOURS, "defaultminimap.txt"); store.setDefault(MINI_MAP_ENABLED, true); - store.setDefault(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE, MSG_HIDE); - store.setDefault(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE, MSG_SHOW); + 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); @@ -519,15 +519,15 @@ protected GUIPreferences() { 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, MSG_SHOW); - store.setDefault(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE, MSG_HIDE); + 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, MSG_SHOW); - store.setDefault(PLAYER_lIST_AUTO_DISPLAY_NONREPORT_PHASE, MSG_HIDE); + 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); @@ -728,12 +728,12 @@ public int getUnitDisplayNonTabbedSizeWidth() { return store.getInt(UNIT_DISPLAY_NONTABBED_SIZE_WIDTH); } - public String getUnitDisplayAutoDisplayReportPhase() { - return store.getString(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE); + public int getUnitDisplayAutoDisplayReportPhase() { + return store.getInt(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE); } - public String getUnitDisplayAutoDisplayNonReportPhase() { - return store.getString(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE); + public int getUnitDisplayAutoDisplayNonReportPhase() { + return store.getInt(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE); } public boolean getUnitDisplayEnabled() { @@ -928,12 +928,12 @@ public boolean getMinimapEnabled() { return store.getBoolean(MINI_MAP_ENABLED); } - public String getMinimapAutoDisplayReportPhase() { - return store.getString(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE); + public int getMinimapAutoDisplayReportPhase() { + return store.getInt(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE); } - public String getMinimapAutoDisplayNonReportPhase() { - return store.getString(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE); + public int getMinimapAutoDisplayNonReportPhase() { + return store.getInt(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE); } public int getMinimapPosX() { @@ -952,12 +952,12 @@ public boolean getMiniReportEnabled() { return store.getBoolean(MINI_REPORT_ENABLED); } - public String getMiniReportAutoDisplayReportPhase() { - return store.getString(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE); + public int getMiniReportAutoDisplayReportPhase() { + return store.getInt(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE); } - public String getMiniReportAutoDisplayNonReportPhase() { - return store.getString(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE); + public int getMiniReportAutoDisplayNonReportPhase() { + return store.getInt(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE); } public int getMiniReportLocaton() { @@ -965,23 +965,23 @@ public int getMiniReportLocaton() { } public boolean getPlayerListEnabled() { - return store.getBoolean(PLAYER_lIST_ENABLED); + return store.getBoolean(PLAYER_LIST_ENABLED); } public int getPlayerListPosX() { - return store.getInt(PLAYER_lIST_POS_X); + return store.getInt(PLAYER_LIST_POS_X); } public int getPlayerListPosY() { - return store.getInt(PLAYER_lIST_POS_Y); + return store.getInt(PLAYER_LIST_POS_Y); } - public String getPlayerListAutoDisplayReportPhase() { - return store.getString(PLAYER_lIST_AUTO_DISPLAY_REPORT_PHASE); + public int getPlayerListAutoDisplayReportPhase() { + return store.getInt(PLAYER_LIST_AUTO_DISPLAY_REPORT_PHASE); } - public String getPlayerListAutoDisplayNonReportPhase() { - return store.getString(PLAYER_lIST_AUTO_DISPLAY_NONREPORT_PHASE); + public int getPlayerListAutoDisplayNonReportPhase() { + return store.getInt(PLAYER_LIST_AUTO_DISPLAY_NONREPORT_PHASE); } public boolean getIsometricEnabled() { @@ -1328,12 +1328,12 @@ public void setUnitDisplayNonTabbedSizeWidth(int i) { store.setValue(UNIT_DISPLAY_NONTABBED_SIZE_WIDTH, i); } - public void setUnitDisplayAutoDisplayReportPhase(String s) { - store.setValue(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE, s); + public void setUnitDisplayAutoDisplayReportPhase(int i) { + store.setValue(UNIT_DISPLAY_AUTO_DISPLAY_REPORT_PHASE, i); } - public void setUnitDisplayAutoDisplayNonReportPhase(String s) { - store.setValue(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, s); + public void setUnitDisplayAutoDisplayNonReportPhase(int i) { + store.setValue(UNIT_DISPLAY_AUTO_DISPLAY_NONREPORT_PHASE, i); } public void toggleUnitDisplay() { @@ -1540,12 +1540,12 @@ public void setMinimapZoom(int zoom) { store.setValue(MINI_MAP_ZOOM, zoom); } - public void setMinimapAutoDisplayReportPhase(String s) { - store.setValue(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE, s); + public void setMinimapAutoDisplayReportPhase(int i) { + store.setValue(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE, i); } - public void setMinimapAutoDisplayNonReportPhase(String s) { - store.setValue(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE, s); + public void setMinimapAutoDisplayNonReportPhase(int i) { + store.setValue(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE, i); } public void setMiniReportEnabled(boolean b) { @@ -1564,12 +1564,12 @@ public void setMiniReportPosY(int i) { store.setValue(MINI_REPORT_POS_Y, i); } - public void setMiniReportAutoDisplayReportPhase(String s) { - store.setValue(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE, s); + public void setMiniReportAutoDisplayReportPhase(int i) { + store.setValue(MINI_REPORT_AUTO_DISPLAY_REPORT_PHASE, i); } - public void setMiniReportAutoDisplayNonReportPhase(String s) { - store.setValue(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE, s); + public void setMiniReportAutoDisplayNonReportPhase(int i) { + store.setValue(MINI_REPORT_AUTO_DISPLAY_NONREPORT_PHASE, i); } public void toggleMiniReportLocation() { @@ -1581,7 +1581,7 @@ public void setMiniReportLocation(int i) { } public void setPlayerListEnabled(boolean b) { - store.setValue(PLAYER_lIST_ENABLED, b); + store.setValue(PLAYER_LIST_ENABLED, b); } public void togglePlayerListEnabled() { @@ -1589,19 +1589,19 @@ public void togglePlayerListEnabled() { } public void setPlayerListPosX(int i) { - store.setValue(PLAYER_lIST_POS_X, i); + store.setValue(PLAYER_LIST_POS_X, i); } public void setPlayerListPosY(int i) { - store.setValue(PLAYER_lIST_POS_Y, i); + store.setValue(PLAYER_LIST_POS_Y, i); } - public void setPlayerListAutoDisplayReportPhase(String s) { - store.setValue(PLAYER_lIST_AUTO_DISPLAY_REPORT_PHASE, s); + public void setPlayerListAutoDisplayReportPhase(int i) { + store.setValue(PLAYER_LIST_AUTO_DISPLAY_REPORT_PHASE, i); } - public void setPlayerListAutoDisplayNonReportPhase(String s) { - store.setValue(PLAYER_lIST_AUTO_DISPLAY_NONREPORT_PHASE, s); + public void setPlayerListAutoDisplayNonReportPhase(int i) { + store.setValue(PLAYER_LIST_AUTO_DISPLAY_NONREPORT_PHASE, i); } public void setBoardEditLoadHeight(int i) { diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index d573dad8e86..666a099cee7 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -68,10 +68,7 @@ public class MiniReportDisplay extends JPanel implements ActionListener, Hyperli private static final int MRD_MAXNAMELENGHT = 60; - public MiniReportDisplay(JFrame parent, ClientGUI clientgui) { - super(parent, "", false); - this.setTitle(msg_title); - + public MiniReportDisplay(ClientGUI clientgui) { if (clientgui == null) { return; } @@ -307,11 +304,11 @@ public void addReportPages() { for (int round = 1; round <= numRounds; round++) { String text = currentClient.receiveReport(currentClient.getGame().getReports(round)); - tabs.add(MSG_ROUND + " " + round, loadHtmlScrollPane(text)); + tabs.add(msg_round + " " + round, loadHtmlScrollPane(text)); } // add the new current phase tab - tabs.add(MSG_PHASE, loadHtmlScrollPane(currentClient.phaseReport)); + tabs.add(msg_phase, loadHtmlScrollPane(currentClient.phaseReport)); tabs.setSelectedIndex(tabs.getTabCount() - 1); tabs.setMinimumSize(new Dimension(0, 0)); @@ -358,7 +355,6 @@ public void hyperlinkUpdate(HyperlinkEvent evt) { public void gamePhaseChange(GamePhaseChangeEvent e) { switch (e.getOldPhase()) { case VICTORY: - currentClientgui.getMiniReportDisplayDialog().savePref(); setVisible(false); break; default: diff --git a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java index 016b7524826..cf46d89fd96 100644 --- a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java +++ b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java @@ -41,29 +41,30 @@ public class PlayerListDialog extends JDialog implements ActionListener, IPrefer private Client client; private JButton butOkay; - private boolean model; - - 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 boolean modal; + + private String msg_okay = Messages.getString("Okay"); + private String msg_title = Messages.getString("PlayerListDialog.title"); + private String msg_noteam = Messages.getString("PlayerListDialog.NoTeam"); + private String msg_team = Messages.getString("PlayerListDialog.Team"); + private String msg_teamless = Messages.getString("PlayerListDialog.TeamLess"); + private String msg_player_gm = Messages.getString("PlayerListDialog.player_gm"); + private String msg_player_ghost = Messages.getString("PlayerListDialog.player_ghost"); + private String msg_player_bot = Messages.getString("PlayerListDialog.player_bot"); + private String msg_player_human = Messages.getString("PlayerListDialog.player_human"); + private String msg_player_observer = Messages.getString("PlayerListDialog.player_observer"); + private String msg_player_done = Messages.getString("PlayerListDialog.player_done"); + private String msg_player_seeall = Messages.getString("PlayerListDialog.player_seeall"); + private String msg_player_singleblind = Messages.getString("PlayerListDialog.player_singleblind"); + private String msg_player_ignoredoubleblind = Messages.getString("PlayerListDialog.player_ignoreDoubleBlind"); private static final GUIPreferences GUIP = GUIPreferences.getInstance(); - public PlayerListDialog(JFrame parent, Client client, boolean model) { - super(parent, MSG_TITLE, false); + public PlayerListDialog(JFrame parent, Client client, boolean modal) { + super(parent, "", false); + this.setTitle(msg_title); this.client = client; - this.model = model; + this.modal = modal; client.getGame().addGameListener(gameListener); @@ -71,7 +72,7 @@ public PlayerListDialog(JFrame parent, Client client, boolean model) { add(Box.createHorizontalStrut(20), BorderLayout.LINE_START); add(Box.createHorizontalStrut(20), BorderLayout.LINE_END); - butOkay = new JButton(MSG_OKAY); + butOkay = new JButton(msg_okay); butOkay.addActionListener(this); add(butOkay, BorderLayout.PAGE_END); @@ -93,7 +94,7 @@ public void windowClosing(WindowEvent e) { pack(); setResizable(false); - if (model) { + 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)); @@ -103,7 +104,7 @@ public void windowClosing(WindowEvent e) { } } - public static void refreshPlayerList(JList playerList, + public void refreshPlayerList(JList playerList, Client client) { refreshPlayerList(playerList, client, false); } @@ -112,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(); @@ -124,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(MSG_NOTEAM); + playerDisplay.append(msg_noteam); } else { - playerDisplay.append(MessageFormat.format(MSG_TEAM, team.getId())); + playerDisplay.append(MessageFormat.format(msg_team, team.getId())); } } else { - playerDisplay.append(MSG_TEAMLESS); + playerDisplay.append(msg_teamless); } } if (player.isGameMaster()) { - playerDisplay.append(MSG_PLAYER_GM); + playerDisplay.append(msg_player_gm); } if (player.isGhost()) { - playerDisplay.append(MSG_PLAYER_GHOST); + playerDisplay.append(msg_player_ghost); } else { if (player.isBot()) { - playerDisplay.append(MSG_PLAYER_BOT); + playerDisplay.append(msg_player_bot); } else { - playerDisplay.append(MSG_PLAYER_HUMAN); + playerDisplay.append(msg_player_human); } if (player.isObserver()) { - playerDisplay.append(MSG_PLAYER_OBSERVER); + playerDisplay.append(msg_player_observer); } else if (player.isDone()) { - playerDisplay.append(MSG_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(MSG_PLAYER_SEEALL); + playerDisplay.append(msg_player_seeall); } if (player.getSingleBlind()) { - playerDisplay.append(MSG_PLAYER_SINGLEBLIND); + playerDisplay.append(msg_player_singleblind); } if (player.canIgnoreDoubleBlind()) { - playerDisplay.append(MSG_PLAYER_IGNOREDOUBLEBLIND); + playerDisplay.append(msg_player_ignoredoubleblind); } ((DefaultListModel) playerList.getModel()).addElement(playerDisplay.toString()); @@ -186,9 +187,8 @@ public Player getSelected() { @Override public void actionPerformed(ActionEvent ae) { if (ae.getSource().equals(butOkay)) { - savePref(); setVisible(false); - if (!model) { + if (!modal) { GUIP.setPlayerListEnabled(false); } } @@ -199,7 +199,6 @@ public void actionPerformed(ActionEvent ae) { public void gamePhaseChange(GamePhaseChangeEvent e) { switch (e.getOldPhase()) { case VICTORY: - savePref(); break; default: break; @@ -211,13 +210,10 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) { - savePref(); - } - } - private void savePref() { - if (!model) { - GUIP.setPlayerListPosX(getLocation().x); - GUIP.setPlayerListPosY(getLocation().y); + if (!modal) { + GUIP.setPlayerListPosX(getLocation().x); + GUIP.setPlayerListPosY(getLocation().y); + } } } diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index 0cc2ef333db..5b09a985af8 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -72,7 +72,7 @@ public String toString() { private static final String RD_REPORTDIPLAY = "ReportDisplay."; private static final String RD_TOOLTIP = ".tooltip"; - private static final String MSG_DONE = Messages.getString("ReportDisplay.Done"); + private String msg_done = Messages.getString("ReportDisplay.Done"); /** * Creates and lays out a new movement phase display for the specified @@ -103,7 +103,7 @@ public ReportDisplay(ClientGUI clientgui) { } numButtonGroups = (int) Math.ceil((buttons.size() + 0.0) / buttonsPerGroup); - butDone.setText(MSG_DONE); + butDone.setText(msg_done); butDone.setEnabled(false); setupButtonPanel(); diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index 49bad2350a7..8e2c22d8497 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -196,6 +196,7 @@ public class ChatLounge extends AbstractPhaseDisplay implements private String msg_viewgameboardtooltip = Messages.getString("BoardSelectionDialog.ViewGameBoardTooltip"); private String msg_viewgameboard = Messages.getString("BoardSelectionDialog.ViewGameBoard"); private String msg_fightersquadronbomberror = Messages.getString("FighterSquadron.bomberror"); + private String msg_mapsetupxmlfiles = Messages.getString("ChatLounge.map.SetupXMLfiles"); private JTabbedPane panTabs = new JTabbedPane(); private JPanel panUnits = new JPanel(); @@ -346,8 +347,6 @@ public class ChatLounge extends AbstractPhaseDisplay implements private static final String CL_ACTIONCOMMAND_CONFIGURE = "CONFIGURE"; private static final String CL_ACTIONCOMMAND_CAMO= "camo"; - 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(), @@ -2157,7 +2156,7 @@ public boolean accept(File f) { @Override public String getDescription() { - return MSG_MAPSETUPXMLFILES; + return msg_mapsetupxmlfiles; } }; diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index 33b95904d8a..880bf4ebe49 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -93,8 +93,8 @@ public class UnitDisplay extends JPanel implements IPreferenceChangeListener { 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 String msg_switchlocation = Messages.getString("UnitDisplay.SwitchLocation"); + private String msg_switchview = Messages.getString("UnitDisplay.SwitchView"); private static final GUIPreferences GUIP = GUIPreferences.getInstance(); private static final UnitDisplayOrderPreferences UDOP = UnitDisplayOrderPreferences.getInstance(); @@ -162,8 +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(MSG_SWITCHVIEW); - butSwitchLocation = new JButton(MSG_SWITCHLOCATION); + butSwitchView = new JButton(msg_switchview); + butSwitchLocation = new JButton(msg_switchlocation); splitABC.setOneTouchExpandable(true); splitBC.setOneTouchExpandable(true); From 1b46626aeeb352d946b3f44609605ba99e5a880b Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 10 Jan 2023 13:07:01 -0500 Subject: [PATCH 46/47] show game board in all the game phases 46 --- .../client/ui/swing/CommonSettingsDialog.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index 6b07b4c663c..163fc61846b 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -1481,8 +1481,8 @@ private JPanel getPhasePanel() { JLabel phaseLabel = new JLabel(msg_reportphases + ": "); unitDisplayAutoDisplayReportCombo = new JComboBox<>(); - unitDisplayAutoDisplayReportCombo.addItem(msg_show); unitDisplayAutoDisplayReportCombo.addItem(msg_hide); + unitDisplayAutoDisplayReportCombo.addItem(msg_show); unitDisplayAutoDisplayReportCombo.addItem(msg_manual); unitDisplayAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); @@ -1493,8 +1493,8 @@ private JPanel getPhasePanel() { phaseLabel = new JLabel(msg_nonreportphases + ": "); unitDisplayAutoDisplayNonReportCombo = new JComboBox<>(); - unitDisplayAutoDisplayNonReportCombo.addItem(msg_show); unitDisplayAutoDisplayNonReportCombo.addItem(msg_hide); + unitDisplayAutoDisplayNonReportCombo.addItem(msg_show); unitDisplayAutoDisplayNonReportCombo.addItem(msg_manual); unitDisplayAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); @@ -1512,8 +1512,8 @@ private JPanel getPhasePanel() { phaseLabel = new JLabel(msg_reportphases + ": "); miniMapAutoDisplayReportCombo = new JComboBox<>(); - miniMapAutoDisplayReportCombo.addItem(msg_show); miniMapAutoDisplayReportCombo.addItem(msg_hide); + miniMapAutoDisplayReportCombo.addItem(msg_show); miniMapAutoDisplayReportCombo.addItem(msg_manual); miniMapAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); @@ -1524,8 +1524,8 @@ private JPanel getPhasePanel() { phaseLabel = new JLabel(msg_nonreportphases + ": "); miniMapAutoDisplayNonReportCombo = new JComboBox<>(); - miniMapAutoDisplayNonReportCombo.addItem(msg_show); miniMapAutoDisplayNonReportCombo.addItem(msg_hide); + miniMapAutoDisplayNonReportCombo.addItem(msg_show); miniMapAutoDisplayNonReportCombo.addItem(msg_manual); miniMapAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); @@ -1543,8 +1543,8 @@ private JPanel getPhasePanel() { phaseLabel = new JLabel(msg_reportphases + ": "); miniReportAutoDisplayReportCombo = new JComboBox<>(); - miniReportAutoDisplayReportCombo.addItem(msg_show); miniReportAutoDisplayReportCombo.addItem(msg_hide); + miniReportAutoDisplayReportCombo.addItem(msg_show); miniReportAutoDisplayReportCombo.addItem(msg_manual); miniReportAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); @@ -1555,8 +1555,8 @@ private JPanel getPhasePanel() { phaseLabel = new JLabel(msg_nonreportphases + ": "); miniReportAutoDisplayNonReportCombo = new JComboBox<>(); - miniReportAutoDisplayNonReportCombo.addItem(msg_show); miniReportAutoDisplayNonReportCombo.addItem(msg_hide); + miniReportAutoDisplayNonReportCombo.addItem(msg_show); miniReportAutoDisplayNonReportCombo.addItem(msg_manual); miniReportAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); @@ -1574,8 +1574,8 @@ private JPanel getPhasePanel() { phaseLabel = new JLabel(msg_reportphases + ": "); playerListAutoDisplayReportCombo = new JComboBox<>(); - playerListAutoDisplayReportCombo.addItem(msg_show); playerListAutoDisplayReportCombo.addItem(msg_hide); + playerListAutoDisplayReportCombo.addItem(msg_show); playerListAutoDisplayReportCombo.addItem(msg_manual); playerListAutoDisplayReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); @@ -1586,8 +1586,8 @@ private JPanel getPhasePanel() { phaseLabel = new JLabel(msg_nonreportphases + ": "); playerListAutoDisplayNonReportCombo = new JComboBox<>(); - playerListAutoDisplayNonReportCombo.addItem(msg_show); playerListAutoDisplayNonReportCombo.addItem(msg_hide); + playerListAutoDisplayNonReportCombo.addItem(msg_show); playerListAutoDisplayNonReportCombo.addItem(msg_manual); playerListAutoDisplayNonReportCombo.setMaximumSize(new Dimension(150, 40)); row = new ArrayList<>(); From 14605bf19787dcc44a0e9e7c6a743f8701a40128 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Thu, 12 Jan 2023 11:40:55 -0500 Subject: [PATCH 47/47] show game boarad in all game phases 47 --- .../ui/dialogs/MiniReportDisplayDialog.java | 4 +- .../client/ui/dialogs/UnitDisplayDialog.java | 4 +- .../megamek/client/ui/swing/ClientGUI.java | 3 +- .../client/ui/swing/CommonMenuBar.java | 44 +++---- .../client/ui/swing/CommonSettingsDialog.java | 118 +++++++++--------- .../client/ui/swing/MiniReportDisplay.java | 4 +- .../client/ui/swing/PlayerListDialog.java | 56 ++++----- .../client/ui/swing/ReportDisplay.java | 4 +- .../client/ui/swing/lobby/ChatLounge.java | 4 +- .../ui/swing/unitDisplay/UnitDisplay.java | 8 +- 10 files changed, 126 insertions(+), 123 deletions(-) diff --git a/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java b/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java index 6452d6cc587..95541fb0c70 100644 --- a/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java +++ b/megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java @@ -32,13 +32,13 @@ public class MiniReportDisplayDialog extends JDialog { //region Variable Declarations private final ClientGUI clientGUI; private static final GUIPreferences GUIP = GUIPreferences.getInstance(); - private String msg_title = Messages.getString("MiniReportDisplay.title"); + 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.setTitle(MSG_TITLE); this.setLocation(GUIP.getMiniReportPosX(), GUIP.getMiniReportPosY()); this.setSize(GUIP.getMiniReportSizeWidth(), GUIP.getMiniReportSizeHeight()); diff --git a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java index 87528dc1f03..71fcf92a7e8 100644 --- a/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java +++ b/megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java @@ -32,14 +32,14 @@ public class UnitDisplayDialog extends JDialog { //region Variable Declarations private final ClientGUI clientGUI; - private String msg_title = Messages.getString("ClientGUI.MechDisplay"); + 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 ClientGUI clientGUI) { super(frame, "", false); - this.setTitle(msg_title); + this.setTitle(MSG_TITLE); if (GUIP.getUnitDisplayStartTabbed()) { this.setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY()); diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index e7071c35edb..c97f7287af6 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -222,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"); @@ -457,7 +458,7 @@ private void loadSoundClip() { } final File file = new File(GUIP.getSoundBingFilename()); if (!file.exists()) { - LogManager.getLogger().error(msg_failedtoloadaudifile + " " + GUIP.getSoundBingFilename()); + LogManager.getLogger().error(MSG_FAILEDTOLOADAUDIFILE + " " + GUIP.getSoundBingFilename()); return; } diff --git a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java index 848abae1142..cec536e7f1c 100644 --- a/megamek/src/megamek/client/ui/swing/CommonMenuBar.java +++ b/megamek/src/megamek/client/ui/swing/CommonMenuBar.java @@ -137,17 +137,17 @@ public class CommonMenuBar extends JMenuBar implements ActionListener, IPreferen /** Maps the Action Command to the respective MenuItem. */ private final Map itemMap = new HashMap<>(); - private String msg_filemenu = Messages.getString("CommonMenuBar.FileMenu"); - private String msg_gamemenu = Messages.getString("CommonMenuBar.GameMenu"); - private String msg_boardmenu = Messages.getString("CommonMenuBar.BoardMenu"); - private String msg_fileboardsaveasimage_tooltip = Messages.getString("CommonMenuBar.fileBoardSaveAsImage.tooltip"); - private String msg_fileboardsaveasimageunits_tooltip = Messages.getString("CommonMenuBar.fileBoardSaveAsImageUnits.tooltip"); - private String msg_boardremove = Messages.getString("CommonMenuBar.boardRemove"); - private String msg_viewmenu = Messages.getString("CommonMenuBar.ViewMenu"); - private String msg_viewtogglefovdarkentooltip = Messages.getString("CommonMenuBar.viewToggleFovDarkenTooltip"); - private String msg_viewtogglefieldoffiretooltip = Messages.getString("CommonMenuBar.viewToggleFieldOfFireToolTip"); - private String msg_viewtogglefiringsolutionstooltip = Messages.getString("CommonMenuBar.viewToggleFiringSolutionsToolTip"); - private String msg_helpmenu = Messages.getString("CommonMenuBar.HelpMenu"); + 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) { @@ -173,7 +173,7 @@ public CommonMenuBar(MegaMekGUI mmg) { /** Creates the common MegaMek menu bar. */ public CommonMenuBar() { // Create the Game menu - JMenu menu = new JMenu(msg_filemenu); + JMenu menu = new JMenu(MSG_FILEMENU); menu.setMnemonic(VK_F); add(menu); initMenuItem(gameLoad, menu, FILE_GAME_LOAD, VK_L); @@ -183,7 +183,7 @@ public CommonMenuBar() { initMenuItem(gameSaveServer, menu, FILE_GAME_SAVE_SERVER); // Create the Unit List sub-menu. - menu = new JMenu(msg_gamemenu); + menu = new JMenu(MSG_GAMEMENU); add(menu); menu.setMnemonic(VK_G); @@ -208,7 +208,7 @@ public CommonMenuBar() { initMenuItem(fireSaveWeaponOrder, menu, FIRE_SAVE_WEAPON_ORDER); // Create the Board sub-menu. - menu = new JMenu(msg_boardmenu); + menu = new JMenu(MSG_BOARDMENU); menu.setMnemonic(VK_B); add(menu); initMenuItem(boardNew, menu, BOARD_NEW); @@ -220,9 +220,9 @@ public CommonMenuBar() { menu.addSeparator(); initMenuItem(boardSaveAsImage, menu, BOARD_SAVE_AS_IMAGE); - boardSaveAsImage.setToolTipText(msg_fileboardsaveasimage_tooltip); + boardSaveAsImage.setToolTipText(MSG_FILEBOARDSAVEASIMAGE_TOOLTIP); initMenuItem(boardSaveAsImageUnits, menu, BOARD_SAVE_AS_IMAGE_UNITS); - boardSaveAsImageUnits.setToolTipText(msg_fileboardsaveasimageunits_tooltip); + boardSaveAsImageUnits.setToolTipText(MSG_FILEBOARDSAVEASIMAGEUNITS_TOOLTIP); menu.addSeparator(); initMenuItem(boardUndo, menu, BOARD_UNDO); @@ -235,7 +235,7 @@ public CommonMenuBar() { initMenuItem(boardClear, menu, BOARD_CLEAR); initMenuItem(boardFlatten, menu, BOARD_FLATTEN); initMenuItem(boardFlood, menu, BOARD_FLOOD); - boardRemove = new JMenu(msg_boardremove); + boardRemove = new JMenu(MSG_BOARDREMOVE); menu.add(boardRemove); initMenuItem(boardRemoveForests, boardRemove, BOARD_REMOVE_FORESTS); initMenuItem(boardRemoveWater, boardRemove, BOARD_REMOVE_WATER); @@ -243,7 +243,7 @@ public CommonMenuBar() { initMenuItem(boardRemoveBuildings, boardRemove, BOARD_REMOVE_BUILDINGS); // Create the view menu. - menu = new JMenu(msg_viewmenu); + menu = new JMenu(MSG_VIEWMENU); menu.setMnemonic(VK_V); add(menu); initMenuItem(viewClientSettings, menu, VIEW_CLIENT_SETTINGS, VK_S); @@ -288,7 +288,7 @@ public CommonMenuBar() { initMenuItem(toggleFovDarken, menu, VIEW_TOGGLE_FOV_DARKEN); toggleFovDarken.setSelected(GUIP.getFovDarken()); - toggleFovDarken.setToolTipText(msg_viewtogglefovdarkentooltip); + toggleFovDarken.setToolTipText(MSG_VIEWTOGGLEFOVDARKENTOOLTIP); initMenuItem(viewLOSSetting, menu, VIEW_LOS_SETTING); initMenuItem(toggleFovHighlight, menu, VIEW_TOGGLE_FOV_HIGHLIGHT); toggleFovHighlight.setSelected(GUIP.getFovHighlight()); @@ -299,15 +299,15 @@ public CommonMenuBar() { initMenuItem(toggleFieldOfFire, menu, VIEW_TOGGLE_FIELD_OF_FIRE); toggleFieldOfFire.setSelected(GUIP.getShowFieldOfFire()); - toggleFieldOfFire.setToolTipText(msg_viewtogglefieldoffiretooltip); + toggleFieldOfFire.setToolTipText(MSG_VIEWTOGGLEFIELDOFFIRETOOLTIP); initMenuItem(toggleFiringSolutions, menu, VIEW_TOGGLE_FIRING_SOLUTIONS); - toggleFiringSolutions.setToolTipText(msg_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(msg_helpmenu); + menu = new JMenu(MSG_HELPMENU); menu.setMnemonic(VK_H); add(menu); initMenuItem(helpContents, menu, HELP_CONTENTS); diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index e347b9398aa..d6d9e0ec3af 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -278,22 +278,22 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg HashMap savedAdvancedOpt = new HashMap<>(); private static final String MSG_REPORTKEYWORDS = Messages.getString("CommonSettingsDialog.ReportKeywords"); - private String msg_unitdisplay = Messages.getString("CommonMenuBar.viewMekDisplay"); - private String msg_minimap = Messages.getString("CommonMenuBar.viewMinimap"); - private String msg_minireport = Messages.getString("CommonMenuBar.viewRoundReport"); - private String msg_playerlist = Messages.getString("CommonMenuBar.viewPlayerList"); - private String msg_show = Messages.getString("ClientGUI.Show"); - private String msg_hide = Messages.getString("ClientGUI.Hide"); - private String msg_manual = Messages.getString("ClientGUI.Manual"); - private String msg_reportphases = Messages.getString("CommonSettingsDialog.ReportPhases"); - private String msg_nonreportphases = Messages.getString("CommonSettingsDialog.NonReportPhases"); - private String msg_main = Messages.getString("CommonSettingsDialog.Main"); - private String msg_graphics = Messages.getString("CommonSettingsDialog.Graphics"); - private String msg_keybinds = Messages.getString("CommonSettingsDialog.KeyBinds"); - private String msg_buttonorder = Messages.getString("CommonSettingsDialog.ButtonOrder"); - private String msg_unitdisplayorder = Messages.getString("CommonSettingsDialog.UnitDisplayOrder"); - private String msg_autodisplay = Messages.getString("CommonSettingsDialog.AutoDisplay"); - private String msg_advanced = Messages.getString("CommonSettingsDialog.Advanced"); + 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) { @@ -330,13 +330,13 @@ public void windowClosing(WindowEvent e) { JScrollPane autoDisplayPane = new JScrollPane(getPhasePanel()); autoDisplayPane.getVerticalScrollBar().setUnitIncrement(16); - 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); + 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(); @@ -1474,16 +1474,16 @@ private JPanel getPhasePanel() { JPanel outer = new JPanel(); outer.setLayout(new BoxLayout(outer, BoxLayout.PAGE_AXIS)); - JLabel unitDisplayLabel = new JLabel(msg_unitdisplay); + JLabel unitDisplayLabel = new JLabel(MSG_UNITDISPLAY); row = new ArrayList<>(); row.add(unitDisplayLabel); comps.add(row); - JLabel phaseLabel = new JLabel(msg_reportphases + ": "); + JLabel phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); unitDisplayAutoDisplayReportCombo = new JComboBox<>(); - unitDisplayAutoDisplayReportCombo.addItem(msg_hide); - unitDisplayAutoDisplayReportCombo.addItem(msg_show); - unitDisplayAutoDisplayReportCombo.addItem(msg_manual); + 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()); @@ -1491,11 +1491,11 @@ private JPanel getPhasePanel() { row.add(unitDisplayAutoDisplayReportCombo); comps.add(row); - phaseLabel = new JLabel(msg_nonreportphases + ": "); + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); unitDisplayAutoDisplayNonReportCombo = new JComboBox<>(); - unitDisplayAutoDisplayNonReportCombo.addItem(msg_hide); - unitDisplayAutoDisplayNonReportCombo.addItem(msg_show); - unitDisplayAutoDisplayNonReportCombo.addItem(msg_manual); + 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()); @@ -1505,16 +1505,16 @@ private JPanel getPhasePanel() { addLineSpacer(comps); - JLabel miniMapLabel = new JLabel(msg_minimap); + JLabel miniMapLabel = new JLabel(MSG_MINIMAP); row = new ArrayList<>(); row.add(miniMapLabel); comps.add(row); - phaseLabel = new JLabel(msg_reportphases + ": "); + phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); miniMapAutoDisplayReportCombo = new JComboBox<>(); - miniMapAutoDisplayReportCombo.addItem(msg_hide); - miniMapAutoDisplayReportCombo.addItem(msg_show); - miniMapAutoDisplayReportCombo.addItem(msg_manual); + 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()); @@ -1522,11 +1522,11 @@ private JPanel getPhasePanel() { row.add(miniMapAutoDisplayReportCombo); comps.add(row); - phaseLabel = new JLabel(msg_nonreportphases + ": "); + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); miniMapAutoDisplayNonReportCombo = new JComboBox<>(); - miniMapAutoDisplayNonReportCombo.addItem(msg_hide); - miniMapAutoDisplayNonReportCombo.addItem(msg_show); - miniMapAutoDisplayNonReportCombo.addItem(msg_manual); + 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()); @@ -1536,16 +1536,16 @@ private JPanel getPhasePanel() { addLineSpacer(comps); - JLabel miniReportLabel = new JLabel(msg_minireport); + JLabel miniReportLabel = new JLabel(MSG_MINIREPORT); row = new ArrayList<>(); row.add(miniReportLabel); comps.add(row); - phaseLabel = new JLabel(msg_reportphases + ": "); + phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); miniReportAutoDisplayReportCombo = new JComboBox<>(); - miniReportAutoDisplayReportCombo.addItem(msg_hide); - miniReportAutoDisplayReportCombo.addItem(msg_show); - miniReportAutoDisplayReportCombo.addItem(msg_manual); + 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()); @@ -1553,11 +1553,11 @@ private JPanel getPhasePanel() { row.add(miniReportAutoDisplayReportCombo); comps.add(row); - phaseLabel = new JLabel(msg_nonreportphases + ": "); + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); miniReportAutoDisplayNonReportCombo = new JComboBox<>(); - miniReportAutoDisplayNonReportCombo.addItem(msg_hide); - miniReportAutoDisplayNonReportCombo.addItem(msg_show); - miniReportAutoDisplayNonReportCombo.addItem(msg_manual); + 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()); @@ -1567,16 +1567,16 @@ private JPanel getPhasePanel() { addLineSpacer(comps); - JLabel playerListLabel = new JLabel(msg_playerlist); + JLabel playerListLabel = new JLabel(MSG_PLAYERLIST); row = new ArrayList<>(); row.add(playerListLabel); comps.add(row); - phaseLabel = new JLabel(msg_reportphases + ": "); + phaseLabel = new JLabel(MSG_REPORTPHASES + ": "); playerListAutoDisplayReportCombo = new JComboBox<>(); - playerListAutoDisplayReportCombo.addItem(msg_hide); - playerListAutoDisplayReportCombo.addItem(msg_show); - playerListAutoDisplayReportCombo.addItem(msg_manual); + 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()); @@ -1584,11 +1584,11 @@ private JPanel getPhasePanel() { row.add(playerListAutoDisplayReportCombo); comps.add(row); - phaseLabel = new JLabel(msg_nonreportphases + ": "); + phaseLabel = new JLabel(MSG_NONREPORTPHASES + ": "); playerListAutoDisplayNonReportCombo = new JComboBox<>(); - playerListAutoDisplayNonReportCombo.addItem(msg_hide); - playerListAutoDisplayNonReportCombo.addItem(msg_show); - playerListAutoDisplayNonReportCombo.addItem(msg_manual); + 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()); diff --git a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java index d42f7b34a40..16ae0d01c68 100644 --- a/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MiniReportDisplay.java @@ -304,11 +304,11 @@ public void addReportPages() { for (int round = 1; round <= numRounds; round++) { String text = currentClient.receiveReport(currentClient.getGame().getReports(round)); - tabs.add(msg_round + " " + round, loadHtmlScrollPane(text)); + tabs.add(MSG_ROUND + " " + round, loadHtmlScrollPane(text)); } // add the new current phase tab - tabs.add(msg_phase, loadHtmlScrollPane(currentClient.phaseReport)); + tabs.add(MSG_PHASE, loadHtmlScrollPane(currentClient.phaseReport)); tabs.setSelectedIndex(tabs.getTabCount() - 1); tabs.setMinimumSize(new Dimension(0, 0)); diff --git a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java index cf46d89fd96..37830ad17e3 100644 --- a/megamek/src/megamek/client/ui/swing/PlayerListDialog.java +++ b/megamek/src/megamek/client/ui/swing/PlayerListDialog.java @@ -43,26 +43,26 @@ public class PlayerListDialog extends JDialog implements ActionListener, IPrefer private JButton butOkay; private boolean modal; - private String msg_okay = Messages.getString("Okay"); - private String msg_title = Messages.getString("PlayerListDialog.title"); - private String msg_noteam = Messages.getString("PlayerListDialog.NoTeam"); - private String msg_team = Messages.getString("PlayerListDialog.Team"); - private String msg_teamless = Messages.getString("PlayerListDialog.TeamLess"); - private String msg_player_gm = Messages.getString("PlayerListDialog.player_gm"); - private String msg_player_ghost = Messages.getString("PlayerListDialog.player_ghost"); - private String msg_player_bot = Messages.getString("PlayerListDialog.player_bot"); - private String msg_player_human = Messages.getString("PlayerListDialog.player_human"); - private String msg_player_observer = Messages.getString("PlayerListDialog.player_observer"); - private String msg_player_done = Messages.getString("PlayerListDialog.player_done"); - private String msg_player_seeall = Messages.getString("PlayerListDialog.player_seeall"); - private String msg_player_singleblind = Messages.getString("PlayerListDialog.player_singleblind"); - private String msg_player_ignoredoubleblind = Messages.getString("PlayerListDialog.player_ignoreDoubleBlind"); + 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.setTitle(MSG_TITLE); this.client = client; this.modal = modal; @@ -72,7 +72,7 @@ public PlayerListDialog(JFrame parent, Client client, boolean modal) { add(Box.createHorizontalStrut(20), BorderLayout.LINE_START); add(Box.createHorizontalStrut(20), BorderLayout.LINE_END); - butOkay = new JButton(msg_okay); + butOkay = new JButton(MSG_OKAY); butOkay.addActionListener(this); add(butOkay, BorderLayout.PAGE_END); @@ -125,46 +125,46 @@ public void refreshPlayerList(JList playerList, Team team = client.getGame().getTeamForPlayer(player); if (team != null) { if (team.getId() == Player.TEAM_NONE) { - playerDisplay.append(msg_noteam); + playerDisplay.append(MSG_NOTEAM); } else { - playerDisplay.append(MessageFormat.format(msg_team, team.getId())); + playerDisplay.append(MessageFormat.format(MSG_TEAM, team.getId())); } } else { - playerDisplay.append(msg_teamless); + playerDisplay.append(MSG_TEAMLESS); } } if (player.isGameMaster()) { - playerDisplay.append(msg_player_gm); + playerDisplay.append(MSG_PLAYER_GM); } if (player.isGhost()) { - playerDisplay.append(msg_player_ghost); + playerDisplay.append(MSG_PLAYER_GHOST); } else { if (player.isBot()) { - playerDisplay.append(msg_player_bot); + playerDisplay.append(MSG_PLAYER_BOT); } else { - playerDisplay.append(msg_player_human); + playerDisplay.append(MSG_PLAYER_HUMAN); } if (player.isObserver()) { - playerDisplay.append(msg_player_observer); + playerDisplay.append(MSG_PLAYER_OBSERVER); } else if (player.isDone()) { - playerDisplay.append(msg_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(msg_player_seeall); + playerDisplay.append(MSG_PLAYER_SEEALL); } if (player.getSingleBlind()) { - playerDisplay.append(msg_player_singleblind); + playerDisplay.append(MSG_PLAYER_SINGLEBLIND); } if (player.canIgnoreDoubleBlind()) { - playerDisplay.append(msg_player_ignoredoubleblind); + playerDisplay.append(MSG_PLAYER_IGNOREDOUBLEBLIND); } ((DefaultListModel) playerList.getModel()).addElement(playerDisplay.toString()); diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index 21701e41a0f..e787eda4bb4 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -72,7 +72,7 @@ public String toString() { private static final String RD_REPORTDIPLAY = "ReportDisplay."; private static final String RD_TOOLTIP = ".tooltip"; - private String msg_done = Messages.getString("ReportDisplay.Done"); + private static final String MSG_DONE = Messages.getString("ReportDisplay.Done"); /** * Creates and lays out a new movement phase display for the specified @@ -103,7 +103,7 @@ public ReportDisplay(ClientGUI clientgui) { } numButtonGroups = (int) Math.ceil((buttons.size() + 0.0) / buttonsPerGroup); - butDone.setText(msg_done); + butDone.setText(MSG_DONE); butDone.setEnabled(false); setupButtonPanel(); diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index b4d9640e061..fcc4d3dc5af 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -346,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(), @@ -2155,7 +2157,7 @@ public boolean accept(File f) { @Override public String getDescription() { - return msg_mapsetupxmlfiles; + return MSG_MAPSETUPXMLFILES; } }; diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java index 880bf4ebe49..33b95904d8a 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java @@ -93,8 +93,8 @@ public class UnitDisplay extends JPanel implements IPreferenceChangeListener { public static final int NON_TABBED_FOUR_INDEX = 4; public static final int NON_TABBED_FIVE_INDEX = 5; - private String msg_switchlocation = Messages.getString("UnitDisplay.SwitchLocation"); - private String msg_switchview = Messages.getString("UnitDisplay.SwitchView"); + 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(); @@ -162,8 +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(msg_switchview); - butSwitchLocation = new JButton(msg_switchlocation); + butSwitchView = new JButton(MSG_SWITCHVIEW); + butSwitchLocation = new JButton(MSG_SWITCHLOCATION); splitABC.setOneTouchExpandable(true); splitBC.setOneTouchExpandable(true);