From ed9b9a762e90e46cb49c6ef9512f3bdc038ec061 Mon Sep 17 00:00:00 2001 From: Mark Benson Date: Sun, 11 Aug 2024 12:24:15 +0100 Subject: [PATCH 1/2] Refreshable DP. --- .../main/java/VASSAL/build/GpIdChecker.java | 24 +++++++++++-------- .../VASSAL/build/module/GameRefresher.java | 17 +++++++------ .../java/VASSAL/counters/DynamicProperty.java | 6 +++++ .../resources/VASSAL/i18n/VASSAL.properties | 1 + 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java b/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java index 408ad32d68..5fa72a44ef 100644 --- a/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java +++ b/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java @@ -21,16 +21,7 @@ import VASSAL.build.module.GameRefresher; import VASSAL.build.module.PrototypeDefinition; import VASSAL.build.widget.PieceSlot; -import VASSAL.counters.BasicPiece; -import VASSAL.counters.Decorator; -import VASSAL.counters.Embellishment; -import VASSAL.counters.FreeRotator; -import VASSAL.counters.GamePiece; -import VASSAL.counters.Labeler; -import VASSAL.counters.Marker; -import VASSAL.counters.PieceCloner; -import VASSAL.counters.PlaceMarker; -import VASSAL.counters.Properties; +import VASSAL.counters.*; import VASSAL.i18n.Resources; import java.util.ArrayList; @@ -89,6 +80,11 @@ public boolean useLayerName() { public boolean useRotateName() { return refresherOptions.contains(GameRefresher.USE_ROTATE_NAME); //$NON-NLS-1$ } + + public boolean useDynamicPropertyName() { + return refresherOptions.contains(GameRefresher.USE_DYNAMICPROPERTY_NAME); //$NON-NLS-1$ + } + public boolean useName() { return refresherOptions.contains(GameRefresher.USE_NAME); //$NON-NLS-1$ } @@ -357,6 +353,14 @@ else if (d instanceof FreeRotator) { } } } + else if (d instanceof DynamicProperty) { + if (useDynamicPropertyName()) { + final String nameToFind = ((DynamicProperty)decoratorNewPc).getDynamicPropertyName(); + if (((DynamicProperty) d).getDynamicPropertyName().equals(nameToFind)) { + return d.myGetState(); + } + } + } } p = d.getInner(); diff --git a/vassal-app/src/main/java/VASSAL/build/module/GameRefresher.java b/vassal-app/src/main/java/VASSAL/build/module/GameRefresher.java index a8cfe393c2..99aa079436 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/GameRefresher.java +++ b/vassal-app/src/main/java/VASSAL/build/module/GameRefresher.java @@ -35,15 +35,7 @@ import VASSAL.command.NullCommand; import VASSAL.command.RemovePiece; import VASSAL.configure.ConfigurerLayout; -import VASSAL.counters.Attachment; -import VASSAL.counters.Deck; -import VASSAL.counters.Decorator; -import VASSAL.counters.GamePiece; -import VASSAL.counters.Mat; -import VASSAL.counters.MatCargo; -import VASSAL.counters.MatHolder; -import VASSAL.counters.Properties; -import VASSAL.counters.Stack; +import VASSAL.counters.*; import VASSAL.i18n.Resources; import VASSAL.tools.BrowserSupport; import VASSAL.tools.ErrorDialog; @@ -97,6 +89,7 @@ public final class GameRefresher implements CommandEncoder, GameComponent { public static final String USE_LABELER_NAME = "UseLabelerName"; public static final String USE_LAYER_NAME = "UseLayerName"; public static final String USE_ROTATE_NAME = "UseRotateName"; + public static final String USE_DYNAMICPROPERTY_NAME = "UseDynamicPropertyName"; public static final String TEST_MODE = "TestMode"; public static final String DELETE_NO_MAP = "DeleteNoMap"; public static final String REFRESH_DECKS = "RefreshDecks"; @@ -747,6 +740,7 @@ static class RefreshDialog extends JDialog { private JCheckBox labelerNameCheck; private JCheckBox layerNameCheck; private JCheckBox rotateNameCheck; + private JCheckBox dynamicPropertyNameCheck; private JCheckBox deletePieceNoMap; private JCheckBox refreshDecks; private JCheckBox deleteOldDecks; @@ -814,6 +808,8 @@ public void windowClosing(WindowEvent we) { fixGPID = new JCheckBox(Resources.getString("GameRefresher.fix_gpid")); panel.add(fixGPID, "gapx 20"); + dynamicPropertyNameCheck = new JCheckBox(Resources.getString("GameRefresher.use_dynamicProperty_descr"), true); + panel.add(dynamicPropertyNameCheck, "gapx 10"); labelerNameCheck = new JCheckBox(Resources.getString("GameRefresher.use_labeler_descr"), true); panel.add(labelerNameCheck, "gapx 10"); layerNameCheck = new JCheckBox(Resources.getString("GameRefresher.use_layer_descr"), true); @@ -887,6 +883,9 @@ protected void setOptions() { if (rotateNameCheck.isSelected()) { options.add(USE_ROTATE_NAME); //$NON-NLS-1$ } + if (dynamicPropertyNameCheck.isSelected()) { + options.add(USE_DYNAMICPROPERTY_NAME); //$NON-NLS-1$ + } if (testModeOn.isSelected()) { options.add(TEST_MODE); //$NON-NLS-1$ } diff --git a/vassal-app/src/main/java/VASSAL/counters/DynamicProperty.java b/vassal-app/src/main/java/VASSAL/counters/DynamicProperty.java index 75f66c8bd1..c96be4c2dc 100644 --- a/vassal-app/src/main/java/VASSAL/counters/DynamicProperty.java +++ b/vassal-app/src/main/java/VASSAL/counters/DynamicProperty.java @@ -76,6 +76,8 @@ public class DynamicProperty extends Decorator implements TranslatablePiece, Pro protected String value = ""; + protected String name = Resources.getString("Editor.DynamicProperty.trait_description"); + protected String key; protected boolean numeric; protected int minValue; @@ -99,6 +101,10 @@ public DynamicProperty(String type, GamePiece p) { mySetType(type); } + public String getDynamicPropertyName() { + return name; + } + @Override public void mySetType(String s) { final SequenceEncoder.Decoder sd = new SequenceEncoder.Decoder(s, ';'); diff --git a/vassal-app/src/main/resources/VASSAL/i18n/VASSAL.properties b/vassal-app/src/main/resources/VASSAL/i18n/VASSAL.properties index 6f170f2a31..257a2e187f 100644 --- a/vassal-app/src/main/resources/VASSAL/i18n/VASSAL.properties +++ b/vassal-app/src/main/resources/VASSAL/i18n/VASSAL.properties @@ -705,6 +705,7 @@ GameRefresher.test_mode=Test Mode - Game will not be updated GameRefresher.use_basic_name=Use counter names to identify unknown counters GameRefresher.fire_global_hotkey=After refresh trigger Global Hotkey VassalPostRefreshGHK GameRefresher.fix_gpid=Refreshed counter will adopt matching counter's Piece Id +GameRefresher.use_dynamicProperty_descr=Use property names to match modified Dynamic Property traits GameRefresher.use_labeler_descr=Use Label descriptions to match modified Text Label traits GameRefresher.use_layer_descr=Use Layer names to match modified Layer traits GameRefresher.use_rotate_descr=Use Rotator names to match modified Can Rotate traits From 063df4297fa64b75589faefae2deb899cf4f9d20 Mon Sep 17 00:00:00 2001 From: Mark Benson Date: Sun, 11 Aug 2024 13:38:41 +0100 Subject: [PATCH 2/2] Restore imports for Counters.* --- .../src/main/java/VASSAL/build/GpIdChecker.java | 12 +++++++++++- .../main/java/VASSAL/build/module/GameRefresher.java | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java b/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java index 0a00013f18..3fbace8e4d 100644 --- a/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java +++ b/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java @@ -21,7 +21,17 @@ import VASSAL.build.module.GameRefresher; import VASSAL.build.module.PrototypeDefinition; import VASSAL.build.widget.PieceSlot; -import VASSAL.counters.*; +import VASSAL.counters.BasicPiece; +import VASSAL.counters.Decorator; +import VASSAL.counters.DynamicProperty; +import VASSAL.counters.Embellishment; +import VASSAL.counters.FreeRotator; +import VASSAL.counters.GamePiece; +import VASSAL.counters.Labeler; +import VASSAL.counters.Marker; +import VASSAL.counters.PieceCloner; +import VASSAL.counters.PlaceMarker; +import VASSAL.counters.Properties; import VASSAL.i18n.Resources; import java.util.ArrayList; diff --git a/vassal-app/src/main/java/VASSAL/build/module/GameRefresher.java b/vassal-app/src/main/java/VASSAL/build/module/GameRefresher.java index 54cccdedb7..f1e03db960 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/GameRefresher.java +++ b/vassal-app/src/main/java/VASSAL/build/module/GameRefresher.java @@ -35,7 +35,15 @@ import VASSAL.command.NullCommand; import VASSAL.command.RemovePiece; import VASSAL.configure.ConfigurerLayout; -import VASSAL.counters.*; +import VASSAL.counters.Attachment; +import VASSAL.counters.Deck; +import VASSAL.counters.Decorator; +import VASSAL.counters.GamePiece; +import VASSAL.counters.Mat; +import VASSAL.counters.MatCargo; +import VASSAL.counters.MatHolder; +import VASSAL.counters.Properties; +import VASSAL.counters.Stack; import VASSAL.i18n.Resources; import VASSAL.tools.BrowserSupport; import VASSAL.tools.ErrorDialog;