lotrointerface.com
Search Downloads

LoTROInterface SVN KragenBars

[/] [branches/] [3.21/] [UI/] [Tooltip.lua] - Blame information for rev 72

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 72 Kragenwar-3044
import "Turbine.UI";
2 Kragenwar-3044
 
3 Kragenwar-3044
Tooltip = class(Turbine.UI.Window);
4 Kragenwar-3044
 
5 Kragenwar-3044
-- colors
6 Kragenwar-3044
Tooltip.BackgroundColor = Turbine.UI.Color(.925, 0, 0, 0);
7 Kragenwar-3044
 
8 Kragenwar-3044
function Tooltip:Constructor()
9 Kragenwar-3044
    Turbine.UI.Window.Constructor(self);
10 Kragenwar-3044
    self:SetMouseVisible(false);
11 Kragenwar-3044
    self:SetVisible(false);
12 Kragenwar-3044
    self:SetZOrder(100);
13 Kragenwar-3044
 
14 Kragenwar-3044
    -- center
15 Kragenwar-3044
    self.center = Turbine.UI.Control();
16 Kragenwar-3044
    self.center:SetParent(self);
17 Kragenwar-3044
    self.center:SetBackColor(Tooltip.BackgroundColor);
18 Kragenwar-3044
 
19 Kragenwar-3044
    -- label
20 Kragenwar-3044
    self.label = KragenPlugs.UI.Label();
21 Kragenwar-3044
    self.label:SetParent(self);
22 Kragenwar-3044
    self.label:SetMultiline(true);
23 Kragenwar-3044
    self.label:SetFont(Turbine.UI.Lotro.Font.TrajanPro16);
24 Kragenwar-3044
    self.label:SetTextAlignment(Turbine.UI.ContentAlignment.TopLeft);
25 Kragenwar-3044
    self.label:SetBackColor(Tooltip.BackgroundColor);
26 Kragenwar-3044
 
27 Kragenwar-3044
    -- top left corner
28 Kragenwar-3044
    self.topLeft = Turbine.UI.Control();
29 Kragenwar-3044
    self.topLeft:SetParent(self);
30 Kragenwar-3044
    self.topLeft:SetSize(19, 19);
31 Kragenwar-3044
    self.topLeft:SetMouseVisible(false);
32 Kragenwar-3044
    self.topLeft:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend);
33 Kragenwar-3044
    self.topLeft:SetBackground("KragenPlugs/UI/Resources/basepanel_topleft.tga");
34 Kragenwar-3044
 
35 Kragenwar-3044
    -- topRight
36 Kragenwar-3044
    self.topRight = Turbine.UI.Control();
37 Kragenwar-3044
    self.topRight:SetParent(self);
38 Kragenwar-3044
    self.topRight:SetSize(19, 19);
39 Kragenwar-3044
    self.topRight:SetMouseVisible(false);
40 Kragenwar-3044
    self.topRight:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend);
41 Kragenwar-3044
    self.topRight:SetBackground("KragenPlugs/UI/Resources/basepanel_topright.tga");
42 Kragenwar-3044
 
43 Kragenwar-3044
    -- bottomLeft
44 Kragenwar-3044
    self.bottomLeft = Turbine.UI.Control();
45 Kragenwar-3044
    self.bottomLeft:SetParent(self);
46 Kragenwar-3044
    self.bottomLeft:SetSize(19, 19);
47 Kragenwar-3044
    self.bottomLeft:SetMouseVisible(false);
48 Kragenwar-3044
    self.bottomLeft:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend);
49 Kragenwar-3044
    self.bottomLeft:SetBackground("KragenPlugs/UI/Resources/basepanel_bottomleft.tga");
50 Kragenwar-3044
 
51 Kragenwar-3044
    -- bottomRight
52 Kragenwar-3044
    self.bottomRight = Turbine.UI.Control();
53 Kragenwar-3044
    self.bottomRight:SetParent(self);
54 Kragenwar-3044
    self.bottomRight:SetSize(19, 19);
55 Kragenwar-3044
    self.bottomRight:SetMouseVisible(false);
56 Kragenwar-3044
    self.bottomRight:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend);
57 Kragenwar-3044
    self.bottomRight:SetBackground("KragenPlugs/UI/Resources/basepanel_bottomright.tga");
58 Kragenwar-3044
 
59 Kragenwar-3044
    -- top side
60 Kragenwar-3044
    self.top = Turbine.UI.Control();
61 Kragenwar-3044
    self.top:SetParent(self);
62 Kragenwar-3044
    self.top:SetSize(0, 3);
63 Kragenwar-3044
    self.top:SetMouseVisible(false);
64 Kragenwar-3044
    self.top:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend);
65 Kragenwar-3044
    self.top:SetBackground("KragenPlugs/UI/Resources/basepanel_topmid.tga");
66 Kragenwar-3044
 
67 Kragenwar-3044
    -- left side
68 Kragenwar-3044
    self.left = Turbine.UI.Control();
69 Kragenwar-3044
    self.left:SetParent(self);
70 Kragenwar-3044
    self.left:SetSize(3, 0);
71 Kragenwar-3044
    self.left:SetMouseVisible(false);
72 Kragenwar-3044
    self.left:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend);
73 Kragenwar-3044
    self.left:SetBackground("KragenPlugs/UI/Resources/basepanel_midleft.tga");
74 Kragenwar-3044
 
75 Kragenwar-3044
    -- right side
76 Kragenwar-3044
    self.right = Turbine.UI.Control();
77 Kragenwar-3044
    self.right:SetParent(self);
78 Kragenwar-3044
    self.right:SetSize(3, 0);
79 Kragenwar-3044
    self.right:SetMouseVisible(false);
80 Kragenwar-3044
    self.right:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend);
81 Kragenwar-3044
    self.right:SetBackground("KragenPlugs/UI/Resources/basepanel_midright.tga");
82 Kragenwar-3044
 
83 Kragenwar-3044
    -- bottom side
84 Kragenwar-3044
    self.bottom = Turbine.UI.Control();
85 Kragenwar-3044
    self.bottom:SetParent(self);
86 Kragenwar-3044
    self.bottom:SetSize(0, 3);
87 Kragenwar-3044
    self.bottom:SetMouseVisible(false);
88 Kragenwar-3044
    self.bottom:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend);
89 Kragenwar-3044
    self.bottom:SetBackground("KragenPlugs/UI/Resources/basepanel_bottommid.tga");
90 Kragenwar-3044
end
91 Kragenwar-3044
 
92 Kragenwar-3044
function Tooltip:SetText(text)
93 Kragenwar-3044
    self.label:SetText(text);
94 Kragenwar-3044
end
95 Kragenwar-3044
 
96 Kragenwar-3044
function Tooltip:SetControl(control)
97 Kragenwar-3044
    self.control = control;
98 Kragenwar-3044
    -- once mouse hover works we can get rid of the timer and mouse enter
99 Kragenwar-3044
    self.timer = KragenPlugs.Utils.Timer(.450);
100 Kragenwar-3044
    self.timer.Signal = function(sender, args)
101 Kragenwar-3044
        KragenPlugs.Utils.ExecuteListener(self.control, "MouseHover", {});
102 Kragenwar-3044
    end
103 Kragenwar-3044
 
104 Kragenwar-3044
    KragenPlugs.Utils.AddListener(self.control, "MouseEnter", function(sender, args)
105 Kragenwar-3044
        self.timer:Start();
106 Kragenwar-3044
    end);
107 Kragenwar-3044
 
108 Kragenwar-3044
    KragenPlugs.Utils.AddListener(self.control, "MouseHover", function(sender, args)
109 Kragenwar-3044
        local x, y = Turbine.UI.Display.GetMousePosition();
110 Kragenwar-3044
        x = x + 32;
111 Kragenwar-3044
        y = y + 32;
112 Kragenwar-3044
        x, y = KragenPlugs.Utils.ValidatePosition(x, y, self:GetSize());
113 Kragenwar-3044
        self:SetPosition(x, y);
114 Kragenwar-3044
        self:SetVisible(true);
115 Kragenwar-3044
    end);
116 Kragenwar-3044
 
117 Kragenwar-3044
    KragenPlugs.Utils.AddListener(self.control, "MouseLeave", function(sender, args)
118 Kragenwar-3044
        self.timer:Stop();
119 Kragenwar-3044
        self:SetVisible(false);
120 Kragenwar-3044
    end);
121 Kragenwar-3044
end
122 Kragenwar-3044
 
123 Kragenwar-3044
function Tooltip:SetSize(width, height)
124 Kragenwar-3044
    -- turbine default tooltips are 480 in size
125 Kragenwar-3044
    width = math.max(width, 38);
126 Kragenwar-3044
    height = math.max(height, 22);
127 Kragenwar-3044
 
128 Kragenwar-3044
    Turbine.UI.Window.SetSize(self, width, height);
129 Kragenwar-3044
end
130 Kragenwar-3044
 
131 Kragenwar-3044
function Tooltip:SizeChanged(args)
132 Kragenwar-3044
    local width, height = self:GetSize();
133 Kragenwar-3044
 
134 Kragenwar-3044
    -- special case to prevent the shadows on the corners from overlapping
135 Kragenwar-3044
    if (height < 38) then
136 Kragenwar-3044
        self.topLeft:SetPosition(0, 0);
137 Kragenwar-3044
        self.top:SetPosition(19, 0);
138 Kragenwar-3044
        self.topRight:SetPosition(width - 19, 0);
139 Kragenwar-3044
        self.bottom:SetPosition(1, height - 3);
140 Kragenwar-3044
        self.left:SetPosition(0, 19);
141 Kragenwar-3044
        self.right:SetPosition(width - 3, 19);
142 Kragenwar-3044
        self.center:SetPosition(3, 3);
143 Kragenwar-3044
        self.label:SetPosition(7, 3);
144 Kragenwar-3044
 
145 Kragenwar-3044
        self.top:SetWidth(width - 38);
146 Kragenwar-3044
        self.bottom:SetWidth(width - 2);
147 Kragenwar-3044
        self.left:SetHeight(height - 22);
148 Kragenwar-3044
        self.right:SetHeight(height - 22);
149 Kragenwar-3044
        self.center:SetSize(width - 6, height - 6);
150 Kragenwar-3044
        self.label:SetSize(width - 14, height - 6);
151 Kragenwar-3044
        self.bottomLeft:SetSize(0, 0);
152 Kragenwar-3044
        self.bottomRight:SetSize(0, 0);
153 Kragenwar-3044
    else
154 Kragenwar-3044
        self.topLeft:SetPosition(0, 0);
155 Kragenwar-3044
        self.top:SetPosition(19, 0);
156 Kragenwar-3044
        self.topRight:SetPosition(width - 19, 0);
157 Kragenwar-3044
        self.bottomLeft:SetPosition(0, height - 19);
158 Kragenwar-3044
        self.bottom:SetPosition(19, height - 3);
159 Kragenwar-3044
        self.bottomRight:SetPosition(width - 19, height - 19);
160 Kragenwar-3044
        self.left:SetPosition(0, 19);
161 Kragenwar-3044
        self.right:SetPosition(width - 3, 19);
162 Kragenwar-3044
        self.center:SetPosition(3, 3);
163 Kragenwar-3044
        self.label:SetPosition(7, 3);
164 Kragenwar-3044
 
165 Kragenwar-3044
        self.top:SetWidth(width - 38);
166 Kragenwar-3044
        self.bottom:SetWidth(width - 38);
167 Kragenwar-3044
        self.left:SetHeight(height - 38);
168 Kragenwar-3044
        self.right:SetHeight(height - 38);
169 Kragenwar-3044
        self.center:SetSize(width - 6, height - 6);
170 Kragenwar-3044
        self.label:SetSize(width - 14, height - 6);
171 Kragenwar-3044
    end
172 Kragenwar-3044
end

All times are GMT -5. The time now is 05:29 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui