/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.DefaultConsole; /* */ import NET.worlds.console.MultiLineLabel; /* */ import NET.worlds.console.RenderCanvas; /* */ import NET.worlds.core.IniFile; /* */ import java.awt.Color; /* */ import java.awt.Font; /* */ import java.awt.Point; /* */ import java.awt.Window; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class ToolTipManager /* */ { /* 22 */ private static ToolTipManager manager_ = null; /* */ private static final int FRAME_DELAY = 15; /* */ private int savedX; /* */ private int savedY; /* */ private int savedLoops; /* */ private boolean toolTipActive; /* */ private WObject savedObject; /* */ private Window toolTipWindow; /* */ private MultiLineLabel toolTipTextArea; /* */ private Font toolTipFont; /* */ /* */ private ToolTipManager() /* */ { /* 35 */ this.savedX = (this.savedY = this.savedLoops = 0); /* 36 */ this.toolTipActive = false; /* 37 */ this.savedObject = null; /* */ /* */ /* 40 */ this.toolTipFont = new Font("Arial", 0, 10); /* 41 */ Console.getActive(); /* */ /* 43 */ this.toolTipWindow = new Window(Console.getFrame()); /* 44 */ this.toolTipTextArea = new MultiLineLabel(); /* 45 */ this.toolTipTextArea.setBackground(Color.yellow); /* 46 */ this.toolTipTextArea.setForeground(Color.black); /* 47 */ this.toolTipTextArea.setMarginWidth(2); /* 48 */ this.toolTipTextArea.setMarginHeight(2); /* 49 */ this.toolTipWindow.setFont(this.toolTipFont); /* 50 */ this.toolTipWindow.add(this.toolTipTextArea); /* */ } /* */ /* */ public static ToolTipManager toolTipManager() /* */ { /* 55 */ if (manager_ == null) /* */ { /* 57 */ manager_ = new ToolTipManager(); /* */ } /* */ /* 60 */ return manager_; /* */ } /* */ /* */ public void heartbeat() /* */ { /* 65 */ if (IniFile.gamma().getIniInt("DisableToolTips", 0) == 1) /* */ { /* */ /* 68 */ return; /* */ } /* */ /* 71 */ WObject obj = Camera.getMousePickWObject(); /* 72 */ int x = (int)Camera.getMousePickX(); /* 73 */ int y = (int)Camera.getMousePickY(); /* */ /* */ /* 76 */ if ((obj != null) && (x > 0) && (y > 0) && /* 77 */ (x == this.savedX) && (y == this.savedY) && (this.savedObject == obj)) /* */ { /* 79 */ this.savedLoops += 1; /* */ } /* */ else /* */ { /* 83 */ if (this.toolTipActive) /* */ { /* 85 */ removeToolTip(); /* 86 */ this.toolTipActive = false; /* */ } /* 88 */ this.savedLoops = 0; /* */ } /* */ /* 91 */ if ((!this.toolTipActive) && (obj != null) && /* 92 */ (this.savedLoops > 15)) /* */ { /* 94 */ this.toolTipActive = true; /* 95 */ if (obj != null) /* */ { /* 97 */ this.savedObject = obj; /* 98 */ if (obj.getToolTipText() != null) /* */ { /* 100 */ String oldText = obj.getToolTipText(); /* 101 */ String newText = oldText.replace('|', '\n'); /* 102 */ createToolTip(this.savedX, this.savedY, newText); /* */ } /* */ } /* */ } /* */ /* 107 */ this.savedX = x; /* 108 */ this.savedY = y; /* 109 */ this.savedObject = obj; /* */ } /* */ /* */ void createToolTip(int winX, int winY, String text) /* */ { /* 114 */ int baseX = ((DefaultConsole)Console.getActive()).getRender().getLocationOnScreen().x; /* 115 */ int baseY = ((DefaultConsole)Console.getActive()).getRender().getLocationOnScreen().y; /* 116 */ int offsetX = 16; /* 117 */ int offsetY = 16; /* */ /* 119 */ this.toolTipWindow.setLocation(winX + baseX + offsetX, winY + baseY + offsetY); /* 120 */ this.toolTipTextArea.setLabel(text); /* 121 */ this.toolTipWindow.setSize(this.toolTipTextArea.getPreferredSize()); /* 122 */ this.toolTipWindow.setEnabled(false); /* 123 */ this.toolTipWindow.setVisible(true); /* */ } /* */ /* */ /* */ public void removeToolTip() /* */ { /* 129 */ this.toolTipWindow.setVisible(false); /* */ } /* */ /* */ public void killToolTip() /* */ { /* 134 */ this.savedLoops = 0; /* 135 */ this.toolTipWindow.setVisible(false); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\ToolTipManager.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */