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

Hide token stack indicator #4343

Merged
merged 6 commits into from
Nov 3, 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
39 changes: 20 additions & 19 deletions src/main/java/net/rptools/maptool/client/AppActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2848,27 +2848,28 @@ protected void executeAction() {
chooser.setSelectedFile(new File(zr.getZone().getName()));
boolean tryAgain = true;
while (tryAgain) {
if (chooser.showSaveDialog(MapTool.getFrame()) == JFileChooser.APPROVE_OPTION) {
File mapFile = chooser.getSelectedFile();
var installDir = AppUtil.getInstallDirectory().toAbsolutePath();
var saveDir = chooser.getSelectedFile().toPath().getParent().toAbsolutePath();
if (saveDir.startsWith(installDir)) {
MapTool.showWarning("msg.warning.saveMapToInstallDir");
} else {
tryAgain = false;
try {
mapFile = getFileWithExtension(mapFile, AppConstants.MAP_FILE_EXTENSION);
if (mapFile.exists()) {
if (!MapTool.confirm("msg.confirm.fileExists")) {
return;
}
if (chooser.showSaveDialog(MapTool.getFrame()) != JFileChooser.APPROVE_OPTION) {
break;
}
File mapFile = chooser.getSelectedFile();
var installDir = AppUtil.getInstallDirectory().toAbsolutePath();
var saveDir = chooser.getSelectedFile().toPath().getParent().toAbsolutePath();
if (saveDir.startsWith(installDir)) {
MapTool.showWarning("msg.warning.saveMapToInstallDir");
} else {
tryAgain = false;
try {
mapFile = getFileWithExtension(mapFile, AppConstants.MAP_FILE_EXTENSION);
if (mapFile.exists()) {
if (!MapTool.confirm("msg.confirm.fileExists")) {
return;
}
PersistenceUtil.saveMap(zr.getZone(), mapFile);
AppPreferences.setSaveMapDir(mapFile.getParentFile());
MapTool.showInformation("msg.info.mapSaved");
} catch (IOException ioe) {
MapTool.showError("msg.error.failedSaveMap", ioe);
}
PersistenceUtil.saveMap(zr.getZone(), mapFile);
AppPreferences.setSaveMapDir(mapFile.getParentFile());
MapTool.showInformation("msg.info.mapSaved");
} catch (IOException ioe) {
MapTool.showError("msg.error.failedSaveMap", ioe);
}
}
}
Expand Down
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 @@ -657,6 +659,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 @@ -1134,6 +1140,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 @@ -3636,7 +3636,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 @@ -2820,4 +2820,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
Loading