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

Refresh Dynamic Property by name #13526

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
14 changes: 14 additions & 0 deletions vassal-app/src/main/java/VASSAL/build/GpIdChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import VASSAL.build.widget.PieceSlot;
import VASSAL.counters.BasicPiece;
import VASSAL.counters.Decorator;
import VASSAL.counters.DynamicProperty;
import VASSAL.counters.Embellishment;
import VASSAL.counters.FreeRotator;
import VASSAL.counters.GamePiece;
Expand Down Expand Up @@ -89,6 +90,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$
}
Expand Down Expand Up @@ -356,6 +362,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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,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";
Expand Down Expand Up @@ -746,6 +747,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;
Expand Down Expand Up @@ -813,6 +815,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);
Expand Down Expand Up @@ -886,6 +890,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$
}
Expand Down
6 changes: 6 additions & 0 deletions vassal-app/src/main/java/VASSAL/counters/DynamicProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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, ';');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=<html>After refresh trigger Global Hotkey <i>VassalPostRefreshGHK</i></html>
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
Expand Down