Skip to content

Commit

Permalink
Merge pull request #4343 from Jmr3366/hideTokenStack_v2
Browse files Browse the repository at this point in the history
Hide token stack indicator
  • Loading branch information
cwisniew authored Nov 3, 2023
2 parents 22d966b + 764192b commit 78d2a52
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/main/java/net/rptools/maptool/client/AppPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public class AppPreferences {
"hideMousePointerWhileDragging";
private static final boolean DEFAULT_KEY_HIDE_MOUSE_POINTER_WHILE_DRAGGING = true;

private static final String KEY_HIDE_TOKEN_STACK_INDICATOR = "hideTokenStackIndicator";
private static final boolean DEFAULT_KEY_HIDE_TOKEN_STACK_INDICATOR = false;

private static final String KEY_OBJECTS_START_SNAP_TO_GRID = "newStampsStartSnapToGrid";
private static final boolean DEFAULT_OBJECTS_START_SNAP_TO_GRID = false;

Expand Down Expand Up @@ -960,6 +963,14 @@ public static boolean getHideMousePointerWhileDragging() {
KEY_HIDE_MOUSE_POINTER_WHILE_DRAGGING, DEFAULT_KEY_HIDE_MOUSE_POINTER_WHILE_DRAGGING);
}

public static void setHideTokenStackIndicator(boolean flag) {
prefs.putBoolean(KEY_HIDE_TOKEN_STACK_INDICATOR, flag);
}

public static boolean getHideTokenStackIndicator() {
return prefs.getBoolean(KEY_HIDE_TOKEN_STACK_INDICATOR, DEFAULT_KEY_HIDE_TOKEN_STACK_INDICATOR);
}

public static void setObjectsStartSnapToGrid(boolean flag) {
prefs.putBoolean(KEY_OBJECTS_START_SNAP_TO_GRID, flag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public class PreferencesDialog extends JDialog {
private final JCheckBox tokensStartSnapToGridCheckBox;
private final JCheckBox tokensSnapWhileDraggingCheckBox;
private final JCheckBox hideMousePointerWhileDraggingCheckBox;
private final JCheckBox hideTokenStackIndicatorCheckBox;
private final JCheckBox newMapsVisibleCheckBox;
private final JCheckBox newTokensVisibleCheckBox;
private final JCheckBox tokensStartFreeSizeCheckBox;
Expand Down Expand Up @@ -323,6 +324,7 @@ public PreferencesDialog() {
tokensStartSnapToGridCheckBox = panel.getCheckBox("tokensStartSnapToGridCheckBox");
tokensSnapWhileDraggingCheckBox = panel.getCheckBox("tokensSnapWhileDragging");
hideMousePointerWhileDraggingCheckBox = panel.getCheckBox("hideMousePointerWhileDragging");
hideTokenStackIndicatorCheckBox = panel.getCheckBox("hideTokenStackIndicator");
newMapsVisibleCheckBox = panel.getCheckBox("newMapsVisibleCheckBox");
newTokensVisibleCheckBox = panel.getCheckBox("newTokensVisibleCheckBox");
stampsStartFreeSizeCheckBox = panel.getCheckBox("stampsStartFreeSize");
Expand Down Expand Up @@ -661,6 +663,10 @@ public void focusLost(FocusEvent e) {
e ->
AppPreferences.setHideMousePointerWhileDragging(
hideMousePointerWhileDraggingCheckBox.isSelected()));
hideTokenStackIndicatorCheckBox.addActionListener(
e ->
AppPreferences.setHideTokenStackIndicator(
hideTokenStackIndicatorCheckBox.isSelected()));
newMapsVisibleCheckBox.addActionListener(
e -> AppPreferences.setNewMapsVisible(newMapsVisibleCheckBox.isSelected()));
newTokensVisibleCheckBox.addActionListener(
Expand Down Expand Up @@ -1138,6 +1144,7 @@ private void setInitialState() {
tokensSnapWhileDraggingCheckBox.setSelected(AppPreferences.getTokensSnapWhileDragging());
hideMousePointerWhileDraggingCheckBox.setSelected(
AppPreferences.getHideMousePointerWhileDragging());
hideTokenStackIndicatorCheckBox.setSelected(AppPreferences.getHideTokenStackIndicator());
newMapsVisibleCheckBox.setSelected(AppPreferences.getNewMapsVisible());
newTokensVisibleCheckBox.setSelected(AppPreferences.getNewTokensVisible());
stampsStartFreeSizeCheckBox.setSelected(AppPreferences.getObjectsStartFreesize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="b641a" layout-manager="GridLayoutManager" row-count="16" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="b641a" layout-manager="GridLayoutManager" row-count="17" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="2" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
Expand Down Expand Up @@ -323,14 +323,33 @@
</constraints>
<properties>
<name value="hideMousePointerWhileDragging"/>
<selected value="false"/>
<text value="&#9;"/>
</properties>
</component>
<vspacer id="a9eb4">
<constraints>
<grid row="15" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="16" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="60bed" class="javax.swing.JLabel">
<constraints>
<grid row="15" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="net/rptools/maptool/language/i18n" key="Preferences.label.tokens.stack.hide"/>
<toolTipText resource-bundle="net/rptools/maptool/language/i18n" key="Preferences.label.tokens.stack.hide.tooltip"/>
</properties>
</component>
<component id="93234" class="javax.swing.JCheckBox">
<constraints>
<grid row="15" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<name value="hideTokenStackIndicator"/>
<text value="&#9;"/>
</properties>
</component>
</children>
</grid>
<grid id="f38d9" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
Expand Down Expand Up @@ -966,7 +985,7 @@
<tabbedpane title-resource-bundle="net/rptools/maptool/language/i18n" title-key="Label.application"/>
</constraints>
<properties>
<visible value="true"/>
<visible value="false"/>
</properties>
<border type="none"/>
<children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3638,7 +3638,9 @@ protected void renderTokens(
// Stacks
if (!tokenList.isEmpty()
&& !tokenList.get(0).isStamp()) { // TODO: find a cleaner way to indicate token layer
if (tokenStackMap != null) { // FIXME Needed to prevent NPE but how can it be null?
boolean hideTSI = AppPreferences.getHideTokenStackIndicator();
if (tokenStackMap != null
&& !hideTSI) { // FIXME Needed to prevent NPE but how can it be null?
for (Token token : tokenStackMap.keySet()) {
Area bounds = getTokenBounds(token);
if (bounds == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2822,4 +2822,6 @@ advanced.roll.variableNotNumber = Variable {0} is not a number.
advanced.roll.unknownProperty = Unknown Property {0}.
advanced.roll.propertyNotNumber = Property {0} is not a number.
advanced.roll.noTokenInContext = No token in context.
advanced.roll.inputNotNumber = Input {0} is not a number.
advanced.roll.inputNotNumber = Input {0} is not a number.
Preferences.label.tokens.stack.hide=Hide Token stack indicator
Preferences.label.tokens.stack.hide.tooltip=Token Layer stack inidicator will be hidden

0 comments on commit 78d2a52

Please sign in to comment.