summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/Property.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/Property.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/Property.java')
-rw-r--r--NET/worlds/scape/Property.java153
1 files changed, 153 insertions, 0 deletions
diff --git a/NET/worlds/scape/Property.java b/NET/worlds/scape/Property.java
new file mode 100644
index 0000000..31b797a
--- /dev/null
+++ b/NET/worlds/scape/Property.java
@@ -0,0 +1,153 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.Main;
+
+public class Property {
+ protected Properties owner;
+ public static final int BOOL_TYPE = 0;
+ public static final int INT_TYPE = 1;
+ public static final int FLOAT_TYPE = 2;
+ public static final int STRING_TYPE = 3;
+ public static final int COLOR_TYPE = 4;
+ public static final int ENUM_TYPE = 5;
+ public static final int FLOAT_ARRAY_TYPE = 6;
+ public static final int POINT2_TYPE = 7;
+ public static final int POINT3_TYPE = 8;
+ public static final int TRANSFORM_TYPE = 9;
+ public static final int URL_TYPE = 10;
+ protected int index;
+ protected String name;
+ protected int propertyType = 3;
+ protected PropEditor editor;
+ public boolean helpExists = false;
+ protected boolean canSetNull = false;
+
+ public Property(Properties owner, int index, String name) {
+ this.owner = owner;
+ this.index = index;
+ this.name = name;
+ }
+
+ public Property(Properties owner, int index, String name, boolean haveHelp) {
+ this.owner = owner;
+ this.index = index;
+ this.name = name;
+ this.helpExists = haveHelp;
+ }
+
+ Property setEditor(PropEditor editor) {
+ this.editor = editor;
+ return this;
+ }
+
+ public PropEditor getEditor() {
+ return this.editor;
+ }
+
+ public Property allowSetNull() {
+ this.canSetNull = true;
+ return this;
+ }
+
+ public boolean canSetNull() {
+ return this.canSetNull;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ public Properties getOwner() {
+ return this.owner;
+ }
+
+ public Object get() {
+ return this.operate(1, null);
+ }
+
+ public Object set(Object obj) {
+ return this.operate(2, obj);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof Property && ((Property)obj).owner == this.owner && ((Property)obj).index == this.index;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.owner.hashCode() ^ this.index;
+ }
+
+ protected Object operate(int func, Object value) {
+ return Main.isMainThread() ? this.safeOperate(func, value) : new CallbackPropertyOperator(this, func, value).getValue();
+ }
+
+ Object safeOperate(int func, Object value) {
+ try {
+ Object ret = this.owner.properties(this.index, 0, func, value);
+ if (func > 1 && func < 5 && this.owner instanceof SuperRoot) {
+ ((SuperRoot)this.owner).markEdited();
+ }
+
+ return ret;
+ } catch (NoSuchPropertyException var4) {
+ assert false;
+
+ return null;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.getName();
+ }
+
+ public void setPropertyType(int type) {
+ this.propertyType = type;
+ }
+
+ public String getPropertyType() {
+ String retVal;
+ switch (this.propertyType) {
+ case 0:
+ retVal = "Boolean";
+ break;
+ case 1:
+ retVal = "Integer";
+ break;
+ case 2:
+ retVal = "Float";
+ break;
+ case 3:
+ retVal = "String";
+ break;
+ case 4:
+ retVal = "Color";
+ break;
+ case 5:
+ retVal = "Enumeration";
+ break;
+ case 6:
+ retVal = "Float Array";
+ break;
+ case 7:
+ retVal = "2D Point";
+ break;
+ case 8:
+ retVal = "3D Point";
+ break;
+ case 9:
+ retVal = "Transform";
+ break;
+ default:
+ retVal = "URL";
+ }
+
+ return retVal;
+ }
+}