|
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 PanelMetaFunctions = {}
|
|
Tercio@11
|
19 local APIFrameFunctions
|
|
Tercio@11
|
20
|
|
Tercio@11
|
21 local simple_panel_counter = 1
|
|
Tercio@11
|
22
|
|
Tercio@11
|
23 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
24 --> metatables
|
|
Tercio@11
|
25
|
|
Tercio@11
|
26 PanelMetaFunctions.__call = function (_table, value)
|
|
Tercio@11
|
27 --> nothing to do
|
|
Tercio@11
|
28 return true
|
|
Tercio@11
|
29 end
|
|
Tercio@11
|
30
|
|
Tercio@11
|
31 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
32 --> members
|
|
Tercio@11
|
33
|
|
Tercio@11
|
34 --> tooltip
|
|
Tercio@11
|
35 local gmember_tooltip = function (_object)
|
|
Tercio@11
|
36 return _object:GetTooltip()
|
|
Tercio@11
|
37 end
|
|
Tercio@11
|
38 --> shown
|
|
Tercio@11
|
39 local gmember_shown = function (_object)
|
|
Tercio@11
|
40 return _object:IsShown()
|
|
Tercio@11
|
41 end
|
|
Tercio@11
|
42 --> backdrop color
|
|
Tercio@11
|
43 local gmember_color = function (_object)
|
|
Tercio@11
|
44 return _object.frame:GetBackdropColor()
|
|
Tercio@11
|
45 end
|
|
Tercio@11
|
46 --> backdrop table
|
|
Tercio@11
|
47 local gmember_backdrop = function (_object)
|
|
Tercio@11
|
48 return _object.frame:GetBackdrop()
|
|
Tercio@11
|
49 end
|
|
Tercio@11
|
50 --> frame width
|
|
Tercio@11
|
51 local gmember_width = function (_object)
|
|
Tercio@11
|
52 return _object.frame:GetWidth()
|
|
Tercio@11
|
53 end
|
|
Tercio@11
|
54 --> frame height
|
|
Tercio@11
|
55 local gmember_height = function (_object)
|
|
Tercio@11
|
56 return _object.frame:GetHeight()
|
|
Tercio@11
|
57 end
|
|
Tercio@11
|
58 --> locked
|
|
Tercio@11
|
59 local gmember_locked = function (_object)
|
|
Tercio@11
|
60 return _rawget (_object, "is_locked")
|
|
Tercio@11
|
61 end
|
|
Tercio@11
|
62
|
|
Tercio@11
|
63 local get_members_function_index = {
|
|
Tercio@11
|
64 ["tooltip"] = gmember_tooltip,
|
|
Tercio@11
|
65 ["shown"] = gmember_shown,
|
|
Tercio@11
|
66 ["color"] = gmember_color,
|
|
Tercio@11
|
67 ["backdrop"] = gmember_backdrop,
|
|
Tercio@11
|
68 ["width"] = gmember_width,
|
|
Tercio@11
|
69 ["height"] = gmember_height,
|
|
Tercio@11
|
70 ["locked"] = gmember_locked,
|
|
Tercio@11
|
71 }
|
|
Tercio@11
|
72
|
|
Tercio@11
|
73 PanelMetaFunctions.__index = function (_table, _member_requested)
|
|
Tercio@11
|
74
|
|
Tercio@11
|
75 local func = get_members_function_index [_member_requested]
|
|
Tercio@11
|
76 if (func) then
|
|
Tercio@11
|
77 return func (_table, _member_requested)
|
|
Tercio@11
|
78 end
|
|
Tercio@11
|
79
|
|
Tercio@11
|
80 local fromMe = _rawget (_table, _member_requested)
|
|
Tercio@11
|
81 if (fromMe) then
|
|
Tercio@11
|
82 return fromMe
|
|
Tercio@11
|
83 end
|
|
Tercio@11
|
84
|
|
Tercio@11
|
85 return PanelMetaFunctions [_member_requested]
|
|
Tercio@11
|
86 end
|
|
Tercio@11
|
87
|
|
Tercio@11
|
88
|
|
Tercio@11
|
89 --> tooltip
|
|
Tercio@11
|
90 local smember_tooltip = function (_object, _value)
|
|
Tercio@11
|
91 return _object:SetTooltip (_value)
|
|
Tercio@11
|
92 end
|
|
Tercio@11
|
93 --> show
|
|
Tercio@11
|
94 local smember_show = function (_object, _value)
|
|
Tercio@11
|
95 if (_value) then
|
|
Tercio@11
|
96 return _object:Show()
|
|
Tercio@11
|
97 else
|
|
Tercio@11
|
98 return _object:Hide()
|
|
Tercio@11
|
99 end
|
|
Tercio@11
|
100 end
|
|
Tercio@11
|
101 --> hide
|
|
Tercio@11
|
102 local smember_hide = function (_object, _value)
|
|
Tercio@11
|
103 if (not _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 --> backdrop color
|
|
Tercio@11
|
110 local smember_color = function (_object, _value)
|
|
Tercio@11
|
111 local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
|
|
Tercio@11
|
112 return _object:SetBackdropColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
113 end
|
|
Tercio@11
|
114 --> frame width
|
|
Tercio@11
|
115 local smember_width = function (_object, _value)
|
|
Tercio@11
|
116 return _object.frame:SetWidth (_value)
|
|
Tercio@11
|
117 end
|
|
Tercio@11
|
118 --> frame height
|
|
Tercio@11
|
119 local smember_height = function (_object, _value)
|
|
Tercio@11
|
120 return _object.frame:SetHeight (_value)
|
|
Tercio@11
|
121 end
|
|
Tercio@11
|
122
|
|
Tercio@11
|
123 --> locked
|
|
Tercio@11
|
124 local smember_locked = function (_object, _value)
|
|
Tercio@11
|
125 if (_value) then
|
|
Tercio@11
|
126 _object.frame:SetMovable (false)
|
|
Tercio@11
|
127 return _rawset (_object, "is_locked", true)
|
|
Tercio@11
|
128 else
|
|
Tercio@11
|
129 _object.frame:SetMovable (true)
|
|
Tercio@11
|
130 _rawset (_object, "is_locked", false)
|
|
Tercio@11
|
131 return
|
|
Tercio@11
|
132 end
|
|
Tercio@11
|
133 end
|
|
Tercio@11
|
134
|
|
Tercio@11
|
135 --> backdrop
|
|
Tercio@11
|
136 local smember_backdrop = function (_object, _value)
|
|
Tercio@11
|
137 return _object.frame:SetBackdrop (_value)
|
|
Tercio@11
|
138 end
|
|
Tercio@11
|
139
|
|
Tercio@11
|
140 --> close with right button
|
|
Tercio@11
|
141 local smember_right_close = function (_object, _value)
|
|
Tercio@11
|
142 return _rawset (_object, "rightButtonClose", _value)
|
|
Tercio@11
|
143 end
|
|
Tercio@11
|
144
|
|
Tercio@11
|
145 local set_members_function_index = {
|
|
Tercio@11
|
146 ["tooltip"] = smember_tooltip,
|
|
Tercio@11
|
147 ["show"] = smember_show,
|
|
Tercio@11
|
148 ["hide"] = smember_hide,
|
|
Tercio@11
|
149 ["color"] = smember_color,
|
|
Tercio@11
|
150 ["backdrop"] = smember_backdrop,
|
|
Tercio@11
|
151 ["width"] = smember_width,
|
|
Tercio@11
|
152 ["height"] = smember_height,
|
|
Tercio@11
|
153 ["locked"] = smember_locked,
|
|
Tercio@11
|
154 ["close_with_right"] = smember_right_close,
|
|
Tercio@11
|
155 }
|
|
Tercio@11
|
156
|
|
Tercio@11
|
157 PanelMetaFunctions.__newindex = function (_table, _key, _value)
|
|
Tercio@11
|
158 local func = set_members_function_index [_key]
|
|
Tercio@11
|
159 if (func) then
|
|
Tercio@11
|
160 return func (_table, _value)
|
|
Tercio@11
|
161 else
|
|
Tercio@11
|
162 return _rawset (_table, _key, _value)
|
|
Tercio@11
|
163 end
|
|
Tercio@11
|
164 end
|
|
Tercio@11
|
165
|
|
Tercio@11
|
166 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
167 --> methods
|
|
Tercio@11
|
168
|
|
Tercio@11
|
169 --> right click to close
|
|
Tercio@11
|
170 function PanelMetaFunctions:CreateRightClickLabel (textType, w, h, close_text)
|
|
Tercio@11
|
171 local text
|
|
Tercio@11
|
172 w = w or 20
|
|
Tercio@11
|
173 h = h or 20
|
|
Tercio@11
|
174
|
|
Tercio@11
|
175 if (close_text) then
|
|
Tercio@11
|
176 text = close_text
|
|
Tercio@11
|
177 else
|
|
Tercio@11
|
178 if (textType) then
|
|
Tercio@11
|
179 textType = string.lower (textType)
|
|
Tercio@11
|
180 if (textType == "short") then
|
|
Tercio@11
|
181 text = "close window"
|
|
Tercio@11
|
182 elseif (textType == "medium") then
|
|
Tercio@11
|
183 text = "close window"
|
|
Tercio@11
|
184 elseif (textType == "large") then
|
|
Tercio@11
|
185 text = "close window"
|
|
Tercio@11
|
186 end
|
|
Tercio@11
|
187 else
|
|
Tercio@11
|
188 text = "close window"
|
|
Tercio@11
|
189 end
|
|
Tercio@11
|
190 end
|
|
Tercio@11
|
191
|
|
Tercio@11
|
192 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
|
193 end
|
|
Tercio@11
|
194
|
|
Tercio@11
|
195 --> show & hide
|
|
Tercio@11
|
196 function PanelMetaFunctions:Show()
|
|
Tercio@11
|
197 self.frame:Show()
|
|
Tercio@11
|
198
|
|
Tercio@11
|
199 end
|
|
Tercio@11
|
200 function PanelMetaFunctions:Hide()
|
|
Tercio@11
|
201 self.frame:Hide()
|
|
Tercio@11
|
202
|
|
Tercio@11
|
203 end
|
|
Tercio@11
|
204
|
|
Tercio@11
|
205 -- setpoint
|
|
Tercio@11
|
206 function PanelMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
207 v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
|
|
Tercio@11
|
208 if (not v1) then
|
|
Tercio@11
|
209 print ("Invalid parameter for SetPoint")
|
|
Tercio@11
|
210 return
|
|
Tercio@11
|
211 end
|
|
Tercio@11
|
212 return self.widget:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
213 end
|
|
Tercio@11
|
214
|
|
Tercio@11
|
215 -- sizes
|
|
Tercio@11
|
216 function PanelMetaFunctions:SetSize (w, h)
|
|
Tercio@11
|
217 if (w) then
|
|
Tercio@11
|
218 self.frame:SetWidth (w)
|
|
Tercio@11
|
219 end
|
|
Tercio@11
|
220 if (h) then
|
|
Tercio@11
|
221 self.frame:SetHeight (h)
|
|
Tercio@11
|
222 end
|
|
Tercio@11
|
223 end
|
|
Tercio@11
|
224
|
|
Tercio@11
|
225 -- clear
|
|
Tercio@11
|
226 function PanelMetaFunctions:HideWidgets()
|
|
Tercio@11
|
227 for widgetName, widgetSelf in pairs (self) do
|
|
Tercio@11
|
228 if (type (widgetSelf) == "table" and widgetSelf.dframework) then
|
|
Tercio@11
|
229 widgetSelf:Hide()
|
|
Tercio@11
|
230 end
|
|
Tercio@11
|
231 end
|
|
Tercio@11
|
232 end
|
|
Tercio@11
|
233
|
|
Tercio@11
|
234 -- backdrop
|
|
Tercio@11
|
235 function PanelMetaFunctions:SetBackdrop (background, edge, tilesize, edgesize, tile, left, right, top, bottom)
|
|
Tercio@11
|
236
|
|
Tercio@11
|
237 if (_type (background) == "boolean" and not background) then
|
|
Tercio@11
|
238 return self.frame:SetBackdrop (nil)
|
|
Tercio@11
|
239
|
|
Tercio@11
|
240 elseif (_type (background) == "table") then
|
|
Tercio@11
|
241 self.frame:SetBackdrop (background)
|
|
Tercio@11
|
242
|
|
Tercio@11
|
243 else
|
|
Tercio@11
|
244 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
|
245 currentBackdrop.bgFile = background or currentBackdrop.bgFile
|
|
Tercio@11
|
246 currentBackdrop.edgeFile = edgeFile or currentBackdrop.edgeFile
|
|
Tercio@11
|
247 currentBackdrop.tileSize = tilesize or currentBackdrop.tileSize
|
|
Tercio@11
|
248 currentBackdrop.edgeSize = edgesize or currentBackdrop.edgeSize
|
|
Tercio@11
|
249 currentBackdrop.tile = tile or currentBackdrop.tile
|
|
Tercio@11
|
250 currentBackdrop.insets.left = left or currentBackdrop.insets.left
|
|
Tercio@11
|
251 currentBackdrop.insets.right = left or currentBackdrop.insets.right
|
|
Tercio@11
|
252 currentBackdrop.insets.top = left or currentBackdrop.insets.top
|
|
Tercio@11
|
253 currentBackdrop.insets.bottom = left or currentBackdrop.insets.bottom
|
|
Tercio@11
|
254 self.frame:SetBackdrop (currentBackdrop)
|
|
Tercio@11
|
255 end
|
|
Tercio@11
|
256 end
|
|
Tercio@11
|
257
|
|
Tercio@11
|
258 -- backdropcolor
|
|
Tercio@11
|
259 function PanelMetaFunctions:SetBackdropColor (color, arg2, arg3, arg4)
|
|
Tercio@11
|
260 if (arg2) then
|
|
Tercio@11
|
261 self.frame:SetBackdropColor (color, arg2, arg3, arg4 or 1)
|
|
Tercio@11
|
262 else
|
|
Tercio@11
|
263 local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
|
|
Tercio@11
|
264 self.frame:SetBackdropColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
265 end
|
|
Tercio@11
|
266 end
|
|
Tercio@11
|
267
|
|
Tercio@11
|
268 -- border color
|
|
Tercio@11
|
269 function PanelMetaFunctions:SetBackdropBorderColor (color, arg2, arg3, arg4)
|
|
Tercio@11
|
270 if (arg2) then
|
|
Tercio@11
|
271 return self.frame:SetBackdropBorderColor (color, arg2, arg3, arg4)
|
|
Tercio@11
|
272 end
|
|
Tercio@11
|
273 local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
|
|
Tercio@11
|
274 self.frame:SetBackdropBorderColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
275 end
|
|
Tercio@11
|
276
|
|
Tercio@11
|
277 -- tooltip
|
|
Tercio@11
|
278 function PanelMetaFunctions:SetTooltip (tooltip)
|
|
Tercio@11
|
279 if (tooltip) then
|
|
Tercio@11
|
280 return _rawset (self, "have_tooltip", tooltip)
|
|
Tercio@11
|
281 else
|
|
Tercio@11
|
282 return _rawset (self, "have_tooltip", nil)
|
|
Tercio@11
|
283 end
|
|
Tercio@11
|
284 end
|
|
Tercio@11
|
285 function PanelMetaFunctions:GetTooltip()
|
|
Tercio@11
|
286 return _rawget (self, "have_tooltip")
|
|
Tercio@11
|
287 end
|
|
Tercio@11
|
288
|
|
Tercio@11
|
289 -- frame levels
|
|
Tercio@11
|
290 function PanelMetaFunctions:GetFrameLevel()
|
|
Tercio@11
|
291 return self.widget:GetFrameLevel()
|
|
Tercio@11
|
292 end
|
|
Tercio@11
|
293 function PanelMetaFunctions:SetFrameLevel (level, frame)
|
|
Tercio@11
|
294 if (not frame) then
|
|
Tercio@11
|
295 return self.widget:SetFrameLevel (level)
|
|
Tercio@11
|
296 else
|
|
Tercio@11
|
297 local framelevel = frame:GetFrameLevel (frame) + level
|
|
Tercio@11
|
298 return self.widget:SetFrameLevel (framelevel)
|
|
Tercio@11
|
299 end
|
|
Tercio@11
|
300 end
|
|
Tercio@11
|
301
|
|
Tercio@11
|
302 -- frame stratas
|
|
Tercio@11
|
303 function PanelMetaFunctions:SetFrameStrata()
|
|
Tercio@11
|
304 return self.widget:GetFrameStrata()
|
|
Tercio@11
|
305 end
|
|
Tercio@11
|
306 function PanelMetaFunctions:SetFrameStrata (strata)
|
|
Tercio@11
|
307 if (_type (strata) == "table") then
|
|
Tercio@11
|
308 self.widget:SetFrameStrata (strata:GetFrameStrata())
|
|
Tercio@11
|
309 else
|
|
Tercio@11
|
310 self.widget:SetFrameStrata (strata)
|
|
Tercio@11
|
311 end
|
|
Tercio@11
|
312 end
|
|
Tercio@11
|
313
|
|
Tercio@11
|
314 --> hooks
|
|
Tercio@11
|
315 function PanelMetaFunctions:SetHook (hookType, func)
|
|
Tercio@11
|
316 if (func) then
|
|
Tercio@11
|
317 _rawset (self, hookType.."Hook", func)
|
|
Tercio@11
|
318 else
|
|
Tercio@11
|
319 _rawset (self, hookType.."Hook", nil)
|
|
Tercio@11
|
320 end
|
|
Tercio@11
|
321 end
|
|
Tercio@11
|
322
|
|
Tercio@11
|
323 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
324 --> scripts
|
|
Tercio@11
|
325
|
|
Tercio@11
|
326 local OnEnter = function (frame)
|
|
Tercio@11
|
327 if (frame.MyObject.OnEnterHook) then
|
|
Tercio@11
|
328 local interrupt = frame.MyObject.OnEnterHook (frame, frame.MyObject)
|
|
Tercio@11
|
329 if (interrupt) then
|
|
Tercio@11
|
330 return
|
|
Tercio@11
|
331 end
|
|
Tercio@11
|
332 end
|
|
Tercio@11
|
333
|
|
Tercio@11
|
334 if (frame.MyObject.have_tooltip) then
|
|
Tercio@11
|
335 GameCooltip2:Reset()
|
|
Tercio@11
|
336 GameCooltip2:SetType ("tooltip")
|
|
Tercio@11
|
337 GameCooltip2:SetColor ("main", "transparent")
|
|
Tercio@11
|
338 GameCooltip2:AddLine (frame.MyObject.have_tooltip)
|
|
Tercio@11
|
339 GameCooltip2:SetOwner (frame)
|
|
Tercio@11
|
340 GameCooltip2:ShowCooltip()
|
|
Tercio@11
|
341 end
|
|
Tercio@11
|
342 end
|
|
Tercio@11
|
343
|
|
Tercio@11
|
344 local OnLeave = function (frame)
|
|
Tercio@11
|
345 if (frame.MyObject.OnLeaveHook) then
|
|
Tercio@11
|
346 local interrupt = frame.MyObject.OnLeaveHook (frame, frame.MyObject)
|
|
Tercio@11
|
347 if (interrupt) then
|
|
Tercio@11
|
348 return
|
|
Tercio@11
|
349 end
|
|
Tercio@11
|
350 end
|
|
Tercio@11
|
351
|
|
Tercio@11
|
352 if (frame.MyObject.have_tooltip) then
|
|
Tercio@11
|
353 GameCooltip2:ShowMe (false)
|
|
Tercio@11
|
354 end
|
|
Tercio@11
|
355
|
|
Tercio@11
|
356 end
|
|
Tercio@11
|
357
|
|
Tercio@11
|
358 local OnHide = function (frame)
|
|
Tercio@11
|
359 if (frame.MyObject.OnHideHook) then
|
|
Tercio@11
|
360 local interrupt = frame.MyObject.OnHideHook (frame, frame.MyObject)
|
|
Tercio@11
|
361 if (interrupt) then
|
|
Tercio@11
|
362 return
|
|
Tercio@11
|
363 end
|
|
Tercio@11
|
364 end
|
|
Tercio@11
|
365 end
|
|
Tercio@11
|
366
|
|
Tercio@11
|
367 local OnShow = function (frame)
|
|
Tercio@11
|
368 if (frame.MyObject.OnShowHook) then
|
|
Tercio@11
|
369 local interrupt = frame.MyObject.OnShowHook (frame, frame.MyObject)
|
|
Tercio@11
|
370 if (interrupt) then
|
|
Tercio@11
|
371 return
|
|
Tercio@11
|
372 end
|
|
Tercio@11
|
373 end
|
|
Tercio@11
|
374 end
|
|
Tercio@11
|
375
|
|
Tercio@11
|
376 local OnMouseDown = function (frame, button)
|
|
Tercio@11
|
377 if (frame.MyObject.OnMouseDownHook) then
|
|
Tercio@11
|
378 local interrupt = frame.MyObject.OnMouseDownHook (frame, button, frame.MyObject)
|
|
Tercio@11
|
379 if (interrupt) then
|
|
Tercio@11
|
380 return
|
|
Tercio@11
|
381 end
|
|
Tercio@11
|
382 end
|
|
Tercio@11
|
383
|
|
Tercio@11
|
384 if (frame.MyObject.container == UIParent) then
|
|
Tercio@11
|
385 if (not frame.isLocked and frame:IsMovable()) then
|
|
Tercio@11
|
386 frame.isMoving = true
|
|
Tercio@11
|
387 frame:StartMoving()
|
|
Tercio@11
|
388 end
|
|
Tercio@11
|
389
|
|
Tercio@11
|
390 elseif (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
|
|
Tercio@11
|
391 if (not frame.isLocked and frame:IsMovable()) then
|
|
Tercio@11
|
392 frame.MyObject.container.isMoving = true
|
|
Tercio@11
|
393 frame.MyObject.container:StartMoving()
|
|
Tercio@11
|
394 end
|
|
Tercio@11
|
395 end
|
|
Tercio@11
|
396
|
|
Tercio@11
|
397
|
|
Tercio@11
|
398 end
|
|
Tercio@11
|
399
|
|
Tercio@11
|
400 local OnMouseUp = function (frame, button)
|
|
Tercio@11
|
401 if (frame.MyObject.OnMouseUpHook) then
|
|
Tercio@11
|
402 local interrupt = frame.MyObject.OnMouseUpHook (frame, button, frame.MyObject)
|
|
Tercio@11
|
403 if (interrupt) then
|
|
Tercio@11
|
404 return
|
|
Tercio@11
|
405 end
|
|
Tercio@11
|
406 end
|
|
Tercio@11
|
407
|
|
Tercio@11
|
408 if (button == "RightButton" and frame.MyObject.rightButtonClose) then
|
|
Tercio@11
|
409 frame.MyObject:Hide()
|
|
Tercio@11
|
410 end
|
|
Tercio@11
|
411
|
|
Tercio@11
|
412 if (frame.MyObject.container == UIParent) then
|
|
Tercio@11
|
413 if (frame.isMoving) then
|
|
Tercio@11
|
414 frame:StopMovingOrSizing()
|
|
Tercio@11
|
415 frame.isMoving = false
|
|
Tercio@11
|
416 end
|
|
Tercio@11
|
417 else
|
|
Tercio@11
|
418 if (frame.MyObject.container.isMoving) then
|
|
Tercio@11
|
419 frame.MyObject.container:StopMovingOrSizing()
|
|
Tercio@11
|
420 frame.MyObject.container.isMoving = false
|
|
Tercio@11
|
421 end
|
|
Tercio@11
|
422 end
|
|
Tercio@11
|
423 end
|
|
Tercio@11
|
424
|
|
Tercio@11
|
425 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
426 --> object constructor
|
|
Tercio@11
|
427 function DF:CreatePanel (parent, w, h, backdrop, backdropcolor, bordercolor, member, name)
|
|
Tercio@11
|
428 return DF:NewPanel (parent, parent, name, member, w, h, backdrop, backdropcolor, bordercolor)
|
|
Tercio@11
|
429 end
|
|
Tercio@11
|
430
|
|
Tercio@11
|
431 function DF:NewPanel (parent, container, name, member, w, h, backdrop, backdropcolor, bordercolor)
|
|
Tercio@11
|
432
|
|
Tercio@11
|
433 if (not name) then
|
|
Tercio@11
|
434 name = "DetailsFrameworkPanelNumber" .. DF.PanelCounter
|
|
Tercio@11
|
435 DF.PanelCounter = DF.PanelCounter + 1
|
|
Tercio@11
|
436
|
|
Tercio@11
|
437 elseif (not parent) then
|
|
Tercio@11
|
438 parent = UIParent
|
|
Tercio@11
|
439 end
|
|
Tercio@11
|
440 if (not container) then
|
|
Tercio@11
|
441 container = parent
|
|
Tercio@11
|
442 end
|
|
Tercio@11
|
443
|
|
Tercio@11
|
444 if (name:find ("$parent")) then
|
|
Tercio@11
|
445 name = name:gsub ("$parent", parent:GetName())
|
|
Tercio@11
|
446 end
|
|
Tercio@11
|
447
|
|
Tercio@11
|
448 local PanelObject = {type = "panel", dframework = true}
|
|
Tercio@11
|
449
|
|
Tercio@11
|
450 if (member) then
|
|
Tercio@11
|
451 parent [member] = PanelObject
|
|
Tercio@11
|
452 end
|
|
Tercio@11
|
453
|
|
Tercio@11
|
454 if (parent.dframework) then
|
|
Tercio@11
|
455 parent = parent.widget
|
|
Tercio@11
|
456 end
|
|
Tercio@11
|
457 if (container.dframework) then
|
|
Tercio@11
|
458 container = container.widget
|
|
Tercio@11
|
459 end
|
|
Tercio@11
|
460
|
|
Tercio@11
|
461
|
|
Tercio@11
|
462 --> default members:
|
|
Tercio@11
|
463 --> hooks
|
|
Tercio@11
|
464 PanelObject.OnEnterHook = nil
|
|
Tercio@11
|
465 PanelObject.OnLeaveHook = nil
|
|
Tercio@11
|
466 PanelObject.OnHideHook = nil
|
|
Tercio@11
|
467 PanelObject.OnShowHook = nil
|
|
Tercio@11
|
468 PanelObject.OnMouseDownHook = nil
|
|
Tercio@11
|
469 PanelObject.OnMouseUpHook = nil
|
|
Tercio@11
|
470 --> misc
|
|
Tercio@11
|
471 PanelObject.is_locked = true
|
|
Tercio@11
|
472 PanelObject.container = container
|
|
Tercio@11
|
473 PanelObject.rightButtonClose = false
|
|
Tercio@11
|
474
|
|
Tercio@11
|
475 PanelObject.frame = CreateFrame ("frame", name, parent, "DetailsFrameworkPanelTemplate")
|
|
Tercio@11
|
476 PanelObject.widget = PanelObject.frame
|
|
Tercio@11
|
477
|
|
Tercio@11
|
478 if (not APIFrameFunctions) then
|
|
Tercio@11
|
479 APIFrameFunctions = {}
|
|
Tercio@11
|
480 local idx = getmetatable (PanelObject.frame).__index
|
|
Tercio@11
|
481 for funcName, funcAddress in pairs (idx) do
|
|
Tercio@11
|
482 if (not PanelMetaFunctions [funcName]) then
|
|
Tercio@11
|
483 PanelMetaFunctions [funcName] = function (object, ...)
|
|
Tercio@20
|
484 local x = loadstring ( "return _G['"..object.frame:GetName().."']:"..funcName.."(...)")
|
|
Tercio@11
|
485 return x (...)
|
|
Tercio@11
|
486 end
|
|
Tercio@11
|
487 end
|
|
Tercio@11
|
488 end
|
|
Tercio@11
|
489 end
|
|
Tercio@11
|
490
|
|
Tercio@11
|
491 PanelObject.frame:SetWidth (w or 100)
|
|
Tercio@11
|
492 PanelObject.frame:SetHeight (h or 100)
|
|
Tercio@11
|
493
|
|
Tercio@11
|
494 PanelObject.frame.MyObject = PanelObject
|
|
Tercio@11
|
495
|
|
Tercio@11
|
496 --> hooks
|
|
Tercio@11
|
497 PanelObject.frame:SetScript ("OnEnter", OnEnter)
|
|
Tercio@11
|
498 PanelObject.frame:SetScript ("OnLeave", OnLeave)
|
|
Tercio@11
|
499 PanelObject.frame:SetScript ("OnHide", OnHide)
|
|
Tercio@11
|
500 PanelObject.frame:SetScript ("OnShow", OnShow)
|
|
Tercio@11
|
501 PanelObject.frame:SetScript ("OnMouseDown", OnMouseDown)
|
|
Tercio@11
|
502 PanelObject.frame:SetScript ("OnMouseUp", OnMouseUp)
|
|
Tercio@11
|
503
|
|
Tercio@11
|
504 _setmetatable (PanelObject, PanelMetaFunctions)
|
|
Tercio@11
|
505
|
|
Tercio@11
|
506 if (backdrop) then
|
|
Tercio@11
|
507 PanelObject:SetBackdrop (backdrop)
|
|
Tercio@11
|
508 elseif (_type (backdrop) == "boolean") then
|
|
Tercio@11
|
509 PanelObject.frame:SetBackdrop (nil)
|
|
Tercio@11
|
510 end
|
|
Tercio@11
|
511
|
|
Tercio@11
|
512 if (backdropcolor) then
|
|
Tercio@11
|
513 PanelObject:SetBackdropColor (backdropcolor)
|
|
Tercio@11
|
514 end
|
|
Tercio@11
|
515
|
|
Tercio@11
|
516 if (bordercolor) then
|
|
Tercio@11
|
517 PanelObject:SetBackdropBorderColor (bordercolor)
|
|
Tercio@11
|
518 end
|
|
Tercio@11
|
519
|
|
Tercio@11
|
520 return PanelObject
|
|
Tercio@11
|
521 end
|
|
Tercio@11
|
522
|
|
Tercio@11
|
523 ------------fill panel
|
|
Tercio@11
|
524
|
|
Tercio@11
|
525 local button_on_enter = function (self)
|
|
Tercio@11
|
526 self.MyObject._icon:SetBlendMode ("ADD")
|
|
Tercio@11
|
527 end
|
|
Tercio@11
|
528 local button_on_leave = function (self)
|
|
Tercio@11
|
529 self.MyObject._icon:SetBlendMode ("BLEND")
|
|
Tercio@11
|
530 end
|
|
Tercio@11
|
531
|
|
Tercio@20
|
532 local add_row = function (self, t, need_update)
|
|
Tercio@20
|
533 local index = #self.rows+1
|
|
Tercio@20
|
534
|
|
Tercio@20
|
535 local thisrow = DF:NewPanel (self, self, "$parentHeader_" .. self._name .. index, nil, 1, 20)
|
|
Tercio@20
|
536 thisrow.backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]}
|
|
Tercio@20
|
537 thisrow.color = "silver"
|
|
Tercio@20
|
538 thisrow.type = t.type
|
|
Tercio@20
|
539 thisrow.func = t.func
|
|
Tercio@20
|
540 thisrow.name = t.name
|
|
Tercio@20
|
541 thisrow.notext = t.notext
|
|
Tercio@20
|
542 thisrow.icon = t.icon
|
|
Tercio@20
|
543 thisrow.iconalign = t.iconalign
|
|
Tercio@20
|
544
|
|
Tercio@20
|
545 thisrow.hidden = t.hidden or false
|
|
Tercio@20
|
546
|
|
Tercio@20
|
547 local text = DF:NewLabel (thisrow, nil, self._name .. "$parentLabel" .. index, "text")
|
|
Tercio@20
|
548 text:SetPoint ("left", thisrow, "left", 2, 0)
|
|
Tercio@20
|
549 text:SetText (t.name)
|
|
Tercio@20
|
550
|
|
Tercio@20
|
551 tinsert (self._raw_rows, t)
|
|
Tercio@20
|
552 tinsert (self.rows, thisrow)
|
|
Tercio@20
|
553
|
|
Tercio@20
|
554 if (need_update) then
|
|
Tercio@20
|
555 self:AlignRows()
|
|
Tercio@20
|
556 end
|
|
Tercio@11
|
557 end
|
|
Tercio@11
|
558
|
|
Tercio@20
|
559 local align_rows = function (self)
|
|
Tercio@20
|
560
|
|
Tercio@20
|
561 local rows_shown = 0
|
|
Tercio@20
|
562 for index, row in ipairs (self.rows) do
|
|
Tercio@20
|
563 if (not row.hidden) then
|
|
Tercio@20
|
564 rows_shown = rows_shown + 1
|
|
Tercio@20
|
565 end
|
|
Tercio@20
|
566 end
|
|
Tercio@20
|
567
|
|
Tercio@20
|
568 local cur_width = 0
|
|
Tercio@20
|
569 local row_width = self._width / rows_shown
|
|
Tercio@22
|
570
|
|
Tercio@20
|
571 local sindex = 1
|
|
Tercio@20
|
572
|
|
Tercio@20
|
573 wipe (self._anchors)
|
|
Tercio@20
|
574
|
|
Tercio@20
|
575 for index, row in ipairs (self.rows) do
|
|
Tercio@20
|
576 if (not row.hidden) then
|
|
Tercio@20
|
577 if (self._autowidth) then
|
|
Tercio@20
|
578 if (self._raw_rows [index].width) then
|
|
Tercio@20
|
579 row.width = self._raw_rows [index].width
|
|
Tercio@20
|
580 else
|
|
Tercio@20
|
581 row.width = row_width
|
|
Tercio@20
|
582 end
|
|
Tercio@20
|
583 row:SetPoint ("topleft", self, "topleft", cur_width, 0)
|
|
Tercio@20
|
584 tinsert (self._anchors, cur_width)
|
|
Tercio@20
|
585 cur_width = cur_width + row_width + 1
|
|
Tercio@20
|
586 else
|
|
Tercio@20
|
587 row:SetPoint ("topleft", self, "topleft", cur_width, 0)
|
|
Tercio@20
|
588 row.width = self._raw_rows [index].width
|
|
Tercio@20
|
589 tinsert (self._anchors, cur_width)
|
|
Tercio@20
|
590 cur_width = cur_width + self._raw_rows [index].width + 1
|
|
Tercio@20
|
591 end
|
|
Tercio@20
|
592 row:Show()
|
|
Tercio@20
|
593
|
|
Tercio@20
|
594 local type = row.type
|
|
Tercio@20
|
595
|
|
Tercio@20
|
596 if (type == "text") then
|
|
Tercio@20
|
597 for i = 1, #self.scrollframe.lines do
|
|
Tercio@20
|
598 local line = self.scrollframe.lines [i]
|
|
Tercio@20
|
599 local text = tremove (line.text_available)
|
|
Tercio@20
|
600 if (not text) then
|
|
Tercio@20
|
601 self:CreateRowText (line)
|
|
Tercio@20
|
602 text = tremove (line.text_available)
|
|
Tercio@20
|
603 end
|
|
Tercio@20
|
604 tinsert (line.text_inuse, text)
|
|
Tercio@20
|
605 text:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
|
|
Tercio@20
|
606 text:SetWidth (row.width)
|
|
Tercio@20
|
607 end
|
|
Tercio@20
|
608 elseif (type == "entry") then
|
|
Tercio@20
|
609 for i = 1, #self.scrollframe.lines do
|
|
Tercio@20
|
610 local line = self.scrollframe.lines [i]
|
|
Tercio@20
|
611 local entry = tremove (line.entry_available)
|
|
Tercio@20
|
612 if (not entry) then
|
|
Tercio@20
|
613 self:CreateRowEntry (line)
|
|
Tercio@20
|
614 entry = tremove (line.entry_available)
|
|
Tercio@20
|
615 end
|
|
Tercio@20
|
616 tinsert (line.entry_inuse, entry)
|
|
Tercio@20
|
617 entry:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
|
|
Tercio@20
|
618 if (sindex == rows_shown) then
|
|
Tercio@20
|
619 entry:SetWidth (row.width - 25)
|
|
Tercio@20
|
620 else
|
|
Tercio@20
|
621 entry:SetWidth (row.width)
|
|
Tercio@20
|
622 end
|
|
Tercio@20
|
623 entry.func = row.func
|
|
Tercio@20
|
624 end
|
|
Tercio@20
|
625 elseif (type == "button") then
|
|
Tercio@20
|
626 for i = 1, #self.scrollframe.lines do
|
|
Tercio@20
|
627 local line = self.scrollframe.lines [i]
|
|
Tercio@20
|
628 local button = tremove (line.button_available)
|
|
Tercio@20
|
629 if (not button) then
|
|
Tercio@20
|
630 self:CreateRowButton (line)
|
|
Tercio@20
|
631 button = tremove (line.button_available)
|
|
Tercio@20
|
632 end
|
|
Tercio@20
|
633 tinsert (line.button_inuse, button)
|
|
Tercio@20
|
634 button:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
|
|
Tercio@20
|
635 if (sindex == rows_shown) then
|
|
Tercio@20
|
636 button:SetWidth (row.width - 25)
|
|
Tercio@20
|
637 else
|
|
Tercio@20
|
638 button:SetWidth (row.width)
|
|
Tercio@20
|
639 end
|
|
Tercio@20
|
640
|
|
Tercio@20
|
641 if (row.icon) then
|
|
Tercio@20
|
642 button._icon.texture = row.icon
|
|
Tercio@20
|
643 button._icon:ClearAllPoints()
|
|
Tercio@20
|
644 if (row.iconalign) then
|
|
Tercio@20
|
645 if (row.iconalign == "center") then
|
|
Tercio@20
|
646 button._icon:SetPoint ("center", button, "center")
|
|
Tercio@20
|
647 elseif (row.iconalign == "right") then
|
|
Tercio@20
|
648 button._icon:SetPoint ("right", button, "right")
|
|
Tercio@20
|
649 end
|
|
Tercio@20
|
650 else
|
|
Tercio@20
|
651 button._icon:SetPoint ("left", button, "left")
|
|
Tercio@20
|
652 end
|
|
Tercio@20
|
653 end
|
|
Tercio@20
|
654
|
|
Tercio@20
|
655 if (row.name and not row.notext) then
|
|
Tercio@20
|
656 button._text:SetPoint ("left", button._icon, "right", 2, 0)
|
|
Tercio@20
|
657 button._text.text = row.name
|
|
Tercio@20
|
658 end
|
|
Tercio@20
|
659
|
|
Tercio@20
|
660 end
|
|
Tercio@20
|
661 elseif (type == "icon") then
|
|
Tercio@20
|
662 for i = 1, #self.scrollframe.lines do
|
|
Tercio@20
|
663 local line = self.scrollframe.lines [i]
|
|
Tercio@20
|
664 local icon = tremove (line.icon_available)
|
|
Tercio@20
|
665 if (not icon) then
|
|
Tercio@20
|
666 self:CreateRowIcon (line)
|
|
Tercio@20
|
667 icon = tremove (line.icon_available)
|
|
Tercio@20
|
668 end
|
|
Tercio@20
|
669 tinsert (line.icon_inuse, icon)
|
|
Tercio@20
|
670 icon:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ( ((row.width or 22) - 22) / 2), 0)
|
|
Tercio@20
|
671 icon.func = row.func
|
|
Tercio@20
|
672 end
|
|
Tercio@20
|
673 end
|
|
Tercio@20
|
674
|
|
Tercio@20
|
675 sindex = sindex + 1
|
|
Tercio@20
|
676 else
|
|
Tercio@20
|
677 row:Hide()
|
|
Tercio@20
|
678 end
|
|
Tercio@20
|
679 end
|
|
Tercio@20
|
680
|
|
Tercio@20
|
681 if (#self.rows > 0) then
|
|
Tercio@20
|
682 if (self._autowidth) then
|
|
Tercio@20
|
683 self.rows [#self.rows]:SetWidth (row_width - rows_shown + 1)
|
|
Tercio@20
|
684 else
|
|
Tercio@20
|
685 self.rows [#self.rows]:SetWidth (self._raw_rows [rows_shown].width - rows_shown + 1)
|
|
Tercio@20
|
686 end
|
|
Tercio@20
|
687 end
|
|
Tercio@20
|
688
|
|
Tercio@20
|
689 self.showing_amt = rows_shown
|
|
Tercio@20
|
690 end
|
|
Tercio@20
|
691
|
|
Tercio@20
|
692 local update_rows = function (self, updated_rows)
|
|
Tercio@20
|
693 for i = 1, #updated_rows do
|
|
Tercio@20
|
694 local t = updated_rows [i]
|
|
Tercio@20
|
695 local raw = self._raw_rows [i]
|
|
Tercio@20
|
696
|
|
Tercio@20
|
697 if (not raw) then
|
|
Tercio@20
|
698 self:AddRow (t)
|
|
Tercio@20
|
699 else
|
|
Tercio@20
|
700 raw.name = t.name
|
|
Tercio@20
|
701 raw.hidden = t.hidden or false
|
|
Tercio@20
|
702
|
|
Tercio@20
|
703 local widget = self.rows [i]
|
|
Tercio@20
|
704 widget.name = t.name
|
|
Tercio@20
|
705 widget.hidden = t.hidden or false
|
|
Tercio@20
|
706
|
|
Tercio@20
|
707 widget.text:SetText (t.name)
|
|
Tercio@20
|
708 end
|
|
Tercio@20
|
709 end
|
|
Tercio@20
|
710
|
|
Tercio@20
|
711 for i = #updated_rows+1, #self._raw_rows do
|
|
Tercio@20
|
712 local raw = self._raw_rows [i]
|
|
Tercio@20
|
713 local widget = self.rows [i]
|
|
Tercio@20
|
714 raw.hidden = true
|
|
Tercio@20
|
715 widget.hidden = true
|
|
Tercio@20
|
716 end
|
|
Tercio@20
|
717
|
|
Tercio@20
|
718 for index, row in ipairs (self.scrollframe.lines) do
|
|
Tercio@20
|
719 for i = #row.text_inuse, 1, -1 do
|
|
Tercio@20
|
720 tinsert (row.text_available, tremove (row.text_inuse, i))
|
|
Tercio@20
|
721 end
|
|
Tercio@20
|
722 for i = 1, #row.text_available do
|
|
Tercio@20
|
723 row.text_available[i]:Hide()
|
|
Tercio@20
|
724 end
|
|
Tercio@20
|
725
|
|
Tercio@20
|
726 for i = #row.entry_inuse, 1, -1 do
|
|
Tercio@20
|
727 tinsert (row.entry_available, tremove (row.entry_inuse, i))
|
|
Tercio@20
|
728 end
|
|
Tercio@20
|
729 for i = 1, #row.entry_available do
|
|
Tercio@20
|
730 row.entry_available[i]:Hide()
|
|
Tercio@20
|
731 end
|
|
Tercio@20
|
732
|
|
Tercio@20
|
733 for i = #row.button_inuse, 1, -1 do
|
|
Tercio@20
|
734 tinsert (row.button_available, tremove (row.button_inuse, i))
|
|
Tercio@20
|
735 end
|
|
Tercio@20
|
736 for i = 1, #row.button_available do
|
|
Tercio@20
|
737 row.button_available[i]:Hide()
|
|
Tercio@20
|
738 end
|
|
Tercio@20
|
739
|
|
Tercio@20
|
740 for i = #row.icon_inuse, 1, -1 do
|
|
Tercio@20
|
741 tinsert (row.icon_available, tremove (row.icon_inuse, i))
|
|
Tercio@20
|
742 end
|
|
Tercio@20
|
743 for i = 1, #row.icon_available do
|
|
Tercio@20
|
744 row.icon_available[i]:Hide()
|
|
Tercio@20
|
745 end
|
|
Tercio@20
|
746 end
|
|
Tercio@20
|
747
|
|
Tercio@22
|
748 self.current_header = updated_rows
|
|
Tercio@22
|
749
|
|
Tercio@20
|
750 self:AlignRows()
|
|
Tercio@20
|
751
|
|
Tercio@20
|
752 end
|
|
Tercio@20
|
753
|
|
Tercio@20
|
754 local create_panel_text = function (self, row)
|
|
Tercio@20
|
755 row.text_total = row.text_total + 1
|
|
Tercio@20
|
756 local text = DF:NewLabel (row, nil, self._name .. "$parentLabel" .. row.text_total, "text" .. row.text_total)
|
|
Tercio@20
|
757 tinsert (row.text_available, text)
|
|
Tercio@20
|
758 end
|
|
Tercio@20
|
759
|
|
Tercio@20
|
760 local create_panel_entry = function (self, row)
|
|
Tercio@20
|
761 row.entry_total = row.entry_total + 1
|
|
Tercio@20
|
762 local editbox = DF:NewTextEntry (row, nil, "$parentEntry" .. row.entry_total, "entry", 120, 20)
|
|
Tercio@20
|
763 editbox.align = "left"
|
|
Tercio@20
|
764
|
|
Tercio@20
|
765 editbox:SetHook ("OnEnterPressed", function()
|
|
Tercio@20
|
766 editbox.widget.focuslost = true
|
|
Tercio@20
|
767 editbox:ClearFocus()
|
|
Tercio@20
|
768 editbox.func (editbox.index, editbox.text)
|
|
Tercio@20
|
769 return true
|
|
Tercio@20
|
770 end)
|
|
Tercio@20
|
771
|
|
Tercio@20
|
772 editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1})
|
|
Tercio@20
|
773 editbox:SetBackdropColor (1, 1, 1, 0.1)
|
|
Tercio@20
|
774 editbox:SetBackdropBorderColor (1, 1, 1, 0.1)
|
|
Tercio@20
|
775 editbox.editbox.current_bordercolor = {1, 1, 1, 0.1}
|
|
Tercio@20
|
776
|
|
Tercio@20
|
777 tinsert (row.entry_available, editbox)
|
|
Tercio@20
|
778 end
|
|
Tercio@20
|
779
|
|
Tercio@20
|
780 local create_panel_button = function (self, row)
|
|
Tercio@20
|
781 row.button_total = row.button_total + 1
|
|
Tercio@20
|
782 local button = DF:NewButton (row, nil, "$parentButton" .. row.button_total, "button" .. row.button_total, 120, 20)
|
|
Tercio@22
|
783 --, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
|
|
Tercio@22
|
784 --button:InstallCustomTexture()
|
|
Tercio@20
|
785
|
|
Tercio@20
|
786 --> create icon and the text
|
|
Tercio@20
|
787 local icon = DF:NewImage (button, nil, 20, 20)
|
|
Tercio@20
|
788 local text = DF:NewLabel (button)
|
|
Tercio@20
|
789
|
|
Tercio@20
|
790 button._icon = icon
|
|
Tercio@20
|
791 button._text = text
|
|
Tercio@20
|
792
|
|
Tercio@20
|
793 button:SetHook ("OnEnter", button_on_enter)
|
|
Tercio@20
|
794 button:SetHook ("OnLeave", button_on_leave)
|
|
Tercio@20
|
795
|
|
Tercio@20
|
796 tinsert (row.button_available, button)
|
|
Tercio@20
|
797 end
|
|
Tercio@20
|
798
|
|
Tercio@20
|
799 local icon_onclick = function (texture, iconbutton)
|
|
Tercio@20
|
800 iconbutton._icon.texture = texture
|
|
Tercio@20
|
801 iconbutton.func (iconbutton.index, texture)
|
|
Tercio@20
|
802 end
|
|
Tercio@20
|
803
|
|
Tercio@20
|
804 local create_panel_icon = function (self, row)
|
|
Tercio@20
|
805 row.icon_total = row.icon_total + 1
|
|
Tercio@20
|
806 local iconbutton = DF:NewButton (row, nil, "$parentIconButton" .. row.icon_total, "iconbutton", 22, 20)
|
|
Tercio@20
|
807 iconbutton:InstallCustomTexture()
|
|
Tercio@20
|
808
|
|
Tercio@20
|
809 iconbutton:SetHook ("OnEnter", button_on_enter)
|
|
Tercio@20
|
810 iconbutton:SetHook ("OnLeave", button_on_leave)
|
|
Tercio@20
|
811
|
|
Tercio@20
|
812 iconbutton:SetHook ("OnMouseUp", function()
|
|
Tercio@20
|
813 DF:IconPick (icon_onclick, true, iconbutton)
|
|
Tercio@20
|
814 return true
|
|
Tercio@20
|
815 end)
|
|
Tercio@20
|
816
|
|
Tercio@20
|
817 local icon = DF:NewImage (iconbutton, nil, 20, 20, "artwork", nil, "_icon", "$parentIcon" .. row.icon_total)
|
|
Tercio@20
|
818 iconbutton._icon = icon
|
|
Tercio@20
|
819
|
|
Tercio@20
|
820 icon:SetPoint ("center", iconbutton, "center", 0, 0)
|
|
Tercio@20
|
821
|
|
Tercio@20
|
822 tinsert (row.icon_available, iconbutton)
|
|
Tercio@20
|
823 end
|
|
Tercio@20
|
824
|
|
Tercio@20
|
825 local set_fill_function = function (self, func)
|
|
Tercio@20
|
826 self._fillfunc = func
|
|
Tercio@20
|
827 end
|
|
Tercio@20
|
828 local set_total_function = function (self, func)
|
|
Tercio@20
|
829 self._totalfunc = func
|
|
Tercio@20
|
830 end
|
|
Tercio@20
|
831 local drop_header_function = function (self)
|
|
Tercio@20
|
832 wipe (self.rows)
|
|
Tercio@20
|
833 end
|
|
Tercio@22
|
834
|
|
Tercio@22
|
835 local fillpanel_update_size = function (self, elapsed)
|
|
Tercio@22
|
836 local panel = self.MyObject
|
|
Tercio@22
|
837
|
|
Tercio@22
|
838 panel._width = panel:GetWidth()
|
|
Tercio@22
|
839 panel._height = panel:GetHeight()
|
|
Tercio@22
|
840
|
|
Tercio@22
|
841 panel:UpdateRowAmount()
|
|
Tercio@22
|
842 if (panel.current_header) then
|
|
Tercio@22
|
843 update_rows (panel, panel.current_header)
|
|
Tercio@22
|
844 end
|
|
Tercio@22
|
845 panel:Refresh()
|
|
Tercio@22
|
846
|
|
Tercio@22
|
847 self:SetScript ("OnUpdate", nil)
|
|
Tercio@22
|
848 end
|
|
Tercio@22
|
849
|
|
Tercio@20
|
850 -- ~fillpanel
|
|
Tercio@22
|
851 --alias
|
|
Tercio@22
|
852 function DF:CreateFillPanel (parent, rows, w, h, total_lines, fill_row, autowidth, options, member, name)
|
|
Tercio@22
|
853 return DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
|
|
Tercio@22
|
854 end
|
|
Tercio@22
|
855
|
|
Tercio@11
|
856 function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
|
|
Tercio@11
|
857
|
|
Tercio@11
|
858 local panel = DF:NewPanel (parent, parent, name, member, w, h)
|
|
Tercio@11
|
859 panel.backdrop = nil
|
|
Tercio@11
|
860
|
|
Tercio@11
|
861 options = options or {rowheight = 20}
|
|
Tercio@11
|
862 panel.rows = {}
|
|
Tercio@20
|
863
|
|
Tercio@20
|
864 panel.AddRow = add_row
|
|
Tercio@20
|
865 panel.AlignRows = align_rows
|
|
Tercio@20
|
866 panel.UpdateRows = update_rows
|
|
Tercio@20
|
867 panel.CreateRowText = create_panel_text
|
|
Tercio@20
|
868 panel.CreateRowEntry = create_panel_entry
|
|
Tercio@20
|
869 panel.CreateRowButton = create_panel_button
|
|
Tercio@20
|
870 panel.CreateRowIcon = create_panel_icon
|
|
Tercio@20
|
871 panel.SetFillFunction = set_fill_function
|
|
Tercio@20
|
872 panel.SetTotalFunction = set_total_function
|
|
Tercio@20
|
873 panel.DropHeader = drop_header_function
|
|
Tercio@20
|
874
|
|
Tercio@20
|
875 panel._name = name
|
|
Tercio@20
|
876 panel._width = w
|
|
Tercio@20
|
877 panel._height = h
|
|
Tercio@20
|
878 panel._raw_rows = {}
|
|
Tercio@20
|
879 panel._anchors = {}
|
|
Tercio@20
|
880 panel._fillfunc = fill_row
|
|
Tercio@20
|
881 panel._totalfunc = total_lines
|
|
Tercio@20
|
882 panel._autowidth = autowidth
|
|
Tercio@20
|
883
|
|
Tercio@22
|
884 panel:SetScript ("OnSizeChanged", function()
|
|
Tercio@22
|
885 panel:SetScript ("OnUpdate", fillpanel_update_size)
|
|
Tercio@22
|
886 end)
|
|
Tercio@22
|
887
|
|
Tercio@11
|
888 for index, t in ipairs (rows) do
|
|
Tercio@20
|
889 panel.AddRow (panel, t)
|
|
Tercio@11
|
890 end
|
|
Tercio@11
|
891
|
|
Tercio@11
|
892 local refresh_fillbox = function (self)
|
|
Tercio@20
|
893
|
|
Tercio@11
|
894 local offset = FauxScrollFrame_GetOffset (self)
|
|
Tercio@20
|
895 local filled_lines = panel._totalfunc (panel)
|
|
Tercio@20
|
896
|
|
Tercio@11
|
897 for index = 1, #self.lines do
|
|
Tercio@20
|
898
|
|
Tercio@11
|
899 local row = self.lines [index]
|
|
Tercio@11
|
900 if (index <= filled_lines) then
|
|
Tercio@20
|
901
|
|
Tercio@11
|
902 local real_index = index + offset
|
|
Tercio@20
|
903 local results = panel._fillfunc (real_index, panel)
|
|
Tercio@11
|
904
|
|
Tercio@11
|
905 if (results [1]) then
|
|
Tercio@11
|
906 row:Show()
|
|
Tercio@20
|
907
|
|
Tercio@20
|
908 local text, entry, button, icon = 1, 1, 1, 1
|
|
Tercio@11
|
909
|
|
Tercio@20
|
910 for index, t in ipairs (panel.rows) do
|
|
Tercio@20
|
911 if (not t.hidden) then
|
|
Tercio@20
|
912 if (t.type == "text") then
|
|
Tercio@20
|
913 local fontstring = row.text_inuse [text]
|
|
Tercio@20
|
914 text = text + 1
|
|
Tercio@20
|
915 fontstring:SetText (results [index])
|
|
Tercio@20
|
916 fontstring.index = real_index
|
|
Tercio@20
|
917 fontstring:Show()
|
|
Tercio@11
|
918
|
|
Tercio@20
|
919 elseif (t.type == "entry") then
|
|
Tercio@20
|
920 local entrywidget = row.entry_inuse [entry]
|
|
Tercio@20
|
921 entry = entry + 1
|
|
Tercio@20
|
922 entrywidget:SetText (results [index])
|
|
Tercio@20
|
923 entrywidget.index = real_index
|
|
Tercio@20
|
924 entrywidget:Show()
|
|
Tercio@20
|
925
|
|
Tercio@20
|
926 elseif (t.type == "button") then
|
|
Tercio@20
|
927 local buttonwidget = row.button_inuse [button]
|
|
Tercio@20
|
928 button = button + 1
|
|
Tercio@20
|
929 buttonwidget.index = real_index
|
|
Tercio@11
|
930
|
|
Tercio@22
|
931
|
|
Tercio@20
|
932
|
|
Tercio@20
|
933 if (type (results [index]) == "table") then
|
|
Tercio@20
|
934 if (results [index].text) then
|
|
Tercio@20
|
935 buttonwidget:SetText (results [index].text)
|
|
Tercio@20
|
936 end
|
|
Tercio@20
|
937
|
|
Tercio@20
|
938 if (results [index].icon) then
|
|
Tercio@20
|
939 buttonwidget._icon:SetTexture (results [index].icon)
|
|
Tercio@20
|
940 end
|
|
Tercio@20
|
941
|
|
Tercio@20
|
942 if (results [index].func) then
|
|
Tercio@22
|
943 local func = function()
|
|
Tercio@22
|
944 t.func (real_index, results [index].value)
|
|
Tercio@22
|
945 panel:Refresh()
|
|
Tercio@22
|
946 end
|
|
Tercio@22
|
947 buttonwidget:SetClickFunction (func)
|
|
Tercio@22
|
948 else
|
|
Tercio@22
|
949 local func = function()
|
|
Tercio@22
|
950 t.func (real_index, index)
|
|
Tercio@22
|
951 panel:Refresh()
|
|
Tercio@22
|
952 end
|
|
Tercio@22
|
953 buttonwidget:SetClickFunction (func)
|
|
Tercio@20
|
954 end
|
|
Tercio@20
|
955 else
|
|
Tercio@22
|
956 local func = function()
|
|
Tercio@22
|
957 t.func (real_index, index)
|
|
Tercio@22
|
958 panel:Refresh()
|
|
Tercio@22
|
959 end
|
|
Tercio@22
|
960 buttonwidget:SetClickFunction (func)
|
|
Tercio@20
|
961 buttonwidget:SetText (results [index])
|
|
Tercio@11
|
962 end
|
|
Tercio@11
|
963
|
|
Tercio@20
|
964 buttonwidget:Show()
|
|
Tercio@11
|
965
|
|
Tercio@20
|
966 elseif (t.type == "icon") then
|
|
Tercio@20
|
967 local iconwidget = row.icon_inuse [icon]
|
|
Tercio@20
|
968 icon = icon + 1
|
|
Tercio@20
|
969
|
|
Tercio@20
|
970 iconwidget.line = index
|
|
Tercio@20
|
971 iconwidget.index = real_index
|
|
Tercio@20
|
972
|
|
Tercio@20
|
973 local result = results [index]:gsub (".-%\\", "")
|
|
Tercio@20
|
974 iconwidget._icon.texture = results [index]
|
|
Tercio@20
|
975
|
|
Tercio@20
|
976 iconwidget:Show()
|
|
Tercio@11
|
977 end
|
|
Tercio@11
|
978 end
|
|
Tercio@11
|
979 end
|
|
Tercio@20
|
980
|
|
Tercio@11
|
981 else
|
|
Tercio@11
|
982 row:Hide()
|
|
Tercio@11
|
983 end
|
|
Tercio@11
|
984 else
|
|
Tercio@11
|
985 row:Hide()
|
|
Tercio@11
|
986 end
|
|
Tercio@11
|
987 end
|
|
Tercio@11
|
988 end
|
|
Tercio@11
|
989
|
|
Tercio@11
|
990 function panel:Refresh()
|
|
Tercio@22
|
991 if (type (panel._totalfunc) == "boolean") then
|
|
Tercio@22
|
992 --> not yet initialized
|
|
Tercio@22
|
993 return
|
|
Tercio@22
|
994 end
|
|
Tercio@20
|
995 local filled_lines = panel._totalfunc (panel)
|
|
Tercio@17
|
996 local scroll_total_lines = #panel.scrollframe.lines
|
|
Tercio@11
|
997 local line_height = options.rowheight
|
|
Tercio@20
|
998 refresh_fillbox (panel.scrollframe)
|
|
Tercio@11
|
999 FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height)
|
|
Tercio@11
|
1000 end
|
|
Tercio@11
|
1001
|
|
Tercio@11
|
1002 local scrollframe = CreateFrame ("scrollframe", name .. "Scroll", panel.widget, "FauxScrollFrameTemplate")
|
|
Tercio@11
|
1003 scrollframe:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (self, offset, 20, panel.Refresh) end)
|
|
Tercio@11
|
1004 scrollframe:SetPoint ("topleft", panel.widget, "topleft", 0, -21)
|
|
Tercio@11
|
1005 scrollframe:SetPoint ("topright", panel.widget, "topright", -23, -21)
|
|
Tercio@11
|
1006 scrollframe:SetPoint ("bottomleft", panel.widget, "bottomleft")
|
|
Tercio@11
|
1007 scrollframe:SetPoint ("bottomright", panel.widget, "bottomright", -23, 0)
|
|
Tercio@11
|
1008 scrollframe:SetSize (w, h)
|
|
Tercio@11
|
1009 panel.scrollframe = scrollframe
|
|
Tercio@11
|
1010 scrollframe.lines = {}
|
|
Tercio@11
|
1011
|
|
Tercio@11
|
1012 --create lines
|
|
Tercio@22
|
1013 function panel:UpdateRowAmount()
|
|
Tercio@22
|
1014 local size = options.rowheight
|
|
Tercio@22
|
1015 local amount = math.floor (((panel._height-21) / size))
|
|
Tercio@22
|
1016
|
|
Tercio@22
|
1017 for i = #scrollframe.lines+1, amount do
|
|
Tercio@22
|
1018 local row = CreateFrame ("frame", panel:GetName() .. "Row_" .. i, panel.widget)
|
|
Tercio@22
|
1019 row:SetSize (1, size)
|
|
Tercio@22
|
1020 row.color = {1, 1, 1, .2}
|
|
Tercio@22
|
1021
|
|
Tercio@22
|
1022 row:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]]})
|
|
Tercio@22
|
1023
|
|
Tercio@22
|
1024 if (i%2 == 0) then
|
|
Tercio@22
|
1025 row:SetBackdropColor (.5, .5, .5, 0.2)
|
|
Tercio@22
|
1026 else
|
|
Tercio@22
|
1027 row:SetBackdropColor (1, 1, 1, 0.00)
|
|
Tercio@22
|
1028 end
|
|
Tercio@22
|
1029
|
|
Tercio@22
|
1030 row:SetPoint ("topleft", scrollframe, "topleft", 0, (i-1) * size * -1)
|
|
Tercio@22
|
1031 row:SetPoint ("topright", scrollframe, "topright", 0, (i-1) * size * -1)
|
|
Tercio@22
|
1032 tinsert (scrollframe.lines, row)
|
|
Tercio@22
|
1033
|
|
Tercio@22
|
1034 row.text_available = {}
|
|
Tercio@22
|
1035 row.text_inuse = {}
|
|
Tercio@22
|
1036 row.text_total = 0
|
|
Tercio@22
|
1037
|
|
Tercio@22
|
1038 row.entry_available = {}
|
|
Tercio@22
|
1039 row.entry_inuse = {}
|
|
Tercio@22
|
1040 row.entry_total = 0
|
|
Tercio@22
|
1041
|
|
Tercio@22
|
1042 row.button_available = {}
|
|
Tercio@22
|
1043 row.button_inuse = {}
|
|
Tercio@22
|
1044 row.button_total = 0
|
|
Tercio@22
|
1045
|
|
Tercio@22
|
1046 row.icon_available = {}
|
|
Tercio@22
|
1047 row.icon_inuse = {}
|
|
Tercio@22
|
1048 row.icon_total = 0
|
|
Tercio@20
|
1049 end
|
|
Tercio@11
|
1050 end
|
|
Tercio@22
|
1051 panel:UpdateRowAmount()
|
|
Tercio@22
|
1052
|
|
Tercio@20
|
1053 panel.AlignRows (panel)
|
|
Tercio@20
|
1054
|
|
Tercio@11
|
1055 return panel
|
|
Tercio@11
|
1056 end
|
|
Tercio@11
|
1057
|
|
Tercio@11
|
1058
|
|
Tercio@11
|
1059 ------------color pick
|
|
Tercio@11
|
1060 local color_pick_func = function()
|
|
Tercio@11
|
1061 local r, g, b = ColorPickerFrame:GetColorRGB()
|
|
Tercio@11
|
1062 local a = OpacitySliderFrame:GetValue()
|
|
Tercio@11
|
1063 ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
|
|
Tercio@11
|
1064 end
|
|
Tercio@11
|
1065 local color_pick_func_cancel = function()
|
|
Tercio@11
|
1066 ColorPickerFrame:SetColorRGB (unpack (ColorPickerFrame.previousValues))
|
|
Tercio@11
|
1067 local r, g, b = ColorPickerFrame:GetColorRGB()
|
|
Tercio@11
|
1068 local a = OpacitySliderFrame:GetValue()
|
|
Tercio@11
|
1069 ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
|
|
Tercio@11
|
1070 end
|
|
Tercio@11
|
1071
|
|
Tercio@11
|
1072 function DF:ColorPick (frame, r, g, b, alpha, callback)
|
|
Tercio@11
|
1073
|
|
Tercio@11
|
1074 ColorPickerFrame:ClearAllPoints()
|
|
Tercio@11
|
1075 ColorPickerFrame:SetPoint ("bottomleft", frame, "topright", 0, 0)
|
|
Tercio@11
|
1076
|
|
Tercio@11
|
1077 ColorPickerFrame.dcallback = callback
|
|
Tercio@11
|
1078 ColorPickerFrame.dframe = frame
|
|
Tercio@11
|
1079
|
|
Tercio@11
|
1080 ColorPickerFrame.func = color_pick_func
|
|
Tercio@11
|
1081 ColorPickerFrame.opacityFunc = color_pick_func
|
|
Tercio@11
|
1082 ColorPickerFrame.cancelFunc = color_pick_func_cancel
|
|
Tercio@11
|
1083
|
|
Tercio@11
|
1084 ColorPickerFrame.opacity = alpha
|
|
Tercio@11
|
1085 ColorPickerFrame.hasOpacity = alpha and true
|
|
Tercio@11
|
1086
|
|
Tercio@11
|
1087 ColorPickerFrame.previousValues = {r, g, b}
|
|
Tercio@11
|
1088 ColorPickerFrame:SetParent (UIParent)
|
|
Tercio@11
|
1089 ColorPickerFrame:SetFrameStrata ("tooltip")
|
|
Tercio@11
|
1090 ColorPickerFrame:SetColorRGB (r, g, b)
|
|
Tercio@11
|
1091 ColorPickerFrame:Show()
|
|
Tercio@11
|
1092
|
|
Tercio@11
|
1093 end
|
|
Tercio@11
|
1094
|
|
Tercio@11
|
1095 ------------icon pick
|
|
Tercio@20
|
1096 function DF:IconPick (callback, close_when_select, param1, param2)
|
|
Tercio@11
|
1097
|
|
Tercio@11
|
1098 if (not DF.IconPickFrame) then
|
|
Tercio@11
|
1099
|
|
Tercio@11
|
1100 local string_lower = string.lower
|
|
Tercio@11
|
1101
|
|
Tercio@11
|
1102 DF.IconPickFrame = CreateFrame ("frame", "DetailsFrameworkIconPickFrame", UIParent)
|
|
Tercio@11
|
1103 tinsert (UISpecialFrames, "DetailsFrameworkIconPickFrame")
|
|
Tercio@11
|
1104 DF.IconPickFrame:SetFrameStrata ("DIALOG")
|
|
Tercio@11
|
1105
|
|
Tercio@11
|
1106 DF.IconPickFrame:SetPoint ("center", UIParent, "center")
|
|
Tercio@11
|
1107 DF.IconPickFrame:SetWidth (350)
|
|
Tercio@11
|
1108 DF.IconPickFrame:SetHeight (227)
|
|
Tercio@11
|
1109 DF.IconPickFrame:EnableMouse (true)
|
|
Tercio@11
|
1110 DF.IconPickFrame:SetMovable (true)
|
|
Tercio@11
|
1111 DF.IconPickFrame:SetBackdrop ({bgFile = DF.folder .. "background", edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
|
|
Tercio@11
|
1112 tile = true, tileSize = 32, edgeSize = 32, insets = {left = 5, right = 5, top = 5, bottom = 5}})
|
|
Tercio@11
|
1113
|
|
Tercio@11
|
1114 DF.IconPickFrame:SetBackdropBorderColor (170/255, 170/255, 170/255)
|
|
Tercio@11
|
1115 DF.IconPickFrame:SetBackdropColor (24/255, 24/255, 24/255, .8)
|
|
Tercio@11
|
1116 DF.IconPickFrame:SetFrameLevel (1)
|
|
Tercio@11
|
1117
|
|
Tercio@11
|
1118 DF.IconPickFrame.emptyFunction = function() end
|
|
Tercio@11
|
1119 DF.IconPickFrame.callback = DF.IconPickFrame.emptyFunction
|
|
Tercio@11
|
1120
|
|
Tercio@11
|
1121 DF.IconPickFrame.preview = CreateFrame ("frame", nil, UIParent)
|
|
Tercio@11
|
1122 DF.IconPickFrame.preview:SetFrameStrata ("tooltip")
|
|
Tercio@11
|
1123 DF.IconPickFrame.preview:SetSize (76, 76)
|
|
Tercio@11
|
1124 local preview_image = DF:NewImage (DF.IconPickFrame.preview, nil, 76, 76)
|
|
Tercio@11
|
1125 preview_image:SetAllPoints (DF.IconPickFrame.preview)
|
|
Tercio@11
|
1126 DF.IconPickFrame.preview.icon = preview_image
|
|
Tercio@11
|
1127 DF.IconPickFrame.preview:Hide()
|
|
Tercio@11
|
1128
|
|
Tercio@11
|
1129 DF.IconPickFrame.searchLabel = DF:NewLabel (DF.IconPickFrame, nil, "$parentSearchBoxLabel", nil, "search:", font, size, color)
|
|
Tercio@11
|
1130 DF.IconPickFrame.searchLabel:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12, -20)
|
|
Tercio@11
|
1131 DF.IconPickFrame.search = DF:NewTextEntry (DF.IconPickFrame, nil, "$parentSearchBox", nil, 140, 20)
|
|
Tercio@11
|
1132 DF.IconPickFrame.search:SetPoint ("left", DF.IconPickFrame.searchLabel, "right", 2, 0)
|
|
Tercio@11
|
1133 DF.IconPickFrame.search:SetHook ("OnTextChanged", function()
|
|
Tercio@11
|
1134 DF.IconPickFrame.searching = DF.IconPickFrame.search:GetText()
|
|
Tercio@11
|
1135 if (DF.IconPickFrame.searching == "") then
|
|
Tercio@11
|
1136 DF.IconPickFrameScroll:Show()
|
|
Tercio@11
|
1137 DF.IconPickFrame.searching = nil
|
|
Tercio@11
|
1138 DF.IconPickFrame.updateFunc()
|
|
Tercio@11
|
1139 else
|
|
Tercio@11
|
1140 DF.IconPickFrameScroll:Hide()
|
|
Tercio@11
|
1141 FauxScrollFrame_SetOffset (DF.IconPickFrame, 1)
|
|
Tercio@11
|
1142 DF.IconPickFrame.last_filter_index = 1
|
|
Tercio@11
|
1143 DF.IconPickFrame.updateFunc()
|
|
Tercio@11
|
1144 end
|
|
Tercio@11
|
1145 end)
|
|
Tercio@11
|
1146
|
|
Tercio@11
|
1147 --> close button
|
|
Tercio@11
|
1148 local close_button = CreateFrame ("button", nil, DF.IconPickFrame, "UIPanelCloseButton")
|
|
Tercio@11
|
1149 close_button:SetWidth (32)
|
|
Tercio@11
|
1150 close_button:SetHeight (32)
|
|
Tercio@11
|
1151 close_button:SetPoint ("TOPRIGHT", DF.IconPickFrame, "TOPRIGHT", -8, -7)
|
|
Tercio@11
|
1152 close_button:SetFrameLevel (close_button:GetFrameLevel()+2)
|
|
Tercio@11
|
1153
|
|
Tercio@11
|
1154 local MACRO_ICON_FILENAMES = {}
|
|
Tercio@11
|
1155 DF.IconPickFrame:SetScript ("OnShow", function()
|
|
Tercio@11
|
1156
|
|
Tercio@11
|
1157 MACRO_ICON_FILENAMES = {};
|
|
Tercio@11
|
1158 MACRO_ICON_FILENAMES[1] = "INV_MISC_QUESTIONMARK";
|
|
Tercio@11
|
1159 local index = 2;
|
|
Tercio@11
|
1160
|
|
Tercio@11
|
1161 for i = 1, GetNumSpellTabs() do
|
|
Tercio@11
|
1162 local tab, tabTex, offset, numSpells, _ = GetSpellTabInfo(i);
|
|
Tercio@11
|
1163 offset = offset + 1;
|
|
Tercio@11
|
1164 local tabEnd = offset + numSpells;
|
|
Tercio@11
|
1165 for j = offset, tabEnd - 1 do
|
|
Tercio@11
|
1166 --to get spell info by slot, you have to pass in a pet argument
|
|
Tercio@11
|
1167 local spellType, ID = GetSpellBookItemInfo(j, "player");
|
|
Tercio@11
|
1168 if (spellType ~= "FUTURESPELL") then
|
|
Tercio@11
|
1169 local spellTexture = strupper(GetSpellBookItemTexture(j, "player"));
|
|
Tercio@11
|
1170 if ( not string.match( spellTexture, "INTERFACE\\BUTTONS\\") ) then
|
|
Tercio@11
|
1171 MACRO_ICON_FILENAMES[index] = gsub( spellTexture, "INTERFACE\\ICONS\\", "");
|
|
Tercio@11
|
1172 index = index + 1;
|
|
Tercio@11
|
1173 end
|
|
Tercio@11
|
1174 end
|
|
Tercio@11
|
1175 if (spellType == "FLYOUT") then
|
|
Tercio@11
|
1176 local _, _, numSlots, isKnown = GetFlyoutInfo(ID);
|
|
Tercio@11
|
1177 if (isKnown and numSlots > 0) then
|
|
Tercio@11
|
1178 for k = 1, numSlots do
|
|
Tercio@11
|
1179 local spellID, overrideSpellID, isKnown = GetFlyoutSlotInfo(ID, k)
|
|
Tercio@11
|
1180 if (isKnown) then
|
|
Tercio@11
|
1181 MACRO_ICON_FILENAMES[index] = gsub( strupper(GetSpellTexture(spellID)), "INTERFACE\\ICONS\\", "");
|
|
Tercio@11
|
1182 index = index + 1;
|
|
Tercio@11
|
1183 end
|
|
Tercio@11
|
1184 end
|
|
Tercio@11
|
1185 end
|
|
Tercio@11
|
1186 end
|
|
Tercio@11
|
1187 end
|
|
Tercio@11
|
1188 end
|
|
Tercio@11
|
1189
|
|
Tercio@11
|
1190 GetLooseMacroItemIcons (MACRO_ICON_FILENAMES)
|
|
Tercio@11
|
1191 GetLooseMacroIcons (MACRO_ICON_FILENAMES)
|
|
Tercio@11
|
1192 GetMacroIcons (MACRO_ICON_FILENAMES)
|
|
Tercio@11
|
1193 GetMacroItemIcons (MACRO_ICON_FILENAMES )
|
|
Tercio@11
|
1194
|
|
Tercio@11
|
1195 end)
|
|
Tercio@11
|
1196
|
|
Tercio@11
|
1197 DF.IconPickFrame:SetScript ("OnHide", function()
|
|
Tercio@11
|
1198 MACRO_ICON_FILENAMES = nil;
|
|
Tercio@11
|
1199 collectgarbage()
|
|
Tercio@11
|
1200 end)
|
|
Tercio@11
|
1201
|
|
Tercio@11
|
1202 DF.IconPickFrame.buttons = {}
|
|
Tercio@11
|
1203
|
|
Tercio@11
|
1204 local OnClickFunction = function (self)
|
|
Tercio@20
|
1205 DF.IconPickFrame.callback (self.icon:GetTexture(), DF.IconPickFrame.param1, DF.IconPickFrame.param2)
|
|
Tercio@11
|
1206 if (DF.IconPickFrame.click_close) then
|
|
Tercio@11
|
1207 close_button:Click()
|
|
Tercio@11
|
1208 end
|
|
Tercio@11
|
1209 end
|
|
Tercio@11
|
1210
|
|
Tercio@11
|
1211 local onenter = function (self)
|
|
Tercio@11
|
1212 DF.IconPickFrame.preview:SetPoint ("bottom", self, "top", 0, 2)
|
|
Tercio@11
|
1213 DF.IconPickFrame.preview.icon:SetTexture (self.icon:GetTexture())
|
|
Tercio@11
|
1214 DF.IconPickFrame.preview:Show()
|
|
Tercio@11
|
1215 self.icon:SetBlendMode ("ADD")
|
|
Tercio@11
|
1216 end
|
|
Tercio@11
|
1217 local onleave = function (self)
|
|
Tercio@11
|
1218 DF.IconPickFrame.preview:Hide()
|
|
Tercio@11
|
1219 self.icon:SetBlendMode ("BLEND")
|
|
Tercio@11
|
1220 end
|
|
Tercio@11
|
1221
|
|
Tercio@11
|
1222 local backdrop = {bgFile = DF.folder .. "background", tile = true, tileSize = 16,
|
|
Tercio@11
|
1223 insets = {left = 0, right = 0, top = 0, bottom = 0}, edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10}
|
|
Tercio@11
|
1224
|
|
Tercio@11
|
1225 for i = 0, 9 do
|
|
Tercio@11
|
1226 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..(i+1), DF.IconPickFrame)
|
|
Tercio@11
|
1227 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..(i+1).."Icon", "overlay")
|
|
Tercio@11
|
1228 newcheck.icon = image
|
|
Tercio@11
|
1229 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1230 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1231 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1232
|
|
Tercio@11
|
1233 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1234 newcheck.param1 = i+1
|
|
Tercio@11
|
1235
|
|
Tercio@11
|
1236 newcheck:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12 + (i*30), -40)
|
|
Tercio@11
|
1237 newcheck:SetID (i+1)
|
|
Tercio@11
|
1238 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1239 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1240 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1241 end
|
|
Tercio@11
|
1242 for i = 11, 20 do
|
|
Tercio@11
|
1243 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1244 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1245 newcheck.icon = image
|
|
Tercio@11
|
1246 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1247 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1248 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1249
|
|
Tercio@11
|
1250 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1251 newcheck.param1 = i
|
|
Tercio@11
|
1252
|
|
Tercio@11
|
1253 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1254 newcheck:SetID (i)
|
|
Tercio@11
|
1255 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1256 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1257 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1258 end
|
|
Tercio@11
|
1259 for i = 21, 30 do
|
|
Tercio@11
|
1260 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1261 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1262 newcheck.icon = image
|
|
Tercio@11
|
1263 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1264 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1265 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1266
|
|
Tercio@11
|
1267 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1268 newcheck.param1 = i
|
|
Tercio@11
|
1269
|
|
Tercio@11
|
1270 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1271 newcheck:SetID (i)
|
|
Tercio@11
|
1272 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1273 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1274 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1275 end
|
|
Tercio@11
|
1276 for i = 31, 40 do
|
|
Tercio@11
|
1277 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1278 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1279 newcheck.icon = image
|
|
Tercio@11
|
1280 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1281 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1282 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1283
|
|
Tercio@11
|
1284 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1285 newcheck.param1 = i
|
|
Tercio@11
|
1286
|
|
Tercio@11
|
1287 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1288 newcheck:SetID (i)
|
|
Tercio@11
|
1289 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1290 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1291 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1292 end
|
|
Tercio@11
|
1293 for i = 41, 50 do
|
|
Tercio@11
|
1294 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1295 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1296 newcheck.icon = image
|
|
Tercio@11
|
1297 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1298 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1299 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1300
|
|
Tercio@11
|
1301 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1302 newcheck.param1 = i
|
|
Tercio@11
|
1303
|
|
Tercio@11
|
1304 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1305 newcheck:SetID (i)
|
|
Tercio@11
|
1306 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1307 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1308 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1309 end
|
|
Tercio@11
|
1310 for i = 51, 60 do
|
|
Tercio@11
|
1311 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
|
|
Tercio@11
|
1312 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
|
|
Tercio@11
|
1313 newcheck.icon = image
|
|
Tercio@11
|
1314 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
|
|
Tercio@11
|
1315 newcheck:SetSize (30, 28)
|
|
Tercio@11
|
1316 newcheck:SetBackdrop (backdrop)
|
|
Tercio@11
|
1317
|
|
Tercio@11
|
1318 newcheck:SetScript ("OnClick", OnClickFunction)
|
|
Tercio@11
|
1319 newcheck.param1 = i
|
|
Tercio@11
|
1320
|
|
Tercio@11
|
1321 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
|
|
Tercio@11
|
1322 newcheck:SetID (i)
|
|
Tercio@11
|
1323 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
|
|
Tercio@11
|
1324 newcheck:SetScript ("OnEnter", onenter)
|
|
Tercio@11
|
1325 newcheck:SetScript ("OnLeave", onleave)
|
|
Tercio@11
|
1326 end
|
|
Tercio@11
|
1327
|
|
Tercio@11
|
1328 local scroll = CreateFrame ("ScrollFrame", "DetailsFrameworkIconPickFrameScroll", DF.IconPickFrame, "ListScrollFrameTemplate")
|
|
Tercio@11
|
1329
|
|
Tercio@11
|
1330 local ChecksFrame_Update = function (self)
|
|
Tercio@11
|
1331
|
|
Tercio@11
|
1332 local numMacroIcons = #MACRO_ICON_FILENAMES
|
|
Tercio@11
|
1333 local macroPopupIcon, macroPopupButton
|
|
Tercio@11
|
1334 local macroPopupOffset = FauxScrollFrame_GetOffset (scroll)
|
|
Tercio@11
|
1335 local index
|
|
Tercio@11
|
1336
|
|
Tercio@11
|
1337 local texture
|
|
Tercio@11
|
1338 local filter
|
|
Tercio@11
|
1339 if (DF.IconPickFrame.searching) then
|
|
Tercio@11
|
1340 filter = string_lower (DF.IconPickFrame.searching)
|
|
Tercio@11
|
1341 end
|
|
Tercio@11
|
1342
|
|
Tercio@11
|
1343 if (filter and filter ~= "") then
|
|
Tercio@11
|
1344
|
|
Tercio@11
|
1345 local ignored = 0
|
|
Tercio@11
|
1346 local tryed = 0
|
|
Tercio@11
|
1347 local found = 0
|
|
Tercio@11
|
1348 local type = type
|
|
Tercio@11
|
1349 local buttons = DF.IconPickFrame.buttons
|
|
Tercio@11
|
1350 index = 1
|
|
Tercio@11
|
1351
|
|
Tercio@11
|
1352 for i = 1, 60 do
|
|
Tercio@11
|
1353
|
|
Tercio@11
|
1354 macroPopupIcon = buttons[i].icon
|
|
Tercio@11
|
1355 macroPopupButton = buttons[i]
|
|
Tercio@11
|
1356
|
|
Tercio@11
|
1357 for o = index, numMacroIcons do
|
|
Tercio@11
|
1358
|
|
Tercio@11
|
1359 tryed = tryed + 1
|
|
Tercio@11
|
1360
|
|
Tercio@11
|
1361 texture = MACRO_ICON_FILENAMES [o]
|
|
Tercio@11
|
1362 if (type (texture) == "number") then
|
|
Tercio@11
|
1363 macroPopupIcon:SetToFileData (texture)
|
|
Tercio@11
|
1364 texture = macroPopupIcon:GetTexture()
|
|
Tercio@11
|
1365 macroPopupIcon:SetTexture (nil)
|
|
Tercio@11
|
1366 else
|
|
Tercio@11
|
1367 texture = "INTERFACE\\ICONS\\" .. texture
|
|
Tercio@11
|
1368 end
|
|
Tercio@11
|
1369
|
|
Tercio@11
|
1370 if (texture and texture:find (filter)) then
|
|
Tercio@11
|
1371 macroPopupIcon:SetTexture (texture)
|
|
Tercio@11
|
1372 macroPopupButton:Show()
|
|
Tercio@11
|
1373 found = found + 1
|
|
Tercio@11
|
1374 DF.IconPickFrame.last_filter_index = o
|
|
Tercio@11
|
1375 index = o+1
|
|
Tercio@11
|
1376 break
|
|
Tercio@11
|
1377 else
|
|
Tercio@11
|
1378 ignored = ignored + 1
|
|
Tercio@11
|
1379 end
|
|
Tercio@11
|
1380
|
|
Tercio@11
|
1381 end
|
|
Tercio@11
|
1382 end
|
|
Tercio@11
|
1383
|
|
Tercio@11
|
1384 for o = found+1, 60 do
|
|
Tercio@11
|
1385 macroPopupButton = _G ["DetailsFrameworkIconPickFrameButton"..o]
|
|
Tercio@11
|
1386 macroPopupButton:Hide()
|
|
Tercio@11
|
1387 end
|
|
Tercio@11
|
1388 else
|
|
Tercio@11
|
1389 for i = 1, 60 do
|
|
Tercio@11
|
1390 macroPopupIcon = _G ["DetailsFrameworkIconPickFrameButton"..i.."Icon"]
|
|
Tercio@11
|
1391 macroPopupButton = _G ["DetailsFrameworkIconPickFrameButton"..i]
|
|
Tercio@11
|
1392 index = (macroPopupOffset * 10) + i
|
|
Tercio@11
|
1393 texture = MACRO_ICON_FILENAMES [index]
|
|
Tercio@11
|
1394 if ( index <= numMacroIcons and texture ) then
|
|
Tercio@11
|
1395
|
|
Tercio@11
|
1396 if (type (texture) == "number") then
|
|
Tercio@11
|
1397 macroPopupIcon:SetToFileData (texture)
|
|
Tercio@11
|
1398 else
|
|
Tercio@11
|
1399 macroPopupIcon:SetTexture ("INTERFACE\\ICONS\\" .. texture)
|
|
Tercio@11
|
1400 end
|
|
Tercio@11
|
1401
|
|
Tercio@11
|
1402 macroPopupIcon:SetTexCoord (4/64, 60/64, 4/64, 60/64)
|
|
Tercio@11
|
1403 macroPopupButton.IconID = index
|
|
Tercio@11
|
1404 macroPopupButton:Show()
|
|
Tercio@11
|
1405 else
|
|
Tercio@11
|
1406 macroPopupButton:Hide()
|
|
Tercio@11
|
1407 end
|
|
Tercio@11
|
1408 end
|
|
Tercio@11
|
1409 end
|
|
Tercio@11
|
1410
|
|
Tercio@11
|
1411 -- Scrollbar stuff
|
|
Tercio@11
|
1412 FauxScrollFrame_Update (scroll, ceil (numMacroIcons / 10) , 5, 20 )
|
|
Tercio@11
|
1413 end
|
|
Tercio@11
|
1414
|
|
Tercio@11
|
1415 DF.IconPickFrame.updateFunc = ChecksFrame_Update
|
|
Tercio@11
|
1416
|
|
Tercio@11
|
1417 scroll:SetPoint ("topleft", DF.IconPickFrame, "topleft", -18, -37)
|
|
Tercio@11
|
1418 scroll:SetWidth (330)
|
|
Tercio@11
|
1419 scroll:SetHeight (178)
|
|
Tercio@11
|
1420 scroll:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (scroll, offset, 20, ChecksFrame_Update) end)
|
|
Tercio@11
|
1421 scroll.update = ChecksFrame_Update
|
|
Tercio@11
|
1422 DF.IconPickFrameScroll = scroll
|
|
Tercio@11
|
1423 DF.IconPickFrame:Hide()
|
|
Tercio@11
|
1424
|
|
Tercio@11
|
1425 end
|
|
Tercio@11
|
1426
|
|
Tercio@20
|
1427 DF.IconPickFrame.param1, DF.IconPickFrame.param2 = param1, param2
|
|
Tercio@20
|
1428
|
|
Tercio@11
|
1429 DF.IconPickFrame:Show()
|
|
Tercio@11
|
1430 DF.IconPickFrameScroll.update (DF.IconPickFrameScroll)
|
|
Tercio@11
|
1431 DF.IconPickFrame.callback = callback or DF.IconPickFrame.emptyFunction
|
|
Tercio@11
|
1432 DF.IconPickFrame.click_close = close_when_select
|
|
Tercio@11
|
1433
|
|
Tercio@11
|
1434 end
|
|
Tercio@11
|
1435
|
|
Tercio@11
|
1436 local simple_panel_counter = 1
|
|
Tercio@11
|
1437 local simple_panel_mouse_down = function (self, button)
|
|
Tercio@11
|
1438 if (button == "RightButton") then
|
|
Tercio@11
|
1439 if (self.IsMoving) then
|
|
Tercio@11
|
1440 self.IsMoving = false
|
|
Tercio@11
|
1441 self:StopMovingOrSizing()
|
|
Tercio@11
|
1442 if (self.db and self.db.position) then
|
|
Tercio@11
|
1443 DF:SavePositionOnScreen (self)
|
|
Tercio@11
|
1444 end
|
|
Tercio@11
|
1445 end
|
|
Tercio@17
|
1446 if (not self.DontRightClickClose) then
|
|
Tercio@17
|
1447 self:Hide()
|
|
Tercio@17
|
1448 end
|
|
Tercio@11
|
1449 return
|
|
Tercio@11
|
1450 end
|
|
Tercio@11
|
1451 if (not self.IsMoving and not self.IsLocked) then
|
|
Tercio@11
|
1452 self.IsMoving = true
|
|
Tercio@11
|
1453 self:StartMoving()
|
|
Tercio@11
|
1454 end
|
|
Tercio@11
|
1455 end
|
|
Tercio@11
|
1456 local simple_panel_mouse_up = function (self, button)
|
|
Tercio@11
|
1457 if (self.IsMoving) then
|
|
Tercio@11
|
1458 self.IsMoving = false
|
|
Tercio@11
|
1459 self:StopMovingOrSizing()
|
|
Tercio@11
|
1460 if (self.db and self.db.position) then
|
|
Tercio@11
|
1461 DF:SavePositionOnScreen (self)
|
|
Tercio@11
|
1462 end
|
|
Tercio@11
|
1463 end
|
|
Tercio@11
|
1464 end
|
|
Tercio@11
|
1465 local simple_panel_settitle = function (self, title)
|
|
Tercio@22
|
1466 self.Title:SetText (title)
|
|
Tercio@11
|
1467 end
|
|
Tercio@11
|
1468
|
|
Tercio@22
|
1469 local simple_panel_close_click = function (self)
|
|
Tercio@22
|
1470 self:GetParent():GetParent():Hide()
|
|
Tercio@22
|
1471 end
|
|
Tercio@22
|
1472
|
|
Tercio@22
|
1473 local SimplePanel_frame_backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}
|
|
Tercio@22
|
1474 local SimplePanel_frame_backdrop_color = {0, 0, 0, 0.9}
|
|
Tercio@22
|
1475 local SimplePanel_frame_backdrop_border_color = {0, 0, 0, 1}
|
|
Tercio@22
|
1476
|
|
Tercio@26
|
1477 local no_options = {}
|
|
Tercio@26
|
1478 function DF:CreateSimplePanel (parent, w, h, title, name, panel_options)
|
|
Tercio@11
|
1479
|
|
Tercio@11
|
1480 if (not name) then
|
|
Tercio@11
|
1481 name = "DetailsFrameworkSimplePanel" .. simple_panel_counter
|
|
Tercio@11
|
1482 simple_panel_counter = simple_panel_counter + 1
|
|
Tercio@11
|
1483 end
|
|
Tercio@11
|
1484 if (not parent) then
|
|
Tercio@11
|
1485 parent = UIParent
|
|
Tercio@11
|
1486 end
|
|
Tercio@26
|
1487
|
|
Tercio@26
|
1488 panel_options = panel_options or no_options
|
|
Tercio@11
|
1489
|
|
Tercio@11
|
1490 local f = CreateFrame ("frame", name, UIParent)
|
|
Tercio@11
|
1491 f:SetSize (w or 400, h or 250)
|
|
Tercio@11
|
1492 f:SetPoint ("center", UIParent, "center", 0, 0)
|
|
Tercio@11
|
1493 f:SetFrameStrata ("FULLSCREEN")
|
|
Tercio@11
|
1494 f:EnableMouse()
|
|
Tercio@11
|
1495 f:SetMovable (true)
|
|
Tercio@22
|
1496 f:SetBackdrop (SimplePanel_frame_backdrop)
|
|
Tercio@22
|
1497 f:SetBackdropColor (unpack (SimplePanel_frame_backdrop_color))
|
|
Tercio@22
|
1498 f:SetBackdropBorderColor (unpack (SimplePanel_frame_backdrop_border_color))
|
|
Tercio@26
|
1499
|
|
Tercio@26
|
1500 f.DontRightClickClose = panel_options.DontRightClickClose
|
|
Tercio@26
|
1501
|
|
Tercio@26
|
1502 if (not panel_options.NoTUISpecialFrame) then
|
|
Tercio@26
|
1503 tinsert (UISpecialFrames, name)
|
|
Tercio@26
|
1504 end
|
|
Tercio@22
|
1505
|
|
Tercio@22
|
1506 local title_bar = CreateFrame ("frame", name .. "TitleBar", f)
|
|
Tercio@22
|
1507 title_bar:SetPoint ("topleft", f, "topleft", 2, -3)
|
|
Tercio@22
|
1508 title_bar:SetPoint ("topright", f, "topright", -2, -3)
|
|
Tercio@22
|
1509 title_bar:SetHeight (20)
|
|
Tercio@22
|
1510 title_bar:SetBackdrop (SimplePanel_frame_backdrop)
|
|
Tercio@22
|
1511 title_bar:SetBackdropColor (.2, .2, .2, 1)
|
|
Tercio@22
|
1512 title_bar:SetBackdropBorderColor (0, 0, 0, 1)
|
|
Tercio@26
|
1513 f.TitleBar = title_bar
|
|
Tercio@22
|
1514
|
|
Tercio@22
|
1515 local close = CreateFrame ("button", name and name .. "CloseButton", title_bar)
|
|
Tercio@22
|
1516 close:SetSize (16, 16)
|
|
Tercio@22
|
1517 close:SetNormalTexture (DF.folder .. "icons")
|
|
Tercio@22
|
1518 close:SetHighlightTexture (DF.folder .. "icons")
|
|
Tercio@22
|
1519 close:SetPushedTexture (DF.folder .. "icons")
|
|
Tercio@22
|
1520 close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@22
|
1521 close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@22
|
1522 close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@22
|
1523 close:SetAlpha (0.7)
|
|
Tercio@22
|
1524 close:SetScript ("OnClick", simple_panel_close_click)
|
|
Tercio@22
|
1525 f.Close = close
|
|
Tercio@22
|
1526
|
|
Tercio@22
|
1527 local title_string = title_bar:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
|
|
Tercio@22
|
1528 title_string:SetTextColor (.8, .8, .8, 1)
|
|
Tercio@22
|
1529 title_string:SetText (title or "")
|
|
Tercio@22
|
1530 f.Title = title_string
|
|
Tercio@22
|
1531
|
|
Tercio@22
|
1532 f.Title:SetPoint ("center", title_bar, "center")
|
|
Tercio@22
|
1533 f.Close:SetPoint ("right", title_bar, "right", -2, 0)
|
|
Tercio@22
|
1534
|
|
Tercio@11
|
1535 f:SetScript ("OnMouseDown", simple_panel_mouse_down)
|
|
Tercio@11
|
1536 f:SetScript ("OnMouseUp", simple_panel_mouse_up)
|
|
Tercio@11
|
1537
|
|
Tercio@11
|
1538 f.SetTitle = simple_panel_settitle
|
|
Tercio@11
|
1539
|
|
Tercio@11
|
1540 simple_panel_counter = simple_panel_counter + 1
|
|
Tercio@11
|
1541
|
|
Tercio@11
|
1542 return f
|
|
Tercio@11
|
1543 end
|
|
Tercio@11
|
1544
|
|
Tercio@11
|
1545 local Panel1PxBackdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 64,
|
|
Tercio@11
|
1546 edgeFile = DF.folder .. "border_3", edgeSize = 9, insets = {left = 2, right = 2, top = 3, bottom = 3}}
|
|
Tercio@11
|
1547
|
|
Tercio@11
|
1548 local Panel1PxOnClickClose = function (self)
|
|
Tercio@11
|
1549 self:GetParent():Hide()
|
|
Tercio@11
|
1550 end
|
|
Tercio@11
|
1551 local Panel1PxOnToggleLock = function (self)
|
|
Tercio@11
|
1552 if (self.IsLocked) then
|
|
Tercio@11
|
1553 self.IsLocked = false
|
|
Tercio@11
|
1554 self:SetMovable (true)
|
|
Tercio@11
|
1555 self:EnableMouse (true)
|
|
Tercio@11
|
1556 self.Lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1557 self.Lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1558 self.Lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@17
|
1559 if (self.OnUnlock) then
|
|
Tercio@17
|
1560 self:OnUnlock()
|
|
Tercio@17
|
1561 end
|
|
Tercio@17
|
1562 if (self.db) then
|
|
Tercio@17
|
1563 self.db.IsLocked = self.IsLocked
|
|
Tercio@17
|
1564 end
|
|
Tercio@11
|
1565 else
|
|
Tercio@11
|
1566 self.IsLocked = true
|
|
Tercio@11
|
1567 self:SetMovable (false)
|
|
Tercio@11
|
1568 self:EnableMouse (false)
|
|
Tercio@11
|
1569 self.Lock:GetNormalTexture():SetTexCoord (16/128, 32/128, 0, 1)
|
|
Tercio@11
|
1570 self.Lock:GetHighlightTexture():SetTexCoord (16/128, 32/128, 0, 1)
|
|
Tercio@11
|
1571 self.Lock:GetPushedTexture():SetTexCoord (16/128, 32/128, 0, 1)
|
|
Tercio@17
|
1572 if (self.OnLock) then
|
|
Tercio@17
|
1573 self:OnLock()
|
|
Tercio@17
|
1574 end
|
|
Tercio@17
|
1575 if (self.db) then
|
|
Tercio@17
|
1576 self.db.IsLocked = self.IsLocked
|
|
Tercio@17
|
1577 end
|
|
Tercio@11
|
1578 end
|
|
Tercio@11
|
1579 end
|
|
Tercio@11
|
1580 local Panel1PxOnClickLock = function (self)
|
|
Tercio@11
|
1581 local f = self:GetParent()
|
|
Tercio@11
|
1582 Panel1PxOnToggleLock (f)
|
|
Tercio@11
|
1583 end
|
|
Tercio@11
|
1584 local Panel1PxSetTitle = function (self, text)
|
|
Tercio@11
|
1585 self.Title:SetText (text or "")
|
|
Tercio@11
|
1586 end
|
|
Tercio@11
|
1587
|
|
Tercio@20
|
1588 local Panel1PxSetLocked= function (self, lock_state)
|
|
Tercio@20
|
1589 if (type (lock_state) ~= "boolean") then
|
|
Tercio@20
|
1590 return
|
|
Tercio@20
|
1591 end
|
|
Tercio@20
|
1592 if (lock_state) then
|
|
Tercio@20
|
1593 -- lock it
|
|
Tercio@20
|
1594 self.IsLocked = false
|
|
Tercio@20
|
1595 Panel1PxOnClickLock (self.Lock)
|
|
Tercio@20
|
1596 else
|
|
Tercio@20
|
1597 -- unlockit
|
|
Tercio@20
|
1598 self.IsLocked = true
|
|
Tercio@20
|
1599 Panel1PxOnClickLock (self.Lock)
|
|
Tercio@20
|
1600 end
|
|
Tercio@20
|
1601 end
|
|
Tercio@20
|
1602
|
|
Tercio@11
|
1603 local Panel1PxReadConfig = function (self)
|
|
Tercio@11
|
1604 local db = self.db
|
|
Tercio@11
|
1605 if (db) then
|
|
Tercio@11
|
1606 db.IsLocked = db.IsLocked or false
|
|
Tercio@11
|
1607 self.IsLocked = db.IsLocked
|
|
Tercio@11
|
1608 db.position = db.position or {x = 0, y = 0}
|
|
Tercio@19
|
1609 db.position.x = db.position.x or 0
|
|
Tercio@19
|
1610 db.position.y = db.position.y or 0
|
|
Tercio@11
|
1611 DF:RestoreFramePosition (self)
|
|
Tercio@11
|
1612 end
|
|
Tercio@11
|
1613 end
|
|
Tercio@11
|
1614
|
|
Tercio@11
|
1615 function DF:SavePositionOnScreen (frame)
|
|
Tercio@11
|
1616 if (frame.db and frame.db.position) then
|
|
Tercio@11
|
1617 local x, y = DF:GetPositionOnScreen (frame)
|
|
Tercio@18
|
1618 --print ("saving...", x, y, frame:GetName())
|
|
Tercio@19
|
1619 if (x and y) then
|
|
Tercio@19
|
1620 frame.db.position.x, frame.db.position.y = x, y
|
|
Tercio@19
|
1621 end
|
|
Tercio@11
|
1622 end
|
|
Tercio@11
|
1623 end
|
|
Tercio@11
|
1624
|
|
Tercio@11
|
1625 function DF:GetPositionOnScreen (frame)
|
|
Tercio@11
|
1626 local xOfs, yOfs = frame:GetCenter()
|
|
Tercio@11
|
1627 if (not xOfs) then
|
|
Tercio@11
|
1628 return
|
|
Tercio@11
|
1629 end
|
|
Tercio@11
|
1630 local scale = frame:GetEffectiveScale()
|
|
Tercio@11
|
1631 local UIscale = UIParent:GetScale()
|
|
Tercio@11
|
1632 xOfs = xOfs*scale - GetScreenWidth()*UIscale/2
|
|
Tercio@11
|
1633 yOfs = yOfs*scale - GetScreenHeight()*UIscale/2
|
|
Tercio@11
|
1634 return xOfs/UIscale, yOfs/UIscale
|
|
Tercio@11
|
1635 end
|
|
Tercio@11
|
1636
|
|
Tercio@11
|
1637 function DF:RestoreFramePosition (frame)
|
|
Tercio@11
|
1638 if (frame.db and frame.db.position) then
|
|
Tercio@11
|
1639 local scale, UIscale = frame:GetEffectiveScale(), UIParent:GetScale()
|
|
Tercio@11
|
1640 frame:ClearAllPoints()
|
|
Tercio@19
|
1641 frame.db.position.x = frame.db.position.x or 0
|
|
Tercio@19
|
1642 frame.db.position.y = frame.db.position.y or 0
|
|
Tercio@11
|
1643 frame:SetPoint ("center", UIParent, "center", frame.db.position.x * UIscale / scale, frame.db.position.y * UIscale / scale)
|
|
Tercio@11
|
1644 end
|
|
Tercio@11
|
1645 end
|
|
Tercio@11
|
1646
|
|
Tercio@20
|
1647 local Panel1PxSavePosition= function (self)
|
|
Tercio@20
|
1648 DF:SavePositionOnScreen (self)
|
|
Tercio@20
|
1649 end
|
|
Tercio@20
|
1650
|
|
Tercio@18
|
1651 local Panel1PxHasPosition = function (self)
|
|
Tercio@18
|
1652 local db = self.db
|
|
Tercio@18
|
1653 if (db) then
|
|
Tercio@18
|
1654 if (db.position and db.position.x and (db.position.x ~= 0 or db.position.y ~= 0)) then
|
|
Tercio@18
|
1655 return true
|
|
Tercio@18
|
1656 end
|
|
Tercio@18
|
1657 end
|
|
Tercio@18
|
1658 end
|
|
Tercio@18
|
1659
|
|
Tercio@13
|
1660 function DF:Create1PxPanel (parent, w, h, title, name, config, title_anchor, no_special_frame)
|
|
Tercio@11
|
1661 local f = CreateFrame ("frame", name, parent or UIParent)
|
|
Tercio@11
|
1662 f:SetSize (w or 100, h or 75)
|
|
Tercio@11
|
1663 f:SetPoint ("center", UIParent, "center")
|
|
Tercio@11
|
1664
|
|
Tercio@13
|
1665 if (name and not no_special_frame) then
|
|
Tercio@11
|
1666 tinsert (UISpecialFrames, name)
|
|
Tercio@11
|
1667 end
|
|
Tercio@11
|
1668
|
|
Tercio@11
|
1669 f:SetScript ("OnMouseDown", simple_panel_mouse_down)
|
|
Tercio@11
|
1670 f:SetScript ("OnMouseUp", simple_panel_mouse_up)
|
|
Tercio@11
|
1671
|
|
Tercio@11
|
1672 f:SetBackdrop (Panel1PxBackdrop)
|
|
Tercio@11
|
1673 f:SetBackdropColor (0, 0, 0, 0.5)
|
|
Tercio@11
|
1674
|
|
Tercio@17
|
1675 f.IsLocked = (config and config.IsLocked ~= nil and config.IsLocked) or false
|
|
Tercio@11
|
1676 f:SetMovable (true)
|
|
Tercio@11
|
1677 f:EnableMouse (true)
|
|
Tercio@11
|
1678 f:SetUserPlaced (true)
|
|
Tercio@11
|
1679
|
|
Tercio@11
|
1680 f.db = config
|
|
Tercio@18
|
1681 --print (config.position.x, config.position.x)
|
|
Tercio@11
|
1682 Panel1PxReadConfig (f)
|
|
Tercio@11
|
1683
|
|
Tercio@11
|
1684 local close = CreateFrame ("button", name and name .. "CloseButton", f)
|
|
Tercio@11
|
1685 close:SetSize (16, 16)
|
|
Tercio@11
|
1686 close:SetNormalTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1687 close:SetHighlightTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1688 close:SetPushedTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1689 close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@11
|
1690 close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@11
|
1691 close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
|
|
Tercio@11
|
1692 close:SetAlpha (0.7)
|
|
Tercio@11
|
1693
|
|
Tercio@11
|
1694 local lock = CreateFrame ("button", name and name .. "LockButton", f)
|
|
Tercio@11
|
1695 lock:SetSize (16, 16)
|
|
Tercio@11
|
1696 lock:SetNormalTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1697 lock:SetHighlightTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1698 lock:SetPushedTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1699 lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1700 lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1701 lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
|
|
Tercio@11
|
1702 lock:SetAlpha (0.7)
|
|
Tercio@11
|
1703
|
|
Tercio@11
|
1704 close:SetPoint ("topright", f, "topright", -3, -3)
|
|
Tercio@11
|
1705 lock:SetPoint ("right", close, "left", 3, 0)
|
|
Tercio@11
|
1706
|
|
Tercio@11
|
1707 close:SetScript ("OnClick", Panel1PxOnClickClose)
|
|
Tercio@11
|
1708 lock:SetScript ("OnClick", Panel1PxOnClickLock)
|
|
Tercio@11
|
1709
|
|
Tercio@11
|
1710 local title_string = f:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
|
|
Tercio@11
|
1711 title_string:SetPoint ("topleft", f, "topleft", 5, -5)
|
|
Tercio@11
|
1712 title_string:SetText (title or "")
|
|
Tercio@11
|
1713
|
|
Tercio@11
|
1714 if (title_anchor) then
|
|
Tercio@11
|
1715 if (title_anchor == "top") then
|
|
Tercio@11
|
1716 title_string:ClearAllPoints()
|
|
Tercio@11
|
1717 title_string:SetPoint ("bottomleft", f, "topleft", 0, 0)
|
|
Tercio@11
|
1718 close:ClearAllPoints()
|
|
Tercio@11
|
1719 close:SetPoint ("bottomright", f, "topright", 0, 0)
|
|
Tercio@11
|
1720 end
|
|
Tercio@11
|
1721 f.title_anchor = title_anchor
|
|
Tercio@11
|
1722 end
|
|
Tercio@11
|
1723
|
|
Tercio@11
|
1724 f.SetTitle = Panel1PxSetTitle
|
|
Tercio@11
|
1725 f.Title = title_string
|
|
Tercio@11
|
1726 f.Lock = lock
|
|
Tercio@11
|
1727 f.Close = close
|
|
Tercio@18
|
1728 f.HasPosition = Panel1PxHasPosition
|
|
Tercio@20
|
1729 f.SavePosition = Panel1PxSavePosition
|
|
Tercio@11
|
1730
|
|
Tercio@17
|
1731 f.IsLocked = not f.IsLocked
|
|
Tercio@20
|
1732 f.SetLocked = Panel1PxSetLocked
|
|
Tercio@17
|
1733 Panel1PxOnToggleLock (f)
|
|
Tercio@17
|
1734
|
|
Tercio@11
|
1735 return f
|
|
Tercio@11
|
1736 end
|
|
Tercio@11
|
1737
|
|
Tercio@11
|
1738 ------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@20
|
1739 -- ~prompt
|
|
Tercio@20
|
1740 function DF:ShowPromptPanel (message, func_true, func_false)
|
|
Tercio@20
|
1741
|
|
Tercio@20
|
1742 if (not DF.prompt_panel) then
|
|
Tercio@20
|
1743 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent)
|
|
Tercio@22
|
1744 f:SetSize (400, 65)
|
|
Tercio@20
|
1745 f:SetFrameStrata ("DIALOG")
|
|
Tercio@22
|
1746 f:SetPoint ("center", UIParent, "center", 0, 300)
|
|
Tercio@20
|
1747 f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
|
|
Tercio@20
|
1748 f:SetBackdropColor (0, 0, 0, 0.8)
|
|
Tercio@20
|
1749 f:SetBackdropBorderColor (0, 0, 0, 1)
|
|
Tercio@20
|
1750
|
|
Tercio@22
|
1751 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@22
|
1752 prompt:SetPoint ("top", f, "top", 0, -15)
|
|
Tercio@22
|
1753 prompt:SetJustifyH ("center")
|
|
Tercio@22
|
1754 f.prompt = prompt
|
|
Tercio@22
|
1755
|
|
Tercio@22
|
1756 local button_true = DF:CreateButton (f, nil, 60, 20, "Yes")
|
|
Tercio@20
|
1757 button_true:SetPoint ("bottomleft", f, "bottomleft", 5, 5)
|
|
Tercio@20
|
1758 f.button_true = button_true
|
|
Tercio@20
|
1759
|
|
Tercio@22
|
1760 local button_false = DF:CreateButton (f, nil, 60, 20, "No")
|
|
Tercio@20
|
1761 button_false:SetPoint ("bottomright", f, "bottomright", -5, 5)
|
|
Tercio@20
|
1762 f.button_false = button_false
|
|
Tercio@20
|
1763
|
|
Tercio@20
|
1764 button_true:SetClickFunction (function()
|
|
Tercio@20
|
1765 local my_func = button_true.true_function
|
|
Tercio@20
|
1766 if (my_func) then
|
|
Tercio@20
|
1767 local okey, errormessage = pcall (my_func, true)
|
|
Tercio@20
|
1768 if (not okey) then
|
|
Tercio@20
|
1769 print ("error:", errormessage)
|
|
Tercio@20
|
1770 end
|
|
Tercio@22
|
1771 f:Hide()
|
|
Tercio@20
|
1772 end
|
|
Tercio@20
|
1773 end)
|
|
Tercio@20
|
1774
|
|
Tercio@20
|
1775 button_false:SetClickFunction (function()
|
|
Tercio@20
|
1776 local my_func = button_false.false_function
|
|
Tercio@20
|
1777 if (my_func) then
|
|
Tercio@20
|
1778 local okey, errormessage = pcall (my_func, true)
|
|
Tercio@20
|
1779 if (not okey) then
|
|
Tercio@20
|
1780 print ("error:", errormessage)
|
|
Tercio@20
|
1781 end
|
|
Tercio@22
|
1782 f:Hide()
|
|
Tercio@20
|
1783 end
|
|
Tercio@20
|
1784 end)
|
|
Tercio@20
|
1785
|
|
Tercio@20
|
1786 f:Hide()
|
|
Tercio@20
|
1787 DF.promtp_panel = f
|
|
Tercio@20
|
1788 end
|
|
Tercio@20
|
1789
|
|
Tercio@20
|
1790 assert (type (func_true) == "function" and type (func_false) == "function", "ShowPromptPanel expects two functions.")
|
|
Tercio@20
|
1791
|
|
Tercio@22
|
1792 DF.promtp_panel.prompt:SetText (message)
|
|
Tercio@20
|
1793 DF.promtp_panel.button_true.true_function = func_true
|
|
Tercio@20
|
1794 DF.promtp_panel.button_false.false_function = func_false
|
|
Tercio@20
|
1795
|
|
Tercio@20
|
1796 DF.promtp_panel:Show()
|
|
Tercio@20
|
1797 end
|
|
Tercio@22
|
1798
|
|
Tercio@22
|
1799
|
|
Tercio@22
|
1800 function DF:ShowTextPromptPanel (message, callback)
|
|
Tercio@22
|
1801
|
|
Tercio@22
|
1802 if (not DF.text_prompt_panel) then
|
|
Tercio@22
|
1803
|
|
Tercio@22
|
1804 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent)
|
|
Tercio@22
|
1805 f:SetSize (400, 100)
|
|
Tercio@22
|
1806 f:SetFrameStrata ("DIALOG")
|
|
Tercio@22
|
1807 f:SetPoint ("center", UIParent, "center", 0, 300)
|
|
Tercio@22
|
1808 f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
|
|
Tercio@22
|
1809 f:SetBackdropColor (0, 0, 0, 0.8)
|
|
Tercio@22
|
1810 f:SetBackdropBorderColor (0, 0, 0, 1)
|
|
Tercio@22
|
1811
|
|
Tercio@22
|
1812 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@22
|
1813 prompt:SetPoint ("top", f, "top", 0, -15)
|
|
Tercio@22
|
1814 prompt:SetJustifyH ("center")
|
|
Tercio@22
|
1815 f.prompt = prompt
|
|
Tercio@22
|
1816
|
|
Tercio@22
|
1817 local button_true = DF:CreateButton (f, nil, 60, 20, "Okey")
|
|
Tercio@22
|
1818 button_true:SetPoint ("bottomleft", f, "bottomleft", 10, 5)
|
|
Tercio@22
|
1819 f.button_true = button_true
|
|
Tercio@22
|
1820
|
|
Tercio@22
|
1821 local button_false = DF:CreateButton (f, function() f.textbox:ClearFocus(); f:Hide() end, 60, 20, "Cancel")
|
|
Tercio@22
|
1822 button_false:SetPoint ("bottomright", f, "bottomright", -10, 5)
|
|
Tercio@22
|
1823 f.button_false = button_false
|
|
Tercio@22
|
1824
|
|
Tercio@22
|
1825 local textbox = DF:CreateTextEntry (f, function()end, 380, 20, "textbox", nil, nil, nil, nil)
|
|
Tercio@22
|
1826 textbox:SetPoint ("topleft", f, "topleft", 10, -45)
|
|
Tercio@22
|
1827
|
|
Tercio@22
|
1828 button_true:SetClickFunction (function()
|
|
Tercio@22
|
1829 local my_func = button_true.true_function
|
|
Tercio@22
|
1830 if (my_func) then
|
|
Tercio@22
|
1831 local okey, errormessage = pcall (my_func, textbox:GetText())
|
|
Tercio@22
|
1832 textbox:ClearFocus()
|
|
Tercio@22
|
1833 if (not okey) then
|
|
Tercio@22
|
1834 print ("error:", errormessage)
|
|
Tercio@22
|
1835 end
|
|
Tercio@22
|
1836 f:Hide()
|
|
Tercio@22
|
1837 end
|
|
Tercio@22
|
1838 end)
|
|
Tercio@22
|
1839
|
|
Tercio@22
|
1840 f:Hide()
|
|
Tercio@22
|
1841 DF.text_prompt_panel = f
|
|
Tercio@22
|
1842 end
|
|
Tercio@22
|
1843
|
|
Tercio@22
|
1844 DF.text_prompt_panel:Show()
|
|
Tercio@22
|
1845
|
|
Tercio@22
|
1846 DF.text_prompt_panel.prompt:SetText (message)
|
|
Tercio@22
|
1847 DF.text_prompt_panel.button_true.true_function = callback
|
|
Tercio@22
|
1848 DF.text_prompt_panel.textbox:SetText ("")
|
|
Tercio@22
|
1849 DF.text_prompt_panel.textbox:SetFocus (true)
|
|
Tercio@22
|
1850
|
|
Tercio@22
|
1851 end
|
|
Tercio@22
|
1852
|
|
Tercio@20
|
1853 ------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
1854 --> options button -- ~options
|
|
Tercio@11
|
1855 function DF:CreateOptionsButton (parent, callback, name)
|
|
Tercio@11
|
1856
|
|
Tercio@11
|
1857 local b = CreateFrame ("button", name, parent)
|
|
Tercio@11
|
1858 b:SetSize (14, 14)
|
|
Tercio@11
|
1859 b:SetNormalTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1860 b:SetHighlightTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1861 b:SetPushedTexture (DF.folder .. "icons")
|
|
Tercio@11
|
1862 b:GetNormalTexture():SetTexCoord (48/128, 64/128, 0, 1)
|
|
Tercio@11
|
1863 b:GetHighlightTexture():SetTexCoord (48/128, 64/128, 0, 1)
|
|
Tercio@11
|
1864 b:GetPushedTexture():SetTexCoord (48/128, 64/128, 0, 1)
|
|
Tercio@11
|
1865 b:SetAlpha (0.7)
|
|
Tercio@11
|
1866
|
|
Tercio@11
|
1867 b:SetScript ("OnClick", callback)
|
|
Tercio@11
|
1868 b:SetScript ("OnEnter", function (self)
|
|
Tercio@11
|
1869 GameCooltip2:Reset()
|
|
Tercio@11
|
1870 GameCooltip2:AddLine ("Options")
|
|
Tercio@11
|
1871 GameCooltip2:ShowCooltip (self, "tooltip")
|
|
Tercio@11
|
1872 end)
|
|
Tercio@11
|
1873 b:SetScript ("OnLeave", function (self)
|
|
Tercio@11
|
1874 GameCooltip2:Hide()
|
|
Tercio@11
|
1875 end)
|
|
Tercio@11
|
1876
|
|
Tercio@11
|
1877 return b
|
|
Tercio@11
|
1878
|
|
Tercio@11
|
1879 end
|
|
Tercio@11
|
1880
|
|
Tercio@11
|
1881 ------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
1882 --> feedback panel -- ~feedback
|
|
Tercio@11
|
1883
|
|
Tercio@11
|
1884 function DF:CreateFeedbackButton (parent, callback, name)
|
|
Tercio@11
|
1885 local b = CreateFrame ("button", name, parent)
|
|
Tercio@11
|
1886 b:SetSize (12, 13)
|
|
Tercio@11
|
1887 b:SetNormalTexture (DF.folder .. "mail")
|
|
Tercio@11
|
1888 b:SetPushedTexture (DF.folder .. "mail")
|
|
Tercio@11
|
1889 b:SetHighlightTexture (DF.folder .. "mail")
|
|
Tercio@11
|
1890
|
|
Tercio@11
|
1891 b:SetScript ("OnClick", callback)
|
|
Tercio@11
|
1892 b:SetScript ("OnEnter", function (self)
|
|
Tercio@11
|
1893 GameCooltip2:Reset()
|
|
Tercio@11
|
1894 GameCooltip2:AddLine ("Send Feedback")
|
|
Tercio@11
|
1895 GameCooltip2:ShowCooltip (self, "tooltip")
|
|
Tercio@11
|
1896 end)
|
|
Tercio@11
|
1897 b:SetScript ("OnLeave", function (self)
|
|
Tercio@11
|
1898 GameCooltip2:Hide()
|
|
Tercio@11
|
1899 end)
|
|
Tercio@11
|
1900
|
|
Tercio@11
|
1901 return b
|
|
Tercio@11
|
1902 end
|
|
Tercio@11
|
1903
|
|
Tercio@11
|
1904 local backdrop_fb_line = {bgFile = DF.folder .. "background", edgeFile = DF.folder .. "border_3",
|
|
Tercio@11
|
1905 tile = true, tileSize = 64, edgeSize = 8, insets = {left = 2, right = 2, top = 2, bottom = 2}}
|
|
Tercio@11
|
1906
|
|
Tercio@11
|
1907 local on_enter_feedback = function (self)
|
|
Tercio@11
|
1908 self:SetBackdropColor (1, 1, 0, 0.5)
|
|
Tercio@11
|
1909 end
|
|
Tercio@11
|
1910 local on_leave_feedback = function (self)
|
|
Tercio@11
|
1911 self:SetBackdropColor (0, 0, 0, 0.3)
|
|
Tercio@11
|
1912 end
|
|
Tercio@11
|
1913
|
|
Tercio@11
|
1914 local on_click_feedback = function (self)
|
|
Tercio@11
|
1915
|
|
Tercio@11
|
1916 local feedback_link_textbox = DF.feedback_link_textbox
|
|
Tercio@11
|
1917
|
|
Tercio@11
|
1918 if (not feedback_link_textbox) then
|
|
Tercio@11
|
1919 local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
|
|
Tercio@11
|
1920 editbox:SetAutoFocus (false)
|
|
Tercio@11
|
1921 editbox:SetHook ("OnEditFocusGained", function()
|
|
Tercio@11
|
1922 editbox.text = editbox.link
|
|
Tercio@11
|
1923 editbox:HighlightText()
|
|
Tercio@11
|
1924 end)
|
|
Tercio@11
|
1925 editbox:SetHook ("OnEditFocusLost", function()
|
|
Tercio@11
|
1926 editbox:Hide()
|
|
Tercio@11
|
1927 end)
|
|
Tercio@11
|
1928 editbox:SetHook ("OnChar", function()
|
|
Tercio@11
|
1929 editbox.text = editbox.link
|
|
Tercio@11
|
1930 editbox:HighlightText()
|
|
Tercio@11
|
1931 end)
|
|
Tercio@11
|
1932 editbox.text = ""
|
|
Tercio@11
|
1933
|
|
Tercio@11
|
1934 DF.feedback_link_textbox = editbox
|
|
Tercio@11
|
1935 feedback_link_textbox = editbox
|
|
Tercio@11
|
1936 end
|
|
Tercio@11
|
1937
|
|
Tercio@11
|
1938 feedback_link_textbox.link = self.link
|
|
Tercio@11
|
1939 feedback_link_textbox.text = self.link
|
|
Tercio@11
|
1940 feedback_link_textbox:Show()
|
|
Tercio@11
|
1941
|
|
Tercio@11
|
1942 feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
|
|
Tercio@11
|
1943
|
|
Tercio@11
|
1944 feedback_link_textbox:HighlightText()
|
|
Tercio@11
|
1945
|
|
Tercio@11
|
1946 feedback_link_textbox:SetFocus()
|
|
Tercio@11
|
1947 feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
|
|
Tercio@11
|
1948 end
|
|
Tercio@11
|
1949
|
|
Tercio@11
|
1950 local feedback_get_fb_line = function (self)
|
|
Tercio@11
|
1951
|
|
Tercio@11
|
1952 local line = self.feedback_lines [self.next_feedback]
|
|
Tercio@11
|
1953 if (not line) then
|
|
Tercio@11
|
1954 line = CreateFrame ("frame", "AddonFeedbackPanelFB" .. self.next_feedback, self)
|
|
Tercio@11
|
1955 line:SetBackdrop (backdrop_fb_line)
|
|
Tercio@11
|
1956 line:SetBackdropColor (0, 0, 0, 0.3)
|
|
Tercio@11
|
1957 line:SetSize (390, 42)
|
|
Tercio@11
|
1958 line:SetPoint ("topleft", self.feedback_anchor, "bottomleft", 0, -5 + ((self.next_feedback-1) * 46 * -1))
|
|
Tercio@11
|
1959 line:SetScript ("OnEnter", on_enter_feedback)
|
|
Tercio@11
|
1960 line:SetScript ("OnLeave", on_leave_feedback)
|
|
Tercio@11
|
1961 line:SetScript ("OnMouseUp", on_click_feedback)
|
|
Tercio@11
|
1962
|
|
Tercio@11
|
1963 line.icon = line:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
1964 line.icon:SetSize (90, 36)
|
|
Tercio@11
|
1965
|
|
Tercio@11
|
1966 line.desc = line:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
|
|
Tercio@11
|
1967
|
|
Tercio@11
|
1968 line.icon:SetPoint ("left", line, "left", 5, 0)
|
|
Tercio@11
|
1969 line.desc:SetPoint ("left", line.icon, "right", 5, 0)
|
|
Tercio@11
|
1970
|
|
Tercio@11
|
1971 local arrow = line:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
1972 arrow:SetTexture ([[Interface\Buttons\JumpUpArrow]])
|
|
Tercio@11
|
1973 arrow:SetRotation (-1.55)
|
|
Tercio@11
|
1974 arrow:SetPoint ("right", line, "right", -5, 0)
|
|
Tercio@11
|
1975
|
|
Tercio@11
|
1976 self.feedback_lines [self.next_feedback] = line
|
|
Tercio@11
|
1977 end
|
|
Tercio@11
|
1978
|
|
Tercio@11
|
1979 self.next_feedback = self.next_feedback + 1
|
|
Tercio@11
|
1980
|
|
Tercio@11
|
1981 return line
|
|
Tercio@11
|
1982 end
|
|
Tercio@11
|
1983
|
|
Tercio@11
|
1984 local on_click_feedback = function (self)
|
|
Tercio@11
|
1985
|
|
Tercio@11
|
1986 local feedback_link_textbox = DF.feedback_link_textbox
|
|
Tercio@11
|
1987
|
|
Tercio@11
|
1988 if (not feedback_link_textbox) then
|
|
Tercio@11
|
1989 local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
|
|
Tercio@11
|
1990 editbox:SetAutoFocus (false)
|
|
Tercio@11
|
1991 editbox:SetHook ("OnEditFocusGained", function()
|
|
Tercio@11
|
1992 editbox.text = editbox.link
|
|
Tercio@11
|
1993 editbox:HighlightText()
|
|
Tercio@11
|
1994 end)
|
|
Tercio@11
|
1995 editbox:SetHook ("OnEditFocusLost", function()
|
|
Tercio@11
|
1996 editbox:Hide()
|
|
Tercio@11
|
1997 end)
|
|
Tercio@11
|
1998 editbox:SetHook ("OnChar", function()
|
|
Tercio@11
|
1999 editbox.text = editbox.link
|
|
Tercio@11
|
2000 editbox:HighlightText()
|
|
Tercio@11
|
2001 end)
|
|
Tercio@11
|
2002 editbox.text = ""
|
|
Tercio@11
|
2003
|
|
Tercio@11
|
2004 DF.feedback_link_textbox = editbox
|
|
Tercio@11
|
2005 feedback_link_textbox = editbox
|
|
Tercio@11
|
2006 end
|
|
Tercio@11
|
2007
|
|
Tercio@11
|
2008 feedback_link_textbox.link = self.link
|
|
Tercio@11
|
2009 feedback_link_textbox.text = self.link
|
|
Tercio@11
|
2010 feedback_link_textbox:Show()
|
|
Tercio@11
|
2011
|
|
Tercio@11
|
2012 feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
|
|
Tercio@11
|
2013
|
|
Tercio@11
|
2014 feedback_link_textbox:HighlightText()
|
|
Tercio@11
|
2015
|
|
Tercio@11
|
2016 feedback_link_textbox:SetFocus()
|
|
Tercio@11
|
2017 feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
|
|
Tercio@11
|
2018 end
|
|
Tercio@11
|
2019
|
|
Tercio@11
|
2020 local on_enter_addon = function (self)
|
|
Tercio@11
|
2021 if (self.tooltip) then
|
|
Tercio@11
|
2022 GameCooltip2:Preset (2)
|
|
Tercio@11
|
2023 GameCooltip2:AddLine ("|cFFFFFF00" .. self.name .. "|r")
|
|
Tercio@11
|
2024 GameCooltip2:AddLine ("")
|
|
Tercio@11
|
2025 GameCooltip2:AddLine (self.tooltip)
|
|
Tercio@11
|
2026 GameCooltip2:ShowCooltip (self, "tooltip")
|
|
Tercio@11
|
2027 end
|
|
Tercio@11
|
2028 self.icon:SetBlendMode ("ADD")
|
|
Tercio@11
|
2029 end
|
|
Tercio@11
|
2030 local on_leave_addon = function (self)
|
|
Tercio@11
|
2031 if (self.tooltip) then
|
|
Tercio@11
|
2032 GameCooltip2:Hide()
|
|
Tercio@11
|
2033 end
|
|
Tercio@11
|
2034 self.icon:SetBlendMode ("BLEND")
|
|
Tercio@11
|
2035 end
|
|
Tercio@11
|
2036 local on_click_addon = function (self)
|
|
Tercio@11
|
2037 local addon_link_textbox = DF.addon_link_textbox
|
|
Tercio@11
|
2038
|
|
Tercio@11
|
2039 if (not addon_link_textbox) then
|
|
Tercio@11
|
2040 local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 128, 64)
|
|
Tercio@11
|
2041 editbox:SetAutoFocus (false)
|
|
Tercio@11
|
2042 editbox:SetHook ("OnEditFocusGained", function()
|
|
Tercio@11
|
2043 editbox.text = editbox.link
|
|
Tercio@11
|
2044 editbox:HighlightText()
|
|
Tercio@11
|
2045 end)
|
|
Tercio@11
|
2046 editbox:SetHook ("OnEditFocusLost", function()
|
|
Tercio@11
|
2047 editbox:Hide()
|
|
Tercio@11
|
2048 end)
|
|
Tercio@11
|
2049 editbox:SetHook ("OnChar", function()
|
|
Tercio@11
|
2050 editbox.text = editbox.link
|
|
Tercio@11
|
2051 editbox:HighlightText()
|
|
Tercio@11
|
2052 end)
|
|
Tercio@11
|
2053 editbox.text = ""
|
|
Tercio@11
|
2054
|
|
Tercio@11
|
2055 DF.addon_link_textbox = editbox
|
|
Tercio@11
|
2056 addon_link_textbox = editbox
|
|
Tercio@11
|
2057 end
|
|
Tercio@11
|
2058
|
|
Tercio@11
|
2059 addon_link_textbox.link = self.link
|
|
Tercio@11
|
2060 addon_link_textbox.text = self.link
|
|
Tercio@11
|
2061 addon_link_textbox:Show()
|
|
Tercio@11
|
2062
|
|
Tercio@11
|
2063 addon_link_textbox:SetPoint ("topleft", self.icon, "topleft", 0, 0)
|
|
Tercio@11
|
2064
|
|
Tercio@11
|
2065 addon_link_textbox:HighlightText()
|
|
Tercio@11
|
2066
|
|
Tercio@11
|
2067 addon_link_textbox:SetFocus()
|
|
Tercio@11
|
2068 addon_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
|
|
Tercio@11
|
2069 end
|
|
Tercio@11
|
2070
|
|
Tercio@11
|
2071 local feedback_get_addons_line = function (self)
|
|
Tercio@11
|
2072 local line = self.addons_lines [self.next_addons]
|
|
Tercio@11
|
2073 if (not line) then
|
|
Tercio@11
|
2074
|
|
Tercio@11
|
2075 line = CreateFrame ("frame", "AddonFeedbackPanelSA" .. self.next_addons, self)
|
|
Tercio@11
|
2076 line:SetSize (128, 64)
|
|
Tercio@11
|
2077
|
|
Tercio@11
|
2078 if (self.next_addons == 1) then
|
|
Tercio@11
|
2079 line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5)
|
|
Tercio@11
|
2080 elseif (self.next_addons_line_break == self.next_addons) then
|
|
Tercio@11
|
2081 line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5 + floor (self.next_addons_line_break/3) * 66 * -1)
|
|
Tercio@11
|
2082 self.next_addons_line_break = self.next_addons_line_break + 3
|
|
Tercio@11
|
2083 else
|
|
Tercio@11
|
2084 local previous = self.addons_lines [self.next_addons - 1]
|
|
Tercio@11
|
2085 line:SetPoint ("topleft", previous, "topright", 2, 0)
|
|
Tercio@11
|
2086 end
|
|
Tercio@11
|
2087
|
|
Tercio@11
|
2088 line:SetScript ("OnEnter", on_enter_addon)
|
|
Tercio@11
|
2089 line:SetScript ("OnLeave", on_leave_addon)
|
|
Tercio@11
|
2090 line:SetScript ("OnMouseUp", on_click_addon)
|
|
Tercio@11
|
2091
|
|
Tercio@11
|
2092 line.icon = line:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
2093 line.icon:SetSize (128, 64)
|
|
Tercio@11
|
2094
|
|
Tercio@11
|
2095 line.icon:SetPoint ("topleft", line, "topleft", 0, 0)
|
|
Tercio@11
|
2096
|
|
Tercio@11
|
2097 self.addons_lines [self.next_addons] = line
|
|
Tercio@11
|
2098 end
|
|
Tercio@11
|
2099
|
|
Tercio@11
|
2100 self.next_addons = self.next_addons + 1
|
|
Tercio@11
|
2101
|
|
Tercio@11
|
2102 return line
|
|
Tercio@11
|
2103 end
|
|
Tercio@11
|
2104
|
|
Tercio@11
|
2105 local default_coords = {0, 1, 0, 1}
|
|
Tercio@11
|
2106 local feedback_add_fb = function (self, table)
|
|
Tercio@11
|
2107 local line = self:GetFeedbackLine()
|
|
Tercio@11
|
2108 line.icon:SetTexture (table.icon)
|
|
Tercio@11
|
2109 line.icon:SetTexCoord (unpack (table.coords or default_coords))
|
|
Tercio@11
|
2110 line.desc:SetText (table.desc)
|
|
Tercio@11
|
2111 line.link = table.link
|
|
Tercio@11
|
2112 line:Show()
|
|
Tercio@11
|
2113 end
|
|
Tercio@11
|
2114
|
|
Tercio@11
|
2115 local feedback_add_addon = function (self, table)
|
|
Tercio@11
|
2116 local block = self:GetAddonsLine()
|
|
Tercio@11
|
2117 block.icon:SetTexture (table.icon)
|
|
Tercio@11
|
2118 block.icon:SetTexCoord (unpack (table.coords or default_coords))
|
|
Tercio@11
|
2119 block.link = table.link
|
|
Tercio@11
|
2120 block.tooltip = table.desc
|
|
Tercio@11
|
2121 block.name = table.name
|
|
Tercio@11
|
2122 block:Show()
|
|
Tercio@11
|
2123 end
|
|
Tercio@11
|
2124
|
|
Tercio@11
|
2125 local feedback_hide_all = function (self)
|
|
Tercio@11
|
2126 self.next_feedback = 1
|
|
Tercio@11
|
2127 self.next_addons = 1
|
|
Tercio@11
|
2128
|
|
Tercio@11
|
2129 for index, line in ipairs (self.feedback_lines) do
|
|
Tercio@11
|
2130 line:Hide()
|
|
Tercio@11
|
2131 end
|
|
Tercio@11
|
2132
|
|
Tercio@11
|
2133 for index, line in ipairs (self.addons_lines) do
|
|
Tercio@11
|
2134 line:Hide()
|
|
Tercio@11
|
2135 end
|
|
Tercio@11
|
2136 end
|
|
Tercio@11
|
2137
|
|
Tercio@11
|
2138 -- feedback_methods = { { icon = icon path, desc = description, link = url}}
|
|
Tercio@11
|
2139 function DF:ShowFeedbackPanel (addon_name, version, feedback_methods, more_addons)
|
|
Tercio@11
|
2140
|
|
Tercio@11
|
2141 local f = _G.AddonFeedbackPanel
|
|
Tercio@11
|
2142
|
|
Tercio@11
|
2143 if (not f) then
|
|
Tercio@11
|
2144 f = DF:Create1PxPanel (UIParent, 400, 100, addon_name .. " Feedback", "AddonFeedbackPanel", nil)
|
|
Tercio@11
|
2145 f:SetFrameStrata ("FULLSCREEN")
|
|
Tercio@11
|
2146 f:SetPoint ("center", UIParent, "center")
|
|
Tercio@11
|
2147 f:SetBackdropColor (0, 0, 0, 0.8)
|
|
Tercio@11
|
2148 f.feedback_lines = {}
|
|
Tercio@11
|
2149 f.addons_lines = {}
|
|
Tercio@11
|
2150 f.next_feedback = 1
|
|
Tercio@11
|
2151 f.next_addons = 1
|
|
Tercio@11
|
2152 f.next_addons_line_break = 4
|
|
Tercio@11
|
2153
|
|
Tercio@11
|
2154 local feedback_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@11
|
2155 feedback_anchor:SetText ("Feedback:")
|
|
Tercio@11
|
2156 feedback_anchor:SetPoint ("topleft", f, "topleft", 5, -30)
|
|
Tercio@11
|
2157 f.feedback_anchor = feedback_anchor
|
|
Tercio@11
|
2158 local excla_text = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@11
|
2159 excla_text:SetText ("click and copy the link")
|
|
Tercio@11
|
2160 excla_text:SetPoint ("topright", f, "topright", -5, -30)
|
|
Tercio@11
|
2161 excla_text:SetTextColor (1, 0.8, 0.2, 0.6)
|
|
Tercio@11
|
2162
|
|
Tercio@11
|
2163 local addons_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@11
|
2164 addons_anchor:SetText ("AddOns From the Same Author:")
|
|
Tercio@11
|
2165 f.addons_anchor = addons_anchor
|
|
Tercio@11
|
2166 local excla_text2 = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@11
|
2167 excla_text2:SetText ("click and copy the link")
|
|
Tercio@11
|
2168 excla_text2:SetTextColor (1, 0.8, 0.2, 0.6)
|
|
Tercio@11
|
2169 f.excla_text2 = excla_text2
|
|
Tercio@11
|
2170
|
|
Tercio@11
|
2171 f.GetFeedbackLine = feedback_get_fb_line
|
|
Tercio@11
|
2172 f.GetAddonsLine = feedback_get_addons_line
|
|
Tercio@11
|
2173 f.AddFeedbackMethod = feedback_add_fb
|
|
Tercio@11
|
2174 f.AddOtherAddon = feedback_add_addon
|
|
Tercio@11
|
2175 f.HideAll = feedback_hide_all
|
|
Tercio@11
|
2176
|
|
Tercio@11
|
2177 DF:SetFontSize (f.Title, 14)
|
|
Tercio@11
|
2178
|
|
Tercio@11
|
2179 end
|
|
Tercio@11
|
2180
|
|
Tercio@11
|
2181 f:HideAll()
|
|
Tercio@11
|
2182 f:SetTitle (addon_name)
|
|
Tercio@11
|
2183
|
|
Tercio@11
|
2184 for index, feedback in ipairs (feedback_methods) do
|
|
Tercio@11
|
2185 f:AddFeedbackMethod (feedback)
|
|
Tercio@11
|
2186 end
|
|
Tercio@11
|
2187
|
|
Tercio@11
|
2188 f.addons_anchor:SetPoint ("topleft", f, "topleft", 5, f.next_feedback * 50 * -1)
|
|
Tercio@11
|
2189 f.excla_text2:SetPoint ("topright", f, "topright", -5, f.next_feedback * 50 * -1)
|
|
Tercio@11
|
2190
|
|
Tercio@11
|
2191 for index, addon in ipairs (more_addons) do
|
|
Tercio@11
|
2192 f:AddOtherAddon (addon)
|
|
Tercio@11
|
2193 end
|
|
Tercio@11
|
2194
|
|
Tercio@11
|
2195 f:SetHeight (80 + ((f.next_feedback-1) * 50) + (ceil ((f.next_addons-1)/3) * 66))
|
|
Tercio@11
|
2196
|
|
Tercio@11
|
2197 f:Show()
|
|
Tercio@11
|
2198
|
|
Tercio@11
|
2199 return true
|
|
Tercio@11
|
2200 end
|
|
Tercio@11
|
2201
|
|
Tercio@11
|
2202
|
|
Tercio@11
|
2203 ------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
2204 --> chart panel -- ~chart
|
|
Tercio@11
|
2205
|
|
Tercio@11
|
2206 local chart_panel_backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
|
|
Tercio@11
|
2207 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 32, insets = {left = 5, right = 5, top = 5, bottom = 5}}
|
|
Tercio@11
|
2208
|
|
Tercio@11
|
2209 local chart_panel_align_timelabels = function (self, elapsed_time)
|
|
Tercio@11
|
2210
|
|
Tercio@11
|
2211 self.TimeScale = elapsed_time
|
|
Tercio@11
|
2212
|
|
Tercio@11
|
2213 local linha = self.TimeLabels [17]
|
|
Tercio@11
|
2214 local minutos, segundos = math.floor (elapsed_time / 60), math.floor (elapsed_time % 60)
|
|
Tercio@11
|
2215 if (segundos < 10) then
|
|
Tercio@11
|
2216 segundos = "0" .. segundos
|
|
Tercio@11
|
2217 end
|
|
Tercio@11
|
2218
|
|
Tercio@11
|
2219 if (minutos > 0) then
|
|
Tercio@11
|
2220 if (minutos < 10) then
|
|
Tercio@11
|
2221 minutos = "0" .. minutos
|
|
Tercio@11
|
2222 end
|
|
Tercio@11
|
2223 linha:SetText (minutos .. ":" .. segundos)
|
|
Tercio@11
|
2224 else
|
|
Tercio@11
|
2225 linha:SetText ("00:" .. segundos)
|
|
Tercio@11
|
2226 end
|
|
Tercio@11
|
2227
|
|
Tercio@11
|
2228 local time_div = elapsed_time / 16 --786 -- 49.125
|
|
Tercio@11
|
2229
|
|
Tercio@11
|
2230 for i = 2, 16 do
|
|
Tercio@11
|
2231
|
|
Tercio@11
|
2232 local linha = self.TimeLabels [i]
|
|
Tercio@11
|
2233
|
|
Tercio@11
|
2234 local this_time = time_div * (i-1)
|
|
Tercio@11
|
2235 local minutos, segundos = math.floor (this_time / 60), math.floor (this_time % 60)
|
|
Tercio@11
|
2236
|
|
Tercio@11
|
2237 if (segundos < 10) then
|
|
Tercio@11
|
2238 segundos = "0" .. segundos
|
|
Tercio@11
|
2239 end
|
|
Tercio@11
|
2240
|
|
Tercio@11
|
2241 if (minutos > 0) then
|
|
Tercio@11
|
2242 if (minutos < 10) then
|
|
Tercio@11
|
2243 minutos = "0" .. minutos
|
|
Tercio@11
|
2244 end
|
|
Tercio@11
|
2245 linha:SetText (minutos .. ":" .. segundos)
|
|
Tercio@11
|
2246 else
|
|
Tercio@11
|
2247 linha:SetText ("00:" .. segundos)
|
|
Tercio@11
|
2248 end
|
|
Tercio@11
|
2249
|
|
Tercio@11
|
2250 end
|
|
Tercio@11
|
2251
|
|
Tercio@11
|
2252 end
|
|
Tercio@11
|
2253
|
|
Tercio@11
|
2254 local chart_panel_set_scale = function (self, amt, func, text)
|
|
Tercio@22
|
2255
|
|
Tercio@11
|
2256 if (type (amt) ~= "number") then
|
|
Tercio@11
|
2257 return
|
|
Tercio@11
|
2258 end
|
|
Tercio@11
|
2259
|
|
Tercio@11
|
2260 local piece = amt / 1000 / 8
|
|
Tercio@22
|
2261 if (not text or text == "") then
|
|
Tercio@22
|
2262 text = amt > 1000000 and "M" or amt > 1000 and "K"
|
|
Tercio@22
|
2263 end
|
|
Tercio@11
|
2264
|
|
Tercio@11
|
2265 for i = 1, 8 do
|
|
Tercio@11
|
2266 if (func) then
|
|
Tercio@11
|
2267 self ["dpsamt" .. math.abs (i-9)]:SetText ( func (piece*i) .. (text or ""))
|
|
Tercio@11
|
2268 else
|
|
Tercio@11
|
2269 if (piece*i > 1) then
|
|
Tercio@22
|
2270 self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.1f", piece*i) .. (text or ""))
|
|
Tercio@11
|
2271 else
|
|
Tercio@11
|
2272 self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.3f", piece*i) .. (text or ""))
|
|
Tercio@11
|
2273 end
|
|
Tercio@11
|
2274 end
|
|
Tercio@11
|
2275 end
|
|
Tercio@11
|
2276 end
|
|
Tercio@11
|
2277
|
|
Tercio@11
|
2278 local chart_panel_can_move = function (self, can)
|
|
Tercio@11
|
2279 self.can_move = can
|
|
Tercio@11
|
2280 end
|
|
Tercio@11
|
2281
|
|
Tercio@11
|
2282 local chart_panel_overlay_reset = function (self)
|
|
Tercio@11
|
2283 self.OverlaysAmount = 1
|
|
Tercio@11
|
2284 for index, pack in ipairs (self.Overlays) do
|
|
Tercio@11
|
2285 for index2, texture in ipairs (pack) do
|
|
Tercio@11
|
2286 texture:Hide()
|
|
Tercio@11
|
2287 end
|
|
Tercio@11
|
2288 end
|
|
Tercio@11
|
2289 end
|
|
Tercio@11
|
2290
|
|
Tercio@11
|
2291 local chart_panel_reset = function (self)
|
|
Tercio@11
|
2292
|
|
Tercio@11
|
2293 self.Graphic:ResetData()
|
|
Tercio@11
|
2294 self.Graphic.max_value = 0
|
|
Tercio@11
|
2295
|
|
Tercio@11
|
2296 self.TimeScale = nil
|
|
Tercio@11
|
2297 self.BoxLabelsAmount = 1
|
|
Tercio@11
|
2298 table.wipe (self.GData)
|
|
Tercio@11
|
2299 table.wipe (self.OData)
|
|
Tercio@11
|
2300
|
|
Tercio@11
|
2301 for index, box in ipairs (self.BoxLabels) do
|
|
Tercio@11
|
2302 box.check:Hide()
|
|
Tercio@11
|
2303 box.button:Hide()
|
|
Tercio@11
|
2304 box.box:Hide()
|
|
Tercio@11
|
2305 box.text:Hide()
|
|
Tercio@11
|
2306 box.border:Hide()
|
|
Tercio@11
|
2307 box.showing = false
|
|
Tercio@11
|
2308 end
|
|
Tercio@11
|
2309
|
|
Tercio@11
|
2310 chart_panel_overlay_reset (self)
|
|
Tercio@11
|
2311 end
|
|
Tercio@11
|
2312
|
|
Tercio@11
|
2313 local chart_panel_enable_line = function (f, thisbox)
|
|
Tercio@11
|
2314
|
|
Tercio@11
|
2315 local index = thisbox.index
|
|
Tercio@11
|
2316 local type = thisbox.type
|
|
Tercio@11
|
2317
|
|
Tercio@11
|
2318 if (thisbox.enabled) then
|
|
Tercio@11
|
2319 --disable
|
|
Tercio@11
|
2320 thisbox.check:Hide()
|
|
Tercio@11
|
2321 thisbox.enabled = false
|
|
Tercio@11
|
2322 else
|
|
Tercio@11
|
2323 --enable
|
|
Tercio@11
|
2324 thisbox.check:Show()
|
|
Tercio@11
|
2325 thisbox.enabled = true
|
|
Tercio@11
|
2326 end
|
|
Tercio@11
|
2327
|
|
Tercio@11
|
2328 if (type == "graphic") then
|
|
Tercio@11
|
2329
|
|
Tercio@11
|
2330 f.Graphic:ResetData()
|
|
Tercio@11
|
2331 f.Graphic.max_value = 0
|
|
Tercio@11
|
2332
|
|
Tercio@11
|
2333 local max = 0
|
|
Tercio@11
|
2334 local max_time = 0
|
|
Tercio@11
|
2335
|
|
Tercio@11
|
2336 for index, box in ipairs (f.BoxLabels) do
|
|
Tercio@11
|
2337 if (box.type == type and box.showing and box.enabled) then
|
|
Tercio@11
|
2338 local data = f.GData [index]
|
|
Tercio@11
|
2339
|
|
Tercio@11
|
2340 f.Graphic:AddDataSeries (data[1], data[2], nil, data[3])
|
|
Tercio@11
|
2341
|
|
Tercio@11
|
2342 if (data[4] > max) then
|
|
Tercio@11
|
2343 max = data[4]
|
|
Tercio@11
|
2344 end
|
|
Tercio@11
|
2345 if (data [5] > max_time) then
|
|
Tercio@11
|
2346 max_time = data [5]
|
|
Tercio@11
|
2347 end
|
|
Tercio@11
|
2348 end
|
|
Tercio@11
|
2349 end
|
|
Tercio@11
|
2350
|
|
Tercio@11
|
2351 f:SetScale (max)
|
|
Tercio@11
|
2352 f:SetTime (max_time)
|
|
Tercio@11
|
2353
|
|
Tercio@11
|
2354 elseif (type == "overlay") then
|
|
Tercio@11
|
2355
|
|
Tercio@11
|
2356 chart_panel_overlay_reset (f)
|
|
Tercio@11
|
2357
|
|
Tercio@11
|
2358 for index, box in ipairs (f.BoxLabels) do
|
|
Tercio@11
|
2359 if (box.type == type and box.showing and box.enabled) then
|
|
Tercio@11
|
2360
|
|
Tercio@11
|
2361 f:AddOverlay (box.index)
|
|
Tercio@11
|
2362
|
|
Tercio@11
|
2363 end
|
|
Tercio@11
|
2364 end
|
|
Tercio@11
|
2365
|
|
Tercio@11
|
2366 end
|
|
Tercio@11
|
2367 end
|
|
Tercio@11
|
2368
|
|
Tercio@11
|
2369 local create_box = function (self, next_box)
|
|
Tercio@11
|
2370
|
|
Tercio@11
|
2371 local thisbox = {}
|
|
Tercio@11
|
2372 self.BoxLabels [next_box] = thisbox
|
|
Tercio@11
|
2373
|
|
Tercio@11
|
2374 local box = DF:NewImage (self.Graphic, nil, 16, 16, "border")
|
|
Tercio@11
|
2375
|
|
Tercio@11
|
2376 local text = DF:NewLabel (self.Graphic)
|
|
Tercio@11
|
2377
|
|
Tercio@11
|
2378 local border = DF:NewImage (self.Graphic, [[Interface\DialogFrame\UI-DialogBox-Gold-Corner]], 30, 30, "artwork")
|
|
Tercio@11
|
2379 border:SetPoint ("center", box, "center", -3, -4)
|
|
Tercio@11
|
2380 border:SetTexture ([[Interface\DialogFrame\UI-DialogBox-Gold-Corner]])
|
|
Tercio@11
|
2381
|
|
Tercio@11
|
2382 local checktexture = DF:NewImage (self.Graphic, [[Interface\Buttons\UI-CheckBox-Check]], 18, 18, "overlay")
|
|
Tercio@11
|
2383 checktexture:SetPoint ("center", box, "center", -1, -1)
|
|
Tercio@11
|
2384 checktexture:SetTexture ([[Interface\Buttons\UI-CheckBox-Check]])
|
|
Tercio@11
|
2385
|
|
Tercio@11
|
2386 thisbox.box = box
|
|
Tercio@11
|
2387 thisbox.text = text
|
|
Tercio@11
|
2388 thisbox.border = border
|
|
Tercio@11
|
2389 thisbox.check = checktexture
|
|
Tercio@11
|
2390 thisbox.enabled = true
|
|
Tercio@11
|
2391
|
|
Tercio@11
|
2392 local button = CreateFrame ("button", nil, self.Graphic)
|
|
Tercio@11
|
2393 button:SetSize (20, 20)
|
|
Tercio@11
|
2394 button:SetScript ("OnClick", function()
|
|
Tercio@11
|
2395 chart_panel_enable_line (self, thisbox)
|
|
Tercio@11
|
2396 end)
|
|
Tercio@22
|
2397 button:SetPoint ("center", box.widget or box, "center")
|
|
Tercio@11
|
2398
|
|
Tercio@11
|
2399 thisbox.button = button
|
|
Tercio@11
|
2400
|
|
Tercio@11
|
2401 thisbox.box:SetPoint ("right", text, "left", -4, 0)
|
|
Tercio@11
|
2402
|
|
Tercio@11
|
2403 if (next_box == 1) then
|
|
Tercio@11
|
2404 thisbox.text:SetPoint ("topright", self, "topright", -35, -16)
|
|
Tercio@11
|
2405 else
|
|
Tercio@11
|
2406 thisbox.text:SetPoint ("right", self.BoxLabels [next_box-1].box, "left", -7, 0)
|
|
Tercio@11
|
2407 end
|
|
Tercio@11
|
2408
|
|
Tercio@11
|
2409 return thisbox
|
|
Tercio@11
|
2410
|
|
Tercio@11
|
2411 end
|
|
Tercio@11
|
2412
|
|
Tercio@11
|
2413 local realign_labels = function (self)
|
|
Tercio@11
|
2414
|
|
Tercio@11
|
2415 local width = self:GetWidth() - 108
|
|
Tercio@11
|
2416
|
|
Tercio@11
|
2417 local first_box = self.BoxLabels [1]
|
|
Tercio@11
|
2418 first_box.text:SetPoint ("topright", self, "topright", -35, -16)
|
|
Tercio@11
|
2419
|
|
Tercio@11
|
2420 local line_width = first_box.text:GetStringWidth() + 26
|
|
Tercio@11
|
2421
|
|
Tercio@11
|
2422 for i = 2, #self.BoxLabels do
|
|
Tercio@11
|
2423
|
|
Tercio@11
|
2424 local box = self.BoxLabels [i]
|
|
Tercio@11
|
2425
|
|
Tercio@11
|
2426 if (box.box:IsShown()) then
|
|
Tercio@11
|
2427
|
|
Tercio@11
|
2428 line_width = line_width + box.text:GetStringWidth() + 26
|
|
Tercio@11
|
2429
|
|
Tercio@11
|
2430 if (line_width > width) then
|
|
Tercio@11
|
2431 line_width = box.text:GetStringWidth() + 26
|
|
Tercio@11
|
2432 box.text:SetPoint ("topright", self, "topright", -35, -40)
|
|
Tercio@11
|
2433 else
|
|
Tercio@11
|
2434 box.text:SetPoint ("right", self.BoxLabels [i-1].box, "left", -7, 0)
|
|
Tercio@11
|
2435 end
|
|
Tercio@11
|
2436 else
|
|
Tercio@11
|
2437 break
|
|
Tercio@11
|
2438 end
|
|
Tercio@11
|
2439 end
|
|
Tercio@11
|
2440
|
|
Tercio@11
|
2441 end
|
|
Tercio@11
|
2442
|
|
Tercio@11
|
2443 local chart_panel_add_label = function (self, color, name, type, number)
|
|
Tercio@11
|
2444
|
|
Tercio@11
|
2445 local next_box = self.BoxLabelsAmount
|
|
Tercio@11
|
2446 local thisbox = self.BoxLabels [next_box]
|
|
Tercio@11
|
2447
|
|
Tercio@11
|
2448 if (not thisbox) then
|
|
Tercio@11
|
2449 thisbox = create_box (self, next_box)
|
|
Tercio@11
|
2450 end
|
|
Tercio@11
|
2451
|
|
Tercio@11
|
2452 self.BoxLabelsAmount = self.BoxLabelsAmount + 1
|
|
Tercio@11
|
2453
|
|
Tercio@11
|
2454 thisbox.type = type
|
|
Tercio@11
|
2455 thisbox.index = number
|
|
Tercio@11
|
2456
|
|
Tercio@11
|
2457 thisbox.box:SetTexture (unpack (color))
|
|
Tercio@11
|
2458 thisbox.text:SetText (name)
|
|
Tercio@11
|
2459
|
|
Tercio@11
|
2460 thisbox.check:Show()
|
|
Tercio@11
|
2461 thisbox.button:Show()
|
|
Tercio@11
|
2462 thisbox.border:Show()
|
|
Tercio@11
|
2463 thisbox.box:Show()
|
|
Tercio@11
|
2464 thisbox.text:Show()
|
|
Tercio@11
|
2465
|
|
Tercio@11
|
2466 thisbox.showing = true
|
|
Tercio@11
|
2467 thisbox.enabled = true
|
|
Tercio@11
|
2468
|
|
Tercio@11
|
2469 realign_labels (self)
|
|
Tercio@11
|
2470
|
|
Tercio@11
|
2471 end
|
|
Tercio@11
|
2472
|
|
Tercio@11
|
2473 local line_default_color = {1, 1, 1}
|
|
Tercio@11
|
2474 local draw_overlay = function (self, this_overlay, overlayData, color)
|
|
Tercio@11
|
2475
|
|
Tercio@11
|
2476 local pixel = self.Graphic:GetWidth() / self.TimeScale
|
|
Tercio@11
|
2477 local index = 1
|
|
Tercio@11
|
2478 local r, g, b = unpack (color)
|
|
Tercio@11
|
2479
|
|
Tercio@11
|
2480 for i = 1, #overlayData, 2 do
|
|
Tercio@11
|
2481 local aura_start = overlayData [i]
|
|
Tercio@11
|
2482 local aura_end = overlayData [i+1]
|
|
Tercio@11
|
2483
|
|
Tercio@11
|
2484 local this_block = this_overlay [index]
|
|
Tercio@11
|
2485 if (not this_block) then
|
|
Tercio@11
|
2486 this_block = self.Graphic:CreateTexture (nil, "border")
|
|
Tercio@11
|
2487 tinsert (this_overlay, this_block)
|
|
Tercio@11
|
2488 end
|
|
Tercio@11
|
2489 this_block:SetHeight (self.Graphic:GetHeight())
|
|
Tercio@11
|
2490
|
|
Tercio@11
|
2491 this_block:SetPoint ("left", self.Graphic, "left", pixel * aura_start, 0)
|
|
Tercio@11
|
2492 if (aura_end) then
|
|
Tercio@11
|
2493 this_block:SetWidth ((aura_end-aura_start)*pixel)
|
|
Tercio@11
|
2494 else
|
|
Tercio@11
|
2495 --malformed table
|
|
Tercio@11
|
2496 this_block:SetWidth (pixel*5)
|
|
Tercio@11
|
2497 end
|
|
Tercio@11
|
2498
|
|
Tercio@11
|
2499 this_block:SetTexture (r, g, b, 0.25)
|
|
Tercio@11
|
2500 this_block:Show()
|
|
Tercio@11
|
2501
|
|
Tercio@11
|
2502 index = index + 1
|
|
Tercio@11
|
2503 end
|
|
Tercio@11
|
2504
|
|
Tercio@11
|
2505 end
|
|
Tercio@11
|
2506
|
|
Tercio@11
|
2507 local chart_panel_add_overlay = function (self, overlayData, color, name, icon)
|
|
Tercio@11
|
2508
|
|
Tercio@11
|
2509 if (not self.TimeScale) then
|
|
Tercio@11
|
2510 error ("Use SetTime (time) before adding an overlay.")
|
|
Tercio@11
|
2511 end
|
|
Tercio@11
|
2512
|
|
Tercio@11
|
2513 if (type (overlayData) == "number") then
|
|
Tercio@11
|
2514 local overlay_index = overlayData
|
|
Tercio@11
|
2515 draw_overlay (self, self.Overlays [self.OverlaysAmount], self.OData [overlay_index][1], self.OData [overlay_index][2])
|
|
Tercio@11
|
2516 else
|
|
Tercio@11
|
2517 local this_overlay = self.Overlays [self.OverlaysAmount]
|
|
Tercio@11
|
2518 if (not this_overlay) then
|
|
Tercio@11
|
2519 this_overlay = {}
|
|
Tercio@11
|
2520 tinsert (self.Overlays, this_overlay)
|
|
Tercio@11
|
2521 end
|
|
Tercio@11
|
2522
|
|
Tercio@11
|
2523 draw_overlay (self, this_overlay, overlayData, color)
|
|
Tercio@11
|
2524
|
|
Tercio@11
|
2525 tinsert (self.OData, {overlayData, color or line_default_color})
|
|
Tercio@11
|
2526 if (name) then
|
|
Tercio@11
|
2527 self:AddLabel (color or line_default_color, name, "overlay", #self.OData)
|
|
Tercio@11
|
2528 end
|
|
Tercio@11
|
2529 end
|
|
Tercio@11
|
2530
|
|
Tercio@11
|
2531 self.OverlaysAmount = self.OverlaysAmount + 1
|
|
Tercio@11
|
2532 end
|
|
Tercio@11
|
2533
|
|
Tercio@11
|
2534 local SMA_table = {}
|
|
Tercio@11
|
2535 local SMA_max = 0
|
|
Tercio@11
|
2536 local reset_SMA = function()
|
|
Tercio@11
|
2537 table.wipe (SMA_table)
|
|
Tercio@11
|
2538 SMA_max = 0
|
|
Tercio@11
|
2539 end
|
|
Tercio@11
|
2540
|
|
Tercio@11
|
2541 local calc_SMA
|
|
Tercio@11
|
2542 calc_SMA = function (a, b, ...)
|
|
Tercio@11
|
2543 if (b) then
|
|
Tercio@11
|
2544 return calc_SMA (a + b, ...)
|
|
Tercio@11
|
2545 else
|
|
Tercio@11
|
2546 return a
|
|
Tercio@11
|
2547 end
|
|
Tercio@11
|
2548 end
|
|
Tercio@11
|
2549
|
|
Tercio@11
|
2550 local do_SMA = function (value, max_value)
|
|
Tercio@11
|
2551
|
|
Tercio@11
|
2552 if (#SMA_table == 10) then
|
|
Tercio@11
|
2553 tremove (SMA_table, 1)
|
|
Tercio@11
|
2554 end
|
|
Tercio@11
|
2555
|
|
Tercio@11
|
2556 SMA_table [#SMA_table + 1] = value
|
|
Tercio@11
|
2557
|
|
Tercio@11
|
2558 local new_value = calc_SMA (unpack (SMA_table)) / #SMA_table
|
|
Tercio@11
|
2559
|
|
Tercio@11
|
2560 if (new_value > SMA_max) then
|
|
Tercio@11
|
2561 SMA_max = new_value
|
|
Tercio@11
|
2562 return new_value, SMA_max
|
|
Tercio@11
|
2563 else
|
|
Tercio@11
|
2564 return new_value
|
|
Tercio@11
|
2565 end
|
|
Tercio@11
|
2566
|
|
Tercio@11
|
2567 end
|
|
Tercio@11
|
2568
|
|
Tercio@11
|
2569 local chart_panel_add_data = function (self, graphicData, color, name, elapsed_time, lineTexture, smoothLevel, firstIndex)
|
|
Tercio@11
|
2570
|
|
Tercio@11
|
2571 local f = self
|
|
Tercio@11
|
2572 self = self.Graphic
|
|
Tercio@22
|
2573
|
|
Tercio@11
|
2574 local _data = {}
|
|
Tercio@11
|
2575 local max_value = graphicData.max_value
|
|
Tercio@11
|
2576 local amount = #graphicData
|
|
Tercio@11
|
2577
|
|
Tercio@11
|
2578 local scaleW = 1/self:GetWidth()
|
|
Tercio@11
|
2579
|
|
Tercio@11
|
2580 local content = graphicData
|
|
Tercio@11
|
2581 tinsert (content, 1, 0)
|
|
Tercio@11
|
2582 tinsert (content, 1, 0)
|
|
Tercio@11
|
2583 tinsert (content, #content+1, 0)
|
|
Tercio@11
|
2584 tinsert (content, #content+1, 0)
|
|
Tercio@11
|
2585
|
|
Tercio@11
|
2586 local _i = 3
|
|
Tercio@11
|
2587
|
|
Tercio@11
|
2588 local graphMaxDps = math.max (self.max_value, max_value)
|
|
Tercio@11
|
2589
|
|
Tercio@11
|
2590 if (not smoothLevel) then
|
|
Tercio@11
|
2591 while (_i <= #content-2) do
|
|
Tercio@11
|
2592 local v = (content[_i-2]+content[_i-1]+content[_i]+content[_i+1]+content[_i+2])/5 --> normalize
|
|
Tercio@11
|
2593 _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
|
|
Tercio@11
|
2594 _i = _i + 1
|
|
Tercio@11
|
2595 end
|
|
Tercio@11
|
2596
|
|
Tercio@11
|
2597 elseif (smoothLevel == "SHORT") then
|
|
Tercio@11
|
2598 while (_i <= #content-2) do
|
|
Tercio@11
|
2599 local value = (content[_i] + content[_i+1]) / 2
|
|
Tercio@11
|
2600 _data [#_data+1] = {scaleW*(_i-2), value}
|
|
Tercio@11
|
2601 _data [#_data+1] = {scaleW*(_i-2), value}
|
|
Tercio@11
|
2602 _i = _i + 2
|
|
Tercio@11
|
2603 end
|
|
Tercio@11
|
2604
|
|
Tercio@11
|
2605 elseif (smoothLevel == "SMA") then
|
|
Tercio@11
|
2606 reset_SMA()
|
|
Tercio@11
|
2607 while (_i <= #content-2) do
|
|
Tercio@11
|
2608 local value, is_new_max_value = do_SMA (content[_i], max_value)
|
|
Tercio@11
|
2609 if (is_new_max_value) then
|
|
Tercio@11
|
2610 max_value = is_new_max_value
|
|
Tercio@11
|
2611 end
|
|
Tercio@11
|
2612 _data [#_data+1] = {scaleW*(_i-2), value} --> x and y coords
|
|
Tercio@11
|
2613 _i = _i + 1
|
|
Tercio@11
|
2614 end
|
|
Tercio@11
|
2615
|
|
Tercio@11
|
2616 elseif (smoothLevel == -1) then
|
|
Tercio@11
|
2617 while (_i <= #content-2) do
|
|
Tercio@11
|
2618 local current = content[_i]
|
|
Tercio@11
|
2619
|
|
Tercio@11
|
2620 local minus_2 = content[_i-2] * 0.6
|
|
Tercio@11
|
2621 local minus_1 = content[_i-1] * 0.8
|
|
Tercio@11
|
2622 local plus_1 = content[_i+1] * 0.8
|
|
Tercio@11
|
2623 local plus_2 = content[_i+2] * 0.6
|
|
Tercio@11
|
2624
|
|
Tercio@11
|
2625 local v = (current + minus_2 + minus_1 + plus_1 + plus_2)/5 --> normalize
|
|
Tercio@11
|
2626 _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
|
|
Tercio@11
|
2627 _i = _i + 1
|
|
Tercio@11
|
2628 end
|
|
Tercio@11
|
2629
|
|
Tercio@11
|
2630 elseif (smoothLevel == 1) then
|
|
Tercio@11
|
2631 _i = 2
|
|
Tercio@11
|
2632 while (_i <= #content-1) do
|
|
Tercio@11
|
2633 local v = (content[_i-1]+content[_i]+content[_i+1])/3 --> normalize
|
|
Tercio@11
|
2634 _data [#_data+1] = {scaleW*(_i-1), v/graphMaxDps} --> x and y coords
|
|
Tercio@11
|
2635 _i = _i + 1
|
|
Tercio@11
|
2636 end
|
|
Tercio@11
|
2637
|
|
Tercio@11
|
2638 elseif (smoothLevel == 2) then
|
|
Tercio@11
|
2639 _i = 1
|
|
Tercio@11
|
2640 while (_i <= #content) do
|
|
Tercio@11
|
2641 local v = content[_i] --> do not normalize
|
|
Tercio@11
|
2642 _data [#_data+1] = {scaleW*(_i), v/graphMaxDps} --> x and y coords
|
|
Tercio@11
|
2643 _i = _i + 1
|
|
Tercio@11
|
2644 end
|
|
Tercio@11
|
2645
|
|
Tercio@11
|
2646 end
|
|
Tercio@11
|
2647
|
|
Tercio@11
|
2648 tremove (content, 1)
|
|
Tercio@11
|
2649 tremove (content, 1)
|
|
Tercio@11
|
2650 tremove (content, #graphicData)
|
|
Tercio@11
|
2651 tremove (content, #graphicData)
|
|
Tercio@11
|
2652
|
|
Tercio@11
|
2653 if (max_value > self.max_value) then
|
|
Tercio@11
|
2654 --> normalize previous data
|
|
Tercio@11
|
2655 if (self.max_value > 0) then
|
|
Tercio@11
|
2656 local normalizePercent = self.max_value / max_value
|
|
Tercio@11
|
2657 for dataIndex, Data in ipairs (self.Data) do
|
|
Tercio@11
|
2658 local Points = Data.Points
|
|
Tercio@11
|
2659 for i = 1, #Points do
|
|
Tercio@11
|
2660 Points[i][2] = Points[i][2]*normalizePercent
|
|
Tercio@11
|
2661 end
|
|
Tercio@11
|
2662 end
|
|
Tercio@11
|
2663 end
|
|
Tercio@11
|
2664
|
|
Tercio@11
|
2665 self.max_value = max_value
|
|
Tercio@11
|
2666 f:SetScale (max_value)
|
|
Tercio@11
|
2667
|
|
Tercio@11
|
2668 end
|
|
Tercio@11
|
2669
|
|
Tercio@11
|
2670 tinsert (f.GData, {_data, color or line_default_color, lineTexture, max_value, elapsed_time})
|
|
Tercio@11
|
2671 if (name) then
|
|
Tercio@11
|
2672 f:AddLabel (color or line_default_color, name, "graphic", #f.GData)
|
|
Tercio@11
|
2673 end
|
|
Tercio@11
|
2674
|
|
Tercio@11
|
2675 if (firstIndex) then
|
|
Tercio@11
|
2676 if (lineTexture) then
|
|
Tercio@11
|
2677 if (not lineTexture:find ("\\") and not lineTexture:find ("//")) then
|
|
Tercio@11
|
2678 local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)LibGraph%-2%.0%.lua")
|
|
Tercio@11
|
2679 if path then
|
|
Tercio@11
|
2680 lineTexture = "Interface\\AddOns\\" .. path .. lineTexture
|
|
Tercio@11
|
2681 else
|
|
Tercio@11
|
2682 lineTexture = nil
|
|
Tercio@11
|
2683 end
|
|
Tercio@11
|
2684 end
|
|
Tercio@11
|
2685 end
|
|
Tercio@11
|
2686
|
|
Tercio@11
|
2687 table.insert (self.Data, 1, {Points = _data, Color = color or line_default_color, lineTexture = lineTexture, ElapsedTime = elapsed_time})
|
|
Tercio@11
|
2688 self.NeedsUpdate = true
|
|
Tercio@11
|
2689 else
|
|
Tercio@11
|
2690 self:AddDataSeries (_data, color or line_default_color, nil, lineTexture)
|
|
Tercio@11
|
2691 self.Data [#self.Data].ElapsedTime = elapsed_time
|
|
Tercio@11
|
2692 end
|
|
Tercio@11
|
2693
|
|
Tercio@11
|
2694 local max_time = 0
|
|
Tercio@11
|
2695 for _, data in ipairs (self.Data) do
|
|
Tercio@11
|
2696 if (data.ElapsedTime > max_time) then
|
|
Tercio@11
|
2697 max_time = data.ElapsedTime
|
|
Tercio@11
|
2698 end
|
|
Tercio@11
|
2699 end
|
|
Tercio@11
|
2700
|
|
Tercio@11
|
2701 f:SetTime (max_time)
|
|
Tercio@11
|
2702
|
|
Tercio@11
|
2703 end
|
|
Tercio@11
|
2704
|
|
Tercio@11
|
2705 local chart_panel_onresize = function (self)
|
|
Tercio@11
|
2706 local width, height = self:GetSize()
|
|
Tercio@11
|
2707 local spacement = width - 78 - 60
|
|
Tercio@11
|
2708 spacement = spacement / 16
|
|
Tercio@11
|
2709
|
|
Tercio@11
|
2710 for i = 1, 17 do
|
|
Tercio@11
|
2711 local label = self.TimeLabels [i]
|
|
Tercio@11
|
2712 label:SetPoint ("bottomleft", self, "bottomleft", 78 + ((i-1)*spacement), 13)
|
|
Tercio@11
|
2713 label.line:SetHeight (height - 45)
|
|
Tercio@11
|
2714 end
|
|
Tercio@11
|
2715
|
|
Tercio@11
|
2716 local spacement = (self.Graphic:GetHeight()) / 8
|
|
Tercio@11
|
2717 for i = 1, 8 do
|
|
Tercio@11
|
2718 self ["dpsamt"..i]:SetPoint ("TOPLEFT", self, "TOPLEFT", 27, -25 + (-(spacement* (i-1))) )
|
|
Tercio@11
|
2719 self ["dpsamt"..i].line:SetWidth (width-20)
|
|
Tercio@11
|
2720 end
|
|
Tercio@11
|
2721
|
|
Tercio@11
|
2722 self.Graphic:SetSize (width - 135, height - 67)
|
|
Tercio@11
|
2723 self.Graphic:SetPoint ("topleft", self, "topleft", 108, -35)
|
|
Tercio@11
|
2724 end
|
|
Tercio@11
|
2725
|
|
Tercio@11
|
2726 local chart_panel_vlines_on = function (self)
|
|
Tercio@11
|
2727 for i = 1, 17 do
|
|
Tercio@11
|
2728 local label = self.TimeLabels [i]
|
|
Tercio@11
|
2729 label.line:Show()
|
|
Tercio@11
|
2730 end
|
|
Tercio@11
|
2731 end
|
|
Tercio@11
|
2732
|
|
Tercio@11
|
2733 local chart_panel_vlines_off = function (self)
|
|
Tercio@11
|
2734 for i = 1, 17 do
|
|
Tercio@11
|
2735 local label = self.TimeLabels [i]
|
|
Tercio@11
|
2736 label.line:Hide()
|
|
Tercio@11
|
2737 end
|
|
Tercio@11
|
2738 end
|
|
Tercio@11
|
2739
|
|
Tercio@11
|
2740 local chart_panel_set_title = function (self, title)
|
|
Tercio@11
|
2741 self.chart_title.text = title
|
|
Tercio@11
|
2742 end
|
|
Tercio@11
|
2743
|
|
Tercio@11
|
2744 local chart_panel_mousedown = function (self, button)
|
|
Tercio@11
|
2745 if (button == "LeftButton" and self.can_move) then
|
|
Tercio@11
|
2746 if (not self.isMoving) then
|
|
Tercio@11
|
2747 self:StartMoving()
|
|
Tercio@11
|
2748 self.isMoving = true
|
|
Tercio@11
|
2749 end
|
|
Tercio@11
|
2750 elseif (button == "RightButton" and not self.no_right_click_close) then
|
|
Tercio@11
|
2751 if (not self.isMoving) then
|
|
Tercio@11
|
2752 self:Hide()
|
|
Tercio@11
|
2753 end
|
|
Tercio@11
|
2754 end
|
|
Tercio@11
|
2755 end
|
|
Tercio@11
|
2756 local chart_panel_mouseup = function (self, button)
|
|
Tercio@11
|
2757 if (button == "LeftButton" and self.isMoving) then
|
|
Tercio@11
|
2758 self:StopMovingOrSizing()
|
|
Tercio@11
|
2759 self.isMoving = nil
|
|
Tercio@11
|
2760 end
|
|
Tercio@11
|
2761 end
|
|
Tercio@11
|
2762
|
|
Tercio@11
|
2763 local chart_panel_hide_close_button = function (self)
|
|
Tercio@11
|
2764 self.CloseButton:Hide()
|
|
Tercio@11
|
2765 end
|
|
Tercio@11
|
2766
|
|
Tercio@11
|
2767 local chart_panel_right_click_close = function (self, value)
|
|
Tercio@11
|
2768 if (type (value) == "boolean") then
|
|
Tercio@11
|
2769 if (value) then
|
|
Tercio@11
|
2770 self.no_right_click_close = nil
|
|
Tercio@11
|
2771 else
|
|
Tercio@11
|
2772 self.no_right_click_close = true
|
|
Tercio@11
|
2773 end
|
|
Tercio@11
|
2774 end
|
|
Tercio@11
|
2775 end
|
|
Tercio@11
|
2776
|
|
Tercio@11
|
2777 function DF:CreateChartPanel (parent, w, h, name)
|
|
Tercio@11
|
2778
|
|
Tercio@11
|
2779 if (not name) then
|
|
Tercio@11
|
2780 name = "DFPanel" .. DF.PanelCounter
|
|
Tercio@11
|
2781 DF.PanelCounter = DF.PanelCounter + 1
|
|
Tercio@11
|
2782 end
|
|
Tercio@11
|
2783
|
|
Tercio@11
|
2784 parent = parent or UIParent
|
|
Tercio@11
|
2785 w = w or 800
|
|
Tercio@11
|
2786 h = h or 500
|
|
Tercio@11
|
2787
|
|
Tercio@11
|
2788 local f = CreateFrame ("frame", name, parent)
|
|
Tercio@11
|
2789 f:SetSize (w or 500, h or 400)
|
|
Tercio@11
|
2790 f:EnableMouse (true)
|
|
Tercio@11
|
2791 f:SetMovable (true)
|
|
Tercio@11
|
2792
|
|
Tercio@11
|
2793 f:SetScript ("OnMouseDown", chart_panel_mousedown)
|
|
Tercio@11
|
2794 f:SetScript ("OnMouseUp", chart_panel_mouseup)
|
|
Tercio@11
|
2795
|
|
Tercio@11
|
2796 f:SetBackdrop (chart_panel_backdrop)
|
|
Tercio@11
|
2797 f:SetBackdropColor (.3, .3, .3, .3)
|
|
Tercio@11
|
2798
|
|
Tercio@11
|
2799 local c = CreateFrame ("Button", nil, f, "UIPanelCloseButton")
|
|
Tercio@11
|
2800 c:SetWidth (32)
|
|
Tercio@11
|
2801 c:SetHeight (32)
|
|
Tercio@11
|
2802 c:SetPoint ("TOPRIGHT", f, "TOPRIGHT", -3, -7)
|
|
Tercio@11
|
2803 c:SetFrameLevel (f:GetFrameLevel()+1)
|
|
Tercio@11
|
2804 c:SetAlpha (0.9)
|
|
Tercio@11
|
2805 f.CloseButton = c
|
|
Tercio@11
|
2806
|
|
Tercio@11
|
2807 local title = DF:NewLabel (f, nil, "$parentTitle", "chart_title", "Chart!", nil, 20, {1, 1, 0})
|
|
Tercio@11
|
2808 title:SetPoint ("topleft", f, "topleft", 110, -13)
|
|
Tercio@11
|
2809
|
|
Tercio@11
|
2810 local bottom_texture = DF:NewImage (f, nil, 702, 25, "background", nil, nil, "$parentBottomTexture")
|
|
Tercio@11
|
2811 bottom_texture:SetTexture (0, 0, 0, .6)
|
|
Tercio@11
|
2812 bottom_texture:SetPoint ("bottomleft", f, "bottomleft", 8, 7)
|
|
Tercio@11
|
2813 bottom_texture:SetPoint ("bottomright", f, "bottomright", -8, 7)
|
|
Tercio@11
|
2814
|
|
Tercio@11
|
2815 f.Overlays = {}
|
|
Tercio@11
|
2816 f.OverlaysAmount = 1
|
|
Tercio@11
|
2817
|
|
Tercio@11
|
2818 f.BoxLabels = {}
|
|
Tercio@11
|
2819 f.BoxLabelsAmount = 1
|
|
Tercio@11
|
2820
|
|
Tercio@11
|
2821 f.TimeLabels = {}
|
|
Tercio@11
|
2822 for i = 1, 17 do
|
|
Tercio@11
|
2823 local time = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
|
|
Tercio@11
|
2824 time:SetText ("00:00")
|
|
Tercio@11
|
2825 time:SetPoint ("bottomleft", f, "bottomleft", 78 + ((i-1)*36), 13)
|
|
Tercio@11
|
2826 f.TimeLabels [i] = time
|
|
Tercio@11
|
2827
|
|
Tercio@11
|
2828 local line = f:CreateTexture (nil, "border")
|
|
Tercio@11
|
2829 line:SetSize (1, h-45)
|
|
Tercio@11
|
2830 line:SetTexture (1, 1, 1, .1)
|
|
Tercio@11
|
2831 line:SetPoint ("bottomleft", time, "topright", 0, -10)
|
|
Tercio@11
|
2832 line:Hide()
|
|
Tercio@11
|
2833 time.line = line
|
|
Tercio@11
|
2834 end
|
|
Tercio@11
|
2835
|
|
Tercio@11
|
2836 --graphic
|
|
Tercio@11
|
2837 local g = LibStub:GetLibrary("LibGraph-2.0"):CreateGraphLine (name .. "Graphic", f, "topleft","topleft", 108, -35, w - 120, h - 67)
|
|
Tercio@11
|
2838 g:SetXAxis (-1,1)
|
|
Tercio@11
|
2839 g:SetYAxis (-1,1)
|
|
Tercio@11
|
2840 g:SetGridSpacing (false, false)
|
|
Tercio@11
|
2841 g:SetGridColor ({0.5,0.5,0.5,0.3})
|
|
Tercio@11
|
2842 g:SetAxisDrawing (false,false)
|
|
Tercio@11
|
2843 g:SetAxisColor({1.0,1.0,1.0,1.0})
|
|
Tercio@11
|
2844 g:SetAutoScale (true)
|
|
Tercio@11
|
2845 g:SetLineTexture ("smallline")
|
|
Tercio@11
|
2846 g:SetBorderSize ("right", 0.001)
|
|
Tercio@11
|
2847 g:SetBorderSize ("left", 0.000)
|
|
Tercio@11
|
2848 g:SetBorderSize ("top", 0.002)
|
|
Tercio@11
|
2849 g:SetBorderSize ("bottom", 0.001)
|
|
Tercio@11
|
2850 g.VerticalLines = {}
|
|
Tercio@11
|
2851 g.max_value = 0
|
|
Tercio@11
|
2852
|
|
Tercio@11
|
2853 g:SetLineTexture ("line")
|
|
Tercio@11
|
2854
|
|
Tercio@11
|
2855 f.Graphic = g
|
|
Tercio@11
|
2856 f.GData = {}
|
|
Tercio@11
|
2857 f.OData = {}
|
|
Tercio@11
|
2858
|
|
Tercio@11
|
2859 --div lines
|
|
Tercio@11
|
2860 for i = 1, 8, 1 do
|
|
Tercio@11
|
2861 local line = g:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
2862 line:SetTexture (1, 1, 1, .2)
|
|
Tercio@11
|
2863 line:SetWidth (670)
|
|
Tercio@11
|
2864 line:SetHeight (1.1)
|
|
Tercio@11
|
2865
|
|
Tercio@11
|
2866 local s = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
|
|
Tercio@11
|
2867 f ["dpsamt"..i] = s
|
|
Tercio@11
|
2868 s:SetText ("100k")
|
|
Tercio@11
|
2869 s:SetPoint ("topleft", f, "topleft", 27, -61 + (-(24.6*i)))
|
|
Tercio@11
|
2870
|
|
Tercio@11
|
2871 line:SetPoint ("topleft", s, "bottom", -27, 0)
|
|
Tercio@11
|
2872 s.line = line
|
|
Tercio@11
|
2873 end
|
|
Tercio@11
|
2874
|
|
Tercio@11
|
2875 f.SetTime = chart_panel_align_timelabels
|
|
Tercio@11
|
2876 f.EnableVerticalLines = chart_panel_vlines_on
|
|
Tercio@11
|
2877 f.DisableVerticalLines = chart_panel_vlines_off
|
|
Tercio@11
|
2878 f.SetTitle = chart_panel_set_title
|
|
Tercio@11
|
2879 f.SetScale = chart_panel_set_scale
|
|
Tercio@11
|
2880 f.Reset = chart_panel_reset
|
|
Tercio@11
|
2881 f.AddLine = chart_panel_add_data
|
|
Tercio@11
|
2882 f.CanMove = chart_panel_can_move
|
|
Tercio@11
|
2883 f.AddLabel = chart_panel_add_label
|
|
Tercio@11
|
2884 f.AddOverlay = chart_panel_add_overlay
|
|
Tercio@11
|
2885 f.HideCloseButton = chart_panel_hide_close_button
|
|
Tercio@11
|
2886 f.RightClickClose = chart_panel_right_click_close
|
|
Tercio@11
|
2887
|
|
Tercio@11
|
2888 f:SetScript ("OnSizeChanged", chart_panel_onresize)
|
|
Tercio@11
|
2889 chart_panel_onresize (f)
|
|
Tercio@11
|
2890
|
|
Tercio@11
|
2891 return f
|
|
Tercio@20
|
2892 end
|
|
Tercio@20
|
2893
|
|
Tercio@20
|
2894 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@20
|
2895 -- ~gframe
|
|
Tercio@20
|
2896 local gframe_on_enter_line = function (self)
|
|
Tercio@20
|
2897 self:SetBackdropColor (0, 0, 0, 0)
|
|
Tercio@20
|
2898
|
|
Tercio@20
|
2899 local parent = self:GetParent()
|
|
Tercio@20
|
2900 local ball = self.ball
|
|
Tercio@20
|
2901 ball:SetBlendMode ("ADD")
|
|
Tercio@20
|
2902
|
|
Tercio@20
|
2903 local on_enter = parent._onenter_line
|
|
Tercio@20
|
2904 if (on_enter) then
|
|
Tercio@20
|
2905 return on_enter (self, parent)
|
|
Tercio@20
|
2906 end
|
|
Tercio@20
|
2907 end
|
|
Tercio@20
|
2908
|
|
Tercio@20
|
2909 local gframe_on_leave_line = function (self)
|
|
Tercio@20
|
2910 self:SetBackdropColor (0, 0, 0, .6)
|
|
Tercio@20
|
2911
|
|
Tercio@20
|
2912 local parent = self:GetParent()
|
|
Tercio@20
|
2913 local ball = self.ball
|
|
Tercio@20
|
2914 ball:SetBlendMode ("BLEND")
|
|
Tercio@20
|
2915
|
|
Tercio@20
|
2916 local on_leave = parent._onleave_line
|
|
Tercio@20
|
2917 if (on_leave) then
|
|
Tercio@20
|
2918 return on_leave (self, parent)
|
|
Tercio@20
|
2919 end
|
|
Tercio@20
|
2920 end
|
|
Tercio@20
|
2921
|
|
Tercio@20
|
2922 local gframe_create_line = function (self)
|
|
Tercio@20
|
2923 local index = #self._lines+1
|
|
Tercio@20
|
2924
|
|
Tercio@20
|
2925 local f = CreateFrame ("frame", nil, self)
|
|
Tercio@20
|
2926 self._lines [index] = f
|
|
Tercio@20
|
2927 f.id = index
|
|
Tercio@20
|
2928 f:SetScript ("OnEnter", gframe_on_enter_line)
|
|
Tercio@20
|
2929 f:SetScript ("OnLeave", gframe_on_leave_line)
|
|
Tercio@20
|
2930
|
|
Tercio@20
|
2931 f:SetWidth (self._linewidth)
|
|
Tercio@20
|
2932
|
|
Tercio@20
|
2933 if (index == 1) then
|
|
Tercio@20
|
2934 f:SetPoint ("topleft", self, "topleft")
|
|
Tercio@20
|
2935 f:SetPoint ("bottomleft", self, "bottomleft")
|
|
Tercio@20
|
2936 else
|
|
Tercio@20
|
2937 local previous_line = self._lines [index-1]
|
|
Tercio@20
|
2938 f:SetPoint ("topleft", previous_line, "topright")
|
|
Tercio@20
|
2939 f:SetPoint ("bottomleft", previous_line, "bottomright")
|
|
Tercio@20
|
2940 end
|
|
Tercio@20
|
2941
|
|
Tercio@20
|
2942 local t = f:CreateTexture (nil, "background")
|
|
Tercio@20
|
2943 t:SetWidth (1)
|
|
Tercio@20
|
2944 t:SetPoint ("topright", f, "topright")
|
|
Tercio@20
|
2945 t:SetPoint ("bottomright", f, "bottomright")
|
|
Tercio@20
|
2946 t:SetTexture (1, 1, 1, .1)
|
|
Tercio@20
|
2947 f.grid = t
|
|
Tercio@20
|
2948
|
|
Tercio@20
|
2949 local b = f:CreateTexture (nil, "overlay")
|
|
Tercio@20
|
2950 b:SetTexture ([[Interface\COMMON\Indicator-Yellow]])
|
|
Tercio@20
|
2951 b:SetSize (16, 16)
|
|
Tercio@20
|
2952 f.ball = b
|
|
Tercio@20
|
2953 local anchor = CreateFrame ("frame", nil, f)
|
|
Tercio@20
|
2954 anchor:SetAllPoints (b)
|
|
Tercio@20
|
2955 b.tooltip_anchor = anchor
|
|
Tercio@20
|
2956
|
|
Tercio@20
|
2957 local spellicon = f:CreateTexture (nil, "artwork")
|
|
Tercio@20
|
2958 spellicon:SetPoint ("bottom", b, "bottom", 0, 10)
|
|
Tercio@20
|
2959 spellicon:SetSize (16, 16)
|
|
Tercio@20
|
2960 f.spellicon = spellicon
|
|
Tercio@20
|
2961
|
|
Tercio@20
|
2962 local timeline = f:CreateFontString (nil, "overlay", "GameFontNormal")
|
|
Tercio@20
|
2963 timeline:SetPoint ("bottomright", f, "bottomright", -2, 0)
|
|
Tercio@20
|
2964 _detalhes:SetFontSize (timeline, 8)
|
|
Tercio@20
|
2965 f.timeline = timeline
|
|
Tercio@20
|
2966
|
|
Tercio@20
|
2967 return f
|
|
Tercio@20
|
2968 end
|
|
Tercio@20
|
2969
|
|
Tercio@20
|
2970 local gframe_getline = function (self, index)
|
|
Tercio@20
|
2971 local line = self._lines [index]
|
|
Tercio@20
|
2972 if (not line) then
|
|
Tercio@20
|
2973 line = gframe_create_line (self)
|
|
Tercio@20
|
2974 end
|
|
Tercio@20
|
2975 return line
|
|
Tercio@20
|
2976 end
|
|
Tercio@20
|
2977
|
|
Tercio@20
|
2978 local gframe_reset = function (self)
|
|
Tercio@20
|
2979 for i, line in ipairs (self._lines) do
|
|
Tercio@20
|
2980 line:Hide()
|
|
Tercio@20
|
2981 end
|
|
Tercio@20
|
2982 if (self.GraphLib_Lines_Used) then
|
|
Tercio@20
|
2983 for i = #self.GraphLib_Lines_Used, 1, -1 do
|
|
Tercio@20
|
2984 local line = tremove (self.GraphLib_Lines_Used)
|
|
Tercio@20
|
2985 tinsert (self.GraphLib_Lines, line)
|
|
Tercio@20
|
2986 line:Hide()
|
|
Tercio@20
|
2987 end
|
|
Tercio@20
|
2988 end
|
|
Tercio@20
|
2989 end
|
|
Tercio@20
|
2990
|
|
Tercio@20
|
2991 local gframe_update = function (self, lines)
|
|
Tercio@20
|
2992
|
|
Tercio@20
|
2993 local g = LibStub:GetLibrary ("LibGraph-2.0")
|
|
Tercio@20
|
2994 local h = self:GetHeight()/100
|
|
Tercio@20
|
2995 local amtlines = #lines
|
|
Tercio@20
|
2996 local linewidth = self._linewidth
|
|
Tercio@20
|
2997
|
|
Tercio@20
|
2998 local max_value = 0
|
|
Tercio@20
|
2999 for i = 1, amtlines do
|
|
Tercio@20
|
3000 if (lines [i].value > max_value) then
|
|
Tercio@20
|
3001 max_value = lines [i].value
|
|
Tercio@20
|
3002 end
|
|
Tercio@20
|
3003 end
|
|
Tercio@20
|
3004
|
|
Tercio@20
|
3005 local o = 1
|
|
Tercio@20
|
3006 local lastvalue = self:GetHeight()/2
|
|
Tercio@20
|
3007
|
|
Tercio@20
|
3008 for i = 1, min (amtlines, self._maxlines) do
|
|
Tercio@20
|
3009
|
|
Tercio@20
|
3010 local data = lines [i]
|
|
Tercio@20
|
3011
|
|
Tercio@20
|
3012 local pvalue = data.value / max_value * 100
|
|
Tercio@20
|
3013 if (pvalue > 98) then
|
|
Tercio@20
|
3014 pvalue = 98
|
|
Tercio@20
|
3015 end
|
|
Tercio@20
|
3016 pvalue = pvalue * h
|
|
Tercio@20
|
3017
|
|
Tercio@20
|
3018 g:DrawLine (self, (o-1)*linewidth, lastvalue, o*linewidth, pvalue, linewidth, {1, 1, 1, 1}, "overlay")
|
|
Tercio@20
|
3019 lastvalue = pvalue
|
|
Tercio@20
|
3020
|
|
Tercio@20
|
3021 local line = self:GetLine (i)
|
|
Tercio@20
|
3022 line:Show()
|
|
Tercio@20
|
3023 line.ball:Show()
|
|
Tercio@20
|
3024
|
|
Tercio@20
|
3025 line.ball:SetPoint ("bottomleft", self, "bottomleft", (o*linewidth)-8, pvalue-8)
|
|
Tercio@20
|
3026 line.spellicon:SetTexture (nil)
|
|
Tercio@20
|
3027 line.timeline:SetText (data.text)
|
|
Tercio@20
|
3028 line.timeline:Show()
|
|
Tercio@20
|
3029
|
|
Tercio@20
|
3030 line.data = data
|
|
Tercio@20
|
3031
|
|
Tercio@20
|
3032 o = o + 1
|
|
Tercio@20
|
3033 end
|
|
Tercio@20
|
3034
|
|
Tercio@20
|
3035 end
|
|
Tercio@20
|
3036
|
|
Tercio@20
|
3037 function DF:CreateGFrame (parent, w, h, linewidth, onenter, onleave, member, name)
|
|
Tercio@20
|
3038 local f = CreateFrame ("frame", name, parent)
|
|
Tercio@20
|
3039 f:SetSize (w or 450, h or 150)
|
|
Tercio@20
|
3040 f.CustomLine = [[Interface\AddOns\Details\Libs\LibGraph-2.0\line]]
|
|
Tercio@20
|
3041
|
|
Tercio@20
|
3042 if (member) then
|
|
Tercio@20
|
3043 parent [member] = f
|
|
Tercio@20
|
3044 end
|
|
Tercio@20
|
3045
|
|
Tercio@20
|
3046 f.CreateLine = gframe_create_line
|
|
Tercio@20
|
3047 f.GetLine = gframe_getline
|
|
Tercio@20
|
3048 f.Reset = gframe_reset
|
|
Tercio@20
|
3049 f.UpdateLines = gframe_update
|
|
Tercio@20
|
3050
|
|
Tercio@20
|
3051 f._lines = {}
|
|
Tercio@20
|
3052
|
|
Tercio@20
|
3053 f._onenter_line = onenter
|
|
Tercio@20
|
3054 f._onleave_line = onleave
|
|
Tercio@20
|
3055
|
|
Tercio@20
|
3056 f._linewidth = linewidth or 50
|
|
Tercio@20
|
3057 f._maxlines = floor (f:GetWidth() / f._linewidth)
|
|
Tercio@20
|
3058
|
|
Tercio@20
|
3059 return f
|
|
Tercio@11
|
3060 end |