summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/IntegerPropertyEditor.java
blob: dc210ac1172941d898353745acbde055664f6f03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package NET.worlds.scape;

import NET.worlds.console.PolledDialog;

public class IntegerPropertyEditor extends PropEditor {
   boolean rangeLimits = false;
   int minVal;
   int maxVal;

   private IntegerPropertyEditor(Property property) {
      super(property);
   }

   private IntegerPropertyEditor(Property property, int minVal, int maxVal) {
      super(property);
      this.rangeLimits = true;
      this.minVal = minVal;
      this.maxVal = maxVal;
   }

   @Override
   public PolledDialog edit(EditTile parent, String title) {
      return new IntegerFieldEditorDialog(parent, title, this.property, this);
   }

   public static Property make(Property property) {
      property.setPropertyType(1);
      return property.setEditor(new IntegerPropertyEditor(property));
   }

   public static Property make(Property property, int minVal, int maxVal) {
      property.setPropertyType(1);
      return property.setEditor(new IntegerPropertyEditor(property, minVal, maxVal));
   }
}