/* */ package NET.worlds.console; /* */ /* */ import NET.worlds.core.IniFile; /* */ import NET.worlds.core.Std; /* */ import NET.worlds.network.BuddyListUpdateCmd; /* */ import NET.worlds.network.Galaxy; /* */ import NET.worlds.network.InfiniteWaitException; /* */ import NET.worlds.network.NetUpdate; /* */ import NET.worlds.network.NetworkObject; /* */ import NET.worlds.network.PacketTooLargeException; /* */ import NET.worlds.network.WorldServer; /* */ import NET.worlds.network.netPacket; /* */ import NET.worlds.network.whisperCmd; /* */ import NET.worlds.scape.AnimatedActionManager; /* */ import NET.worlds.scape.Drone; /* */ import NET.worlds.scape.FrameEvent; /* */ import NET.worlds.scape.MouseDownEvent; /* */ import NET.worlds.scape.Pilot; /* */ import NET.worlds.scape.PosableDrone; /* */ import NET.worlds.scape.PosableShape; /* */ import NET.worlds.scape.Room; /* */ import NET.worlds.scape.TeleportAction; /* */ import java.awt.Color; /* */ import java.awt.Container; /* */ import java.awt.Dimension; /* */ import java.awt.Event; /* */ import java.awt.Font; /* */ import java.awt.Graphics; /* */ import java.awt.Image; /* */ import java.awt.Menu; /* */ import java.awt.MenuItem; /* */ import java.awt.PopupMenu; /* */ import java.awt.Window; /* */ import java.io.IOException; /* */ import java.text.MessageFormat; /* */ import java.util.Collections; /* */ import java.util.Comparator; /* */ import java.util.Enumeration; /* */ import java.util.StringTokenizer; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class FriendsListPart /* */ extends QuantizedCanvas /* */ implements FramePart, DialogReceiver, DialogDisabled, NameListOwner, Comparator /* */ { /* */ private static final long serialVersionUID = 2875678557235430189L; /* */ private static final String oldIniItemName = "Friends"; /* */ private static final String iniItemName = "Friend"; /* 195 */ private static int maxFriends = Gamma.shaperEnabled() ? 500 : 250; /* 196 */ private static int absMaxFriends = 600; /* */ /* */ /* */ private static final String separator = ";"; /* */ /* */ /* */ private static final String whereQuery = "&|+where?"; /* */ /* */ /* */ private static final String whereResponse = "&|+where>"; /* */ /* 207 */ VoiceChat chatter = new VoiceChat(); /* */ /* */ private static final int MOUSEMOVE = 0; /* */ /* */ private static final int MOUSEDRAG = 1; /* */ /* */ private static final int MOUSEDOWN = 2; /* */ /* */ private static final int MOUSEUP = 3; /* */ /* */ private static final int MOUSEENTER = 4; /* */ /* */ private static final int MOUSEEXIT = 5; /* */ /* */ private static final int BLANK = 0; /* */ /* */ private static final int NORMAL = 1; /* */ /* */ private static final int CURSED = 2; /* */ /* */ private static final int DOWN = 3; /* */ /* */ private static final int TELEPORT_IDLE = 0; /* */ /* */ private static final int TELEPORT_REQUEST_LOCATION = 1; /* */ /* */ private static final int TELEPORT_WAIT_FOR_LOCATION = 2; /* */ /* */ private static final int buttonWidth = 97; /* */ /* */ private static final int buttonHeight = 11; /* */ /* */ private static final int xText = 20; /* */ /* */ private static final int yText = 9; /* */ /* */ private static final int xTextClip = 94; /* */ /* */ private static Image friendsImage; /* */ /* */ private static Image moreFriendsImage; /* */ private static Font font; /* */ private static FriendsListPart active; /* 250 */ private Vector friends = new Vector(); /* */ /* */ /* 253 */ private Vector onlineFriends = new Vector(); /* */ /* */ /* 256 */ private Vector mutedOnlineFriends = new Vector(); /* */ /* */ /* 259 */ private Vector serverUpdates = new Vector(); /* */ /* */ /* 262 */ private Object friendsMutex = new Object(); /* */ /* */ /* 265 */ private int cursedButton = -1; /* 266 */ private int clickedButton = -1; /* */ /* */ /* */ private boolean clickedButtonDown; /* */ /* */ /* */ private PopupMenu menu; /* */ /* */ /* 275 */ private MenuItem teleportItem = new MenuItem(Console.message("Go-There")); /* 276 */ private MenuItem emailItem = new MenuItem(Console.message("E-Mail")); /* 277 */ private MenuItem muteItem = new MenuItem(Console.message("Mute")); /* 278 */ private MenuItem whisperItem = new MenuItem(Console.message("Whisper")); /* 279 */ private MenuItem voiceChatItem = new MenuItem(Console.message("Voice-Chat")); /* 280 */ private MenuItem infoItem = new MenuItem(Console.message("Personal-I")); /* 281 */ private MenuItem tradeItem = new MenuItem(Console.message("Talk-Trade")); /* */ /* */ /* */ private PopupMenu droneMenu; /* */ /* */ /* 287 */ private MenuItem droneAddItem = new MenuItem( /* 288 */ Console.message("Add-2-friends")); /* 289 */ private MenuItem droneEmailItem = new MenuItem(Console.message("E-Mail")); /* 290 */ private MenuItem droneMuteItem = new MenuItem(Console.message("Mute")); /* 291 */ private MenuItem droneWhisperItem = new MenuItem(Console.message("Whisper")); /* 292 */ private MenuItem droneVoiceChatItem = new MenuItem( /* 293 */ Console.message("Voice-Chat")); /* 294 */ private MenuItem droneInfoItem = new MenuItem(Console.message("Personal-I")); /* 295 */ private MenuItem droneTradeItem = new MenuItem( /* 296 */ Console.message("Talk-Trade")); /* */ /* */ /* */ /* 300 */ private String activeFriendName = ""; /* */ /* */ /* */ private String teleportTarget; /* */ /* */ /* 306 */ private int teleportState = 0; /* */ /* */ /* */ private int teleportWaitStartTime; /* */ /* */ /* */ private boolean teleportWaitSentMsg; /* */ /* */ /* */ private int friendsButtons; /* */ /* */ /* */ private int moreFriendsButton; /* */ /* */ /* */ private boolean moreFriendsActive; /* */ /* */ /* */ private MenuItem editItem; /* */ /* */ /* */ private Menu actionMenu; /* */ /* */ /* */ private MoreFriendsDialog moreFriendsDialog; /* */ /* */ /* */ private DefaultConsole console; /* */ /* */ /* */ private Galaxy galaxy; /* */ /* */ /* */ private IniFile serverSection; /* */ /* */ /* */ private boolean isDialogDisabled; /* */ /* */ /* 345 */ private int showMenuY = -1; /* */ /* */ private static final String voiceChatWhisper = "&|+voicechat"; /* */ /* */ /* */ public FriendsListPart() /* */ { /* 352 */ AnimatedActionManager.get(); /* */ /* */ /* 355 */ if (font == null) { /* 356 */ String friendsGif = IniFile.override().getIniString("friendsGif", /* 357 */ "friends.gif"); /* 358 */ friendsImage = ImageCanvas.getSystemImage(friendsGif, this); /* 359 */ String moreFriendsGif = IniFile.override().getIniString( /* 360 */ "moreFriendsGif", Console.message("mfriends.gif")); /* 361 */ moreFriendsImage = ImageCanvas.getSystemImage(moreFriendsGif, this); /* 362 */ int fontSize = new Integer(Console.message("FriendsPointSize")) /* 363 */ .intValue(); /* 364 */ font = new Font(Console.message("FriendsFont"), 0, /* 365 */ fontSize); /* */ } /* */ /* */ /* */ /* 370 */ this.teleportItem.setFont(font); /* 371 */ this.emailItem.setFont(font); /* 372 */ this.muteItem.setFont(font); /* 373 */ this.whisperItem.setFont(font); /* 374 */ this.tradeItem.setFont(font); /* 375 */ this.voiceChatItem.setFont(font); /* 376 */ this.infoItem.setFont(font); /* 377 */ this.menu = new PopupMenu(); /* 378 */ this.menu.add(this.teleportItem); /* */ /* */ /* 381 */ String prodName = IniFile.override().getIniString("ProductName", ""); /* 382 */ if ((!prodName.equalsIgnoreCase("RedLightWorld")) && /* 383 */ (!prodName.equalsIgnoreCase("RedLightCenter"))) /* 384 */ this.menu.add(this.emailItem); /* 385 */ this.menu.add(this.muteItem); /* 386 */ this.menu.add(this.whisperItem); /* 387 */ boolean allowTrading = (IniFile.gamma().getIniInt("EnableTrading", 0) == 1) || /* 388 */ (NetUpdate.isInternalVersion()); /* */ /* 390 */ if (allowTrading) { /* 391 */ this.menu.add(this.tradeItem); /* */ } /* */ /* */ /* */ /* */ /* */ /* 398 */ this.menu.add(this.infoItem); /* 399 */ add(this.menu); /* */ /* */ /* 402 */ this.droneAddItem.setFont(font); /* 403 */ this.droneEmailItem.setFont(font); /* 404 */ this.droneMuteItem.setFont(font); /* 405 */ this.droneWhisperItem.setFont(font); /* 406 */ this.droneTradeItem.setFont(font); /* 407 */ this.droneVoiceChatItem.setFont(font); /* 408 */ this.droneInfoItem.setFont(font); /* 409 */ this.droneMenu = new PopupMenu(); /* 410 */ this.droneMenu.setFont(font); /* 411 */ this.droneMenu.add(this.droneAddItem); /* 412 */ this.droneMenu.add(this.droneEmailItem); /* 413 */ this.droneMenu.add(this.droneMuteItem); /* 414 */ this.droneMenu.add(this.droneWhisperItem); /* 415 */ if (allowTrading) { /* 416 */ this.droneMenu.add(this.droneTradeItem); /* */ } /* */ /* */ /* */ /* */ /* 422 */ this.droneMenu.add(this.droneInfoItem); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void update(Graphics g) /* */ { /* 434 */ paint(g); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void paint(Graphics g) /* */ { /* 443 */ int height = getSize().height; /* 444 */ int buttons = height / 11; /* */ /* */ /* 447 */ synchronized (this.friendsMutex) /* */ { /* */ /* 450 */ int count = this.onlineFriends.size(); /* 451 */ this.moreFriendsButton = (buttons - 1); /* 452 */ if (count >= buttons) /* */ { /* */ /* */ /* */ /* */ /* */ /* 459 */ this.friendsButtons = (buttons - 1); /* 460 */ this.moreFriendsActive = true; /* */ } /* */ else /* */ { /* 464 */ this.friendsButtons = count; /* 465 */ this.moreFriendsActive = false; /* */ } /* */ /* */ /* 469 */ int y = buttons * 11; /* 470 */ int extra = height - y; /* 471 */ if (extra > 0) { /* 472 */ g.setColor(Color.black); /* 473 */ g.fillRect(0, 0, 97, extra); /* */ } /* */ /* 476 */ for (int i = 0; i < buttons; i++) { /* 477 */ int state = 1; /* 478 */ if ((i >= this.friendsButtons) && (!isMoreFriendsButton(i))) { /* 479 */ state = 0; /* 480 */ } else if (i == this.clickedButton) { /* 481 */ state = this.clickedButtonDown ? 3 : 1; /* 482 */ } else if (i == this.cursedButton) /* 483 */ state = 2; /* 484 */ drawButton(g, i, state); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ public int getRemainder(int proposedHeight) /* */ { /* 493 */ int buttons = proposedHeight / 11; /* 494 */ int y = buttons * 11; /* 495 */ return proposedHeight - y; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public Dimension getPreferredSize() /* */ { /* 504 */ return new Dimension(97, 1); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public Dimension getMinimumSize() /* */ { /* 513 */ return getPreferredSize(); /* */ } /* */ /* */ /* */ /* */ @Deprecated /* */ public boolean mouseMove(Event e, int x, int y) /* */ { /* 521 */ return buttonAction(x, y, 0); /* */ } /* */ /* */ @Deprecated /* */ public boolean mouseDown(Event e, int x, int y) /* */ { /* 527 */ return buttonAction(x, y, 2); /* */ } /* */ /* */ @Deprecated /* */ public boolean mouseUp(Event e, int x, int y) /* */ { /* 533 */ if (buttonAction(x, y, 3)) { /* 534 */ if (this.showMenuY != -1) { /* 535 */ this.menu.show(this, 0, this.showMenuY); /* 536 */ this.showMenuY = -1; /* */ } /* 538 */ return true; /* */ } /* 540 */ return false; /* */ } /* */ /* */ @Deprecated /* */ public boolean mouseDrag(Event e, int x, int y) /* */ { /* 546 */ return buttonAction(x, y, 1); /* */ } /* */ /* */ @Deprecated /* */ public boolean mouseEnter(Event e, int x, int y) /* */ { /* 552 */ return buttonAction(x, y, 4); /* */ } /* */ /* */ @Deprecated /* */ public boolean mouseExit(Event e, int x, int y) /* */ { /* 558 */ return buttonAction(x, y, 5); /* */ } /* */ /* */ /* */ @Deprecated /* */ public boolean handleEvent(Event event) /* */ { /* 565 */ if (this.isDialogDisabled) /* 566 */ return false; /* 567 */ return super.handleEvent(event); /* */ } /* */ /* */ private void loadFriends() /* */ { /* 572 */ if (this.friends.size() != 0) { /* 573 */ this.friends.removeAllElements(); /* */ } /* 575 */ if (Console.getActive().broadcastEnabled()) { /* 576 */ maxFriends = 600; /* */ } /* */ /* 579 */ for (int i = 0; i < absMaxFriends; i++) { /* 580 */ String name = this.serverSection.getIniString("Friend" + i, ""); /* 581 */ if (name.length() == 0) /* */ break; /* 583 */ if ((isValidUserName(name)) && (!icontains(this.friends, name))) { /* 584 */ this.friends.addElement(name); /* */ } /* */ } /* 587 */ if (this.friends.size() == 0) /* */ { /* */ /* */ /* */ /* 592 */ String friendsStr = this.serverSection.getIniString("Friends", ""); /* 593 */ StringTokenizer tokens = new StringTokenizer(friendsStr, ";"); /* 594 */ while ((tokens.hasMoreTokens()) && (this.friends.size() < absMaxFriends)) { /* 595 */ String name = tokens.nextToken(); /* */ /* */ /* 598 */ if ((isValidUserName(name)) && (!icontains(this.friends, name))) /* 599 */ this.friends.addElement(name); /* */ } /* 601 */ if (this.friends.size() != 0) { /* 602 */ saveFriends(); /* 603 */ this.serverSection.setIniString("Friends", ""); /* */ } /* */ } /* 606 */ Collections.sort(this.friends, this); /* */ } /* */ /* */ /* */ void saveFriends() /* */ { /* 612 */ if (this.serverSection == null) /* 613 */ return; /* 614 */ int count = this.friends.size(); /* 615 */ for (int i = 0; i < count; i++) /* 616 */ this.serverSection.setIniString("Friend" + i, /* 617 */ (String)this.friends.elementAt(i)); /* 618 */ this.serverSection.setIniString("Friend" + count, ""); /* */ } /* */ /* */ /* */ /* */ /* */ private boolean isMoreFriendsButton(int button) /* */ { /* 626 */ return (button == this.moreFriendsButton) && (this.moreFriendsActive); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private Graphics drawButton(Graphics g, int button, int state) /* */ { /* 637 */ Image image = button == this.moreFriendsButton ? moreFriendsImage : /* 638 */ friendsImage; /* */ /* */ /* */ /* */ /* 643 */ if ((g != null) || ((g = getGraphics()) != null)) { /* 644 */ int y = button * 11; /* */ /* */ /* */ /* 648 */ Graphics g1 = g.create(0, y, 97, 11); /* */ /* */ /* */ /* */ /* 653 */ g1.drawImage(image, -state * 97, 0, null); /* */ /* 655 */ if ((button >= 0) && (button < this.friendsButtons) && /* 656 */ (button < this.onlineFriends.size())) /* */ { /* */ /* 659 */ g1.clipRect(0, 0, 94, 11); /* 660 */ g1.setFont(font); /* 661 */ g1.setColor(Color.white); /* 662 */ g1.drawString((String)this.onlineFriends.elementAt(button), 20, /* 663 */ 9); /* */ } /* 665 */ g1.dispose(); /* */ } /* 667 */ return g; /* */ } /* */ /* */ private boolean buttonAction(int x, int y, int action) /* */ { /* 672 */ synchronized (this.friendsMutex) { /* 673 */ Graphics g = null; /* 674 */ int button = y / 11; /* 675 */ if (((button < 0) || (button >= this.friendsButtons)) && /* 676 */ (!isMoreFriendsButton(button))) { /* 677 */ button = -1; /* */ } /* 679 */ if ((action == 0) || (action == 4)) { /* 680 */ if (button != this.cursedButton) { /* 681 */ g = drawButton(g, this.cursedButton, 1); /* 682 */ g = drawButton(g, this.cursedButton = button, 2); /* */ } /* 684 */ } else if (action == 5) { /* 685 */ if (this.cursedButton != -1) { /* 686 */ g = drawButton(g, this.cursedButton, 1); /* 687 */ this.cursedButton = -1; /* */ } /* 689 */ if ((this.clickedButton != -1) && (this.clickedButtonDown)) { /* 690 */ g = drawButton(g, this.clickedButton, 1); /* 691 */ this.clickedButtonDown = false; /* */ } /* 693 */ } else if (action == 2) { /* 694 */ if (this.clickedButton != -1) { /* 695 */ g = drawButton(g, this.clickedButton, 1); /* 696 */ this.clickedButtonDown = false; /* */ } /* 698 */ if ((this.clickedButton = button) != -1) { /* 699 */ g = drawButton(g, this.clickedButton, 3); /* 700 */ this.clickedButtonDown = true; /* */ } /* 702 */ } else if (action == 1) { /* 703 */ if (this.clickedButton != -1) { /* 704 */ if (this.clickedButtonDown) { /* 705 */ if (button != this.clickedButton) { /* 706 */ g = drawButton(g, this.clickedButton, 1); /* 707 */ this.clickedButtonDown = false; /* */ } /* 709 */ } else if (button == this.clickedButton) { /* 710 */ g = drawButton(g, this.clickedButton, 3); /* 711 */ this.clickedButtonDown = true; /* */ } /* */ } /* 714 */ } else if (action == 3) { /* 715 */ this.cursedButton = button; /* */ /* */ /* */ /* */ /* 720 */ if (this.clickedButtonDown) { /* 721 */ if (this.cursedButton == this.clickedButton) { /* 722 */ g = drawButton(g, this.clickedButton, 2); /* */ } else { /* 724 */ g = drawButton(g, this.clickedButton, 1); /* */ } /* */ /* */ /* */ /* 729 */ if (this.clickedButton == this.moreFriendsButton) /* */ { /* */ /* 732 */ if (this.moreFriendsDialog == null) { /* 733 */ this.moreFriendsDialog = new MoreFriendsDialog(this, /* 734 */ this.menu, this.onlineFriends); /* */ /* */ } /* */ /* */ /* */ } /* 740 */ else if ((this.clickedButton >= 0) && /* 741 */ (this.clickedButton < this.onlineFriends.size())) { /* 742 */ this.activeFriendName = /* 743 */ ((String)this.onlineFriends.elementAt(this.clickedButton)); /* 744 */ assert (this.activeFriendName != null); /* 745 */ this.showMenuY = ((this.clickedButton + 1) * 11); /* */ } /* */ } /* */ /* 749 */ if (this.cursedButton != this.clickedButton) /* 750 */ g = drawButton(g, this.cursedButton, 2); /* 751 */ this.clickedButtonDown = false; /* 752 */ this.clickedButton = -1; /* */ } /* 754 */ if (g != null) /* 755 */ g.dispose(); /* */ } /* 757 */ return true; /* */ } /* */ /* */ /* */ /* */ private static boolean sendMsg(WorldServer server, netPacket packet) /* */ { /* */ try /* */ { /* 766 */ server.sendNetworkMsg(packet); /* 767 */ return true; /* */ } /* */ catch (InfiniteWaitException localInfiniteWaitException) {}catch (PacketTooLargeException localPacketTooLargeException) {} /* */ /* 771 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void activate(Console c, Container f, Console prev) /* */ { /* 780 */ active = this; /* */ /* */ /* */ /* 784 */ this.console = ((DefaultConsole)c); /* */ /* 786 */ this.console.getRender().add(this.droneMenu); /* */ /* */ /* 789 */ this.editItem = c.addMenuItem(Console.message("Edit-Friends"), "Options"); /* */ /* 791 */ this.editItem.setEnabled(this.friends != null); /* */ } /* */ /* */ /* */ /* */ public void deactivate() /* */ { /* 798 */ active = null; /* 799 */ this.editItem = null; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ @Deprecated /* */ public boolean action(Event event, Object what) /* */ { /* 809 */ if (event.target == this.editItem) /* */ { /* */ /* 812 */ new EditNamesDialog(this, Console.message("Edit-Friends2"), /* 813 */ Console.message("Add-Friend")); /* 814 */ return true; /* */ } /* */ /* */ /* 818 */ return maybeFriendAction(event.target); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public boolean handle(FrameEvent f) /* */ { /* 831 */ synchronized (this.friendsMutex) { /* 832 */ int count = this.serverUpdates.size(); /* 833 */ if (count != 0) { /* 834 */ WorldServer server = this.console.getServerNew(); /* 835 */ if (server != null) /* */ { /* */ do /* */ { /* 839 */ this.serverUpdates.removeElementAt(0); /* 836 */ if (count-- == 0) /* */ break; /* 838 */ } while (sendMsg(server, (netPacket)this.serverUpdates.elementAt(0))); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* 846 */ synchronized (this) { /* 847 */ if (this.teleportState == 1) { /* 848 */ WorldServer server = this.console.getServerNew(); /* 849 */ if (server != null) { /* 850 */ sendMsg(server, new whisperCmd(this.teleportTarget, "&|+where?")); /* 851 */ this.teleportState = 2; /* 852 */ this.teleportWaitStartTime = Std.getRealTime(); /* 853 */ this.teleportWaitSentMsg = false; /* */ } else { /* 855 */ Console.println(Console.message("Cant-go-there")); /* 856 */ this.teleportState = 0; /* */ } /* */ } /* */ /* 860 */ if (this.teleportState == 2) { /* 861 */ int now = Std.getRealTime(); /* 862 */ if (now > this.teleportWaitStartTime + 5000) { /* 863 */ if (now > this.teleportWaitStartTime + 30000) /* */ { /* 865 */ this.teleportState = 0; /* 866 */ if (this.teleportWaitSentMsg) { /* 867 */ Object[] arguments = { new String(this.teleportTarget) }; /* 868 */ Console.println(MessageFormat.format( /* 869 */ Console.message("Cancel-teleport"), /* 870 */ arguments)); /* */ } /* 872 */ } else if (!this.teleportWaitSentMsg) /* */ { /* 874 */ Object[] arguments = { new String(this.teleportTarget) }; /* 875 */ Console.println(MessageFormat.format( /* 876 */ Console.message("Delay-locating"), arguments)); /* 877 */ this.teleportWaitSentMsg = true; /* */ } /* */ } /* */ } /* */ } /* 882 */ return true; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void dialogDisable(boolean disable) /* */ { /* 892 */ if ((this.isDialogDisabled = disable)) { /* 893 */ this.cursedButton = -1; /* 894 */ this.clickedButton = -1; /* 895 */ this.clickedButtonDown = false; /* 896 */ repaint(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void setServer(WorldServer server, IniFile serverSection) /* */ { /* 906 */ this.serverSection = serverSection; /* 907 */ this.galaxy = server.getGalaxy(); /* 908 */ assert (serverSection != null); /* 909 */ assert (this.galaxy != null); /* */ /* */ /* */ /* 913 */ loadFriends(); /* 914 */ if (this.editItem != null) { /* 915 */ this.editItem.setEnabled(true); /* */ } /* */ /* 918 */ sendAll(server); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void maybeServerDisconnect() /* */ { /* 928 */ if (this.galaxy != null) { /* 929 */ if (this.editItem != null) /* 930 */ this.editItem.setEnabled(false); /* 931 */ clearAll(); /* */ } /* */ } /* */ /* */ public static boolean tryToRun(String s) { /* */ try { /* 937 */ Runtime.getRuntime().exec(s); /* 938 */ return true; /* */ } catch (IOException e) {} /* 940 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ private boolean maybeFriendAction(Object target) /* */ { /* 949 */ if ((target == this.emailItem) || (target == this.droneEmailItem)) { /* 950 */ EMailPart.showMessage(this.console, this.activeFriendName); /* 951 */ } else if ((target == this.whisperItem) || (target == this.droneWhisperItem)) { /* 952 */ Console.startWhispering(this.activeFriendName); /* 953 */ } else if ((target == this.voiceChatItem) || (target == this.droneVoiceChatItem)) { /* 954 */ this.chatter.beginChat(this.activeFriendName, this.console); /* 955 */ } else if (target == this.droneAddItem) { /* 956 */ if (mayAddNameListName(Console.getFrame())) /* 957 */ addNameListName(this.activeFriendName); /* 958 */ } else { if (target == this.teleportItem) /* 959 */ synchronized (this) { /* 960 */ this.teleportTarget = this.activeFriendName; /* 961 */ if ((this.teleportState == 2) && /* 962 */ (this.teleportWaitSentMsg)) { /* 963 */ Console.println(Console.message("Cancel-new-tele")); /* */ } /* 965 */ this.teleportState = 1; /* */ } /* 967 */ if ((target == this.muteItem) || (target == this.droneMuteItem)) { /* 968 */ if (this.console.getMutes().mayAddNameListName(Console.getFrame())) /* 969 */ this.console.getMutes().addNameListName(this.activeFriendName); /* 970 */ } else if ((target == this.infoItem) || (target == this.droneInfoItem)) { /* 971 */ new PersonalInfoDownload(this.activeFriendName, this.console); /* 972 */ } else if ((target == this.tradeItem) || (target == this.droneTradeItem)) { /* 973 */ WhisperManager.whisperManager().startToTrade(this.activeFriendName); /* */ } else /* 975 */ return false; } /* 976 */ return true; /* */ } /* */ /* */ /* */ /* */ /* */ private void clearAll() /* */ { /* 984 */ if (this.galaxy != null) { /* 985 */ synchronized (this.friendsMutex) { /* 986 */ this.onlineFriends.removeAllElements(); /* 987 */ this.mutedOnlineFriends.removeAllElements(); /* */ } /* 989 */ if (active == this) /* 990 */ repaint(); /* 991 */ this.galaxy.sentFriendsList(false); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ private void sendAll(WorldServer server) /* */ { /* 1001 */ if (!this.galaxy.sentFriendsList()) { /* 1002 */ synchronized (this.friendsMutex) { /* 1003 */ int count = this.friends.size(); /* 1004 */ for (int i = 0; i < count; i++) /* 1005 */ sendMsg(server, /* 1006 */ new BuddyListUpdateCmd( /* 1007 */ (String)this.friends.elementAt(i), 1)); /* */ } /* 1009 */ this.galaxy.sentFriendsList(true); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ private static String getWorldName(String url) /* */ { /* 1019 */ int rindex = url.indexOf(".world#"); /* 1020 */ if (rindex != -1) { /* */ int windex; /* 1022 */ if (((windex = url.lastIndexOf('/', rindex)) != -1) || /* 1023 */ ((windex = url.lastIndexOf(':', rindex)) != -1)) /* 1024 */ return url.substring(windex + 1, rindex); /* */ } /* 1026 */ return null; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static void processWhisper(WorldServer server, String user, String text) /* */ { /* 1041 */ if ((active != null) && (active.galaxy == server.getGalaxy())) { /* 1042 */ active.instanceProcessWhisper(server, user, text); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private synchronized void instanceProcessWhisper(WorldServer server, String user, String text) /* */ { /* 1055 */ if (text.startsWith("&|+where?")) /* */ { /* */ Pilot pilot; /* */ /* */ String url; /* 1060 */ if (((pilot = Pilot.getActive()) != null) && /* 1061 */ ((url = pilot.getTeleportURL()) != null)) { /* 1062 */ if (this.console.getSpecialGuest()) /* */ { /* */ /* */ /* 1066 */ int i = url.indexOf('<'); /* 1067 */ int j = url.indexOf('>'); /* 1068 */ url = url.substring(0, i) + url.substring(j + 1); /* */ } /* */ /* 1071 */ if (Pilot.getActive().getRoom().getAllowTeleport()) { /* 1072 */ sendMsg(server, new whisperCmd(user, "&|+where>" + url)); /* */ } /* */ /* */ } /* */ } /* 1077 */ else if (text.startsWith("&|+where>")) /* */ { /* */ /* */ /* 1081 */ if ((this.teleportState == 2) && /* 1082 */ (this.teleportTarget.equals(user))) { /* 1083 */ String pos = text.substring("&|+where>".length()); /* */ /* */ /* 1086 */ boolean valid = false; /* */ /* 1088 */ String targetWorld = getWorldName(pos); /* */ /* */ /* 1091 */ if ((pos.startsWith("home:")) || (pos.startsWith("http://"))) { /* 1092 */ valid = true; /* */ /* */ } /* */ else /* */ { /* */ /* 1098 */ if ((targetWorld != null) && (targetWorld.length() > 0)) /* */ { /* 1100 */ Pilot pilot = Pilot.getActive(); /* 1101 */ if (pilot != null) /* */ { /* 1103 */ String url = pilot.getTeleportURL(); /* 1104 */ if ((url != null) && /* 1105 */ (targetWorld.equals(getWorldName(url)))) { /* 1106 */ valid = true; /* 1107 */ pos = url.substring(0, url.lastIndexOf('#')) + /* 1108 */ pos.substring(pos.lastIndexOf('#')); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* 1115 */ if (!valid) { /* 1116 */ String s = WorldsMarkPart.findPackage(targetWorld); /* 1117 */ if (s != null) { /* 1118 */ valid = true; /* 1119 */ pos = "home:" + s + "/" + s + ".world" + /* 1120 */ pos.substring(pos.lastIndexOf('#')); /* */ } /* */ } /* */ } /* */ /* 1125 */ if (valid) { /* 1126 */ TeleportAction.teleport(pos, null); /* 1127 */ if (this.teleportWaitSentMsg) { /* 1128 */ Object[] arguments = { new String(this.teleportTarget) }; /* 1129 */ Console.println(MessageFormat.format( /* 1130 */ Console.message("Found-tele"), arguments)); /* */ } /* */ } else { /* 1133 */ Object[] arguments = { new String(this.teleportTarget), /* 1134 */ new String(targetWorld) }; /* 1135 */ String msg = MessageFormat.format( /* 1136 */ Console.message("Cant-go-world"), arguments); /* 1137 */ Console.println(msg); /* */ } /* */ /* 1140 */ this.teleportState = 0; /* 1141 */ this.teleportTarget = null; /* */ } /* */ /* */ /* */ } /* 1146 */ else if (text.startsWith("&|+voicechat")) { /* 1147 */ this.chatter.handleChatWhisper(user, text, this.console); /* */ /* */ } /* 1150 */ else if (text.startsWith(VoiceChat.VCdebugCommand)) { /* 1151 */ VoiceChat.setExtra(text); /* 1152 */ } else if (text.startsWith(VoiceChat.VCdebugCommandReset)) { /* 1153 */ VoiceChat.resetExtra(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ public int getNameListCount() /* */ { /* 1162 */ return this.friends.size(); /* */ } /* */ /* */ /* */ public String getNameListName(int index) /* */ { /* 1168 */ return (String)this.friends.elementAt(index); /* */ } /* */ /* */ /* */ public void removeNameListName(int index) /* */ { /* 1174 */ synchronized (this.friendsMutex) { /* 1175 */ String name = (String)this.friends.elementAt(index); /* 1176 */ this.friends.removeElementAt(index); /* 1177 */ saveFriends(); /* */ /* */ /* */ /* 1181 */ if ((index = iindexOf(this.onlineFriends, name)) != -1) { /* 1182 */ this.onlineFriends.removeElementAt(index); /* 1183 */ if (active == this) { /* 1184 */ repaint(); /* */ } /* */ } /* */ /* 1188 */ if ((index = iindexOf(this.mutedOnlineFriends, name)) != -1) { /* 1189 */ this.mutedOnlineFriends.removeElementAt(index); /* */ } /* */ /* 1192 */ this.serverUpdates.addElement(new BuddyListUpdateCmd(name, 0)); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public boolean mayAddNameListName(Window currentWindow) /* */ { /* 1202 */ if (this.friends.size() < maxFriends) /* 1203 */ return true; /* 1204 */ Object[] arguments = { new String(maxFriends) }; /* 1205 */ new OkCancelDialog(currentWindow, null, /* 1206 */ Console.message("Too-many-names"), null, Console.message("OK"), /* 1207 */ MessageFormat.format(Console.message("You-are-limitedF"), /* 1208 */ arguments), true); /* 1209 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public int addNameListName(String name) /* */ { /* 1219 */ synchronized (this.friendsMutex) /* */ { /* */ /* 1222 */ int index = iindexOf(this.friends, name); /* 1223 */ if (index != -1) { /* 1224 */ return index; /* */ } /* */ /* 1227 */ this.friends.addElement(name); /* 1228 */ Collections.sort(this.friends, this); /* 1229 */ saveFriends(); /* */ /* */ /* 1232 */ this.serverUpdates.addElement(new BuddyListUpdateCmd(name, 1)); /* 1233 */ return this.friends.size() - 1; /* */ } /* */ } /* */ /* */ public int compare(String arg0, String arg1) /* */ { /* 1239 */ return arg0.compareToIgnoreCase(arg1); /* */ } /* */ /* */ /* */ /* */ /* */ public static void droneClick(Drone who, MouseDownEvent event) /* */ { /* 1247 */ if (active != null) { /* 1248 */ active.instanceDroneClick(who, event); /* */ } /* */ } /* */ /* */ private void instanceDroneClick(Drone who, MouseDownEvent event) /* */ { /* 1254 */ String tmp = who.getLongID(); /* 1255 */ if (tmp != null) { /* 1256 */ this.activeFriendName = tmp; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 1265 */ Object[] arguments = { new String(this.activeFriendName) }; /* 1266 */ this.droneAddItem = new MenuItem(MessageFormat.format( /* 1267 */ Console.message("Add-to-friends"), arguments)); /* 1268 */ this.droneMenu.remove(0); /* 1269 */ this.droneAddItem.setFont(font); /* 1270 */ this.droneMenu.insert(this.droneAddItem, 0); /* */ /* */ /* */ /* 1274 */ this.droneAddItem.setEnabled(!icontains(this.friends, this.activeFriendName)); /* */ /* 1276 */ if (this.actionMenu != null) { /* 1277 */ this.droneMenu.remove(this.actionMenu); /* */ } /* */ /* 1280 */ if ((who instanceof PosableDrone)) { /* 1281 */ PosableDrone pd = (PosableDrone)who; /* 1282 */ PosableShape ps = pd.getInternalPosableShape(); /* 1283 */ if (ps != null) { /* 1284 */ this.actionMenu = new Menu(Console.message("Actions")); /* */ /* 1286 */ if (AnimatedActionManager.get().buildActionMenu(this.actionMenu, ps)) { /* 1287 */ this.droneMenu.add(this.actionMenu); /* 1288 */ this.actionMenu.addActionListener( /* 1289 */ AnimatedActionManager.get()); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 1305 */ this.droneMenu.show(this.console.getRender(), event.x, event.y); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static void processBuddyListNotify(WorldServer server, String name, int state) /* */ { /* 1336 */ Galaxy g = server.getGalaxy(); /* 1337 */ Enumeration consoleList = g.getConsoles(); /* 1338 */ while (consoleList.hasMoreElements()) { /* 1339 */ Object c = consoleList.nextElement(); /* 1340 */ if ((c instanceof DefaultConsole)) { /* 1341 */ FriendsListPart target = ((DefaultConsole)c).getFriends(); /* 1342 */ if (state < 2) { /* 1343 */ boolean muted = MuteListPart.isMuted(server, name); /* 1344 */ if (state == 1) { /* 1345 */ target.addOnlineFriend(name, muted); /* */ } else /* 1347 */ target.removeOnlineFriend(name, muted); /* */ } else { /* 1349 */ assert (name.length() == 0); /* 1350 */ target.clearAll(); /* */ } /* */ } /* */ } /* 1354 */ if (state == 2) /* */ { /* 1356 */ consoleList = g.getConsoles(); /* 1357 */ while (consoleList.hasMoreElements()) { /* 1358 */ Object c = consoleList.nextElement(); /* 1359 */ if ((c instanceof DefaultConsole)) { /* 1360 */ FriendsListPart target = ((DefaultConsole)c).getFriends(); /* 1361 */ target.sendAll(server); /* 1362 */ break; /* */ } /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ public static String ilookup(Vector v, String name) /* */ { /* 1373 */ int count = v.size(); /* 1374 */ for (int i = 0; i < count; i++) { /* 1375 */ String ele = (String)v.elementAt(i); /* 1376 */ if (ele.equalsIgnoreCase(name)) /* 1377 */ return ele; /* */ } /* 1379 */ return null; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public static int iindexOf(Vector v, String name) /* */ { /* 1388 */ int count = v.size(); /* 1389 */ for (int i = 0; i < count; i++) { /* 1390 */ String ele = (String)v.elementAt(i); /* 1391 */ if (ele.equalsIgnoreCase(name)) /* 1392 */ return i; /* */ } /* 1394 */ return -1; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public static boolean icontains(Vector v, String name) /* */ { /* 1403 */ return iindexOf(v, name) != -1; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void changeMuteState(String name, boolean muted) /* */ { /* 1414 */ synchronized (this.friendsMutex) { /* 1415 */ if (icontains(this.friends, name)) /* */ { /* */ /* */ /* 1419 */ if (muted) { /* 1420 */ name = ilookup(this.onlineFriends, name); /* 1421 */ if (name != null) { /* 1422 */ removeOnlineFriend(name, false); /* 1423 */ addOnlineFriend(name, true); /* */ } /* */ /* */ /* */ } /* */ else /* */ { /* 1430 */ name = ilookup(this.mutedOnlineFriends, name); /* 1431 */ if (name != null) { /* 1432 */ removeOnlineFriend(name, true); /* 1433 */ addOnlineFriend(name, false); /* */ } /* */ } /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ private void listChanged() /* */ { /* 1446 */ this.cursedButton = -1; /* 1447 */ this.clickedButton = -1; /* 1448 */ this.clickedButtonDown = false; /* 1449 */ repaint(); /* */ } /* */ /* */ private void addOnlineFriend(String name, boolean muted) /* */ { /* 1454 */ synchronized (this.friendsMutex) /* */ { /* */ /* */ /* 1458 */ if ((this.friends != null) && (icontains(this.friends, name))) /* */ { /* */ /* 1461 */ if ((!muted) && (!icontains(this.onlineFriends, name))) { /* 1462 */ this.onlineFriends.addElement(name); /* */ /* */ /* 1465 */ if (active == this) { /* 1466 */ listChanged(); /* 1467 */ if (this.moreFriendsDialog != null) { /* 1468 */ this.moreFriendsDialog.addName(name); /* */ } /* */ /* */ } /* */ /* */ /* */ } /* 1475 */ else if ((muted) && (!icontains(this.mutedOnlineFriends, name))) { /* 1476 */ this.mutedOnlineFriends.addElement(name); /* */ } /* */ } /* */ } /* */ } /* */ /* */ private void removeOnlineFriend(String name, boolean muted) /* */ { /* 1484 */ synchronized (this.friendsMutex) /* */ { /* */ /* 1487 */ if (!muted) { /* 1488 */ int index = this.onlineFriends.indexOf(name); /* 1489 */ if (index != -1) { /* 1490 */ this.onlineFriends.removeElementAt(index); /* */ /* */ /* 1493 */ if (active == this) { /* 1494 */ listChanged(); /* 1495 */ if (this.moreFriendsDialog != null) { /* 1496 */ this.moreFriendsDialog.removeName(index); /* */ } /* */ } /* */ } /* */ } /* */ else /* */ { /* 1503 */ this.mutedOnlineFriends.removeElement(name); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ public void dialogDone(Object who, boolean confirmed) /* */ { /* 1513 */ synchronized (this.friendsMutex) { /* 1514 */ if (who == this.moreFriendsDialog) { /* 1515 */ this.moreFriendsDialog = null; /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static boolean isValidUserName(String name) /* */ { /* 1528 */ String validChars = "_-"; /* 1529 */ name = Console.parseUnicode(name); /* */ /* 1531 */ int length = name.length(); /* 1532 */ if ((length >= 2) && (length <= 16)) { /* 1533 */ char[] nameChars = name.toCharArray(); /* 1534 */ for (int i = 0; i < length; i++) /* 1535 */ if ((!Character.isLetterOrDigit(nameChars[i])) && /* 1536 */ (validChars.indexOf(nameChars[i]) == -1)) /* 1537 */ return false; /* 1538 */ return true; /* */ } /* 1540 */ return false; /* */ } /* */ /* */ void moreFriendsAction(String name, MenuItem function) /* */ { /* 1545 */ this.activeFriendName = name; /* 1546 */ assert (this.activeFriendName != null); /* 1547 */ maybeFriendAction(function); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\FriendsListPart.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */