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/PropList.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/PropList.java')
| -rw-r--r-- | NET/worlds/scape/PropList.java | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/NET/worlds/scape/PropList.java b/NET/worlds/scape/PropList.java new file mode 100644 index 0000000..2a9d3a4 --- /dev/null +++ b/NET/worlds/scape/PropList.java @@ -0,0 +1,119 @@ +package NET.worlds.scape; + +import NET.worlds.core.IniFile; +import java.awt.List; +import java.util.Enumeration; +import java.util.Vector; + +public class PropList extends List { + private Object obj; + private Vector properties; + private static String[] sortOrder = new String[]{ + "Name", + "Tilesize", + "Transform", + "From", + "To", + "Extent", + "Bumpable", + "Collision Extent", + "Visible", + "Optimizable", + "DrawFirstOnIntersection", + "DrawOrderUnimportant" + }; + + static { + int numUserPreferences = IniFile.gamma().getIniInt("PropertyOrderCount", -1); + if (numUserPreferences >= 0) { + sortOrder = new String[numUserPreferences]; + + for (int i = 0; i < numUserPreferences; i++) { + sortOrder[i] = IniFile.gamma().getIniString("PropertyOrder" + i, ""); + } + } + } + + public static void setPreferences(String[] prefs) { + sortOrder = prefs; + } + + public Object getObject() { + return this.obj; + } + + public void setObject(Object obj) { + int selected = this.getSelectedIndex(); + if (obj != this.obj) { + selected = -1; + } + + this.obj = obj; + int count = this.countItems(); + if (count != 0) { + this.delItems(0, count - 1); + } + + Vector unsorted = new Vector(); + Enumeration e = new EnumProperties(obj); + + for (int var11 = 0; e.hasMoreElements(); var11++) { + Property p = (Property)e.nextElement(); + if (!(p instanceof VectorProperty) && (p.getEditor() != null || !(p.get() instanceof Properties))) { + unsorted.addElement(p); + } + } + + this.properties = new Vector(unsorted.size()); + + for (int sortItem = 0; sortItem < sortOrder.length; sortItem++) { + String s = sortOrder[sortItem]; + int size = unsorted.size(); + + for (int i = 0; i < size; i++) { + Property p = (Property)unsorted.elementAt(i); + if (p.getName().equals(s)) { + this.properties.addElement(p); + unsorted.removeElementAt(i); + break; + } + } + } + + int size = unsorted.size(); + + for (int ix = 0; ix < size; ix++) { + this.properties.addElement(unsorted.elementAt(ix)); + } + + size = this.properties.size(); + + for (int ix = 0; ix < size; ix++) { + Property prop = (Property)this.properties.elementAt(ix); + this.addItem(prop.getName() + " (" + prop.getPropertyType() + ")" + " (" + prop.get() + ")"); + } + + count = this.countItems(); + if (count != 0 && selected != -1) { + if (selected >= count) { + selected = count - 1; + } + + this.select(selected); + } + } + + public Property getSelectedProperty() { + int i = this.getSelectedIndex(); + return i != -1 ? (Property)this.properties.elementAt(i) : null; + } + + @Override + public void addItem(String s) { + if (s.length() > 128) { + s = s.substring(0, 125) + "..."; + } + + super.addItem(s); + } +} |