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)); } }