diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/ObjectSelectorDialog.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/ObjectSelectorDialog.java')
| -rw-r--r-- | NET/worlds/scape/ObjectSelectorDialog.java | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/NET/worlds/scape/ObjectSelectorDialog.java b/NET/worlds/scape/ObjectSelectorDialog.java new file mode 100644 index 0000000..f02a89e --- /dev/null +++ b/NET/worlds/scape/ObjectSelectorDialog.java @@ -0,0 +1,91 @@ +package NET.worlds.scape; + +import NET.worlds.core.Std; +import java.util.Enumeration; +import java.util.Vector; + +abstract class ObjectSelectorDialog extends ListAdderDialog { + private Property property; + private Vector objectVector = null; + SuperRoot root = null; + Class clas = null; + + ObjectSelectorDialog(EditTile parent, String title, Property property, SuperRoot r, Class clas) { + super(parent, title); + this.property = property; + this.root = r; + this.clas = clas; + this.ready(); + } + + private void quicksort(String[] objectList, int l, int r) { + if (r > l) { + String v = objectList[r]; + int i = l - 1; + int j = r; + + String tstr; + Object tobj; + do { + while (objectList[++i].compareTo(v) < 0) { + } + + do { + j--; + } while (j > l && objectList[j].compareTo(v) > 0); + + tstr = objectList[i]; + objectList[i] = objectList[j]; + objectList[j] = tstr; + tobj = this.objectVector.elementAt(i); + this.objectVector.setElementAt(this.objectVector.elementAt(j), i); + this.objectVector.setElementAt(tobj, j); + } while (j > i); + + objectList[j] = objectList[i]; + objectList[i] = objectList[r]; + objectList[r] = tstr; + this.objectVector.setElementAt(this.objectVector.elementAt(i), j); + this.objectVector.setElementAt(this.objectVector.elementAt(r), i); + this.objectVector.setElementAt(tobj, r); + this.quicksort(objectList, l, i - 1); + this.quicksort(objectList, i + 1, r); + } + } + + @Override + protected void build() { + this.objectVector = new Vector(); + if (this.root != null) { + Enumeration e = this.root.getDeepOwned(); + + while (e.hasMoreElements()) { + Object obj = e.nextElement(); + if (Std.instanceOf(obj, this.clas)) { + this.objectVector.addElement(obj); + } + } + + String[] objectList = new String[this.objectVector.size()]; + + for (int i = 0; i < objectList.length; i++) { + objectList[i] = this.objectVector.elementAt(i).toString(); + } + + this.quicksort(objectList, 0, objectList.length - 1); + this.setListContents(objectList); + } + + super.build(); + } + + protected abstract void addIt(Property var1, Object var2); + + @Override + protected void add(int option) { + Object obj = this.objectVector.elementAt(option); + if (obj != null) { + this.addIt(this.property, obj); + } + } +} |