|
Tercio@11
|
1
|
|
Tercio@11
|
2 local DF = _G ["DetailsFramework"]
|
|
Tercio@20
|
3 if (not DF or not DetailsFrameworkCanLoad) then
|
|
Tercio@18
|
4 return
|
|
Tercio@18
|
5 end
|
|
Tercio@18
|
6
|
|
Tercio@20
|
7 local _
|
|
Tercio@11
|
8 --> lua locals
|
|
Tercio@11
|
9 local _rawset = rawset --> lua local
|
|
Tercio@11
|
10 local _rawget = rawget --> lua local
|
|
Tercio@11
|
11 local _setmetatable = setmetatable --> lua local
|
|
Tercio@11
|
12 local _unpack = unpack --> lua local
|
|
Tercio@11
|
13 local _type = type --> lua local
|
|
Tercio@11
|
14 local _math_floor = math.floor --> lua local
|
|
Tercio@11
|
15 local loadstring = loadstring --> lua local
|
|
Tercio@11
|
16
|
|
Tercio@11
|
17 local cleanfunction = function() end
|
|
Tercio@11
|
18 local APIFrameFunctions
|
|
Tercio@11
|
19
|
|
Tercio@39
|
20 do
|
|
Tercio@39
|
21 local metaPrototype = {
|
|
Tercio@39
|
22 WidgetType = "panel",
|
|
Tercio@39
|
23 SetHook = DF.SetHook,
|
|
Tercio@39
|
24 RunHooksForWidget = DF.RunHooksForWidget,
|
|
Tercio@39
|
25 }
|
|
Tercio@39
|
26
|
|
Tercio@39
|
27 _G [DF.GlobalWidgetControlNames ["panel"]] = _G [DF.GlobalWidgetControlNames ["panel"]] or metaPrototype
|
|
Tercio@39
|
28 end
|
|
Tercio@39
|
29
|
|
Tercio@39
|
30 local PanelMetaFunctions = _G [DF.GlobalWidgetControlNames ["panel"]]
|
|
Tercio@39
|
31
|
|
Tercio@11
|
32 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
33 --> metatables
|
|
Tercio@11
|
34
|
|
Tercio@11
|
35 PanelMetaFunctions.__call = function (_table, value)
|
|
Tercio@11
|
36 --> nothing to do
|
|
Tercio@11
|
37 return true
|
|
Tercio@11
|
38 end
|
|
Tercio@11
|
39
|
|
Tercio@11
|
40 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
41 --> members
|
|
Tercio@11
|
42
|
|
Tercio@11
|
43 --> tooltip
|
|
Tercio@11
|
44 local gmember_tooltip = function (_object)
|
|
Tercio@11
|
45 return _object:GetTooltip()
|
|
Tercio@11
|
46 end
|
|
Tercio@11
|
47 --> shown
|
|
Tercio@11
|
48 local gmember_shown = function (_object)
|
|
Tercio@11
|
49 return _object:IsShown()
|
|
Tercio@11
|
50 end
|
|
Tercio@11
|
51 --> backdrop color
|
|
Tercio@11
|
52 local gmember_color = function (_object)
|
|
Tercio@11
|
53 return _object.frame:GetBackdropColor()
|
|
Tercio@11
|
54 end
|
|
Tercio@11
|
55 --> backdrop table
|
|
Tercio@11
|
56 local gmember_backdrop = function (_object)
|
|
Tercio@11
|
57 return _object.frame:GetBackdrop()
|
|
Tercio@11
|
58 end
|
|
Tercio@11
|
59 --> frame width
|
|
Tercio@11
|
60 local gmember_width = function (_object)
|
|
Tercio@11
|
61 return _object.frame:GetWidth()
|
|
Tercio@11
|
62 end
|
|
Tercio@11
|
63 --> frame height
|
|
Tercio@11
|
64 local gmember_height = function (_object)
|
|
Tercio@11
|
65 return _object.frame:GetHeight()
|
|
Tercio@11
|
66 end
|
|
Tercio@11
|
67 --> locked
|
|
Tercio@11
|
68 local gmember_locked = function (_object)
|
|
Tercio@11
|
69 return _rawget (_object, "is_locked")
|
|
Tercio@11
|
70 end
|
|
Tercio@11
|
71
|
|
Tercio@39
|
72 PanelMetaFunctions.GetMembers = PanelMetaFunctions.GetMembers or {}
|
|
Tercio@39
|
73 PanelMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
|
|
Tercio@39
|
74 PanelMetaFunctions.GetMembers ["shown"] = gmember_shown
|
|
Tercio@39
|
75 PanelMetaFunctions.GetMembers ["color"] = gmember_color
|
|
Tercio@39
|
76 PanelMetaFunctions.GetMembers ["backdrop"] = gmember_backdrop
|
|
Tercio@39
|
77 PanelMetaFunctions.GetMembers ["width"] = gmember_width
|
|
Tercio@39
|
78 PanelMetaFunctions.GetMembers ["height"] = gmember_height
|
|
Tercio@39
|
79 PanelMetaFunctions.GetMembers ["locked"] = gmember_locked
|
|
Tercio@11
|
80
|
|
Tercio@11
|
81 PanelMetaFunctions.__index = function (_table, _member_requested)
|
|
Tercio@11
|
82
|
|
Tercio@39
|
83 local func = PanelMetaFunctions.GetMembers [_member_requested]
|
|
Tercio@11
|
84 if (func) then
|
|
Tercio@11
|
85 return func (_table, _member_requested)
|
|
Tercio@11
|
86 end
|
|
Tercio@11
|
87
|
|
Tercio@11
|
88 local fromMe = _rawget (_table, _member_requested)
|
|
Tercio@11
|
89 if (fromMe) then
|
|
Tercio@11
|
90 return fromMe
|
|
Tercio@11
|
91 end
|
|
Tercio@11
|
92
|
|
Tercio@11
|
93 return PanelMetaFunctions [_member_requested]
|
|
Tercio@11
|
94 end
|
|
Tercio@11
|
95
|
|
Tercio@11
|
96
|
|
Tercio@11
|
97 --> tooltip
|
|
Tercio@11
|
98 local smember_tooltip = function (_object, _value)
|
|
Tercio@11
|
99 return _object:SetTooltip (_value)
|
|
Tercio@11
|
100 end
|
|
Tercio@11
|
101 --> show
|
|
Tercio@11
|
102 local smember_show = function (_object, _value)
|
|
Tercio@11
|
103 if (_value) then
|
|
Tercio@11
|
104 return _object:Show()
|
|
Tercio@11
|
105 else
|
|
Tercio@11
|
106 return _object:Hide()
|
|
Tercio@11
|
107 end
|
|
Tercio@11
|
108 end
|
|
Tercio@11
|
109 --> hide
|
|
Tercio@11
|
110 local smember_hide = function (_object, _value)
|
|
Tercio@11
|
111 if (not _value) then
|
|
Tercio@11
|
112 return _object:Show()
|
|
Tercio@11
|
113 else
|
|
Tercio@11
|
114 return _object:Hide()
|
|
Tercio@11
|
115 end
|
|
Tercio@11
|
116 end
|
|
Tercio@11
|
117 --> backdrop color
|
|
Tercio@11
|
118 local smember_color = function (_object, _value)
|
|
Tercio@11
|
119 local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
|
|
Tercio@11
|
120 return _object:SetBackdropColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
121 end
|
|
Tercio@11
|
122 --> frame width
|
|
Tercio@11
|
123 local smember_width = function (_object, _value)
|
|
Tercio@11
|
124 return _object.frame:SetWidth (_value)
|
|
Tercio@11
|
125 end
|
|
Tercio@11
|
126 --> frame height
|
|
Tercio@11
|
127 local smember_height = function (_object, _value)
|
|
Tercio@11
|
128 return _object.frame:SetHeight (_value)
|
|
Tercio@11
|
129 end
|
|
Tercio@11
|
130
|
|
Tercio@11
|
131 --> locked
|
|
Tercio@11
|
132 local smember_locked = function (_object, _value)
|
|
Tercio@11
|
133 if (_value) then
|
|
Tercio@11
|
134 _object.frame:SetMovable (false)
|
|
Tercio@11
|
135 return _rawset (_object, "is_locked", true)
|
|
Tercio@11
|
136 else
|
|
Tercio@11
|
137 _object.frame:SetMovable (true)
|
|
Tercio@11
|
138 _rawset (_object, "is_locked", false)
|
|
Tercio@11
|
139 return
|
|
Tercio@11
|
140 end
|
|
Tercio@11
|
141 end
|
|
Tercio@11
|
142
|
|
Tercio@11
|
143 --> backdrop
|
|
Tercio@11
|
144 local smember_backdrop = function (_object, _value)
|
|
Tercio@11
|
145 return _object.frame:SetBackdrop (_value)
|
|
Tercio@11
|
146 end
|
|
Tercio@11
|
147
|
|
Tercio@11
|
148 --> close with right button
|
|
Tercio@11
|
149 local smember_right_close = function (_object, _value)
|
|
Tercio@11
|
150 return _rawset (_object, "rightButtonClose", _value)
|
|
Tercio@11
|
151 end
|
|
Tercio@11
|
152
|
|
Tercio@39
|
153 PanelMetaFunctions.SetMembers = PanelMetaFunctions.SetMembers or {}
|
|
Tercio@39
|
154 PanelMetaFunctions.SetMembers["tooltip"] = smember_tooltip
|
|
Tercio@39
|
155 PanelMetaFunctions.SetMembers["show"] = smember_show
|
|
Tercio@39
|
156 PanelMetaFunctions.SetMembers["hide"] = smember_hide
|
|
Tercio@39
|
157 PanelMetaFunctions.SetMembers["color"] = smember_color
|
|
Tercio@39
|
158 PanelMetaFunctions.SetMembers["backdrop"] = smember_backdrop
|
|
Tercio@39
|
159 PanelMetaFunctions.SetMembers["width"] = smember_width
|
|
Tercio@39
|
160 PanelMetaFunctions.SetMembers["height"] = smember_height
|
|
Tercio@39
|
161 PanelMetaFunctions.SetMembers["locked"] = smember_locked
|
|
Tercio@39
|
162 PanelMetaFunctions.SetMembers["close_with_right"] = smember_right_close
|
|
Tercio@39
|
163
|
|
Tercio@11
|
164 PanelMetaFunctions.__newindex = function (_table, _key, _value)
|
|
Tercio@39
|
165 local func = PanelMetaFunctions.SetMembers [_key]
|
|
Tercio@11
|
166 if (func) then
|
|
Tercio@11
|
167 return func (_table, _value)
|
|
Tercio@11
|
168 else
|
|
Tercio@11
|
169 return _rawset (_table, _key, _value)
|
|
Tercio@11
|
170 end
|
|
Tercio@11
|
171 end
|
|
Tercio@11
|
172
|
|
Tercio@11
|
173 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
174 --> methods
|
|
Tercio@11
|
175
|
|
Tercio@11
|
176 --> right click to close
|
|
Tercio@11
|
177 function PanelMetaFunctions:CreateRightClickLabel (textType, w, h, close_text)
|
|
Tercio@11
|
178 local text
|
|
Tercio@11
|
179 w = w or 20
|
|
Tercio@11
|
180 h = h or 20
|
|
Tercio@11
|
181
|
|
Tercio@11
|
182 if (close_text) then
|
|
Tercio@11
|
183 text = close_text
|
|
Tercio@11
|
184 else
|
|
Tercio@11
|
185 if (textType) then
|
|
Tercio@11
|
186 textType = string.lower (textType)
|
|
Tercio@11
|
187 if (textType == "short") then
|
|
Tercio@11
|
188 text = "close window"
|
|
Tercio@11
|
189 elseif (textType == "medium") then
|
|
Tercio@11
|
190 text = "close window"
|
|
Tercio@11
|
191 elseif (textType == "large") then
|
|
Tercio@11
|
192 text = "close window"
|
|
Tercio@11
|
193 end
|
|
Tercio@11
|
194 else
|
|
Tercio@11
|
195 text = "close window"
|
|
Tercio@11
|
196 end
|
|
Tercio@11
|
197 end
|
|
Tercio@11
|
198
|
|
Tercio@11
|
199 return DF:NewLabel (self, _, "$parentRightMouseToClose", nil, "|TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:"..w..":"..h..":0:1:512:512:8:70:328:409|t " .. text)
|
|
Tercio@11
|
200 end
|
|
Tercio@11
|
201
|
|
Tercio@11
|
202 --> show & hide
|
|
Tercio@11
|
203 function PanelMetaFunctions:Show()
|
|
Tercio@11
|
204 self.frame:Show()
|
|
Tercio@11
|
205
|
|
Tercio@11
|
206 end
|
|
Tercio@11
|
207 function PanelMetaFunctions:Hide()
|
|
Tercio@11
|
208 self.frame:Hide()
|
|
Tercio@11
|
209
|
|
Tercio@11
|
210 end
|
|
Tercio@11
|
211
|
|
Tercio@11
|
212 -- setpoint
|
|
Tercio@11
|
213 function PanelMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
214 v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
|
|
Tercio@11
|
215 if (not v1) then
|
|
Tercio@11
|
216 print ("Invalid parameter for SetPoint")
|
|
Tercio@11
|
217 return
|
|
Tercio@11
|
218 end
|
|
Tercio@11
|
219 return self.widget:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
220 end
|
|
Tercio@11
|
221
|
|
Tercio@11
|
222 -- sizes
|
|
Tercio@11
|
223 function PanelMetaFunctions:SetSize (w, h)
|
|
Tercio@11
|
224 if (w) then
|
|
Tercio@11
|
225 self.frame:SetWidth (w)
|
|
Tercio@11
|
226 end
|
|
Tercio@11
|
227 if (h) then
|
|
Tercio@11
|
228 self.frame:SetHeight (h)
|
|
Tercio@11
|
229 end
|
|
Tercio@11
|
230 end
|
|
Tercio@11
|
231
|
|
Tercio@11
|
232 -- clear
|
|
Tercio@11
|
233 function PanelMetaFunctions:HideWidgets()
|
|
Tercio@11
|
234 for widgetName, widgetSelf in pairs (self) do
|
|
Tercio@11
|
235 if (type (widgetSelf) == "table" and widgetSelf.dframework) then
|
|
Tercio@11
|
236 widgetSelf:Hide()
|
|
Tercio@11
|
237 end
|
|
Tercio@11
|
238 end
|
|
Tercio@11
|
239 end
|
|
Tercio@11
|
240
|
|
Tercio@11
|
241 -- backdrop
|
|
Tercio@11
|
242 function PanelMetaFunctions:SetBackdrop (background, edge, tilesize, edgesize, tile, left, right, top, bottom)
|
|
Tercio@11
|
243
|
|
Tercio@11
|
244 if (_type (background) == "boolean" and not background) then
|
|
Tercio@11
|
245 return self.frame:SetBackdrop (nil)
|
|
Tercio@11
|
246
|
|
Tercio@11
|
247 elseif (_type (background) == "table") then
|
|
Tercio@11
|
248 self.frame:SetBackdrop (background)
|
|
Tercio@11
|
249
|
|
Tercio@11
|
250 else
|
|
Tercio@11
|
251 local currentBackdrop = self.frame:GetBackdrop() or {edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", tile=true, tileSize=16, edgeSize=16, insets={left=1, right=0, top=0, bottom=0}}
|
|
Tercio@11
|
252 currentBackdrop.bgFile = background or currentBackdrop.bgFile
|
|
Tercio@11
|
253 currentBackdrop.edgeFile = edgeFile or currentBackdrop.edgeFile
|
|
Tercio@11
|
254 currentBackdrop.tileSize = tilesize or currentBackdrop.tileSize
|
|
Tercio@11
|
255 currentBackdrop.edgeSize = edgesize or currentBackdrop.edgeSize
|
|
Tercio@11
|
256 currentBackdrop.tile = tile or currentBackdrop.tile
|
|
Tercio@11
|
257 currentBackdrop.insets.left = left or currentBackdrop.insets.left
|
|
Tercio@11
|
258 currentBackdrop.insets.right = left or currentBackdrop.insets.right
|
|
Tercio@11
|
259 currentBackdrop.insets.top = left or currentBackdrop.insets.top
|
|
Tercio@11
|
260 currentBackdrop.insets.bottom = left or currentBackdrop.insets.bottom
|
|
Tercio@11
|
261 self.frame:SetBackdrop (currentBackdrop)
|
|
Tercio@11
|
262 end
|
|
Tercio@11
|
263 end
|
|
Tercio@11
|
264
|
|
Tercio@11
|
265 -- backdropcolor
|
|
Tercio@11
|
266 function PanelMetaFunctions:SetBackdropColor (color, arg2, arg3, arg4)
|
|
Tercio@11
|
267 if (arg2) then
|
|
Tercio@11
|
268 self.frame:SetBackdropColor (color, arg2, arg3, arg4 or 1)
|
|
Tercio@11
|
269 else
|
|
Tercio@11
|
270 local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
|
|
Tercio@11
|
271 self.frame:SetBackdropColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
272 end
|
|
Tercio@11
|
273 end
|
|
Tercio@11
|
274
|
|
Tercio@11
|
275 -- border color
|
|
Tercio@11
|
276 function PanelMetaFunctions:SetBackdropBorderColor (color, arg2, arg3, arg4)
|
|
Tercio@11
|
277 if (arg2) then
|
|
Tercio@11
|
278 return self.frame:SetBackdropBorderColor (color, arg2, arg3, arg4)
|
|
Tercio@11
|
279 end
|
|
Tercio@11
|
280 local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
|
|
Tercio@11
|
281 self.frame:SetBackdropBorderColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
282 end
|
|
Tercio@11
|
283
|
|
Tercio@11
|
284 -- tooltip
|
|
Tercio@11
|
285 function PanelMetaFunctions:SetTooltip (tooltip)
|
|
Tercio@11
|
286 if (tooltip) then
|
|
Tercio@11
|
287 return _rawset (self, "have_tooltip", tooltip)
|
|
Tercio@11
|
288 else
|
|
Tercio@11
|
289 return _rawset (self, "have_tooltip", nil)
|
|
Tercio@11
|
290 end
|
|
Tercio@11
|
291 end
|
|
Tercio@11
|
292 function PanelMetaFunctions:GetTooltip()
|
|
Tercio@11
|
293 return _rawget (self, "have_tooltip")
|
|
Tercio@11
|
294 end
|
|
Tercio@11
|
295
|
|
Tercio@11
|
296 -- frame levels
|
|
Tercio@11
|
297 function PanelMetaFunctions:GetFrameLevel()
|
|
Tercio@11
|
298 return self.widget:GetFrameLevel()
|
|
Tercio@11
|
299 end
|
|
Tercio@11
|
300 function PanelMetaFunctions:SetFrameLevel (level, frame)
|
|
Tercio@11
|
301 if (not frame) then
|
|
Tercio@11
|
302 return self.widget:SetFrameLevel (level)
|
|
Tercio@11
|
303 else
|
|
Tercio@11
|
304 local framelevel = frame:GetFrameLevel (frame) + level
|
|
Tercio@11
|
305 return self.widget:SetFrameLevel (framelevel)
|
|
Tercio@11
|
306 end
|
|
Tercio@11
|
307 end
|
|
Tercio@11
|
308
|
|
Tercio@11
|
309 -- frame stratas
|
|
Tercio@11
|
310 function PanelMetaFunctions:SetFrameStrata()
|
|
Tercio@11
|
311 return self.widget:GetFrameStrata()
|
|
Tercio@11
|
312 end
|
|
Tercio@11
|
313 function PanelMetaFunctions:SetFrameStrata (strata)
|
|
Tercio@11
|
314 if (_type (strata) == "table") then
|
|
Tercio@11
|
315 self.widget:SetFrameStrata (strata:GetFrameStrata())
|
|
Tercio@11
|
316 else
|
|
Tercio@11
|
317 self.widget:SetFrameStrata (strata)
|
|
Tercio@11
|
318 end
|
|
Tercio@11
|
319 end
|
|
Tercio@11
|
320
|
|
Tercio@11
|
321 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
322 --> scripts
|
|
Tercio@11
|
323
|
|
Tercio@11
|
324 local OnEnter = function (frame)
|
|
Tercio@39
|
325 local capsule = frame.MyObject
|
|
Tercio@39
|
326 local kill = capsule:RunHooksForWidget ("OnEnter", frame, capsule)
|
|
Tercio@39
|
327 if (kill) then
|
|
Tercio@39
|
328 return
|
|
Tercio@11
|
329 end
|
|
Tercio@11
|
330
|
|
Tercio@11
|
331 if (frame.MyObject.have_tooltip) then
|
|
Tercio@11
|
332 GameCooltip2:Reset()
|
|
Tercio@11
|
333 GameCooltip2:SetType ("tooltip")
|
|
Tercio@11
|
334 GameCooltip2:SetColor ("main", "transparent")
|
|
Tercio@11
|
335 GameCooltip2:AddLine (frame.MyObject.have_tooltip)
|
|
Tercio@11
|
336 GameCooltip2:SetOwner (frame)
|
|
Tercio@11
|
337 GameCooltip2:ShowCooltip()
|
|
Tercio@11
|
338 end
|
|
Tercio@11
|
339 end
|
|
Tercio@11
|
340
|
|
Tercio@11
|
341 local OnLeave = function (frame)
|
|
Tercio@39
|
342 local capsule = frame.MyObject
|
|
Tercio@39
|
343 local kill = capsule:RunHooksForWidget ("OnLeave", frame, capsule)
|
|
Tercio@39
|
344 if (kill) then
|
|
Tercio@39
|
345 return
|
|
Tercio@11
|
346 end
|
|
Tercio@11
|
347
|
|
Tercio@11
|
348 if (frame.MyObject.have_tooltip) then
|
|
Tercio@11
|
349 GameCooltip2:ShowMe (false)
|
|
Tercio@11
|
350 end
|
|
Tercio@11
|
351
|
|
Tercio@11
|
352 end
|
|
Tercio@11
|
353
|
|
Tercio@11
|
354 local OnHide = function (frame)
|
|
Tercio@39
|
355 local capsule = frame.MyObject
|
|
Tercio@39
|
356 local kill = capsule:RunHooksForWidget ("OnHide", frame, capsule)
|
|
Tercio@39
|
357 if (kill) then
|
|
Tercio@39
|
358 return
|
|
Tercio@11
|
359 end
|
|
Tercio@11
|
360 end
|
|
Tercio@11
|
361
|
|
Tercio@11
|
362 local OnShow = function (frame)
|
|
Tercio@39
|
363 local capsule = frame.MyObject
|
|
Tercio@39
|
364 local kill = capsule:RunHooksForWidget ("OnShow", frame, capsule)
|
|
Tercio@39
|
365 if (kill) then
|
|
Tercio@39
|
366 return
|
|
Tercio@11
|
367 end
|
|
Tercio@11
|
368 end
|
|
Tercio@11
|
369
|
|
Tercio@11
|
370 local OnMouseDown = function (frame, button)
|
|
Tercio@39
|
371 local capsule = frame.MyObject
|
|
Tercio@39
|
372 local kill = capsule:RunHooksForWidget ("OnMouseDown", frame, button, capsule)
|
|
Tercio@39
|
373 if (kill) then
|
|
Tercio@39
|
374 return
|
|
Tercio@11
|
375 end
|
|
Tercio@11
|
376
|
|
Tercio@11
|
377 if (frame.MyObject.container == UIParent) then
|
|
Tercio@11
|
378 if (not frame.isLocked and frame:IsMovable()) then
|
|
Tercio@11
|
379 frame.isMoving = true
|
|
Tercio@11
|
380 frame:StartMoving()
|
|
Tercio@11
|
381 end
|
|
Tercio@11
|
382
|
|
Tercio@11
|
383 elseif (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
|
|
Tercio@11
|
384 if (not frame.isLocked and frame:IsMovable()) then
|
|
Tercio@11
|
385 frame.MyObject.container.isMoving = true
|
|
Tercio@11
|
386 frame.MyObject.container:StartMoving()
|
|
Tercio@11
|
387 end
|
|
Tercio@11
|
388 end
|
|
Tercio@11
|
389
|
|
Tercio@11
|
390
|
|
Tercio@11
|
391 end
|
|
Tercio@11
|
392
|
|
Tercio@11
|
393 local OnMouseUp = function (frame, button)
|
|
Tercio@39
|
394 local capsule = frame.MyObject
|
|
Tercio@39
|
395 local kill = capsule:RunHooksForWidget ("OnMouseUp", frame, button, capsule)
|
|
Tercio@39
|
396 if (kill) then
|
|
Tercio@39
|
397 return
|
|
Tercio@11
|
398 end
|
|
Tercio@11
|
399
|
|
Tercio@11
|
400 if (button == "RightButton" and frame.MyObject.rightButtonClose) then
|
|
Tercio@11
|
401 frame.MyObject:Hide()
|
|
Tercio@11
|
402 end
|
|
Tercio@11
|
403
|
|
Tercio@11
|
404 if (frame.MyObject.container == UIParent) then
|
|
Tercio@11
|
405 if (frame.isMoving) then
|
|
Tercio@11
|
406 frame:StopMovingOrSizing()
|
|
Tercio@11
|
407 frame.isMoving = false
|
|
Tercio@11
|
408 end
|
|
Tercio@11
|
409 else
|
|
Tercio@11
|
410 if (frame.MyObject.container.isMoving) then
|
|
Tercio@11
|
411 frame.MyObject.container:StopMovingOrSizing()
|
|
Tercio@11
|
412 frame.MyObject.container.isMoving = false
|
|
Tercio@11
|
413 end
|
|
Tercio@11
|
414 end
|
|
Tercio@11
|
415 end
|
|
Tercio@11
|
416
|
|
Tercio@11
|
417 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
418 --> object constructor
|
|
Tercio@11
|
419 function DF:CreatePanel (parent, w, h, backdrop, backdropcolor, bordercolor, member, name)
|
|
Tercio@11
|
420 return DF:NewPanel (parent, parent, name, member, w, h, backdrop, backdropcolor, bordercolor)
|
|
Tercio@11
|
421 end
|
|
Tercio@11
|
422
|
|
Tercio@11
|
423 function DF:NewPanel (parent, container, name, member, w, h, backdrop, backdropcolor, bordercolor)
|
|
Tercio@11
|
424
|
|
Tercio@11
|
425 if (not name) then
|
|
Tercio@11
|
426 name = "DetailsFrameworkPanelNumber" .. DF.PanelCounter
|
|
Tercio@11
|
427 DF.PanelCounter = DF.PanelCounter + 1
|
|
Tercio@11
|
428
|
|
Tercio@11
|
429 elseif (not parent) then
|
|
Tercio@11
|
430 parent = UIParent
|
|
Tercio@11
|
431 end
|
|
Tercio@11
|
432 if (not container) then
|
|
Tercio@11
|
433 container = parent
|
|
Tercio@11
|
434 end
|
|
Tercio@11
|
435
|
|
Tercio@11
|
436 if (name:find ("$parent")) then
|
|
Tercio@11
|
437 name = name:gsub ("$parent", parent:GetName())
|
|
Tercio@11
|
438 end
|
|
Tercio@11
|
439
|
|
Tercio@11
|
440 local PanelObject = {type = "panel", dframework = true}
|
|
Tercio@11
|
441
|
|
Tercio@11
|
442 if (member) then
|
|
Tercio@11
|
443 parent [member] = PanelObject
|
|
Tercio@11
|
444 end
|
|
Tercio@11
|
445
|
|
Tercio@11
|
446 if (parent.dframework) then
|
|
Tercio@11
|
447 parent = parent.widget
|
|
Tercio@11
|
448 end
|
|
Tercio@11
|
449 if (container.dframework) then
|
|
Tercio@11
|
450 container = container.widget
|
|
Tercio@11
|
451 end
|
|
Tercio@11
|
452
|
|
Tercio@11
|
453 --> default members:
|
|
Tercio@11
|
454 --> misc
|
|
Tercio@11
|
455 PanelObject.is_locked = true
|
|
Tercio@11
|
456 PanelObject.container = container
|
|
Tercio@11
|
457 PanelObject.rightButtonClose = false
|
|
Tercio@11
|
458
|
|
Tercio@11
|
459 PanelObject.frame = CreateFrame ("frame", name, parent, "DetailsFrameworkPanelTemplate")
|
|
Tercio@11
|
460 PanelObject.widget = PanelObject.frame
|
|
Tercio@11
|
461
|
|
Tercio@11
|
462 if (not APIFrameFunctions) then
|
|
Tercio@11
|
463 APIFrameFunctions = {}
|
|
Tercio@11
|
464 local idx = getmetatable (PanelObject.frame).__index
|
|
Tercio@11
|
465 for funcName, funcAddress in pairs (idx) do
|
|
Tercio@11
|
466 if (not PanelMetaFunctions [funcName]) then
|
|
Tercio@11
|
467 PanelMetaFunctions [funcName] = function (object, ...)
|
|
Tercio@20
|
468 local x = loadstring ( "return _G['"..object.frame:GetName().."']:"..funcName.."(...)")
|
|
Tercio@11
|
469 return x (...)
|
|
Tercio@11
|
470 end
|
|
Tercio@11
|
471 end
|
|
Tercio@11
|
472 end
|
|
Tercio@11
|
473 end
|
|
Tercio@11
|
474
|
|
Tercio@11
|
475 PanelObject.frame:SetWidth (w or 100)
|
|
Tercio@11
|
476 PanelObject.frame:SetHeight (h or 100)
|
|
Tercio@11
|
477
|
|
Tercio@11
|
478 PanelObject.frame.MyObject = PanelObject
|
|
Tercio@11
|
479
|
|
Tercio@39
|
480 PanelObject.HookList = {
|
|
Tercio@39
|
481 OnEnter = {},
|
|
Tercio@39
|
482 OnLeave = {},
|
|
Tercio@39
|
483 OnHide = {},
|
|
Tercio@39
|
484 OnShow = {},
|
|
Tercio@39
|
485 OnMouseDown = {},
|
|
Tercio@39
|
486 OnMouseUp = {},
|
|
Tercio@39
|
487 }
|
|
Tercio@39
|
488
|
|
Tercio@11
|
489 --> hooks
|
|
Tercio@11
|
490 PanelObject.frame:SetScript ("OnEnter", OnEnter)
|
|
Tercio@11
|
491 PanelObject.frame:SetScript ("OnLeave", OnLeave)
|
|
Tercio@11
|
492 PanelObject.frame:SetScript ("OnHide", OnHide)
|
|
Tercio@11
|
493 PanelObject.frame:SetScript ("OnShow", OnShow)
|
|
Tercio@11
|
494 PanelObject.frame:SetScript ("OnMouseDown", OnMouseDown)
|
|
Tercio@11
|
495 PanelObject.frame:SetScript ("OnMouseUp", OnMouseUp)
|
|
Tercio@11
|
496
|
|
Tercio@11
|
497 _setmetatable (PanelObject, PanelMetaFunctions)
|
|
Tercio@11
|
498
|
|
Tercio@11
|
499 if (backdrop) then
|
|
Tercio@11
|
500 PanelObject:SetBackdrop (backdrop)
|
|
Tercio@11
|
501 elseif (_type (backdrop) == "boolean") then
|
|
Tercio@11
|
502 PanelObject.frame:SetBackdrop (nil)
|
|
Tercio@11
|
503 end
|
|
Tercio@11
|
504
|
|
Tercio@11
|
505 if (backdropcolor) then
|
|
Tercio@11
|
506 PanelObject:SetBackdropColor (backdropcolor)
|
|
Tercio@11
|
507 end
|
|
Tercio@11
|
508
|
|
Tercio@11
|
509 if (bordercolor) then
|
|
Tercio@11
|
510 PanelObject:SetBackdropBorderColor (bordercolor)
|
|
Tercio@11
|
511 end
|
|
Tercio@11
|
512
|
|
Tercio@11
|
513 return PanelObject
|
|
Tercio@11
|
514 end
|
|
Tercio@11
|
515
|
|
Tercio@11
|
516 ------------fill panel
|
|
Tercio@11
|
517
|
|
Tercio@11
|
518 local button_on_enter = function (self)
|
|
Tercio@11
|
519 self.MyObject._icon:SetBlendMode ("ADD")
|
|
Tercio@49
|
520 if (self.MyObject.onenter_func) then
|
|
Tercio@49
|
521 pcall (self.MyObject.onenter_func, self.MyObject)
|
|
Tercio@49
|
522 end
|
|
Tercio@11
|
523 end
|
|
Tercio@11
|
524 local button_on_leave = function (self)
|
|
Tercio@11
|
525 self.MyObject._icon:SetBlendMode ("BLEND")
|
|
Tercio@49
|
526 if (self.MyObject.onleave_func) then
|
|
Tercio@49
|
527 pcall (self.MyObject.onleave_func, self.MyObject)
|
|
Tercio@49
|
528 end
|
|
Tercio@11
|
529 end
|
|
Tercio@11
|
530
|
|
Tercio@20
|
531 local add_row = function (self, t, need_update)
|
|
Tercio@20
|
532 local index = #self.rows+1
|
|
Tercio@20
|
533
|
|
Tercio@20
|
534 local thisrow = DF:NewPanel (self, self, "$parentHeader_" .. self._name .. index, nil, 1, 20)
|
|
Tercio@20
|
535 thisrow.backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]}
|
|
Tercio@20
|
536 thisrow.color = "silver"
|
|
Tercio@20
|
537 thisrow.type = t.type
|
|
Tercio@20
|
538 thisrow.func = t.func
|
|
Tercio@20
|
539 thisrow.name = t.name
|
|
Tercio@20
|
540 thisrow.notext = t.notext
|
|
Tercio@20
|
541 thisrow.icon = t.icon
|
|
Tercio@20
|
542 thisrow.iconalign = t.iconalign
|
|
Tercio@20
|
543
|
|
Tercio@20
|
544 thisrow.hidden = t.hidden or false
|
|
Tercio@20
|
545
|
|
Tercio@49
|
546 thisrow.onenter = t.onenter
|
|
Tercio@49
|
547 thisrow.onleave = t.onleave
|
|
Tercio@49
|
548
|
|
Tercio@20
|
549 local text = DF:NewLabel (thisrow, nil, self._name .. "$parentLabel" .. index, "text")
|
|
Tercio@20
|
550 text:SetPoint ("left", thisrow, "left", 2, 0)
|
|
Tercio@20
|
551 text:SetText (t.name)
|
|
Tercio@20
|
552
|
|
Tercio@20
|
553 tinsert (self._raw_rows, t)
|
|
Tercio@20
|
554 tinsert (self.rows, thisrow)
|
|
Tercio@20
|
555
|
|
Tercio@20
|
556 if (need_update) then
|
|
Tercio@20
|
557 self:AlignRows()
|
|
Tercio@20
|
558 end
|
|
Tercio@11
|
559 end
|
|
Tercio@11
|
560
|
|
Tercio@20
|
561 local align_rows = function (self)
|
|
Tercio@20
|
562
|
|
Tercio@20
|
563 local rows_shown = 0
|
|
Tercio@20
|
564 for index, row in ipairs (self.rows) do
|
|
Tercio@20
|
565 if (not row.hidden) then
|
|
Tercio@20
|
566 rows_shown = rows_shown + 1
|
|
Tercio@20
|
567 end
|
|
Tercio@20
|
568 end
|
|
Tercio@20
|
569
|
|
Tercio@20
|
570 local cur_width = 0
|
|
Tercio@20
|
571 local row_width = self._width / rows_shown
|
|
Tercio@22
|
572
|
|
Tercio@20
|
573 local sindex = 1
|
|
Tercio@20
|
574
|
|
Tercio@20
|
575 wipe (self._anchors)
|
|
Tercio@20
|
576
|
|
Tercio@20
|
577 for index, row in ipairs (self.rows) do
|
|
Tercio@20
|
578 if (not row.hidden) then
|
|
Tercio@20
|
579 if (self._autowidth) then
|
|
Tercio@20
|
580 if (self._raw_rows [index].width) then
|
|
Tercio@20
|
581 row.width = self._raw_rows [index].width
|
|
Tercio@20
|
582 else
|
|
Tercio@20
|
583 row.width = row_width
|
|
Tercio@20
|
584 end
|
|
Tercio@20
|
585 row:SetPoint ("topleft", self, "topleft", cur_width, 0)
|
|
Tercio@20
|
586 tinsert (self._anchors, cur_width)
|
|
Tercio@20
|
587 cur_width = cur_width + row_width + 1
|
|
Tercio@20
|
588 else
|
|
Tercio@20
|
589 row:SetPoint ("topleft", self, "topleft", cur_width, 0)
|
|
Tercio@20
|
590 row.width = self._raw_rows [index].width
|
|
Tercio@20
|
591 tinsert (self._anchors, cur_width)
|
|
Tercio@20
|
592 cur_width = cur_width + self._raw_rows [index].width + 1
|
|
Tercio@20
|
593 end
|
|
Tercio@42
|
594
|
|
Tercio@20
|
595 row:Show()
|
|
Tercio@20
|
596
|
|
Tercio@20
|
597 local type = row.type
|
|
Tercio@20
|
598
|
|
Tercio@20
|
599 if (type == "text") then
|
|
Tercio@20
|
600 for i = 1, #self.scrollframe.lines do
|
|
Tercio@20
|
601 local line = self.scrollframe.lines [i]
|
|
Tercio@20
|
602 local text = tremove (line.text_available)
|
|
Tercio@20
|
603 if (not text) then
|
|
Tercio@20
|
604 self:CreateRowText (line)
|
|
Tercio@20
|
605 text = tremove (line.text_available)
|
|
Tercio@20
|
606 end
|
|
Tercio@20
|
607 tinsert (line.text_inuse, text)
|
|
Tercio@20
|
608 text:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
|
|
Tercio@20
|
609 text:SetWidth (row.width)
|
|
Tercio@42
|
610
|
|
Tercio@42
|
611 DF:SetFontSize (text, row.textsize or 10)
|
|
Tercio@42
|
612 text:SetJustifyH (row.textalign or "left")
|
|
Tercio@20
|
613 end
|
|
Tercio@20
|
614 elseif (type == "entry") then
|
|
Tercio@20
|
615 for i = 1, #self.scrollframe.lines do
|
|
Tercio@20
|
616 local line = self.scrollframe.lines [i]
|
|
Tercio@20
|
617 local entry = tremove (line.entry_available)
|
|
Tercio@20
|
618 if (not entry) then
|
|
Tercio@20
|
619 self:CreateRowEntry (line)
|
|
Tercio@20
|
620 entry = tremove (line.entry_available)
|
|
Tercio@20
|
621 end
|
|
Tercio@20
|
622 tinsert (line.entry_inuse, entry)
|
|
Tercio@20
|
623 entry:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
|
|
Tercio@20
|
624 if (sindex == rows_shown) then
|
|
Tercio@20
|
625 entry:SetWidth (row.width - 25)
|
|
Tercio@20
|
626 else
|
|
Tercio@20
|
627 entry:SetWidth (row.width)
|
|
Tercio@20
|
628 end
|
|
Tercio@20
|
629 entry.func = row.func
|
|
Tercio@49
|
630
|
|
Tercio@49
|
631 entry.onenter_func = nil
|
|
Tercio@49
|
632 entry.onleave_func = nil
|
|
Tercio@49
|
633
|
|
Tercio@49
|
634 if (row.onenter) then
|
|
Tercio@49
|
635 entry.onenter_func = row.onenter
|
|
Tercio@49
|
636 end
|
|
Tercio@49
|
637 if (row.onleave) then
|
|
Tercio@49
|
638 entry.onleave_func = row.onleave
|
|
Tercio@49
|
639 end
|
|
Tercio@20
|
640 end
|
|
Tercio@20
|
641 elseif (type == "button") then
|
|
Tercio@20
|
642 for i = 1, #self.scrollframe.lines do
|
|
Tercio@20
|
643 local line = self.scrollframe.lines [i]
|
|
Tercio@20
|
644 local button = tremove (line.button_available)
|
|
Tercio@20
|
645 if (not button) then
|
|
Tercio@20
|
646 self:CreateRowButton (line)
|
|
Tercio@20
|
647 button = tremove (line.button_available)
|
|
Tercio@20
|
648 end
|
|
Tercio@20
|
649 tinsert (line.button_inuse, button)
|
|
Tercio@20
|
650 button:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
|
|
Tercio@20
|
651 if (sindex == rows_shown) then
|
|
Tercio@20
|
652 button:SetWidth (row.width - 25)
|
|
Tercio@20
|
653 else
|
|
Tercio@20
|
654 button:SetWidth (row.width)
|
|
Tercio@20
|
655 end
|
|
Tercio@20
|
656
|
|
Tercio@20
|
657 if (row.icon) then
|
|
Tercio@20
|
658 button._icon.texture = row.icon
|
|
Tercio@20
|
659 button._icon:ClearAllPoints()
|
|
Tercio@20
|
660 if (row.iconalign) then
|
|
Tercio@20
|
661 if (row.iconalign == "center") then
|
|
Tercio@20
|
662 button._icon:SetPoint ("center", button, "center")
|
|
Tercio@20
|
663 elseif (row.iconalign == "right") then
|
|
Tercio@20
|
664 button._icon:SetPoint ("right", button, "right")
|
|
Tercio@20
|
665 end
|
|
Tercio@20
|
666 else
|
|
Tercio@20
|
667 button._icon:SetPoint ("left", button, "left")
|
|
Tercio@20
|
668 end
|
|
Tercio@20
|
669 end
|
|
Tercio@20
|
670
|
|
Tercio@20
|
671 if (row.name and not row.notext) then
|
|
Tercio@20
|
672 button._text:SetPoint ("left", button._icon, "right", 2, 0)
|
|
Tercio@20
|
673 button._text.text = row.name
|
|
Tercio@49
|
674 end
|
|
Tercio@49
|
675
|
|
Tercio@49
|
676 button.onenter_func = nil
|
|
Tercio@49
|
677 button.onleave_func = nil
|
|
Tercio@49
|
678
|
|
Tercio@49
|
679 if (row.onenter) then
|
|
Tercio@49
|
680 button.onenter_func = row.onenter
|
|
Tercio@49
|
681 end
|
|
Tercio@49
|
682 if (row.onleave) then
|
|
Tercio@49
|
683 button.onleave_func = row.onleave
|
|
Tercio@49
|
684 end
|
|
Tercio@20
|
685
|
|
Tercio@20
|
686 end
|
|
Tercio@20
|
687 elseif (type == "icon") then
|
|
Tercio@20
|
688 for i = 1, #self.scrollframe.lines do
|
|
Tercio@20
|
689 local line = self.scrollframe.lines [i]
|
|
Tercio@20
|
690 local icon = tremove (line.icon_available)
|
|
Tercio@20
|
691 if (not icon) then
|
|
Tercio@20
|
692 self:CreateRowIcon (line)
|
|
Tercio@20
|
693 icon = tremove (line.icon_available)
|
|
Tercio@20
|
694 end
|
|
Tercio@20
|
695 tinsert (line.icon_inuse, icon)
|
|
Tercio@20
|
696 icon:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ( ((row.width or 22) - 22) / 2), 0)
|
|
Tercio@20
|
697 icon.func = row.func
|
|
Tercio@20
|
698 end
|
|
Tercio@49
|
699
|
|
Tercio@49
|
700 elseif (type == "texture") then
|
|
Tercio@49
|
701 for i = 1, #self.scrollframe.lines do
|
|
Tercio@49
|
702 local line = self.scrollframe.lines [i]
|
|
Tercio@49
|
703 local texture = tremove (line.texture_available)
|
|
Tercio@49
|
704 if (not texture) then
|
|
Tercio@49
|
705 self:CreateRowTexture (line)
|
|
Tercio@49
|
706 texture = tremove (line.texture_available)
|
|
Tercio@49
|
707 end
|
|
Tercio@49
|
708 tinsert (line.texture_inuse, texture)
|
|
Tercio@49
|
709 texture:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ( ((row.width or 22) - 22) / 2), 0)
|
|
Tercio@49
|
710 end
|
|
Tercio@49
|
711
|
|
Tercio@20
|
712 end
|
|
Tercio@20
|
713
|
|
Tercio@20
|
714 sindex = sindex + 1
|
|
Tercio@20
|
715 else
|
|
Tercio@20
|
716 row:Hide()
|
|
Tercio@20
|
717 end
|
|
Tercio@20
|
718 end
|
|
Tercio@20
|
719
|
|
Tercio@20
|
720 if (#self.rows > 0) then
|
|
Tercio@20
|
721 if (self._autowidth) then
|
|
Tercio@20
|
722 self.rows [#self.rows]:SetWidth (row_width - rows_shown + 1)
|
|
Tercio@20
|
723 else
|
|
Tercio@20
|
724 self.rows [#self.rows]:SetWidth (self._raw_rows [rows_shown].width - rows_shown + 1)
|
|
Tercio@20
|
725 end
|
|
Tercio@20
|
726 end
|
|
Tercio@20
|
727
|
|
Tercio@20
|
728 self.showing_amt = rows_shown
|
|
Tercio@20
|
729 end
|
|
Tercio@20
|
730
|
|
Tercio@20
|
731 local update_rows = function (self, updated_rows)
|
|
Tercio@49
|
732
|
|
Tercio@20
|
733 for i = 1, #updated_rows do
|
|
Tercio@20
|
734 local t = updated_rows [i]
|
|
Tercio@20
|
735 local raw = self._raw_rows [i]
|
|
Tercio@20
|
736
|
|
Tercio@20
|
737 if (not raw) then
|
|
Tercio@20
|
738 self:AddRow (t)
|
|
Tercio@20
|
739 else
|
|
Tercio@20
|
740 raw.name = t.name
|
|
Tercio@20
|
741 raw.hidden = t.hidden or false
|
|
Tercio@42
|
742 raw.textsize = t.textsize
|
|
Tercio@42
|
743 raw.textalign = t.textalign
|
|
Tercio@20
|
744
|
|
Tercio@20
|
745 local widget = self.rows [i]
|
|
Tercio@20
|
746 widget.name = t.name
|
|
Tercio@42
|
747 widget.textsize = t.textsize
|
|
Tercio@42
|
748 widget.textalign = t.textalign
|
|
Tercio@20
|
749 widget.hidden = t.hidden or false
|
|
Tercio@20
|
750
|
|
Tercio@49
|
751 --
|
|
Tercio@49
|
752 widget.onenter = t.onenter
|
|
Tercio@49
|
753 widget.onleave = t.onleave
|
|
Tercio@49
|
754 --
|
|
Tercio@49
|
755
|
|
Tercio@20
|
756 widget.text:SetText (t.name)
|
|
Tercio@42
|
757 DF:SetFontSize (widget.text, raw.textsize or 10)
|
|
Tercio@42
|
758 widget.text:SetJustifyH (raw.textalign or "left")
|
|
Tercio@42
|
759
|
|
Tercio@20
|
760 end
|
|
Tercio@20
|
761 end
|
|
Tercio@20
|
762
|
|
Tercio@20
|
763 for i = #updated_rows+1, #self._raw_rows do
|
|
Tercio@20
|
764 local raw = self._raw_rows [i]
|
|
Tercio@20
|
765 local widget = self.rows [i]
|
|
Tercio@20
|
766 raw.hidden = true
|
|
Tercio@20
|
767 widget.hidden = true
|
|
Tercio@20
|
768 end
|
|
Tercio@20
|
769
|
|
Tercio@20
|
770 for index, row in ipairs (self.scrollframe.lines) do
|
|
Tercio@20
|
771 for i = #row.text_inuse, 1, -1 do
|
|
Tercio@20
|
772 tinsert (row.text_available, tremove (row.text_inuse, i))
|
|
Tercio@20
|
773 end
|
|
Tercio@20
|
774 for i = 1, #row.text_available do
|
|
Tercio@20
|
775 row.text_available[i]:Hide()
|
|
Tercio@20
|
776 end
|
|
Tercio@20
|
777
|
|
Tercio@20
|
778 for i = #row.entry_inuse, 1, -1 do
|
|
Tercio@20
|
779 tinsert (row.entry_available, tremove (row.entry_inuse, i))
|
|
Tercio@20
|
780 end
|
|
Tercio@20
|
781 for i = 1, #row.entry_available do
|
|
Tercio@20
|
782 row.entry_available[i]:Hide()
|
|
Tercio@20
|
783 end
|
|
Tercio@20
|
784
|
|
Tercio@20
|
785 for i = #row.button_inuse, 1, -1 do
|
|
Tercio@20
|
786 tinsert (row.button_available, tremove (row.button_inuse, i))
|
|
Tercio@20
|
787 end
|
|
Tercio@20
|
788 for i = 1, #row.button_available do
|
|
Tercio@20
|
789 row.button_available[i]:Hide()
|
|
Tercio@20
|
790 end
|
|
Tercio@20
|
791
|
|
Tercio@20
|
792 for i = #row.icon_inuse, 1, -1 do
|
|
Tercio@20
|
793 tinsert (row.icon_available, tremove (row.icon_inuse, i))
|
|
Tercio@20
|
794 end
|
|
Tercio@20
|
795 for i = 1, #row.icon_available do
|
|
Tercio@20
|
796 row.icon_available[i]:Hide()
|
|
Tercio@20
|
797 end
|
|
Tercio@49
|
798
|
|
Tercio@49
|
799 for i = #row.texture_inuse, 1, -1 do
|
|
Tercio@49
|
800 tinsert (row.texture_available, tremove (row.texture_inuse, i))
|
|
Tercio@49
|
801 end
|
|
Tercio@49
|
802 for i = 1, #row.texture_available do
|
|
Tercio@49
|
803 row.texture_available[i]:Hide()
|
|
Tercio@49
|
804 end
|
|
Tercio@20
|
805 end
|
|
Tercio@20
|
806
|
|
Tercio@22
|
807 self.current_header = updated_rows
|
|
Tercio@22
|
808
|
|
Tercio@20
|
809 self:AlignRows()
|
|
Tercio@20
|
810
|
|
Tercio@20
|
811 end
|
|
Tercio@20
|
812
|
|
Tercio@20
|
813 local create_panel_text = function (self, row)
|
|
Tercio@20
|
814 row.text_total = row.text_total + 1
|
|
Tercio@20
|
815 local text = DF:NewLabel (row, nil, self._name .. "$parentLabel" .. row.text_total, "text" .. row.text_total)
|
|
Tercio@20
|
816 tinsert (row.text_available, text)
|
|
Tercio@20
|
817 end
|
|
Tercio@20
|
818
|
|
Tercio@20
|
819 local create_panel_entry = function (self, row)
|
|
Tercio@20
|
820 row.entry_total = row.entry_total + 1
|
|
Tercio@20
|
821 local editbox = DF:NewTextEntry (row, nil, "$parentEntry" .. row.entry_total, "entry", 120, 20)
|
|
Tercio@20
|
822 editbox.align = "left"
|
|
Tercio@20
|
823
|
|
Tercio@20
|
824 editbox:SetHook ("OnEnterPressed", function()
|
|
Tercio@20
|
825 editbox.widget.focuslost = true
|
|
Tercio@20
|
826 editbox:ClearFocus()
|
|
Tercio@20
|
827 editbox.func (editbox.index, editbox.text)
|
|
Tercio@20
|
828 return true
|
|
Tercio@49
|
829 end)
|
|
Tercio@49
|
830
|
|
Tercio@49
|
831 editbox:SetHook ("OnEnter", function()
|
|
Tercio@49
|
832 if (editbox.onenter_func) then
|
|
Tercio@49
|
833 pcall (editbox.onenter_func, editbox)
|
|
Tercio@49
|
834 end
|
|
Tercio@49
|
835 end)
|
|
Tercio@49
|
836 editbox:SetHook ("OnLeave", function()
|
|
Tercio@49
|
837 if (editbox.onleave_func) then
|
|
Tercio@49
|
838 pcall (editbox.onleave_func, editbox)
|
|
Tercio@49
|
839 end
|
|
Tercio@49
|
840 end)
|
|
Tercio@20
|
841
|
|
Tercio@20
|
842 editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1})
|
|
Tercio@20
|
843 editbox:SetBackdropColor (1, 1, 1, 0.1)
|
|
Tercio@20
|
844 editbox:SetBackdropBorderColor (1, 1, 1, 0.1)
|
|
Tercio@20
|
845 editbox.editbox.current_bordercolor = {1, 1, 1, 0.1}
|
|
Tercio@20
|
846
|
|
Tercio@20
|
847 tinsert (row.entry_available, editbox)
|
|
Tercio@20
|
848 end
|
|
Tercio@20
|
849
|
|
Tercio@20
|
850 local create_panel_button = function (self, row)
|
|
Tercio@20
|
851 row.button_total = row.button_total + 1
|
|
Tercio@20
|
852 local button = DF:NewButton (row, nil, "$parentButton" .. row.button_total, "button" .. row.button_total, 120, 20)
|
|
Tercio@20
|
853
|
|
Tercio@20
|
854 --> create icon and the text
|
|
Tercio@20
|
855 local icon = DF:NewImage (button, nil, 20, 20)
|
|
Tercio@20
|
856 local text = DF:NewLabel (button)
|
|
Tercio@20
|
857
|
|
Tercio@20
|
858 button._icon = icon
|
|
Tercio@20
|
859 button._text = text
|
|
Tercio@20
|
860
|
|
Tercio@20
|
861 button:SetHook ("OnEnter", button_on_enter)
|
|
Tercio@20
|
862 button:SetHook ("OnLeave", button_on_leave)
|
|
Tercio@20
|
863
|
|
Tercio@20
|
864 tinsert (row.button_available, button)
|
|
Tercio@20
|
865 end
|
|
Tercio@20
|
866
|
|
Tercio@20
|
867 local icon_onclick = function (texture, iconbutton)
|
|
Tercio@20
|
868 iconbutton._icon.texture = texture
|
|
Tercio@20
|
869 iconbutton.func (iconbutton.index, texture)
|
|
Tercio@20
|
870 end
|
|
Tercio@20
|
871
|
|
Tercio@20
|
872 local create_panel_icon = function (self, row)
|
|
Tercio@20
|
873 row.icon_total = row.icon_total + 1
|
|
Tercio@20
|
874 local iconbutton = DF:NewButton (row, nil, "$parentIconButton" .. row.icon_total, "iconbutton", 22, 20)
|
|
Tercio@20
|
875 iconbutton:InstallCustomTexture()
|
|
Tercio@20
|
876
|
|
Tercio@20
|
877 iconbutton:SetHook ("OnEnter", button_on_enter)
|
|
Tercio@20
|
878 iconbutton:SetHook ("OnLeave", button_on_leave)
|
|
Tercio@20
|
879
|
|
Tercio@20
|
880 iconbutton:SetHook ("OnMouseUp", function()
|
|
Tercio@20
|
881 DF:IconPick (icon_onclick, true, iconbutton)
|
|
Tercio@20
|
882 return true
|
|
Tercio@20
|
883 end)
|
|
Tercio@20
|
884
|
|
Tercio@20
|
885 local icon = DF:NewImage (iconbutton, nil, 20, 20, "artwork", nil, "_icon", "$parentIcon" .. row.icon_total)
|
|
Tercio@20
|
886 iconbutton._icon = icon
|
|
Tercio@20
|
887
|
|
Tercio@20
|
888 icon:SetPoint ("center", iconbutton, "center", 0, 0)
|
|
Tercio@20
|
889
|
|
Tercio@20
|
890 tinsert (row.icon_available, iconbutton)
|
|
Tercio@20
|
891 end
|
|
Tercio@20
|
892
|
|
Tercio@49
|
893 local create_panel_texture = function (self, row)
|
|
Tercio@49
|
894 row.texture_total = row.texture_total + 1
|
|
Tercio@49
|
895 local texture = DF:NewImage (row, nil, 20, 20, "artwork", nil, "_icon" .. row.texture_total, "$parentIcon" .. row.texture_total)
|
|
Tercio@49
|
896 tinsert (row.texture_available, texture)
|
|
Tercio@49
|
897 end
|
|
Tercio@49
|
898
|
|
Tercio@20
|
899 local set_fill_function = function (self, func)
|
|
Tercio@20
|
900 self._fillfunc = func
|
|
Tercio@20
|
901 end
|
|
Tercio@20
|
902 local set_total_function = function (self, func)
|
|
Tercio@20
|
903 self._totalfunc = func
|
|
Tercio@20
|
904 end
|
|
Tercio@20
|
905 local drop_header_function = function (self)
|
|
Tercio@20
|
906 wipe (self.rows)
|
|
Tercio@20
|
907 end
|
|
Tercio@22
|
908
|
|
Tercio@22
|
909 local fillpanel_update_size = function (self, elapsed)
|
|
Tercio@22
|
910 local panel = self.MyObject
|
|
Tercio@22
|
911
|
|
Tercio@22
|
912 panel._width = panel:GetWidth()
|
|
Tercio@22
|
913 panel._height = panel:GetHeight()
|
|
Tercio@22
|
914
|
|
Tercio@22
|
915 panel:UpdateRowAmount()
|
|
Tercio@22
|
916 if (panel.current_header) then
|
|
Tercio@22
|
917 update_rows (panel, panel.current_header)
|
|
Tercio@22
|
918 end
|
|
Tercio@22
|
919 panel:Refresh()
|
|
Tercio@22
|
920
|
|
Tercio@22
|
921 self:SetScript ("OnUpdate", nil)
|
|
Tercio@22
|
922 end
|
|
Tercio@22
|
923
|
|
Tercio@20
|
924 -- ~fillpanel
|
|
Tercio@22
|
925 --alias
|
|
Tercio@22
|
926 function DF:CreateFillPanel (parent, rows, w, h, total_lines, fill_row, autowidth, options, member, name)
|
|
Tercio@22
|
927 return DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
|
|
Tercio@22
|
928 end
|
|
Tercio@22
|
929
|
|
Tercio@11
|
930 function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
|
|
Tercio@11
|
931
|
|
Tercio@11
|
932 local panel = DF:NewPanel (parent, parent, name, member, w, h)
|
|
Tercio@11
|
933 panel.backdrop = nil
|
|
Tercio@11
|
934
|
|
Tercio@11
|
935 options = options or {rowheight = 20}
|
|
Tercio@11
|
936 panel.rows = {}
|
|
Tercio@20
|
937
|
|
Tercio@20
|
938 panel.AddRow = add_row
|
|
Tercio@20
|
939 panel.AlignRows = align_rows
|
|
Tercio@20
|
940 panel.UpdateRows = update_rows
|
|
Tercio@20
|
941 panel.CreateRowText = create_panel_text
|
|
Tercio@20
|
942 panel.CreateRowEntry = create_panel_entry
|
|
Tercio@20
|
943 panel.CreateRowButton = create_panel_button
|
|
Tercio@20
|
944 panel.CreateRowIcon = create_panel_icon
|
|
Tercio@49
|
945 panel.CreateRowTexture = create_panel_texture
|
|
Tercio@20
|
946 panel.SetFillFunction = set_fill_function
|
|
Tercio@20
|
947 panel.SetTotalFunction = set_total_function
|
|
Tercio@20
|
948 panel.DropHeader = drop_header_function
|
|
Tercio@20
|
949
|
|
Tercio@20
|
950 panel._name = name
|
|
Tercio@20
|
951 panel._width = w
|
|
Tercio@20
|
952 panel._height = h
|
|
Tercio@20
|
953 panel._raw_rows = {}
|
|
Tercio@20
|
954 panel._anchors = {}
|
|
Tercio@20
|
955 panel._fillfunc = fill_row
|
|
Tercio@20
|
956 panel._totalfunc = total_lines
|
|
Tercio@20
|
957 panel._autowidth = autowidth
|
|
Tercio@20
|
958
|
|
Tercio@22
|
959 panel:SetScript ("OnSizeChanged", function()
|
|
Tercio@22
|
960 panel:SetScript ("OnUpdate", fillpanel_update_size)
|
|
Tercio@22
|
961 end)
|
|
Tercio@22
|
962
|
|
Tercio@11
|
963 for index, t in ipairs (rows) do
|
|
Tercio@20
|
964 panel.AddRow (panel, t)
|
|
Tercio@11
|
965 end
|
|
Tercio@55
|
966
|
|
Tercio@11
|
967 local refresh_fillbox = function (self)
|
|
Tercio@20
|
968
|
|
Tercio@11
|
969 local offset = FauxScrollFrame_GetOffset (self)
|
|
Tercio@20
|
970 local filled_lines = panel._totalfunc (panel)
|
|
Tercio@20
|
971
|
|
Tercio@11
|
972 for index = 1, #self.lines do
|
|
Tercio@20
|
973
|
|
Tercio@11
|
974 local row = self.lines [index]
|
|
Tercio@11
|
975 if (index <= filled_lines) then
|
|
Tercio@20
|
976
|
|
Tercio@11
|
977 local real_index = index + offset
|
|
Tercio@20
|
978 local results = panel._fillfunc (real_index, panel)
|
|
Tercio@11
|
979
|
|
Tercio@49
|
980 if (results and results [1]) then
|
|
Tercio@11
|
981 row:Show()
|
|
Tercio@20
|
982
|
|
Tercio@49
|
983 local text, entry, button, icon, texture = 1, 1, 1, 1, 1
|
|
Tercio@11
|
984
|
|
Tercio@20
|
985 for index, t in ipairs (panel.rows) do
|
|
Tercio@20
|
986 if (not t.hidden) then
|
|
Tercio@20
|
987 if (t.type == "text") then
|
|
Tercio@20
|
988 local fontstring = row.text_inuse [text]
|
|
Tercio@20
|
989 text = text + 1
|
|
Tercio@20
|
990 fontstring:SetText (results [index])
|
|
Tercio@20
|
991 fontstring.index = real_index
|
|
Tercio@20
|
992 fontstring:Show()
|
|
Tercio@11
|
993
|
|
Tercio@20
|
994 elseif (t.type == "entry") then
|
|
Tercio@20
|
995 local entrywidget = row.entry_inuse [entry]
|
|
Tercio@20
|
996 entry = entry + 1
|
|
Tercio@20
|
997 entrywidget.index = real_index
|
|
Tercio@49
|
998
|
|
Tercio@49
|
999 if (type (results [index]) == "table") then
|
|
Tercio@49
|
1000 entrywidget:SetText (results [index].text)
|
|
Tercio@49
|
1001 entrywidget.id = results [index].id
|
|
Tercio@49
|
1002 entrywidget.data1 = results [index].data1
|
|
Tercio@49
|
1003 entrywidget.data2 = results [index].data2
|
|
Tercio@49
|
1004 else
|
|
Tercio@49
|
1005 entrywidget:SetText (results [index])
|
|
Tercio@49
|
1006 end
|
|
Tercio@49
|
1007
|
|
Tercio@49
|
1008 entrywidget:SetCursorPosition(0)
|
|
Tercio@49
|
1009
|
|
Tercio@20
|
1010 entrywidget:Show()
|
|
Tercio@20
|
1011
|
|
Tercio@20
|
1012 elseif (t.type == "button") then
|
|
Tercio@20
|
1013 local buttonwidget = row.button_inuse [button]
|
|
Tercio@20
|
1014 button = button + 1
|
|
Tercio@20
|
1015 buttonwidget.index = real_index
|
|
Tercio@22
|
1016
|
|
Tercio@20
|
1017 if (type (results [index]) == "table") then
|
|
Tercio@20
|
1018 if (results [index].text) then
|
|
Tercio@20
|
1019 buttonwidget:SetText (results [index].text)
|
|
Tercio@20
|
1020 end
|
|
Tercio@20
|
1021
|
|
Tercio@20
|
1022 if (results [index].icon) then
|
|
Tercio@20
|
1023 buttonwidget._icon:SetTexture (results [index].icon)
|
|
Tercio@20
|
1024 end
|
|
Tercio@20
|
1025
|
|
Tercio@20
|
1026 if (results [index].func) then
|
|
Tercio@22
|
1027 local func = function()
|
|
Tercio@22
|
1028 t.func (real_index, results [index].value)
|
|
Tercio@22
|
1029 panel:Refresh()
|
|
Tercio@22
|
1030 end
|
|
Tercio@22
|
1031 buttonwidget:SetClickFunction (func)
|
|
Tercio@22
|
1032 else
|
|
Tercio@22
|
1033 local func = function()
|
|
Tercio@22
|
1034 t.func (real_index, index)
|
|
Tercio@22
|
1035 panel:Refresh()
|
|
Tercio@22
|
1036 end
|
|
Tercio@22
|
1037 buttonwidget:SetClickFunction (func)
|
|
Tercio@20
|
1038 end
|
|
Tercio@49
|
1039
|
|
Tercio@49
|
1040 buttonwidget.id = results [index].id
|
|
Tercio@49
|
1041 buttonwidget.data1 = results [index].data1
|
|
Tercio@49
|
1042 buttonwidget.data2 = results [index].data2
|
|
Tercio@49
|
1043
|
|
Tercio@20
|
1044 else
|
|
Tercio@22
|
1045 local func = function()
|
|
Tercio@22
|
1046 t.func (real_index, index)
|
|
Tercio@22
|
1047 panel:Refresh()
|
|
Tercio@22
|
1048 end
|
|
Tercio@22
|
1049 buttonwidget:SetClickFunction (func)
|
|
Tercio@20
|
1050 buttonwidget:SetText (results [index])
|
|
Tercio@11
|
1051 end
|
|
Tercio@11
|
1052
|
|
Tercio@20
|
1053 buttonwidget:Show()
|
|
Tercio@11
|
1054
|
|
Tercio@20
|
1055 elseif (t.type == "icon") then
|
|
Tercio@20
|
1056 local iconwidget = row.icon_inuse [icon]
|
|
Tercio@20
|
1057 icon = icon + 1
|
|
Tercio@20
|
1058
|
|
Tercio@20
|
1059 iconwidget.line = index
|
|
Tercio@20
|
1060 iconwidget.index = real_index
|
|
Tercio@20
|
1061
|
|
Tercio@39
|
1062 --print (index, results [index])
|
|
Tercio@39
|
1063 if (type (results [index]) == "string") then
|
|
Tercio@39
|
1064 local result = results [index]:gsub (".-%\\", "")
|
|
Tercio@39
|
1065 iconwidget._icon.texture = results [index]
|
|
Tercio@39
|
1066 else
|
|
Tercio@39
|
1067 iconwidget._icon:SetTexture (results [index])
|
|
Tercio@39
|
1068 end
|
|
Tercio@20
|
1069
|
|
Tercio@20
|
1070 iconwidget:Show()
|
|
Tercio@49
|
1071
|
|
Tercio@49
|
1072 elseif (t.type == "texture") then
|
|
Tercio@49
|
1073 local texturewidget = row.texture_inuse [texture]
|
|
Tercio@49
|
1074 texture = texture + 1
|
|
Tercio@49
|
1075
|
|
Tercio@49
|
1076 texturewidget.line = index
|
|
Tercio@49
|
1077 texturewidget.index = real_index
|
|
Tercio@49
|
1078
|
|
Tercio@49
|
1079 if (type (results [index]) == "string") then
|
|
Tercio@49
|
1080 local result = results [index]:gsub (".-%\\", "")
|
|
Tercio@49
|
1081 texturewidget.texture = results [index]
|
|
Tercio@49
|
1082 else
|
|
Tercio@49
|
1083 texturewidget:SetTexture (results [index])
|
|
Tercio@49
|
1084 end
|
|
Tercio@49
|
1085
|
|
Tercio@49
|
1086 texturewidget:Show()
|
|
Tercio@11
|
1087 end
|
|
Tercio@11
|
1088 end
|
|
Tercio@11
|
1089 end
|
|
Tercio@20
|
1090
|
|
Tercio@11
|
1091 else
|
|
Tercio@11
|
1092 row:Hide()
|
|
Tercio@11
|
1093 end
|
|
Tercio@11
|
1094 else
|
|
Tercio@11
|
1095 row:Hide()
|
|
Tercio@11
|
1096 end
|
|
Tercio@11
|
1097 end
|
|
Tercio@11
|
1098 end
|
|
Tercio@11
|
1099
|
|
Tercio@11
|
1100 function panel:Refresh()
|
|
Tercio@22
|
1101 if (type (panel._totalfunc) == "boolean") then
|
|
Tercio@22
|
1102 --> not yet initialized
|
|
Tercio@22
|
1103 return
|
|
Tercio@22
|
1104 end
|
|
Tercio@20
|
1105 local filled_lines = panel._totalfunc (panel)
|
|
Tercio@17
|
1106 local scroll_total_lines = #panel.scrollframe.lines
|
|
Tercio@11
|
1107 local line_height = options.rowheight
|
|
Tercio@20
|
1108 refresh_fillbox (panel.scrollframe)
|
|
Tercio@11
|
1109 FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height)
|
|
Tercio@49
|
1110 panel.scrollframe:Show()
|
|
Tercio@11
|
1111 end
|
|
Tercio@11
|
1112
|
|
Tercio@11
|
1113 local scrollframe = CreateFrame ("scrollframe", name .. "Scroll", panel.widget, "FauxScrollFrameTemplate")
|
|
Tercio@11
|
1114 scrollframe:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (self, offset, 20, panel.Refresh) end)
|
|
Tercio@11
|
1115 scrollframe:SetPoint ("topleft", panel.widget, "topleft", 0, -21)
|
|
Tercio@11
|
1116 scrollframe:SetPoint ("topright", panel.widget, "topright", -23, -21)
|
|
Tercio@11
|
1117 scrollframe:SetPoint ("bottomleft", panel.widget, "bottomleft")
|
|
Tercio@11
|
1118 scrollframe:SetPoint ("bottomright", panel.widget, "bottomright", -23, 0)
|
|
Tercio@11
|
1119 scrollframe:SetSize (w, h)
|
|
Tercio@11
|
1120 panel.scrollframe = scrollframe
|
|
Tercio@11
|
1121 scrollframe.lines = {}
|
|
Tercio@11
|
1122
|
|
Tercio@11
|
1123 --create lines
|
|
Tercio@22
|
1124 function panel:UpdateRowAmount()
|
|
Tercio@22
|
1125 local size = options.rowheight
|
|
Tercio@22
|
1126 local amount = math.floor (((panel._height-21) / size))
|
|
Tercio@22
|
1127
|
|
Tercio@22
|
1128 for i = #scrollframe.lines+1, amount do
|
|
Tercio@22
|
1129 local row = CreateFrame ("frame", panel:GetName() .. "Row_" .. i, panel.widget)
|
|
Tercio@22
|
1130 row:SetSize (1, size)
|
|
Tercio@22
|
1131 row.color = {1, 1, 1, .2}
|
|
Tercio@22
|
1132
|
|
Tercio@22
|
1133 row:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]]})
|
|
Tercio@22
|
1134
|
|
Tercio@22
|
1135 if (i%2 == 0) then
|
|
Tercio@22
|
1136 row:SetBackdropColor (.5, .5, .5, 0.2)
|
|
Tercio@22
|
1137 else
|
|
Tercio@22
|
1138 row:SetBackdropColor (1, 1, 1, 0.00)
|
|
Tercio@22
|
1139 end
|
|
Tercio@22
|
1140
|
|
Tercio@22
|
1141 row:SetPoint ("topleft", scrollframe, "topleft", 0, (i-1) * size * -1)
|
|
Tercio@22
|
1142 row:SetPoint ("topright", scrollframe, "topright", 0, (i-1) * size * -1)
|
|
Tercio@22
|
1143 tinsert (scrollframe.lines, row)
|
|
Tercio@22
|
1144
|
|
Tercio@22
|
1145 row.text_available = {}
|
|
Tercio@22
|
1146 row.text_inuse = {}
|
|
Tercio@22
|
1147 row.text_total = 0
|
|
Tercio@22
|
1148
|
|
Tercio@22
|
1149 row.entry_available = {}
|
|
Tercio@22
|
1150 row.entry_inuse = {}
|
|
Tercio@22
|
1151 row.entry_total = 0
|
|
Tercio@22
|
1152
|
|
Tercio@22
|
1153 row.button_available = {}
|
|
Tercio@22
|
1154 row.button_inuse = {}
|
|
Tercio@22
|
1155 row.button_total = 0
|
|
Tercio@22
|
1156
|
|
Tercio@22
|
1157 row.icon_available = {}
|
|
Tercio@22
|
1158 row.icon_inuse = {}
|
|
Tercio@22
|
1159 row.icon_total = 0
|
|
Tercio@49
|
1160
|
|
Tercio@49
|
1161 row.texture_available = {}
|
|
Tercio@49
|
1162 row.texture_inuse = {}
|
|
Tercio@49
|
1163 row.texture_total = 0
|
|
Tercio@20
|
1164 end
|
|
Tercio@11
|
1165 end
|
|
Tercio@22
|
1166 panel:UpdateRowAmount()
|
|
Tercio@22
|
1167
|
|
Tercio@20
|
1168 panel.AlignRows (panel)
|
|
Tercio@20
|
1169
|
|
Tercio@11
|
1170 return panel
|
|
Tercio@11
|
1171 end
|
|
Tercio@11
|
1172
|
|
Tercio@11
|
1173
|
|
Tercio@11
|
1174 ------------color pick
|
|
Tercio@11
|
1175 local color_pick_func = function()
|
|
Tercio@11
|
1176 local r, g, b = ColorPickerFrame:GetColorRGB()
|
|
Tercio@11
|
1177 local a = OpacitySliderFrame:GetValue()
|
|
Tercio@11
|
1178 ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
|
|
Tercio@11
|
1179 end
|
|
Tercio@11
|
1180 local color_pick_func_cancel = function()
|
|
Tercio@11
|
1181 ColorPickerFrame:SetColorRGB (unpack (ColorPickerFrame.previousValues))
|
|
Tercio@11
|
1182 local r, g, b = ColorPickerFrame:GetColorRGB()
|
|
Tercio@11
|
1183 local a = OpacitySliderFrame:GetValue()
|
|
Tercio@11
|
1184 ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
|
|
Tercio@11
|
1185 end
|
|
Tercio@11
|
1186
|
|
Tercio@11
|
1187 function DF:ColorPick (frame, r, g, b, alpha, callback)
|
|
Tercio@11
|
1188
|
|
Tercio@11
|
1189 ColorPickerFrame:ClearAllPoints()
|
|
Tercio@11
|
1190 ColorPickerFrame:SetPoint ("bottomleft", frame, "topright", 0, 0)
|
|
Tercio@11
|
1191
|
|
Tercio@11
|
1192 ColorPickerFrame.dcallback = callback
|
|
Tercio@11
|
1193 ColorPickerFrame.dframe = frame
|
|
Tercio@11
|
1194
|
|
Tercio@11
|
1195 ColorPickerFrame.func = color_pick_func
|
|
Tercio@11
|
1196 ColorPickerFrame.opacityFunc = color_pick_func
|
|
Tercio@11
|
1197 ColorPickerFrame.cancelFunc = color_pick_func_cancel
|
|
Tercio@11
|
1198
|
|
Tercio@11
|
1199 ColorPickerFrame.opacity = alpha
|
|
Tercio@11
|
1200 ColorPickerFrame.hasOpacity = alpha and true
|
|
Tercio@11
|
1201
|
|
Tercio@11
|
1202 ColorPickerFrame.previousValues = {r, g, b}
|
|
Tercio@11
|
1203 ColorPickerFrame:SetParent (UIParent)
|
|
Tercio@11
|
1204 ColorPickerFrame:SetFrameStrata ("tooltip")
|
|
Tercio@11
|
1205 ColorPickerFrame:SetColorRGB (r, g, b)
|
|
Tercio@11
|
1206 ColorPickerFrame:Show()
|
|
Tercio@11
|
1207
|
|
Tercio@11
|
1208 end
|
|
Tercio@11
|
1209
|
|
Tercio@11
|
1210 ------------icon pick
|
|
Tercio@20
|
1211 function DF:IconPick (callback, close_when_select, param1, param2)
|
|
Tercio@11
|
1212
|
|
Tercio@11
|
1213 if (not DF.IconPickFrame) then
|
|
Tercio@11
|
1214
|
|
Tercio@11
|
1215 local string_lower = string.lower
|
|
Tercio@11
|
1216
|
|
Tercio@11
|
1217 DF.IconPickFrame = CreateFrame ("frame", "DetailsFrameworkIconPickFrame", UIParent)
|
|
Tercio@11
|
1218 tinsert (UISpecialFrames, "DetailsFrameworkIconPickFrame")
|
|
Tercio@11
|
1219 DF.IconPickFrame:SetFrameStrata ("DIALOG")
|
|
Tercio@11
|
1220
|
|
Tercio@11
|
1221 DF.IconPickFrame:SetPoint ("center", UIParent, "center")
|
|
Tercio@11
|
1222 DF.IconPickFrame:SetWidth (350)
|
|
Tercio@11
|
1223 DF.IconPickFrame:SetHeight (227)
|
|
Tercio@11
|
1224 DF.IconPickFrame:EnableMouse (true)
|
|
Tercio@11
|
1225 DF.IconPickFrame:SetMovable (true)
|
|
Tercio@11
|
1226
|
|
Tercio@53
|
1227 DF.IconPickFrame:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
|
|
Tercio@53
|
1228
|
|
Tercio@53
|
1229 DF.IconPickFrame:SetBackdropBorderColor (0, 0, 0)
|
|
Tercio@11
|
1230 DF.IconPickFrame:SetBackdropColor (24/255, 24/255, 24/255, .8)
|
|
Tercio@11
|
1231 DF.IconPickFrame:SetFrameLevel (1)
|
|
Tercio@11
|
1232
|
|
Tercio@53
|
1233 DF.IconPickFrame:SetScript ("OnMouseDown", function (self)
|
|
Tercio@53
|
1234 if (not self.isMoving) then
|
|
Tercio@53
|
1235 DF.IconPickFrame:StartMoving()
|
|
Tercio@53
|
1236 self.isMoving = true
|
|
Tercio@53
|
1237 end
|
|
Tercio@53
|
1238 end)
|
|
Tercio@53
|
1239
|
|
Tercio@53
|
1240 DF.IconPickFrame:SetScript ("OnMouseUp", function (self)
|
|
Tercio@53
|
1241 if (self.isMoving) then
|
|
Tercio@53
|
1242 DF.IconPickFrame:StopMovingOrSizing()
|
|
Tercio@53
|
1243 self.isMoving = nil
|
|
Tercio@53
|
1244 end
|
|
Tercio@53
|
1245 end)
|
|
Tercio@53
|
1246
|
|
Tercio@11
|
1247 DF.IconPickFrame.emptyFunction = function() end
|
|
Tercio@11
|
1248 DF.IconPickFrame.callback = DF.IconPickFrame.emptyFunction
|
|
Tercio@11
|
1249
|
|
Tercio@11
|
1250 DF.IconPickFrame.preview = CreateFrame ("frame", nil, UIParent)
|
|
Tercio@11
|
1251 DF.IconPickFrame.preview:SetFrameStrata ("tooltip")
|
|
Tercio@11
|
1252 DF.IconPickFrame.preview:SetSize (76, 76)
|
|
Tercio@11
|
1253 local preview_image = DF:NewImage (DF.IconPickFrame.preview, nil, 76, 76)
|
|
Tercio@11
|
1254 preview_image:SetAllPoints (DF.IconPickFrame.preview)
|
|
Tercio@11
|
1255 DF.IconPickFrame.preview.icon = preview_image
|
|
Tercio@11
|
1256 DF.IconPickFrame.preview:Hide()
|
|
Tercio@11
|
1257
|
|
Tercio@11
|
1258 DF.IconPickFrame.searchLabel = DF:NewLabel (DF.IconPickFrame, nil, "$parentSearchBoxLabel", nil, "search:", font, size, color)
|
|
Tercio@11
|
1259 DF.IconPickFrame.searchLabel:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12, -20)
|
|
Tercio@11
|
1260 DF.IconPickFrame.search = DF:NewTextEntry (DF.IconPickFrame, nil, "$parentSearchBox", nil, 140, 20)
|
|
Tercio@11
|
1261 DF.IconPickFrame.search:SetPoint ("left", DF.IconPickFrame.searchLabel, "right", 2, 0)
|
|
Tercio@11
|
1262 DF.IconPickFrame.search:SetHook ("OnTextChanged", function()
|
|
Tercio@11
|
1263 DF.IconPickFrame.searching = DF.IconPickFrame.search:GetText()
|
|
Tercio@11
|
1264 if (DF.IconPickFrame.searching == "") then
|
|
Tercio@11
|
1265 DF.IconPickFrameScroll:Show()
|
|
Tercio@11
|
1266 DF.IconPickFrame.searching = nil
|
|
Tercio@11
|
1267 DF.IconPickFrame.updateFunc()
|
|
Tercio@11
|
1268 else
|
|
Tercio@11
|
1269 DF.IconPickFrameScroll:Hide()
|
|
Tercio@11
|
1270 FauxScrollFrame_SetOffset (DF.IconPickFrame, 1)
|
|
Tercio@11
|
1271 DF.IconPickFrame.last_filter_index = 1
|
|
Tercio@11
|
1272 DF.IconPickFrame.updateFunc()
|
|
Tercio@11
|
1273 end
|
|
Tercio@11
|
1274 end)
|
|
Tercio@11
|
1275
|
|
Tercio@11
|
1276 --> close button
|
|
Tercio@11
|
1277 local close_button = CreateFrame ("button", nil, DF.IconPickFrame, "UIPanelCloseButton")
|
|
Tercio@11
|
1278 close_button:SetWidth (32)
|
|
Tercio@11
|
1279 close_button:SetHeight (32)
|
|
Tercio@11
|
1280 close_button:SetPoint ("TOPRIGHT", DF.IconPickFrame, "TOPRIGHT", -8, -7)
|
|
Tercio@11
|
1281 close_button:SetFrameLevel (close_button:GetFrameLevel()+2)
|
|
Tercio@11
|
1282
|
|
Tercio@11
|
1283 local MACRO_ICON_FILENAMES = {}
|
|
Tercio@53
|
1284 local SPELLNAMES_CACHE = {}
|
|
Tercio@53
|
1285
|
|
Tercio@11
|
1286 DF.IconPickFrame:SetScript ("OnShow", function()
|
|
Tercio@53
|
1287
|
|
Tercio@53
|
1288 MACRO_ICON_FILENAMES [1] = "INV_MISC_QUESTIONMARK";
|
|
Tercio@11
|
1289 local index = 2;
|
|
Tercio@11
|
1290
|
|
Tercio@11
|
1291 for i = 1, GetNumSpellTabs() do
|
|
Tercio@53
|
1292 local tab, tabTex, offset, numSpells, _ = GetSpellTabInfo (i)
|
|
Tercio@53
|
1293 offset = offset + 1
|
|
Tercio@53
|
1294 local tabEnd = offset + numSpells
|
|
Tercio@53
|
1295
|
|
Tercio@11
|
1296 for j = offset, tabEnd - 1 do
|
|
Tercio@11
|
1297 --to get spell info by slot, you have to pass in a pet argument
|
|
Tercio@53
|
1298 local spellType, ID = GetSpellBookItemInfo (j, "player")
|
|
Tercio@11
|
1299 if (spellType ~= "FUTURESPELL") then
|
|
Tercio@53
|
1300 MACRO_ICON_FILENAMES [index] = GetSpellBookItemTexture (j, "player") or 0
|
|
Tercio@53
|
1301 index = index + 1;
|
|
Tercio@53
|
1302
|
|
Tercio@53
|
1303 elseif (spellType == "FLYOUT") then
|
|
Tercio@53
|
1304 local _, _, numSlots, isKnown = GetFlyoutInfo (ID)
|
|
Tercio@11
|
1305 if (isKnown and numSlots > 0) then
|
|
Tercio@11
|
1306 for k = 1, numSlots do
|
|
Tercio@53
|
1307 local spellID, overrideSpellID, isKnown = GetFlyoutSlotInfo (ID, k)
|
|
Tercio@11
|
1308 if (isKnown) then
|
|
Tercio@53
|
1309 MACRO_ICON_FILENAMES [index] = GetSpellTexture (spellID) or 0
|
|
Tercio@11
|
1310 index = index + 1;
|
|
Tercio@11
|
1311 end
|
|
Tercio@11
|
1312 end
|
|
Tercio@11
|
1313 end
|
|
Tercio@53
|
1314
|
|
Tercio@11
|
1315 end
|
|
Tercio@11
|
1316 end
|
|
Tercio@11
|
1317 end
|
|
Tercio@11
|
1318
|
|
Tercio@11
|
1319 GetLooseMacroItemIcons (MACRO_ICON_FILENAMES)
|
|
Tercio@11
|
1320 GetLooseMacroIcons (MACRO_ICON_FILENAMES)
|
|
Tercio@11
|
1321 GetMacroIcons (MACRO_ICON_FILENAMES)
|
|
Tercio@53
|
1322 GetMacroItemIcons (MACRO_ICON_FILENAMES)
|
|
Tercio@53
|
1323
|
|
Tercio@11
|
1324 end)
|
|
Tercio@11
|
1325
|
|
Tercio@11
|
1326 DF.IconPickFrame:SetScript ("OnHide", function()
|
|
Tercio@53
|
1327 wipe (MACRO_ICON_FILENAMES)
|
|
Tercio@11
|
1328 collectgarbage()
|
|
Tercio@11
|
1329 end)
|
|
Tercio@11
|
1330
|
|
Tercio@11
|
1331 DF.IconPickFrame.buttons = {}
|
|
Tercio@11
|
1332
|
|
Tercio@11
|
1333 local OnClickFunction = function (self)
|
|
Tercio@20
|
1334 DF.IconPickFrame.callback (self.icon:GetTexture(), DF.IconPickFrame.param1, DF.IconPickFrame.param2)
|
|
Tercio@11
|
1335 if (DF.IconPickFrame.click_close) then
|
|
Tercio@11
|
1336 close_button:Click()
|
|
Tercio@11
|
1337 end
|
|
Tercio@11
|
1338 end
|
|
Tercio@11
|
1339
|
|
Tercio@11
|
1340 local onenter = function (self)
|
|
Tercio@11
|
1341 DF.IconPickFrame.preview:SetPoint ("bottom", self, "top", 0, 2)
|
|
Tercio@11
|
1342 DF.IconPickFrame.preview.icon:SetTexture (self.icon:GetTexture())
|
|
Tercio@11
|
1343 DF.IconPickFrame.preview:Show()
|
|
Tercio@11
|
1344 self.icon:SetBlendMode ("ADD")
|
|
Tercio@11
|
1345 end
|
|
Tercio@11
|
1346 local onleave = function (self)
|
|
Tercio@11
|
1347 DF.IconPickFrame.preview:Hide()
|
|
Tercio@11
|
1348 self.icon:SetBlendMode ("BLEND")
|
|
Tercio@11
|
1349 end
|
|
Tercio@11
|
1350
|
|
Tercio@11
|
1351 local backdrop = {bgFile = DF.folder .. "background", tile = true, tileSize = 16,
|
|
Tercio@11
|
1352 insets = {left = 0, right = 0, top = 0, bottom = 0}, edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10}
|
|
Tercio@11
|
1353
|
|
Tercio@11
|
1354 for i = 0, 9 do
|
|
Tercio@11
|
1355 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..(i+1), DF.IconPickFrame)
|
|
Tercio@11
|
1356 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..(i+1).."Icon", "overlay")
|
|
Tercio@11
|
1357 newcheck.icon = image
|
|
Tercio@11
|
1358 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1359 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1360 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1361
|
|
Tercio@11
|
1362 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1363 newcheck.param1 = i+1
|
|
Tercio@11
|
1364
|
|
Tercio@11
|
1365 newcheck:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12 + (i*30), -40)
|
|
Tercio@11
|
1366 newcheck:SetID (i+1)
|
|
Tercio@11
|
1367 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1368 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1369 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1370 end
|
|
Tercio@11
|
1371 for i = 11, 20 do
|
|
Tercio@11
|
1372 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1373 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1374 newcheck.icon = image
|
|
Tercio@11
|
1375 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1376 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1377 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1378
|
|
Tercio@11
|
1379 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1380 newcheck.param1 = i
|
|
Tercio@11
|
1381
|
|
Tercio@11
|
1382 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1383 newcheck:SetID (i)
|
|
Tercio@11
|
1384 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1385 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1386 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1387 end
|
|
Tercio@11
|
1388 for i = 21, 30 do
|
|
Tercio@11
|
1389 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1390 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1391 newcheck.icon = image
|
|
Tercio@11
|
1392 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1393 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1394 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1395
|
|
Tercio@11
|
1396 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1397 newcheck.param1 = i
|
|
Tercio@11
|
1398
|
|
Tercio@11
|
1399 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1400 newcheck:SetID (i)
|
|
Tercio@11
|
1401 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1402 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1403 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1404 end
|
|
Tercio@11
|
1405 for i = 31, 40 do
|
|
Tercio@11
|
1406 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1407 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1408 newcheck.icon = image
|
|
Tercio@11
|
1409 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1410 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1411 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1412
|
|
Tercio@11
|
1413 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1414 newcheck.param1 = i
|
|
Tercio@11
|
1415
|
|
Tercio@11
|
1416 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1417 newcheck:SetID (i)
|
|
Tercio@11
|
1418 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1419 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1420 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1421 end
|
|
Tercio@11
|
1422 for i = 41, 50 do
|
|
Tercio@11
|
1423 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1424 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1425 newcheck.icon = image
|
|
Tercio@11
|
1426 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1427 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1428 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1429
|
|
Tercio@11
|
1430 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1431 newcheck.param1 = i
|
|
Tercio@11
|
1432
|
|
Tercio@11
|
1433 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1434 newcheck:SetID (i)
|
|
Tercio@11
|
1435 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1436 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1437 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1438 end
|
|
Tercio@11
|
1439 for i = 51, 60 do
|
|
Tercio@11
|
1440 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1441 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1442 newcheck.icon = image
|
|
Tercio@11
|
1443 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1444 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1445 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1446
|
|
Tercio@11
|
1447 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1448 newcheck.param1 = i
|
|
Tercio@11
|
1449
|
|
Tercio@11
|
1450 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1451 newcheck:SetID (i)
|
|
Tercio@11
|
1452 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1453 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1454 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1455 end
|
|
Tercio@11
|
1456
|
|
Tercio@11
|
1457 local scroll = CreateFrame ("ScrollFrame", "DetailsFrameworkIconPickFrameScroll", DF.IconPickFrame, "ListScrollFrameTemplate")
|
|
Tercio@11
|
1458
|
|
Tercio@11
|
1459 local ChecksFrame_Update = function (self)
|
|
Tercio@11
|
1460
|
|
Tercio@11
|
1461 local numMacroIcons = #MACRO_ICON_FILENAMES
|
|
Tercio@11
|
1462 local macroPopupIcon, macroPopupButton
|
|
Tercio@11
|
1463 local macroPopupOffset = FauxScrollFrame_GetOffset (scroll)
|
|
Tercio@11
|
1464 local index
|
|
Tercio@11
|
1465
|
|
Tercio@11
|
1466 local texture
|
|
Tercio@11
|
1467 local filter
|
|
Tercio@11
|
1468 if (DF.IconPickFrame.searching) then
|
|
Tercio@11
|
1469 filter = string_lower (DF.IconPickFrame.searching)
|
|
Tercio@11
|
1470 end
|
|
Tercio@53
|
1471
|
|
Tercio@53
|
1472 local pool
|
|
Tercio@53
|
1473 local shown = 0
|
|
Tercio@11
|
1474
|
|
Tercio@11
|
1475 if (filter and filter ~= "") then
|
|
Tercio@53
|
1476 if (#SPELLNAMES_CACHE == 0) then
|
|
Tercio@53
|
1477 --build name cache
|
|
Tercio@53
|
1478 local GetSpellInfo = GetSpellInfo
|
|
Tercio@53
|
1479 for i = 1, #MACRO_ICON_FILENAMES do
|
|
Tercio@53
|
1480 local spellName = GetSpellInfo (MACRO_ICON_FILENAMES [i])
|
|
Tercio@53
|
1481 SPELLNAMES_CACHE [i] = spellName or "NULL"
|
|
Tercio@11
|
1482 end
|
|
Tercio@11
|
1483 end
|
|
Tercio@53
|
1484
|
|
Tercio@53
|
1485 --do the filter
|
|
Tercio@53
|
1486 pool = {}
|
|
Tercio@53
|
1487 for i = 1, #SPELLNAMES_CACHE do
|
|
Tercio@53
|
1488 if (SPELLNAMES_CACHE [i]:find (filter)) then
|
|
Tercio@53
|
1489 pool [#pool+1] = MACRO_ICON_FILENAMES [i]
|
|
Tercio@53
|
1490 shown = shown + 1
|
|
Tercio@53
|
1491 end
|
|
Tercio@53
|
1492 end
|
|
Tercio@53
|
1493 else
|
|
Tercio@53
|
1494 shown = nil
|
|
Tercio@53
|
1495 end
|
|
Tercio@11
|
1496
|
|
Tercio@53
|
1497 if (not pool) then
|
|
Tercio@53
|
1498 pool = MACRO_ICON_FILENAMES
|
|
Tercio@53
|
1499 end
|
|
Tercio@53
|
1500
|
|
Tercio@53
|
1501 for i = 1, 60 do
|
|
Tercio@53
|
1502 macroPopupIcon = _G ["DetailsFrameworkIconPickFrameButton"..i.."Icon"]
|
|
Tercio@53
|
1503 macroPopupButton = _G ["DetailsFrameworkIconPickFrameButton"..i]
|
|
Tercio@53
|
1504 index = (macroPopupOffset * 10) + i
|
|
Tercio@53
|
1505 texture = pool [index]
|
|
Tercio@53
|
1506 if ( index <= numMacroIcons and texture ) then
|
|
Tercio@53
|
1507
|
|
Tercio@53
|
1508 if (type (texture) == "number") then
|
|
Tercio@53
|
1509 macroPopupIcon:SetTexture (texture)
|
|
Tercio@53
|
1510 else
|
|
Tercio@53
|
1511 macroPopupIcon:SetTexture ("INTERFACE\\ICONS\\" .. texture)
|
|
Tercio@53
|
1512 end
|
|
Tercio@53
|
1513
|
|
Tercio@53
|
1514 macroPopupIcon:SetTexCoord (4/64, 60/64, 4/64, 60/64)
|
|
Tercio@53
|
1515 macroPopupButton.IconID = index
|
|
Tercio@53
|
1516 macroPopupButton:Show()
|
|
Tercio@53
|
1517 else
|
|
Tercio@11
|
1518 macroPopupButton:Hide()
|
|
Tercio@11
|
1519 end
|
|
Tercio@53
|
1520 end
|
|
Tercio@11
|
1521
|
|
Tercio@53
|
1522 pool = nil
|
|
Tercio@11
|
1523
|
|
Tercio@11
|
1524 -- Scrollbar stuff
|
|
Tercio@53
|
1525 FauxScrollFrame_Update (scroll, ceil ((shown or numMacroIcons) / 10) , 5, 20 )
|
|
Tercio@11
|
1526 end
|
|
Tercio@11
|
1527
|
|
Tercio@11
|
1528 DF.IconPickFrame.updateFunc = ChecksFrame_Update
|
|
Tercio@11
|
1529
|
|
Tercio@11
|
1530 scroll:SetPoint ("topleft", DF.IconPickFrame, "topleft", -18, -37)
|
|
Tercio@11
|
1531 scroll:SetWidth (330)
|
|
Tercio@11
|
1532 scroll:SetHeight (178)
|
|
Tercio@11
|
1533 scroll:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (scroll, offset, 20, ChecksFrame_Update) end)
|
|
Tercio@11
|
1534 scroll.update = ChecksFrame_Update
|
|
Tercio@11
|
1535 DF.IconPickFrameScroll = scroll
|
|
Tercio@11
|
1536 DF.IconPickFrame:Hide()
|
|
Tercio@11
|
1537
|
|
Tercio@11
|
1538 end
|
|
Tercio@11
|
1539
|
|
Tercio@20
|
1540 DF.IconPickFrame.param1, DF.IconPickFrame.param2 = param1, param2
|
|
Tercio@20
|
1541
|
|
Tercio@11
|
1542 DF.IconPickFrame:Show()
|
|
Tercio@11
|
1543 DF.IconPickFrameScroll.update (DF.IconPickFrameScroll)
|
|
Tercio@11
|
1544 DF.IconPickFrame.callback = callback or DF.IconPickFrame.emptyFunction
|
|
Tercio@11
|
1545 DF.IconPickFrame.click_close = close_when_select
|
|
Tercio@11
|
1546
|
|
Tercio@11
|
1547 end
|
|
Tercio@11
|
1548
|
|
Tercioo@29
|
1549 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercioo@29
|
1550
|
|
Tercioo@29
|
1551 function DF:ShowPanicWarning (text)
|
|
Tercioo@29
|
1552 if (not DF.PanicWarningWindow) then
|
|
Tercioo@29
|
1553 DF.PanicWarningWindow = CreateFrame ("frame", "DetailsFrameworkPanicWarningWindow", UIParent)
|
|
Tercioo@29
|
1554 DF.PanicWarningWindow:SetHeight (80)
|
|
Tercioo@29
|
1555 DF.PanicWarningWindow:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
|
|
Tercioo@29
|
1556 DF.PanicWarningWindow:SetBackdropColor (1, 0, 0, 0.2)
|
|
Tercioo@29
|
1557 DF.PanicWarningWindow:SetPoint ("topleft", UIParent, "topleft", 0, -250)
|
|
Tercioo@29
|
1558 DF.PanicWarningWindow:SetPoint ("topright", UIParent, "topright", 0, -250)
|
|
Tercioo@29
|
1559
|
|
Tercioo@29
|
1560 DF.PanicWarningWindow.text = DF.PanicWarningWindow:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercioo@29
|
1561 DF.PanicWarningWindow.text:SetPoint ("center", DF.PanicWarningWindow, "center")
|
|
Tercioo@29
|
1562 DF.PanicWarningWindow.text:SetTextColor (1, 0.6, 0)
|
|
Tercioo@29
|
1563 end
|
|
Tercioo@29
|
1564
|
|
Tercioo@29
|
1565 DF.PanicWarningWindow.text:SetText (text)
|
|
Tercioo@29
|
1566 DF.PanicWarningWindow:Show()
|
|
Tercioo@29
|
1567 end
|
|
Tercioo@29
|
1568
|
|
Tercioo@29
|
1569 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercioo@29
|
1570
|
|
Tercioo@29
|
1571
|
|
Tercio@11
|
1572 local simple_panel_mouse_down = function (self, button)
|
|
Tercio@11
|
1573 if (button == "RightButton") then
|
|
Tercio@11
|
1574 if (self.IsMoving) then
|
|
Tercio@11
|
1575 self.IsMoving = false
|
|
Tercio@11
|
1576 self:StopMovingOrSizing()
|
|
Tercio@11
|
1577 if (self.db and self.db.position) then
|
|
Tercio@11
|
1578 DF:SavePositionOnScreen (self)
|
|
Tercio@11
|
1579 end
|
|
Tercio@11
|
1580 end
|
|
Tercio@17
|
1581 if (not self.DontRightClickClose) then
|
|
Tercio@17
|
1582 self:Hide()
|
|
Tercio@17
|
1583 end
|
|
Tercio@11
|
1584 return
|
|
Tercio@11
|
1585 end
|
|
Tercio@11
|
1586 if (not self.IsMoving and not self.IsLocked) then
|
|
Tercio@11
|
1587 self.IsMoving = true
|
|
Tercio@11
|
1588 self:StartMoving()
|
|
Tercio@11
|
1589 end
|
|
Tercio@11
|
1590 end
|
|
Tercio@11
|
1591 local simple_panel_mouse_up = function (self, button)
|
|
Tercio@11
|
1592 if (self.IsMoving) then
|
|
Tercio@11
|
1593 self.IsMoving = false
|
|
Tercio@11
|
1594 self:StopMovingOrSizing()
|
|
Tercio@11
|
1595 if (self.db and self.db.position) then
|
|
Tercio@11
|
1596 DF:SavePositionOnScreen (self)
|
|
Tercio@11
|
1597 end
|
|
Tercio@11
|
1598 end
|
|
Tercio@11
|
1599 end
|
|
Tercio@11
|
1600 local simple_panel_settitle = function (self, title)
|
|
Tercio@22
|
1601 self.Title:SetText (title)
|
|
Tercio@11
|
1602 end
|
|
Tercio@11
|
1603
|
|
Tercio@22
|
1604 local simple_panel_close_click = function (self)
|
|
Tercio@22
|
1605 self:GetParent():GetParent():Hide()
|
|
Tercio@22
|
1606 end
|
|
Tercio@22
|
1607
|
|
Tercio@22
|
1608 local SimplePanel_frame_backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}
|
|
Tercio@22
|
1609 local SimplePanel_frame_backdrop_color = {0, 0, 0, 0.9}
|
|
Tercio@22
|
1610 local SimplePanel_frame_backdrop_border_color = {0, 0, 0, 1}
|
|
Tercio@22
|
1611
|
|
Tercio@39
|
1612 function DF:CreateScaleBar (frame, config)
|
|
Tercio@39
|
1613 local scaleBar = DF:CreateSlider (frame, 120, 14, 0.6, 1.6, 0.1, config.scale, true, "ScaleBar", nil, "Scale:", DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE"), DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
|
|
Tercio@40
|
1614 scaleBar:SetPoint ("right", frame.Close, "left", -26, 0)
|
|
Tercio@39
|
1615 scaleBar:SetFrameLevel (DF.FRAMELEVEL_OVERLAY)
|
|
Tercio@39
|
1616 scaleBar.OnValueChanged = function (_, _, value)
|
|
Tercio@39
|
1617 config.scale = value
|
|
Tercio@39
|
1618 if (not scaleBar.IsValueChanging) then
|
|
Tercio@39
|
1619 frame:SetScale (config.scale)
|
|
Tercio@39
|
1620 end
|
|
Tercio@39
|
1621 end
|
|
Tercio@39
|
1622 scaleBar:SetHook ("OnMouseUp", function()
|
|
Tercio@39
|
1623 frame:SetScale (config.scale)
|
|
Tercio@39
|
1624 end)
|
|
Tercio@39
|
1625 end
|
|
Tercio@39
|
1626
|
|
Tercio@26
|
1627 local no_options = {}
|
|
Tercio@39
|
1628 function DF:CreateSimplePanel (parent, w, h, title, name, panel_options, db)
|
|
Tercio@49
|
1629
|
|
Tercio@39
|
1630 if (db and name and not db [name]) then
|
|
Tercio@39
|
1631 db [name] = {scale = 1}
|
|
Tercio@39
|
1632 end
|
|
Tercio@11
|
1633
|
|
Tercio@11
|
1634 if (not name) then
|
|
Tercioo@29
|
1635 name = "DetailsFrameworkSimplePanel" .. DF.SimplePanelCounter
|
|
Tercioo@29
|
1636 DF.SimplePanelCounter = DF.SimplePanelCounter + 1
|
|
Tercio@11
|
1637 end
|
|
Tercio@11
|
1638 if (not parent) then
|
|
Tercio@11
|
1639 parent = UIParent
|
|
Tercio@11
|
1640 end
|
|
Tercio@26
|
1641
|
|
Tercio@26
|
1642 panel_options = panel_options or no_options
|
|
Tercio@49
|
1643
|
|
Tercio@11
|
1644 local f = CreateFrame ("frame", name, UIParent)
|
|
Tercio@11
|
1645 f:SetSize (w or 400, h or 250)
|
|
Tercio@11
|
1646 f:SetPoint ("center", UIParent, "center", 0, 0)
|
|
Tercio@11
|
1647 f:SetFrameStrata ("FULLSCREEN")
|
|
Tercio@11
|
1648 f:EnableMouse()
|
|
Tercio@11
|
1649 f:SetMovable (true)
|
|
Tercio@22
|
1650 f:SetBackdrop (SimplePanel_frame_backdrop)
|
|
Tercio@22
|
1651 f:SetBackdropColor (unpack (SimplePanel_frame_backdrop_color))
|
|
Tercio@22
|
1652 f:SetBackdropBorderColor (unpack (SimplePanel_frame_backdrop_border_color))
|
|
Tercio@26
|
1653
|
|
Tercio@26
|
1654 f.DontRightClickClose = panel_options.DontRightClickClose
|
|
Tercio@26
|
1655
|
|
Tercio@26
|
1656 if (not panel_options.NoTUISpecialFrame) then
|
|
Tercio@26
|
1657 tinsert (UISpecialFrames, name)
|
|
Tercio@26
|
1658 end
|
|
Tercio@22
|
1659
|
|
Tercio@22
|
1660 local title_bar = CreateFrame ("frame", name .. "TitleBar", f)
|
|
Tercio@22
|
1661 title_bar:SetPoint ("topleft", f, "topleft", 2, -3)
|
|
Tercio@22
|
1662 title_bar:SetPoint ("topright", f, "topright", -2, -3)
|
|
Tercio@22
|
1663 title_bar:SetHeight (20)
|
|
Tercio@22
|
1664 title_bar:SetBackdrop (SimplePanel_frame_backdrop)
|
|
Tercio@22
|
1665 title_bar:SetBackdropColor (.2, .2, .2, 1)
|
|
Tercio@22
|
1666 title_bar:SetBackdropBorderColor (0, 0, 0, 1)
|
|
Tercio@26
|
1667 f.TitleBar = title_bar
|
|
Tercio@22
|
1668
|
|
Tercio@22
|
1669 local close = CreateFrame ("button", name and name .. "CloseButton", title_bar)
|
|
Tercio@39
|
1670 close:SetFrameLevel (DF.FRAMELEVEL_OVERLAY)
|
|
Tercio@22
|
1671 close:SetSize (16, 16)
|
|
Tercio@22
|
1672 close:SetNormalTexture (DF.folder .. "icons")
|
|
Tercio@22
|
1673 close:SetHighlightTexture (DF.folder .. "icons")
|
|
Tercio@22
|
1674 close:SetPushedTexture (DF.folder .. "icons")
|
|
Tercio@22
|
1675 close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@22
|
1676 close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@22
|
1677 close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@22
|
1678 close:SetAlpha (0.7)
|
|
Tercio@22
|
1679 close:SetScript ("OnClick", simple_panel_close_click)
|
|
Tercio@22
|
1680 f.Close = close
|
|
Tercio@22
|
1681
|
|
Tercio@22
|
1682 local title_string = title_bar:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
|
|
Tercio@22
|
1683 title_string:SetTextColor (.8, .8, .8, 1)
|
|
Tercio@22
|
1684 title_string:SetText (title or "")
|
|
Tercio@22
|
1685 f.Title = title_string
|
|
Tercio@22
|
1686
|
|
Tercio@39
|
1687 if (panel_options.UseScaleBar and db [name]) then
|
|
Tercio@39
|
1688 DF:CreateScaleBar (f, db [name])
|
|
Tercio@39
|
1689 f:SetScale (db [name].scale)
|
|
Tercio@39
|
1690 end
|
|
Tercio@39
|
1691
|
|
Tercio@22
|
1692 f.Title:SetPoint ("center", title_bar, "center")
|
|
Tercio@22
|
1693 f.Close:SetPoint ("right", title_bar, "right", -2, 0)
|
|
Tercio@22
|
1694
|
|
Tercio@11
|
1695 f:SetScript ("OnMouseDown", simple_panel_mouse_down)
|
|
Tercio@11
|
1696 f:SetScript ("OnMouseUp", simple_panel_mouse_up)
|
|
Tercio@11
|
1697
|
|
Tercio@11
|
1698 f.SetTitle = simple_panel_settitle
|
|
Tercio@11
|
1699
|
|
Tercio@11
|
1700 return f
|
|
Tercio@11
|
1701 end
|
|
Tercio@11
|
1702
|
|
Tercio@11
|
1703 local Panel1PxBackdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 64,
|
|
Tercio@11
|
1704 edgeFile = DF.folder .. "border_3", edgeSize = 9, insets = {left = 2, right = 2, top = 3, bottom = 3}}
|
|
Tercio@11
|
1705
|
|
Tercio@11
|
1706 local Panel1PxOnClickClose = function (self)
|
|
Tercio@11
|
1707 self:GetParent():Hide()
|
|
Tercio@11
|
1708 end
|
|
Tercio@11
|
1709 local Panel1PxOnToggleLock = function (self)
|
|
Tercio@11
|
1710 if (self.IsLocked) then
|
|
Tercio@11
|
1711 self.IsLocked = false
|
|
Tercio@11
|
1712 self:SetMovable (true)
|
|
Tercio@11
|
1713 self:EnableMouse (true)
|
|
Tercio@11
|
1714 self.Lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1715 self.Lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1716 self.Lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@17
|
1717 if (self.OnUnlock) then
|
|
Tercio@17
|
1718 self:OnUnlock()
|
|
Tercio@17
|
1719 end
|
|
Tercio@17
|
1720 if (self.db) then
|
|
Tercio@17
|
1721 self.db.IsLocked = self.IsLocked
|
|
Tercio@17
|
1722 end
|
|
Tercio@11
|
1723 else
|
|
Tercio@11
|
1724 self.IsLocked = true
|
|
Tercio@11
|
1725 self:SetMovable (false)
|
|
Tercio@11
|
1726 self:EnableMouse (false)
|
|
Tercio@11
|
1727 self.Lock:GetNormalTexture():SetTexCoord (16/128, 32/128, 0, 1)
|
|
Tercio@11
|
1728 self.Lock:GetHighlightTexture():SetTexCoord (16/128, 32/128, 0, 1)
|
|
Tercio@11
|
1729 self.Lock:GetPushedTexture():SetTexCoord (16/128, 32/128, 0, 1)
|
|
Tercio@17
|
1730 if (self.OnLock) then
|
|
Tercio@17
|
1731 self:OnLock()
|
|
Tercio@17
|
1732 end
|
|
Tercio@17
|
1733 if (self.db) then
|
|
Tercio@17
|
1734 self.db.IsLocked = self.IsLocked
|
|
Tercio@17
|
1735 end
|
|
Tercio@11
|
1736 end
|
|
Tercio@11
|
1737 end
|
|
Tercio@11
|
1738 local Panel1PxOnClickLock = function (self)
|
|
Tercio@11
|
1739 local f = self:GetParent()
|
|
Tercio@11
|
1740 Panel1PxOnToggleLock (f)
|
|
Tercio@11
|
1741 end
|
|
Tercio@11
|
1742 local Panel1PxSetTitle = function (self, text)
|
|
Tercio@11
|
1743 self.Title:SetText (text or "")
|
|
Tercio@11
|
1744 end
|
|
Tercio@11
|
1745
|
|
Tercio@20
|
1746 local Panel1PxSetLocked= function (self, lock_state)
|
|
Tercio@20
|
1747 if (type (lock_state) ~= "boolean") then
|
|
Tercio@20
|
1748 return
|
|
Tercio@20
|
1749 end
|
|
Tercio@20
|
1750 if (lock_state) then
|
|
Tercio@20
|
1751 -- lock it
|
|
Tercio@20
|
1752 self.IsLocked = false
|
|
Tercio@20
|
1753 Panel1PxOnClickLock (self.Lock)
|
|
Tercio@20
|
1754 else
|
|
Tercio@20
|
1755 -- unlockit
|
|
Tercio@20
|
1756 self.IsLocked = true
|
|
Tercio@20
|
1757 Panel1PxOnClickLock (self.Lock)
|
|
Tercio@20
|
1758 end
|
|
Tercio@20
|
1759 end
|
|
Tercio@20
|
1760
|
|
Tercio@11
|
1761 local Panel1PxReadConfig = function (self)
|
|
Tercio@11
|
1762 local db = self.db
|
|
Tercio@11
|
1763 if (db) then
|
|
Tercio@11
|
1764 db.IsLocked = db.IsLocked or false
|
|
Tercio@11
|
1765 self.IsLocked = db.IsLocked
|
|
Tercio@11
|
1766 db.position = db.position or {x = 0, y = 0}
|
|
Tercio@19
|
1767 db.position.x = db.position.x or 0
|
|
Tercio@19
|
1768 db.position.y = db.position.y or 0
|
|
Tercio@11
|
1769 DF:RestoreFramePosition (self)
|
|
Tercio@11
|
1770 end
|
|
Tercio@11
|
1771 end
|
|
Tercio@11
|
1772
|
|
Tercio@11
|
1773 function DF:SavePositionOnScreen (frame)
|
|
Tercio@11
|
1774 if (frame.db and frame.db.position) then
|
|
Tercio@11
|
1775 local x, y = DF:GetPositionOnScreen (frame)
|
|
Tercio@18
|
1776 --print ("saving...", x, y, frame:GetName())
|
|
Tercio@19
|
1777 if (x and y) then
|
|
Tercio@19
|
1778 frame.db.position.x, frame.db.position.y = x, y
|
|
Tercio@19
|
1779 end
|
|
Tercio@11
|
1780 end
|
|
Tercio@11
|
1781 end
|
|
Tercio@11
|
1782
|
|
Tercio@11
|
1783 function DF:GetPositionOnScreen (frame)
|
|
Tercio@11
|
1784 local xOfs, yOfs = frame:GetCenter()
|
|
Tercio@11
|
1785 if (not xOfs) then
|
|
Tercio@11
|
1786 return
|
|
Tercio@11
|
1787 end
|
|
Tercio@11
|
1788 local scale = frame:GetEffectiveScale()
|
|
Tercio@11
|
1789 local UIscale = UIParent:GetScale()
|
|
Tercio@11
|
1790 xOfs = xOfs*scale - GetScreenWidth()*UIscale/2
|
|
Tercio@11
|
1791 yOfs = yOfs*scale - GetScreenHeight()*UIscale/2
|
|
Tercio@11
|
1792 return xOfs/UIscale, yOfs/UIscale
|
|
Tercio@11
|
1793 end
|
|
Tercio@11
|
1794
|
|
Tercio@11
|
1795 function DF:RestoreFramePosition (frame)
|
|
Tercio@11
|
1796 if (frame.db and frame.db.position) then
|
|
Tercio@11
|
1797 local scale, UIscale = frame:GetEffectiveScale(), UIParent:GetScale()
|
|
Tercio@11
|
1798 frame:ClearAllPoints()
|
|
Tercio@19
|
1799 frame.db.position.x = frame.db.position.x or 0
|
|
Tercio@19
|
1800 frame.db.position.y = frame.db.position.y or 0
|
|
Tercio@11
|
1801 frame:SetPoint ("center", UIParent, "center", frame.db.position.x * UIscale / scale, frame.db.position.y * UIscale / scale)
|
|
Tercio@11
|
1802 end
|
|
Tercio@11
|
1803 end
|
|
Tercio@11
|
1804
|
|
Tercio@20
|
1805 local Panel1PxSavePosition= function (self)
|
|
Tercio@20
|
1806 DF:SavePositionOnScreen (self)
|
|
Tercio@20
|
1807 end
|
|
Tercio@20
|
1808
|
|
Tercio@18
|
1809 local Panel1PxHasPosition = function (self)
|
|
Tercio@18
|
1810 local db = self.db
|
|
Tercio@18
|
1811 if (db) then
|
|
Tercio@18
|
1812 if (db.position and db.position.x and (db.position.x ~= 0 or db.position.y ~= 0)) then
|
|
Tercio@18
|
1813 return true
|
|
Tercio@18
|
1814 end
|
|
Tercio@18
|
1815 end
|
|
Tercio@18
|
1816 end
|
|
Tercio@18
|
1817
|
|
Tercio@13
|
1818 function DF:Create1PxPanel (parent, w, h, title, name, config, title_anchor, no_special_frame)
|
|
Tercio@11
|
1819 local f = CreateFrame ("frame", name, parent or UIParent)
|
|
Tercio@11
|
1820 f:SetSize (w or 100, h or 75)
|
|
Tercio@11
|
1821 f:SetPoint ("center", UIParent, "center")
|
|
Tercio@11
|
1822
|
|
Tercio@13
|
1823 if (name and not no_special_frame) then
|
|
Tercio@11
|
1824 tinsert (UISpecialFrames, name)
|
|
Tercio@11
|
1825 end
|
|
Tercio@11
|
1826
|
|
Tercio@11
|
1827 f:SetScript ("OnMouseDown", simple_panel_mouse_down)
|
|
Tercio@11
|
1828 f:SetScript ("OnMouseUp", simple_panel_mouse_up)
|
|
Tercio@11
|
1829
|
|
Tercio@11
|
1830 f:SetBackdrop (Panel1PxBackdrop)
|
|
Tercio@11
|
1831 f:SetBackdropColor (0, 0, 0, 0.5)
|
|
Tercio@11
|
1832
|
|
Tercio@17
|
1833 f.IsLocked = (config and config.IsLocked ~= nil and config.IsLocked) or false
|
|
Tercio@11
|
1834 f:SetMovable (true)
|
|
Tercio@11
|
1835 f:EnableMouse (true)
|
|
Tercio@11
|
1836 f:SetUserPlaced (true)
|
|
Tercio@11
|
1837
|
|
Tercio@11
|
1838 f.db = config
|
|
Tercio@18
|
1839 --print (config.position.x, config.position.x)
|
|
Tercio@11
|
1840 Panel1PxReadConfig (f)
|
|
Tercio@11
|
1841
|
|
Tercio@11
|
1842 local close = CreateFrame ("button", name and name .. "CloseButton", f)
|
|
Tercio@11
|
1843 close:SetSize (16, 16)
|
|
Tercio@11
|
1844 close:SetNormalTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1845 close:SetHighlightTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1846 close:SetPushedTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1847 close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@11
|
1848 close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@11
|
1849 close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@11
|
1850 close:SetAlpha (0.7)
|
|
Tercio@11
|
1851
|
|
Tercio@11
|
1852 local lock = CreateFrame ("button", name and name .. "LockButton", f)
|
|
Tercio@11
|
1853 lock:SetSize (16, 16)
|
|
Tercio@11
|
1854 lock:SetNormalTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1855 lock:SetHighlightTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1856 lock:SetPushedTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1857 lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1858 lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1859 lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1860 lock:SetAlpha (0.7)
|
|
Tercio@11
|
1861
|
|
Tercio@11
|
1862 close:SetPoint ("topright", f, "topright", -3, -3)
|
|
Tercio@11
|
1863 lock:SetPoint ("right", close, "left", 3, 0)
|
|
Tercio@11
|
1864
|
|
Tercio@11
|
1865 close:SetScript ("OnClick", Panel1PxOnClickClose)
|
|
Tercio@11
|
1866 lock:SetScript ("OnClick", Panel1PxOnClickLock)
|
|
Tercio@11
|
1867
|
|
Tercio@11
|
1868 local title_string = f:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
|
|
Tercio@11
|
1869 title_string:SetPoint ("topleft", f, "topleft", 5, -5)
|
|
Tercio@11
|
1870 title_string:SetText (title or "")
|
|
Tercio@11
|
1871
|
|
Tercio@11
|
1872 if (title_anchor) then
|
|
Tercio@11
|
1873 if (title_anchor == "top") then
|
|
Tercio@11
|
1874 title_string:ClearAllPoints()
|
|
Tercio@11
|
1875 title_string:SetPoint ("bottomleft", f, "topleft", 0, 0)
|
|
Tercio@11
|
1876 close:ClearAllPoints()
|
|
Tercio@11
|
1877 close:SetPoint ("bottomright", f, "topright", 0, 0)
|
|
Tercio@11
|
1878 end
|
|
Tercio@11
|
1879 f.title_anchor = title_anchor
|
|
Tercio@11
|
1880 end
|
|
Tercio@11
|
1881
|
|
Tercio@11
|
1882 f.SetTitle = Panel1PxSetTitle
|
|
Tercio@11
|
1883 f.Title = title_string
|
|
Tercio@11
|
1884 f.Lock = lock
|
|
Tercio@11
|
1885 f.Close = close
|
|
Tercio@18
|
1886 f.HasPosition = Panel1PxHasPosition
|
|
Tercio@20
|
1887 f.SavePosition = Panel1PxSavePosition
|
|
Tercio@11
|
1888
|
|
Tercio@17
|
1889 f.IsLocked = not f.IsLocked
|
|
Tercio@20
|
1890 f.SetLocked = Panel1PxSetLocked
|
|
Tercio@17
|
1891 Panel1PxOnToggleLock (f)
|
|
Tercio@17
|
1892
|
|
Tercio@11
|
1893 return f
|
|
Tercio@11
|
1894 end
|
|
Tercio@11
|
1895
|
|
Tercio@11
|
1896 ------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@20
|
1897 -- ~prompt
|
|
Tercio@20
|
1898 function DF:ShowPromptPanel (message, func_true, func_false)
|
|
Tercio@20
|
1899
|
|
Tercio@20
|
1900 if (not DF.prompt_panel) then
|
|
Tercio@20
|
1901 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent)
|
|
Tercio@22
|
1902 f:SetSize (400, 65)
|
|
Tercio@20
|
1903 f:SetFrameStrata ("DIALOG")
|
|
Tercio@22
|
1904 f:SetPoint ("center", UIParent, "center", 0, 300)
|
|
Tercio@20
|
1905 f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
|
|
Tercio@20
|
1906 f:SetBackdropColor (0, 0, 0, 0.8)
|
|
Tercio@20
|
1907 f:SetBackdropBorderColor (0, 0, 0, 1)
|
|
Tercio@20
|
1908
|
|
Tercio@22
|
1909 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@22
|
1910 prompt:SetPoint ("top", f, "top", 0, -15)
|
|
Tercio@22
|
1911 prompt:SetJustifyH ("center")
|
|
Tercio@22
|
1912 f.prompt = prompt
|
|
Tercio@22
|
1913
|
|
Tercio@22
|
1914 local button_true = DF:CreateButton (f, nil, 60, 20, "Yes")
|
|
Tercio@20
|
1915 button_true:SetPoint ("bottomleft", f, "bottomleft", 5, 5)
|
|
Tercio@20
|
1916 f.button_true = button_true
|
|
Tercio@20
|
1917
|
|
Tercio@22
|
1918 local button_false = DF:CreateButton (f, nil, 60, 20, "No")
|
|
Tercio@20
|
1919 button_false:SetPoint ("bottomright", f, "bottomright", -5, 5)
|
|
Tercio@20
|
1920 f.button_false = button_false
|
|
Tercio@20
|
1921
|
|
Tercio@20
|
1922 button_true:SetClickFunction (function()
|
|
Tercio@20
|
1923 local my_func = button_true.true_function
|
|
Tercio@20
|
1924 if (my_func) then
|
|
Tercio@20
|
1925 local okey, errormessage = pcall (my_func, true)
|
|
Tercio@20
|
1926 if (not okey) then
|
|
Tercio@20
|
1927 print ("error:", errormessage)
|
|
Tercio@20
|
1928 end
|
|
Tercio@22
|
1929 f:Hide()
|
|
Tercio@20
|
1930 end
|
|
Tercio@20
|
1931 end)
|
|
Tercio@20
|
1932
|
|
Tercio@20
|
1933 button_false:SetClickFunction (function()
|
|
Tercio@20
|
1934 local my_func = button_false.false_function
|
|
Tercio@20
|
1935 if (my_func) then
|
|
Tercio@20
|
1936 local okey, errormessage = pcall (my_func, true)
|
|
Tercio@20
|
1937 if (not okey) then
|
|
Tercio@20
|
1938 print ("error:", errormessage)
|
|
Tercio@20
|
1939 end
|
|
Tercio@22
|
1940 f:Hide()
|
|
Tercio@20
|
1941 end
|
|
Tercio@20
|
1942 end)
|
|
Tercio@20
|
1943
|
|
Tercio@20
|
1944 f:Hide()
|
|
Tercio@20
|
1945 DF.promtp_panel = f
|
|
Tercio@20
|
1946 end
|
|
Tercio@20
|
1947
|
|
Tercio@20
|
1948 assert (type (func_true) == "function" and type (func_false) == "function", "ShowPromptPanel expects two functions.")
|
|
Tercio@20
|
1949
|
|
Tercio@22
|
1950 DF.promtp_panel.prompt:SetText (message)
|
|
Tercio@20
|
1951 DF.promtp_panel.button_true.true_function = func_true
|
|
Tercio@20
|
1952 DF.promtp_panel.button_false.false_function = func_false
|
|
Tercio@20
|
1953
|
|
Tercio@20
|
1954 DF.promtp_panel:Show()
|
|
Tercio@20
|
1955 end
|
|
Tercio@22
|
1956
|
|
Tercio@22
|
1957
|
|
Tercio@22
|
1958 function DF:ShowTextPromptPanel (message, callback)
|
|
Tercio@22
|
1959
|
|
Tercio@22
|
1960 if (not DF.text_prompt_panel) then
|
|
Tercio@22
|
1961
|
|
Tercio@22
|
1962 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent)
|
|
Tercio@22
|
1963 f:SetSize (400, 100)
|
|
Tercio@22
|
1964 f:SetFrameStrata ("DIALOG")
|
|
Tercio@22
|
1965 f:SetPoint ("center", UIParent, "center", 0, 300)
|
|
Tercio@22
|
1966 f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
|
|
Tercio@22
|
1967 f:SetBackdropColor (0, 0, 0, 0.8)
|
|
Tercio@22
|
1968 f:SetBackdropBorderColor (0, 0, 0, 1)
|
|
Tercio@22
|
1969
|
|
Tercio@22
|
1970 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@22
|
1971 prompt:SetPoint ("top", f, "top", 0, -15)
|
|
Tercio@22
|
1972 prompt:SetJustifyH ("center")
|
|
Tercio@22
|
1973 f.prompt = prompt
|
|
Tercioo@29
|
1974
|
|
Tercioo@29
|
1975 local button_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
|
|
Tercioo@29
|
1976 local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
|
|
Tercioo@29
|
1977
|
|
Tercioo@29
|
1978 local button_true = DF:CreateButton (f, nil, 60, 20, "Okey", nil, nil, nil, nil, nil, nil, options_dropdown_template, button_text_template)
|
|
Tercio@22
|
1979 button_true:SetPoint ("bottomleft", f, "bottomleft", 10, 5)
|
|
Tercio@22
|
1980 f.button_true = button_true
|
|
Tercio@22
|
1981
|
|
Tercioo@29
|
1982 local button_false = DF:CreateButton (f, function() f.textbox:ClearFocus(); f:Hide() end, 60, 20, "Cancel", nil, nil, nil, nil, nil, nil, options_dropdown_template, button_text_template)
|
|
Tercio@22
|
1983 button_false:SetPoint ("bottomright", f, "bottomright", -10, 5)
|
|
Tercio@22
|
1984 f.button_false = button_false
|
|
Tercio@22
|
1985
|
|
Tercioo@29
|
1986 local textbox = DF:CreateTextEntry (f, function()end, 380, 20, "textbox", nil, nil, options_dropdown_template)
|
|
Tercio@22
|
1987 textbox:SetPoint ("topleft", f, "topleft", 10, -45)
|
|
Tercioo@29
|
1988 f.EntryBox = textbox
|
|
Tercio@22
|
1989
|
|
Tercio@22
|
1990 button_true:SetClickFunction (function()
|
|
Tercio@22
|
1991 local my_func = button_true.true_function
|
|
Tercio@22
|
1992 if (my_func) then
|
|
Tercio@22
|
1993 local okey, errormessage = pcall (my_func, textbox:GetText())
|
|
Tercio@22
|
1994 textbox:ClearFocus()
|
|
Tercio@22
|
1995 if (not okey) then
|
|
Tercio@22
|
1996 print ("error:", errormessage)
|
|
Tercio@22
|
1997 end
|
|
Tercio@22
|
1998 f:Hide()
|
|
Tercio@22
|
1999 end
|
|
Tercio@22
|
2000 end)
|
|
Tercio@22
|
2001
|
|
Tercio@22
|
2002 f:Hide()
|
|
Tercio@22
|
2003 DF.text_prompt_panel = f
|
|
Tercio@22
|
2004 end
|
|
Tercio@22
|
2005
|
|
Tercio@22
|
2006 DF.text_prompt_panel:Show()
|
|
Tercio@22
|
2007
|
|
Tercioo@29
|
2008 DetailsFrameworkPrompt.EntryBox:SetText ("")
|
|
Tercio@22
|
2009 DF.text_prompt_panel.prompt:SetText (message)
|
|
Tercio@22
|
2010 DF.text_prompt_panel.button_true.true_function = callback
|
|
Tercioo@29
|
2011
|
|
Tercio@22
|
2012 DF.text_prompt_panel.textbox:SetFocus (true)
|
|
Tercio@22
|
2013
|
|
Tercio@22
|
2014 end
|
|
Tercio@22
|
2015
|
|
Tercio@20
|
2016 ------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
2017 --> options button -- ~options
|
|
Tercio@11
|
2018 function DF:CreateOptionsButton (parent, callback, name)
|
|
Tercio@11
|
2019
|
|
Tercio@11
|
2020 local b = CreateFrame ("button", name, parent)
|
|
Tercio@11
|
2021 b:SetSize (14, 14)
|
|
Tercio@11
|
2022 b:SetNormalTexture (DF.folder .. "icons")
|
|
Tercio@11
|
2023 b:SetHighlightTexture (DF.folder .. "icons")
|
|
Tercio@11
|
2024 b:SetPushedTexture (DF.folder .. "icons")
|
|
Tercio@11
|
2025 b:GetNormalTexture():SetTexCoord (48/128, 64/128, 0, 1)
|
|
Tercio@11
|
2026 b:GetHighlightTexture():SetTexCoord (48/128, 64/128, 0, 1)
|
|
Tercio@11
|
2027 b:GetPushedTexture():SetTexCoord (48/128, 64/128, 0, 1)
|
|
Tercio@11
|
2028 b:SetAlpha (0.7)
|
|
Tercio@11
|
2029
|
|
Tercio@11
|
2030 b:SetScript ("OnClick", callback)
|
|
Tercio@11
|
2031 b:SetScript ("OnEnter", function (self)
|
|
Tercio@11
|
2032 GameCooltip2:Reset()
|
|
Tercio@11
|
2033 GameCooltip2:AddLine ("Options")
|
|
Tercio@11
|
2034 GameCooltip2:ShowCooltip (self, "tooltip")
|
|
Tercio@11
|
2035 end)
|
|
Tercio@11
|
2036 b:SetScript ("OnLeave", function (self)
|
|
Tercio@11
|
2037 GameCooltip2:Hide()
|
|
Tercio@11
|
2038 end)
|
|
Tercio@11
|
2039
|
|
Tercio@11
|
2040 return b
|
|
Tercio@11
|
2041
|
|
Tercio@11
|
2042 end
|
|
Tercio@11
|
2043
|
|
Tercio@11
|
2044 ------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
2045 --> feedback panel -- ~feedback
|
|
Tercio@11
|
2046
|
|
Tercio@11
|
2047 function DF:CreateFeedbackButton (parent, callback, name)
|
|
Tercio@11
|
2048 local b = CreateFrame ("button", name, parent)
|
|
Tercio@11
|
2049 b:SetSize (12, 13)
|
|
Tercio@11
|
2050 b:SetNormalTexture (DF.folder .. "mail")
|
|
Tercio@11
|
2051 b:SetPushedTexture (DF.folder .. "mail")
|
|
Tercio@11
|
2052 b:SetHighlightTexture (DF.folder .. "mail")
|
|
Tercio@11
|
2053
|
|
Tercio@11
|
2054 b:SetScript ("OnClick", callback)
|
|
Tercio@11
|
2055 b:SetScript ("OnEnter", function (self)
|
|
Tercio@11
|
2056 GameCooltip2:Reset()
|
|
Tercio@11
|
2057 GameCooltip2:AddLine ("Send Feedback")
|
|
Tercio@11
|
2058 GameCooltip2:ShowCooltip (self, "tooltip")
|
|
Tercio@11
|
2059 end)
|
|
Tercio@11
|
2060 b:SetScript ("OnLeave", function (self)
|
|
Tercio@11
|
2061 GameCooltip2:Hide()
|
|
Tercio@11
|
2062 end)
|
|
Tercio@11
|
2063
|
|
Tercio@11
|
2064 return b
|
|
Tercio@11
|
2065 end
|
|
Tercio@11
|
2066
|
|
Tercio@11
|
2067 local backdrop_fb_line = {bgFile = DF.folder .. "background", edgeFile = DF.folder .. "border_3",
|
|
Tercio@11
|
2068 tile = true, tileSize = 64, edgeSize = 8, insets = {left = 2, right = 2, top = 2, bottom = 2}}
|
|
Tercio@11
|
2069
|
|
Tercio@11
|
2070 local on_enter_feedback = function (self)
|
|
Tercio@11
|
2071 self:SetBackdropColor (1, 1, 0, 0.5)
|
|
Tercio@11
|
2072 end
|
|
Tercio@11
|
2073 local on_leave_feedback = function (self)
|
|
Tercio@11
|
2074 self:SetBackdropColor (0, 0, 0, 0.3)
|
|
Tercio@11
|
2075 end
|
|
Tercio@11
|
2076
|
|
Tercio@11
|
2077 local on_click_feedback = function (self)
|
|
Tercio@11
|
2078
|
|
Tercio@11
|
2079 local feedback_link_textbox = DF.feedback_link_textbox
|
|
Tercio@11
|
2080
|
|
Tercio@11
|
2081 if (not feedback_link_textbox) then
|
|
Tercio@11
|
2082 local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
|
|
Tercio@11
|
2083 editbox:SetAutoFocus (false)
|
|
Tercio@11
|
2084 editbox:SetHook ("OnEditFocusGained", function()
|
|
Tercio@11
|
2085 editbox.text = editbox.link
|
|
Tercio@11
|
2086 editbox:HighlightText()
|
|
Tercio@11
|
2087 end)
|
|
Tercio@11
|
2088 editbox:SetHook ("OnEditFocusLost", function()
|
|
Tercio@11
|
2089 editbox:Hide()
|
|
Tercio@11
|
2090 end)
|
|
Tercio@11
|
2091 editbox:SetHook ("OnChar", function()
|
|
Tercio@11
|
2092 editbox.text = editbox.link
|
|
Tercio@11
|
2093 editbox:HighlightText()
|
|
Tercio@11
|
2094 end)
|
|
Tercio@11
|
2095 editbox.text = ""
|
|
Tercio@11
|
2096
|
|
Tercio@11
|
2097 DF.feedback_link_textbox = editbox
|
|
Tercio@11
|
2098 feedback_link_textbox = editbox
|
|
Tercio@11
|
2099 end
|
|
Tercio@11
|
2100
|
|
Tercio@11
|
2101 feedback_link_textbox.link = self.link
|
|
Tercio@11
|
2102 feedback_link_textbox.text = self.link
|
|
Tercio@11
|
2103 feedback_link_textbox:Show()
|
|
Tercio@11
|
2104
|
|
Tercio@11
|
2105 feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
|
|
Tercio@11
|
2106
|
|
Tercio@11
|
2107 feedback_link_textbox:HighlightText()
|
|
Tercio@11
|
2108
|
|
Tercio@11
|
2109 feedback_link_textbox:SetFocus()
|
|
Tercio@11
|
2110 feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
|
|
Tercio@11
|
2111 end
|
|
Tercio@11
|
2112
|
|
Tercio@11
|
2113 local feedback_get_fb_line = function (self)
|
|
Tercio@11
|
2114
|
|
Tercio@11
|
2115 local line = self.feedback_lines [self.next_feedback]
|
|
Tercio@11
|
2116 if (not line) then
|
|
Tercio@11
|
2117 line = CreateFrame ("frame", "AddonFeedbackPanelFB" .. self.next_feedback, self)
|
|
Tercio@11
|
2118 line:SetBackdrop (backdrop_fb_line)
|
|
Tercio@11
|
2119 line:SetBackdropColor (0, 0, 0, 0.3)
|
|
Tercio@11
|
2120 line:SetSize (390, 42)
|
|
Tercio@11
|
2121 line:SetPoint ("topleft", self.feedback_anchor, "bottomleft", 0, -5 + ((self.next_feedback-1) * 46 * -1))
|
|
Tercio@11
|
2122 line:SetScript ("OnEnter", on_enter_feedback)
|
|
Tercio@11
|
2123 line:SetScript ("OnLeave", on_leave_feedback)
|
|
Tercio@11
|
2124 line:SetScript ("OnMouseUp", on_click_feedback)
|
|
Tercio@11
|
2125
|
|
Tercio@11
|
2126 line.icon = line:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
2127 line.icon:SetSize (90, 36)
|
|
Tercio@11
|
2128
|
|
Tercio@11
|
2129 line.desc = line:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
|
|
Tercio@11
|
2130
|
|
Tercio@11
|
2131 line.icon:SetPoint ("left", line, "left", 5, 0)
|
|
Tercio@11
|
2132 line.desc:SetPoint ("left", line.icon, "right", 5, 0)
|
|
Tercio@11
|
2133
|
|
Tercio@11
|
2134 local arrow = line:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
2135 arrow:SetTexture ([[Interface\Buttons\JumpUpArrow]])
|
|
Tercio@11
|
2136 arrow:SetRotation (-1.55)
|
|
Tercio@11
|
2137 arrow:SetPoint ("right", line, "right", -5, 0)
|
|
Tercio@11
|
2138
|
|
Tercio@11
|
2139 self.feedback_lines [self.next_feedback] = line
|
|
Tercio@11
|
2140 end
|
|
Tercio@11
|
2141
|
|
Tercio@11
|
2142 self.next_feedback = self.next_feedback + 1
|
|
Tercio@11
|
2143
|
|
Tercio@11
|
2144 return line
|
|
Tercio@11
|
2145 end
|
|
Tercio@11
|
2146
|
|
Tercio@11
|
2147 local on_click_feedback = function (self)
|
|
Tercio@11
|
2148
|
|
Tercio@11
|
2149 local feedback_link_textbox = DF.feedback_link_textbox
|
|
Tercio@11
|
2150
|
|
Tercio@11
|
2151 if (not feedback_link_textbox) then
|
|
Tercio@11
|
2152 local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
|
|
Tercio@11
|
2153 editbox:SetAutoFocus (false)
|
|
Tercio@11
|
2154 editbox:SetHook ("OnEditFocusGained", function()
|
|
Tercio@11
|
2155 editbox.text = editbox.link
|
|
Tercio@11
|
2156 editbox:HighlightText()
|
|
Tercio@11
|
2157 end)
|
|
Tercio@11
|
2158 editbox:SetHook ("OnEditFocusLost", function()
|
|
Tercio@11
|
2159 editbox:Hide()
|
|
Tercio@11
|
2160 end)
|
|
Tercio@11
|
2161 editbox:SetHook ("OnChar", function()
|
|
Tercio@11
|
2162 editbox.text = editbox.link
|
|
Tercio@11
|
2163 editbox:HighlightText()
|
|
Tercio@11
|
2164 end)
|
|
Tercio@11
|
2165 editbox.text = ""
|
|
Tercio@11
|
2166
|
|
Tercio@11
|
2167 DF.feedback_link_textbox = editbox
|
|
Tercio@11
|
2168 feedback_link_textbox = editbox
|
|
Tercio@11
|
2169 end
|
|
Tercio@11
|
2170
|
|
Tercio@11
|
2171 feedback_link_textbox.link = self.link
|
|
Tercio@11
|
2172 feedback_link_textbox.text = self.link
|
|
Tercio@11
|
2173 feedback_link_textbox:Show()
|
|
Tercio@11
|
2174
|
|
Tercio@11
|
2175 feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
|
|
Tercio@11
|
2176
|
|
Tercio@11
|
2177 feedback_link_textbox:HighlightText()
|
|
Tercio@11
|
2178
|
|
Tercio@11
|
2179 feedback_link_textbox:SetFocus()
|
|
Tercio@11
|
2180 feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
|
|
Tercio@11
|
2181 end
|
|
Tercio@11
|
2182
|
|
Tercio@11
|
2183 local on_enter_addon = function (self)
|
|
Tercio@11
|
2184 if (self.tooltip) then
|
|
Tercio@11
|
2185 GameCooltip2:Preset (2)
|
|
Tercio@11
|
2186 GameCooltip2:AddLine ("|cFFFFFF00" .. self.name .. "|r")
|
|
Tercio@11
|
2187 GameCooltip2:AddLine ("")
|
|
Tercio@11
|
2188 GameCooltip2:AddLine (self.tooltip)
|
|
Tercio@11
|
2189 GameCooltip2:ShowCooltip (self, "tooltip")
|
|
Tercio@11
|
2190 end
|
|
Tercio@11
|
2191 self.icon:SetBlendMode ("ADD")
|
|
Tercio@11
|
2192 end
|
|
Tercio@11
|
2193 local on_leave_addon = function (self)
|
|
Tercio@11
|
2194 if (self.tooltip) then
|
|
Tercio@11
|
2195 GameCooltip2:Hide()
|
|
Tercio@11
|
2196 end
|
|
Tercio@11
|
2197 self.icon:SetBlendMode ("BLEND")
|
|
Tercio@11
|
2198 end
|
|
Tercio@11
|
2199 local on_click_addon = function (self)
|
|
Tercio@11
|
2200 local addon_link_textbox = DF.addon_link_textbox
|
|
Tercio@11
|
2201
|
|
Tercio@11
|
2202 if (not addon_link_textbox) then
|
|
Tercio@11
|
2203 local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 128, 64)
|
|
Tercio@11
|
2204 editbox:SetAutoFocus (false)
|
|
Tercio@11
|
2205 editbox:SetHook ("OnEditFocusGained", function()
|
|
Tercio@11
|
2206 editbox.text = editbox.link
|
|
Tercio@11
|
2207 editbox:HighlightText()
|
|
Tercio@11
|
2208 end)
|
|
Tercio@11
|
2209 editbox:SetHook ("OnEditFocusLost", function()
|
|
Tercio@11
|
2210 editbox:Hide()
|
|
Tercio@11
|
2211 end)
|
|
Tercio@11
|
2212 editbox:SetHook ("OnChar", function()
|
|
Tercio@11
|
2213 editbox.text = editbox.link
|
|
Tercio@11
|
2214 editbox:HighlightText()
|
|
Tercio@11
|
2215 end)
|
|
Tercio@11
|
2216 editbox.text = ""
|
|
Tercio@11
|
2217
|
|
Tercio@11
|
2218 DF.addon_link_textbox = editbox
|
|
Tercio@11
|
2219 addon_link_textbox = editbox
|
|
Tercio@11
|
2220 end
|
|
Tercio@11
|
2221
|
|
Tercio@11
|
2222 addon_link_textbox.link = self.link
|
|
Tercio@11
|
2223 addon_link_textbox.text = self.link
|
|
Tercio@11
|
2224 addon_link_textbox:Show()
|
|
Tercio@11
|
2225
|
|
Tercio@11
|
2226 addon_link_textbox:SetPoint ("topleft", self.icon, "topleft", 0, 0)
|
|
Tercio@11
|
2227
|
|
Tercio@11
|
2228 addon_link_textbox:HighlightText()
|
|
Tercio@11
|
2229
|
|
Tercio@11
|
2230 addon_link_textbox:SetFocus()
|
|
Tercio@11
|
2231 addon_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
|
|
Tercio@11
|
2232 end
|
|
Tercio@11
|
2233
|
|
Tercio@11
|
2234 local feedback_get_addons_line = function (self)
|
|
Tercio@11
|
2235 local line = self.addons_lines [self.next_addons]
|
|
Tercio@11
|
2236 if (not line) then
|
|
Tercio@11
|
2237
|
|
Tercio@11
|
2238 line = CreateFrame ("frame", "AddonFeedbackPanelSA" .. self.next_addons, self)
|
|
Tercio@11
|
2239 line:SetSize (128, 64)
|
|
Tercio@11
|
2240
|
|
Tercio@11
|
2241 if (self.next_addons == 1) then
|
|
Tercio@11
|
2242 line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5)
|
|
Tercio@11
|
2243 elseif (self.next_addons_line_break == self.next_addons) then
|
|
Tercio@11
|
2244 line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5 + floor (self.next_addons_line_break/3) * 66 * -1)
|
|
Tercio@11
|
2245 self.next_addons_line_break = self.next_addons_line_break + 3
|
|
Tercio@11
|
2246 else
|
|
Tercio@11
|
2247 local previous = self.addons_lines [self.next_addons - 1]
|
|
Tercio@11
|
2248 line:SetPoint ("topleft", previous, "topright", 2, 0)
|
|
Tercio@11
|
2249 end
|
|
Tercio@11
|
2250
|
|
Tercio@11
|
2251 line:SetScript ("OnEnter", on_enter_addon)
|
|
Tercio@11
|
2252 line:SetScript ("OnLeave", on_leave_addon)
|
|
Tercio@11
|
2253 line:SetScript ("OnMouseUp", on_click_addon)
|
|
Tercio@11
|
2254
|
|
Tercio@11
|
2255 line.icon = line:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
2256 line.icon:SetSize (128, 64)
|
|
Tercio@11
|
2257
|
|
Tercio@11
|
2258 line.icon:SetPoint ("topleft", line, "topleft", 0, 0)
|
|
Tercio@11
|
2259
|
|
Tercio@11
|
2260 self.addons_lines [self.next_addons] = line
|
|
Tercio@11
|
2261 end
|
|
Tercio@11
|
2262
|
|
Tercio@11
|
2263 self.next_addons = self.next_addons + 1
|
|
Tercio@11
|
2264
|
|
Tercio@11
|
2265 return line
|
|
Tercio@11
|
2266 end
|
|
Tercio@11
|
2267
|
|
Tercio@11
|
2268 local default_coords = {0, 1, 0, 1}
|
|
Tercio@11
|
2269 local feedback_add_fb = function (self, table)
|
|
Tercio@11
|
2270 local line = self:GetFeedbackLine()
|
|
Tercio@11
|
2271 line.icon:SetTexture (table.icon)
|
|
Tercio@11
|
2272 line.icon:SetTexCoord (unpack (table.coords or default_coords))
|
|
Tercio@11
|
2273 line.desc:SetText (table.desc)
|
|
Tercio@11
|
2274 line.link = table.link
|
|
Tercio@11
|
2275 line:Show()
|
|
Tercio@11
|
2276 end
|
|
Tercio@11
|
2277
|
|
Tercio@11
|
2278 local feedback_add_addon = function (self, table)
|
|
Tercio@11
|
2279 local block = self:GetAddonsLine()
|
|
Tercio@11
|
2280 block.icon:SetTexture (table.icon)
|
|
Tercio@11
|
2281 block.icon:SetTexCoord (unpack (table.coords or default_coords))
|
|
Tercio@11
|
2282 block.link = table.link
|
|
Tercio@11
|
2283 block.tooltip = table.desc
|
|
Tercio@11
|
2284 block.name = table.name
|
|
Tercio@11
|
2285 block:Show()
|
|
Tercio@11
|
2286 end
|
|
Tercio@11
|
2287
|
|
Tercio@11
|
2288 local feedback_hide_all = function (self)
|
|
Tercio@11
|
2289 self.next_feedback = 1
|
|
Tercio@11
|
2290 self.next_addons = 1
|
|
Tercio@11
|
2291
|
|
Tercio@11
|
2292 for index, line in ipairs (self.feedback_lines) do
|
|
Tercio@11
|
2293 line:Hide()
|
|
Tercio@11
|
2294 end
|
|
Tercio@11
|
2295
|
|
Tercio@11
|
2296 for index, line in ipairs (self.addons_lines) do
|
|
Tercio@11
|
2297 line:Hide()
|
|
Tercio@11
|
2298 end
|
|
Tercio@11
|
2299 end
|
|
Tercio@11
|
2300
|
|
Tercio@11
|
2301 -- feedback_methods = { { icon = icon path, desc = description, link = url}}
|
|
Tercio@11
|
2302 function DF:ShowFeedbackPanel (addon_name, version, feedback_methods, more_addons)
|
|
Tercio@11
|
2303
|
|
Tercio@11
|
2304 local f = _G.AddonFeedbackPanel
|
|
Tercio@11
|
2305
|
|
Tercio@11
|
2306 if (not f) then
|
|
Tercio@11
|
2307 f = DF:Create1PxPanel (UIParent, 400, 100, addon_name .. " Feedback", "AddonFeedbackPanel", nil)
|
|
Tercio@11
|
2308 f:SetFrameStrata ("FULLSCREEN")
|
|
Tercio@11
|
2309 f:SetPoint ("center", UIParent, "center")
|
|
Tercio@11
|
2310 f:SetBackdropColor (0, 0, 0, 0.8)
|
|
Tercio@11
|
2311 f.feedback_lines = {}
|
|
Tercio@11
|
2312 f.addons_lines = {}
|
|
Tercio@11
|
2313 f.next_feedback = 1
|
|
Tercio@11
|
2314 f.next_addons = 1
|
|
Tercio@11
|
2315 f.next_addons_line_break = 4
|
|
Tercio@11
|
2316
|
|
Tercio@11
|
2317 local feedback_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@11
|
2318 feedback_anchor:SetText ("Feedback:")
|
|
Tercio@11
|
2319 feedback_anchor:SetPoint ("topleft", f, "topleft", 5, -30)
|
|
Tercio@11
|
2320 f.feedback_anchor = feedback_anchor
|
|
Tercio@11
|
2321 local excla_text = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@11
|
2322 excla_text:SetText ("click and copy the link")
|
|
Tercio@11
|
2323 excla_text:SetPoint ("topright", f, "topright", -5, -30)
|
|
Tercio@11
|
2324 excla_text:SetTextColor (1, 0.8, 0.2, 0.6)
|
|
Tercio@11
|
2325
|
|
Tercio@11
|
2326 local addons_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@11
|
2327 addons_anchor:SetText ("AddOns From the Same Author:")
|
|
Tercio@11
|
2328 f.addons_anchor = addons_anchor
|
|
Tercio@11
|
2329 local excla_text2 = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@11
|
2330 excla_text2:SetText ("click and copy the link")
|
|
Tercio@11
|
2331 excla_text2:SetTextColor (1, 0.8, 0.2, 0.6)
|
|
Tercio@11
|
2332 f.excla_text2 = excla_text2
|
|
Tercio@11
|
2333
|
|
Tercio@11
|
2334 f.GetFeedbackLine = feedback_get_fb_line
|
|
Tercio@11
|
2335 f.GetAddonsLine = feedback_get_addons_line
|
|
Tercio@11
|
2336 f.AddFeedbackMethod = feedback_add_fb
|
|
Tercio@11
|
2337 f.AddOtherAddon = feedback_add_addon
|
|
Tercio@11
|
2338 f.HideAll = feedback_hide_all
|
|
Tercio@11
|
2339
|
|
Tercio@11
|
2340 DF:SetFontSize (f.Title, 14)
|
|
Tercio@11
|
2341
|
|
Tercio@11
|
2342 end
|
|
Tercio@11
|
2343
|
|
Tercio@11
|
2344 f:HideAll()
|
|
Tercio@11
|
2345 f:SetTitle (addon_name)
|
|
Tercio@11
|
2346
|
|
Tercio@11
|
2347 for index, feedback in ipairs (feedback_methods) do
|
|
Tercio@11
|
2348 f:AddFeedbackMethod (feedback)
|
|
Tercio@11
|
2349 end
|
|
Tercio@11
|
2350
|
|
Tercio@11
|
2351 f.addons_anchor:SetPoint ("topleft", f, "topleft", 5, f.next_feedback * 50 * -1)
|
|
Tercio@11
|
2352 f.excla_text2:SetPoint ("topright", f, "topright", -5, f.next_feedback * 50 * -1)
|
|
Tercio@11
|
2353
|
|
Tercio@11
|
2354 for index, addon in ipairs (more_addons) do
|
|
Tercio@11
|
2355 f:AddOtherAddon (addon)
|
|
Tercio@11
|
2356 end
|
|
Tercio@11
|
2357
|
|
Tercio@11
|
2358 f:SetHeight (80 + ((f.next_feedback-1) * 50) + (ceil ((f.next_addons-1)/3) * 66))
|
|
Tercio@11
|
2359
|
|
Tercio@11
|
2360 f:Show()
|
|
Tercio@11
|
2361
|
|
Tercio@11
|
2362 return true
|
|
Tercio@11
|
2363 end
|
|
Tercio@11
|
2364
|
|
Tercio@11
|
2365
|
|
Tercio@11
|
2366 ------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
2367 --> chart panel -- ~chart
|
|
Tercio@11
|
2368
|
|
Tercio@11
|
2369 local chart_panel_backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
|
|
Tercio@11
|
2370 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 32, insets = {left = 5, right = 5, top = 5, bottom = 5}}
|
|
Tercio@11
|
2371
|
|
Tercio@11
|
2372 local chart_panel_align_timelabels = function (self, elapsed_time)
|
|
Tercio@11
|
2373
|
|
Tercio@11
|
2374 self.TimeScale = elapsed_time
|
|
Tercio@11
|
2375
|
|
Tercio@11
|
2376 local linha = self.TimeLabels [17]
|
|
Tercio@11
|
2377 local minutos, segundos = math.floor (elapsed_time / 60), math.floor (elapsed_time % 60)
|
|
Tercio@11
|
2378 if (segundos < 10) then
|
|
Tercio@11
|
2379 segundos = "0" .. segundos
|
|
Tercio@11
|
2380 end
|
|
Tercio@11
|
2381
|
|
Tercio@11
|
2382 if (minutos > 0) then
|
|
Tercio@11
|
2383 if (minutos < 10) then
|
|
Tercio@11
|
2384 minutos = "0" .. minutos
|
|
Tercio@11
|
2385 end
|
|
Tercio@11
|
2386 linha:SetText (minutos .. ":" .. segundos)
|
|
Tercio@11
|
2387 else
|
|
Tercio@11
|
2388 linha:SetText ("00:" .. segundos)
|
|
Tercio@11
|
2389 end
|
|
Tercio@11
|
2390
|
|
Tercio@11
|
2391 local time_div = elapsed_time / 16 --786 -- 49.125
|
|
Tercio@11
|
2392
|
|
Tercio@11
|
2393 for i = 2, 16 do
|
|
Tercio@11
|
2394
|
|
Tercio@11
|
2395 local linha = self.TimeLabels [i]
|
|
Tercio@11
|
2396
|
|
Tercio@11
|
2397 local this_time = time_div * (i-1)
|
|
Tercio@11
|
2398 local minutos, segundos = math.floor (this_time / 60), math.floor (this_time % 60)
|
|
Tercio@11
|
2399
|
|
Tercio@11
|
2400 if (segundos < 10) then
|
|
Tercio@11
|
2401 segundos = "0" .. segundos
|
|
Tercio@11
|
2402 end
|
|
Tercio@11
|
2403
|
|
Tercio@11
|
2404 if (minutos > 0) then
|
|
Tercio@11
|
2405 if (minutos < 10) then
|
|
Tercio@11
|
2406 minutos = "0" .. minutos
|
|
Tercio@11
|
2407 end
|
|
Tercio@11
|
2408 linha:SetText (minutos .. ":" .. segundos)
|
|
Tercio@11
|
2409 else
|
|
Tercio@11
|
2410 linha:SetText ("00:" .. segundos)
|
|
Tercio@11
|
2411 end
|
|
Tercio@11
|
2412
|
|
Tercio@11
|
2413 end
|
|
Tercio@11
|
2414
|
|
Tercio@11
|
2415 end
|
|
Tercio@11
|
2416
|
|
Tercio@11
|
2417 local chart_panel_set_scale = function (self, amt, func, text)
|
|
Tercio@22
|
2418
|
|
Tercio@11
|
2419 if (type (amt) ~= "number") then
|
|
Tercio@11
|
2420 return
|
|
Tercio@11
|
2421 end
|
|
Tercio@11
|
2422
|
|
Tercio@11
|
2423 local piece = amt / 1000 / 8
|
|
Tercio@22
|
2424 if (not text or text == "") then
|
|
Tercio@22
|
2425 text = amt > 1000000 and "M" or amt > 1000 and "K"
|
|
Tercio@22
|
2426 end
|
|
Tercio@11
|
2427
|
|
Tercio@11
|
2428 for i = 1, 8 do
|
|
Tercio@11
|
2429 if (func) then
|
|
Tercio@11
|
2430 self ["dpsamt" .. math.abs (i-9)]:SetText ( func (piece*i) .. (text or ""))
|
|
Tercio@11
|
2431 else
|
|
Tercio@11
|
2432 if (piece*i > 1) then
|
|
Tercio@22
|
2433 self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.1f", piece*i) .. (text or ""))
|
|
Tercio@11
|
2434 else
|
|
Tercio@11
|
2435 self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.3f", piece*i) .. (text or ""))
|
|
Tercio@11
|
2436 end
|
|
Tercio@11
|
2437 end
|
|
Tercio@11
|
2438 end
|
|
Tercio@11
|
2439 end
|
|
Tercio@11
|
2440
|
|
Tercio@11
|
2441 local chart_panel_can_move = function (self, can)
|
|
Tercio@11
|
2442 self.can_move = can
|
|
Tercio@11
|
2443 end
|
|
Tercio@11
|
2444
|
|
Tercio@11
|
2445 local chart_panel_overlay_reset = function (self)
|
|
Tercio@11
|
2446 self.OverlaysAmount = 1
|
|
Tercio@11
|
2447 for index, pack in ipairs (self.Overlays) do
|
|
Tercio@11
|
2448 for index2, texture in ipairs (pack) do
|
|
Tercio@11
|
2449 texture:Hide()
|
|
Tercio@11
|
2450 end
|
|
Tercio@11
|
2451 end
|
|
Tercio@11
|
2452 end
|
|
Tercio@11
|
2453
|
|
Tercio@11
|
2454 local chart_panel_reset = function (self)
|
|
Tercio@11
|
2455
|
|
Tercio@11
|
2456 self.Graphic:ResetData()
|
|
Tercio@11
|
2457 self.Graphic.max_value = 0
|
|
Tercio@11
|
2458
|
|
Tercio@11
|
2459 self.TimeScale = nil
|
|
Tercio@11
|
2460 self.BoxLabelsAmount = 1
|
|
Tercio@11
|
2461 table.wipe (self.GData)
|
|
Tercio@11
|
2462 table.wipe (self.OData)
|
|
Tercio@11
|
2463
|
|
Tercio@11
|
2464 for index, box in ipairs (self.BoxLabels) do
|
|
Tercio@11
|
2465 box.check:Hide()
|
|
Tercio@11
|
2466 box.button:Hide()
|
|
Tercio@11
|
2467 box.box:Hide()
|
|
Tercio@11
|
2468 box.text:Hide()
|
|
Tercio@11
|
2469 box.border:Hide()
|
|
Tercio@11
|
2470 box.showing = false
|
|
Tercio@11
|
2471 end
|
|
Tercio@11
|
2472
|
|
Tercio@11
|
2473 chart_panel_overlay_reset (self)
|
|
Tercio@11
|
2474 end
|
|
Tercio@11
|
2475
|
|
Tercio@11
|
2476 local chart_panel_enable_line = function (f, thisbox)
|
|
Tercio@11
|
2477
|
|
Tercio@11
|
2478 local index = thisbox.index
|
|
Tercio@11
|
2479 local type = thisbox.type
|
|
Tercio@11
|
2480
|
|
Tercio@11
|
2481 if (thisbox.enabled) then
|
|
Tercio@11
|
2482 --disable
|
|
Tercio@11
|
2483 thisbox.check:Hide()
|
|
Tercio@11
|
2484 thisbox.enabled = false
|
|
Tercio@11
|
2485 else
|
|
Tercio@11
|
2486 --enable
|
|
Tercio@11
|
2487 thisbox.check:Show()
|
|
Tercio@11
|
2488 thisbox.enabled = true
|
|
Tercio@11
|
2489 end
|
|
Tercio@11
|
2490
|
|
Tercio@11
|
2491 if (type == "graphic") then
|
|
Tercio@11
|
2492
|
|
Tercio@11
|
2493 f.Graphic:ResetData()
|
|
Tercio@11
|
2494 f.Graphic.max_value = 0
|
|
Tercio@11
|
2495
|
|
Tercio@11
|
2496 local max = 0
|
|
Tercio@11
|
2497 local max_time = 0
|
|
Tercio@11
|
2498
|
|
Tercio@11
|
2499 for index, box in ipairs (f.BoxLabels) do
|
|
Tercio@11
|
2500 if (box.type == type and box.showing and box.enabled) then
|
|
Tercio@11
|
2501 local data = f.GData [index]
|
|
Tercio@11
|
2502
|
|
Tercio@11
|
2503 f.Graphic:AddDataSeries (data[1], data[2], nil, data[3])
|
|
Tercio@11
|
2504
|
|
Tercio@11
|
2505 if (data[4] > max) then
|
|
Tercio@11
|
2506 max = data[4]
|
|
Tercio@11
|
2507 end
|
|
Tercio@11
|
2508 if (data [5] > max_time) then
|
|
Tercio@11
|
2509 max_time = data [5]
|
|
Tercio@11
|
2510 end
|
|
Tercio@11
|
2511 end
|
|
Tercio@11
|
2512 end
|
|
Tercio@11
|
2513
|
|
Tercio@11
|
2514 f:SetScale (max)
|
|
Tercio@11
|
2515 f:SetTime (max_time)
|
|
Tercio@11
|
2516
|
|
Tercio@11
|
2517 elseif (type == "overlay") then
|
|
Tercio@11
|
2518
|
|
Tercio@11
|
2519 chart_panel_overlay_reset (f)
|
|
Tercio@11
|
2520
|
|
Tercio@11
|
2521 for index, box in ipairs (f.BoxLabels) do
|
|
Tercio@11
|
2522 if (box.type == type and box.showing and box.enabled) then
|
|
Tercio@11
|
2523
|
|
Tercio@11
|
2524 f:AddOverlay (box.index)
|
|
Tercio@11
|
2525
|
|
Tercio@11
|
2526 end
|
|
Tercio@11
|
2527 end
|
|
Tercio@11
|
2528
|
|
Tercio@11
|
2529 end
|
|
Tercio@11
|
2530 end
|
|
Tercio@11
|
2531
|
|
Tercio@11
|
2532 local create_box = function (self, next_box)
|
|
Tercio@11
|
2533
|
|
Tercio@11
|
2534 local thisbox = {}
|
|
Tercio@11
|
2535 self.BoxLabels [next_box] = thisbox
|
|
Tercio@11
|
2536
|
|
Tercio@11
|
2537 local box = DF:NewImage (self.Graphic, nil, 16, 16, "border")
|
|
Tercio@11
|
2538
|
|
Tercio@11
|
2539 local text = DF:NewLabel (self.Graphic)
|
|
Tercio@11
|
2540
|
|
Tercio@11
|
2541 local border = DF:NewImage (self.Graphic, [[Interface\DialogFrame\UI-DialogBox-Gold-Corner]], 30, 30, "artwork")
|
|
Tercio@11
|
2542 border:SetPoint ("center", box, "center", -3, -4)
|
|
Tercio@11
|
2543 border:SetTexture ([[Interface\DialogFrame\UI-DialogBox-Gold-Corner]])
|
|
Tercio@11
|
2544
|
|
Tercio@11
|
2545 local checktexture = DF:NewImage (self.Graphic, [[Interface\Buttons\UI-CheckBox-Check]], 18, 18, "overlay")
|
|
Tercio@11
|
2546 checktexture:SetPoint ("center", box, "center", -1, -1)
|
|
Tercio@11
|
2547 checktexture:SetTexture ([[Interface\Buttons\UI-CheckBox-Check]])
|
|
Tercio@11
|
2548
|
|
Tercio@11
|
2549 thisbox.box = box
|
|
Tercio@11
|
2550 thisbox.text = text
|
|
Tercio@11
|
2551 thisbox.border = border
|
|
Tercio@11
|
2552 thisbox.check = checktexture
|
|
Tercio@11
|
2553 thisbox.enabled = true
|
|
Tercio@11
|
2554
|
|
Tercio@11
|
2555 local button = CreateFrame ("button", nil, self.Graphic)
|
|
Tercio@11
|
2556 button:SetSize (20, 20)
|
|
Tercio@11
|
2557 button:SetScript ("OnClick", function()
|
|
Tercio@11
|
2558 chart_panel_enable_line (self, thisbox)
|
|
Tercio@11
|
2559 end)
|
|
Tercio@22
|
2560 button:SetPoint ("center", box.widget or box, "center")
|
|
Tercio@11
|
2561
|
|
Tercio@11
|
2562 thisbox.button = button
|
|
Tercio@11
|
2563
|
|
Tercio@11
|
2564 thisbox.box:SetPoint ("right", text, "left", -4, 0)
|
|
Tercio@11
|
2565
|
|
Tercio@11
|
2566 if (next_box == 1) then
|
|
Tercio@11
|
2567 thisbox.text:SetPoint ("topright", self, "topright", -35, -16)
|
|
Tercio@11
|
2568 else
|
|
Tercio@11
|
2569 thisbox.text:SetPoint ("right", self.BoxLabels [next_box-1].box, "left", -7, 0)
|
|
Tercio@11
|
2570 end
|
|
Tercio@11
|
2571
|
|
Tercio@11
|
2572 return thisbox
|
|
Tercio@11
|
2573
|
|
Tercio@11
|
2574 end
|
|
Tercio@11
|
2575
|
|
Tercio@11
|
2576 local realign_labels = function (self)
|
|
Tercio@11
|
2577
|
|
Tercio@11
|
2578 local width = self:GetWidth() - 108
|
|
Tercio@11
|
2579
|
|
Tercio@11
|
2580 local first_box = self.BoxLabels [1]
|
|
Tercio@11
|
2581 first_box.text:SetPoint ("topright", self, "topright", -35, -16)
|
|
Tercio@11
|
2582
|
|
Tercio@11
|
2583 local line_width = first_box.text:GetStringWidth() + 26
|
|
Tercio@11
|
2584
|
|
Tercio@11
|
2585 for i = 2, #self.BoxLabels do
|
|
Tercio@11
|
2586
|
|
Tercio@11
|
2587 local box = self.BoxLabels [i]
|
|
Tercio@11
|
2588
|
|
Tercio@11
|
2589 if (box.box:IsShown()) then
|
|
Tercio@11
|
2590
|
|
Tercio@11
|
2591 line_width = line_width + box.text:GetStringWidth() + 26
|
|
Tercio@11
|
2592
|
|
Tercio@11
|
2593 if (line_width > width) then
|
|
Tercio@11
|
2594 line_width = box.text:GetStringWidth() + 26
|
|
Tercio@11
|
2595 box.text:SetPoint ("topright", self, "topright", -35, -40)
|
|
Tercio@11
|
2596 else
|
|
Tercio@11
|
2597 box.text:SetPoint ("right", self.BoxLabels [i-1].box, "left", -7, 0)
|
|
Tercio@11
|
2598 end
|
|
Tercio@11
|
2599 else
|
|
Tercio@11
|
2600 break
|
|
Tercio@11
|
2601 end
|
|
Tercio@11
|
2602 end
|
|
Tercio@11
|
2603
|
|
Tercio@11
|
2604 end
|
|
Tercio@11
|
2605
|
|
Tercio@11
|
2606 local chart_panel_add_label = function (self, color, name, type, number)
|
|
Tercio@11
|
2607
|
|
Tercio@11
|
2608 local next_box = self.BoxLabelsAmount
|
|
Tercio@11
|
2609 local thisbox = self.BoxLabels [next_box]
|
|
Tercio@11
|
2610
|
|
Tercio@11
|
2611 if (not thisbox) then
|
|
Tercio@11
|
2612 thisbox = create_box (self, next_box)
|
|
Tercio@11
|
2613 end
|
|
Tercio@11
|
2614
|
|
Tercio@11
|
2615 self.BoxLabelsAmount = self.BoxLabelsAmount + 1
|
|
Tercio@11
|
2616
|
|
Tercio@11
|
2617 thisbox.type = type
|
|
Tercio@11
|
2618 thisbox.index = number
|
|
Tercio@11
|
2619
|
|
Tercio@39
|
2620 thisbox.box:SetColorTexture (unpack (color))
|
|
Tercio@11
|
2621 thisbox.text:SetText (name)
|
|
Tercio@11
|
2622
|
|
Tercio@11
|
2623 thisbox.check:Show()
|
|
Tercio@11
|
2624 thisbox.button:Show()
|
|
Tercio@11
|
2625 thisbox.border:Show()
|
|
Tercio@11
|
2626 thisbox.box:Show()
|
|
Tercio@11
|
2627 thisbox.text:Show()
|
|
Tercio@11
|
2628
|
|
Tercio@11
|
2629 thisbox.showing = true
|
|
Tercio@11
|
2630 thisbox.enabled = true
|
|
Tercio@11
|
2631
|
|
Tercio@11
|
2632 realign_labels (self)
|
|
Tercio@11
|
2633
|
|
Tercio@11
|
2634 end
|
|
Tercio@11
|
2635
|
|
Tercio@11
|
2636 local line_default_color = {1, 1, 1}
|
|
Tercio@11
|
2637 local draw_overlay = function (self, this_overlay, overlayData, color)
|
|
Tercio@11
|
2638
|
|
Tercio@11
|
2639 local pixel = self.Graphic:GetWidth() / self.TimeScale
|
|
Tercio@11
|
2640 local index = 1
|
|
Tercio@40
|
2641 local r, g, b = unpack (color or line_default_color)
|
|
Tercio@11
|
2642
|
|
Tercio@11
|
2643 for i = 1, #overlayData, 2 do
|
|
Tercio@11
|
2644 local aura_start = overlayData [i]
|
|
Tercio@11
|
2645 local aura_end = overlayData [i+1]
|
|
Tercio@11
|
2646
|
|
Tercio@11
|
2647 local this_block = this_overlay [index]
|
|
Tercio@11
|
2648 if (not this_block) then
|
|
Tercio@11
|
2649 this_block = self.Graphic:CreateTexture (nil, "border")
|
|
Tercio@11
|
2650 tinsert (this_overlay, this_block)
|
|
Tercio@11
|
2651 end
|
|
Tercio@11
|
2652 this_block:SetHeight (self.Graphic:GetHeight())
|
|
Tercio@11
|
2653
|
|
Tercio@11
|
2654 this_block:SetPoint ("left", self.Graphic, "left", pixel * aura_start, 0)
|
|
Tercio@11
|
2655 if (aura_end) then
|
|
Tercio@11
|
2656 this_block:SetWidth ((aura_end-aura_start)*pixel)
|
|
Tercio@11
|
2657 else
|
|
Tercio@11
|
2658 --malformed table
|
|
Tercio@11
|
2659 this_block:SetWidth (pixel*5)
|
|
Tercio@11
|
2660 end
|
|
Tercio@11
|
2661
|
|
Tercio@39
|
2662 this_block:SetColorTexture (r, g, b, 0.25)
|
|
Tercio@11
|
2663 this_block:Show()
|
|
Tercio@11
|
2664
|
|
Tercio@11
|
2665 index = index + 1
|
|
Tercio@11
|
2666 end
|
|
Tercio@11
|
2667
|
|
Tercio@11
|
2668 end
|
|
Tercio@11
|
2669
|
|
Tercio@11
|
2670 local chart_panel_add_overlay = function (self, overlayData, color, name, icon)
|
|
Tercio@11
|
2671
|
|
Tercio@11
|
2672 if (not self.TimeScale) then
|
|
Tercio@11
|
2673 error ("Use SetTime (time) before adding an overlay.")
|
|
Tercio@11
|
2674 end
|
|
Tercio@11
|
2675
|
|
Tercio@11
|
2676 if (type (overlayData) == "number") then
|
|
Tercio@11
|
2677 local overlay_index = overlayData
|
|
Tercio@11
|
2678 draw_overlay (self, self.Overlays [self.OverlaysAmount], self.OData [overlay_index][1], self.OData [overlay_index][2])
|
|
Tercio@11
|
2679 else
|
|
Tercio@11
|
2680 local this_overlay = self.Overlays [self.OverlaysAmount]
|
|
Tercio@11
|
2681 if (not this_overlay) then
|
|
Tercio@11
|
2682 this_overlay = {}
|
|
Tercio@11
|
2683 tinsert (self.Overlays, this_overlay)
|
|
Tercio@11
|
2684 end
|
|
Tercio@11
|
2685
|
|
Tercio@11
|
2686 draw_overlay (self, this_overlay, overlayData, color)
|
|
Tercio@11
|
2687
|
|
Tercio@11
|
2688 tinsert (self.OData, {overlayData, color or line_default_color})
|
|
Tercio@11
|
2689 if (name) then
|
|
Tercio@11
|
2690 self:AddLabel (color or line_default_color, name, "overlay", #self.OData)
|
|
Tercio@11
|
2691 end
|
|
Tercio@11
|
2692 end
|
|
Tercio@11
|
2693
|
|
Tercio@11
|
2694 self.OverlaysAmount = self.OverlaysAmount + 1
|
|
Tercio@11
|
2695 end
|
|
Tercio@11
|
2696
|
|
Tercio@11
|
2697 local SMA_table = {}
|
|
Tercio@11
|
2698 local SMA_max = 0
|
|
Tercio@11
|
2699 local reset_SMA = function()
|
|
Tercio@11
|
2700 table.wipe (SMA_table)
|
|
Tercio@11
|
2701 SMA_max = 0
|
|
Tercio@11
|
2702 end
|
|
Tercio@11
|
2703
|
|
Tercio@11
|
2704 local calc_SMA
|
|
Tercio@11
|
2705 calc_SMA = function (a, b, ...)
|
|
Tercio@11
|
2706 if (b) then
|
|
Tercio@11
|
2707 return calc_SMA (a + b, ...)
|
|
Tercio@11
|
2708 else
|
|
Tercio@11
|
2709 return a
|
|
Tercio@11
|
2710 end
|
|
Tercio@11
|
2711 end
|
|
Tercio@11
|
2712
|
|
Tercio@11
|
2713 local do_SMA = function (value, max_value)
|
|
Tercio@11
|
2714
|
|
Tercio@11
|
2715 if (#SMA_table == 10) then
|
|
Tercio@11
|
2716 tremove (SMA_table, 1)
|
|
Tercio@11
|
2717 end
|
|
Tercio@11
|
2718
|
|
Tercio@11
|
2719 SMA_table [#SMA_table + 1] = value
|
|
Tercio@11
|
2720
|
|
Tercio@11
|
2721 local new_value = calc_SMA (unpack (SMA_table)) / #SMA_table
|
|
Tercio@11
|
2722
|
|
Tercio@11
|
2723 if (new_value > SMA_max) then
|
|
Tercio@11
|
2724 SMA_max = new_value
|
|
Tercio@11
|
2725 return new_value, SMA_max
|
|
Tercio@11
|
2726 else
|
|
Tercio@11
|
2727 return new_value
|
|
Tercio@11
|
2728 end
|
|
Tercio@11
|
2729
|
|
Tercio@11
|
2730 end
|
|
Tercio@11
|
2731
|
|
Tercio@55
|
2732 local chart_panel_onresize = function (self)
|
|
Tercio@55
|
2733 local width, height = self:GetSize()
|
|
Tercio@55
|
2734 local spacement = width - 78 - 60
|
|
Tercio@55
|
2735 spacement = spacement / 16
|
|
Tercio@55
|
2736
|
|
Tercio@55
|
2737 for i = 1, 17 do
|
|
Tercio@55
|
2738 local label = self.TimeLabels [i]
|
|
Tercio@55
|
2739 label:SetPoint ("bottomleft", self, "bottomleft", 78 + ((i-1)*spacement), 13)
|
|
Tercio@55
|
2740 label.line:SetHeight (height - 45)
|
|
Tercio@55
|
2741 end
|
|
Tercio@55
|
2742
|
|
Tercio@55
|
2743 local spacement = (self.Graphic:GetHeight()) / 8
|
|
Tercio@55
|
2744 for i = 1, 8 do
|
|
Tercio@55
|
2745 self ["dpsamt"..i]:SetPoint ("TOPLEFT", self, "TOPLEFT", 27, -25 + (-(spacement* (i-1))) )
|
|
Tercio@55
|
2746 self ["dpsamt"..i].line:SetWidth (width-20)
|
|
Tercio@55
|
2747 end
|
|
Tercio@55
|
2748
|
|
Tercio@55
|
2749 self.Graphic:SetSize (width - 135, height - 67)
|
|
Tercio@55
|
2750 self.Graphic:SetPoint ("topleft", self, "topleft", 108, -35)
|
|
Tercio@55
|
2751 end
|
|
Tercio@55
|
2752
|
|
Tercio@11
|
2753 local chart_panel_add_data = function (self, graphicData, color, name, elapsed_time, lineTexture, smoothLevel, firstIndex)
|
|
Tercio@11
|
2754
|
|
Tercio@11
|
2755 local f = self
|
|
Tercio@11
|
2756 self = self.Graphic
|
|
Tercio@22
|
2757
|
|
Tercio@11
|
2758 local _data = {}
|
|
Tercio@11
|
2759 local max_value = graphicData.max_value
|
|
Tercio@11
|
2760 local amount = #graphicData
|
|
Tercio@11
|
2761
|
|
Tercio@11
|
2762 local scaleW = 1/self:GetWidth()
|
|
Tercio@11
|
2763
|
|
Tercio@11
|
2764 local content = graphicData
|
|
Tercio@11
|
2765 tinsert (content, 1, 0)
|
|
Tercio@11
|
2766 tinsert (content, 1, 0)
|
|
Tercio@11
|
2767 tinsert (content, #content+1, 0)
|
|
Tercio@11
|
2768 tinsert (content, #content+1, 0)
|
|
Tercio@11
|
2769
|
|
Tercio@11
|
2770 local _i = 3
|
|
Tercio@11
|
2771
|
|
Tercio@11
|
2772 local graphMaxDps = math.max (self.max_value, max_value)
|
|
Tercio@11
|
2773
|
|
Tercio@11
|
2774 if (not smoothLevel) then
|
|
Tercio@11
|
2775 while (_i <= #content-2) do
|
|
Tercio@11
|
2776 local v = (content[_i-2]+content[_i-1]+content[_i]+content[_i+1]+content[_i+2])/5 --> normalize
|
|
Tercio@11
|
2777 _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
|
|
Tercio@11
|
2778 _i = _i + 1
|
|
Tercio@11
|
2779 end
|
|
Tercio@11
|
2780
|
|
Tercio@11
|
2781 elseif (smoothLevel == "SHORT") then
|
|
Tercio@11
|
2782 while (_i <= #content-2) do
|
|
Tercio@11
|
2783 local value = (content[_i] + content[_i+1]) / 2
|
|
Tercio@11
|
2784 _data [#_data+1] = {scaleW*(_i-2), value}
|
|
Tercio@11
|
2785 _data [#_data+1] = {scaleW*(_i-2), value}
|
|
Tercio@11
|
2786 _i = _i + 2
|
|
Tercio@11
|
2787 end
|
|
Tercio@11
|
2788
|
|
Tercio@11
|
2789 elseif (smoothLevel == "SMA") then
|
|
Tercio@11
|
2790 reset_SMA()
|
|
Tercio@11
|
2791 while (_i <= #content-2) do
|
|
Tercio@11
|
2792 local value, is_new_max_value = do_SMA (content[_i], max_value)
|
|
Tercio@11
|
2793 if (is_new_max_value) then
|
|
Tercio@11
|
2794 max_value = is_new_max_value
|
|
Tercio@11
|
2795 end
|
|
Tercio@11
|
2796 _data [#_data+1] = {scaleW*(_i-2), value} --> x and y coords
|
|
Tercio@11
|
2797 _i = _i + 1
|
|
Tercio@11
|
2798 end
|
|
Tercio@11
|
2799
|
|
Tercio@11
|
2800 elseif (smoothLevel == -1) then
|
|
Tercio@11
|
2801 while (_i <= #content-2) do
|
|
Tercio@11
|
2802 local current = content[_i]
|
|
Tercio@11
|
2803
|
|
Tercio@11
|
2804 local minus_2 = content[_i-2] * 0.6
|
|
Tercio@11
|
2805 local minus_1 = content[_i-1] * 0.8
|
|
Tercio@11
|
2806 local plus_1 = content[_i+1] * 0.8
|
|
Tercio@11
|
2807 local plus_2 = content[_i+2] * 0.6
|
|
Tercio@11
|
2808
|
|
Tercio@11
|
2809 local v = (current + minus_2 + minus_1 + plus_1 + plus_2)/5 --> normalize
|
|
Tercio@11
|
2810 _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
|
|
Tercio@11
|
2811 _i = _i + 1
|
|
Tercio@11
|
2812 end
|
|
Tercio@11
|
2813
|
|
Tercio@11
|
2814 elseif (smoothLevel == 1) then
|
|
Tercio@11
|
2815 _i = 2
|
|
Tercio@11
|
2816 while (_i <= #content-1) do
|
|
Tercio@11
|
2817 local v = (content[_i-1]+content[_i]+content[_i+1])/3 --> normalize
|
|
Tercio@11
|
2818 _data [#_data+1] = {scaleW*(_i-1), v/graphMaxDps} --> x and y coords
|
|
Tercio@11
|
2819 _i = _i + 1
|
|
Tercio@11
|
2820 end
|
|
Tercio@11
|
2821
|
|
Tercio@11
|
2822 elseif (smoothLevel == 2) then
|
|
Tercio@11
|
2823 _i = 1
|
|
Tercio@11
|
2824 while (_i <= #content) do
|
|
Tercio@11
|
2825 local v = content[_i] --> do not normalize
|
|
Tercio@11
|
2826 _data [#_data+1] = {scaleW*(_i), v/graphMaxDps} --> x and y coords
|
|
Tercio@11
|
2827 _i = _i + 1
|
|
Tercio@11
|
2828 end
|
|
Tercio@11
|
2829
|
|
Tercio@11
|
2830 end
|
|
Tercio@11
|
2831
|
|
Tercio@11
|
2832 tremove (content, 1)
|
|
Tercio@11
|
2833 tremove (content, 1)
|
|
Tercio@11
|
2834 tremove (content, #graphicData)
|
|
Tercio@11
|
2835 tremove (content, #graphicData)
|
|
Tercio@11
|
2836
|
|
Tercio@11
|
2837 if (max_value > self.max_value) then
|
|
Tercio@11
|
2838 --> normalize previous data
|
|
Tercio@11
|
2839 if (self.max_value > 0) then
|
|
Tercio@11
|
2840 local normalizePercent = self.max_value / max_value
|
|
Tercio@11
|
2841 for dataIndex, Data in ipairs (self.Data) do
|
|
Tercio@11
|
2842 local Points = Data.Points
|
|
Tercio@11
|
2843 for i = 1, #Points do
|
|
Tercio@11
|
2844 Points[i][2] = Points[i][2]*normalizePercent
|
|
Tercio@11
|
2845 end
|
|
Tercio@11
|
2846 end
|
|
Tercio@11
|
2847 end
|
|
Tercio@11
|
2848
|
|
Tercio@11
|
2849 self.max_value = max_value
|
|
Tercio@11
|
2850 f:SetScale (max_value)
|
|
Tercio@11
|
2851
|
|
Tercio@11
|
2852 end
|
|
Tercio@11
|
2853
|
|
Tercio@11
|
2854 tinsert (f.GData, {_data, color or line_default_color, lineTexture, max_value, elapsed_time})
|
|
Tercio@11
|
2855 if (name) then
|
|
Tercio@11
|
2856 f:AddLabel (color or line_default_color, name, "graphic", #f.GData)
|
|
Tercio@11
|
2857 end
|
|
Tercio@11
|
2858
|
|
Tercio@11
|
2859 if (firstIndex) then
|
|
Tercio@11
|
2860 if (lineTexture) then
|
|
Tercio@11
|
2861 if (not lineTexture:find ("\\") and not lineTexture:find ("//")) then
|
|
Tercio@11
|
2862 local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)LibGraph%-2%.0%.lua")
|
|
Tercio@11
|
2863 if path then
|
|
Tercio@11
|
2864 lineTexture = "Interface\\AddOns\\" .. path .. lineTexture
|
|
Tercio@11
|
2865 else
|
|
Tercio@11
|
2866 lineTexture = nil
|
|
Tercio@11
|
2867 end
|
|
Tercio@11
|
2868 end
|
|
Tercio@11
|
2869 end
|
|
Tercio@11
|
2870
|
|
Tercio@11
|
2871 table.insert (self.Data, 1, {Points = _data, Color = color or line_default_color, lineTexture = lineTexture, ElapsedTime = elapsed_time})
|
|
Tercio@11
|
2872 self.NeedsUpdate = true
|
|
Tercio@11
|
2873 else
|
|
Tercio@11
|
2874 self:AddDataSeries (_data, color or line_default_color, nil, lineTexture)
|
|
Tercio@11
|
2875 self.Data [#self.Data].ElapsedTime = elapsed_time
|
|
Tercio@11
|
2876 end
|
|
Tercio@11
|
2877
|
|
Tercio@11
|
2878 local max_time = 0
|
|
Tercio@11
|
2879 for _, data in ipairs (self.Data) do
|
|
Tercio@11
|
2880 if (data.ElapsedTime > max_time) then
|
|
Tercio@11
|
2881 max_time = data.ElapsedTime
|
|
Tercio@11
|
2882 end
|
|
Tercio@11
|
2883 end
|
|
Tercio@11
|
2884
|
|
Tercio@11
|
2885 f:SetTime (max_time)
|
|
Tercio@11
|
2886
|
|
Tercio@55
|
2887 chart_panel_onresize (f)
|
|
Tercio@55
|
2888
|
|
Tercio@11
|
2889 end
|
|
Tercio@11
|
2890
|
|
Tercio@55
|
2891
|
|
Tercio@11
|
2892
|
|
Tercio@11
|
2893 local chart_panel_vlines_on = function (self)
|
|
Tercio@11
|
2894 for i = 1, 17 do
|
|
Tercio@11
|
2895 local label = self.TimeLabels [i]
|
|
Tercio@11
|
2896 label.line:Show()
|
|
Tercio@11
|
2897 end
|
|
Tercio@11
|
2898 end
|
|
Tercio@11
|
2899
|
|
Tercio@11
|
2900 local chart_panel_vlines_off = function (self)
|
|
Tercio@11
|
2901 for i = 1, 17 do
|
|
Tercio@11
|
2902 local label = self.TimeLabels [i]
|
|
Tercio@11
|
2903 label.line:Hide()
|
|
Tercio@11
|
2904 end
|
|
Tercio@11
|
2905 end
|
|
Tercio@11
|
2906
|
|
Tercio@11
|
2907 local chart_panel_set_title = function (self, title)
|
|
Tercio@11
|
2908 self.chart_title.text = title
|
|
Tercio@11
|
2909 end
|
|
Tercio@11
|
2910
|
|
Tercio@11
|
2911 local chart_panel_mousedown = function (self, button)
|
|
Tercio@11
|
2912 if (button == "LeftButton" and self.can_move) then
|
|
Tercio@11
|
2913 if (not self.isMoving) then
|
|
Tercio@11
|
2914 self:StartMoving()
|
|
Tercio@11
|
2915 self.isMoving = true
|
|
Tercio@11
|
2916 end
|
|
Tercio@11
|
2917 elseif (button == "RightButton" and not self.no_right_click_close) then
|
|
Tercio@11
|
2918 if (not self.isMoving) then
|
|
Tercio@11
|
2919 self:Hide()
|
|
Tercio@11
|
2920 end
|
|
Tercio@11
|
2921 end
|
|
Tercio@11
|
2922 end
|
|
Tercio@11
|
2923 local chart_panel_mouseup = function (self, button)
|
|
Tercio@11
|
2924 if (button == "LeftButton" and self.isMoving) then
|
|
Tercio@11
|
2925 self:StopMovingOrSizing()
|
|
Tercio@11
|
2926 self.isMoving = nil
|
|
Tercio@11
|
2927 end
|
|
Tercio@11
|
2928 end
|
|
Tercio@11
|
2929
|
|
Tercio@11
|
2930 local chart_panel_hide_close_button = function (self)
|
|
Tercio@11
|
2931 self.CloseButton:Hide()
|
|
Tercio@11
|
2932 end
|
|
Tercio@11
|
2933
|
|
Tercio@11
|
2934 local chart_panel_right_click_close = function (self, value)
|
|
Tercio@11
|
2935 if (type (value) == "boolean") then
|
|
Tercio@11
|
2936 if (value) then
|
|
Tercio@11
|
2937 self.no_right_click_close = nil
|
|
Tercio@11
|
2938 else
|
|
Tercio@11
|
2939 self.no_right_click_close = true
|
|
Tercio@11
|
2940 end
|
|
Tercio@11
|
2941 end
|
|
Tercio@11
|
2942 end
|
|
Tercio@11
|
2943
|
|
Tercio@11
|
2944 function DF:CreateChartPanel (parent, w, h, name)
|
|
Tercio@11
|
2945
|
|
Tercio@11
|
2946 if (not name) then
|
|
Tercio@11
|
2947 name = "DFPanel" .. DF.PanelCounter
|
|
Tercio@11
|
2948 DF.PanelCounter = DF.PanelCounter + 1
|
|
Tercio@11
|
2949 end
|
|
Tercio@11
|
2950
|
|
Tercio@11
|
2951 parent = parent or UIParent
|
|
Tercio@11
|
2952 w = w or 800
|
|
Tercio@11
|
2953 h = h or 500
|
|
Tercio@11
|
2954
|
|
Tercio@11
|
2955 local f = CreateFrame ("frame", name, parent)
|
|
Tercio@11
|
2956 f:SetSize (w or 500, h or 400)
|
|
Tercio@11
|
2957 f:EnableMouse (true)
|
|
Tercio@11
|
2958 f:SetMovable (true)
|
|
Tercio@11
|
2959
|
|
Tercio@11
|
2960 f:SetScript ("OnMouseDown", chart_panel_mousedown)
|
|
Tercio@11
|
2961 f:SetScript ("OnMouseUp", chart_panel_mouseup)
|
|
Tercio@11
|
2962
|
|
Tercio@11
|
2963 f:SetBackdrop (chart_panel_backdrop)
|
|
Tercio@11
|
2964 f:SetBackdropColor (.3, .3, .3, .3)
|
|
Tercio@11
|
2965
|
|
Tercio@11
|
2966 local c = CreateFrame ("Button", nil, f, "UIPanelCloseButton")
|
|
Tercio@11
|
2967 c:SetWidth (32)
|
|
Tercio@11
|
2968 c:SetHeight (32)
|
|
Tercio@11
|
2969 c:SetPoint ("TOPRIGHT", f, "TOPRIGHT", -3, -7)
|
|
Tercio@11
|
2970 c:SetFrameLevel (f:GetFrameLevel()+1)
|
|
Tercio@11
|
2971 c:SetAlpha (0.9)
|
|
Tercio@11
|
2972 f.CloseButton = c
|
|
Tercio@11
|
2973
|
|
Tercio@11
|
2974 local title = DF:NewLabel (f, nil, "$parentTitle", "chart_title", "Chart!", nil, 20, {1, 1, 0})
|
|
Tercio@11
|
2975 title:SetPoint ("topleft", f, "topleft", 110, -13)
|
|
Tercio@11
|
2976
|
|
Tercio@11
|
2977 local bottom_texture = DF:NewImage (f, nil, 702, 25, "background", nil, nil, "$parentBottomTexture")
|
|
Tercio@39
|
2978 bottom_texture:SetColorTexture (0, 0, 0, .6)
|
|
Tercio@11
|
2979 bottom_texture:SetPoint ("bottomleft", f, "bottomleft", 8, 7)
|
|
Tercio@11
|
2980 bottom_texture:SetPoint ("bottomright", f, "bottomright", -8, 7)
|
|
Tercio@11
|
2981
|
|
Tercio@11
|
2982 f.Overlays = {}
|
|
Tercio@11
|
2983 f.OverlaysAmount = 1
|
|
Tercio@11
|
2984
|
|
Tercio@11
|
2985 f.BoxLabels = {}
|
|
Tercio@11
|
2986 f.BoxLabelsAmount = 1
|
|
Tercio@11
|
2987
|
|
Tercio@11
|
2988 f.TimeLabels = {}
|
|
Tercio@11
|
2989 for i = 1, 17 do
|
|
Tercio@11
|
2990 local time = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
|
|
Tercio@11
|
2991 time:SetText ("00:00")
|
|
Tercio@11
|
2992 time:SetPoint ("bottomleft", f, "bottomleft", 78 + ((i-1)*36), 13)
|
|
Tercio@11
|
2993 f.TimeLabels [i] = time
|
|
Tercio@11
|
2994
|
|
Tercio@11
|
2995 local line = f:CreateTexture (nil, "border")
|
|
Tercio@11
|
2996 line:SetSize (1, h-45)
|
|
Tercio@39
|
2997 line:SetColorTexture (1, 1, 1, .1)
|
|
Tercio@11
|
2998 line:SetPoint ("bottomleft", time, "topright", 0, -10)
|
|
Tercio@11
|
2999 line:Hide()
|
|
Tercio@11
|
3000 time.line = line
|
|
Tercio@11
|
3001 end
|
|
Tercio@11
|
3002
|
|
Tercio@11
|
3003 --graphic
|
|
Tercio@11
|
3004 local g = LibStub:GetLibrary("LibGraph-2.0"):CreateGraphLine (name .. "Graphic", f, "topleft","topleft", 108, -35, w - 120, h - 67)
|
|
Tercio@11
|
3005 g:SetXAxis (-1,1)
|
|
Tercio@11
|
3006 g:SetYAxis (-1,1)
|
|
Tercio@11
|
3007 g:SetGridSpacing (false, false)
|
|
Tercio@11
|
3008 g:SetGridColor ({0.5,0.5,0.5,0.3})
|
|
Tercio@11
|
3009 g:SetAxisDrawing (false,false)
|
|
Tercio@11
|
3010 g:SetAxisColor({1.0,1.0,1.0,1.0})
|
|
Tercio@11
|
3011 g:SetAutoScale (true)
|
|
Tercio@11
|
3012 g:SetLineTexture ("smallline")
|
|
Tercio@11
|
3013 g:SetBorderSize ("right", 0.001)
|
|
Tercio@11
|
3014 g:SetBorderSize ("left", 0.000)
|
|
Tercio@11
|
3015 g:SetBorderSize ("top", 0.002)
|
|
Tercio@11
|
3016 g:SetBorderSize ("bottom", 0.001)
|
|
Tercio@11
|
3017 g.VerticalLines = {}
|
|
Tercio@11
|
3018 g.max_value = 0
|
|
Tercio@11
|
3019
|
|
Tercio@11
|
3020 g:SetLineTexture ("line")
|
|
Tercio@11
|
3021
|
|
Tercio@11
|
3022 f.Graphic = g
|
|
Tercio@11
|
3023 f.GData = {}
|
|
Tercio@11
|
3024 f.OData = {}
|
|
Tercio@11
|
3025
|
|
Tercio@11
|
3026 --div lines
|
|
Tercio@11
|
3027 for i = 1, 8, 1 do
|
|
Tercio@11
|
3028 local line = g:CreateTexture (nil, "overlay")
|
|
Tercio@39
|
3029 line:SetColorTexture (1, 1, 1, .2)
|
|
Tercio@11
|
3030 line:SetWidth (670)
|
|
Tercio@11
|
3031 line:SetHeight (1.1)
|
|
Tercio@11
|
3032
|
|
Tercio@11
|
3033 local s = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
|
|
Tercio@11
|
3034 f ["dpsamt"..i] = s
|
|
Tercio@11
|
3035 s:SetText ("100k")
|
|
Tercio@11
|
3036 s:SetPoint ("topleft", f, "topleft", 27, -61 + (-(24.6*i)))
|
|
Tercio@11
|
3037
|
|
Tercio@11
|
3038 line:SetPoint ("topleft", s, "bottom", -27, 0)
|
|
Tercio@11
|
3039 s.line = line
|
|
Tercio@11
|
3040 end
|
|
Tercio@11
|
3041
|
|
Tercio@11
|
3042 f.SetTime = chart_panel_align_timelabels
|
|
Tercio@11
|
3043 f.EnableVerticalLines = chart_panel_vlines_on
|
|
Tercio@11
|
3044 f.DisableVerticalLines = chart_panel_vlines_off
|
|
Tercio@11
|
3045 f.SetTitle = chart_panel_set_title
|
|
Tercio@11
|
3046 f.SetScale = chart_panel_set_scale
|
|
Tercio@11
|
3047 f.Reset = chart_panel_reset
|
|
Tercio@11
|
3048 f.AddLine = chart_panel_add_data
|
|
Tercio@11
|
3049 f.CanMove = chart_panel_can_move
|
|
Tercio@11
|
3050 f.AddLabel = chart_panel_add_label
|
|
Tercio@11
|
3051 f.AddOverlay = chart_panel_add_overlay
|
|
Tercio@11
|
3052 f.HideCloseButton = chart_panel_hide_close_button
|
|
Tercio@11
|
3053 f.RightClickClose = chart_panel_right_click_close
|
|
Tercio@11
|
3054
|
|
Tercio@11
|
3055 f:SetScript ("OnSizeChanged", chart_panel_onresize)
|
|
Tercio@11
|
3056 chart_panel_onresize (f)
|
|
Tercio@11
|
3057
|
|
Tercio@11
|
3058 return f
|
|
Tercio@20
|
3059 end
|
|
Tercio@20
|
3060
|
|
Tercio@20
|
3061 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@20
|
3062 -- ~gframe
|
|
Tercio@20
|
3063 local gframe_on_enter_line = function (self)
|
|
Tercio@20
|
3064 self:SetBackdropColor (0, 0, 0, 0)
|
|
Tercio@20
|
3065
|
|
Tercio@20
|
3066 local parent = self:GetParent()
|
|
Tercio@20
|
3067 local ball = self.ball
|
|
Tercio@20
|
3068 ball:SetBlendMode ("ADD")
|
|
Tercio@20
|
3069
|
|
Tercio@20
|
3070 local on_enter = parent._onenter_line
|
|
Tercio@20
|
3071 if (on_enter) then
|
|
Tercio@20
|
3072 return on_enter (self, parent)
|
|
Tercio@20
|
3073 end
|
|
Tercio@20
|
3074 end
|
|
Tercio@20
|
3075
|
|
Tercio@20
|
3076 local gframe_on_leave_line = function (self)
|
|
Tercio@20
|
3077 self:SetBackdropColor (0, 0, 0, .6)
|
|
Tercio@20
|
3078
|
|
Tercio@20
|
3079 local parent = self:GetParent()
|
|
Tercio@20
|
3080 local ball = self.ball
|
|
Tercio@20
|
3081 ball:SetBlendMode ("BLEND")
|
|
Tercio@20
|
3082
|
|
Tercio@20
|
3083 local on_leave = parent._onleave_line
|
|
Tercio@20
|
3084 if (on_leave) then
|
|
Tercio@20
|
3085 return on_leave (self, parent)
|
|
Tercio@20
|
3086 end
|
|
Tercio@20
|
3087 end
|
|
Tercio@20
|
3088
|
|
Tercio@20
|
3089 local gframe_create_line = function (self)
|
|
Tercio@20
|
3090 local index = #self._lines+1
|
|
Tercio@20
|
3091
|
|
Tercio@20
|
3092 local f = CreateFrame ("frame", nil, self)
|
|
Tercio@20
|
3093 self._lines [index] = f
|
|
Tercio@20
|
3094 f.id = index
|
|
Tercio@20
|
3095 f:SetScript ("OnEnter", gframe_on_enter_line)
|
|
Tercio@20
|
3096 f:SetScript ("OnLeave", gframe_on_leave_line)
|
|
Tercio@20
|
3097
|
|
Tercio@20
|
3098 f:SetWidth (self._linewidth)
|
|
Tercio@20
|
3099
|
|
Tercio@20
|
3100 if (index == 1) then
|
|
Tercio@20
|
3101 f:SetPoint ("topleft", self, "topleft")
|
|
Tercio@20
|
3102 f:SetPoint ("bottomleft", self, "bottomleft")
|
|
Tercio@20
|
3103 else
|
|
Tercio@20
|
3104 local previous_line = self._lines [index-1]
|
|
Tercio@20
|
3105 f:SetPoint ("topleft", previous_line, "topright")
|
|
Tercio@20
|
3106 f:SetPoint ("bottomleft", previous_line, "bottomright")
|
|
Tercio@20
|
3107 end
|
|
Tercio@20
|
3108
|
|
Tercio@20
|
3109 local t = f:CreateTexture (nil, "background")
|
|
Tercio@20
|
3110 t:SetWidth (1)
|
|
Tercio@20
|
3111 t:SetPoint ("topright", f, "topright")
|
|
Tercio@20
|
3112 t:SetPoint ("bottomright", f, "bottomright")
|
|
Tercio@39
|
3113 t:SetColorTexture (1, 1, 1, .1)
|
|
Tercio@20
|
3114 f.grid = t
|
|
Tercio@20
|
3115
|
|
Tercio@20
|
3116 local b = f:CreateTexture (nil, "overlay")
|
|
Tercio@20
|
3117 b:SetTexture ([[Interface\COMMON\Indicator-Yellow]])
|
|
Tercio@20
|
3118 b:SetSize (16, 16)
|
|
Tercio@20
|
3119 f.ball = b
|
|
Tercio@20
|
3120 local anchor = CreateFrame ("frame", nil, f)
|
|
Tercio@20
|
3121 anchor:SetAllPoints (b)
|
|
Tercio@20
|
3122 b.tooltip_anchor = anchor
|
|
Tercio@20
|
3123
|
|
Tercio@20
|
3124 local spellicon = f:CreateTexture (nil, "artwork")
|
|
Tercio@20
|
3125 spellicon:SetPoint ("bottom", b, "bottom", 0, 10)
|
|
Tercio@20
|
3126 spellicon:SetSize (16, 16)
|
|
Tercio@20
|
3127 f.spellicon = spellicon
|
|
Tercio@20
|
3128
|
|
Tercio@53
|
3129 local text = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@53
|
3130 local textBackground = f:CreateTexture (nil, "artwork")
|
|
Tercio@53
|
3131 textBackground:SetSize (30, 16)
|
|
Tercio@53
|
3132 textBackground:SetColorTexture (0, 0, 0, 0.5)
|
|
Tercio@53
|
3133 textBackground:SetPoint ("bottom", f.ball, "top", 0, -6)
|
|
Tercio@53
|
3134 text:SetPoint ("center", textBackground, "center")
|
|
Tercio@53
|
3135 DF:SetFontSize (text, 10)
|
|
Tercio@53
|
3136 f.text = text
|
|
Tercio@53
|
3137 f.textBackground = textBackground
|
|
Tercio@53
|
3138
|
|
Tercio@20
|
3139 local timeline = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@20
|
3140 timeline:SetPoint ("bottomright", f, "bottomright", -2, 0)
|
|
Tercio@40
|
3141 DF:SetFontSize (timeline, 8)
|
|
Tercio@20
|
3142 f.timeline = timeline
|
|
Tercio@20
|
3143
|
|
Tercio@20
|
3144 return f
|
|
Tercio@20
|
3145 end
|
|
Tercio@20
|
3146
|
|
Tercio@20
|
3147 local gframe_getline = function (self, index)
|
|
Tercio@20
|
3148 local line = self._lines [index]
|
|
Tercio@20
|
3149 if (not line) then
|
|
Tercio@20
|
3150 line = gframe_create_line (self)
|
|
Tercio@20
|
3151 end
|
|
Tercio@20
|
3152 return line
|
|
Tercio@20
|
3153 end
|
|
Tercio@20
|
3154
|
|
Tercio@20
|
3155 local gframe_reset = function (self)
|
|
Tercio@20
|
3156 for i, line in ipairs (self._lines) do
|
|
Tercio@20
|
3157 line:Hide()
|
|
Tercio@20
|
3158 end
|
|
Tercio@20
|
3159 if (self.GraphLib_Lines_Used) then
|
|
Tercio@20
|
3160 for i = #self.GraphLib_Lines_Used, 1, -1 do
|
|
Tercio@20
|
3161 local line = tremove (self.GraphLib_Lines_Used)
|
|
Tercio@20
|
3162 tinsert (self.GraphLib_Lines, line)
|
|
Tercio@20
|
3163 line:Hide()
|
|
Tercio@20
|
3164 end
|
|
Tercio@20
|
3165 end
|
|
Tercio@20
|
3166 end
|
|
Tercio@20
|
3167
|
|
Tercio@20
|
3168 local gframe_update = function (self, lines)
|
|
Tercio@20
|
3169
|
|
Tercio@20
|
3170 local g = LibStub:GetLibrary ("LibGraph-2.0")
|
|
Tercio@20
|
3171 local h = self:GetHeight()/100
|
|
Tercio@20
|
3172 local amtlines = #lines
|
|
Tercio@20
|
3173 local linewidth = self._linewidth
|
|
Tercio@20
|
3174
|
|
Tercio@20
|
3175 local max_value = 0
|
|
Tercio@20
|
3176 for i = 1, amtlines do
|
|
Tercio@20
|
3177 if (lines [i].value > max_value) then
|
|
Tercio@20
|
3178 max_value = lines [i].value
|
|
Tercio@20
|
3179 end
|
|
Tercio@20
|
3180 end
|
|
Tercio@20
|
3181
|
|
Tercio@40
|
3182 self.MaxValue = max_value
|
|
Tercio@40
|
3183
|
|
Tercio@20
|
3184 local o = 1
|
|
Tercio@20
|
3185 local lastvalue = self:GetHeight()/2
|
|
Tercio@40
|
3186 max_value = math.max (max_value, 0.0000001)
|
|
Tercio@20
|
3187
|
|
Tercio@20
|
3188 for i = 1, min (amtlines, self._maxlines) do
|
|
Tercio@20
|
3189
|
|
Tercio@20
|
3190 local data = lines [i]
|
|
Tercio@20
|
3191
|
|
Tercio@20
|
3192 local pvalue = data.value / max_value * 100
|
|
Tercio@20
|
3193 if (pvalue > 98) then
|
|
Tercio@20
|
3194 pvalue = 98
|
|
Tercio@20
|
3195 end
|
|
Tercio@20
|
3196 pvalue = pvalue * h
|
|
Tercio@20
|
3197
|
|
Tercio@20
|
3198 g:DrawLine (self, (o-1)*linewidth, lastvalue, o*linewidth, pvalue, linewidth, {1, 1, 1, 1}, "overlay")
|
|
Tercio@20
|
3199 lastvalue = pvalue
|
|
Tercio@20
|
3200
|
|
Tercio@20
|
3201 local line = self:GetLine (i)
|
|
Tercio@20
|
3202 line:Show()
|
|
Tercio@20
|
3203 line.ball:Show()
|
|
Tercio@20
|
3204
|
|
Tercio@20
|
3205 line.ball:SetPoint ("bottomleft", self, "bottomleft", (o*linewidth)-8, pvalue-8)
|
|
Tercio@20
|
3206 line.spellicon:SetTexture (nil)
|
|
Tercio@20
|
3207 line.timeline:SetText (data.text)
|
|
Tercio@20
|
3208 line.timeline:Show()
|
|
Tercio@20
|
3209
|
|
Tercio@53
|
3210 if (data.utext) then
|
|
Tercio@53
|
3211 line.text:Show()
|
|
Tercio@53
|
3212 line.textBackground:Show()
|
|
Tercio@53
|
3213 line.text:SetText (data.utext)
|
|
Tercio@53
|
3214 else
|
|
Tercio@53
|
3215 line.text:Hide()
|
|
Tercio@53
|
3216 line.textBackground:Hide()
|
|
Tercio@53
|
3217 end
|
|
Tercio@53
|
3218
|
|
Tercio@20
|
3219 line.data = data
|
|
Tercio@20
|
3220
|
|
Tercio@20
|
3221 o = o + 1
|
|
Tercio@20
|
3222 end
|
|
Tercio@20
|
3223
|
|
Tercio@20
|
3224 end
|
|
Tercio@20
|
3225
|
|
Tercio@20
|
3226 function DF:CreateGFrame (parent, w, h, linewidth, onenter, onleave, member, name)
|
|
Tercio@20
|
3227 local f = CreateFrame ("frame", name, parent)
|
|
Tercio@20
|
3228 f:SetSize (w or 450, h or 150)
|
|
Tercio@45
|
3229 --f.CustomLine = [[Interface\AddOns\Details\Libs\LibGraph-2.0\line]]
|
|
Tercio@20
|
3230
|
|
Tercio@20
|
3231 if (member) then
|
|
Tercio@20
|
3232 parent [member] = f
|
|
Tercio@20
|
3233 end
|
|
Tercio@20
|
3234
|
|
Tercio@20
|
3235 f.CreateLine = gframe_create_line
|
|
Tercio@20
|
3236 f.GetLine = gframe_getline
|
|
Tercio@20
|
3237 f.Reset = gframe_reset
|
|
Tercio@20
|
3238 f.UpdateLines = gframe_update
|
|
Tercio@20
|
3239
|
|
Tercio@40
|
3240 f.MaxValue = 0
|
|
Tercio@40
|
3241
|
|
Tercio@20
|
3242 f._lines = {}
|
|
Tercio@20
|
3243
|
|
Tercio@20
|
3244 f._onenter_line = onenter
|
|
Tercio@20
|
3245 f._onleave_line = onleave
|
|
Tercio@20
|
3246
|
|
Tercio@20
|
3247 f._linewidth = linewidth or 50
|
|
Tercio@20
|
3248 f._maxlines = floor (f:GetWidth() / f._linewidth)
|
|
Tercio@20
|
3249
|
|
Tercio@20
|
3250 return f
|
|
Tercio@39
|
3251 end
|
|
Tercio@39
|
3252
|
|
Tercio@39
|
3253
|
|
Tercio@39
|
3254 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@39
|
3255 -- ~buttoncontainer
|
|
Tercio@39
|
3256
|
|
Tercio@39
|
3257 function DF:CreateButtonContainer (parent, name)
|
|
Tercio@39
|
3258 local f = CreateFrame ("frame", name, parent)
|
|
Tercio@39
|
3259 -- f.
|
|
Tercio@39
|
3260 end
|
|
Tercio@39
|
3261
|
|
Tercio@39
|
3262
|
|
Tercio@39
|
3263 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@39
|
3264 --> options tabs and buttons -dot
|
|
Tercio@39
|
3265
|
|
Tercio@39
|
3266 function DF:FindHighestParent (self)
|
|
Tercio@39
|
3267 local f
|
|
Tercio@39
|
3268 if (self:GetParent() == UIParent) then
|
|
Tercio@39
|
3269 f = self
|
|
Tercio@39
|
3270 end
|
|
Tercio@39
|
3271 if (not f) then
|
|
Tercio@39
|
3272 f = self
|
|
Tercio@39
|
3273 for i = 1, 6 do
|
|
Tercio@39
|
3274 local parent = f:GetParent()
|
|
Tercio@39
|
3275 if (parent == UIParent) then
|
|
Tercio@39
|
3276 break
|
|
Tercio@39
|
3277 else
|
|
Tercio@39
|
3278 f = parent
|
|
Tercio@39
|
3279 end
|
|
Tercio@39
|
3280 end
|
|
Tercio@39
|
3281 end
|
|
Tercio@39
|
3282
|
|
Tercio@39
|
3283 return f
|
|
Tercio@39
|
3284 end
|
|
Tercio@39
|
3285
|
|
Tercio@39
|
3286 DF.TabContainerFunctions = {}
|
|
Tercio@39
|
3287
|
|
Tercio@39
|
3288 local button_tab_template = DF.table.copy ({}, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
|
|
Tercio@39
|
3289 button_tab_template.backdropbordercolor = nil
|
|
Tercio@39
|
3290
|
|
Tercio@39
|
3291 DF.TabContainerFunctions.CreateUnderlineGlow = function (button)
|
|
Tercio@39
|
3292 local selectedGlow = button:CreateTexture (nil, "background", -4)
|
|
Tercio@39
|
3293 selectedGlow:SetPoint ("topleft", button.widget, "bottomleft", -7, 0)
|
|
Tercio@39
|
3294 selectedGlow:SetPoint ("topright", button.widget, "bottomright", 7, 0)
|
|
Tercio@39
|
3295 selectedGlow:SetTexture ([[Interface\BUTTONS\UI-Panel-Button-Glow]])
|
|
Tercio@39
|
3296 selectedGlow:SetTexCoord (0, 95/128, 30/64, 38/64)
|
|
Tercio@39
|
3297 selectedGlow:SetBlendMode ("ADD")
|
|
Tercio@39
|
3298 selectedGlow:SetHeight (8)
|
|
Tercio@39
|
3299 selectedGlow:SetAlpha (.75)
|
|
Tercio@39
|
3300 selectedGlow:Hide()
|
|
Tercio@39
|
3301 button.selectedUnderlineGlow = selectedGlow
|
|
Tercio@39
|
3302 end
|
|
Tercio@39
|
3303
|
|
Tercio@39
|
3304 DF.TabContainerFunctions.OnMouseDown = function (self, button)
|
|
Tercio@39
|
3305 --> search for UIParent
|
|
Tercio@39
|
3306 local f = DF:FindHighestParent (self)
|
|
Tercio@39
|
3307 local container = self:GetParent()
|
|
Tercio@39
|
3308
|
|
Tercio@39
|
3309 if (button == "LeftButton") then
|
|
Tercio@39
|
3310 if (not f.IsMoving and f:IsMovable()) then
|
|
Tercio@39
|
3311 f:StartMoving()
|
|
Tercio@39
|
3312 f.IsMoving = true
|
|
Tercio@39
|
3313 end
|
|
Tercio@39
|
3314 elseif (button == "RightButton") then
|
|
Tercio@39
|
3315 if (not f.IsMoving and container.IsContainer) then
|
|
Tercio@39
|
3316 if (self.IsFrontPage) then
|
|
Tercio@39
|
3317 if (container.CanCloseWithRightClick) then
|
|
Tercio@39
|
3318 if (f.CloseFunction) then
|
|
Tercio@39
|
3319 f:CloseFunction()
|
|
Tercio@39
|
3320 else
|
|
Tercio@39
|
3321 f:Hide()
|
|
Tercio@39
|
3322 end
|
|
Tercio@39
|
3323 end
|
|
Tercio@39
|
3324 else
|
|
Tercio@39
|
3325 --goes back to front page
|
|
Tercio@39
|
3326 DF.TabContainerFunctions.SelectIndex (self, _, 1)
|
|
Tercio@39
|
3327 end
|
|
Tercio@39
|
3328 end
|
|
Tercio@39
|
3329 end
|
|
Tercio@39
|
3330 end
|
|
Tercio@39
|
3331
|
|
Tercio@39
|
3332 DF.TabContainerFunctions.OnMouseUp = function (self, button)
|
|
Tercio@39
|
3333 local f = DF:FindHighestParent (self)
|
|
Tercio@39
|
3334 if (f.IsMoving) then
|
|
Tercio@39
|
3335 f:StopMovingOrSizing()
|
|
Tercio@39
|
3336 f.IsMoving = false
|
|
Tercio@39
|
3337 end
|
|
Tercio@39
|
3338 end
|
|
Tercio@39
|
3339
|
|
Tercio@39
|
3340 DF.TabContainerFunctions.SelectIndex = function (self, fixedParam, menuIndex)
|
|
Tercio@39
|
3341 local mainFrame = self.AllFrames and self or self.mainFrame or self:GetParent()
|
|
Tercio@39
|
3342
|
|
Tercio@39
|
3343 for i = 1, #mainFrame.AllFrames do
|
|
Tercio@39
|
3344 mainFrame.AllFrames[i]:Hide()
|
|
Tercio@39
|
3345 if (mainFrame.ButtonNotSelectedBorderColor) then
|
|
Tercio@39
|
3346 mainFrame.AllButtons[i]:SetBackdropBorderColor (unpack (mainFrame.ButtonNotSelectedBorderColor))
|
|
Tercio@39
|
3347 end
|
|
Tercio@39
|
3348 if (mainFrame.AllButtons[i].selectedUnderlineGlow) then
|
|
Tercio@39
|
3349 mainFrame.AllButtons[i].selectedUnderlineGlow:Hide()
|
|
Tercio@39
|
3350 end
|
|
Tercio@39
|
3351 end
|
|
Tercio@39
|
3352
|
|
Tercio@39
|
3353 mainFrame.AllFrames[menuIndex]:Show()
|
|
Tercio@39
|
3354 if (mainFrame.ButtonSelectedBorderColor) then
|
|
Tercio@39
|
3355 mainFrame.AllButtons[menuIndex]:SetBackdropBorderColor (unpack (mainFrame.ButtonSelectedBorderColor))
|
|
Tercio@39
|
3356 end
|
|
Tercio@39
|
3357 if (mainFrame.AllButtons[menuIndex].selectedUnderlineGlow) then
|
|
Tercio@39
|
3358 mainFrame.AllButtons[menuIndex].selectedUnderlineGlow:Show()
|
|
Tercio@39
|
3359 end
|
|
Tercio@39
|
3360 mainFrame.CurrentIndex = menuIndex
|
|
Tercio@39
|
3361 end
|
|
Tercio@39
|
3362
|
|
Tercio@39
|
3363 DF.TabContainerFunctions.SetIndex = function (self, index)
|
|
Tercio@39
|
3364 self.CurrentIndex = index
|
|
Tercio@39
|
3365 end
|
|
Tercio@39
|
3366
|
|
Tercio@39
|
3367 local tab_container_on_show = function (self)
|
|
Tercio@39
|
3368 local index = self.CurrentIndex
|
|
Tercio@39
|
3369 self.SelectIndex (self.AllButtons[index], nil, index)
|
|
Tercio@39
|
3370 end
|
|
Tercio@39
|
3371
|
|
Tercio@39
|
3372 function DF:CreateTabContainer (parent, title, frame_name, frame_list, options_table)
|
|
Tercio@39
|
3373
|
|
Tercio@39
|
3374 local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
|
|
Tercio@39
|
3375 local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
|
|
Tercio@39
|
3376 local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
|
|
Tercio@39
|
3377 local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
|
|
Tercio@39
|
3378 local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
|
|
Tercio@39
|
3379
|
|
Tercio@39
|
3380 options_table = options_table or {}
|
|
Tercio@39
|
3381 local frame_width = parent:GetWidth()
|
|
Tercio@39
|
3382 local frame_height = parent:GetHeight()
|
|
Tercio@39
|
3383 local y_offset = options_table.y_offset or 0
|
|
Tercio@39
|
3384 local button_width = options_table.button_width or 160
|
|
Tercio@39
|
3385 local button_height = options_table.button_height or 20
|
|
Tercio@39
|
3386 local button_anchor_x = options_table.button_x or 230
|
|
Tercio@39
|
3387 local button_anchor_y = options_table.button_y or -32
|
|
Tercio@39
|
3388 local button_text_size = options_table.button_text_size or 10
|
|
Tercio@39
|
3389
|
|
Tercio@39
|
3390 local mainFrame = CreateFrame ("frame", frame_name, parent.widget or parent)
|
|
Tercio@39
|
3391 mainFrame:SetAllPoints()
|
|
Tercio@39
|
3392 DF:Mixin (mainFrame, DF.TabContainerFunctions)
|
|
Tercio@39
|
3393
|
|
Tercio@39
|
3394 local mainTitle = DF:CreateLabel (mainFrame, title, 24, "white")
|
|
Tercio@39
|
3395 mainTitle:SetPoint ("topleft", mainFrame, "topleft", 10, -30 + y_offset)
|
|
Tercio@39
|
3396
|
|
Tercio@39
|
3397 mainFrame:SetFrameLevel (200)
|
|
Tercio@39
|
3398
|
|
Tercio@39
|
3399 mainFrame.AllFrames = {}
|
|
Tercio@39
|
3400 mainFrame.AllButtons = {}
|
|
Tercio@39
|
3401 mainFrame.CurrentIndex = 1
|
|
Tercio@39
|
3402 mainFrame.IsContainer = true
|
|
Tercio@39
|
3403 mainFrame.ButtonSelectedBorderColor = options_table.button_selected_border_color or {1, 1, 0, 1}
|
|
Tercio@39
|
3404 mainFrame.ButtonNotSelectedBorderColor = options_table.button_border_color or {0, 0, 0, 0}
|
|
Tercio@39
|
3405
|
|
Tercio@39
|
3406 if (options_table.right_click_interact ~= nil) then
|
|
Tercio@39
|
3407 mainFrame.CanCloseWithRightClick = options_table.right_click_interact
|
|
Tercio@39
|
3408 else
|
|
Tercio@39
|
3409 mainFrame.CanCloseWithRightClick = true
|
|
Tercio@39
|
3410 end
|
|
Tercio@39
|
3411
|
|
Tercio@39
|
3412 for i, frame in ipairs (frame_list) do
|
|
Tercio@39
|
3413 local f = CreateFrame ("frame", "$parent" .. frame.name, mainFrame)
|
|
Tercio@39
|
3414 f:SetAllPoints()
|
|
Tercio@39
|
3415 f:SetFrameLevel (210)
|
|
Tercio@39
|
3416 f:Hide()
|
|
Tercio@39
|
3417
|
|
Tercio@39
|
3418 local title = DF:CreateLabel (f, frame.title, 16, "silver")
|
|
Tercio@39
|
3419 title:SetPoint ("topleft", mainTitle, "bottomleft", 0, 0)
|
|
Tercio@39
|
3420
|
|
Tercio@39
|
3421 local tabButton = DF:CreateButton (mainFrame, DF.TabContainerFunctions.SelectIndex, button_width, button_height, frame.title, i, nil, nil, nil, nil, false, button_tab_template)
|
|
Tercio@39
|
3422 tabButton:SetFrameLevel (220)
|
|
Tercio@39
|
3423 tabButton.textsize = button_text_size
|
|
Tercio@39
|
3424 tabButton.mainFrame = mainFrame
|
|
Tercio@39
|
3425 DF.TabContainerFunctions.CreateUnderlineGlow (tabButton)
|
|
Tercio@39
|
3426
|
|
Tercio@39
|
3427 if (i == 1) then
|
|
Tercio@39
|
3428 local right_click_to_back = DF:CreateLabel (f, "right click to close", 10, "gray")
|
|
Tercio@39
|
3429 right_click_to_back:SetPoint ("bottomright", f, "bottomright", -1, 0)
|
|
Tercio@39
|
3430 f.IsFrontPage = true
|
|
Tercio@39
|
3431 else
|
|
Tercio@39
|
3432 local right_click_to_back = DF:CreateLabel (f, "right click to go back to main menu", 10, "gray")
|
|
Tercio@39
|
3433 right_click_to_back:SetPoint ("bottomright", f, "bottomright", -1, 0)
|
|
Tercio@39
|
3434 end
|
|
Tercio@39
|
3435
|
|
Tercio@39
|
3436 f:SetScript ("OnMouseDown", DF.TabContainerFunctions.OnMouseDown)
|
|
Tercio@39
|
3437 f:SetScript ("OnMouseUp", DF.TabContainerFunctions.OnMouseUp)
|
|
Tercio@39
|
3438
|
|
Tercio@39
|
3439 tinsert (mainFrame.AllFrames, f)
|
|
Tercio@39
|
3440 tinsert (mainFrame.AllButtons, tabButton)
|
|
Tercio@39
|
3441 end
|
|
Tercio@39
|
3442
|
|
Tercio@39
|
3443 --order buttons
|
|
Tercio@39
|
3444 local x = button_anchor_x
|
|
Tercio@39
|
3445 local y = button_anchor_y
|
|
Tercio@39
|
3446 local space_for_buttons = frame_width - (#frame_list*3) - button_anchor_x
|
|
Tercio@39
|
3447 local amount_buttons_per_row = floor (space_for_buttons / button_width)
|
|
Tercio@39
|
3448 local last_button = mainFrame.AllButtons[1]
|
|
Tercio@39
|
3449
|
|
Tercio@39
|
3450 mainFrame.AllButtons[1]:SetPoint ("topleft", mainTitle, "topleft", x, y)
|
|
Tercio@39
|
3451 x = x + button_width + 2
|
|
Tercio@39
|
3452
|
|
Tercio@39
|
3453 for i = 2, #mainFrame.AllButtons do
|
|
Tercio@39
|
3454 local button = mainFrame.AllButtons [i]
|
|
Tercio@39
|
3455 button:SetPoint ("topleft", mainTitle, "topleft", x, y)
|
|
Tercio@39
|
3456 x = x + button_width + 2
|
|
Tercio@39
|
3457
|
|
Tercio@39
|
3458 if (i % amount_buttons_per_row == 0) then
|
|
Tercio@39
|
3459 x = button_anchor_x
|
|
Tercio@39
|
3460 y = y - button_height - 1
|
|
Tercio@39
|
3461 end
|
|
Tercio@39
|
3462 end
|
|
Tercio@39
|
3463
|
|
Tercio@39
|
3464 --> when show the frame, reset to the current internal index
|
|
Tercio@39
|
3465 mainFrame:SetScript ("OnShow", tab_container_on_show)
|
|
Tercio@39
|
3466 --> select the first frame
|
|
Tercio@39
|
3467 mainFrame.SelectIndex (mainFrame.AllButtons[1], nil, 1)
|
|
Tercio@39
|
3468
|
|
Tercio@39
|
3469 return mainFrame
|
|
Tercio@39
|
3470 end
|
|
Tercio@39
|
3471
|
|
Tercio@39
|
3472
|
|
Tercio@39
|
3473
|
|
Tercio@39
|
3474
|
|
Tercio@39
|
3475
|
|
Tercio@40
|
3476 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@40
|
3477 -- ~listbox
|
|
Tercio@39
|
3478
|
|
Tercio@40
|
3479 local simple_list_box_ResetWidgets = function (self)
|
|
Tercio@40
|
3480 for _, widget in ipairs (self.widgets) do
|
|
Tercio@40
|
3481 widget:Hide()
|
|
Tercio@40
|
3482 end
|
|
Tercio@40
|
3483 self.nextWidget = 1
|
|
Tercio@40
|
3484 end
|
|
Tercio@39
|
3485
|
|
Tercio@40
|
3486 local simple_list_box_onenter = function (self, capsule)
|
|
Tercio@40
|
3487 self:GetParent().options.onenter (self, capsule, capsule.value)
|
|
Tercio@40
|
3488 end
|
|
Tercio@39
|
3489
|
|
Tercio@40
|
3490 local simple_list_box_onleave = function (self, capsule)
|
|
Tercio@40
|
3491 self:GetParent().options.onleave (self, capsule, capsule.value)
|
|
Tercio@40
|
3492 GameTooltip:Hide()
|
|
Tercio@40
|
3493 end
|
|
Tercio@39
|
3494
|
|
Tercio@40
|
3495 local simple_list_box_GetOrCreateWidget = function (self)
|
|
Tercio@40
|
3496 local index = self.nextWidget
|
|
Tercio@40
|
3497 local widget = self.widgets [index]
|
|
Tercio@40
|
3498 if (not widget) then
|
|
Tercio@40
|
3499 widget = DF:CreateButton (self, function()end, self.options.width, self.options.row_height, "", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
|
|
Tercio@40
|
3500 widget:SetHook ("OnEnter", simple_list_box_onenter)
|
|
Tercio@40
|
3501 widget:SetHook ("OnLeave", simple_list_box_onleave)
|
|
Tercio@40
|
3502 widget.textcolor = self.options.textcolor
|
|
Tercio@40
|
3503 tinsert (self.widgets, widget)
|
|
Tercio@40
|
3504 end
|
|
Tercio@40
|
3505 self.nextWidget = self.nextWidget + 1
|
|
Tercio@40
|
3506 return widget
|
|
Tercio@40
|
3507 end
|
|
Tercio@39
|
3508
|
|
Tercio@40
|
3509 local simple_list_box_RefreshWidgets = function (self)
|
|
Tercio@40
|
3510 self:ResetWidgets()
|
|
Tercio@40
|
3511 local amt = 0
|
|
Tercio@40
|
3512 for value, _ in pairs (self.list_table) do
|
|
Tercio@40
|
3513 local widget = self:GetOrCreateWidget()
|
|
Tercio@40
|
3514 widget:SetPoint ("topleft", self, "topleft", 1, -self.options.row_height * (self.nextWidget-2) - 4)
|
|
Tercio@40
|
3515 widget:SetPoint ("topright", self, "topright", -1, -self.options.row_height * (self.nextWidget-2) - 4)
|
|
Tercio@40
|
3516 widget:SetClickFunction (self.func, value)
|
|
Tercio@40
|
3517 widget.value = value
|
|
Tercio@40
|
3518
|
|
Tercio@40
|
3519 if (self.options.icon) then
|
|
Tercio@40
|
3520 if (type (self.options.icon) == "string" or type (self.options.icon) == "number") then
|
|
Tercio@40
|
3521 widget:SetIcon (self.options.icon, self.options.row_height, self.options.row_height)
|
|
Tercio@40
|
3522 elseif (type (self.options.icon) == "function") then
|
|
Tercio@40
|
3523 local icon = self.options.icon (value)
|
|
Tercio@40
|
3524 if (icon) then
|
|
Tercio@40
|
3525 widget:SetIcon (icon, self.options.row_height, self.options.row_height)
|
|
Tercio@40
|
3526 end
|
|
Tercio@40
|
3527 end
|
|
Tercio@40
|
3528 else
|
|
Tercio@40
|
3529 widget:SetIcon ("", self.options.row_height, self.options.row_height)
|
|
Tercio@40
|
3530 end
|
|
Tercio@40
|
3531
|
|
Tercio@40
|
3532 if (self.options.text) then
|
|
Tercio@40
|
3533 if (type (self.options.text) == "function") then
|
|
Tercio@40
|
3534 local text = self.options.text (value)
|
|
Tercio@40
|
3535 if (text) then
|
|
Tercio@40
|
3536 widget:SetText (text)
|
|
Tercio@40
|
3537 else
|
|
Tercio@40
|
3538 widget:SetText ("")
|
|
Tercio@40
|
3539 end
|
|
Tercio@40
|
3540 else
|
|
Tercio@40
|
3541 widget:SetText (self.options.text or "")
|
|
Tercio@40
|
3542 end
|
|
Tercio@40
|
3543 else
|
|
Tercio@40
|
3544 widget:SetText ("")
|
|
Tercio@40
|
3545 end
|
|
Tercio@40
|
3546
|
|
Tercio@40
|
3547 widget.value = value
|
|
Tercio@40
|
3548 widget:Show()
|
|
Tercio@40
|
3549 amt = amt + 1
|
|
Tercio@40
|
3550 end
|
|
Tercio@40
|
3551 if (amt == 0) then
|
|
Tercio@40
|
3552 self.EmptyLabel:Show()
|
|
Tercio@40
|
3553 else
|
|
Tercio@40
|
3554 self.EmptyLabel:Hide()
|
|
Tercio@40
|
3555 end
|
|
Tercio@40
|
3556 end
|
|
Tercio@39
|
3557
|
|
Tercio@40
|
3558 local backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1}
|
|
Tercio@40
|
3559 local default_options = {
|
|
Tercio@40
|
3560 height = 400,
|
|
Tercio@40
|
3561 row_height = 16,
|
|
Tercio@40
|
3562 width = 230,
|
|
Tercio@40
|
3563 icon = false,
|
|
Tercio@40
|
3564 text = "",
|
|
Tercio@40
|
3565 textcolor = "wheat",
|
|
Tercio@40
|
3566 onenter = function (self, capsule)
|
|
Tercio@40
|
3567 if (capsule) then
|
|
Tercio@40
|
3568 capsule.textcolor = "white"
|
|
Tercio@40
|
3569 end
|
|
Tercio@40
|
3570 end,
|
|
Tercio@40
|
3571 onleave = function (self, capsule)
|
|
Tercio@40
|
3572 if (capsule) then
|
|
Tercio@40
|
3573 capsule.textcolor = self:GetParent().options.textcolor
|
|
Tercio@40
|
3574 end
|
|
Tercio@40
|
3575 GameTooltip:Hide()
|
|
Tercio@40
|
3576 end,
|
|
Tercio@40
|
3577 }
|
|
Tercio@39
|
3578
|
|
Tercio@40
|
3579 local simple_list_box_SetData = function (self, t)
|
|
Tercio@40
|
3580 self.list_table = t
|
|
Tercio@40
|
3581 end
|
|
Tercio@40
|
3582
|
|
Tercio@40
|
3583 function DF:CreateSimpleListBox (parent, name, title, empty_text, list_table, onclick, options)
|
|
Tercio@40
|
3584 local f = CreateFrame ("frame", name, parent)
|
|
Tercio@40
|
3585
|
|
Tercio@40
|
3586 f.ResetWidgets = simple_list_box_ResetWidgets
|
|
Tercio@40
|
3587 f.GetOrCreateWidget = simple_list_box_GetOrCreateWidget
|
|
Tercio@40
|
3588 f.Refresh = simple_list_box_RefreshWidgets
|
|
Tercio@40
|
3589 f.SetData = simple_list_box_SetData
|
|
Tercio@40
|
3590 f.nextWidget = 1
|
|
Tercio@40
|
3591 f.list_table = list_table
|
|
Tercio@40
|
3592 f.func = function (self, button, value)
|
|
Tercio@40
|
3593 onclick (value)
|
|
Tercio@40
|
3594 f:Refresh()
|
|
Tercio@40
|
3595 end
|
|
Tercio@40
|
3596 f.widgets = {}
|
|
Tercio@40
|
3597 f:SetBackdrop (backdrop)
|
|
Tercio@40
|
3598 f:SetBackdropColor (0, 0, 0, 0.3)
|
|
Tercio@40
|
3599 f:SetBackdropBorderColor (0, 0, 0, 0.5)
|
|
Tercio@40
|
3600 f.options = options or {}
|
|
Tercio@40
|
3601 self.table.deploy (f.options, default_options)
|
|
Tercio@40
|
3602
|
|
Tercio@40
|
3603 f:SetSize (f.options.width + 2, f.options.height)
|
|
Tercio@40
|
3604
|
|
Tercio@40
|
3605 local name = DF:CreateLabel (f, title, 12, "silver")
|
|
Tercio@40
|
3606 name:SetTemplate (DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
|
|
Tercio@40
|
3607 name:SetPoint ("bottomleft", f, "topleft", 0, 2)
|
|
Tercio@40
|
3608 f.Title = name
|
|
Tercio@40
|
3609
|
|
Tercio@40
|
3610 local emptyLabel = DF:CreateLabel (f, empty_text, 12, "gray")
|
|
Tercio@40
|
3611 emptyLabel:SetAlpha (.6)
|
|
Tercio@40
|
3612 emptyLabel:SetSize (f.options.width-10, f.options.height)
|
|
Tercio@40
|
3613 emptyLabel:SetPoint ("center", 0, 0)
|
|
Tercio@40
|
3614 emptyLabel:Hide()
|
|
Tercio@40
|
3615 emptyLabel.align = "center"
|
|
Tercio@40
|
3616 f.EmptyLabel = emptyLabel
|
|
Tercio@40
|
3617
|
|
Tercio@40
|
3618 return f
|
|
Tercio@40
|
3619 end
|
|
Tercio@40
|
3620
|
|
Tercio@40
|
3621
|
|
Tercio@40
|
3622 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@40
|
3623 -- ~scrollbox
|
|
Tercio@40
|
3624
|
|
Tercio@40
|
3625 DF.SortFunctions = {}
|
|
Tercio@40
|
3626
|
|
Tercio@40
|
3627 local SortMember = ""
|
|
Tercio@40
|
3628 local SortByMember = function (t1, t2)
|
|
Tercio@40
|
3629 return t1[SortMember] > t2[SortMember]
|
|
Tercio@40
|
3630 end
|
|
Tercio@40
|
3631 local SortByMemberReverse = function (t1, t2)
|
|
Tercio@40
|
3632 return t1[SortMember] < t2[SortMember]
|
|
Tercio@40
|
3633 end
|
|
Tercio@40
|
3634
|
|
Tercio@40
|
3635 DF.SortFunctions.Sort = function (self, t, by, is_reverse)
|
|
Tercio@40
|
3636 SortMember = by
|
|
Tercio@40
|
3637 if (not is_reverse) then
|
|
Tercio@40
|
3638 table.sort (t, SortByMember)
|
|
Tercio@40
|
3639 else
|
|
Tercio@40
|
3640 table.sort (t, SortByMemberReverse)
|
|
Tercio@40
|
3641 end
|
|
Tercio@40
|
3642 end
|
|
Tercio@40
|
3643
|
|
Tercio@40
|
3644
|
|
Tercio@40
|
3645 DF.ScrollBoxFunctions = {}
|
|
Tercio@40
|
3646
|
|
Tercio@40
|
3647 DF.ScrollBoxFunctions.Refresh = function (self)
|
|
Tercio@40
|
3648 for _, frame in ipairs (self.Frames) do
|
|
Tercio@40
|
3649 frame:Hide()
|
|
Tercio@40
|
3650 frame._InUse = nil
|
|
Tercio@40
|
3651 end
|
|
Tercio@40
|
3652
|
|
Tercio@40
|
3653 local offset = 0
|
|
Tercio@40
|
3654 if (self.IsFauxScroll) then
|
|
Tercio@40
|
3655 FauxScrollFrame_Update (self, #self.data, self.LineAmount, self.LineHeight+1)
|
|
Tercio@40
|
3656 offset = FauxScrollFrame_GetOffset (self)
|
|
Tercio@40
|
3657 end
|
|
Tercio@40
|
3658
|
|
Tercio@53
|
3659 local okay, totalLines = pcall (self.refresh_func, self, self.data, offset, self.LineAmount)
|
|
Tercio@40
|
3660 if (not okay) then
|
|
Tercio@40
|
3661 error ("Details! FrameWork: Refresh(): " .. totalLines)
|
|
Tercio@40
|
3662 end
|
|
Tercio@40
|
3663
|
|
Tercio@40
|
3664 for _, frame in ipairs (self.Frames) do
|
|
Tercio@40
|
3665 if (not frame._InUse) then
|
|
Tercio@40
|
3666 frame:Hide()
|
|
Tercio@40
|
3667 else
|
|
Tercio@40
|
3668 frame:Show()
|
|
Tercio@40
|
3669 end
|
|
Tercio@40
|
3670 end
|
|
Tercio@40
|
3671
|
|
Tercio@40
|
3672 self:Show()
|
|
Tercio@40
|
3673
|
|
Tercio@53
|
3674 if (self.HideScrollBar) then
|
|
Tercio@53
|
3675 local frameName = self:GetName()
|
|
Tercio@53
|
3676 if (frameName) then
|
|
Tercio@53
|
3677 local scrollBar = _G [frameName .. "ScrollBar"]
|
|
Tercio@53
|
3678 if (scrollBar) then
|
|
Tercio@53
|
3679 scrollBar:Hide()
|
|
Tercio@53
|
3680 end
|
|
Tercio@53
|
3681 else
|
|
Tercio@53
|
3682
|
|
Tercio@53
|
3683 end
|
|
Tercio@53
|
3684
|
|
Tercio@53
|
3685 end
|
|
Tercio@53
|
3686
|
|
Tercio@40
|
3687 return self.Frames
|
|
Tercio@40
|
3688 end
|
|
Tercio@40
|
3689
|
|
Tercio@40
|
3690 DF.ScrollBoxFunctions.OnVerticalScroll = function (self, offset)
|
|
Tercio@40
|
3691 FauxScrollFrame_OnVerticalScroll (self, offset, self.LineHeight, self.Refresh)
|
|
Tercio@40
|
3692 return true
|
|
Tercio@40
|
3693 end
|
|
Tercio@40
|
3694
|
|
Tercio@40
|
3695 DF.ScrollBoxFunctions.CreateLine = function (self, func)
|
|
Tercio@53
|
3696 if (not func) then
|
|
Tercio@53
|
3697 func = self.CreateLineFunc
|
|
Tercio@53
|
3698 end
|
|
Tercio@40
|
3699 local okay, newLine = pcall (func, self, #self.Frames+1)
|
|
Tercio@40
|
3700 if (okay) then
|
|
Tercio@40
|
3701 tinsert (self.Frames, newLine)
|
|
Tercio@53
|
3702 newLine.Index = #self.Frames
|
|
Tercio@40
|
3703 return newLine
|
|
Tercio@40
|
3704 else
|
|
Tercio@40
|
3705 error ("Details! FrameWork: CreateLine(): " .. newLine)
|
|
Tercio@40
|
3706 end
|
|
Tercio@40
|
3707 end
|
|
Tercio@40
|
3708
|
|
Tercio@40
|
3709 DF.ScrollBoxFunctions.GetLine = function (self, line_index)
|
|
Tercio@40
|
3710 local line = self.Frames [line_index]
|
|
Tercio@40
|
3711 if (line) then
|
|
Tercio@40
|
3712 line._InUse = true
|
|
Tercio@40
|
3713 end
|
|
Tercio@40
|
3714 return line
|
|
Tercio@40
|
3715 end
|
|
Tercio@40
|
3716
|
|
Tercio@40
|
3717 DF.ScrollBoxFunctions.SetData = function (self, data)
|
|
Tercio@40
|
3718 self.data = data
|
|
Tercio@40
|
3719 end
|
|
Tercio@40
|
3720 DF.ScrollBoxFunctions.GetData = function (self)
|
|
Tercio@40
|
3721 return self.data
|
|
Tercio@40
|
3722 end
|
|
Tercio@40
|
3723
|
|
Tercio@53
|
3724 DF.ScrollBoxFunctions.GetFrames = function (self)
|
|
Tercio@53
|
3725 return self.Frames
|
|
Tercio@53
|
3726 end
|
|
Tercio@53
|
3727
|
|
Tercio@53
|
3728 DF.ScrollBoxFunctions.GetNumFramesCreated = function (self)
|
|
Tercio@53
|
3729 return #self.Frames
|
|
Tercio@53
|
3730 end
|
|
Tercio@53
|
3731
|
|
Tercio@53
|
3732 DF.ScrollBoxFunctions.GetNumFramesShown = function (self)
|
|
Tercio@53
|
3733 return self.LineAmount
|
|
Tercio@53
|
3734 end
|
|
Tercio@53
|
3735
|
|
Tercio@53
|
3736 DF.ScrollBoxFunctions.SetNumFramesShown = function (self, new_amount)
|
|
Tercio@53
|
3737 --> hide frames which won't be used
|
|
Tercio@53
|
3738 if (new_amount < #self.Frames) then
|
|
Tercio@53
|
3739 for i = new_amount+1, #self.Frames do
|
|
Tercio@53
|
3740 self.Frames [i]:Hide()
|
|
Tercio@53
|
3741 end
|
|
Tercio@53
|
3742 end
|
|
Tercio@53
|
3743
|
|
Tercio@53
|
3744 --> set the new amount
|
|
Tercio@53
|
3745 self.LineAmount = new_amount
|
|
Tercio@53
|
3746 end
|
|
Tercio@53
|
3747
|
|
Tercio@53
|
3748 DF.ScrollBoxFunctions.SetFramesHeight = function (self, new_height)
|
|
Tercio@53
|
3749 self.LineHeight = new_height
|
|
Tercio@53
|
3750 self:OnSizeChanged()
|
|
Tercio@53
|
3751 self:Refresh()
|
|
Tercio@53
|
3752 end
|
|
Tercio@53
|
3753
|
|
Tercio@53
|
3754 DF.ScrollBoxFunctions.OnSizeChanged = function (self)
|
|
Tercio@53
|
3755 if (self.ReajustNumFrames) then
|
|
Tercio@53
|
3756 --> how many lines the scroll can show
|
|
Tercio@53
|
3757 local amountOfFramesToShow = floor (self:GetHeight() / self.LineHeight)
|
|
Tercio@53
|
3758
|
|
Tercio@53
|
3759 --> how many lines the scroll already have
|
|
Tercio@53
|
3760 local totalFramesCreated = self:GetNumFramesCreated()
|
|
Tercio@53
|
3761
|
|
Tercio@53
|
3762 --> how many lines are current shown
|
|
Tercio@53
|
3763 local totalFramesShown = self:GetNumFramesShown()
|
|
Tercio@53
|
3764
|
|
Tercio@53
|
3765 --> the amount of frames increased
|
|
Tercio@53
|
3766 if (amountOfFramesToShow > totalFramesShown) then
|
|
Tercio@53
|
3767 for i = totalFramesShown+1, amountOfFramesToShow do
|
|
Tercio@53
|
3768 --> check if need to create a new line
|
|
Tercio@53
|
3769 if (i > totalFramesCreated) then
|
|
Tercio@53
|
3770 self:CreateLine (self.CreateLineFunc)
|
|
Tercio@53
|
3771 end
|
|
Tercio@53
|
3772 end
|
|
Tercio@53
|
3773
|
|
Tercio@53
|
3774 --> the amount of frames decreased
|
|
Tercio@53
|
3775 elseif (amountOfFramesToShow < totalFramesShown) then
|
|
Tercio@53
|
3776 --> hide all frames above the new amount to show
|
|
Tercio@53
|
3777 for i = totalFramesCreated, amountOfFramesToShow, -1 do
|
|
Tercio@53
|
3778 if (self.Frames [i]) then
|
|
Tercio@53
|
3779 self.Frames [i]:Hide()
|
|
Tercio@53
|
3780 end
|
|
Tercio@53
|
3781 end
|
|
Tercio@53
|
3782 end
|
|
Tercio@53
|
3783
|
|
Tercio@53
|
3784 --> set the new amount of frames
|
|
Tercio@53
|
3785 self:SetNumFramesShown (amountOfFramesToShow)
|
|
Tercio@53
|
3786
|
|
Tercio@53
|
3787 --> refresh lines
|
|
Tercio@53
|
3788 self:Refresh()
|
|
Tercio@53
|
3789 end
|
|
Tercio@53
|
3790 end
|
|
Tercio@53
|
3791
|
|
Tercio@53
|
3792 function DF:CreateScrollBox (parent, name, refresh_func, data, width, height, line_amount, line_height, create_line_func, auto_amount, no_scroll)
|
|
Tercio@40
|
3793 local scroll = CreateFrame ("scrollframe", name, parent, "FauxScrollFrameTemplate")
|
|
Tercio@40
|
3794
|
|
Tercio@40
|
3795 scroll:SetSize (width, height)
|
|
Tercio@40
|
3796 scroll.LineAmount = line_amount
|
|
Tercio@40
|
3797 scroll.LineHeight = line_height
|
|
Tercio@40
|
3798 scroll.IsFauxScroll = true
|
|
Tercio@53
|
3799 scroll.HideScrollBar = no_scroll
|
|
Tercio@40
|
3800 scroll.Frames = {}
|
|
Tercio@53
|
3801 scroll.ReajustNumFrames = auto_amount
|
|
Tercio@53
|
3802 scroll.CreateLineFunc = create_line_func
|
|
Tercio@40
|
3803
|
|
Tercio@40
|
3804 DF:Mixin (scroll, DF.SortFunctions)
|
|
Tercio@40
|
3805 DF:Mixin (scroll, DF.ScrollBoxFunctions)
|
|
Tercio@40
|
3806
|
|
Tercio@40
|
3807 scroll.refresh_func = refresh_func
|
|
Tercio@40
|
3808 scroll.data = data
|
|
Tercio@40
|
3809
|
|
Tercio@40
|
3810 scroll:SetScript ("OnVerticalScroll", scroll.OnVerticalScroll)
|
|
Tercio@53
|
3811 scroll:SetScript ("OnSizeChanged", DF.ScrollBoxFunctions.OnSizeChanged)
|
|
Tercio@40
|
3812
|
|
Tercio@40
|
3813 return scroll
|
|
Tercio@40
|
3814 end
|
|
Tercio@40
|
3815
|
|
Tercio@40
|
3816
|
|
Tercio@53
|
3817 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@53
|
3818 -- ~resizers
|
|
Tercio@40
|
3819
|
|
Tercio@53
|
3820 function DF:CreateResizeGrips (parent)
|
|
Tercio@53
|
3821 if (parent) then
|
|
Tercio@53
|
3822 local parentName = parent:GetName()
|
|
Tercio@53
|
3823
|
|
Tercio@53
|
3824 local leftResizer = CreateFrame ("button", parentName and parentName .. "LeftResizer" or nil, parent)
|
|
Tercio@53
|
3825 local rightResizer = CreateFrame ("button", parentName and parentName .. "RightResizer" or nil, parent)
|
|
Tercio@53
|
3826
|
|
Tercio@53
|
3827 leftResizer:SetPoint ("bottomleft", parent, "bottomleft")
|
|
Tercio@53
|
3828 rightResizer:SetPoint ("bottomright", parent, "bottomright")
|
|
Tercio@53
|
3829 leftResizer:SetSize (16, 16)
|
|
Tercio@53
|
3830 rightResizer:SetSize (16, 16)
|
|
Tercio@53
|
3831
|
|
Tercio@53
|
3832 rightResizer:SetNormalTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]])
|
|
Tercio@53
|
3833 rightResizer:SetHighlightTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]])
|
|
Tercio@53
|
3834 rightResizer:SetPushedTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]])
|
|
Tercio@53
|
3835 leftResizer:SetNormalTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]])
|
|
Tercio@53
|
3836 leftResizer:SetHighlightTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]])
|
|
Tercio@53
|
3837 leftResizer:SetPushedTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]])
|
|
Tercio@53
|
3838
|
|
Tercio@53
|
3839 leftResizer:GetNormalTexture():SetTexCoord (1, 0, 0, 1)
|
|
Tercio@53
|
3840 leftResizer:GetHighlightTexture():SetTexCoord (1, 0, 0, 1)
|
|
Tercio@53
|
3841 leftResizer:GetPushedTexture():SetTexCoord (1, 0, 0, 1)
|
|
Tercio@53
|
3842
|
|
Tercio@53
|
3843 return leftResizer, rightResizer
|
|
Tercio@53
|
3844 end
|
|
Tercio@53
|
3845 end
|