summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/EnumPropertyEditor.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/EnumPropertyEditor.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/EnumPropertyEditor.java')
-rw-r--r--NET/worlds/scape/EnumPropertyEditor.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/NET/worlds/scape/EnumPropertyEditor.java b/NET/worlds/scape/EnumPropertyEditor.java
new file mode 100644
index 0000000..07a363a
--- /dev/null
+++ b/NET/worlds/scape/EnumPropertyEditor.java
@@ -0,0 +1,47 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.PolledDialog;
+
+public class EnumPropertyEditor extends PropEditor {
+ private String[] choices;
+ private int[] numbers;
+
+ private EnumPropertyEditor(Property property, String[] names, int[] values) {
+ super(property);
+
+ assert names != null;
+
+ assert values != null;
+
+ int len = Math.max(names.length, values.length);
+
+ assert len > 1;
+
+ this.choices = new String[len];
+ this.numbers = new int[len];
+
+ for (int i = 0; i < len; i++) {
+ if (i < names.length) {
+ this.choices[i] = names[i];
+ } else {
+ this.choices[i] = names[names.length - 1] + i;
+ }
+
+ if (i < values.length) {
+ this.numbers[i] = values[i];
+ } else {
+ this.numbers[i] = values[values.length - 1] + i - values.length;
+ }
+ }
+ }
+
+ @Override
+ public PolledDialog edit(EditTile parent, String title) {
+ return new EnumFieldEditorDialog(parent, title, this.property, this.choices, this.numbers);
+ }
+
+ public static Property make(Property property, String[] names, int[] values) {
+ property.setPropertyType(5);
+ return property.setEditor(new EnumPropertyEditor(property, names, values));
+ }
+}