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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
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);
}
}
|