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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
/* */ package NET.worlds.scape;
/* */
/* */ import NET.worlds.core.IniFile;
/* */ import NET.worlds.network.NetUpdate;
/* */ import NET.worlds.network.URL;
/* */ import java.awt.Menu;
/* */ import java.awt.MenuItem;
/* */ import java.awt.event.ActionEvent;
/* */ import java.awt.event.ActionListener;
/* */ import java.io.File;
/* */ import java.io.IOException;
/* */ import java.io.PrintStream;
/* */ import java.io.RandomAccessFile;
/* */ import java.util.Enumeration;
/* */ import java.util.StringTokenizer;
/* */ import java.util.Vector;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class AnimatedActionManager
/* */ implements ActionListener, BGLoaded
/* */ {
/* */ public static AnimatedActionManager get()
/* */ {
/* 38 */ if (theAnimatedActionManager == null) {
/* 39 */ theAnimatedActionManager = new AnimatedActionManager();
/* */ }
/* 41 */ return theAnimatedActionManager;
/* */ }
/* */
/* */ private Vector<AnimatedAction> getActionList(URL avatar, URL object)
/* */ {
/* 46 */ if ((this.actionList == null) || (avatar == null) || (object == null)) { return null;
/* */ }
/* 48 */ String av = PosableShape.getBodyType(avatar);
/* 49 */ if (av == null) { return null;
/* */ }
/* 51 */ String ob = object.toString();
/* 52 */ int dot = ob.lastIndexOf(".");
/* 53 */ if (dot != -1) {
/* 54 */ ob = ob.substring(0, dot);
/* */ }
/* 56 */ Vector<AnimatedAction> ret = new Vector();
/* */
/* */
/* */
/* 60 */ Enumeration<AnimatedAction> e = this.actionList.elements();
/* 61 */ while (e.hasMoreElements())
/* */ {
/* 63 */ AnimatedAction a = (AnimatedAction)e.nextElement();
/* 64 */ if (vectorCheck(av, a.avatarNames))
/* */ {
/* 66 */ if (vectorCheck(ob, a.targetObjects))
/* */ {
/* 68 */ ret.addElement(a);
/* */ }
/* */ }
/* */ }
/* */
/* 73 */ return ret;
/* */ }
/* */
/* */
/* */ private boolean vectorCheck(String s, Vector<String> v)
/* */ {
/* 79 */ Enumeration<String> e = v.elements();
/* 80 */ while (e.hasMoreElements())
/* */ {
/* 82 */ String element = (String)e.nextElement();
/* 83 */ if (s.toLowerCase().endsWith(element.toLowerCase()))
/* 84 */ return true;
/* 85 */ if (element.equals("any"))
/* 86 */ return true;
/* */ }
/* 88 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public boolean buildActionMenu(Menu m, Shape target)
/* */ {
/* 97 */ assert (m != null);
/* */
/* */
/* 100 */ if (this._currentAction != null) { return false;
/* */ }
/* */
/* */
/* 104 */ SuperRoot ultimateOwner = target;
/* 105 */ while (ultimateOwner.getOwner() != null)
/* */ {
/* 107 */ ultimateOwner = ultimateOwner.getOwner();
/* 108 */ if ((ultimateOwner instanceof PosableShape))
/* */ {
/* 110 */ target = (Shape)ultimateOwner;
/* 111 */ break;
/* */ }
/* */ }
/* */
/* */
/* 116 */ Pilot p = Pilot.getActive();
/* 117 */ if (p == null) return false;
/* 118 */ if (!(p instanceof HoloPilot)) return false;
/* 119 */ HoloPilot hp = (HoloPilot)p;
/* */
/* */
/* */
/* 123 */ if (hp.getInternalDrone().getRoom() != target.getRoom())
/* */ {
/* */
/* 126 */ return false;
/* */ }
/* */
/* */
/* */
/* 131 */ Vector<AnimatedAction> v = getActionList(hp.getInternalDrone()
/* 132 */ .getCurrentURL(), target.getURL());
/* */
/* 134 */ this.currentMenuActions = v;
/* */
/* 136 */ if (v == null) return false;
/* 137 */ if (v.size() == 0) { return false;
/* */ }
/* 139 */ Enumeration<AnimatedAction> e = v.elements();
/* 140 */ while (e.hasMoreElements())
/* */ {
/* 142 */ AnimatedAction a = (AnimatedAction)e.nextElement();
/* 143 */ a.setTargetShape(target);
/* */
/* 145 */ int idx = a.actionName.indexOf("\\");
/* */
/* 147 */ if (idx != -1)
/* */ {
/* 149 */ String action = a.actionName.substring(idx + 1);
/* */
/* 151 */ String submenu = a.actionName.substring(0, idx);
/* 152 */ int items = m.getItemCount();
/* 153 */ boolean inserted = false;
/* 154 */ for (int i = 0; i < items; i++)
/* */ {
/* 156 */ MenuItem item = m.getItem(i);
/* 157 */ if (item.getLabel().equals(submenu))
/* */ {
/* 159 */ if ((item instanceof Menu))
/* */ {
/* 161 */ ((Menu)item).add(action);
/* */
/* 163 */ inserted = true;
/* 164 */ break;
/* */ }
/* */ }
/* */ }
/* 168 */ if (!inserted)
/* */ {
/* 170 */ Menu sm = new Menu(submenu);
/* 171 */ sm.addActionListener(this);
/* 172 */ sm.add(action);
/* 173 */ m.add(sm);
/* */ }
/* */ }
/* */ else
/* */ {
/* 178 */ m.add(a.actionName);
/* */ }
/* */ }
/* */
/* 182 */ return true;
/* */ }
/* */
/* */
/* */
/* */ public boolean processMenuClick(String actionName)
/* */ {
/* 189 */ if (this.currentMenuActions == null) { return false;
/* */ }
/* 191 */ Enumeration<AnimatedAction> e = this.currentMenuActions.elements();
/* 192 */ while (e.hasMoreElements())
/* */ {
/* 194 */ AnimatedAction a = (AnimatedAction)e.nextElement();
/* 195 */ String thisAction = a.actionName;
/* 196 */ int idx = thisAction.indexOf('\\');
/* 197 */ if (idx != -1)
/* */ {
/* 199 */ thisAction = thisAction.substring(idx + 1);
/* */ }
/* */
/* */
/* */
/* */
/* 205 */ if (thisAction.equals(actionName))
/* */ {
/* 207 */ Pilot p = Pilot.getActive();
/* 208 */ if (p == null) return false;
/* 209 */ if (!(p instanceof HoloPilot)) return false;
/* 210 */ HoloPilot hp = (HoloPilot)p;
/* */
/* 212 */ if (this._currentAction != null)
/* */ {
/* 214 */ this._currentAction.abort();
/* */ }
/* 216 */ this._currentAction = a;
/* */
/* 218 */ a.execute(hp);
/* 219 */ return true;
/* */ }
/* */ }
/* */
/* 223 */ return false;
/* */ }
/* */
/* */
/* 227 */ private AnimatedAction _currentAction = null;
/* */ static final String actionFile = "actions/actions.dat";
/* */
/* */ public void actionCompleted(AnimatedAction a) {
/* 231 */ assert (a == this._currentAction);
/* 232 */ this._currentAction = null;
/* */ }
/* */
/* */ static final String localActionFile = "actions.dat";
/* */ static final String version = "VERSION";
/* */ public void actionPerformed(ActionEvent e) {
/* 238 */ processMenuClick(e.getActionCommand());
/* */ }
/* */
/* */ static final String action = "ACTION";
/* */ private Vector<AnimatedAction> actionList;
/* */ private Vector<AnimatedAction> currentMenuActions;
/* */ private AnimatedActionManager()
/* */ {
/* 246 */ System.out.println("Loading action manager");
/* 247 */ this.actionList = new Vector();
/* */
/* 249 */ loadActionsFile();
/* */ }
/* */
/* */
/* */ private void loadActionsFile()
/* */ {
/* 255 */ File f = new File("actions.dat");
/* 256 */ if (f.exists()) { parseActionFile("actions.dat");
/* */ }
/* */
/* 259 */ String serv = NetUpdate.getUpgradeServerURL();
/* 260 */ String s = IniFile.override().getIniString("actionFile",
/* 261 */ "actions/actions.dat");
/* 262 */ BackgroundLoader.get(this, URL.make(serv + s));
/* */ }
/* */
/* */
/* */ public synchronized Object asyncBackgroundLoad(String localName, URL remoteURL)
/* */ {
/* 268 */ return localName;
/* */ }
/* */
/* */ public boolean syncBackgroundLoad(Object obj, URL remoteURL) {
/* 272 */ System.out.println("Got actions file ");
/* 273 */ String localName = (String)obj;
/* 274 */ if ((localName != null) && (new File(localName).exists()))
/* */ {
/* 276 */ parseActionFile(localName);
/* */ }
/* 278 */ return false;
/* */ }
/* */
/* */ public Room getBackgroundLoadRoom() {
/* 282 */ return null;
/* */ }
/* */
/* */
/* */
/* */ private String getLine(RandomAccessFile fIn)
/* */ throws IOException
/* */ {
/* 290 */ while (fIn.getFilePointer() < fIn.length())
/* */ {
/* 292 */ String line = fIn.readLine().trim();
/* 293 */ if (line == null) return null;
/* 294 */ if ((!line.startsWith("//")) &&
/* 295 */ (line.length() != 0))
/* */ {
/* 297 */ return line;
/* */ }
/* */ }
/* 300 */ return null;
/* */ }
/* */
/* */
/* */ private void parseActionFile(String fileName)
/* */ {
/* 306 */ int verNum = 0;
/* */
/* 308 */ assert (this.actionList != null);
/* 309 */ this.actionList.removeAllElements();
/* */
/* */ try
/* */ {
/* 313 */ RandomAccessFile fIn = new RandomAccessFile(fileName,
/* 314 */ "r");
/* */
/* */ String line;
/* 317 */ while ((line = getLine(fIn)) != null) {
/* */ String line;
/* 319 */ StringTokenizer tok = new StringTokenizer(line);
/* */
/* 321 */ String firstWord = tok.nextToken();
/* 322 */ if (firstWord.equals("VERSION"))
/* */ {
/* 324 */ String ver = tok.nextToken();
/* 325 */ if (ver.equals("1")) {
/* 326 */ verNum = 1;
/* 327 */ } else if (ver.equals("2")) {
/* 328 */ verNum = 2;
/* */ } else {
/* 330 */ throw new Exception("Bad version.");
/* */ }
/* 332 */ } else if (firstWord.equals("ACTION"))
/* */ {
/* 334 */ if (verNum == 0) {
/* 335 */ throw new Exception("Actions file version not specified.");
/* */ }
/* 337 */ AnimatedAction a = new AnimatedAction();
/* 338 */ a.actionName = line.substring("ACTION".length() + 1);
/* 339 */ readVector(fIn, a.avatarNames);
/* 340 */ readVector(fIn, a.targetObjects);
/* 341 */ if (verNum > 1)
/* */ {
/* 343 */ a.consentRequired = getLine(fIn)
/* 344 */ .toLowerCase().equals("consent");
/* */ }
/* 346 */ StringTokenizer tok2 = new StringTokenizer(
/* 347 */ getLine(fIn));
/* 348 */ Float x = new Float(tok2.nextToken());
/* 349 */ Float y = new Float(tok2.nextToken());
/* 350 */ a.targetRelPosition = new Point2(
/* 351 */ x.floatValue(), y.floatValue());
/* 352 */ Float yaw = new Float(getLine(fIn));
/* 353 */ a.targetRelYaw = yaw.floatValue();
/* 354 */ a.preAnimationAction =
/* 355 */ AnimatedAction.getAction(getLine(fIn));
/* 356 */ a.preAnimationParameter = getLine(fIn);
/* 357 */ a.actionName1 = getLine(fIn);
/* 358 */ if (verNum > 1)
/* */ {
/* 360 */ a.simultaneousAction =
/* 361 */ AnimatedAction.getAction(getLine(fIn));
/* 362 */ a.simultaneousParameter = getLine(fIn);
/* */ }
/* 364 */ a.postAnimationAction =
/* 365 */ AnimatedAction.getAction(getLine(fIn));
/* 366 */ a.postAnimationParameter = getLine(fIn);
/* 367 */ a.actionName2 = getLine(fIn);
/* 368 */ this.actionList.addElement(a);
/* */ }
/* */ }
/* */
/* 372 */ fIn.close();
/* */ }
/* */ catch (Exception e)
/* */ {
/* 376 */ System.out.println("Error reading actions.dat: " +
/* 377 */ e.toString());
/* */ }
/* */ }
/* */
/* */ private void readVector(RandomAccessFile fIn, Vector<String> v) throws IOException
/* */ {
/* 383 */ String line = getLine(fIn);
/* 384 */ StringTokenizer tok = new StringTokenizer(line);
/* */
/* 386 */ while (tok.hasMoreTokens())
/* */ {
/* 388 */ v.addElement(tok.nextToken());
/* */ }
/* */ }
/* */
/* */
/* */
/* 394 */ private static AnimatedActionManager theAnimatedActionManager = null;
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\AnimatedActionManager.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|