From 84adf7076980b158c35c02cf7611fd250cd0a5d7 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 6 Nov 2023 18:36:06 -0500 Subject: [PATCH] add client setting for auto centering --- megamek/i18n/megamek/client/messages.properties | 2 ++ .../megamek/client/ui/swing/CommonSettingsDialog.java | 4 ++++ .../src/megamek/client/ui/swing/GUIPreferences.java | 10 ++++++++++ .../megamek/client/ui/swing/boardview/BoardView.java | 5 ++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 99db501900a..d6e3bbcd696 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -1295,6 +1295,8 @@ CommonSettingsDialog.unitDisplayHeatToolTip=Max heat value for each level CommonSettingsDialog.unitTooltipMaxWidth=Max Width for Unit Tooltip CommonSettingsDialog.unitTooltipMaxWidth.tooltip=keeps tool tip from growing too wide CommonSettingsDialog.useAverageSkills=Use the current random skill settings when adding units in the lobby. +CommonSettingsDialog.useAutoCenter.tooltip=User initiated centering still applies +CommonSettingsDialog.useAutoCenter=Use automatic unit centering on the board CommonSettingsDialog.useCamoOverlay=Use Camo Overlay CommonSettingsDialog.useInclines=Show incline highlighting and shadows at hex borders CommonSettingsDialog.useShadowMap=Show terrain and building shadows diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index 5094c860e71..0686dcf5229 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -184,6 +184,7 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg private final JCheckBox dockMultipleOnYAxis = new JCheckBox(Messages.getString("CommonSettingsDialog.dockMultipleOnYAxis")); private final JCheckBox useCamoOverlay = new JCheckBox(Messages.getString("CommonSettingsDialog.useCamoOverlay")); private final JCheckBox useSoftCenter = new JCheckBox(Messages.getString("CommonSettingsDialog.useSoftCenter")); + private final JCheckBox useAutoCenter = new JCheckBox(Messages.getString("CommonSettingsDialog.useAutoCenter")); private final JCheckBox levelhighlight = new JCheckBox(Messages.getString("CommonSettingsDialog.levelHighlight")); private final JCheckBox shadowMap = new JCheckBox(Messages.getString("CommonSettingsDialog.useShadowMap")); private final JCheckBox hexInclines = new JCheckBox(Messages.getString("CommonSettingsDialog.useInclines")); @@ -584,6 +585,7 @@ private JPanel getGameBoardPanel() { comps.add(checkboxEntry(showUnitId, null)); comps.add(checkboxEntry(entityOwnerColor, Messages.getString("CommonSettingsDialog.entityOwnerColor.tooltip"))); comps.add(checkboxEntry(useSoftCenter, Messages.getString("CommonSettingsDialog.useSoftCenter.tooltip"))); + comps.add(checkboxEntry(useAutoCenter, Messages.getString("CommonSettingsDialog.useAutoCenter.tooltip"))); row = new ArrayList<>(); csbUnitTextColor = new ColourSelectorButton(Messages.getString("CommonSettingsDialog.colors.UnitTextColor")); @@ -1603,6 +1605,7 @@ public void setVisible(boolean visible) { shadowMap.setSelected(GUIP.getShadowMap()); hexInclines.setSelected(GUIP.getHexInclines()); useSoftCenter.setSelected(GUIP.getSoftCenter()); + useAutoCenter.setSelected(GUIP.getAutoCenter()); entityOwnerColor.setSelected(GUIP.getUnitLabelBorder()); teamColoring.setSelected(GUIP.getTeamColoring()); @@ -2013,6 +2016,7 @@ protected void okAction() { GUIP.setShadowMap(shadowMap.isSelected()); GUIP.setHexInclines(hexInclines.isSelected()); GUIP.setSoftcenter(useSoftCenter.isSelected()); + GUIP.setAutocenter(useAutoCenter.isSelected()); GUIP.setGameSummaryBoardView(gameSummaryBV.isSelected()); GUIP.setGameSummaryMinimap(gameSummaryMM.isSelected()); diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index bc018feea5b..6a9c8907c05 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -118,6 +118,7 @@ public class GUIPreferences extends PreferenceStoreProxy { public static final String FLOATINGISO = "FloatingIsometric"; public static final String MMSYMBOL = "MmSymbol"; public static final String SOFTCENTER = "SoftCenter"; + public static final String AUTOCENTER = "AutoCenter"; public static final String AUTO_END_FIRING = "AutoEndFiring"; public static final String AUTO_DECLARE_SEARCHLIGHT = "AutoDeclareSearchlight"; @@ -694,6 +695,7 @@ protected GUIPreferences() { store.setDefault(SHOW_DAMAGE_DECAL, true); store.setDefault(SKIN_FILE, "BW - Default.xml"); store.setDefault(SOFTCENTER, false); + store.setDefault(AUTOCENTER, true); store.setDefault(UI_THEME, UIManager.getSystemLookAndFeelClassName()); store.setDefault(RAT_TECH_LEVEL, 0); @@ -1469,6 +1471,10 @@ public boolean getSoftCenter() { return store.getBoolean(SOFTCENTER); } + public boolean getAutoCenter() { + return store.getBoolean(AUTOCENTER); + } + public boolean getNoSaveNag() { return store.getBoolean(ADVANCED_NO_SAVE_NAG); } @@ -2214,6 +2220,10 @@ public void setSoftcenter(boolean b) { store.setValue(SOFTCENTER, b); } + public void setAutocenter(boolean b) { + store.setValue(AUTOCENTER, b); + } + public void setAsCardFont(String asCardFont) { store.setValue(AS_CARD_FONT, asCardFont); } diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 7a6c1942d39..cb803585f47 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -995,7 +995,10 @@ void addMovingUnit(Entity entity, Vector movePath) { // Center on the starting hex of the moving unit. UnitLocation loc = movePath.get(0); - centerOnHex(loc.getCoords()); + + if (GUIP.getAutoCenter()) { + centerOnHex(loc.getCoords()); + } } }