summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/SetPropertyAction.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/SetPropertyAction.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/SetPropertyAction.java')
-rw-r--r--NET/worlds/scape/SetPropertyAction.java270
1 files changed, 270 insertions, 0 deletions
diff --git a/NET/worlds/scape/SetPropertyAction.java b/NET/worlds/scape/SetPropertyAction.java
new file mode 100644
index 0000000..1bb2f45
--- /dev/null
+++ b/NET/worlds/scape/SetPropertyAction.java
@@ -0,0 +1,270 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.Console;
+import NET.worlds.console.Gamma;
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.Enumeration;
+
+public abstract class SetPropertyAction extends Action {
+ SuperRoot _target;
+ String _targetName;
+ String _roomName;
+ String _propName;
+ private int _propIndex = -1;
+ private String _paramName = null;
+ private static Object classCookie = new Object();
+
+ public SuperRoot getTarget() {
+ if (this._target == null && this._targetName != null) {
+ Room r = null;
+ if (this._roomName != null) {
+ World w = this.getWorld();
+ if (w != null) {
+ r = w.getRoom(this._roomName);
+ }
+ } else {
+ r = this.getRoom();
+ }
+
+ if (r != null) {
+ Enumeration list = r.getDeepOwned();
+ this._target = SuperRoot.nameSearch(list, this._targetName);
+ }
+ }
+
+ return this._target != null ? this._target : this.getOwner();
+ }
+
+ protected boolean useParam() {
+ return this._paramName != null;
+ }
+
+ protected String paramName() {
+ return this._paramName;
+ }
+
+ protected String param() {
+ return this._paramName == null ? null : Gamma.getParam(this._paramName);
+ }
+
+ static int index(int index, String name, Object target) {
+ if (index == -1 && name != null) {
+ Enumeration pe = new EnumProperties(target);
+
+ while (pe.hasMoreElements()) {
+ Property prop = (Property)pe.nextElement();
+ if (prop.getName().equals(name)) {
+ index = prop.getIndex();
+ break;
+ }
+ }
+ }
+
+ return index;
+ }
+
+ public static Object propHelper(int mode, Object value, String name, SuperRoot target) {
+ Object ret = null;
+ int i = index(-1, name, target);
+ if (i != -1) {
+ try {
+ ret = target.properties(i, 0, mode, value);
+ } catch (NoSuchPropertyException var7) {
+ }
+ }
+
+ return ret;
+ }
+
+ private Object propHelper(int mode, Object value) {
+ SuperRoot target = this.getTarget();
+ Object ret = null;
+ if ((this._propIndex = index(this._propIndex, this._propName, target)) != -1) {
+ try {
+ ret = target.properties(this._propIndex, 0, mode, value);
+ } catch (NoSuchPropertyException var6) {
+ assert false;
+ }
+ } else if (target == null) {
+ Console.println(this.getName() + Console.message("null-target"));
+ } else if (this._propName == null) {
+ Object[] arguments = new Object[]{new String(this.getName()), new String(this.getTarget().getName())};
+ Console.println(MessageFormat.format(Console.message("null-property"), arguments));
+ } else {
+ Object[] arguments = new Object[]{new String(this.getName()), new String(this._propName), new String(this.getTarget().getName())};
+ Console.println(MessageFormat.format(Console.message("non-property"), arguments));
+ }
+
+ return ret;
+ }
+
+ protected final void set(Object value) {
+ this.propHelper(2, value);
+ }
+
+ protected final Object get() {
+ return this.propHelper(1, null);
+ }
+
+ protected final void add(Object value) {
+ this.propHelper(3, value);
+ }
+
+ protected final void remove(Object value) {
+ this.propHelper(4, value);
+ }
+
+ protected final Property enumerate() {
+ return (Property)this.propHelper(0, null);
+ }
+
+ @Override
+ public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
+ Object ret = null;
+ switch (index - offset) {
+ case 0:
+ if (mode == 0) {
+ Property p = new Property(this, index, "Target");
+ p.allowSetNull();
+ ret = ObjPropertyEditor.make(p, this.getRoom(), "NET.worlds.scape.SuperRoot");
+ } else if (mode == 1) {
+ ret = this.getTarget();
+ } else if (mode == 2) {
+ this._target = (SuperRoot)value;
+ this._propIndex = -1;
+ }
+ break;
+ case 1:
+ if (mode == 0) {
+ ret = StringPropertyEditor.make(new Property(this, index, "Target Room"));
+ } else if (mode == 1) {
+ ret = this._roomName;
+ } else if (mode == 4) {
+ this._roomName = null;
+ } else if (mode == 2) {
+ this._roomName = (String)value;
+ this._target = null;
+ }
+ break;
+ case 2:
+ if (mode == 0) {
+ Property p = new Property(this, index, "Target Name");
+ p.allowSetNull();
+ ret = StringPropertyEditor.make(p);
+ } else if (mode == 1) {
+ ret = this._targetName;
+ } else if (mode == 4) {
+ this._targetName = null;
+ } else if (mode == 2) {
+ this._targetName = (String)value;
+ this._target = null;
+ }
+ break;
+ case 3:
+ if (mode == 0) {
+ ret = new Property(this, index, "Property Name");
+ if (this.getTarget() != null) {
+ ret = PropPropEditor.make((Property)ret, this.getTarget(), true);
+ }
+ } else if (mode == 1) {
+ SuperRoot t = this.getTarget();
+ if ((this._propIndex = index(this._propIndex, this._propName, t)) != -1 && t != null) {
+ ret = this.enumerate();
+ } else {
+ ret = null;
+ }
+ } else if (mode == 2) {
+ if (value == null) {
+ this._propIndex = -1;
+ this._propName = null;
+ } else if (value instanceof String) {
+ this._propIndex = -1;
+ this._propName = (String)value;
+ } else {
+ this._propIndex = ((Property)value).getIndex();
+ this._propName = ((Property)value).getName();
+ }
+ }
+ break;
+ case 4:
+ if (mode == 0) {
+ ret = BooleanPropertyEditor.make(new Property(this, index, "Use parameter"), "Use 'Set To' value", "Use parameter");
+ } else if (mode == 1) {
+ ret = new Boolean(this._paramName != null);
+ } else if (mode == 2) {
+ if ((Boolean)value) {
+ if (this._paramName == null) {
+ this._paramName = "";
+ }
+ } else {
+ this._paramName = null;
+ }
+ }
+ break;
+ case 5:
+ if (mode == 0) {
+ ret = new Property(this, index, "Parameter Name");
+ if (this._paramName != null) {
+ ret = StringPropertyEditor.make((Property)ret);
+ }
+ } else if (mode == 1) {
+ ret = this._paramName == null ? "" : this._paramName;
+ } else if (mode == 2) {
+ this._paramName = (String)value;
+ }
+ break;
+ default:
+ ret = super.properties(index, offset + 6, mode, value);
+ }
+
+ return ret;
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ s.saveVersion(4, classCookie);
+ super.saveState(s);
+ s.saveMaybeNull(this.getTarget());
+ s.saveString(this._roomName);
+ s.saveString(this._targetName);
+ s.saveString(this._propName);
+ s.saveString(this._paramName);
+ }
+
+ protected void setPropertyActionRestoreState(Restorer r) throws IOException, TooNewException {
+ switch (r.restoreVersion(classCookie)) {
+ case 1:
+ super.restoreState(r);
+ this._target = (SuperRoot)r.restore();
+ this._propName = r.restoreString();
+ break;
+ case 2:
+ super.restoreState(r);
+ this._target = (SuperRoot)r.restoreMaybeNull();
+ this._propName = r.restoreString();
+ break;
+ case 3:
+ super.restoreState(r);
+ this._target = (SuperRoot)r.restoreMaybeNull();
+ this._propName = r.restoreString();
+ this._paramName = r.restoreString();
+ break;
+ case 4:
+ super.restoreState(r);
+ this._target = (SuperRoot)r.restoreMaybeNull();
+ this._roomName = r.restoreString();
+ this._targetName = r.restoreString();
+ this._propName = r.restoreString();
+ this._paramName = r.restoreString();
+ break;
+ default:
+ throw new TooNewException();
+ }
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ this.setPropertyActionRestoreState(r);
+ }
+}