package NET.worlds.console; import NET.worlds.core.ArchiveMaker; import NET.worlds.core.IniFile; import NET.worlds.core.Std; import NET.worlds.network.Galaxy; import NET.worlds.network.NetUpdate; import NET.worlds.network.RemoteFileConst; import NET.worlds.network.URL; import NET.worlds.network.WorldServer; import NET.worlds.scape.BooleanPropertyEditor; import NET.worlds.scape.CDAudio; import NET.worlds.scape.CDControl; import NET.worlds.scape.CDPlayerAction; import NET.worlds.scape.EquipAction; import NET.worlds.scape.FrameEvent; import NET.worlds.scape.MusicManager; import NET.worlds.scape.NoSuchPropertyException; import NET.worlds.scape.Pilot; import NET.worlds.scape.PosableShape; import NET.worlds.scape.Property; import NET.worlds.scape.RenderWare; import NET.worlds.scape.Restorer; import NET.worlds.scape.Saver; import NET.worlds.scape.SelectAvatarAction; import NET.worlds.scape.SendURLAction; import NET.worlds.scape.TeleportAction; import NET.worlds.scape.TooNewException; import NET.worlds.scape.URLPropertyEditor; import NET.worlds.scape.VehicleShape; import NET.worlds.scape.World; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.CheckboxMenuItem; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.Event; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridLayout; import java.awt.Label; import java.awt.Menu; import java.awt.MenuItem; import java.awt.Panel; import java.awt.PopupMenu; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; import java.text.Collator; import java.text.DateFormat; import java.text.MessageFormat; import java.util.Date; import java.util.Locale; import java.util.MissingResourceException; import java.util.NoSuchElementException; import java.util.ResourceBundle; import java.util.StringTokenizer; import java.util.Vector; public class DefaultConsole extends Console implements DialogReceiver, ImageButtonsCallback, RemoteFileConst { MenuItem aboutItem; MenuItem statisticsItem; MenuItem upgradeItem; MenuItem channelItem; MenuItem infoItem; MenuItem sleepItem; MenuItem helpItem; MenuItem gettingStartedItem; MenuItem serverItem; MenuItem numVisItem; MenuItem checkAccountItem; MenuItem becomeVIPItem; MenuItem toggleVoiceChatItem; MenuItem chatItem; MenuItem shaperHelpItem; MenuItem inventoryItem; MenuItem checkInventoryItem; MenuItem bankItem; MenuItem ubuItem; MenuItem proxyServerItem; MenuItem musicManItem; MenuItem condenseItem; MenuItem expandItem; MenuItem i18nTest; MenuItem currentLang; Menu switchLang; Vector downItems = null; Vector langItems = null; Vector fontItems = null; static final String LANGUAGES = "languages.lst"; static final String FONTS = "fonts.lst"; Vector viewItems = null; Vector camSpeedItems = null; CheckboxMenuItem currentViewItem; CheckboxMenuItem currentCamSpeedItem; ImageButtons driveButton; ImageButtons quitButton; ImageButtons exploreButton; ImageButtons menuButtons; ImageButtons adCubeButton; String defaultAd = IniFile.override().getIniString("defaultAd", "home:adworlds.cmp"); AdPart ad = new AdPart(URL.make(this.defaultAd)); ColorFiller adFiller; ChatPart chat = new ChatPart(); RenderCanvas render = new RenderCanvas(this, new Dimension(560, 360)); Panel renderAndUniverse; UniversePanel universe; CardLayout renderCard; InventoryPart inventory = new InventoryPart(); WorldsMarkPart marks = new WorldsMarkPart(); FriendsListPart friends = new FriendsListPart(); ActionsPart actions = new ActionsPart(); MuteListPart mutes = new MuteListPart(); MapPart map = new MapPart(); SavedAvPart savedAvs = new SavedAvPart(); private static Font font = new Font(Console.message("ConsoleFont"), 0, 12); private static Font mfont = new Font(Console.message("MenuFont"), 0, 12); private static int chatLines = IniFile.gamma().getIniInt("ChatLines", 6); private static int maxWebSize = 540; CDControl cdcontrol; boolean playedCD; MenuItem cdPlayerItem; MenuItem volumeItem; MenuItem graphicsItem; MenuItem nametagItem; MenuItem chatBoxItem; MenuItem broadcastToRoom; MenuItem broadcastToAll; MenuItem bootSomeone; CheckboxMenuItem orthographicViewItem; MenuItem recorderPlayItem; MenuItem recorderRecItem; MenuItem recorderStopItem; boolean universeMode; private static final int[] menuButtonHeights = new int[]{23, 21, 21, 21, 21, 21, 25, -29}; private Vector viewNames; private Vector speedNames; private static final int HELP = 0; private static final int OPTIONS = 1; private static final int WORLDSMAIL = 2; private static final int WORLDSMARK = 3; private static final int LETS = 4; private static final int ACTIONS = 5; private static final int VIP = 6; static String loadingString = Console.message("Loading"); static String arrowKeyMsg = Console.message("Use-arrow-keys"); String statusMessage = arrowKeyMsg; String overrideMessage; String lastStatus = ""; int lastUpdateTime = 0; boolean wasTeleporting = false; private int lastVMCheck; private int lastVMBigWarning; Component bottom; Component top; Label status = new UnpaddedLabel("", 2); Label yourName = new UnpaddedLabel("", 0); static String[] lNames = lpList(); static int lLength = lNames.length; static MenuItem[] lLangs = new MenuItem[lLength]; static Locale[] newLocale = new Locale[lLength]; static String[][] lCodes = new String[lLength][2]; Vector lList = new Vector(); Vector sList = new Vector(); int[] lSizes = new int[10]; int dLength = this.dpList(this.lList, this.sList, this.lSizes); MenuItem[] dLangs = this.dLength == 0 ? null : new MenuItem[this.dLength]; Locale[] newdLocale = this.dLength == 0 ? null : new Locale[this.dLength]; Vector flList = new Vector(); Vector fsList = new Vector(); int[] fSizes = new int[10]; int fLength = this.fpList(this.flList, this.fsList, this.fSizes); MenuItem[] dFonts = this.fLength == 0 ? null : new MenuItem[this.fLength]; Locale[] newfLocale = this.fLength == 0 ? null : new Locale[this.fLength]; static boolean wasDelta; static boolean doDrive; Panel mapPanel; private static String signIn = Console.message("Sign-In"); private static String signOut = Console.message("Sign-Out"); private static String signingIn = Console.message("Signing-In"); private static String noMultiUser = Console.message("Network"); private static String enable3D = Console.message("Enable3D"); private static String disable3D = Console.message("Disable3D"); private static String showTags = Console.message("ShowNametags"); private static String hideTags = Console.message("HideNametags"); private static String enableClassicChat = Console.message("EnableClassicChat"); private static String disableClassicChat = Console.message("DisableClassicChat"); private static String configureChat = Console.message("Config-Chat"); Menu chatLogMenu; AvMenu avatarMenu; private int chooseView = -1; private int chooseCamSpeed = -1; private static String sleepStatus = Console.message("Sleeping"); OkCancelDialog reloginDialog; private Object nextAvatarMutex = new Object(); private URL nextAvatar; private CheckboxMenuItem nextAvatarItem; private CheckboxMenuItem curAvatarItem; private static String lastWorldName = ""; private static String lowVMMsg = Console.message("Low-virt"); private boolean showedMidWarn; private static boolean startupMemCheck = true; public static int physMem; protected URL avatarURL; private static Object classCookie = new Object(); public UniversePanel getUniversePanel() { return this.universe; } @Override public void printLine(String msg) { this.chat.println(msg); super.printLine(msg); } @Override protected void printWhisperFrom(String from, String msg) { WhisperManager.whisperManager().printFrom(from, msg); } @Override protected void printWhisperTo(String to, String msg) { WhisperManager.whisperManager().printTo(to, msg); } @Override protected void startWhisperingTo(String to) { WhisperManager.whisperManager().startTo(to); } public DefaultConsole() { this.init(); this.loadViewNames(); this.speedNames = new Vector(); this.speedNames.addElement(new DefaultConsole.CameraSpeed("Slow", 1)); this.speedNames.addElement(new DefaultConsole.CameraSpeed("Medium", 2)); this.speedNames.addElement(new DefaultConsole.CameraSpeed("Fast", 3)); } public void loadViewNames() { this.viewNames = new Vector(); this.viewNames.addElement(new DefaultConsole.CameraView("First-person", 1)); this.viewNames.addElement(new DefaultConsole.CameraView("Low-first-person", 2)); this.viewNames.addElement(new DefaultConsole.CameraView("Waist", 3)); this.viewNames.addElement(new DefaultConsole.CameraView("Shoulder", 4)); this.viewNames.addElement(new DefaultConsole.CameraView("Head", 5)); this.viewNames.addElement(new DefaultConsole.CameraView("Overhead", 6)); this.viewNames.addElement(new DefaultConsole.CameraView("Behind", 7)); this.viewNames.addElement(new DefaultConsole.CameraView("Wide-shot", 8)); if (Gamma.getShaper() != null) { this.viewNames.addElement(new DefaultConsole.CameraView("Orthographic", 9)); } } public void setOrthoEnabled(boolean in) { if (this.orthographicViewItem != null) { this.orthographicViewItem.setEnabled(in); } } @Override public void loadInit() { super.loadInit(); } public void removeUseArrowStatusMsg() { if (this.statusMessage == arrowKeyMsg) { this.statusMessage = ""; } } public void overrideStatusMsg(String msg) { synchronized (this.status) { this.overrideMessage = msg; if (msg != null) { this.status.setText(msg); } else { this.status.setText(this.lastStatus); } } } public String message(String Id, Locale currentLocale) { Locale.setDefault(currentLocale); Console.println(currentLocale.getDisplayName()); try { ResourceBundle messages = ResourceBundle.getBundle("MessagesBundle", currentLocale); return messages.getString(Id); } catch (MissingResourceException var4) { return "NO MESSAGE for " + Id; } } private void init() { this.addPart(this.render); this.addPart(this.chat); this.addPart(this.inventory); this.addPart(this.marks); this.addPart(this.friends); this.addPart(this.actions); this.addPart(this.mutes); this.addPart(this.ad); this.addPart(this.map); this.addPart(this.savedAvs); Panel drivePanel = new Panel(new FlowLayout(1, 0, 0)); String driveGif = IniFile.override().getIniString("driveGif", "drive.gif"); this.addPart(this.driveButton = new ImageButtons(driveGif, 81, 19, this)); String quitGif = IniFile.override().getIniString("quitGif", Console.message("quit.gif")); this.addPart(this.quitButton = new ImageButtons(quitGif, 65, 19, this)); String exploreGif = IniFile.override().getIniString("exploreGif", Console.message("explore.gif")); this.addPart(this.exploreButton = new ImageButtons(exploreGif, 98, 22, this)); drivePanel.add(this.driveButton); this.driveButton.setDownUpHandler(new ImageButtonsCallback() { @Override public Object imageButtonsCallback(Component who, int which) { if (which != -1) { DefaultConsole.this.startDrive(); } else { DefaultConsole.this.driveButton.drawDown(); } return this; } }); Panel mid = new Panel(); mid.setLayout(new GridLayout(1, 3)); int bgR = IniFile.override().getIniInt("uiBackgroundRed", 49); int bgG = IniFile.override().getIniInt("uiBackgroundGreen", 0); int bgB = IniFile.override().getIniInt("uiBackgroundBlue", 255); mid.setBackground(new Color(bgR, bgG, bgB)); mid.add(this.yourName); mid.add(drivePanel); mid.add(this.status); this.chat.line.setBackground(Color.black); this.chat.line.setForeground(Color.white); this.chat.line.setFont(font); Panel chatter = new InsetPanel(new BorderLayout(0, 3), 0, 0, 3, 0); chatter.add("North", mid); chatter.add("Center", this.chat.listen.getComponent()); chatter.add("South", this.chat.line); this.chat.listen.setBackground(Color.black); this.chat.listen.setForeground(Color.white); this.chat.listen.setFont(font); Panel p = new Panel(new BorderLayout()); new Panel(new BorderLayout()); Panel r = new Panel(new BorderLayout()); Panel s = new Panel(new BorderLayout()); ColorFiller qBlue1 = new ColorFiller(65, 19); qBlue1.setBackground(new Color(bgR, bgG, bgB)); r.add("West", this.quitButton); r.add("East", qBlue1); int bgbR = IniFile.override().getIniInt("uiBackground2Red", 0); int bgbG = IniFile.override().getIniInt("uiBackground2Green", 0); int bgbB = IniFile.override().getIniInt("uiBackground2Blue", 0); s.add("North", r); s.add("Center", this.ad); if (chatLines > 6) { int h = chatLines * this.chat.listen.getComponent().getFontMetrics(this.chat.listen.getFont()).getHeight(); h -= 96; if (h > 0) { this.adFiller = new ColorFiller(130, h); this.adFiller.setBackground(new Color(bgbR, bgbG, bgbB)); s.add("South", this.adFiller); } } p.add("West", s); this.mapPanel = new Panel(new BorderLayout()); this.mapPanel.add("Center", this.map); this.mapPanel.setBackground(Color.black); r = new Panel(new BorderLayout()); ColorFiller qBlue = new ColorFiller(60, 19); qBlue.setBackground(new Color(bgR, bgG, bgB)); r.add("North", qBlue); ColorFiller qBlack = new ColorFiller(60, 3); qBlack.setBackground(new Color(bgbR, bgbG, bgbB)); r.add("South", qBlack); Panel bgbRx = new Panel(new BorderLayout()); bgbRx.add("East", this.exploreButton); bgbRx.add("West", r); this.mapPanel.add("North", bgbRx); p.add("East", this.mapPanel); p.add("Center", chatter); this.bottom = p; this.renderCard = new CardLayout(); this.renderAndUniverse = new Panel(this.renderCard); this.renderAndUniverse.add("render", this.render); p = new InsetPanel(new BorderLayout(), 3, 3, 0, 0); p.add("Center", this.renderAndUniverse); int bgbRxx = IniFile.override().getIniInt("uiBackground3Red", 0); int bgbGx = IniFile.override().getIniInt("uiBackground3Green", 0); int bgbBx = IniFile.override().getIniInt("uiBackground3Blue", 0); qBlue1 = new ColorFiller(97, 1); qBlue1.setBackground(new Color(bgbRxx, bgbGx, bgbBx)); Panel rt = new Panel(new QuantizedStackedLayout(qBlue1)); String panelGif = IniFile.override().getIniString("rtPanel", Console.message("rtpanel.gif")); this.addPart(this.menuButtons = new ImageButtons(panelGif, 97, menuButtonHeights, this)); rt.add(qBlue1); rt.add(this.menuButtons); rt.add(this.friends); p.add("East", rt); this.top = p; } public void relayoutMap() { this.mapPanel.invalidate(); this.mapPanel.validate(); this.mapPanel.doLayout(); this.mapPanel.repaint(); } public void startDrive() { this.statusMessage = Console.message("Drag-mouse"); doDrive = true; Window.makeJavaReleaseCapture(); } @Override public void setOnlineState(boolean enabled, boolean online) { synchronized (this) { if (this.serverItem != null) { this.serverItem.setEnabled(enabled); if (!enabled) { Galaxy g = this.getGalaxy(); if (g != null && !g.isAnonymous()) { this.serverItem.setLabel(signingIn); } else { this.serverItem.setLabel(noMultiUser); } } else if (online) { this.serverItem.setLabel(signOut); } else { this.serverItem.setLabel(signIn); } } } } private void handleNametagsItem() { if (IniFile.gamma().getIniInt("SHOWNAMETAGS", 1) == 0) { IniFile.gamma().setIniInt("SHOWNAMETAGS", 1); this.nametagItem.setLabel(hideTags); } else { IniFile.gamma().setIniInt("SHOWNAMETAGS", 0); this.nametagItem.setLabel(showTags); } new OkCancelDialog(getFrame(), null, Console.message("Alert"), null, Console.message("OK"), Console.message("Change-exit"), true); } private void handleGraphicsItem() { if (IniFile.gamma().getIniInt("UserEnabled3DHardware", 0) == 0) { IniFile.gamma().setIniInt("UserEnabled3DHardware", 1); this.graphicsItem.setLabel(disable3D); } else { IniFile.gamma().setIniInt("UserEnabled3DHardware", 0); this.graphicsItem.setLabel(enable3D); } new OkCancelDialog(getFrame(), null, Console.message("Alert"), null, Console.message("OK"), Console.message("Change-exit"), true); } private void handleChatBoxItem() { if (IniFile.gamma().getIniInt("classicChatBox", 1) == 0) { IniFile.gamma().setIniInt("classicChatBox", 1); this.chatBoxItem.setLabel(disableClassicChat); } else { IniFile.gamma().setIniInt("classicChatBox", 0); this.chatBoxItem.setLabel(enableClassicChat); } new OkCancelDialog(getFrame(), null, Console.message("Alert"), null, Console.message("OK"), Console.message("Change-exit"), true); } public AvMenu getAvatarMenu() { return this.avatarMenu; } @Override public void inventoryChanged() { super.inventoryChanged(); if (this.avatarMenu != null) { this.avatarMenu.buildSpecialGuestMenu(); } } public void setMenusWRTVIP() { if (this.avatarMenu != null) { this.avatarMenu.setEnabled(this.getVIP()); this.avatarMenu.customize.setEnabled(this.getVIP()); } if (this.savedAvs != null) { this.savedAvs.setEnabled(this.getVIP()); } if (this.chatLogMenu != null) { this.chatLogMenu.setEnabled(this.getVIP()); } if (this.toggleVoiceChatItem != null) { this.toggleVoiceChatItem.setLabel(this.getVIP() && VoiceChat.voiceChatEnabled ? Console.message("Reject-Voice") : Console.message("Accept-Voice")); this.toggleVoiceChatItem.setEnabled(this.getVIP() && VoiceChat.voiceChatAvailable()); } if (this.becomeVIPItem != null) { this.becomeVIPItem.setLabel(vip > 0 ? (vip > 1 ? Console.message("Youre-a-VIP") : Console.message("Become-full-VIP")) : Console.message("Become-VIP")); } if (this.numVisItem != null) { this.numVisItem.setEnabled(this.getVIP()); } } public void addBroadcastMenu() { if (this.bootSomeone == null) { if (IniFile.gamma().getIniInt("Broadcast", 0) != 0) { Menu menu = new Menu(Console.message("Broadcast")); menu.add(this.broadcastToRoom = new MenuItem(Console.message("Users"))); menu.add(this.broadcastToAll = new MenuItem(Console.message("All-users"))); this.addMenuItem(menu, "Options"); } this.bootSomeone = new MenuItem(Console.message("Boot-user")); this.addMenuItem(this.bootSomeone, "Options"); } } private Menu updateChatLogMenu() { if (this.chatLogMenu == null) { this.chatLogMenu = new Menu(Console.message("View-Chat")); } else { this.chatLogMenu.removeAll(); } ActionListener logAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new SendURLAction("file:" + e.getActionCommand()).startBrowser(); } }; String[] list = this.logList(); MenuItem item = null; for (int i = 0; i < list.length; i++) { int si = list[i].indexOf(".glog.html"); if (si > 6) { Object[] arguments = new Object[]{new String(list[i].substring(5, si))}; item = new MenuItem(MessageFormat.format(Console.message("Chat-with"), arguments)); } else { if (si <= 0) { continue; } item = new MenuItem(Console.message("General-chat")); } item.setActionCommand(list[i]); item.addActionListener(logAction); this.chatLogMenu.add(item); } return this.chatLogMenu; } private String[] logList() { File dir = new File("."); FilenameFilter f = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("chat.") && name.endsWith(".glog.html"); } }; return dir.list(f); } private static String[] lpList() { File dir = new File("."); FilenameFilter f = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("MessagesBundle") && name.endsWith(".properties"); } }; String[] list = dir.list(f); Collator sortCollator = Collator.getInstance(); sortStrings(sortCollator, list); return list; } private int dpList(Vector lList, Vector sList, int[] lSizes) { String err = NetUpdate.getLanguages(URL.make(NetUpdate.getUpgradeServerURL() + "I18N/" + "languages.lst"), lList, sList, lSizes); if (err != null) { System.out.println(err); return 0; } else { return lList.size(); } } private int fpList(Vector lList, Vector sList, int[] lSizes) { String err = NetUpdate.getLanguages(URL.make(NetUpdate.getUpgradeServerURL() + "I18N/" + "fonts.lst"), lList, sList, lSizes); if (err != null) { System.out.println(err); return 0; } else { return lList.size(); } } public static void sortStrings(Collator collator, String[] words, Locale[] Locales, String[][] Codes) { for (int i = 0; i < words.length; i++) { for (int j = i + 1; j < words.length; j++) { if (collator.compare(words[i], words[j]) > 0) { String tmp = words[i]; Locale ltmp = Locales[i]; String c0 = Codes[i][0]; String c1 = Codes[i][1]; words[i] = words[j]; Locales[i] = Locales[j]; Codes[i][0] = Codes[j][0]; Codes[i][1] = Codes[j][1]; words[j] = tmp; Locales[j] = ltmp; Codes[j][0] = c0; Codes[j][1] = c1; } } } } public static void sortStrings(Collator collator, String[] words, Locale[] Locales, Vector CodeL, Vector CodeS) { for (int i = 0; i < words.length; i++) { for (int j = i + 1; j < words.length; j++) { if (collator.compare(words[i], words[j]) > 0) { String tmp = words[i]; Locale ltmp = Locales[i]; String c0 = CodeL.elementAt(i); String c1 = CodeS.elementAt(i); words[i] = words[j]; Locales[i] = Locales[j]; CodeL.setElementAt(CodeL.elementAt(j), i); CodeS.setElementAt(CodeS.elementAt(j), i); words[j] = tmp; Locales[j] = ltmp; CodeL.setElementAt(c0, j); CodeS.setElementAt(c1, j); } } } } public static void sortStrings(Collator collator, String[] words) { for (int i = 0; i < words.length; i++) { for (int j = i + 1; j < words.length; j++) { if (collator.compare(words[i], words[j]) > 0) { String tmp = words[i]; words[i] = words[j]; words[j] = tmp; } } } } @Override public void activate(Container c) { super.activate(c); c.setBackground(Color.black); c.setForeground(Color.white); c.setLayout(new BorderLayout()); c.add("Center", this.top); c.add("South", this.bottom); this.chat.line.setBackground(Color.white); this.chat.line.setForeground(Color.black); boolean useShaper = Gamma.getShaper() != null; if (useShaper) { this.shaperHelpItem = this.addMenuItem(Console.message("using-shaper"), "Help"); } if (NetUpdate.getInfoURL() != null) { this.helpItem = this.addMenuItem(Console.message("Help-Contents"), "Help"); this.infoItem = this.addMenuItem(Console.message("Latest-info"), "Help"); } Object[] arguments = new Object[]{new String(Std.getProductName())}; this.aboutItem = this.addMenuItem(MessageFormat.format(Console.message("About-product"), arguments), "Help"); int cameraMode = IniFile.gamma().getIniInt("CAM_MODE", 7); int cameraSpeed = IniFile.gamma().getIniInt("CAM_SPEED", 3); if (!useShaper && cameraMode == 9) { cameraMode = 7; } this.pilot.setOutsideCameraMode(cameraMode, cameraSpeed); Menu viewMenu = new Menu(Console.message("Change-View")); this.addMenuItem(viewMenu, "Options"); MenuItem cameraVMenu = new MenuItem(Console.message("CAMERA-VIEW")); cameraVMenu.setFont(mfont); viewMenu.add(cameraVMenu); this.viewItems = new Vector(); for (int i = 0; i < this.viewNames.size(); i++) { DefaultConsole.CameraView currView = this.viewNames.elementAt(i); CheckboxMenuItem item = new CheckboxMenuItem(" " + Console.message(currView.viewName), cameraMode == currView.viewID); if (cameraMode == currView.viewID) { this.currentViewItem = item; } item.setFont(mfont); viewMenu.add(item); this.viewItems.addElement(item); if (currView.viewName == "Orthographic") { this.orthographicViewItem = item; } } viewMenu.addSeparator(); MenuItem cameraSMenu = new MenuItem(Console.message("CAMERA-SPEED")); cameraSMenu.setFont(mfont); viewMenu.add(cameraSMenu); this.camSpeedItems = new Vector(); for (int i = 0; i < this.speedNames.size(); i++) { DefaultConsole.CameraSpeed currSpeed = this.speedNames.elementAt(i); CheckboxMenuItem itemx = new CheckboxMenuItem(" " + Console.message(currSpeed.speedName), currSpeed.speedID == cameraSpeed); if (currSpeed.speedID == cameraSpeed) { this.currentCamSpeedItem = itemx; } itemx.setFont(mfont); viewMenu.add(itemx); this.camSpeedItems.addElement(itemx); } this.becomeVIPItem = this.addMenuItem(vip == 1 ? Console.message("Become-full-VIP") : Console.message("Become-VIP"), "VIP"); this.addMenuItem(this.avatarMenu = new AvMenu(this, this.lastPilotRequested), "VIP"); this.addMenuItem(this.savedAvs, "VIP"); this.addMenuItem(this.avatarMenu.customize, "VIP"); this.toggleVoiceChatItem = this.addMenuItem(Console.message("Enable-Voice"), "VIP"); this.toggleVoiceChatItem.setEnabled(false); this.numVisItem = this.addMenuItem(Console.message("Num-Visible"), "VIP"); if (NetUpdate.isInternalVersion() || IniFile.gamma().getIniInt("EnableTrading", 0) == 1) { this.inventoryItem = this.addMenuItem("My Stuff", "VIP"); this.checkInventoryItem = this.addMenuItem("Check Inventory", "VIP"); } if (NetUpdate.isInternalVersion() || IniFile.gamma().getIniInt("EnableBank", 0) == 1) { this.bankItem = this.addMenuItem("Access Bank Account", "VIP"); } if (IniFile.gamma().getIniInt("EnableUBU", 0) == 1) { this.ubuItem = this.addMenuItem("U-B-U Vanatar", "VIP"); } this.setMenusWRTVIP(); this.proxyServerItem = this.addMenuItem(Console.message("Proxy-Server"), "Options"); this.checkAccountItem = this.addMenuItem(Console.message("Account-Info"), "Options"); if (useShaper) { this.statisticsItem = this.addMenuItem(Console.message("Display-Stat"), "Options"); } this.upgradeItem = this.addMenuItem(Console.message("Upgrade-Now"), "Options"); if (useShaper) { this.channelItem = this.addMenuItem(Console.message("Dimension-Sel"), "Options"); } this.serverItem = this.addMenuItem(signIn, "Options"); this.setOnlineState(this.galaxy.getOnlineEnabled(), this.galaxy.getOnline()); if (IniFile.gamma().getIniInt("recorderEnabled", 1) == 1) { Menu recorderMenu = new Menu(Console.message("Recorder")); this.addMenuItem(recorderMenu, "Options"); this.recorderRecItem = new MenuItem(Console.message("Record")); recorderMenu.add(this.recorderRecItem); this.recorderStopItem = new MenuItem(Console.message("Stop")); recorderMenu.add(this.recorderStopItem); this.recorderPlayItem = new MenuItem(Console.message("Play")); recorderMenu.add(this.recorderPlayItem); } if (NetUpdate.isInternalVersion()) { Menu languageMenu = new Menu(Console.message("Languages")); this.addMenuItem(languageMenu, "Options"); Menu downloadFont = new Menu(Console.message("Download-Font")); languageMenu.add(downloadFont); downloadFont.setFont(mfont); this.fontItems = new Vector(); for (int i = 0; i < this.fLength; i++) { if (this.flList.elementAt(i) != null) { if (this.fsList.elementAt(i) != null) { this.newfLocale[i] = new Locale(this.flList.elementAt(i), this.fsList.elementAt(i)); String code = this.flList.elementAt(i) + "_" + this.fsList.elementAt(i); if (code.equals(Console.message(code))) { this.dFonts[i] = new MenuItem(this.newfLocale[i].getDisplayName()); } else { this.dFonts[i] = new MenuItem(Console.message(code)); } } else { String code = this.flList.elementAt(i); if (code.equals(Console.message(code))) { this.dFonts[i] = new MenuItem(this.flList.elementAt(i)); } else { this.dFonts[i] = new MenuItem(Console.message(code)); } } this.dFonts[i].setFont(mfont); downloadFont.add(this.dFonts[i]); this.fontItems.addElement(this.dFonts[i]); } } Menu downloadLanguage = new Menu(Console.message("Download-Language")); languageMenu.add(downloadLanguage); downloadLanguage.setFont(mfont); this.downItems = new Vector(); String[] sLangs = new String[this.dLength]; for (int ix = 0; ix < this.dLength; ix++) { if (this.lList.elementAt(ix) != null) { this.newdLocale[ix] = new Locale(this.lList.elementAt(ix), this.sList.elementAt(ix)); String lName0; if (ix > 0) { Locale locale0 = new Locale(this.lList.elementAt(ix - 1), this.sList.elementAt(ix - 1)); lName0 = locale0.getDisplayName(); } else { lName0 = this.newdLocale[ix].getDisplayName(); } String lName1 = this.newdLocale[ix].getDisplayName(); lName1 = lName1.substring(0, lName1.indexOf(40) - 1); String lName; if (ix < this.dLength - 1) { Locale locale2 = new Locale(this.lList.elementAt(ix + 1), this.sList.elementAt(ix + 1)); String lName2 = locale2.getDisplayName(); lName2 = lName2.substring(0, lName2.indexOf(40) - 1); if (lName2.equals(lName1)) { lName = this.newdLocale[ix].getDisplayName(); } else { lName = lName1; } } else if (ix == this.dLength - 1) { lName0 = lName0.substring(0, lName0.indexOf(40) - 1); if (lName1.equals(lName0)) { lName = this.newdLocale[ix].getDisplayName(); } else { lName = lName1; } } else if (sLangs[ix - 1].equals(lName1)) { lName = this.newdLocale[ix].getDisplayName(); } else { lName = lName1; } String code = this.lList.elementAt(ix) + "_" + this.sList.elementAt(ix); if (code.equals(Console.message(code))) { sLangs[ix] = lName; } else { sLangs[ix] = Console.message(code); } } } Collator sortCollator = Collator.getInstance(); sortStrings(sortCollator, sLangs, this.newdLocale, this.lList, this.sList); for (int ixx = 0; ixx < this.dLength; ixx++) { this.dLangs[ixx] = new MenuItem(sLangs[ixx]); this.dLangs[ixx].setFont(mfont); downloadLanguage.add(this.dLangs[ixx]); this.downItems.addElement(this.dLangs[ixx]); } Menu switchLang = new Menu(Console.message("Switch-Language")); languageMenu.add(switchLang); switchLang.setFont(mfont); this.langItems = new Vector(); for (int ixx = 0; ixx < lLength; ixx++) { int imb = lNames[ixx].indexOf(95); if (imb < 0) { lCodes[ixx][0] = "en"; lCodes[ixx][1] = "US"; } else { int ipr = lNames[ixx].lastIndexOf(46); if (ipr < 0) { ipr = 0; } lCodes[ixx][0] = lNames[ixx].substring(imb + 1, imb + 3); if (ipr > imb + 4) { lCodes[ixx][1] = lNames[ixx].substring(imb + 4, ipr); } else { lCodes[ixx][1] = lCodes[ixx][0].toUpperCase(); } } } String[] slLangs = new String[lLength]; for (int ixxx = 0; ixxx < lLength; ixxx++) { newLocale[ixxx] = new Locale(lCodes[ixxx][0], lCodes[ixxx][1]); String lName0x; if (ixxx > 0) { Locale locale0 = new Locale(lCodes[ixxx - 1][0], lCodes[ixxx - 1][1]); lName0x = locale0.getDisplayName(); } else { lName0x = newLocale[ixxx].getDisplayName(); } String lName1x = newLocale[ixxx].getDisplayName(); lName1x = lName1x.substring(0, lName1x.indexOf(40) - 1); String lNamex; if (ixxx < lLength - 1) { Locale locale2 = new Locale(lCodes[ixxx + 1][0], lCodes[ixxx + 1][1]); String lName2 = locale2.getDisplayName(); lName2 = lName2.substring(0, lName2.indexOf(40) - 1); if (lName2.equals(lName1x)) { lNamex = newLocale[ixxx].getDisplayName(); } else { lNamex = lName1x; } } else if (ixxx == lLength - 1) { lName0x = lName0x.substring(0, lName0x.indexOf(40) - 1); if (lName1x.equals(lName0x)) { lNamex = newLocale[ixxx].getDisplayName(); } else { lNamex = lName1x; } } else if (slLangs[ixxx - 1].equals(lName1x)) { lNamex = newLocale[ixxx].getDisplayName(); } else { lNamex = lName1x; } String code = lCodes[ixxx][0] + "_" + lCodes[ixxx][1]; if (code.equals(Console.message(code))) { slLangs[ixxx] = lNamex; } else { slLangs[ixxx] = Console.message(code); } } sortStrings(sortCollator, slLangs, newLocale, lCodes); for (int ixxx = 0; ixxx < lLength; ixxx++) { lLangs[ixxx] = new MenuItem(slLangs[ixxx]); lLangs[ixxx].setFont(mfont); switchLang.add(lLangs[ixxx]); this.langItems.addElement(lLangs[ixxx]); } this.currentLang = new MenuItem(Console.message("Current-Language")); languageMenu.add(this.currentLang); this.currentLang.setFont(mfont); } if (useShaper) { this.condenseItem = this.addMenuItem(Console.message("Condense-Files"), "Options"); this.expandItem = this.addMenuItem(Console.message("Expand-Files"), "Options"); this.musicManItem = this.addMenuItem(Console.message("Music-Manager"), "Options"); this.i18nTest = this.addMenuItem(Console.message("I18N-Test"), "Options"); } this.cdPlayerItem = this.addMenuItem(Console.message("MusicM"), "Options"); this.volumeItem = this.addMenuItem(Console.message("Volume-control"), "Options"); if (RenderWare.get3DHardwareAvailable()) { if (RenderWare.get3DHardwareInUse()) { this.graphicsItem = this.addMenuItem(disable3D, "Options"); } else { this.graphicsItem = this.addMenuItem(enable3D, "Options"); } } if (IniFile.gamma().getIniInt("SHOWNAMETAGS", 1) == 1) { this.nametagItem = this.addMenuItem(hideTags, "Options"); } else { this.nametagItem = this.addMenuItem(showTags, "Options"); } if (IniFile.gamma().getIniInt("classicChatBox", 1) == 1) { this.chatBoxItem = this.addMenuItem(disableClassicChat, "Options"); } else { this.chatBoxItem = this.addMenuItem(enableClassicChat, "Options"); this.chatItem = this.addMenuItem(configureChat, "Options"); } if (Gamma.loadProgress != null) { Gamma.loadProgress.setMessage("Preloading avatars..."); Gamma.loadProgress.advance(); } this.menuDone(); getFrame().activate(); LogFile.mailLogIfPresent(this.getSmtpServer()); this.render.requestFocus(); this.setMenusWRTVIP(); this.bootSomeone = null; if (this.broadcastEnabled()) { this.addBroadcastMenu(); } this.universeMode = false; } @Override public void setVIP(boolean f) { super.setVIP(f); this.setMenusWRTVIP(); this.setNameStr(); } @Override public void checkCourtesyVIP() { super.checkCourtesyVIP(); this.setMenusWRTVIP(); this.setNameStr(); } public void setNameStr() { String nameStr = this.galaxy.getUsernameU(); boolean isOnline = this.galaxy.getOnline(); if (!isOnline) { this.yourName.setText(Console.message("Off-line")); } else { if (nameStr.length() > 0) { if (nameStr.regionMatches(true, 0, "VIP ", 0, 4)) { nameStr = nameStr.substring(4); } if (vip > 0) { if (vip > 1) { nameStr = Console.message("VIP") + " " + nameStr; } else { nameStr = Console.message("vip") + " " + nameStr; } } IniFile.gamma().setIniString("LASTCHATNAME", parseExtended(nameStr)); this.yourName.setText(Console.parseUnicode(nameStr)); } } } @Override public void enableBroadcast(boolean enabled) { super.enableBroadcast(enabled); if (enabled) { this.addBroadcastMenu(); } } @Override public void deactivate() { super.deactivate(); this.universeMode = false; } @Override protected void setSleepMode(String mode) { super.setSleepMode(mode); if (mode != null && mode.equals(Console.message("asleep"))) { this.statusMessage = sleepStatus; } else if (this.statusMessage == sleepStatus) { this.statusMessage = ""; } } private void relogin() { if (this.serverItem.getLabel().equals(signOut)) { this.reloginDialog = new OkCancelDialog( getFrame(), this, Console.message("Re-login"), Console.message("Cancel"), Console.message("OK"), Console.message("auto-sign-out"), true ); } } @Override public boolean action(Event event, Object what) { if (event.target == this.aboutItem) { new AboutDialog(Std.getProductName(), getFrame()); } else if (event.target == this.statisticsItem && this.statisticsItem != null) { new StatisticsWindow(getFrame()); } else if (this.viewItems.contains(event.target)) { this.changeView((CheckboxMenuItem)event.target); } else if (this.camSpeedItems.contains(event.target)) { this.changeCamSpeed((CheckboxMenuItem)event.target); } else if (event.target == this.gettingStartedItem) { new SendURLAction(this.getHelpGettingStarted()).startBrowser(); } else if (event.target == this.shaperHelpItem) { String helpURL = IniFile.override().getIniString("ShaperHelp", this.getScriptServer() + "shaperhelp.pl") + "?u="; String lastName = IniFile.gamma().getIniString("lastchatname", ""); if (!lastName.equals("")) { if (lastName.startsWith("VIP ")) { lastName = lastName.substring(4); } helpURL = helpURL + lastName; } new SendURLAction(WebControlImp.processURL(helpURL)).startBrowser(); } else if (event.target == this.helpItem) { String serv = NetUpdate.getUpgradeServerURL(); String directory = IniFile.override().getIniString("HelpDirectory", "help"); String helpPage = IniFile.override().getIniString("HelpPage", Std.getVersion() + Console.message(".html")); if (wasHttpNoSuchFile(serv + directory + "/" + helpPage)) { helpPage = IniFile.override().getIniString("HelpPage", Std.getVersion() + ".html"); } new SendURLAction(serv + directory + "/" + helpPage).startBrowser(); } else if (event.target == this.infoItem) { String infoOverride = IniFile.override().getIniString("infoOverride", ""); if (infoOverride.equals("")) { NetUpdate.showInfo(); } else { new SendURLAction(infoOverride).startBrowser(); } } else if (event.target == this.i18nTest) { Locale df = Locale.getDefault(); Console.println("Default = " + df.getDisplayName()); DateFormat fulldate = DateFormat.getDateTimeInstance(1, 1); Date today = new Date(); Console.println("Today = " + fulldate.format(today)); Locale[] list = DateFormat.getAvailableLocales(); Console.println("Avaliable Locales are:"); for (int i = 0; i < list.length; i++) { Locale.setDefault(list[i]); Console.println(list[i].getDisplayName() + " " + list[i]); } new Locale("en", "US"); Locale fr = new Locale("fr", "FR"); Locale de = new Locale("de", "DE"); Locale ja = new Locale("ja", "JP"); Locale zh = new Locale("zh", "CN"); Locale th = new Locale("th", "TH"); Locale ru = new Locale("ru", "RU"); Locale iw = new Locale("iw", "IL"); Console.println("file.encoding = " + System.getProperty("file.encoding")); Console.println(this.message("test-language", fr)); Console.println(this.message("test-language", de)); Console.println(this.message("test-language", ja)); Console.println(this.message("test-language", zh)); Console.println(this.message("test-language", th)); Console.println(this.message("test-language", ru)); Console.println(this.message("test-language", iw)); Console.println(this.message("test-language", df)); } else if (event.target == this.checkAccountItem) { String accountOverride = IniFile.override().getIniString("accountOverride", ""); if (accountOverride.equals("")) { String accountScript = IniFile.override().getIniString("accountInfoPage", "account" + Console.message(".pl")); if (wasHttpNoSuchFile(this.getScriptServer() + accountScript)) { accountScript = IniFile.override().getIniString("accountInfoPage", "account.pl"); } new SendURLAction(this.getScriptServer() + accountScript, true).startBrowser(); } else { new SendURLAction(accountOverride).startBrowser(); } this.relogin(); } else if (event.target == this.upgradeItem) { NetUpdate.doUpdate(true); } else if (event.target == this.channelItem && this.channelItem != null) { Galaxy g = this.getGalaxy(); String channel = ""; assert g != null; if (g != null) { channel = g.getChannel(); } new ChannelDialog(getFrame(), this, Console.message("Dimension-Sel"), channel); } else if (event.target == this.becomeVIPItem) { String completeOverride = IniFile.override().getIniString("vipOverride", ""); if (completeOverride.equals("")) { String vipScript = IniFile.override().getIniString("vipPage", "vip" + Console.message(".pl")); if (wasHttpNoSuchFile(this.getScriptServer() + vipScript)) { vipScript = IniFile.override().getIniString("vipPage", "vip.pl"); } new SendURLAction(this.getScriptServer() + vipScript, true).startBrowser(); } else { new SendURLAction(completeOverride, false).startBrowser(); } this.relogin(); } else if (event.target == this.numVisItem) { new SetNumVisibleAvs(); } else if (event.target == this.inventoryItem) { EquipAction eAction = new EquipAction(); eAction.trigger(null, null); } else if (event.target == this.checkInventoryItem) { new SendURLAction(this.getScriptServer() + "inventory.pl", true).startBrowser(); } else if (event.target == this.bankItem) { new SendURLAction(this.getScriptServer() + "bank.pl", true).startBrowser(); } else if (event.target == this.ubuItem) { String ubuDest = IniFile.gamma().getIniString("UbuDestURL", this.getScriptServer() + "ubu.pl"); new SendURLAction(ubuDest, true).startBrowser(); } else if (event.target == this.proxyServerItem) { System.out.println("Triggering the Proxy Server dialog."); ProxyServerDialog psd = new ProxyServerDialog(); psd.show(); } else if (event.target == this.toggleVoiceChatItem) { VoiceChat.setVoiceChatEnabled(!VoiceChat.voiceChatEnabled); this.setMenusWRTVIP(); } else if (event.target == this.serverItem) { this.handleServerItem(); } else if (event.target == this.condenseItem) { new ArchiveMaker(true); } else if (event.target == this.expandItem) { new ArchiveMaker(false); } else if (event.target == this.musicManItem) { MusicManager.showDialog(); } else if (event.target == this.cdPlayerItem) { if (this.cdcontrol == null) { this.playedCD = true; this.cdcontrol = new CDControl(getFrame(), this); } } else if (event.target == this.volumeItem) { if (!CDPlayerAction.launchVolumeControlApp()) { new OkCancelDialog(getFrame(), null, Console.message("No-Volume"), null, Console.message("OK"), Console.message("Cannot-locate"), true); } } else if (event.target == this.graphicsItem) { this.handleGraphicsItem(); } else if (event.target == this.nametagItem) { this.handleNametagsItem(); } else if (event.target == this.chatBoxItem) { this.handleChatBoxItem(); } else if (event.target == this.chatItem && this.chatItem != null) { new ChatDialog( getFrame(), this, Console.message("Chat-Configuration"), IniFile.gamma().getIniInt("ChatFontSize", 12), chatLines, IniFile.gamma().getIniInt("ChatLengthLimit", 20000) ); } else if (event.target == this.bootSomeone) { new BootDialog(getFrame(), this, Console.message("Boot-user")); } else if (event.target == this.broadcastToRoom) { startWhispering("room"); } else if (event.target == this.broadcastToAll) { startWhispering("world"); } else if (event.target == this.currentLang) { String code = Locale.getDefault().toString(); if (code == Console.message(code)) { Console.println(Console.message("Current-Language") + " = " + Locale.getDefault().getDisplayName()); } else { Console.println(Console.message("Current-Language") + " = " + Console.message(code)); } } else if (event.target == this.recorderPlayItem) { println(Console.message("BlackBoxPlay")); BlackBox.getInstance().play(); } else if (event.target == this.recorderRecItem) { println(Console.message("BlackBoxRec")); BlackBox.getInstance().record(); } else if (event.target == this.recorderStopItem) { println(Console.message("BlackBoxStop")); BlackBox.getInstance().stop(); } else if (this.fontItems != null && this.fontItems.contains(event.target)) { String languageURL = IniFile.gamma().getIniString("upgradeServer", "") + "/I18N/font_"; for (int i = 0; i < this.fLength; i++) { if (event.target == this.fontItems.elementAt(i)) { if (this.fsList.elementAt(i) != null) { languageURL = languageURL + this.flList.elementAt(i) + "_" + this.fsList.elementAt(i) + ".EXE"; } else { languageURL = languageURL + this.flList.elementAt(i) + ".EXE"; } int sz = this.fSizes[i]; String fName = languageURL.substring(languageURL.lastIndexOf(47) + 1, languageURL.length()); LanguageManager.handle(languageURL, sz, fName); break; } } } else if (this.downItems != null && this.downItems.contains(event.target)) { String languageURL = IniFile.gamma().getIniString("upgradeServer", "") + "/I18N/language_"; for (int ix = 0; ix < this.dLength; ix++) { if (event.target == this.downItems.elementAt(ix)) { if (this.sList.elementAt(ix) != null) { languageURL = languageURL + this.lList.elementAt(ix) + "_" + this.sList.elementAt(ix) + ".zip"; IniFile.gamma().setIniString("DEFAULTLANGUAGE", this.lList.elementAt(ix) + "_" + this.sList.elementAt(ix)); } else { languageURL = languageURL + this.lList.elementAt(ix) + ".zip"; IniFile.gamma().setIniString("DEFAULTLANGUAGE", this.lList.elementAt(ix)); } int sz = this.lSizes[ix]; String fName = languageURL.substring(languageURL.lastIndexOf(47) + 1, languageURL.length()); LanguageManager.handle(languageURL, sz, fName); break; } } } else if (this.langItems != null && this.langItems.contains(event.target)) { for (int ixx = 0; ixx < lLength; ixx++) { if (event.target == this.langItems.elementAt(ixx)) { Locale.setDefault(newLocale[ixx]); String code = newLocale[ixx].toString(); if (code == Console.message(code)) { Console.println(message("Setting-to") + " " + newLocale[ixx].getDisplayName()); } else { Console.println(message("Setting-to") + " " + Console.message(code)); } IniFile.gamma().setIniString("DEFAULTLANGUAGE", lCodes[ixx][0] + "_" + lCodes[ixx][1]); new OkCancelDialog(getFrame(), null, Console.message("Alert"), null, Console.message("OK"), Console.message("Change-exit"), true); break; } } } else if (this.avatarMenu == null || !this.avatarMenu.action(event, what)) { return super.action(event, what); } return true; } public void setCurrentAvatarItem(CheckboxMenuItem item) { if (this.curAvatarItem != null) { this.curAvatarItem.setState(false); } this.curAvatarItem = item; if (this.curAvatarItem != null) { this.curAvatarItem.setState(true); } } public CheckboxMenuItem getCurrentAvatarItem() { return this.curAvatarItem; } public void deletedSavedAvatar(CheckboxMenuItem item) { if (this.curAvatarItem == item) { this.findAvatarMenuItem(this.getDefaultAvatarURL()); } } public void setNextAvatar(URL url, CheckboxMenuItem item) { synchronized (this.nextAvatarMutex) { this.nextAvatar = url; this.nextAvatarItem = item; } } private void findAvatarMenuItem(URL url) { synchronized (this.nextAvatarMutex) { if (this.nextAvatarItem == null) { CheckboxMenuItem item; if ((this.savedAvs == null || (item = this.savedAvs.findMenuItem(url)) == null) && (this.avatarMenu == null || (item = this.avatarMenu.findMenuItem(url)) == null)) { this.setCurrentAvatarItem(null); } else { this.setCurrentAvatarItem(item); } } } } private URL getHelpGettingStarted() { IniFile ini = new IniFile("InstalledWorlds"); String helpName = Console.message("Getting-started"); String w = ini.getIniString("InstalledWorld0", ""); if (!w.equals("")) { URL name = URL.make("home:" + w + "/" + helpName); File f = new File(name.unalias()); if (f.exists()) { return name; } } return URL.make("home:" + helpName); } private void changeView(CheckboxMenuItem item) { this.chooseView = this.viewItems.indexOf(item); if (item != this.currentViewItem) { this.currentViewItem.setState(false); this.currentViewItem = item; this.currentViewItem.setState(true); } } private int getView() { return this.viewItems.indexOf(this.currentViewItem); } private void setView(int view) { this.changeView(this.viewItems.elementAt(view)); } private void changeCamSpeed(CheckboxMenuItem item) { this.chooseCamSpeed = this.camSpeedItems.indexOf(item); if (item != this.currentCamSpeedItem) { this.currentCamSpeedItem.setState(false); this.currentCamSpeedItem = item; this.currentCamSpeedItem.setState(true); } } public void resetCamera() { if (this.viewItems != null && this.camSpeedItems != null) { this.chooseView = this.viewItems.indexOf(this.currentViewItem); this.chooseCamSpeed = this.camSpeedItems.indexOf(this.currentCamSpeedItem); } } private void handleServerItem() { if (!this.serverItem.getLabel().equals(signIn)) { Galaxy.forceOffline(false); } else { this.getGalaxy().localForceOnline(); this.getGalaxy().waitForConnection(this); } } public UniversePanel getUniverse() { return this.universeMode ? this.universe : null; } public synchronized void setUniverseMode(boolean f) { if (f != this.universeMode) { this.universeMode = f; if (this.universeMode) { if (this.universe == null) { this.universe = new UniversePanel(this); this.renderAndUniverse.add("universe", this.universe); } this.renderCard.show(this.renderAndUniverse, "universe"); this.universe.startWatch(); this.render.requestFocus(); } else { this.renderCard.show(this.renderAndUniverse, "render"); if (physMem < 64000000) { this.renderAndUniverse.remove(this.universe); this.universe.stopWatch(); this.universe.flushImage(); this.universe = null; } this.renderAndUniverse.repaint(); } } } public void toggleUniverseMode() { this.setUniverseMode(!this.universeMode); } public boolean isUniverseMode() { return this.universeMode; } @Override public Object imageButtonsCallback(Component who, int which) { if (who != this.driveButton) { if (who == this.quitButton) { maybeQuit(); } else if (who == this.adCubeButton) { String adURL = IniFile.gamma().getIniString("AdCubeURL", "http://www.worlds.com/"); new SendURLAction(adURL, true).startBrowser(); } else if (who == this.exploreButton) { this.toggleUniverseMode(); } else if (who == this.menuButtons) { switch (which) { case 0: return this.getMenu("Help"); case 1: return this.getMenu("Options"); case 2: String prodName = IniFile.override().getIniString("ProductName", ""); if (!prodName.equalsIgnoreCase("RedLightWorld") && !prodName.equalsIgnoreCase("RedLightCenter")) { EMailPart.showMessage(this); } break; case 3: return (PopupMenu)this.marks.getMenu(); case 4: return (PopupMenu)this.marks.getLetsMenu(); case 5: this.actions.present(); break; case 6: return this.getMenu("VIP"); } } } return null; } public RenderCanvas getRender() { return this.render; } public FriendsListPart getFriends() { return this.friends; } public MuteListPart getMutes() { return this.mutes; } @Override public void generateFrameEvents(FrameEvent f) { if (Window.getWindowState(Window.getFrameHandle()) == 1) { this.goToSleep(); } if (doDrive) { doDrive = false; this.render.drive(); wasDelta = true; } super.generateFrameEvents(f); Pilot pilot = Pilot.getActive(); GammaFrame frame = getFrame(); String worldName = ""; if (pilot != null) { World world = pilot.getWorld(); if (world != null) { String name = world.getName(); if (name != null) { worldName = name; } } } if (!lastWorldName.equals(worldName)) { lastWorldName = worldName; String newTitle = GammaFrame.getDefaultTitle(); if (worldName.length() != 0) { newTitle = newTitle + " - " + worldName; if (!this.playedCD) { CDAudio.startupPlay(); this.playedCD = true; } } frame.setTitle(newTitle); } if (pilot != null) { if (this.chooseView != -1 || this.chooseCamSpeed != -1) { int oldCameraMode = pilot.getOutsideCameraMode(); int oldCameraSpeed = pilot.getOutsideCameraSpeed(); int cameraMode = oldCameraMode; int cameraSpeed = oldCameraSpeed; if (this.chooseView != -1) { cameraMode = this.viewNames.elementAt(this.chooseView).viewID; } if (this.chooseCamSpeed != -1) { cameraSpeed = this.speedNames.elementAt(this.chooseCamSpeed).speedID; } pilot.setOutsideCameraMode(cameraMode, cameraSpeed); if (cameraMode != 99) { IniFile.gamma().setIniInt("CAM_MODE", cameraMode); IniFile.gamma().setIniInt("CAM_SPEED", cameraSpeed); } this.chooseView = -1; this.chooseCamSpeed = -1; } if (this.wasTeleporting != this.marks.isTeleporting()) { this.wasTeleporting = this.marks.isTeleporting(); if (this.wasTeleporting) { this.statusMessage = loadingString; } else if (this.statusMessage == loadingString) { this.statusMessage = ""; } } this.checkVMWarning(); if (wasDelta && !this.render.getDeltaMode()) { this.statusMessage = arrowKeyMsg; wasDelta = false; this.driveButton.drawCursed(); } synchronized (this.status) { if (this.statusMessage != this.lastStatus && this.overrideMessage == null) { this.lastStatus = this.statusMessage; this.status.setText(this.statusMessage); } } synchronized (this.nextAvatarMutex) { if (this.nextAvatar != null) { this.setAvatar(this.nextAvatar); this.nextAvatar = null; if (this.avatarMenu != null) { this.avatarMenu.notifyOfChange(); } if (this.nextAvatarItem != null) { this.setCurrentAvatarItem(this.nextAvatarItem); this.nextAvatarItem = null; } } } } } private void checkVMWarning() { int now = Std.getFastTime(); if (now > this.lastVMCheck + 10000) { StatMemNode m = StatMemNode.getNode(); m.updateMemoryStatus(); if (m._availPageMem < 0) { m._availPageMem = 2000000000; } if (m._totPhysMem < 0) { m._totPhysMem = 2000000000; } physMem = m._totPhysMem; if (m._availPageMem >= 4194304) { if (m._availPageMem > 5242880 && this.lastVMBigWarning != 0) { if (m._availPageMem > 10485760) { Console.println(Console.message("plenty-virt")); this.lastVMBigWarning = 0; } else if (!this.showedMidWarn) { Console.println(Console.message("plenty-virt-mem")); this.showedMidWarn = true; } if (this.statusMessage == lowVMMsg) { this.statusMessage = ""; } } } else { if (this.lastVMBigWarning == 0 || this.showedMidWarn || now > this.lastVMBigWarning + 300000) { Console.println(Console.message("Low-virt-mem")); this.lastVMBigWarning = now; this.showedMidWarn = false; } this.statusMessage = lowVMMsg; } Object[] arguments = new Object[]{new String(Std.getProductName()), new Integer(24)}; if (startupMemCheck) { if (m._totPhysMem < 24000000) { String result = MessageFormat.format(Console.message("Mem-detected"), arguments); new OkCancelDialog(getFrame(), null, Console.message("Too-Little-RAM"), null, Console.message("OK"), result, true); } startupMemCheck = false; System.out.println("System has " + m._totPhysMem + " bytes of physical RAM"); } this.lastVMCheck = now; } } @Override public URL getAvatarName() { return this.avatarURL; } @Override public void setServerURL(URL serverURL) { super.setServerURL(serverURL); } @Override public void dialogDone(Object who, boolean confirmed) { if (who instanceof QuitDialog) { if (confirmed) { Console.quit(); } } else if (who instanceof BootDialog) { if (confirmed) { BootDialog bd = (BootDialog)who; String bname = bd.getBoot(); if (!bname.equals("")) { Pilot.sendText("world", "!boot " + bname); } } } else if (who instanceof ChannelDialog) { if (confirmed) { ChannelDialog cd = (ChannelDialog)who; String newChannel = cd.getChannel(); Pilot pilot = Pilot.getActive(); String oldPos = pilot != null ? pilot.getURL() : null; if (oldPos != null) { int channelIndex = oldPos.indexOf("<"); int channelEndIndex = oldPos.indexOf(">"); if (channelIndex >= 0 && channelEndIndex > channelIndex) { TeleportAction.teleport(oldPos.substring(0, channelIndex + 1) + newChannel + oldPos.substring(channelEndIndex), null); } } else { Console.println(Console.message("cant-determine")); } } } else if (who instanceof ChatDialog) { if (confirmed) { ChatDialog cd = (ChatDialog)who; int newFontsize = cd.getFontsize(); int newLines = cd.getLines(); int newLength = cd.getLength(); if (newLines < 6) { newLines = 6; } int oldFontSize = IniFile.gamma().getIniInt("ChatFontSize", 12); int oldLength = IniFile.gamma().getIniInt("ChatLengthLimit", 20000); if (newFontsize != oldFontSize || newLines != chatLines || newLength != oldLength) { if (newFontsize != oldFontSize) { IniFile.gamma().setIniInt("ChatFontSize", newFontsize); } if (newLines != chatLines) { chatLines = newLines; IniFile.gamma().setIniInt("ChatLines", newLines); } if (newLength != oldLength) { NewSharedTextArea.chatLengthLimit = newLength; ClassicSharedTextArea.chatLengthLimit = newLength; IniFile.gamma().setIniInt("ChatLengthLimit", newLength); } if (this.chat.listen.getComponent().getClass() == NewSharedTextArea.class) { try { NewSharedTextArea gta = (NewSharedTextArea)this.chat.listen.getComponent(); gta.setFontSize(newFontsize); gta.setRows(newLines); gta.scrollToBottom(); gta.setScrollBounds(); } catch (Exception var10) { } } int h = chatLines * this.chat.listen.getComponent().getFontMetrics(this.chat.listen.getFont()).getHeight(); h -= 96; if (h > 0 && this.adFiller != null) { this.adFiller.setHeight(h); } Console.frame.validate(); Console.frame.repaint(); } } } else if (who instanceof LoginWizard) { assert false; } else if (who instanceof CDControl) { if (this.cdcontrol == who) { this.cdcontrol = null; } } else if (who instanceof InternetConnectionDialog) { assert false; } else if (who == this.reloginDialog) { if (confirmed) { Galaxy.forceOffline(true); } this.reloginDialog = null; } } @Override public void setAvatar(URL url) { this.avatarURL = url; boolean isVIPAv = url.getInternal().toLowerCase().endsWith(".rwg"); boolean hasAmnesty = url.equals(getDefaultURL()) && !this.getGalaxy().getOnline(); if (!this.getVIP() && isVIPAv && !hasAmnesty) { Console.println(Console.message("Only-VIPs") + " '" + SelectAvatarAction.getPrettyAvatarName(url.getBase()) + "'."); } else if (VehicleShape.isVehicle(url)) { this.tempCarAvatar = url.getAbsolute(); super.setAvatar(url); } else { this.tempCarAvatar = ""; if (this.avatarMenu != null) { this.avatarMenu.customize.setEnabled(!url.getAbsolute().endsWith("mov")); } if (!url.equals(this.getDefaultAvatarURL())) { if (this.getVIPAvatars()) { if (!isVIPAv) { IniFile.gamma().setIniString("VIPAVATAR", ""); } else { IniFile.gamma().setIniString("VIPAVATAR", url.getAbsolute()); } } if (!isVIPAv) { IniFile.gamma().setIniString("AVATAR", url.getAbsolute()); } } super.setAvatar(url); } } private CheckboxMenuItem findAvatar(Vector items, String name) { if (items != null) { int count = items.size(); for (int i = 0; i < count; i++) { CheckboxMenuItem item = items.elementAt(i); if (item.getLabel().equals(name)) { return item; } } } return null; } @Override protected void loadPilot(URL url) { super.loadPilot(url); this.findAvatarMenuItem(url); } @Override public void setChatname(String chatname) { assert chatname != null; if (chatname.length() != 0) { String nameStr = (this.getVIP() ? (vip > 1 ? Console.message("VIP") + " " : Console.message("vip")) + " " : "") + "\"" + Console.parseUnicode(chatname) + "\""; this.yourName.setText(nameStr); IniFile.gamma().setIniString("LASTCHATNAME", parseExtended(nameStr)); } else { this.yourName.setText(Console.message("Off-line")); } } @Override public void connectionCallback(Object caller, boolean connected) { super.connectionCallback(caller, connected); if (caller instanceof Galaxy) { if (caller != this.galaxy) { return; } if (connected) { WorldServer serv = this.getServerNew(); this.friends.setServer(serv, this.getGalaxy().getIniSection()); this.mutes.setServer(serv, this.getGalaxy().getIniSection()); if (vip < 2) { Console.println(vip == 1 ? Console.message("Press-full-VIP") : Console.message("Press-VIP")); } PosableShape.downloadPermittedNames(); } } } @Override public void galaxyDisconnected() { super.galaxyDisconnected(); this.getFriends().maybeServerDisconnect(); } @Override public boolean okToQuit() { int quitDlg = IniFile.override().getIniInt("QuitDialog", 1); try { if (quitDlg == 1) { new QuitDialog(getFrame(), this); return false; } } catch (Exception var3) { } return true; } public Rectangle getBrowserPlacement() { String coords = IniFile.gamma().getIniString("BROWSERWINDOW", ""); if (coords.length() != 0) { StringTokenizer tok = new StringTokenizer(coords, " ,"); try { return new Rectangle( Integer.parseInt(tok.nextToken()), Integer.parseInt(tok.nextToken()), Integer.parseInt(tok.nextToken()), Integer.parseInt(tok.nextToken()) ); } catch (NumberFormatException var9) { } catch (NoSuchElementException var10) { } } int w = this.menuButtons.getLocationOnScreen().x - (int)(this.menuButtons.getSize().width * 0.7); int frameWidth = Window.getSystemMetrics(32); int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width; int minWidth = Math.min(screenWidth, 640) + 2 * frameWidth; int x = 0; if (w != minWidth) { if (w > minWidth) { x += w - minWidth; } w = minWidth; } if (w > screenWidth) { x += -frameWidth; } int h = this.chat.listen.getLocationOnScreen().y + this.chat.listen.getSize().height - this.chat.line.getSize().height; int y = 0; if (h > maxWebSize) { y += h - maxWebSize; h = maxWebSize; } return new Rectangle(x, y, w, h); } @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, "Avatar"), "rwg;mov"); } else if (mode == 1) { ret = this.lastPilotRequested; } else if (mode == 2) { this.setNextAvatar((URL)value, null); } break; case 1: if (mode == 0) { ret = BooleanPropertyEditor.make(new Property(this, index, "Collect garbage"), "No", "Yes"); } else if (mode == 1) { ret = new Boolean(false); } else if (mode == 2 && (Boolean)value) { System.gc(); System.runFinalization(); } break; default: ret = super.properties(index, offset + 2, mode, value); } return ret; } @Override public void saveState(Saver s) throws IOException { s.saveVersion(0, classCookie); super.saveState(s); } @Override public void restoreState(Restorer r) throws IOException, TooNewException { int vers = r.restoreVersion(classCookie); switch (vers) { case 0: super.restoreState(r); return; default: throw new TooNewException(); } } public class CameraSpeed { public String speedName; public int speedID; public CameraSpeed(String sn, int sid) { this.speedName = sn; this.speedID = sid; } } public class CameraView { public String viewName; public int viewID; public CameraView(String vn, int vid) { this.viewName = vn; this.viewID = vid; } } }