diff --git a/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java b/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java index e69322441a..93a4940cb2 100644 --- a/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java +++ b/vassal-app/src/main/java/VASSAL/build/GpIdChecker.java @@ -288,7 +288,7 @@ protected void copyState(GamePiece oldPiece, GamePiece newPiece) { // Do not copy the state of Marker traits, we want to see the new value from the new definition if (newState != null && !(decoratorNew instanceof Marker)) { // Do not copy Labeler (Text Label) label state UNLESS this Text Label has the capacity to be manually updated - if (!(decoratorNew instanceof Labeler) || ((((Labeler)decoratorNew).getLabelKey() != null) && !NamedKeyStroke.NULL_KEYSTROKE.equals(((Labeler)decoratorNew).getLabelKey()))) { + if (!(decoratorNew instanceof Labeler) || ((Labeler) decoratorNew).canChange()) { decoratorNew.mySetState(newState); } } diff --git a/vassal-app/src/main/java/VASSAL/counters/Labeler.java b/vassal-app/src/main/java/VASSAL/counters/Labeler.java index 39a319bcac..54112ca1ba 100644 --- a/vassal-app/src/main/java/VASSAL/counters/Labeler.java +++ b/vassal-app/src/main/java/VASSAL/counters/Labeler.java @@ -133,6 +133,11 @@ public NamedKeyStroke getLabelKey() { return labelKey; } + /** Can this Label be changed? */ + public boolean canChange() { + return getLabelKey() != null && !NamedKeyStroke.NULL_KEYSTROKE.equals(getLabelKey()); + } + @Override public void mySetType(String type) { commands = null; diff --git a/vassal-app/src/main/java/VASSAL/counters/Replace.java b/vassal-app/src/main/java/VASSAL/counters/Replace.java index 97fb891107..914c38a1bd 100644 --- a/vassal-app/src/main/java/VASSAL/counters/Replace.java +++ b/vassal-app/src/main/java/VASSAL/counters/Replace.java @@ -24,6 +24,7 @@ import VASSAL.configure.BooleanConfigurer; import VASSAL.i18n.PieceI18nData; import VASSAL.i18n.Resources; +import VASSAL.tools.NamedKeyStroke; import javax.swing.KeyStroke; import java.util.ArrayList; @@ -183,6 +184,13 @@ protected void matchTraits(GamePiece base, GamePiece marker) { candidate = null; } } + // Labels are only state matched if they are adjustable. Note this matches the behaviour of the Game Refresher + else if (currentMarker instanceof Labeler) { + if (((Labeler) currentMarker).canChange()) { + currentMarker.mySetState(candidate.myGetState()); + candidate = null; + } + } // Match all other Decorators on full type else { if (candidate.myGetType().equals(currentMarker.myGetType())) {