Skip to content

Commit

Permalink
Merge pull request #4030 from kuronekochomusuke/boardAllTheTime
Browse files Browse the repository at this point in the history
show game board in all the game phases
  • Loading branch information
HammerGS authored Jan 13, 2023
2 parents 68b8350 + da5523a commit 7ef3099
Show file tree
Hide file tree
Showing 31 changed files with 2,066 additions and 1,236 deletions.
30 changes: 24 additions & 6 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ AdvancedOptions.PlanetaryConditionsShowLabels.name=Planetary Conditions Show Lab
AdvancedOptions.PlanetaryConditionsShowValues.name=Planetary Conditions Show Values
AdvancedOptions.PlanetaryConditionsShowIndicators.name=Planetary Conditions Show Indicators
AdvancedOptions.UnitToolTipSeenByResolution.name=UnitToolTip - Seen By Resolution [1=Someone,2=Team,3=Player]
AdvancedOptions.DockOnLeft.name=Dock on left side of the board
AdvancedOptions.DockMultipleOnYAxis.name=Dock multiple panels using the y axis

#Board Editor
BoardEditor.BridgeBuildingElevError=Bridge/Building Elevation is an offset from the surface of a hex and hence must be a positive value!
Expand Down Expand Up @@ -771,6 +773,7 @@ ChatLounge.SearchlightToggleOff=Remove searchlight(s)
ChatLounge.SearchlightToggleOn=Add searchlight(s)
ChatLounge.SelectBo=Please select a bot you control from the player list.
ChatLounge.SelectBotOrPlayer=Please select a bot you control or your player from the player list.
ChatLounge.map.SetupXMLfiles=Map Setup XML files
ChatLounge.SPACE=SPACE
ChatLounge.spaceMap=Space Map
ChatLounge.TechLevel=Tech Level:
Expand Down Expand Up @@ -848,6 +851,7 @@ ClientGUI.errorLoadingFile=Error Loading File
ClientGUI.errorOpeningFileToSave=Error opening file to save!
ClientGUI.errorSavingFile=Error Saving File
ClientGUI.errorSelectingPlayer=Error selecting player
ClientGUI.failedToLoadAudioFile=Failed to load audio file named
ClientGUI.FatalError.message=Could not initialise:\n
ClientGUI.FatalError.message1=Could not initialise minimap:\n
ClientGUI.FatalError.title=Fatal Error
Expand All @@ -856,6 +860,8 @@ ClientGUI.FileSaveServerDialog.title=Select file to save to...
ClientGUI.FileSaveServerDialog.message=Please enter the filename under which the game will be saved to in the server's savegames directory.
ClientGUI.gameSaveDialogMessage=Do you want to save the game before quitting MegaMek?
ClientGUI.gameSaveFirst=Save First?
ClientGUI.Hide=Hide
ClientGUI.Manual=Manual
ClientGUI.MechDisplay=Mech Display
ClientGUI.mechSelectorDialog=Mech Selector Dialog
ClientGUI.Minimap=Minimap
Expand All @@ -872,6 +878,7 @@ ClientGUI.selectMenuItem=Select
ClientGUI.skinningHelpPath=docs/help/en/skinning/skinningHowTo.html
ClientGUI.skinningHelpPath.title=How To: Skinning
ClientGUI.StartingScenario=Starting scenario...
ClientGUI.Show=Show
ClientGUI.targetMenuItem=Target
ClientGUI.title=MegaMek Client
ClientGUI.TransmittingData=Transmitting game data...
Expand Down Expand Up @@ -1156,7 +1163,15 @@ CommonSettingsDialog.useSoftCenter=Use smooth transitioning when selecting units
CommonSettingsDialog.useSoftCenterTip=Instead of an instant snap, the view is smoothly transitioned
CommonSettingsDialog.showIPAddressesInChat=Show IP Addresses in Chat (WARNING: Security Sensitive)
CommonSettingsDialog.showIPAddressesInChat.tooltip=<html>If enabled, all server and client IP addresses will be logged in the public chat box.<br>Enabling this can allow information disclosure, such as private IP addresses of the server.</html>

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

Expand Down Expand Up @@ -2028,6 +2043,7 @@ MiniReportDisplay.Round=Round
MiniReportDisplay.Phase=Phase
MiniReportDisplay.ArrowUp=\u25B2
MiniReportDisplay.ArrowDown=\u25BC
MiniReportDisplay.SwitchLocation=switch location

#Assorted Movement Phase Display Text for buttons, nags, dialogs...
MovementDisplay.AbandonDialog.message=Do you want to abandon this unit?
Expand Down Expand Up @@ -3091,11 +3107,10 @@ RandomNameDialog.lblHistoricalEthnicity.toolTipText=This will generate a random

#Report Display
ReportDisplay.Done=Done
ReportDisplay.Reroll=Reroll
ReportDisplay.Details=Details
ReportDisplay.Round=Round
ReportDisplay.Phase=Phase

ReportDisplay.reportReport=Report
ReportDisplay.reportPlayerList=Player List
ReportDisplay.reportRerollInitiative=Reroll Initiative
ReportDisplay.reportRerollInitiative.tooltip=Pilot with Tactical Genius can reroll initiative in the Initiative Phase
#Ruler
Ruler.Close=Close
Ruler.Distance=Distance:
Expand Down Expand Up @@ -3159,6 +3174,9 @@ TriggerBPodDialog.title=Trigger ABA Pods
TriggerBPodDialog.ChooseTargetDialog.message=Hex {0} contains the following targets.\n\nWhich target do you want to attack?"
TriggerBPodDialog.ChooseTargetDialog.title=Choose Target

UnitDisplay.SwitchLocation=switch location
UnitDisplay.SwitchView=switch view

#Unit Editor Dialog
UnitEditorDialog.avionics=Avionics
UnitEditorDialog.bayCrit=%s Bay # %d
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/client/bot/BotClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ private void toggleStealth() {
*/
public void doAlertDialog(String title, String message) {
JTextPane textArea = new JTextPane();
ReportDisplay.setupStylesheet(textArea);
Report.setupStylesheet(textArea);

textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea,
Expand Down
89 changes: 89 additions & 0 deletions megamek/src/megamek/client/ui/dialogs/MiniReportDisplayDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2022 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/
package megamek.client.ui.dialogs;

import megamek.client.ui.Messages;
import megamek.client.ui.swing.ClientGUI;
import megamek.client.ui.swing.GUIPreferences;
import megamek.client.ui.swing.util.UIUtil;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class MiniReportDisplayDialog extends JDialog {
//region Variable Declarations
private final ClientGUI clientGUI;
private static final GUIPreferences GUIP = GUIPreferences.getInstance();
private static final String MSG_TITLE = Messages.getString("MiniReportDisplay.title");
//endregion Variable Declarations

//region Constructors
public MiniReportDisplayDialog(final JFrame frame, final ClientGUI clientGUI) {
super(frame, "", false);
this.setTitle(MSG_TITLE);

this.setLocation(GUIP.getMiniReportPosX(), GUIP.getMiniReportPosY());
this.setSize(GUIP.getMiniReportSizeWidth(), GUIP.getMiniReportSizeHeight());

UIUtil.updateWindowBounds(this);
this.setResizable(true);
this.setFocusable(false);
this.setFocusableWindowState(false);

addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
GUIP.setMiniReportEnabled(false);
}
});

this.clientGUI = clientGUI;
}
//endregion Constructors

@Override
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) {
GUIP.setMiniReportSizeWidth(getSize().width);
GUIP.setMiniReportSizeHeight(getSize().height);
GUIP.setMiniReportPosX(getLocation().x);
GUIP.setMiniReportPosY(getLocation().y);
}
}

/**
* In addition to the default Dialog processKeyEvent, this method
* dispatches a KeyEvent to the client gui.
* This enables all the gui hotkeys.
*/
@Override
protected void processKeyEvent(KeyEvent evt) {
evt.setSource(clientGUI);
clientGUI.getMenuBar().dispatchEvent(evt);
// Make the source be the ClientGUI and not the dialog
// This prevents a ClassCastException in ToolTipManager
clientGUI.getCurrentPanel().dispatchEvent(evt);
if (!evt.isConsumed()) {
super.processKeyEvent(evt);
}
}
}
64 changes: 50 additions & 14 deletions megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,72 @@

import megamek.client.ui.Messages;
import megamek.client.ui.swing.ClientGUI;
import megamek.client.ui.swing.GUIPreferences;
import megamek.client.ui.swing.unitDisplay.UnitDisplay;
import megamek.client.ui.swing.util.UIUtil;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class UnitDisplayDialog extends JDialog {
//region Variable Declarations
private UnitDisplay unitDisplay;

private final ClientGUI clientGUI;
private static final String MSG_TITLE = Messages.getString("ClientGUI.MechDisplay");
private static final GUIPreferences GUIP = GUIPreferences.getInstance();
//endregion Variable Declarations

//region Constructors
public UnitDisplayDialog(final JFrame frame, final UnitDisplay unitDisplay,
final ClientGUI clientGUI) {
super(frame, Messages.getString("ClientGUI.MechDisplay"), false);
setUnitDisplay(unitDisplay);
public UnitDisplayDialog(final JFrame frame, final ClientGUI clientGUI) {
super(frame, "", false);
this.setTitle(MSG_TITLE);

if (GUIP.getUnitDisplayStartTabbed()) {
this.setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY());
this.setSize(GUIP.getUnitDisplaySizeWidth(), GUIP.getUnitDisplaySizeHeight());
}
else {
this.setLocation(GUIP.getUnitDisplayNontabbedPosX(), GUIP.getUnitDisplayNontabbedPosY());
this.setSize(GUIP.getUnitDisplayNonTabbedSizeWidth(), GUIP.getUnitDisplayNonTabbedSizeHeight());
}

UIUtil.updateWindowBounds(this);
this.setResizable(true);
this.setFocusable(false);
this.setFocusableWindowState(false);

addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
GUIP.setUnitDisplayEnabled(false);
}
});

this.clientGUI = clientGUI;
}
//endregion Constructors

//region Getters/Setters
public UnitDisplay getUnitDisplay() {
return unitDisplay;
}

public void setUnitDisplay(final UnitDisplay unitDisplay) {
this.unitDisplay = unitDisplay;
@Override
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if ((e.getID() == WindowEvent.WINDOW_DEACTIVATED) || (e.getID() == WindowEvent.WINDOW_CLOSING)) {
if ((getSize().width * getSize().height) > 0) {
if (GUIP.getUnitDisplayStartTabbed()) {
GUIP.setUnitDisplayPosX(getLocation().x);
GUIP.setUnitDisplayPosY(getLocation().y);
GUIP.setUnitDisplaySizeWidth(getSize().width);
GUIP.setUnitDisplaySizeHeight(getSize().height);
} else {
GUIP.setUnitDisplayNontabbedPosX(getLocation().x);
GUIP.setUnitDisplayNontabbedPosY(getLocation().y);
GUIP.setUnitDisplayNonTabbedSizeWidth(getSize().width);
GUIP.setUnitDisplayNonTabbedSizeHeight(getSize().height);
clientGUI.getUnitDisplay().saveSplitterLoc();
}
}
}
}
//endregion Getters/Setters

/**
* In addition to the default Dialog processKeyEvent, this method
Expand Down
5 changes: 3 additions & 2 deletions megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 25 additions & 6 deletions megamek/src/megamek/client/ui/swing/ChatterBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
Loading

0 comments on commit 7ef3099

Please sign in to comment.