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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
|
/* */ package NET.worlds.console;
/* */
/* */ import NET.worlds.core.IniFile;
/* */ import NET.worlds.core.Std;
/* */ import NET.worlds.network.Galaxy;
/* */ import NET.worlds.network.URL;
/* */ import NET.worlds.scape.Camera;
/* */ import NET.worlds.scape.Drone;
/* */ import NET.worlds.scape.FrameEvent;
/* */ import NET.worlds.scape.FrameHandler;
/* */ import NET.worlds.scape.HoloPilot;
/* */ import NET.worlds.scape.Pilot;
/* */ import NET.worlds.scape.Point3Temp;
/* */ import NET.worlds.scape.Postrenderable;
/* */ import NET.worlds.scape.SmoothDriver;
/* */ import NET.worlds.scape.Sound;
/* */ import NET.worlds.scape.SoundPlayer;
/* */ import NET.worlds.scape.WMPSoundPlayer;
/* */ import NET.worlds.scape.WavSoundPlayer;
/* */ import java.awt.FileDialog;
/* */ import java.awt.Frame;
/* */ import java.io.DataInputStream;
/* */ import java.io.DataOutputStream;
/* */ import java.io.EOFException;
/* */ import java.io.File;
/* */ import java.io.FileInputStream;
/* */ import java.io.FileOutputStream;
/* */ import java.io.PrintStream;
/* */ import java.util.Enumeration;
/* */ import java.util.Properties;
/* */ import java.util.Vector;
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class BlackBox
/* */ implements BlackBoxCallback, FrameHandler, Postrenderable
/* */ {
/* 41 */ private static BlackBox instance = new BlackBox();
/* */
/* */ public static BlackBox getInstance() {
/* 44 */ return instance;
/* */ }
/* */
/* 47 */ private boolean disable = IniFile.gamma().getIniInt("disableRecorder", 0) == 1;
/* */
/* 49 */ private String autoFile = null;
/* 50 */ private SoundPlayer autoSound = null;
/* */ static final int PLAYING = 0;
/* */
/* 53 */ private BlackBox() { this.state = 2;
/* 54 */ this.commandList = new Vector();
/* 55 */ this.pendingCommand = 0;
/* */
/* 57 */ this.autoFile = IniFile.override().getIniString("AutoPlaybackFile", "");
/* 58 */ if (!this.autoFile.equals("")) {
/* 59 */ play();
/* */ } else {
/* 61 */ this.autoFile = null;
/* */ }
/* */
/* 64 */ String soundFile = IniFile.override().getIniString("AutoPlaybackSound",
/* 65 */ "");
/* 66 */ if (!soundFile.equals("")) {
/* 67 */ Sound owner = new Sound(URL.make(soundFile));
/* 68 */ if (soundFile.toLowerCase().endsWith(".wav")) {
/* 69 */ this.autoSound = new WavSoundPlayer(owner);
/* */ } else {
/* 71 */ this.autoSound = new WMPSoundPlayer(owner);
/* */ }
/* */ }
/* */ }
/* */
/* */ public void finalize()
/* */ {
/* 78 */ stop();
/* */ }
/* */
/* */ public void postrender(Camera cam) {
/* 82 */ if (this.disable) {
/* 83 */ return;
/* */ }
/* */
/* 86 */ if (Std.getSynchronizedTime() % 2 == 0) {
/* 87 */ return;
/* */ }
/* 89 */ if (isPlaying()) {
/* 90 */ cam.nDrawText(Console.message("PLAY"), 10, 10, 18, 16711680);
/* 91 */ } else if (isRecording()) {
/* 92 */ cam.nDrawText(Console.message("REC"), 10, 10, 18, 16711680);
/* */ }
/* */ }
/* */
/* */
/* */ static final int RECORDING = 1;
/* */
/* */ static final int STOPPED = 2;
/* */
/* */ private int state;
/* */
/* */ static final int CHATCMD = 0;
/* */
/* */ static final int TELEPORTCMD = 1;
/* */ static final int ACTORLISTCMD = 2;
/* */ static final int MOVEDRONECMD = 3;
/* */ static final int OBJCLICKEDCMD = 4;
/* */ static final int APPEARDRONECMD = 5;
/* */ static final int DISAPPEARDRONECMD = 6;
/* */ static final int DRONEBITMAPCMD = 7;
/* */ static final int DRONEDELTACMD = 8;
/* */ static final int ANIMATECMD = 9;
/* */ public static final String PilotID = "@Pilot";
/* */ private Vector<BlackBoxCommand> commandList;
/* */ private int commandIdx;
/* */ private long basetime;
/* */ static final int NOCMD = 0;
/* */ static final int PLAYCMD = 1;
/* */ static final int RECCMD = 2;
/* */ static final int STOPCMD = 3;
/* */ private int pendingCommand;
/* */ static final int FILE_VERSION = 1;
/* */ public synchronized void record()
/* */ {
/* 126 */ this.pendingCommand = 2;
/* */ }
/* */
/* */ private boolean doRecord() {
/* 130 */ if (this.state != 2) {
/* 131 */ stop();
/* */ }
/* 133 */ this.commandList.removeAllElements();
/* */
/* */
/* 136 */ this.basetime = Std.getFastTime();
/* */
/* */
/* 139 */ String url = "";
/* 140 */ Pilot pilot = Pilot.getActive();
/* 141 */ if (pilot == null) {
/* 142 */ return false;
/* */ }
/* 144 */ url = pilot.getURL();
/* */
/* 146 */ this.state = 1;
/* */
/* 148 */ submitEvent(new BBTeleportCommand(url));
/* */
/* */
/* 151 */ URL avatar = Console.getActive().getAvatarName();
/* 152 */ if (avatar != null) {
/* 153 */ submitEvent(new BBDroneBitmapCommand("@Pilot",
/* 154 */ avatar.toString()));
/* */ }
/* */
/* */
/* 158 */ ArmyOfZombies.instance().zombify();
/* */
/* 160 */ return true;
/* */ }
/* */
/* */ public synchronized void play() {
/* 164 */ this.pendingCommand = 1;
/* */ }
/* */
/* */ public synchronized void play(URL recFile) {
/* 168 */ this.autoFile = recFile.unalias();
/* 169 */ this.pendingCommand = 1;
/* */ }
/* */
/* */ private void doPlay() {
/* 173 */ if (this.state != 2) {
/* 174 */ stop();
/* */ }
/* 176 */ if (!restore()) {
/* 177 */ return;
/* */ }
/* 179 */ Galaxy.forceOffline(false);
/* 180 */ Console.getActive().setChatname("");
/* */
/* 182 */ Pilot p = Pilot.getActive();
/* 183 */ if ((p instanceof HoloPilot)) {
/* 184 */ HoloPilot hp = (HoloPilot)p;
/* 185 */ hp.removeSmoothDriver();
/* */ }
/* */
/* 188 */ if (this.autoSound != null) {
/* 189 */ this.autoSound.start(1);
/* 190 */ this.autoSound = null;
/* */ }
/* */
/* 193 */ this.commandIdx = 0;
/* */
/* 195 */ this.basetime = Std.getFastTime();
/* */
/* 197 */ this.state = 0;
/* */ }
/* */
/* */ public void commandCompleted(BlackBoxCommand c, boolean ok) {
/* 201 */ if (ok) {
/* 202 */ this.commandIdx += 1;
/* */ } else {
/* 204 */ System.out.println("Failed command!");
/* 205 */ stop();
/* */ }
/* */ }
/* */
/* */ public boolean handle(FrameEvent e) {
/* 210 */ if (this.disable) {
/* 211 */ return false;
/* */ }
/* 213 */ switch (this.pendingCommand) {
/* */ case 1:
/* 215 */ doPlay();
/* 216 */ this.pendingCommand = 0;
/* 217 */ break;
/* */
/* */ case 2:
/* 220 */ doRecord();
/* 221 */ this.pendingCommand = 0;
/* 222 */ break;
/* */
/* */ case 3:
/* 225 */ doStop();
/* 226 */ this.pendingCommand = 0;
/* */ }
/* */
/* */
/* 230 */ if (isPlaying()) {
/* 231 */ if (this.commandIdx >= this.commandList.size()) {
/* 232 */ stop();
/* 233 */ return false;
/* */ }
/* */
/* 236 */ long elapsedTime = Std.getFastTime() - this.basetime;
/* */
/* 238 */ BlackBoxCommand c =
/* 239 */ (BlackBoxCommand)this.commandList.elementAt(this.commandIdx);
/* 240 */ if (c.startTime <= elapsedTime) {
/* 241 */ c.execute(this);
/* */ }
/* 243 */ Pilot p = Pilot.getActive();
/* 244 */ if ((p instanceof HoloPilot)) {
/* 245 */ HoloPilot hp = (HoloPilot)p;
/* 246 */ Drone d = hp.getInternalDrone();
/* 247 */ if (d != null) {
/* 248 */ d.interpolate(e.time, 2000, p);
/* 249 */ p.setZ(p.getPosition().z +
/* 250 */ hp.getSmoothDriver().getEyeHeight());
/* */ }
/* */ }
/* */ }
/* */
/* 255 */ return false;
/* */ }
/* */
/* */ public boolean isRecording() {
/* 259 */ return this.state == 1;
/* */ }
/* */
/* */ public boolean isPlaying() {
/* 263 */ return this.state == 0;
/* */ }
/* */
/* */ public void submitEvent(BlackBoxCommand c) {
/* 267 */ if (this.disable) {
/* 268 */ return;
/* */ }
/* 270 */ if (!isRecording()) {
/* 271 */ return;
/* */ }
/* 273 */ c.timestamp(this.basetime);
/* 274 */ this.commandList.addElement(c);
/* */ }
/* */
/* */ public synchronized void stop() {
/* 278 */ this.pendingCommand = 3;
/* */ }
/* */
/* */ private void doStop() {
/* 282 */ if (this.state == 2) {
/* 283 */ return;
/* */ }
/* 285 */ if (isRecording()) {
/* 286 */ save();
/* */ }
/* */
/* 289 */ if (isPlaying())
/* */ {
/* 291 */ ArmyOfZombies.instance().killZombies();
/* */
/* 293 */ Pilot p = Pilot.getActive();
/* 294 */ if ((p instanceof HoloPilot)) {
/* 295 */ HoloPilot hp = (HoloPilot)p;
/* 296 */ hp.returnSmoothDriver();
/* */ }
/* */
/* */
/* 300 */ Console c = Console.getActive();
/* 301 */ if ((c instanceof DefaultConsole)) {
/* 302 */ DefaultConsole dc = (DefaultConsole)c;
/* 303 */ dc.getGalaxy().localForceOnline();
/* 304 */ dc.getGalaxy().waitForConnection(dc);
/* */ }
/* */ }
/* */
/* 308 */ this.state = 2;
/* */ }
/* */
/* */
/* */ private void save()
/* */ {
/* 314 */ Frame parent = Console.getFrame();
/* */
/* 316 */ Properties p = System.getProperties();
/* 317 */ String oldDir = p.getProperty("user.dir");
/* */
/* 319 */ FileDialog fd = new FileDialog(parent,
/* 320 */ Console.message("Save-recording"), 1);
/* 321 */ fd.setFile("record.rec");
/* 322 */ fd.setVisible(true);
/* */
/* 324 */ String fname = fd.getFile();
/* 325 */ String path = fd.getDirectory();
/* */
/* 327 */ p.remove("user.dir");
/* 328 */ p.put("user.dir", oldDir);
/* 329 */ System.setProperties(p);
/* */
/* 331 */ if (fname == null) {
/* 332 */ return;
/* */ }
/* 334 */ File f = new File(path, fname);
/* */ try {
/* 336 */ FileOutputStream fos = new FileOutputStream(f);
/* 337 */ DataOutputStream dos = new DataOutputStream(fos);
/* 338 */ dos.writeInt(1);
/* */
/* 340 */ Enumeration<BlackBoxCommand> e = this.commandList.elements();
/* 341 */ while (e.hasMoreElements()) {
/* 342 */ BlackBoxCommand cmd = (BlackBoxCommand)e.nextElement();
/* 343 */ cmd.save(dos);
/* */ }
/* */
/* 346 */ dos.close();
/* 347 */ fos.close();
/* */ } catch (Exception e) {
/* 349 */ System.out.println(e);
/* */ }
/* */ }
/* */
/* */ private boolean restore() {
/* 354 */ if (this.autoFile != null) {
/* 355 */ restoreFile(new File(this.autoFile));
/* 356 */ this.autoFile = null;
/* 357 */ return true;
/* */ }
/* */
/* 360 */ Frame parent = Console.getFrame();
/* */
/* 362 */ Properties p = System.getProperties();
/* 363 */ String oldDir = p.getProperty("user.dir");
/* 364 */ FileDialog fd = new FileDialog(parent,
/* 365 */ Console.message("Load-recording"), 0);
/* */
/* 367 */ fd.setVisible(true);
/* */
/* 369 */ String filename = fd.getFile();
/* 370 */ String directory = fd.getDirectory();
/* */
/* 372 */ p.remove("user.dir");
/* 373 */ p.put("user.dir", oldDir);
/* 374 */ System.setProperties(p);
/* */
/* 376 */ if (filename == null) {
/* 377 */ return false;
/* */ }
/* 379 */ File f = new File(directory, filename);
/* */
/* 381 */ restoreFile(f);
/* */
/* 383 */ return true;
/* */ }
/* */
/* */ private void restoreFile(File f) {
/* 387 */ this.commandList.removeAllElements();
/* */ try
/* */ {
/* 390 */ FileInputStream fis = new FileInputStream(f);
/* 391 */ DataInputStream dis = new DataInputStream(fis);
/* 392 */ int version = dis.readInt();
/* 393 */ dis.close();
/* 394 */ if (version != 1) {
/* 395 */ Console.println("Invalid recorder file.");
/* 396 */ return;
/* */ }
/* */ try
/* */ {
/* */ for (;;) {
/* 401 */ int cmdId = dis.readInt();
/* */
/* 403 */ BlackBoxCommand cmd = null;
/* */
/* 405 */ switch (cmdId)
/* */ {
/* */ case 1:
/* 408 */ cmd = new BBTeleportCommand();
/* 409 */ break;
/* */
/* */
/* */ case 3:
/* 413 */ cmd = new BBMoveDroneCommand();
/* 414 */ break;
/* */
/* */
/* */ case 4:
/* 418 */ cmd = new BBWObjClickedCommand();
/* 419 */ break;
/* */
/* */
/* */ case 5:
/* 423 */ cmd = new BBAppearDroneCommand();
/* 424 */ break;
/* */
/* */
/* */ case 6:
/* 428 */ cmd = new BBDisappearDroneCommand();
/* 429 */ break;
/* */
/* */
/* */ case 7:
/* 433 */ cmd = new BBDroneBitmapCommand();
/* 434 */ break;
/* */
/* */
/* */ case 8:
/* 438 */ cmd = new BBDroneDeltaPosCommand();
/* 439 */ break;
/* */
/* */
/* */ case 0:
/* 443 */ cmd = new BBChatCommand();
/* 444 */ break;
/* */
/* */ case 9:
/* 447 */ cmd = new BBAnimateDroneCommand();
/* 448 */ break;
/* */ case 2:
/* */ default:
/* 451 */ System.out.println("Error! Unknown command type.");
/* */ }
/* */
/* */
/* 455 */ if (cmd != null) {
/* 456 */ cmd.load(dis);
/* 457 */ this.commandList.addElement(cmd);
/* */ }
/* */ }
/* */ } catch (EOFException e) {
/* 461 */ dis.close();
/* 462 */ fis.close();
/* */ }
/* */ return;
/* 465 */ } catch (Exception e) { System.out.println(e);
/* */ }
/* */ }
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\BlackBox.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|