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

add client setting for auto centering #4877

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ private <T> void moveElement(DefaultListModel<T> 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"));
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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());

Expand Down
10 changes: 10 additions & 0 deletions megamek/src/megamek/client/ui/swing/GUIPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 4 additions & 1 deletion megamek/src/megamek/client/ui/swing/boardview/BoardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,10 @@ void addMovingUnit(Entity entity, Vector<UnitLocation> movePath) {

// Center on the starting hex of the moving unit.
UnitLocation loc = movePath.get(0);
centerOnHex(loc.getCoords());

if (GUIP.getAutoCenter()) {
centerOnHex(loc.getCoords());
}
}
}

Expand Down