Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5851 and other UI issues from Simon #5854

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ CommonMenuBar.viewGameOptions=Game Options...
CommonMenuBar.viewLOSSetting=LOS Setting
CommonMenuBar.viewForceDisplay=Force Display
CommonMenuBar.viewMekDisplay=Unit Display
CommonMenuBar.viewFiringMovingTabs=Unit Display Tabs
CommonMenuBar.viewAccessibilityWindow=Accessibility Window
CommonMenuBar.viewIncGUIScale=Increase GUI Scale
CommonMenuBar.viewDecGUIScale=Decrease GUI Scale
Expand Down Expand Up @@ -1302,6 +1303,8 @@ CommonSettingsDialog.report=Report
CommonSettingsDialog.reportFontType=Report Font Type
CommonSettingsDialog.reportKeywords=Report Keywords
CommonSettingsDialog.reportPhases=Report Phases
CommonSettingsDialog.tabsMove=Movement Phases
CommonSettingsDialog.tabsFire=Firing Phases
CommonSettingsDialog.seenby.Player=Player
CommonSettingsDialog.seenby.PlayerDetailed=Player Detailed
CommonSettingsDialog.seenby.Someone=Someone
Expand Down
4 changes: 2 additions & 2 deletions megamek/src/megamek/client/ui/swing/ChatterBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void focusGained(FocusEvent e) {

@Override
public void focusLost(FocusEvent e) {
if (inputField.getText().equals("")) {
if (inputField.getText().isEmpty()) {
Sleet01 marked this conversation as resolved.
Show resolved Hide resolved
inputField.setText(chatPlaceholder);
}
}
Expand All @@ -156,7 +156,7 @@ public void focusLost(FocusEvent e) {
playerChatSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
scrPlayers, new JScrollPane(chatArea));
playerChatSplit.setResizeWeight(0.01);

JPanel subPanel = new JPanel(new BorderLayout());
subPanel.setPreferredSize(new Dimension(284, 80));
subPanel.setMinimumSize(new Dimension(284, 80));
Expand Down
34 changes: 34 additions & 0 deletions megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ private <T> void moveElement(DefaultListModel<T> srcModel, int srcIndex, int trg
private JComboBox playerListAutoDisplayNonReportCombo;
private JComboBox forceDisplayAutoDisplayReportCombo;
private JComboBox forceDisplayAutoDisplayNonReportCombo;
private JCheckBox displayMoveDisplayDuringMovePhases;
private JCheckBox displayFireDisplayDuringFirePhases;

// Report
private JTextPane reportKeywordsTextPane;
Expand Down Expand Up @@ -2031,6 +2033,8 @@ protected void cancelAction() {
playerListAutoDisplayNonReportCombo.setSelectedItem(GUIP.getPlayerListAutoDisplayNonReportPhase());
forceDisplayAutoDisplayReportCombo.setSelectedItem(GUIP.getForceDisplayAutoDisplayReportPhase());
forceDisplayAutoDisplayNonReportCombo.setSelectedItem(GUIP.getForceDisplayAutoDisplayNonReportPhase());
displayMoveDisplayDuringMovePhases.setSelected(GUIP.getMoveDisplayTabDuringMovePhases());
displayFireDisplayDuringFirePhases.setSelected(GUIP.getFireDisplayTabDuringFiringPhases());

csbUnitDisplayHeatLevel1.setColour(GUIP.getUnitDisplayHeatLevel1());
csbUnitDisplayHeatLevel2.setColour(GUIP.getUnitDisplayHeatLevel2());
Expand Down Expand Up @@ -2460,6 +2464,8 @@ protected void okAction() {
GUIP.setPlayerListAutoDisplayNonReportPhase(playerListAutoDisplayNonReportCombo.getSelectedIndex());
GUIP.setForceDisplayAutoDisplayReportPhase(forceDisplayAutoDisplayReportCombo.getSelectedIndex());
GUIP.setForceDisplayAutoDisplayNonReportPhase(forceDisplayAutoDisplayNonReportCombo.getSelectedIndex());
GUIP.setMoveDisplayTabDuringMovePhases(displayMoveDisplayDuringMovePhases.isSelected());
GUIP.setFireDisplayTabDuringFiringPhases(displayFireDisplayDuringFirePhases.isSelected());

GUIP.setUnitDisplayHeatColorLevel1(csbUnitDisplayHeatLevel1.getColour());
GUIP.setUnitDisplayHeatColorLevel2(csbUnitDisplayHeatLevel2.getColour());
Expand Down Expand Up @@ -2840,6 +2846,14 @@ private JComboBox createHideShowComboBox(int i) {
return cb;
}

private JCheckBox createOnOffCheckBox(boolean b) {
JCheckBox chkb = new JCheckBox();
chkb.setEnabled(true);
chkb.setSelected(b);

return chkb;
}

private JPanel getPhasePanel() {
List<List<Component>> comps = new ArrayList<>();
ArrayList<Component> row;
Expand Down Expand Up @@ -2937,6 +2951,26 @@ private JPanel getPhasePanel() {
row.add(forceDisplayAutoDisplayNonReportCombo);
comps.add(row);

addLineSpacer(comps);

// Firing/Movement Display changes
row = new ArrayList<>();
JLabel tabsDisplayLabel = new JLabel(Messages.getString("CommonMenuBar.viewFiringMovingTabs"));
row.add(tabsDisplayLabel);
comps.add(row);
row = new ArrayList<>();
phaseLabel = new JLabel(Messages.getString("CommonSettingsDialog.tabsMove") + ": ");
row.add(phaseLabel);
displayMoveDisplayDuringMovePhases = createOnOffCheckBox(GUIP.getMoveDisplayTabDuringMovePhases());
row.add(displayMoveDisplayDuringMovePhases);
comps.add(row);
row = new ArrayList<>();
phaseLabel = new JLabel(Messages.getString("CommonSettingsDialog.tabsFire") + ": ");
row.add(phaseLabel);
displayFireDisplayDuringFirePhases = createOnOffCheckBox(GUIP.getFireDisplayTabDuringFiringPhases());
row.add(displayFireDisplayDuringFirePhases);
comps.add(row);

return createSettingsPanel(comps);
}

Expand Down
5 changes: 3 additions & 2 deletions megamek/src/megamek/client/ui/swing/DeploymentDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import megamek.client.event.BoardViewEvent;
import megamek.client.ui.Messages;
import megamek.client.ui.swing.util.KeyCommandBind;
import megamek.client.ui.swing.widget.MechPanelTabStrip;
import megamek.client.ui.swing.widget.MegamekButton;
import megamek.common.*;
import megamek.common.event.GamePhaseChangeEvent;
Expand Down Expand Up @@ -225,10 +226,10 @@ public void selectEntity(int en) {
setRemoveEnabled(true);

clientgui.getUnitDisplay().displayEntity(ce());
clientgui.getUnitDisplay().showPanel("movement");
clientgui.getUnitDisplay().showPanel(MechPanelTabStrip.SUMMARY);
clientgui.updateFiringArc(ce());
clientgui.showSensorRanges(ce());
computeCFWarningHexes(ce());
computeCFWarningHexes(ce());
} else {
disableButtons();
setNextEnabled(true);
Expand Down
9 changes: 7 additions & 2 deletions megamek/src/megamek/client/ui/swing/FiringDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import megamek.client.ui.Messages;
import megamek.client.ui.swing.util.KeyCommandBind;
import megamek.client.ui.swing.util.MegaMekController;
import megamek.client.ui.swing.widget.MechPanelTabStrip;
import megamek.client.ui.swing.widget.MegamekButton;
import megamek.common.*;
import megamek.common.actions.*;
Expand Down Expand Up @@ -262,7 +263,9 @@ private void viewActingUnit() {
Entity en_Target = clientgui.getUnitDisplay().getCurrentEntity();
// Avoided using selectEntity(), to avoid centering on active unit
clientgui.getUnitDisplay().displayEntity(ce());
clientgui.getUnitDisplay().showPanel("weapons");
if (GUIP.getFireDisplayTabDuringFiringPhases()) {
clientgui.getUnitDisplay().showPanel(MechPanelTabStrip.WEAPONS);
}
clientgui.getUnitDisplay().wPan.selectFirstWeapon();
target(en_Target);
}
Expand Down Expand Up @@ -1454,7 +1457,9 @@ protected void refreshAll() {
}
clientgui.getBoardView().redrawEntity(ce());
clientgui.getUnitDisplay().displayEntity(ce());
clientgui.getUnitDisplay().showPanel("weapons");
if (GUIP.getFireDisplayTabDuringFiringPhases()) {
clientgui.getUnitDisplay().showPanel(MechPanelTabStrip.WEAPONS);
}
clientgui.getUnitDisplay().wPan.selectFirstWeapon();
if (ce().isMakingVTOLGroundAttack()) {
updateVTOLGroundTarget();
Expand Down
20 changes: 20 additions & 0 deletions megamek/src/megamek/client/ui/swing/GUIPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ public class GUIPreferences extends PreferenceStoreProxy {
public static final String MINI_MAP_SYMBOLS_DISPLAY_MODE = "MinimapSymbolsDisplayMode";
public static final String MINI_MAP_AUTO_DISPLAY_REPORT_PHASE = "MinimapAutoDisplayReportPhase";
public static final String MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE = "MinimapAutoDisplayNonReportPhase";
public static final String FIRE_DISPLAY_TAB_DURING_PHASES = "FireDisplayTabDuringPhases";
public static final String MOVE_DISPLAY_TAB_DURING_PHASES = "MoveDisplayTabDuringPhases";
public static final String MINIMUM_SIZE_HEIGHT = "MinimumSizeHeight";
public static final String MINIMUM_SIZE_WIDTH = "MinimumSizeWidth";
public static final String MOUSE_WHEEL_ZOOM = "MouseWheelZoom";
Expand Down Expand Up @@ -667,6 +669,8 @@ protected GUIPreferences() {
store.setDefault(MINI_MAP_ENABLED, true);
store.setDefault(MINI_MAP_AUTO_DISPLAY_REPORT_PHASE, 0);
store.setDefault(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE, 1);
store.setDefault(MOVE_DISPLAY_TAB_DURING_PHASES, true);
store.setDefault(FIRE_DISPLAY_TAB_DURING_PHASES, true);

store.setDefault(MMSYMBOL, true);
store.setDefault(MINIMUM_SIZE_HEIGHT, 200);
Expand Down Expand Up @@ -1230,6 +1234,14 @@ public int getMinimapAutoDisplayNonReportPhase() {
return store.getInt(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE);
}

public boolean getFireDisplayTabDuringFiringPhases() {
return store.getBoolean(FIRE_DISPLAY_TAB_DURING_PHASES);
}

public boolean getMoveDisplayTabDuringMovePhases() {
return store.getBoolean(MOVE_DISPLAY_TAB_DURING_PHASES);
}

public int getMinimapPosX() {
return store.getInt(MINI_MAP_POS_X);
}
Expand Down Expand Up @@ -2069,6 +2081,14 @@ public void setMinimapAutoDisplayNonReportPhase(int i) {
store.setValue(MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE, i);
}

public void setFireDisplayTabDuringFiringPhases(boolean b) {
store.setValue(FIRE_DISPLAY_TAB_DURING_PHASES, b);
}

public void setMoveDisplayTabDuringMovePhases(boolean b) {
store.setValue(MOVE_DISPLAY_TAB_DURING_PHASES, b);
}

public void setMiniReportEnabled(boolean b) {
store.setValue(MINI_REPORT_ENABLED, b);
}
Expand Down
Loading