summaryrefslogtreecommitdiff
path: root/NET/worlds/console/Console.java
blob: 1fc32abefab478d98af49ed72e633666e21ca210 (plain) (blame)
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
package NET.worlds.console;

import NET.worlds.core.IniFile;
import NET.worlds.core.Std;
import NET.worlds.network.ConnectionWaiter;
import NET.worlds.network.DNSLookup;
import NET.worlds.network.Galaxy;
import NET.worlds.network.InfiniteWaitException;
import NET.worlds.network.InvalidServerURLException;
import NET.worlds.network.NetworkObject;
import NET.worlds.network.OldPropertyList;
import NET.worlds.network.PacketTooLargeException;
import NET.worlds.network.PropertyList;
import NET.worlds.network.PropertySetCmd;
import NET.worlds.network.URL;
import NET.worlds.network.VarErrorException;
import NET.worlds.network.WorldServer;
import NET.worlds.network.net2Property;
import NET.worlds.scape.Attribute;
import NET.worlds.scape.BooleanPropertyEditor;
import NET.worlds.scape.Drone;
import NET.worlds.scape.FrameEvent;
import NET.worlds.scape.FrameHandler;
import NET.worlds.scape.HoloDrone;
import NET.worlds.scape.HoloPilot;
import NET.worlds.scape.InventoryManager;
import NET.worlds.scape.LoadedURLSelf;
import NET.worlds.scape.NoSuchPropertyException;
import NET.worlds.scape.Pilot;
import NET.worlds.scape.ProgressiveAdder;
import NET.worlds.scape.PropAdder;
import NET.worlds.scape.Property;
import NET.worlds.scape.Restorer;
import NET.worlds.scape.Room;
import NET.worlds.scape.Saver;
import NET.worlds.scape.StringPropertyEditor;
import NET.worlds.scape.SuperRoot;
import NET.worlds.scape.TeleportStatus;
import NET.worlds.scape.TooNewException;
import NET.worlds.scape.URLPropertyEditor;
import NET.worlds.scape.URLSelf;
import NET.worlds.scape.URLSelfLoader;
import NET.worlds.scape.VectorProperty;
import NET.worlds.scape.WObject;
import NET.worlds.scape.WobLoaded;
import NET.worlds.scape.WobLoader;
import NET.worlds.scape.World;
import java.awt.CardLayout;
import java.awt.CheckboxMenuItem;
import java.awt.Container;
import java.awt.Event;
import java.awt.Font;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.MenuShortcut;
import java.awt.Panel;
import java.awt.PopupMenu;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URLConnection;
import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Vector;

public abstract class Console extends SuperRoot implements URLSelf, MainCallback, NetworkObject, WobLoaded, DialogDisabled, ConnectionWaiter {
   private static Vector<String> storedLines = new Vector<String>();
   protected boolean disableShaperAccess = false;
   protected boolean disableSingleUserAccess = false;
   private static Console active;
   private Panel myCard;
   private static int nameCounter;
   private static Font font = new Font(message("MenuFont"), 0, 12);
   private URL targetAv;
   private static String activeTeleportURL;
   private static String lastTeleportURL;
   private static FrameEvent frameEvent;
   private static int freezeFrameEvents = 0;
   private String sleepMode = "";
   private int lastUserAction;
   private Vector<FramePart> parts = new Vector<FramePart>();
   private static MenuBar menuBar = new MenuBar();
   protected boolean enableMenu = false;
   protected MenuItem exitItem;
   private Hashtable<String, Menu> menus = new Hashtable<String, Menu>();
   protected static boolean autoFullVIP = IniFile.override().getIniInt("tieredVIP", 0) == 0;
   protected static boolean isRedLightWorld = IniFile.override().getIniString("ProductName", "").equalsIgnoreCase("RedLightWorld")
      || IniFile.override().getIniString("ProductName", "").equalsIgnoreCase("RedLightCenter");
   protected static int vip = IniFile.gamma().getIniInt("VIP", 0) != 0 ? (autoFullVIP ? 2 : 1) : 0;
   protected static int spguest = IniFile.gamma().getIniInt("SPGUEST", 0) != 0 ? 2 : 0;
   private boolean canBroadcast = false;
   protected URL lastPilotRequested;
   public String pendingPilot = "";
   protected boolean setFromMenu = false;
   private String postFix = "";
   public static boolean selfCustom = false;
   protected Vector<LoadedURLSelf> callbacks = new Vector<LoadedURLSelf>();
   private String defaultAction = "";
   protected String tempCarAvatar = "";
   protected static String defaultConsole = IniFile.gamma().getIniString("DEFAULTCONSOLE", "NET.worlds.console.DefaultConsole");
   private static Hashtable<URL, Console> defConsoles = new Hashtable<URL, Console>();
   private static Console defaultUnshared;
   private int refcnt = 0;
   protected Pilot pilotSoulTemplate;
   protected Drone droneSoulTemplate;
   protected Pilot pilot;
   public boolean targetValid = false;
   private String sleepStr = message("asleep");
   protected static GammaFrame frame = new GammaFrame();
   protected Galaxy galaxy = null;
   protected URL _galaxyURL;
   private Cursor cursor = new Cursor(URL.make("system:WAIT_CURSOR"));
   private Vector<Object> tempArea = new Vector<Object>();
   private static Object classCookie = new Object();

   static {
      WhisperManager.whisperManager().setParent(frame);
   }

   public static synchronized void println(String msg) {
      if (active != null) {
         active.printLine(msg);
      } else {
         storedLines.addElement(msg);
      }
   }

   public static void printWhisper(String from, String msg) {
      if (active != null) {
         active.printWhisperFrom(from, msg);
      }
   }

   public static void printOwnWhisper(String to, String msg) {
      if (active != null) {
         active.printWhisperTo(to, msg);
      }
   }

   public static void startWhispering(String to) {
      if (active != null) {
         active.startWhisperingTo(to);
      }
   }

   public static synchronized String message(String Id) {
      Locale currentLocale = Locale.getDefault();

      try {
         String bundlePrefix = IniFile.override().getIniString("BundlePrefix", "MessagesBundle");
         ResourceBundle messages = ResourceBundle.getBundle(bundlePrefix, currentLocale);
         String mess = messages.getString(Id);
         if (mess.indexOf(123) == -1 && mess.indexOf(125) == -1) {
            mess = Std.replaceStr(mess, "''", "'");
         }

         if (mess.lastIndexOf(".gif") > 0 || mess.lastIndexOf(".jpg") > 0 || mess.lastIndexOf(".bmp") > 0) {
            File f = new File(mess);
            if (!f.exists()) {
               return Id;
            }
         }

         return mess;
      } catch (MissingResourceException var6) {
         if (Galaxy.getDebugLevel() != 0) {
            System.out.println("MRE: " + var6.getClassName() + " " + var6.getKey());
            System.out.println("NO MESSAGE for " + Id);
         }

         return Id;
      }
   }

   public static synchronized String parseUnicode(String s) {
      if (s == null) {
         return s;
      } else {
         int idx;
         while ((idx = s.indexOf("\\u")) != -1) {
            if (idx >= s.length() - 5) {
               return s;
            }

            String x = s.substring(idx + 2, idx + 6);
            char p = (char)Integer.parseInt(x, 16);
            String tmp = s.substring(0, idx) + p + s.substring(idx + 6);
            s = tmp;
         }

         return s;
      }
   }

   public static synchronized Vector<String> parseUnicode(Vector<String> cc) {
      for (int i = 0; i < cc.size(); i++) {
         String s = cc.elementAt(i);
         String s2 = parseUnicode(s);
         cc.setElementAt(s2, i);
      }

      return cc;
   }

   public static synchronized String parseExtended(String s) {
      String uc = "";

      for (int i = 0; i < s.length(); i++) {
         char c = s.charAt(i);
         if (c > 255) {
            int ii = c;

            try {
               uc = uc + "\\u" + Integer.toHexString(ii);
            } catch (NumberFormatException var6) {
               uc = uc + "?";
            }
         } else {
            uc = uc + c;
         }
      }

      return uc;
   }

   public static boolean wasHttpNoSuchFile(String us) {
      java.net.URL u = null;
      URLConnection uc = null;

      try {
         u = DNSLookup.lookup(new java.net.URL(us));
         uc = u.openConnection();
      } catch (Exception var5) {
         return true;
      }

      try {
         return ((HttpURLConnection)uc).getResponseCode() == 404;
      } catch (Exception var4) {
         return true;
      }
   }

   protected void printWhisperFrom(String from, String msg) {
      if (!msg.startsWith("&|+")) {
         Object[] arguments = new Object[]{new String(from), new String(msg)};
         println(MessageFormat.format(message("whispered"), arguments));
      }
   }

   protected void printWhisperTo(String to, String msg) {
      if (!msg.startsWith("&|+")) {
         Object[] arguments = new Object[]{new String(to), new String(msg)};
         println(MessageFormat.format(message("You-whispered"), arguments));
      }
   }

   protected void startWhisperingTo(String to) {
      Object[] arguments = new Object[]{new String(to)};
      println(MessageFormat.format(message("You-want-whisp"), arguments));
   }

   public void printLine(String msg) {
      System.out.println(msg);
   }

   public boolean isShaperAccessDisabled() {
      return this.disableShaperAccess;
   }

   public boolean isSingleUserAccessDisabled() {
      return this.disableSingleUserAccess;
   }

   public static Console getActive() {
      return active;
   }

   public void inventoryChanged() {
   }

   public void forPilotOnlyActivate() {
      if (active != this) {
         this.myCard = new Panel();
         String myCardName = "" + nameCounter++;
         Container consoleTile = frame.getConsoleTile();
         consoleTile.add(myCardName, this.myCard);
         Console prev = active;
         this.activate(this.myCard);
         ((CardLayout)consoleTile.getLayout()).show(consoleTile, myCardName);
         getFrame().validate();
         if (prev != null) {
            consoleTile.remove(prev.myCard);
            prev.myCard.removeAll();
         }
      }
   }

   protected void setEnableMenu(boolean enable) {
      this.enableMenu = enable;
      if (this == active) {
         enable |= Gamma.shaper != null;
         boolean enabled = frame.getMenuBar() == menuBar && menuBar != null;
         if (enable != enabled) {
            frame.setMenuBar(enable ? menuBar : null);
            frame.pack();
         }
      }
   }

   private static synchronized void setActive(Console active) {
      Console.active = active;
      int sz = storedLines.size();
      if (sz > 0) {
         for (int i = 0; i < sz; i++) {
            active.printLine(storedLines.elementAt(i));
         }

         storedLines.removeAllElements();
      }
   }

   protected void activate(Container c) {
      assert this.pilot != null;

      Console prev = active;
      if (active != null) {
         active.deactivate();
      }

      setActive(this);
      Main.register(this);
      this.menus.clear();
      menuBar = new MenuBar();
      this.getMenu("File");
      if (Gamma.shaper != null) {
         Gamma.shaper.activate(this, c, prev);
      }

      int len = this.parts.size();

      for (int i = 0; i < len; i++) {
         this.parts.elementAt(i).activate(this, c, prev);
      }

      this.exitItem = this.addMenuItem(message("Exit"), "File");
      if (activeTeleportURL != null) {
         teleportNotification("", activeTeleportURL);
      }

      this.cursor.activate();
   }

   protected void menuDone() {
      this.setEnableMenu(this.enableMenu);
   }

   protected void deactivate() {
      if (active == this) {
         setActive(null);
         Main.unregister(this);
         int len = this.parts.size();

         for (int i = 0; i < len; i++) {
            this.parts.elementAt(i).deactivate();
         }

         if (Gamma.shaper != null) {
            Gamma.shaper.deactivate();
         }

         this.cursor.deactivate();
         frame.deactivate();
      }
   }

   public String getActiveTeleportURL() {
      return lastTeleportURL == null ? "" : lastTeleportURL;
   }

   public static void teleportNotification(String err, String url) {
      if (err != null && err.length() == 0) {
         activeTeleportURL = url;
         lastTeleportURL = url.toString();
      } else {
         activeTeleportURL = null;
      }

      if (active != null) {
         if (active instanceof TeleportStatus) {
            ((TeleportStatus)active).teleportStatus(err, url);
         }

         int len = active.parts.size();

         for (int i = 0; i < len; i++) {
            Object fp = active.parts.elementAt(i);
            if (fp instanceof TeleportStatus) {
               ((TeleportStatus)fp).teleportStatus(err, url);
            }
         }
      }
   }

   public static void setFreezeFrameEvents(boolean x) {
      if (x) {
         freezeFrameEvents++;
      } else {
         freezeFrameEvents--;

         assert freezeFrameEvents >= 0;
      }
   }

   @Override
   public void mainCallback() {
      if (frameEvent == null) {
         frameEvent = new FrameEvent(null, null);
      }

      if (freezeFrameEvents <= 0) {
         frameEvent.newFrameTime();
         frameEvent.source = this;
         this.generateFrameEvents(frameEvent);
         frameEvent.target = null;
         frameEvent.receiver = null;
         frameEvent.source = null;
      }
   }

   public void generateFrameEvents(FrameEvent f) {
      World.generateFrameEvents(f);
      int now = Std.getFastTime();
      if (Window.getAndResetUserActionCount() != 0) {
         this.setSleepMode(null);
         this.lastUserAction = now;
      } else if (now > this.lastUserAction + 300000) {
         if (this.lastUserAction == 0) {
            this.lastUserAction = now;
         } else {
            this.goToSleep();
         }
      }

      int len = this.parts.size();
      if (Main.profile != 0) {
         for (int i = 0; i < len; i++) {
            FramePart fp = this.parts.elementAt(i);
            int start = Std.getRealTime();
            long startBytes = Runtime.getRuntime().freeMemory();
            fp.handle(f);
            int dur = Std.getRealTime() - start;
            long used = startBytes - Runtime.getRuntime().freeMemory();
            if (dur > Main.profile) {
               System.out.println("Took " + dur + "ms and " + used + " bytes to call framePart " + fp);
            }
         }
      } else {
         for (int ix = 0; ix < len; ix++) {
            this.parts.elementAt(ix).handle(f);
         }
      }

      ProgressiveAdder.get().handle(f);
      if (this instanceof FrameHandler) {
         ((FrameHandler)this).handle(f);
      }

      if (this.pilot != null) {
         this.pilot.generateFrameEvents(f);
      }
   }

   public void addPart(FramePart p) {
      this.parts.addElement(p);
   }

   public Enumeration<FramePart> getParts() {
      return this.parts.elements();
   }

   public boolean action(Event event, Object what) {
      if (event.target == this.exitItem) {
         return maybeQuit();
      } else if (Gamma.shaper != null && Gamma.shaper.action(event, what)) {
         return true;
      } else {
         int len = this.parts.size();

         for (int i = 0; i < len; i++) {
            if (this.parts.elementAt(i).action(event, what)) {
               return true;
            }
         }

         return false;
      }
   }

   public boolean handleEvent(Event e) {
      return e.id == 201 ? maybeQuit() : false;
   }

   public boolean okToQuit() {
      return true;
   }

   public static void quit() {
      if (Gamma.getShaper() != null) {
         Gamma.getShaper().maybeQuit();
      } else {
         GammaFrameState.saveBorder();
         Main.end();
      }
   }

   public static boolean maybeQuit() {
      Console c = getActive();
      if (c == null || c.okToQuit()) {
         quit();
      }

      return true;
   }

   public static MenuBar getMenuBar() {
      return menuBar;
   }

   public Menu getMenu(String name) {
      Menu menu = this.menus.get(name);
      if (menu == null) {
         if (!name.equals("Help") && !name.equals("Options") && !name.equals("VIP")) {
            menu = new Menu(name);
            menuBar.add(menu);
         } else {
            menu = new PopupMenu();
         }

         this.menus.put(name, menu);
      }

      return menu;
   }

   public void addMenuItem(MenuItem item, String menuName) {
      this.getMenu(menuName).add(item);
      item.setFont(font);
   }

   public MenuItem addMenuItem(String itemName, String menuName) {
      MenuItem item = new MenuItem(itemName);
      this.getMenu(menuName).add(item);
      item.setFont(font);
      return item;
   }

   public MenuItem addMenuItem(String itemName, String menuName, int keyCode, boolean shiftKey) {
      MenuItem item = new MenuItem(itemName);
      MenuShortcut shortcut = new MenuShortcut(keyCode, shiftKey);
      item.setShortcut(shortcut);
      this.getMenu(menuName).add(item);
      item.setFont(font);
      return item;
   }

   public CheckboxMenuItem addMenuCheckbox(String itemName, String menuName) {
      CheckboxMenuItem item = new CheckboxMenuItem(itemName);
      this.getMenu(menuName).add(item);
      item.setFont(font);
      return item;
   }

   @Override
   public void dialogDisable(boolean disable) {
      int len = this.parts.size();

      for (int i = 0; i < len; i++) {
         FramePart part = this.parts.elementAt(i);
         if (part instanceof DialogDisabled) {
            ((DialogDisabled)part).dialogDisable(disable);
         }
      }
   }

   public static final native String encrypt(String var0);

   public static final native String decrypt(String var0);

   public static String encode(String password) {
      String coded = "";
      if (password != null) {
         char[] cryptChars = encrypt(password).toCharArray();

         for (int i = 0; i < cryptChars.length; i++) {
            String hex = Integer.toHexString(cryptChars[i]);
            if (hex.length() == 1) {
               hex = "0" + hex;
            }

            coded = coded + hex;
         }
      }

      return coded;
   }

   public static String decode(String password) {
      try {
         int length = password.length();
         if (length != 0 && (length & 1) == 0) {
            char[] cryptChars = new char[length / 2];
            int j = 0;

            for (int i = 0; i < cryptChars.length; j += 2) {
               cryptChars[i] = (char)Integer.parseInt(password.substring(j, j + 2), 16);
               i++;
            }

            String ret = decrypt(new String(cryptChars));
            if (ret != null && ret.length() != 0) {
               return ret;
            }
         }
      } catch (NumberFormatException var5) {
      }

      return null;
   }

   public static final native int getVolumeInfo();

   public boolean getVIPAvatars() {
      return vip > 0 || isRedLightWorld;
   }

   public boolean getVIP() {
      return vip > 0;
   }

   public void setVIP(boolean vip) {
      Console.vip = vip ? 1 : 0;
      this.checkCourtesyVIP();
      IniFile.gamma().setIniInt("VIP", Console.vip);
      if (autoFullVIP && vip) {
         Console.vip = 2;
      }
   }

   public boolean getFullVIP() {
      return vip == 2;
   }

   public void setFullVIP(boolean fullVIP) {
      if (fullVIP) {
         vip = 2;
      }

      IniFile.gamma().setIniInt("VIP", vip);
   }

   public boolean getSpecialGuest() {
      return spguest > 0;
   }

   public void setSpecialGuest(boolean spguest) {
      if (Console.spguest > 1 != spguest) {
         Console.spguest = spguest ? 1 : 0;
         IniFile.gamma().setIniInt("SPGUEST", Console.spguest);
         Console.spguest = Console.spguest + Console.spguest;
      }
   }

   public void checkCourtesyVIP() {
      int oldVIP = vip;
      if (vip < 1) {
         World w = this.getPilot().getWorld();
         vip = w != null && w.isHomeWorld() && w.getCourtesyVIP() ? 1 : 0;
      }

      if (vip != oldVIP) {
         if (vip == 1) {
            println(message("You-VIP"));
         } else {
            println(message("You-no-VIP"));
         }
      }

      URL av = this.getDefaultAvatarURL();
      if (!av.equals(this.getAvatarName())) {
         this.setAvatar(av);
      }
   }

   public boolean broadcastEnabled() {
      return this.canBroadcast;
   }

   public void enableBroadcast(boolean enabled) {
      this.canBroadcast = enabled;
   }

   public abstract URL getAvatarName();

   public abstract void setChatname(String var1);

   public void serverStatus(WorldServer serv, VarErrorException ve) {
      System.out.println("status-- " + serv + ": " + ve.getMsg());
   }

   @Override
   public void property(OldPropertyList propList) {
      assert false;
   }

   @Override
   public void propertyUpdate(PropertyList propList) {
      assert false;
   }

   @Override
   public WorldServer getServer() {
      URL url = this.getGalaxyURL();
      if (url != null && this.galaxy != null) {
         try {
            return this.getGalaxy().getServer(url);
         } catch (InvalidServerURLException var3) {
            println(">>" + var3.getMessage());
            return null;
         }
      } else {
         return null;
      }
   }

   public WorldServer getServerNew() {
      URL url = this.getGalaxyURL();
      if (url != null && this.galaxy != null) {
         try {
            return this.getGalaxy().getServer(url);
         } catch (InvalidServerURLException var3) {
            println(">>" + var3.getMessage());
            return null;
         }
      } else {
         return null;
      }
   }

   @Override
   public String getLongID() {
      return this.galaxy.getChatname();
   }

   @Override
   public void register() {
   }

   @Override
   public void galaxyDisconnected() {
      this.setChatname("");
      this.galaxy.waitForConnection(this);
   }

   @Override
   public void reacquireServer(WorldServer oldServ) {
   }

   @Override
   public void changeChannel(Galaxy g, String oldChannel, String newChannel) {
      this.pilot.changeChannel(g, oldChannel, newChannel);
   }

   protected void handleVAR_BITMAP(String s) {
      if (s.charAt(0) == 0) {
         s = s.substring(2);
      }

      try {
         this.loadPilot(new URL(URL.getAvatar(), s));
      } catch (MalformedURLException var3) {
         this.loadPilot(URL.make("error:\"" + s + '"'));
      }
   }

   protected void loadPilot(URL url) {
      if (!url.equals(this.lastPilotRequested)) {
         this.lastPilotRequested = url;
         this.pendingPilot = url.toString();
         Pilot.load(url, this);
         this.setFromMenu = false;
      }
   }

   @Override
   public void wobLoaded(WobLoader loader, SuperRoot w) {
      String err = null;
      if (w == null) {
         err = message("no-load-pilot");
         println(err + " " + loader.getWobName());
      } else if (!(w instanceof Pilot)) {
         err = message("not-pilot");
         println(loader.getWobName().toString() + " " + err);
      } else {
         try {
            this.setPilot((Pilot)w);
         } catch (IllegalPilotException var7) {
            err = var7.getMessage();
         }
      }

      if (this.pilot == null && err != null && !this.disableSingleUserAccess) {
         this.useDefaultPilot();
         err = null;
      }

      int end = this.callbacks.size();

      for (int i = 0; i < end; i++) {
         LoadedURLSelf callback = this.callbacks.elementAt(i);
         if (err == null) {
            callback.loadedURLSelf(this, this.getSourceURL(), null);
         } else {
            this.decRef();
            callback.loadedURLSelf(null, this.getSourceURL(), err);
         }
      }

      this.callbacks.removeAllElements();
   }

   public static URL getDefaultURL() {
      String defaultAvatar = IniFile.override().getIniString("DefaultAvatar", "avatar:pengo.mov");
      return URL.make(defaultAvatar);
   }

   protected void useDefaultPilot() {
      try {
         this.setPilot(new HoloPilot(getDefaultURL()));
      } catch (IllegalPilotException var2) {
         assert false;
      }
   }

   public abstract void setOnlineState(boolean var1, boolean var2);

   @Override
   public void connectionCallback(Object caller, boolean connected) {
      if (caller instanceof Galaxy) {
         if (caller != this.galaxy) {
            return;
         }

         if (!connected) {
            return;
         }

         this.setAvatar(this.lastPilotRequested);
         this.displayAds();
      }
   }

   public void displayAds() {
      Pilot p = Pilot.getActive();
      if (p != null) {
         World w = p.getWorld();
         if (w != null) {
            w.setupAdBanner();
         }
      }
   }

   public void setDefaultAction(String newda) {
      this.defaultAction = newda;
   }

   public String getDefaultAction() {
      return this.defaultAction;
   }

   public URL getDefaultAvatarURL() {
      String defAv = getDefaultURL().toString();
      String av = IniFile.gamma().getIniString("AVATAR", defAv);
      String vav = IniFile.gamma().getIniString("VIPAVATAR", "");
      boolean isVIPAv = av.toLowerCase().endsWith(".rwg");
      if (vav.equals("")) {
         vav = av;
         if (isVIPAv) {
            IniFile.gamma().setIniString("VIPAVATAR", av);
         }
      }

      if (this.tempCarAvatar != "") {
         av = this.tempCarAvatar;
      } else if (this.getVIPAvatars()) {
         av = vav;
      } else if (isVIPAv) {
         av = defAv;
      }

      return URL.make(av);
   }

   public Console() {
      this.add(this.cursor);
      this.galaxy = Galaxy.getAnonGalaxy();
      this.regWithGalaxy();
      this.setServerURL(null);
   }

   public Console(URL serverURL) {
      this.add(this.cursor);
      this.galaxy = Galaxy.getAnonGalaxy();
      this.regWithGalaxy();
      this.setServerURL(serverURL);
      this.templateInit();
   }

   @Override
   public void loadInit() {
      this.templateInit();
      this.add(this.cursor);
   }

   public void addCursor(Cursor c) {
      this.add(c);
   }

   private void templateInit() {
      this.pilotSoulTemplate = new HoloPilot();
      this.droneSoulTemplate = new HoloDrone();
      this.add(this.pilotSoulTemplate);
      this.add(this.droneSoulTemplate);
   }

   public static void load(URL url, LoadedURLSelf callback) {
      if (url != null && url.endsWith(".console")) {
         new ConsoleLoader(url, callback);
      } else {
         Console c;
         if (url == null) {
            c = defaultUnshared;
         } else {
            c = defConsoles.get(url);
         }

         if (c != null && c.galaxy == null) {
            if (c.getGalaxyURL() == null) {
               c.galaxy = Galaxy.getAnonGalaxy();
            } else {
               try {
                  c.galaxy = Galaxy.getGalaxy(c.getGalaxyURL());
               } catch (InvalidServerURLException var5) {
                  System.out.println("Illegal ServerURL = " + c.getGalaxyURL());
                  c.galaxy = Galaxy.getAnonGalaxy();
                  c.setServerURL(null);
               }
            }

            c.regWithGalaxy();
            c.regPilot();
         }

         assert c == null || c.galaxy != null;

         if (c == null) {
            try {
               Class<?> cl = Class.forName(defaultConsole);
               c = (Console)cl.newInstance();
            } catch (Exception var4) {
               System.out.println("Can't use class " + defaultConsole + ", using DefaultConsole instead.");
               var4.printStackTrace(System.out);
               c = new DefaultConsole();
            }

            assert c != null;

            if (c.galaxy == null) {
               c.galaxy = Galaxy.getAnonGalaxy();
               c.regWithGalaxy();
               c.regPilot();
            }

            assert c.galaxy != null;

            c.loadInit();
            c.setServerURL(url);
            if (url == null) {
               c.setName("unshared");
               defaultUnshared = c;
            } else {
               defConsoles.put(c.getGalaxyURL(), c);
            }
         }

         c.incRef();
         c.initPilot(url, callback);
      }
   }

   protected void initPilot(URL pilotURL, LoadedURLSelf callback) {
      this.loadPilot(this.getDefaultAvatarURL());
      if (this.pilot == null) {
         this.useDefaultPilot();
      }

      callback.loadedURLSelf(this, pilotURL, null);
   }

   @Override
   public void incRef() {
      this.refcnt++;
   }

   @Override
   public void decRef() {
      if (--this.refcnt == 0) {
         if (this.galaxy != null) {
            this.unregWithGalaxy();
            this.unregPilot();
            this.galaxy.decWorldCount();
            Galaxy oldGalaxy = this.galaxy;
            this.galaxy = null;
         }

         this.pilot = null;
         URL url = this.getSourceURL();
         if (url != null) {
            if (url.endsWith(".console")) {
               URLSelfLoader.unload(this);
            } else {
               defConsoles.remove(url);
            }
         }
      }
   }

   @Override
   public String toString() {
      return super.toString() + "[" + this.getSourceURL() + "]";
   }

   public Pilot getPilotSoulTemplate() {
      return this.pilotSoulTemplate;
   }

   public Drone getDroneSoulTemplate() {
      return this.droneSoulTemplate;
   }

   public Pilot getPilot() {
      return this.pilot;
   }

   public boolean isValidAv() {
      if (this.targetAv == null) {
         return false;
      } else if (!InventoryManager.getInventoryManager().inventoryInitialized()) {
         return true;
      } else {
         String av = this.targetAv.getAbsolute();
         int len = av.length();

         for (int i = 1; i < len; i++) {
            if (av.charAt(i - 1) == '_') {
               char firstChar = av.charAt(i);
               if (Character.isLowerCase(firstChar)) {
                  StringBuffer item = new StringBuffer();
                  item.append(Character.toUpperCase(firstChar));

                  while (++i < len) {
                     char c = av.charAt(i);
                     if (!Character.isLowerCase(c)) {
                        break;
                     }

                     item.append(c);
                  }

                  if (InventoryManager.getInventoryManager().checkInventoryFor(item.toString()) <= 0) {
                     return false;
                  }
               }
            }
         }

         return true;
      }
   }

   public void resetAvatar() {
      this.setAvatar(this.targetAv);
   }

   public void setAvatar(URL url) {
      if (url != null) {
         BlackBox.getInstance().submitEvent(new BBDroneBitmapCommand("@Pilot", url.toString()));
         this.targetAv = url;
         this.targetValid = true;
         if (url.getAbsolute().length() > 220) {
            println(message("av-too-complex"));
            url = URL.make("avatar:holden.mov");
            this.targetValid = false;
         } else if (!this.isValidAv()) {
            println(message("av-has-inventory"));
            url = URL.make("avatar:holden.mov");
            this.targetValid = false;
         }

         this.loadPilot(url);
         WorldServer serv = this.getServerNew();
         if (serv != null) {
            assert serv.getVersion() >= 18;

            PropertyList propList = new PropertyList();
            propList.addProperty(new net2Property(5, 64, 1, url.getAbsolute()));

            try {
               serv.sendNetworkMsg(new PropertySetCmd(propList));
            } catch (PacketTooLargeException var5) {
               assert url.getAbsolute().length() < 220;

               assert false;
            } catch (InfiniteWaitException var6) {
            }
         }
      }
   }

   public static void wake() {
      if (active != null) {
         active.setSleepMode(null);
      }
   }

   public void goToSleep() {
      this.setSleepMode(this.sleepStr);
      Window.getAndResetUserActionCount();
   }

   public boolean isSleeping() {
      return !this.sleepMode.equals("");
   }

   protected void setSleepMode(String mode) {
      if (mode == null) {
         mode = "";
         this.lastUserAction = Std.getFastTime();
      }

      if (this.pilot != null) {
         this.pilot.setSleepMode(mode);
      }

      if (!mode.equals(this.sleepMode)) {
         WorldServer serv = this.getServerNew();
         if (serv != null) {
            PropertyList propList = new PropertyList();
            propList.addProperty(new net2Property(23, 64, 1, mode));

            try {
               serv.sendNetworkMsg(new PropertySetCmd(propList));
            } catch (PacketTooLargeException var5) {
               assert false;
            } catch (InfiniteWaitException var6) {
            }

            this.sleepMode = mode;
         }
      }
   }

   public void setPilot(Pilot a) throws IllegalPilotException {
      assert a != null;

      Room prevRoom = null;
      if (this.pilot != null) {
         prevRoom = this.pilot.getRoom();
         this.unregPilot();
      }

      this.pilot = a;
      this.pilot.getSharer().createDynamicFromNet();
      this.pilot.setConsole(this);
      this.regPilot();
      if (active == this) {
         Pilot.changeActiveRoom(prevRoom);
      }

      this.pilot.setSleepMode(this.sleepMode);
      if (this instanceof DefaultConsole) {
         ((DefaultConsole)this).resetCamera();
      }
   }

   public static GammaFrame getFrame() {
      return frame;
   }

   public Galaxy getGalaxy() {
      assert this.galaxy != null;

      return this.galaxy;
   }

   public URL getGalaxyURL() {
      return this._galaxyURL;
   }

   public void setServerURL(URL serverURL) {
      try {
         if (serverURL != null) {
            this._galaxyURL = URL.make("worldserver://" + getServerHost(serverURL) + "/");
         }
      } catch (InvalidServerURLException var5) {
         println(">>" + var5.getMessage());

         assert false;

         this._galaxyURL = null;
      }

      Galaxy oldGalaxy = this.galaxy;
      this.unregWithGalaxy();
      this.unregPilot();
      if (this._galaxyURL != null) {
         try {
            this.galaxy = Galaxy.getGalaxy(this._galaxyURL);
         } catch (InvalidServerURLException var4) {
            println(">>" + var4.getMessage());
            this.galaxy = Galaxy.getAnonGalaxy();
         }
      } else {
         this.galaxy = Galaxy.getAnonGalaxy();
      }

      assert this.galaxy != null;

      this.regWithGalaxy();
      this.regPilot();
      if (oldGalaxy != null) {
         oldGalaxy.decWorldCount();
         if (oldGalaxy != this.galaxy) {
            oldGalaxy.forceObjectRereg();
         }
      }
   }

   private void regWithGalaxy() {
      assert this.galaxy != null;

      this.galaxy.addConsole(this);
      this.galaxy.waitForConnection(this);
   }

   private void unregWithGalaxy() {
      assert this.galaxy != null;

      this.galaxy.delConsole(this);
   }

   protected void regPilot() {
      if (this.pilot != null) {
         this.pilot.getSharer().adjustShare();
      }
   }

   public static String getServerHost(URL url) throws InvalidServerURLException {
      String s = url.unalias();
      int len = s.length();
      if (len > 14 && s.startsWith("worldserver://")) {
         if (s.charAt(len - 1) == '/') {
            len--;
         }

         s = s.substring(14, len);
         if (s.equals("209.67.68.214:6650")) {
            s = "www.3dcd.com:6650";
         }

         return s;
      } else {
         throw new InvalidServerURLException("Bad worldserver:// URL format");
      }
   }

   public static URL makeServerURL(String host) {
      assert host != null && host.length() > 0;

      return URL.make("worldserver://" + host + "/");
   }

   protected void unregPilot() {
      if (this.pilot != null) {
         this.pilot.getSharer().adjustShare();
      }
   }

   public Cursor getCursor() {
      return this.cursor;
   }

   public String getScriptServer() {
      String Fred = "Fred";
      String override = IniFile.override().getIniString("ScriptServer", Fred);
      if (!override.equals(Fred)) {
         return new String(override);
      } else {
         WorldServer server = this.getServerNew();
         if (server != null) {
            String sname = server.getScriptServer();
            if (sname != null) {
               return new String(sname);
            }
         }

         return new String("http://www-dynamic.us.worlds.net/cgi-bin/");
      }
   }

   public String getSmtpServer() {
      WorldServer server = this.getServerNew();
      if (server != null) {
         String sname = server.getSmtpServer();
         if (sname != null) {
            return sname;
         }
      }

      return "www.3dcd.com:25";
   }

   public String getMailDomain() {
      WorldServer server = this.getServerNew();
      if (server != null) {
         String dname = server.getMailDomain();
         if (dname != null) {
            return dname;
         }
      }

      return "3dcd.com";
   }

   @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) {
               ret = URLPropertyEditor.make(new Property(this, index, "Server URL").allowSetNull(), null);
            } else if (mode == 1) {
               ret = this.getGalaxyURL();
            } else if (mode == 2) {
               if (value == null) {
                  this.setServerURL(null);
               } else {
                  URL u = (URL)value;
                  if (u != null && !u.unalias().startsWith("worldserver:")) {
                     println(message("server-URL"));
                  } else {
                     this.setServerURL(u);
                  }
               }
            }
            break;
         case 1:
            if (mode == 0) {
               ret = BooleanPropertyEditor.make(new Property(this, index, "Enable Menu Bar"), "No", "Yes");
            } else if (mode == 1) {
               ret = new Boolean(this.enableMenu);
            } else if (mode == 2) {
               this.setEnableMenu((Boolean)value);
            }
            break;
         case 2:
            if (mode == 0) {
               ret = BooleanPropertyEditor.make(new Property(this, index, "Disable Shaper Access (irreversible!)"), "No", "Yes");
            } else if (mode == 1) {
               ret = new Boolean(this.disableShaperAccess);
            } else if (mode == 2) {
               this.disableShaperAccess = (Boolean)value;
            }
            break;
         case 3:
            if (mode == 0) {
               ret = BooleanPropertyEditor.make(new Property(this, index, "Disable Single-user Access"), "No", "Yes");
            } else if (mode == 1) {
               ret = new Boolean(this.disableSingleUserAccess);
            } else if (mode == 2) {
               this.disableSingleUserAccess = (Boolean)value;
            }
            break;
         case 4:
            if (mode == 0) {
               ret = new Property(this, index, "Pilot Soul Template");
            } else if (mode == 1) {
               ret = this.pilotSoulTemplate;
            }
            break;
         case 5:
            if (mode == 0) {
               ret = new Property(this, index, "Drone Soul Template");
            } else if (mode == 1) {
               ret = this.droneSoulTemplate;
            }
            break;
         case 6:
            if (mode == 0) {
               ret = new Property(this, index, "Cursor");
            } else if (mode == 1) {
               ret = this.getCursor();
            }
            break;
         case 7:
            if (mode == 0) {
               ret = PropAdder.make(new VectorProperty(this, index, "Temporary Area"));
            } else if (mode == 1) {
               ret = this.tempArea.clone();
            } else if (mode == 4) {
               this.tempArea.removeElement(value);
               ((SuperRoot)value).detach();
            } else if (mode == 3) {
               this.tempArea.addElement(value);
               this.add((SuperRoot)value);
               if (value instanceof Console) {
                  Console c = (Console)value;
                  if (c.pilotSoulTemplate == null) {
                     c.loadInit();
                  }
               }
            } else if (mode == 5 && value instanceof SuperRoot && !(value instanceof Room)) {
               ret = value;
            }
            break;
         case 8:
            if (mode == 0) {
               ret = StringPropertyEditor.make(new Property(this, index, "Default Action"));
            } else if (mode == 1) {
               ret = this.getDefaultAction();
            } else if (mode == 2) {
               this.setDefaultAction((String)value);
            }
            break;
         default:
            ret = super.properties(index, offset + 9, mode, value);
      }

      return ret;
   }

   @Override
   public void saveState(Saver s) throws IOException {
      s.saveVersion(4, classCookie);
      super.saveState(s);
      URL.save(s, this.getGalaxyURL());
      s.saveBoolean(this.enableMenu);
      s.saveBoolean(this.disableShaperAccess);
      s.saveString(this.defaultAction);
      s.save(this.pilotSoulTemplate);
      s.save(this.droneSoulTemplate);
      s.save(this.cursor);
   }

   private static URL restoreOldURL(Restorer r) throws IOException {
      String s = r.restoreString();
      return s != null && !s.equals("UNSHARED") ? makeServerURL(s) : null;
   }

   @Override
   public void restoreState(Restorer r) throws IOException, TooNewException {
      int vers = r.restoreVersion(classCookie);
      switch (vers) {
         case 0:
         case 1:
            WObject w = new WObject();
            w.restoreState(r);
            this.setName(w.getName());
            this.templateInit();
            Enumeration<Attribute> e = w.getAttributes();

            while (e.hasMoreElements()) {
               Attribute a = e.nextElement();
               a.setAttrID(a.getForwardAttrID());
            }

            Pilot.copySoul(w, this.pilotSoulTemplate);
            this.setServerURL(restoreOldURL(r));
            this.enableMenu = r.restoreBoolean();
            this.disableShaperAccess = r.restoreBoolean();
            if (vers == 1) {
               this.cursor = (Cursor)r.restore();
            }
            break;
         case 2:
            super.restoreState(r);
            this.setServerURL(restoreOldURL(r));
            this.enableMenu = r.restoreBoolean();
            this.disableShaperAccess = r.restoreBoolean();
            this.pilotSoulTemplate = (Pilot)r.restore();
            this.add(this.pilotSoulTemplate);
            this.droneSoulTemplate = (Drone)r.restore();
            this.add(this.droneSoulTemplate);
            this.cursor = (Cursor)r.restore();
            break;
         case 3:
            super.restoreState(r);
            this.setServerURL(restoreOldURL(r));
            this.enableMenu = r.restoreBoolean();
            this.disableShaperAccess = r.restoreBoolean();
            this.defaultAction = r.restoreString();
            this.pilotSoulTemplate = (Pilot)r.restore();
            this.add(this.pilotSoulTemplate);
            this.droneSoulTemplate = (Drone)r.restore();
            this.add(this.droneSoulTemplate);
            this.cursor = (Cursor)r.restore();
            break;
         case 4:
            super.restoreState(r);
            this.setServerURL(URL.restore(r));
            this.enableMenu = r.restoreBoolean();
            this.disableShaperAccess = r.restoreBoolean();
            this.defaultAction = r.restoreString();
            this.pilotSoulTemplate = (Pilot)r.restore();
            this.add(this.pilotSoulTemplate);
            this.droneSoulTemplate = (Drone)r.restore();
            this.add(this.droneSoulTemplate);
            this.cursor = (Cursor)r.restore();
            break;
         default:
            throw new TooNewException();
      }

      this.add(this.cursor);
   }
}