From db3140e4f8810480735fba1dcb51da2227491466 Mon Sep 17 00:00:00 2001 From: jmr3366 Date: Tue, 17 Oct 2023 07:48:57 -0400 Subject: [PATCH 1/5] Update AppActions.java --- src/main/java/net/rptools/maptool/client/AppActions.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/net/rptools/maptool/client/AppActions.java b/src/main/java/net/rptools/maptool/client/AppActions.java index a61ba52407..7e5596022f 100644 --- a/src/main/java/net/rptools/maptool/client/AppActions.java +++ b/src/main/java/net/rptools/maptool/client/AppActions.java @@ -2870,6 +2870,8 @@ protected void executeAction() { MapTool.showError("msg.error.failedSaveMap", ioe); } } + } else { + tryAgain = false; } } } From 3868d9cb30d16bbad0eefc1a437c92b60d010260 Mon Sep 17 00:00:00 2001 From: jmr3366 Date: Tue, 17 Oct 2023 08:00:14 -0400 Subject: [PATCH 2/5] Fix for #4324 Resolves #4324 --- src/main/java/net/rptools/maptool/client/AppActions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/rptools/maptool/client/AppActions.java b/src/main/java/net/rptools/maptool/client/AppActions.java index 7e5596022f..605aed59b5 100644 --- a/src/main/java/net/rptools/maptool/client/AppActions.java +++ b/src/main/java/net/rptools/maptool/client/AppActions.java @@ -2871,7 +2871,7 @@ protected void executeAction() { } } } else { - tryAgain = false; + tryAgain = false; } } } From b2cca38239235491723521d58b07aaa556883383 Mon Sep 17 00:00:00 2001 From: jmr3366 Date: Tue, 17 Oct 2023 10:03:47 -0400 Subject: [PATCH 3/5] Update AppActions.java --- .../rptools/maptool/client/AppActions.java | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/AppActions.java b/src/main/java/net/rptools/maptool/client/AppActions.java index 605aed59b5..5d2383d9a3 100644 --- a/src/main/java/net/rptools/maptool/client/AppActions.java +++ b/src/main/java/net/rptools/maptool/client/AppActions.java @@ -2848,30 +2848,27 @@ 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); } - } else { - tryAgain = false; } } } From aa7ef33904f98bf21e30ec595e51d8c53a70c7d8 Mon Sep 17 00:00:00 2001 From: jmr3366 Date: Tue, 17 Oct 2023 14:24:28 -0400 Subject: [PATCH 4/5] Adds #4326 feature request #4326 closes --- .../maptool/client/AppPreferences.java | 11 ++++++++ .../preferencesdialog/PreferencesDialog.java | 7 ++++++ .../PreferencesDialogView.form | 25 ++++++++++++++++--- .../maptool/client/ui/zone/ZoneRenderer.java | 4 ++- .../rptools/maptool/language/i18n.properties | 4 ++- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/AppPreferences.java b/src/main/java/net/rptools/maptool/client/AppPreferences.java index 6f5f2dc64e..b42ea6471e 100644 --- a/src/main/java/net/rptools/maptool/client/AppPreferences.java +++ b/src/main/java/net/rptools/maptool/client/AppPreferences.java @@ -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; @@ -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); } diff --git a/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialog.java b/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialog.java index 87607ebdc4..922d354207 100644 --- a/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialog.java +++ b/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialog.java @@ -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; @@ -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"); @@ -654,6 +656,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( @@ -1131,6 +1137,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()); diff --git a/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.form b/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.form index c31facaba3..dceb86e7d0 100644 --- a/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.form +++ b/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.form @@ -35,7 +35,7 @@ - + @@ -323,14 +323,33 @@ + - + + + + + + + + + + + + + + + + + + + @@ -966,7 +985,7 @@ - + diff --git a/src/main/java/net/rptools/maptool/client/ui/zone/ZoneRenderer.java b/src/main/java/net/rptools/maptool/client/ui/zone/ZoneRenderer.java index 59e5706f02..4012e77ec5 100644 --- a/src/main/java/net/rptools/maptool/client/ui/zone/ZoneRenderer.java +++ b/src/main/java/net/rptools/maptool/client/ui/zone/ZoneRenderer.java @@ -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) { diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index c8ba1b1c1e..91823a48d8 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -2819,4 +2819,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. \ No newline at end of file +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 \ No newline at end of file From 764192b1088b9586306b2a6a7c5a0c84798645a0 Mon Sep 17 00:00:00 2001 From: jmr3366 Date: Thu, 26 Oct 2023 07:18:44 -0400 Subject: [PATCH 5/5] HideToken Stack indicator --- src/main/java/net/rptools/maptool/client/AppActions.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/rptools/maptool/client/AppActions.java b/src/main/java/net/rptools/maptool/client/AppActions.java index 5d2383d9a3..76a900bd47 100644 --- a/src/main/java/net/rptools/maptool/client/AppActions.java +++ b/src/main/java/net/rptools/maptool/client/AppActions.java @@ -2848,7 +2848,9 @@ protected void executeAction() { chooser.setSelectedFile(new File(zr.getZone().getName())); boolean tryAgain = true; while (tryAgain) { - if (chooser.showSaveDialog(MapTool.getFrame()) != JFileChooser.APPROVE_OPTION) break; + 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();