From 69ed1be8c2978668cb24cad4f73e9c96ebda3e2a Mon Sep 17 00:00:00 2001 From: rptools-automation <47437651+rptools-automation@users.noreply.github.com> Date: Sun, 1 Oct 2023 20:41:23 +1030 Subject: [PATCH 01/18] New translations i18n.properties (Polish) --- .../maptool/language/i18n_pl.properties | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/resources/net/rptools/maptool/language/i18n_pl.properties b/src/main/resources/net/rptools/maptool/language/i18n_pl.properties index a1ef7b9f99..850d681b81 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n_pl.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n_pl.properties @@ -1545,7 +1545,7 @@ lineParser.countNonNeg = Opcja liczenia wymaga liczby nieujemnej, a # Notice there are no double quotes around {0}. lineParser.dialogTitle = Wprowadź wartość dla {0}. lineParser.dialogTitleNoToken = Wprowadź wartość. -lineParser.dialogValueFor = Value For "{0}" +lineParser.dialogValueFor = Wartość dla "{0}" lineParser.duplicateLibTokens = Znaleziono duplikaty żetonów „{0}”. lineParser.emptyTokenName = Nie można przypisać pustego ciągu do zmiennej token.name lineParser.errorBodyRoll = Błąd w treści rzutu. @@ -2639,11 +2639,11 @@ token.statSheet.legacyStatSheetDescription = Wcześniejsze (przed 1.14) arkusze token.statSheet.useDefault = Domyślny arkusz danych statystycznych dla typu właściwości # Advanced Dice Rolls -advanced.roll.parserError = Dice Roll String Error line {0} column {1} "{2}". -advanced.roll.unknownDiceType = Unknown Dice Roll Type {0}. -advanced.roll.unknownVariable = Unknown Variable {0}. -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.parserError = Błąd rzutu kostką wiersz {0} kolumna {1} "{2}". +advanced.roll.unknownDiceType = Nieznany typ rzutu kostką {0}. +advanced.roll.unknownVariable = Nieznana zmienna {0}. +advanced.roll.variableNotNumber = Zmienna {0} nie jest liczbą. +advanced.roll.unknownProperty = Nieznana właściwość {0}. +advanced.roll.propertyNotNumber = Właściwość {0} nie jest liczbą. +advanced.roll.noTokenInContext = Brak tokena w kontekście. +advanced.roll.inputNotNumber = Dane wejściowe {0} nie są liczbami. \ No newline at end of file From e725da5745c7717ce38139ec6961214e391d6727 Mon Sep 17 00:00:00 2001 From: cwisniew Date: Mon, 2 Oct 2023 20:20:46 +1030 Subject: [PATCH 02/18] apply compat fix for json.path.set and json.path.delete as well --- .../client/functions/json/JSONMacroFunctions.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java b/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java index c6d9f30c04..1a3c5a9779 100644 --- a/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java @@ -872,7 +872,12 @@ private JsonElement shallowCopy(JsonElement jsonElement) { * @return The resulting json data. */ private JsonElement jsonPathDelete(JsonElement json, String path) { - return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).delete(path).json(); + try { + return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).delete(path).json(); + } catch (PathNotFoundException ex) { + // Return original json, this is to preserve backwards compatability pre library update + return json; + } } /** @@ -906,7 +911,12 @@ private JsonElement jsonPathPut(JsonElement json, String path, String key, Objec private JsonElement jsonPathSet(JsonElement json, String path, Object info) { Object value = asJsonElement(info); - return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).set(path, value).json(); + try { + return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).set(path, value).json(); + } catch (PathNotFoundException ex) { + // Return original json, this is to preserve backwards compatability pre library update + return json; + } } /** From 818a2a4513f6b1012b6a93072f4c77eebb243f91 Mon Sep 17 00:00:00 2001 From: ColdAnkles <13864745+ColdAnkles@users.noreply.github.com> Date: Fri, 6 Oct 2023 19:22:03 +1030 Subject: [PATCH 03/18] Added additional functions to JSAPI Token --- .../script/javascript/api/JSAPIToken.java | 51 +++++++++++++++++++ .../java/net/rptools/maptool/model/Token.java | 12 +++++ 2 files changed, 63 insertions(+) diff --git a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java index e328d89e69..3fb8b20198 100644 --- a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java +++ b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java @@ -15,6 +15,7 @@ package net.rptools.maptool.client.script.javascript.api; import java.util.Iterator; +import java.util.List; import java.util.Set; import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.script.javascript.*; @@ -199,4 +200,54 @@ public void setMap(Zone m) { public String getMapName() { return this.map.getDisplayName(); } + + @HostAccess.Export + public boolean getState(String stateName) { + Object currentState = this.token.getState(stateName); + return (currentState instanceof Boolean && (Boolean) currentState); + } + + @HostAccess.Export + public void setState(String stateName, boolean aValue) { + this.token.setState(stateName, aValue); + } + + @HostAccess.Export + public void setAllStates(Object aValue) { + this.token.setAllStates(aValue); + } + + @HostAccess.Export + public List getSetStates() { + return this.token.getSetStates(); + } + + @HostAccess.Export + public boolean isPC() { + return this.token.getType() == Token.Type.PC; + } + + @HostAccess.Export + public void setPC() { + this.token.setType(Token.Type.PC); + } + + @HostAccess.Export + public boolean isNPC() { + return this.token.getType() == Token.Type.NPC; + } + + @HostAccess.Export + public void setNPC() { + this.token.setType(Token.Type.NPC); + } + + @HostAccess.Export + public String getType() { + if (this.token.getType() == Token.Type.PC) { + return "PC"; + } else { + return "NPC"; + } + } } diff --git a/src/main/java/net/rptools/maptool/model/Token.java b/src/main/java/net/rptools/maptool/model/Token.java index eccf652d3d..acbe44bf3a 100644 --- a/src/main/java/net/rptools/maptool/model/Token.java +++ b/src/main/java/net/rptools/maptool/model/Token.java @@ -1738,6 +1738,18 @@ public Object getState(String property) { return state.get(property); } + public List getSetStates() { + List setStates = new ArrayList(); + for (Map.Entry entry : state.entrySet()) { + if (entry.getValue() instanceof Boolean) { + if ((Boolean) entry.getValue()) { + setStates.add(entry.getKey()); + } + } + } + return setStates; + } + /** * Set the value of state for this Token. * From 9b11d41bf6295c297aa5892b178f154a7866a2f7 Mon Sep 17 00:00:00 2001 From: ColdAnkles <13864745+ColdAnkles@users.noreply.github.com> Date: Sat, 7 Oct 2023 15:02:04 +1030 Subject: [PATCH 04/18] Client<->Server communications and trusted context tests. --- .../script/javascript/api/JSAPIToken.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java index 3fb8b20198..ad3e98508f 100644 --- a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java +++ b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java @@ -209,12 +209,22 @@ public boolean getState(String stateName) { @HostAccess.Export public void setState(String stateName, boolean aValue) { - this.token.setState(stateName, aValue); + boolean trusted = JSScriptEngine.inTrustedContext(); + String playerId = MapTool.getPlayer().getName(); + if (trusted || token.isOwner(playerId)) { + this.token.setState(stateName, aValue); + MapTool.serverCommand().updateTokenProperty(token, Token.Update.setState, stateName, aValue); + } } @HostAccess.Export - public void setAllStates(Object aValue) { - this.token.setAllStates(aValue); + public void setAllStates(boolean aValue) { + boolean trusted = JSScriptEngine.inTrustedContext(); + String playerId = MapTool.getPlayer().getName(); + if (trusted || token.isOwner(playerId)) { + this.token.setAllStates(aValue); + MapTool.serverCommand().updateTokenProperty(token, Token.Update.setAllStates, aValue); + } } @HostAccess.Export @@ -229,7 +239,12 @@ public boolean isPC() { @HostAccess.Export public void setPC() { - this.token.setType(Token.Type.PC); + boolean trusted = JSScriptEngine.inTrustedContext(); + String playerId = MapTool.getPlayer().getName(); + if (trusted || token.isOwner(playerId)) { + this.token.setType(Token.Type.PC); + MapTool.serverCommand().updateTokenProperty(token, Token.Update.setPC); + } } @HostAccess.Export @@ -239,7 +254,12 @@ public boolean isNPC() { @HostAccess.Export public void setNPC() { - this.token.setType(Token.Type.NPC); + boolean trusted = JSScriptEngine.inTrustedContext(); + String playerId = MapTool.getPlayer().getName(); + if (trusted || token.isOwner(playerId)) { + this.token.setType(Token.Type.NPC); + MapTool.serverCommand().updateTokenProperty(token, Token.Update.setNPC); + } } @HostAccess.Export From f10e8442a3def50538e16d808c4e1c472295cfc4 Mon Sep 17 00:00:00 2001 From: ColdAnkles <13864745+ColdAnkles@users.noreply.github.com> Date: Fri, 6 Oct 2023 19:22:03 +1030 Subject: [PATCH 05/18] Added additional functions to JSAPI Token --- .../script/javascript/api/JSAPIToken.java | 51 +++++++++++++++++++ .../java/net/rptools/maptool/model/Token.java | 12 +++++ 2 files changed, 63 insertions(+) diff --git a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java index e328d89e69..3fb8b20198 100644 --- a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java +++ b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java @@ -15,6 +15,7 @@ package net.rptools.maptool.client.script.javascript.api; import java.util.Iterator; +import java.util.List; import java.util.Set; import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.script.javascript.*; @@ -199,4 +200,54 @@ public void setMap(Zone m) { public String getMapName() { return this.map.getDisplayName(); } + + @HostAccess.Export + public boolean getState(String stateName) { + Object currentState = this.token.getState(stateName); + return (currentState instanceof Boolean && (Boolean) currentState); + } + + @HostAccess.Export + public void setState(String stateName, boolean aValue) { + this.token.setState(stateName, aValue); + } + + @HostAccess.Export + public void setAllStates(Object aValue) { + this.token.setAllStates(aValue); + } + + @HostAccess.Export + public List getSetStates() { + return this.token.getSetStates(); + } + + @HostAccess.Export + public boolean isPC() { + return this.token.getType() == Token.Type.PC; + } + + @HostAccess.Export + public void setPC() { + this.token.setType(Token.Type.PC); + } + + @HostAccess.Export + public boolean isNPC() { + return this.token.getType() == Token.Type.NPC; + } + + @HostAccess.Export + public void setNPC() { + this.token.setType(Token.Type.NPC); + } + + @HostAccess.Export + public String getType() { + if (this.token.getType() == Token.Type.PC) { + return "PC"; + } else { + return "NPC"; + } + } } diff --git a/src/main/java/net/rptools/maptool/model/Token.java b/src/main/java/net/rptools/maptool/model/Token.java index eccf652d3d..acbe44bf3a 100644 --- a/src/main/java/net/rptools/maptool/model/Token.java +++ b/src/main/java/net/rptools/maptool/model/Token.java @@ -1738,6 +1738,18 @@ public Object getState(String property) { return state.get(property); } + public List getSetStates() { + List setStates = new ArrayList(); + for (Map.Entry entry : state.entrySet()) { + if (entry.getValue() instanceof Boolean) { + if ((Boolean) entry.getValue()) { + setStates.add(entry.getKey()); + } + } + } + return setStates; + } + /** * Set the value of state for this Token. * From 5cd5c011212872f57b9f713b9857f008219f7cb1 Mon Sep 17 00:00:00 2001 From: ColdAnkles <13864745+ColdAnkles@users.noreply.github.com> Date: Sat, 7 Oct 2023 15:02:04 +1030 Subject: [PATCH 06/18] Client<->Server communications and trusted context tests. --- .../script/javascript/api/JSAPIToken.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java index 3fb8b20198..ad3e98508f 100644 --- a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java +++ b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java @@ -209,12 +209,22 @@ public boolean getState(String stateName) { @HostAccess.Export public void setState(String stateName, boolean aValue) { - this.token.setState(stateName, aValue); + boolean trusted = JSScriptEngine.inTrustedContext(); + String playerId = MapTool.getPlayer().getName(); + if (trusted || token.isOwner(playerId)) { + this.token.setState(stateName, aValue); + MapTool.serverCommand().updateTokenProperty(token, Token.Update.setState, stateName, aValue); + } } @HostAccess.Export - public void setAllStates(Object aValue) { - this.token.setAllStates(aValue); + public void setAllStates(boolean aValue) { + boolean trusted = JSScriptEngine.inTrustedContext(); + String playerId = MapTool.getPlayer().getName(); + if (trusted || token.isOwner(playerId)) { + this.token.setAllStates(aValue); + MapTool.serverCommand().updateTokenProperty(token, Token.Update.setAllStates, aValue); + } } @HostAccess.Export @@ -229,7 +239,12 @@ public boolean isPC() { @HostAccess.Export public void setPC() { - this.token.setType(Token.Type.PC); + boolean trusted = JSScriptEngine.inTrustedContext(); + String playerId = MapTool.getPlayer().getName(); + if (trusted || token.isOwner(playerId)) { + this.token.setType(Token.Type.PC); + MapTool.serverCommand().updateTokenProperty(token, Token.Update.setPC); + } } @HostAccess.Export @@ -239,7 +254,12 @@ public boolean isNPC() { @HostAccess.Export public void setNPC() { - this.token.setType(Token.Type.NPC); + boolean trusted = JSScriptEngine.inTrustedContext(); + String playerId = MapTool.getPlayer().getName(); + if (trusted || token.isOwner(playerId)) { + this.token.setType(Token.Type.NPC); + MapTool.serverCommand().updateTokenProperty(token, Token.Update.setNPC); + } } @HostAccess.Export From 447d6033f85b0d8ea4e5da2796e47bde46a94cee Mon Sep 17 00:00:00 2001 From: ColdAnkles <13864745+ColdAnkles@users.noreply.github.com> Date: Sun, 15 Oct 2023 09:52:52 +1030 Subject: [PATCH 07/18] Clarify function name. Improved getType return. --- .../maptool/client/script/javascript/api/JSAPIToken.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java index ad3e98508f..3045e415e9 100644 --- a/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java +++ b/src/main/java/net/rptools/maptool/client/script/javascript/api/JSAPIToken.java @@ -228,7 +228,7 @@ public void setAllStates(boolean aValue) { } @HostAccess.Export - public List getSetStates() { + public List getActiveStates() { return this.token.getSetStates(); } @@ -264,10 +264,6 @@ public void setNPC() { @HostAccess.Export public String getType() { - if (this.token.getType() == Token.Type.PC) { - return "PC"; - } else { - return "NPC"; - } + return this.token.getType().name(); } } From 7ceccb7e6e8883e36d80d35cf30cbe7ade99159c Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Wed, 18 Oct 2023 13:24:18 +1030 Subject: [PATCH 08/18] Display installation directory in dev options --- .../preferencesdialog/PreferencesDialog.java | 3 ++ .../PreferencesDialogView.form | 29 ++++++++++++++++--- .../PreferencesDialogView.java | 1 - .../rptools/maptool/language/i18n.properties | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) 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..8335950e02 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 @@ -464,6 +464,9 @@ public PreferencesDialog() { } } + final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); + installDirTextField.setText(AppUtil.getInstallDirectory().toString()); + File appCfgFile = AppUtil.getAppCfgFile(); String copyInfo = ""; if (appCfgFile != null) { // Don't try to display message if running from dev. 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..c9d18a55f5 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 @@ -3,7 +3,7 @@ - + @@ -966,7 +966,7 @@ - + @@ -2304,7 +2304,7 @@ - + @@ -2315,10 +2315,31 @@ - + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.java b/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.java index 5aceef4a80..9939a1b641 100644 --- a/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.java +++ b/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.java @@ -14,7 +14,6 @@ */ package net.rptools.maptool.client.ui.preferencesdialog; -import java.awt.*; import javax.swing.*; public class PreferencesDialogView { diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index a9c7b43d5e..c9660feb22 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -691,6 +691,7 @@ Preferences.label.client.fitview = Fit GM view Preferences.label.client.fitview.tooltip = When forcing players to the GM's view, should the player's map be zoomed such that their screen shows at least the same content as the GM's screen? Preferences.label.client.default.username = Default Username Preferences.label.client.default.username.tooltip = The default username that appears in the MapTool toolbar. +Preferences.label.installDir = Installation Directory. Preferences.client.webEndPoint.port = Internal Web Server End Point Port Preferences.client.webEndPoint.port.tooltip = Web Server End Point Port (Internal MapTool Only) Preferences.client.default.username.value = Anonymous User From 371b1c8df7f8d37690bb3c906fd8624cc0a84d05 Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Wed, 18 Oct 2023 14:32:42 +1030 Subject: [PATCH 09/18] Change to install location --- .../maptool/client/ui/preferencesdialog/PreferencesDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8335950e02..8690c595c4 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 @@ -465,7 +465,7 @@ public PreferencesDialog() { } final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); - installDirTextField.setText(AppUtil.getInstallDirectory().toString()); + installDirTextField.setText(AppUtil.getAppInstallLocation()); File appCfgFile = AppUtil.getAppCfgFile(); String copyInfo = ""; From 887c145cd3c6712ed89f4a4bd468b40169c38591 Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Wed, 18 Oct 2023 18:01:32 +1030 Subject: [PATCH 10/18] fix --- src/main/java/net/rptools/maptool/client/AppUtil.java | 9 ++++----- .../client/ui/preferencesdialog/PreferencesDialog.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/AppUtil.java b/src/main/java/net/rptools/maptool/client/AppUtil.java index d5c18fda29..e89e94caae 100644 --- a/src/main/java/net/rptools/maptool/client/AppUtil.java +++ b/src/main/java/net/rptools/maptool/client/AppUtil.java @@ -213,18 +213,17 @@ public static Path getInstallDirectory() { var path = Path.of(getAppInstallLocation()); if (MapTool.isDevelopment()) { // remove build/classes/java - path = path.getParent().getParent().getParent().getParent(); - } else { + path = path.getParent().getParent().getParent(); + } else { // First try to find MapTool* directory in path while (path != null) { if (path.getFileName().toString().matches("(?i).*maptool.*")) { - path = path.getParent(); break; } path = path.getParent(); } } - if (path == null) { - return Path.of(getAppInstallLocation()); + if (path == null) { // if not found then just return the parent of the app subdir + return Path.of(getAppInstallLocation()).resolve("..").toAbsolutePath(); } else { return path; } 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 8690c595c4..8335950e02 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 @@ -465,7 +465,7 @@ public PreferencesDialog() { } final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); - installDirTextField.setText(AppUtil.getAppInstallLocation()); + installDirTextField.setText(AppUtil.getInstallDirectory().toString()); File appCfgFile = AppUtil.getAppCfgFile(); String copyInfo = ""; From 8583bb408a8275a5678d5b4a90cbe408c7f42c05 Mon Sep 17 00:00:00 2001 From: Kenneth VanderLinde Date: Wed, 18 Oct 2023 17:08:34 -0700 Subject: [PATCH 11/18] Disable developer options by default Also store developer options in a separate preference node to keep them separate from regular application preferences. This should make testing and fixups a little easier. --- .../java/net/rptools/maptool/client/DeveloperOptions.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/DeveloperOptions.java b/src/main/java/net/rptools/maptool/client/DeveloperOptions.java index ec695af7dc..2d97e90d6d 100644 --- a/src/main/java/net/rptools/maptool/client/DeveloperOptions.java +++ b/src/main/java/net/rptools/maptool/client/DeveloperOptions.java @@ -18,13 +18,10 @@ import java.util.List; import java.util.prefs.Preferences; import net.rptools.maptool.language.I18N; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; public class DeveloperOptions { - private static final Logger log = LogManager.getLogger(DeveloperOptions.class); private static final Preferences prefs = - Preferences.userRoot().node(AppConstants.APP_NAME + "/prefs"); + Preferences.userRoot().node(AppConstants.APP_NAME + "/dev"); public enum Toggle { /** @@ -57,7 +54,7 @@ public String getKey() { } public boolean isEnabled() { - return prefs.getBoolean(key, true); + return prefs.getBoolean(key, false); } public void setEnabled(boolean enabled) { From 13ccb12cbc4e06a273c26da209c21f8a3d6084a8 Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Thu, 19 Oct 2023 15:52:31 +1030 Subject: [PATCH 12/18] Move location of install directory preferences info --- .../preferencesdialog/PreferencesDialog.java | 6 +- .../PreferencesDialogView.form | 88 +++++++++---------- .../rptools/maptool/language/i18n.properties | 2 +- 3 files changed, 45 insertions(+), 51 deletions(-) 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 8335950e02..f30e655e91 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 @@ -390,6 +390,9 @@ public PreferencesDialog() { fileSyncPath = panel.getTextField("fileSyncPath"); fileSyncPathButton = (JButton) panel.getButton("fileSyncPathButton"); + final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); + installDirTextField.setText(AppUtil.getInstallDirectory().toString()); + publicKeyTextArea = (JTextArea) panel.getTextComponent("publicKeyTextArea"); regeneratePublicKey = (JButton) panel.getButton("regeneratePublicKey"); copyPublicKey = (JButton) panel.getButton("copyKey"); @@ -464,9 +467,6 @@ public PreferencesDialog() { } } - final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); - installDirTextField.setText(AppUtil.getInstallDirectory().toString()); - File appCfgFile = AppUtil.getAppCfgFile(); String copyInfo = ""; if (appCfgFile != null) { // Don't try to display message if running from dev. 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 c9d18a55f5..b5f9adfecd 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 @@ -3,7 +3,7 @@ - + @@ -966,11 +966,11 @@ - + - + @@ -981,7 +981,7 @@ - + @@ -1050,7 +1050,7 @@ - + @@ -1140,7 +1140,7 @@ - + @@ -1193,7 +1193,7 @@ - + @@ -1226,7 +1226,7 @@ - + @@ -1259,7 +1259,7 @@ - + @@ -1288,16 +1288,31 @@ - - - - - - + + - + - + + + + + + + + + + + + + + + + + + + + @@ -2004,7 +2019,7 @@ - + @@ -2017,7 +2032,7 @@ - + @@ -2103,7 +2118,7 @@ - + @@ -2171,7 +2186,7 @@ - + @@ -2207,7 +2222,7 @@ - + @@ -2243,7 +2258,7 @@ - + @@ -2265,12 +2280,12 @@ - + - + @@ -2315,31 +2330,10 @@ - + - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index 5e9009c741..c02409b4b7 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -691,7 +691,7 @@ Preferences.label.client.fitview = Fit GM view Preferences.label.client.fitview.tooltip = When forcing players to the GM's view, should the player's map be zoomed such that their screen shows at least the same content as the GM's screen? Preferences.label.client.default.username = Default Username Preferences.label.client.default.username.tooltip = The default username that appears in the MapTool toolbar. -Preferences.label.installDir = Installation Directory. +Preferences.label.installDir = Installation Directory Preferences.client.webEndPoint.port = Internal Web Server End Point Port Preferences.client.webEndPoint.port.tooltip = Web Server End Point Port (Internal MapTool Only) Preferences.client.default.username.value = Anonymous User From 12dbe1dd7c51543f34b75dfa9b94bf8a5d7ec904 Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Wed, 18 Oct 2023 13:24:18 +1030 Subject: [PATCH 13/18] Display installation directory in dev options --- .../preferencesdialog/PreferencesDialog.java | 3 ++ .../PreferencesDialogView.form | 29 ++++++++++++++++--- .../PreferencesDialogView.java | 1 - .../rptools/maptool/language/i18n.properties | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) 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..8335950e02 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 @@ -464,6 +464,9 @@ public PreferencesDialog() { } } + final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); + installDirTextField.setText(AppUtil.getInstallDirectory().toString()); + File appCfgFile = AppUtil.getAppCfgFile(); String copyInfo = ""; if (appCfgFile != null) { // Don't try to display message if running from dev. 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..c9d18a55f5 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 @@ -3,7 +3,7 @@ - + @@ -966,7 +966,7 @@ - + @@ -2304,7 +2304,7 @@ - + @@ -2315,10 +2315,31 @@ - + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.java b/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.java index 5aceef4a80..9939a1b641 100644 --- a/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.java +++ b/src/main/java/net/rptools/maptool/client/ui/preferencesdialog/PreferencesDialogView.java @@ -14,7 +14,6 @@ */ package net.rptools.maptool.client.ui.preferencesdialog; -import java.awt.*; import javax.swing.*; public class PreferencesDialogView { diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index c8ba1b1c1e..5e9009c741 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -691,6 +691,7 @@ Preferences.label.client.fitview = Fit GM view Preferences.label.client.fitview.tooltip = When forcing players to the GM's view, should the player's map be zoomed such that their screen shows at least the same content as the GM's screen? Preferences.label.client.default.username = Default Username Preferences.label.client.default.username.tooltip = The default username that appears in the MapTool toolbar. +Preferences.label.installDir = Installation Directory. Preferences.client.webEndPoint.port = Internal Web Server End Point Port Preferences.client.webEndPoint.port.tooltip = Web Server End Point Port (Internal MapTool Only) Preferences.client.default.username.value = Anonymous User From 6b9f490696bdfd07584cd4e3eeff0bb5ce11a33c Mon Sep 17 00:00:00 2001 From: cwisniew Date: Mon, 2 Oct 2023 20:20:46 +1030 Subject: [PATCH 14/18] apply compat fix for json.path.set and json.path.delete as well --- .../client/functions/json/JSONMacroFunctions.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java b/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java index c6d9f30c04..1a3c5a9779 100644 --- a/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java @@ -872,7 +872,12 @@ private JsonElement shallowCopy(JsonElement jsonElement) { * @return The resulting json data. */ private JsonElement jsonPathDelete(JsonElement json, String path) { - return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).delete(path).json(); + try { + return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).delete(path).json(); + } catch (PathNotFoundException ex) { + // Return original json, this is to preserve backwards compatability pre library update + return json; + } } /** @@ -906,7 +911,12 @@ private JsonElement jsonPathPut(JsonElement json, String path, String key, Objec private JsonElement jsonPathSet(JsonElement json, String path, Object info) { Object value = asJsonElement(info); - return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).set(path, value).json(); + try { + return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).set(path, value).json(); + } catch (PathNotFoundException ex) { + // Return original json, this is to preserve backwards compatability pre library update + return json; + } } /** From 5f11c9731c659cd3fa1345cfcc1355e5fb26906e Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Wed, 18 Oct 2023 14:32:42 +1030 Subject: [PATCH 15/18] Change to install location --- .../maptool/client/ui/preferencesdialog/PreferencesDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8335950e02..8690c595c4 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 @@ -465,7 +465,7 @@ public PreferencesDialog() { } final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); - installDirTextField.setText(AppUtil.getInstallDirectory().toString()); + installDirTextField.setText(AppUtil.getAppInstallLocation()); File appCfgFile = AppUtil.getAppCfgFile(); String copyInfo = ""; From 201d641e02eced261fb031bc1133e33fcc32fe33 Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Wed, 18 Oct 2023 18:01:32 +1030 Subject: [PATCH 16/18] fix --- src/main/java/net/rptools/maptool/client/AppUtil.java | 9 ++++----- .../client/ui/preferencesdialog/PreferencesDialog.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/AppUtil.java b/src/main/java/net/rptools/maptool/client/AppUtil.java index d5c18fda29..e89e94caae 100644 --- a/src/main/java/net/rptools/maptool/client/AppUtil.java +++ b/src/main/java/net/rptools/maptool/client/AppUtil.java @@ -213,18 +213,17 @@ public static Path getInstallDirectory() { var path = Path.of(getAppInstallLocation()); if (MapTool.isDevelopment()) { // remove build/classes/java - path = path.getParent().getParent().getParent().getParent(); - } else { + path = path.getParent().getParent().getParent(); + } else { // First try to find MapTool* directory in path while (path != null) { if (path.getFileName().toString().matches("(?i).*maptool.*")) { - path = path.getParent(); break; } path = path.getParent(); } } - if (path == null) { - return Path.of(getAppInstallLocation()); + if (path == null) { // if not found then just return the parent of the app subdir + return Path.of(getAppInstallLocation()).resolve("..").toAbsolutePath(); } else { return path; } 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 8690c595c4..8335950e02 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 @@ -465,7 +465,7 @@ public PreferencesDialog() { } final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); - installDirTextField.setText(AppUtil.getAppInstallLocation()); + installDirTextField.setText(AppUtil.getInstallDirectory().toString()); File appCfgFile = AppUtil.getAppCfgFile(); String copyInfo = ""; From c2306ba22c48153fc8df9c440d5f647fca593c18 Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Thu, 19 Oct 2023 15:52:31 +1030 Subject: [PATCH 17/18] Move location of install directory preferences info --- .../preferencesdialog/PreferencesDialog.java | 6 +- .../PreferencesDialogView.form | 88 +++++++++---------- .../rptools/maptool/language/i18n.properties | 2 +- 3 files changed, 45 insertions(+), 51 deletions(-) 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 8335950e02..f30e655e91 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 @@ -390,6 +390,9 @@ public PreferencesDialog() { fileSyncPath = panel.getTextField("fileSyncPath"); fileSyncPathButton = (JButton) panel.getButton("fileSyncPathButton"); + final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); + installDirTextField.setText(AppUtil.getInstallDirectory().toString()); + publicKeyTextArea = (JTextArea) panel.getTextComponent("publicKeyTextArea"); regeneratePublicKey = (JButton) panel.getButton("regeneratePublicKey"); copyPublicKey = (JButton) panel.getButton("copyKey"); @@ -464,9 +467,6 @@ public PreferencesDialog() { } } - final var installDirTextField = (JTextField) panel.getComponent("InstallDirTextField"); - installDirTextField.setText(AppUtil.getInstallDirectory().toString()); - File appCfgFile = AppUtil.getAppCfgFile(); String copyInfo = ""; if (appCfgFile != null) { // Don't try to display message if running from dev. 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 c9d18a55f5..b5f9adfecd 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 @@ -3,7 +3,7 @@ - + @@ -966,11 +966,11 @@ - + - + @@ -981,7 +981,7 @@ - + @@ -1050,7 +1050,7 @@ - + @@ -1140,7 +1140,7 @@ - + @@ -1193,7 +1193,7 @@ - + @@ -1226,7 +1226,7 @@ - + @@ -1259,7 +1259,7 @@ - + @@ -1288,16 +1288,31 @@ - - - - - - + + - + - + + + + + + + + + + + + + + + + + + + + @@ -2004,7 +2019,7 @@ - + @@ -2017,7 +2032,7 @@ - + @@ -2103,7 +2118,7 @@ - + @@ -2171,7 +2186,7 @@ - + @@ -2207,7 +2222,7 @@ - + @@ -2243,7 +2258,7 @@ - + @@ -2265,12 +2280,12 @@ - + - + @@ -2315,31 +2330,10 @@ - + - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index 5e9009c741..c02409b4b7 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -691,7 +691,7 @@ Preferences.label.client.fitview = Fit GM view Preferences.label.client.fitview.tooltip = When forcing players to the GM's view, should the player's map be zoomed such that their screen shows at least the same content as the GM's screen? Preferences.label.client.default.username = Default Username Preferences.label.client.default.username.tooltip = The default username that appears in the MapTool toolbar. -Preferences.label.installDir = Installation Directory. +Preferences.label.installDir = Installation Directory Preferences.client.webEndPoint.port = Internal Web Server End Point Port Preferences.client.webEndPoint.port.tooltip = Web Server End Point Port (Internal MapTool Only) Preferences.client.default.username.value = Anonymous User From 3b7bdfbf585d745e63b6c2c55f6aa16fc7ac2488 Mon Sep 17 00:00:00 2001 From: Kenneth VanderLinde Date: Wed, 18 Oct 2023 17:08:34 -0700 Subject: [PATCH 18/18] Disable developer options by default Also store developer options in a separate preference node to keep them separate from regular application preferences. This should make testing and fixups a little easier. --- .../java/net/rptools/maptool/client/DeveloperOptions.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/DeveloperOptions.java b/src/main/java/net/rptools/maptool/client/DeveloperOptions.java index ec695af7dc..2d97e90d6d 100644 --- a/src/main/java/net/rptools/maptool/client/DeveloperOptions.java +++ b/src/main/java/net/rptools/maptool/client/DeveloperOptions.java @@ -18,13 +18,10 @@ import java.util.List; import java.util.prefs.Preferences; import net.rptools.maptool.language.I18N; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; public class DeveloperOptions { - private static final Logger log = LogManager.getLogger(DeveloperOptions.class); private static final Preferences prefs = - Preferences.userRoot().node(AppConstants.APP_NAME + "/prefs"); + Preferences.userRoot().node(AppConstants.APP_NAME + "/dev"); public enum Toggle { /** @@ -57,7 +54,7 @@ public String getKey() { } public boolean isEnabled() { - return prefs.getBoolean(key, true); + return prefs.getBoolean(key, false); } public void setEnabled(boolean enabled) {