|
Tercio@11
|
1
|
|
Tercioo@29
|
2 local dversion = 15
|
|
Tercio@25
|
3 local major, minor = "DetailsFramework-1.0", dversion
|
|
Tercio@11
|
4 local DF, oldminor = LibStub:NewLibrary (major, minor)
|
|
Tercio@11
|
5
|
|
Tercio@18
|
6 if (not DF) then
|
|
Tercio@20
|
7 DetailsFrameworkCanLoad = false
|
|
Tercio@11
|
8 return
|
|
Tercio@11
|
9 end
|
|
Tercio@11
|
10
|
|
Tercio@20
|
11 DetailsFrameworkCanLoad = true
|
|
Tercio@25
|
12 local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
|
|
Tercio@18
|
13
|
|
Tercioo@29
|
14 local _
|
|
Tercio@11
|
15 local _type = type
|
|
Tercio@11
|
16 local _unpack = unpack
|
|
Tercio@11
|
17 local upper = string.upper
|
|
Tercio@11
|
18
|
|
Tercioo@29
|
19 --> will always give a very random name for our widgets
|
|
Tercioo@29
|
20 local init_counter = math.random (1, 1000000)
|
|
Tercioo@29
|
21
|
|
Tercioo@29
|
22 DF.LabelNameCounter = DF.LabelNameCounter or init_counter
|
|
Tercioo@29
|
23 DF.PictureNameCounter = DF.PictureNameCounter or init_counter
|
|
Tercioo@29
|
24 DF.BarNameCounter = DF.BarNameCounter or init_counter
|
|
Tercioo@29
|
25 DF.DropDownCounter = DF.DropDownCounter or init_counter
|
|
Tercioo@29
|
26 DF.PanelCounter = DF.PanelCounter or init_counter
|
|
Tercioo@29
|
27 DF.SimplePanelCounter = DF.SimplePanelCounter or init_counter
|
|
Tercioo@29
|
28 DF.ButtonCounter = DF.ButtonCounter or init_counter
|
|
Tercioo@29
|
29 DF.SliderCounter = DF.SliderCounter or init_counter
|
|
Tercioo@29
|
30 DF.SwitchCounter = DF.SwitchCounter or init_counter
|
|
Tercioo@29
|
31 DF.SplitBarCounter = DF.SplitBarCounter or init_counter
|
|
Tercio@11
|
32
|
|
Tercio@25
|
33 DF.FrameWorkVersion = tostring (dversion)
|
|
Tercio@25
|
34 function DF:PrintVersion()
|
|
Tercio@25
|
35 print ("Details! Framework Version:", DF.FrameWorkVersion)
|
|
Tercio@25
|
36 end
|
|
Tercio@25
|
37
|
|
Tercio@22
|
38 LibStub:GetLibrary("AceTimer-3.0"):Embed (DF)
|
|
Tercio@22
|
39
|
|
Tercioo@29
|
40 --> get the working folder
|
|
Tercio@11
|
41 do
|
|
Tercio@11
|
42 local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua")
|
|
Tercio@11
|
43 if (path) then
|
|
Tercio@11
|
44 DF.folder = "Interface\\AddOns\\" .. path
|
|
Tercio@11
|
45 else
|
|
Tercioo@29
|
46 --> if not found, try to use the last valid one
|
|
Tercioo@29
|
47 DF.folder = DF.folder or ""
|
|
Tercio@11
|
48 end
|
|
Tercio@11
|
49 end
|
|
Tercio@11
|
50
|
|
Tercio@11
|
51 DF.debug = false
|
|
Tercio@11
|
52
|
|
Tercio@11
|
53 _G ["DetailsFramework"] = DF
|
|
Tercio@11
|
54
|
|
Tercio@11
|
55 DF.embeds = DF.embeds or {}
|
|
Tercio@11
|
56 local embed_functions = {
|
|
Tercio@20
|
57 "RemoveRealName",
|
|
Tercio@20
|
58 "table",
|
|
Tercio@20
|
59 "BuildDropDownFontList",
|
|
Tercio@11
|
60 "SetFontSize",
|
|
Tercio@11
|
61 "SetFontFace",
|
|
Tercio@11
|
62 "SetFontColor",
|
|
Tercio@11
|
63 "GetFontSize",
|
|
Tercio@11
|
64 "GetFontFace",
|
|
Tercio@17
|
65 "SetFontOutline",
|
|
Tercio@11
|
66 "trim",
|
|
Tercio@11
|
67 "Msg",
|
|
Tercio@11
|
68 "CreateFlashAnimation",
|
|
Tercio@11
|
69 "Fade",
|
|
Tercio@11
|
70 "NewColor",
|
|
Tercio@11
|
71 "IsHtmlColor",
|
|
Tercio@11
|
72 "ParseColors",
|
|
Tercio@11
|
73 "BuildMenu",
|
|
Tercio@11
|
74 "ShowTutorialAlertFrame",
|
|
Tercio@11
|
75 "GetNpcIdFromGuid",
|
|
Tercio@11
|
76 "ShowFeedbackPanel",
|
|
Tercio@20
|
77 "SetAsOptionsPanel",
|
|
Tercio@11
|
78
|
|
Tercio@11
|
79 "CreateDropDown",
|
|
Tercio@11
|
80 "CreateButton",
|
|
Tercio@11
|
81 "CreateColorPickButton",
|
|
Tercio@11
|
82 "CreateLabel",
|
|
Tercio@11
|
83 "CreateBar",
|
|
Tercio@11
|
84 "CreatePanel",
|
|
Tercio@11
|
85 "CreateFillPanel",
|
|
Tercio@11
|
86 "ColorPick",
|
|
Tercio@11
|
87 "IconPick",
|
|
Tercio@11
|
88 "CreateSimplePanel",
|
|
Tercio@11
|
89 "CreateChartPanel",
|
|
Tercio@11
|
90 "CreateImage",
|
|
Tercio@11
|
91 "CreateScrollBar",
|
|
Tercio@11
|
92 "CreateSwitch",
|
|
Tercio@11
|
93 "CreateSlider",
|
|
Tercio@11
|
94 "CreateSplitBar",
|
|
Tercio@11
|
95 "CreateTextEntry",
|
|
Tercio@11
|
96 "Create1PxPanel",
|
|
Tercio@11
|
97 "CreateFeedbackButton",
|
|
Tercio@20
|
98 "CreateOptionsFrame",
|
|
Tercio@22
|
99 "NewSpecialLuaEditorEntry",
|
|
Tercio@20
|
100 "ShowPromptPanel",
|
|
Tercio@22
|
101 "ShowTextPromptPanel",
|
|
Tercio@11
|
102 "www_icons",
|
|
Tercio@22
|
103 "GetTemplate",
|
|
Tercioo@29
|
104 "InstallTemplate",
|
|
Tercio@22
|
105 "GetFrameworkFolder",
|
|
Tercioo@29
|
106 "ShowPanicWarning",
|
|
Tercio@11
|
107 }
|
|
Tercio@11
|
108
|
|
Tercio@20
|
109 DF.table = {}
|
|
Tercio@20
|
110
|
|
Tercio@22
|
111 function DF:GetFrameworkFolder()
|
|
Tercio@22
|
112 return DF.folder
|
|
Tercio@22
|
113 end
|
|
Tercio@22
|
114
|
|
Tercio@26
|
115 function DF:FadeFrame (frame, t)
|
|
Tercio@26
|
116 if (t == 0) then
|
|
Tercio@26
|
117 frame.hidden = false
|
|
Tercio@26
|
118 frame.faded = false
|
|
Tercio@26
|
119 frame.fading_out = false
|
|
Tercio@26
|
120 frame.fading_in = false
|
|
Tercio@26
|
121 frame:Show()
|
|
Tercio@26
|
122 frame:SetAlpha (1)
|
|
Tercio@26
|
123
|
|
Tercio@26
|
124 elseif (t == 1) then
|
|
Tercio@26
|
125 frame.hidden = true
|
|
Tercio@26
|
126 frame.faded = true
|
|
Tercio@26
|
127 frame.fading_out = false
|
|
Tercio@26
|
128 frame.fading_in = false
|
|
Tercio@26
|
129 frame:SetAlpha (0)
|
|
Tercio@26
|
130 frame:Hide()
|
|
Tercio@26
|
131 end
|
|
Tercio@26
|
132 end
|
|
Tercio@26
|
133
|
|
Tercio@20
|
134 function DF.table.reverse (t)
|
|
Tercio@20
|
135 local new = {}
|
|
Tercio@20
|
136 local index = 1
|
|
Tercio@20
|
137 for i = #t, 1, -1 do
|
|
Tercio@20
|
138 new [index] = t[i]
|
|
Tercio@20
|
139 index = index + 1
|
|
Tercio@20
|
140 end
|
|
Tercio@20
|
141 return new
|
|
Tercio@20
|
142 end
|
|
Tercio@20
|
143
|
|
Tercio@20
|
144 --> copy from table2 to table1 overwriting values
|
|
Tercio@20
|
145 function DF.table.copy (t1, t2)
|
|
Tercio@20
|
146 for key, value in pairs (t2) do
|
|
Tercio@20
|
147 if (type (value) == "table") then
|
|
Tercio@20
|
148 t1 [key] = t1 [key] or {}
|
|
Tercio@20
|
149 DF.table.copy (t1 [key], t2 [key])
|
|
Tercio@20
|
150 else
|
|
Tercio@20
|
151 t1 [key] = value
|
|
Tercio@20
|
152 end
|
|
Tercio@20
|
153 end
|
|
Tercio@20
|
154 return t1
|
|
Tercio@20
|
155 end
|
|
Tercio@20
|
156
|
|
Tercio@20
|
157 --> copy values that does exist on table2 but not on table1
|
|
Tercio@20
|
158 function DF.table.deploy (t1, t2)
|
|
Tercio@20
|
159 for key, value in pairs (t2) do
|
|
Tercio@20
|
160 if (type (value) == "table") then
|
|
Tercio@20
|
161 t1 [key] = t1 [key] or {}
|
|
Tercio@20
|
162 DF.table.deploy (t1 [key], t2 [key])
|
|
Tercio@22
|
163 elseif (t1 [key] == nil) then
|
|
Tercio@20
|
164 t1 [key] = value
|
|
Tercio@20
|
165 end
|
|
Tercio@20
|
166 end
|
|
Tercio@20
|
167 end
|
|
Tercio@20
|
168
|
|
Tercio@20
|
169 function DF.table.dump (t, s, deep)
|
|
Tercio@20
|
170 s = s or ""
|
|
Tercio@20
|
171 deep = deep or 0
|
|
Tercio@20
|
172 local space = ""
|
|
Tercio@20
|
173 for i = 1, deep do
|
|
Tercio@20
|
174 space = space .. " "
|
|
Tercio@20
|
175 end
|
|
Tercio@20
|
176 for key, value in pairs (t) do
|
|
Tercio@20
|
177 local tpe = _type (value)
|
|
Tercio@20
|
178 if (type (key) ~= "string") then
|
|
Tercio@20
|
179 key = "unknown?"
|
|
Tercio@20
|
180 end
|
|
Tercio@20
|
181 if (tpe == "table") then
|
|
Tercio@20
|
182 s = s .. space .. "[" .. key .. "] = |cFFa9ffa9table {|r\n"
|
|
Tercio@20
|
183 s = s .. DF.table.dump (value, nil, deep+1)
|
|
Tercio@20
|
184 s = s .. space .. "|cFFa9ffa9}|r\n"
|
|
Tercio@20
|
185 elseif (tpe == "string") then
|
|
Tercio@20
|
186 s = s .. space .. "[" .. key .. "] = '|cFFfff1c1" .. value .. "|r'\n"
|
|
Tercio@20
|
187 elseif (tpe == "number") then
|
|
Tercio@20
|
188 s = s .. space .. "[" .. key .. "] = |cFFffc1f4" .. value .. "|r\n"
|
|
Tercio@20
|
189 elseif (tpe == "function") then
|
|
Tercio@20
|
190 s = s .. space .. "[" .. key .. "] = function()\n"
|
|
Tercio@20
|
191 elseif (tpe == "boolean") then
|
|
Tercio@20
|
192 s = s .. space .. "[" .. key .. "] = |cFF99d0ff" .. (value and "true" or "false") .. "|r\n"
|
|
Tercio@20
|
193 end
|
|
Tercio@20
|
194 end
|
|
Tercio@20
|
195 return s
|
|
Tercio@20
|
196 end
|
|
Tercio@20
|
197
|
|
Tercio@11
|
198 DF.www_icons = {
|
|
Tercio@11
|
199 texture = "feedback_sites",
|
|
Tercio@11
|
200 wowi = {0, 0.7890625, 0, 37/128},
|
|
Tercio@11
|
201 curse = {0, 0.7890625, 38/123, 79/128},
|
|
Tercio@11
|
202 mmoc = {0, 0.7890625, 80/123, 123/128},
|
|
Tercio@11
|
203 }
|
|
Tercio@11
|
204
|
|
Tercio@24
|
205 function DF:IntegerToTimer (value)
|
|
Tercio@24
|
206 return "" .. floor (value/60) .. ":" .. format ("%02.f", value%60)
|
|
Tercio@24
|
207 end
|
|
Tercio@24
|
208
|
|
Tercio@11
|
209 function DF:Embed (target)
|
|
Tercio@11
|
210 for k, v in pairs (embed_functions) do
|
|
Tercio@11
|
211 target[v] = self[v]
|
|
Tercio@11
|
212 end
|
|
Tercio@11
|
213 self.embeds [target] = true
|
|
Tercio@11
|
214 return target
|
|
Tercio@11
|
215 end
|
|
Tercio@11
|
216
|
|
Tercioo@28
|
217 function DF:RemoveRealmName (name)
|
|
Tercioo@28
|
218 return name:gsub (("%-.*"), "")
|
|
Tercioo@28
|
219 end
|
|
Tercioo@28
|
220
|
|
Tercio@20
|
221 function DF:RemoveRealName (name)
|
|
Tercio@20
|
222 return name:gsub (("%-.*"), "")
|
|
Tercio@20
|
223 end
|
|
Tercio@20
|
224
|
|
Tercio@11
|
225 function DF:SetFontSize (fontString, ...)
|
|
Tercio@11
|
226 local fonte, _, flags = fontString:GetFont()
|
|
Tercio@11
|
227 fontString:SetFont (fonte, max (...), flags)
|
|
Tercio@11
|
228 end
|
|
Tercio@11
|
229 function DF:SetFontFace (fontString, fontface)
|
|
Tercio@25
|
230 local font = SharedMedia:Fetch ("font", fontface, true)
|
|
Tercio@25
|
231 if (font) then
|
|
Tercio@25
|
232 fontface = font
|
|
Tercio@25
|
233 end
|
|
Tercio@25
|
234
|
|
Tercio@11
|
235 local _, size, flags = fontString:GetFont()
|
|
Tercio@11
|
236 fontString:SetFont (fontface, size, flags)
|
|
Tercio@11
|
237 end
|
|
Tercio@11
|
238 function DF:SetFontColor (fontString, r, g, b, a)
|
|
Tercio@11
|
239 r, g, b, a = DF:ParseColors (r, g, b, a)
|
|
Tercio@11
|
240 fontString:SetTextColor (r, g, b, a)
|
|
Tercio@11
|
241 end
|
|
Tercio@11
|
242
|
|
Tercio@11
|
243 function DF:GetFontSize (fontString)
|
|
Tercio@11
|
244 local _, size = fontString:GetFont()
|
|
Tercio@11
|
245 return size
|
|
Tercio@11
|
246 end
|
|
Tercio@11
|
247 function DF:GetFontFace (fontString)
|
|
Tercio@11
|
248 local fontface = fontString:GetFont()
|
|
Tercio@11
|
249 return fontface
|
|
Tercio@11
|
250 end
|
|
Tercio@11
|
251
|
|
Tercio@11
|
252 function DF:SetFontOutline (fontString, outline)
|
|
Tercio@11
|
253 local fonte, size = fontString:GetFont()
|
|
Tercio@11
|
254 if (outline) then
|
|
Tercio@11
|
255 if (_type (outline) == "boolean" and outline) then
|
|
Tercio@11
|
256 outline = "OUTLINE"
|
|
Tercio@11
|
257 elseif (outline == 1) then
|
|
Tercio@11
|
258 outline = "OUTLINE"
|
|
Tercio@11
|
259 elseif (outline == 2) then
|
|
Tercio@11
|
260 outline = "THICKOUTLINE"
|
|
Tercio@11
|
261 end
|
|
Tercio@11
|
262 end
|
|
Tercio@11
|
263
|
|
Tercio@11
|
264 fontString:SetFont (fonte, size, outline)
|
|
Tercio@11
|
265 end
|
|
Tercio@11
|
266
|
|
Tercio@11
|
267 function DF:trim (s)
|
|
Tercio@11
|
268 local from = s:match"^%s*()"
|
|
Tercio@11
|
269 return from > #s and "" or s:match(".*%S", from)
|
|
Tercio@11
|
270 end
|
|
Tercio@11
|
271
|
|
Tercio@11
|
272 function DF:Msg (msg)
|
|
Tercio@11
|
273 print ("|cFFFFFFAA" .. self.__name .. "|r " .. msg)
|
|
Tercio@11
|
274 end
|
|
Tercio@11
|
275
|
|
Tercio@11
|
276 function DF:GetNpcIdFromGuid (guid)
|
|
Tercio@11
|
277 local NpcId = select ( 6, strsplit ( "-", guid ) )
|
|
Tercio@11
|
278 if (NpcId) then
|
|
Tercio@11
|
279 return tonumber ( NpcId )
|
|
Tercio@11
|
280 end
|
|
Tercio@11
|
281 return 0
|
|
Tercio@11
|
282 end
|
|
Tercio@11
|
283
|
|
Tercio@11
|
284 local onFinish = function (self)
|
|
Tercio@11
|
285 if (self.showWhenDone) then
|
|
Tercio@11
|
286 self.frame:SetAlpha (1)
|
|
Tercio@11
|
287 else
|
|
Tercio@11
|
288 self.frame:SetAlpha (0)
|
|
Tercio@11
|
289 self.frame:Hide()
|
|
Tercio@11
|
290 end
|
|
Tercio@11
|
291
|
|
Tercio@11
|
292 if (self.onFinishFunc) then
|
|
Tercio@11
|
293 self:onFinishFunc (self.frame)
|
|
Tercio@11
|
294 end
|
|
Tercio@11
|
295 end
|
|
Tercio@11
|
296
|
|
Tercio@11
|
297 local stop = function (self)
|
|
Tercio@11
|
298 local FlashAnimation = self.FlashAnimation
|
|
Tercio@11
|
299 FlashAnimation:Stop()
|
|
Tercio@11
|
300 end
|
|
Tercio@11
|
301
|
|
Tercio@11
|
302 local flash = function (self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType)
|
|
Tercio@11
|
303
|
|
Tercio@11
|
304 local FlashAnimation = self.FlashAnimation
|
|
Tercio@11
|
305
|
|
Tercio@11
|
306 local fadeIn = FlashAnimation.fadeIn
|
|
Tercio@11
|
307 local fadeOut = FlashAnimation.fadeOut
|
|
Tercio@11
|
308
|
|
Tercio@11
|
309 fadeIn:Stop()
|
|
Tercio@11
|
310 fadeOut:Stop()
|
|
Tercio@11
|
311
|
|
Tercio@11
|
312 fadeIn:SetDuration (fadeInTime or 1)
|
|
Tercio@11
|
313 fadeIn:SetEndDelay (flashInHoldTime or 0)
|
|
Tercio@11
|
314
|
|
Tercio@11
|
315 fadeOut:SetDuration (fadeOutTime or 1)
|
|
Tercio@11
|
316 fadeOut:SetEndDelay (flashOutHoldTime or 0)
|
|
Tercio@11
|
317
|
|
Tercio@11
|
318 FlashAnimation.duration = flashDuration
|
|
Tercio@11
|
319 FlashAnimation.loopTime = FlashAnimation:GetDuration()
|
|
Tercio@11
|
320 FlashAnimation.finishAt = GetTime() + flashDuration
|
|
Tercio@11
|
321 FlashAnimation.showWhenDone = showWhenDone
|
|
Tercio@11
|
322
|
|
Tercio@11
|
323 FlashAnimation:SetLooping (loopType or "REPEAT")
|
|
Tercio@11
|
324
|
|
Tercio@11
|
325 self:Show()
|
|
Tercio@11
|
326 self:SetAlpha (0)
|
|
Tercio@11
|
327 FlashAnimation:Play()
|
|
Tercio@11
|
328 end
|
|
Tercio@11
|
329
|
|
Tercio@11
|
330 function DF:CreateFlashAnimation (frame, onFinishFunc, onLoopFunc)
|
|
Tercio@11
|
331 local FlashAnimation = frame:CreateAnimationGroup()
|
|
Tercio@11
|
332
|
|
Tercio@11
|
333 FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime
|
|
Tercio@11
|
334 FlashAnimation.fadeOut:SetOrder (1)
|
|
Tercio@11
|
335 FlashAnimation.fadeOut:SetChange (1)
|
|
Tercio@11
|
336
|
|
Tercio@11
|
337 FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime
|
|
Tercio@11
|
338 FlashAnimation.fadeIn:SetOrder (2)
|
|
Tercio@11
|
339 FlashAnimation.fadeIn:SetChange (-1)
|
|
Tercio@11
|
340
|
|
Tercio@11
|
341 frame.FlashAnimation = FlashAnimation
|
|
Tercio@11
|
342 FlashAnimation.frame = frame
|
|
Tercio@11
|
343 FlashAnimation.onFinishFunc = onFinishFunc
|
|
Tercio@11
|
344
|
|
Tercio@11
|
345 FlashAnimation:SetScript ("OnLoop", onLoopFunc)
|
|
Tercio@11
|
346 FlashAnimation:SetScript ("OnFinished", onFinish)
|
|
Tercio@11
|
347
|
|
Tercio@11
|
348 frame.Flash = flash
|
|
Tercio@11
|
349 frame.Stop = stop
|
|
Tercio@11
|
350 end
|
|
Tercio@11
|
351
|
|
Tercio@11
|
352 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
353 --> points
|
|
Tercio@11
|
354
|
|
Tercio@11
|
355 function DF:CheckPoints (v1, v2, v3, v4, v5, object)
|
|
Tercio@11
|
356
|
|
Tercio@11
|
357 if (not v1 and not v2) then
|
|
Tercio@11
|
358 return "topleft", object.widget:GetParent(), "topleft", 0, 0
|
|
Tercio@11
|
359 end
|
|
Tercio@11
|
360
|
|
Tercio@11
|
361 if (_type (v1) == "string") then
|
|
Tercio@11
|
362 local frameGlobal = _G [v1]
|
|
Tercio@11
|
363 if (frameGlobal and frameGlobal.GetObjectType) then
|
|
Tercio@11
|
364 return DF:CheckPoints (frameGlobal, v2, v3, v4, v5, object)
|
|
Tercio@11
|
365 end
|
|
Tercio@11
|
366
|
|
Tercio@11
|
367 elseif (_type (v2) == "string") then
|
|
Tercio@11
|
368 local frameGlobal = _G [v2]
|
|
Tercio@11
|
369 if (frameGlobal and frameGlobal.GetObjectType) then
|
|
Tercio@11
|
370 return DF:CheckPoints (v1, frameGlobal, v3, v4, v5, object)
|
|
Tercio@11
|
371 end
|
|
Tercio@11
|
372 end
|
|
Tercio@11
|
373
|
|
Tercio@11
|
374 if (_type (v1) == "string" and _type (v2) == "table") then --> :setpoint ("left", frame, _, _, _)
|
|
Tercio@11
|
375 if (not v3 or _type (v3) == "number") then --> :setpoint ("left", frame, 10, 10)
|
|
Tercio@11
|
376 v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4
|
|
Tercio@11
|
377 end
|
|
Tercio@11
|
378
|
|
Tercio@11
|
379 elseif (_type (v1) == "string" and _type (v2) == "number") then --> :setpoint ("topleft", x, y)
|
|
Tercio@11
|
380 v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3
|
|
Tercio@11
|
381
|
|
Tercio@11
|
382 elseif (_type (v1) == "number") then --> :setpoint (x, y)
|
|
Tercio@11
|
383 v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2
|
|
Tercio@11
|
384
|
|
Tercio@11
|
385 elseif (_type (v1) == "table") then --> :setpoint (frame, x, y)
|
|
Tercio@11
|
386 v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3
|
|
Tercio@11
|
387
|
|
Tercio@11
|
388 end
|
|
Tercio@11
|
389
|
|
Tercio@11
|
390 if (not v2) then
|
|
Tercio@11
|
391 v2 = object.widget:GetParent()
|
|
Tercio@11
|
392 elseif (v2.dframework) then
|
|
Tercio@11
|
393 v2 = v2.widget
|
|
Tercio@11
|
394 end
|
|
Tercio@11
|
395
|
|
Tercio@11
|
396 return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0
|
|
Tercio@11
|
397 end
|
|
Tercio@11
|
398
|
|
Tercio@11
|
399
|
|
Tercio@11
|
400 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
401 --> colors
|
|
Tercio@11
|
402
|
|
Tercio@11
|
403 function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha)
|
|
Tercio@11
|
404 assert (_type (_colorname) == "string", "NewColor: colorname must be a string.")
|
|
Tercio@11
|
405 assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.")
|
|
Tercio@11
|
406
|
|
Tercio@11
|
407 if (_type (_colortable) == "table") then
|
|
Tercio@11
|
408 if (_colortable[1] and _colortable[2] and _colortable[3]) then
|
|
Tercio@11
|
409 _colortable[4] = _colortable[4] or 1
|
|
Tercio@11
|
410 DF.alias_text_colors [_colorname] = _colortable
|
|
Tercio@11
|
411 else
|
|
Tercio@11
|
412 error ("invalid color table.")
|
|
Tercio@11
|
413 end
|
|
Tercio@11
|
414 elseif (_colortable and _green and _blue) then
|
|
Tercio@11
|
415 _alpha = _alpha or 1
|
|
Tercio@11
|
416 DF.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha}
|
|
Tercio@11
|
417 else
|
|
Tercio@11
|
418 error ("invalid parameter.")
|
|
Tercio@11
|
419 end
|
|
Tercio@11
|
420
|
|
Tercio@11
|
421 return true
|
|
Tercio@11
|
422 end
|
|
Tercio@11
|
423
|
|
Tercio@11
|
424 function DF:IsHtmlColor (color)
|
|
Tercio@11
|
425 return DF.alias_text_colors [color]
|
|
Tercio@11
|
426 end
|
|
Tercio@11
|
427
|
|
Tercio@11
|
428 local tn = tonumber
|
|
Tercio@11
|
429 function DF:ParseColors (_arg1, _arg2, _arg3, _arg4)
|
|
Tercio@11
|
430 if (_type (_arg1) == "table") then
|
|
Tercio@25
|
431 if (not _arg1[1] and _arg1.r) then
|
|
Tercio@25
|
432 _arg1, _arg2, _arg3, _arg4 = _arg1.r, _arg1.g, _arg1.b, _arg1.a
|
|
Tercio@25
|
433 else
|
|
Tercio@25
|
434 _arg1, _arg2, _arg3, _arg4 = _unpack (_arg1)
|
|
Tercio@25
|
435 end
|
|
Tercio@11
|
436
|
|
Tercio@11
|
437 elseif (_type (_arg1) == "string") then
|
|
Tercio@11
|
438
|
|
Tercio@11
|
439 if (string.find (_arg1, "#")) then
|
|
Tercio@11
|
440 _arg1 = _arg1:gsub ("#","")
|
|
Tercio@11
|
441 if (string.len (_arg1) == 8) then --alpha
|
|
Tercio@11
|
442 _arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, tn ("0x" .. _arg1:sub (7, 8))/255, tn ("0x" .. _arg1:sub (1, 2))/255
|
|
Tercio@11
|
443 else
|
|
Tercio@11
|
444 _arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (1, 2))/255, tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, 1
|
|
Tercio@11
|
445 end
|
|
Tercio@11
|
446
|
|
Tercio@11
|
447 else
|
|
Tercio@11
|
448 local color = DF.alias_text_colors [_arg1]
|
|
Tercio@11
|
449 if (color) then
|
|
Tercio@11
|
450 _arg1, _arg2, _arg3, _arg4 = _unpack (color)
|
|
Tercio@11
|
451 else
|
|
Tercio@11
|
452 _arg1, _arg2, _arg3, _arg4 = _unpack (DF.alias_text_colors.none)
|
|
Tercio@11
|
453 end
|
|
Tercio@11
|
454 end
|
|
Tercio@11
|
455 end
|
|
Tercio@11
|
456
|
|
Tercio@11
|
457 if (not _arg1) then
|
|
Tercio@11
|
458 _arg1 = 1
|
|
Tercio@11
|
459 end
|
|
Tercio@11
|
460 if (not _arg2) then
|
|
Tercio@11
|
461 _arg2 = 1
|
|
Tercio@11
|
462 end
|
|
Tercio@11
|
463 if (not _arg3) then
|
|
Tercio@11
|
464 _arg3 = 1
|
|
Tercio@11
|
465 end
|
|
Tercio@11
|
466 if (not _arg4) then
|
|
Tercio@11
|
467 _arg4 = 1
|
|
Tercio@11
|
468 end
|
|
Tercio@11
|
469
|
|
Tercio@11
|
470 return _arg1, _arg2, _arg3, _arg4
|
|
Tercio@11
|
471 end
|
|
Tercio@11
|
472
|
|
Tercio@11
|
473 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
474 --> menus
|
|
Tercio@11
|
475
|
|
Tercio@22
|
476 function DF:BuildMenu (parent, menu, x_offset, y_offset, height, use_two_points, text_template, dropdown_template, switch_template, switch_is_box, slider_template, button_template)
|
|
Tercio@22
|
477
|
|
Tercio@22
|
478 if (not parent.widget_list) then
|
|
Tercio@22
|
479 DF:SetAsOptionsPanel (parent)
|
|
Tercio@22
|
480 end
|
|
Tercio@11
|
481
|
|
Tercio@11
|
482 local cur_x = x_offset
|
|
Tercio@11
|
483 local cur_y = y_offset
|
|
Tercio@11
|
484 local max_x = 0
|
|
Tercio@11
|
485
|
|
Tercio@11
|
486 height = abs ((height or parent:GetHeight()) - abs (y_offset) + 20)
|
|
Tercio@11
|
487 height = height*-1
|
|
Tercio@11
|
488
|
|
Tercio@11
|
489 for index, widget_table in ipairs (menu) do
|
|
Tercio@11
|
490
|
|
Tercio@20
|
491 if (widget_table.type == "blank" or widget_table.type == "space") then
|
|
Tercio@20
|
492 -- do nothing
|
|
Tercio@20
|
493
|
|
Tercio@20
|
494 elseif (widget_table.type == "label" or widget_table.type == "text") then
|
|
Tercio@22
|
495 local label = DF:CreateLabel (parent, widget_table.get() or widget_table.text, widget_table.text_template or text_template or widget_table.size, widget_table.color, widget_table.font, nil, "$parentWidget" .. index, "overlay")
|
|
Tercio@20
|
496 label._get = widget_table.get
|
|
Tercio@20
|
497 label.widget_type = "label"
|
|
Tercio@20
|
498 label:SetPoint (cur_x, cur_y)
|
|
Tercio@20
|
499 tinsert (parent.widget_list, label)
|
|
Tercio@20
|
500
|
|
Tercio@20
|
501 elseif (widget_table.type == "select" or widget_table.type == "dropdown") then
|
|
Tercio@22
|
502 local dropdown = DF:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get(), dropdown_template)
|
|
Tercio@11
|
503 dropdown.tooltip = widget_table.desc
|
|
Tercio@20
|
504 dropdown._get = widget_table.get
|
|
Tercio@20
|
505 dropdown.widget_type = "select"
|
|
Tercio@22
|
506 local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
|
|
Tercio@11
|
507 dropdown:SetPoint ("left", label, "right", 2)
|
|
Tercio@11
|
508 label:SetPoint (cur_x, cur_y)
|
|
Tercio@11
|
509
|
|
Tercio@11
|
510 local size = label.widget:GetStringWidth() + 140 + 4
|
|
Tercio@11
|
511 if (size > max_x) then
|
|
Tercio@11
|
512 max_x = size
|
|
Tercio@11
|
513 end
|
|
Tercio@11
|
514
|
|
Tercio@20
|
515 tinsert (parent.widget_list, dropdown)
|
|
Tercio@20
|
516
|
|
Tercio@11
|
517 elseif (widget_table.type == "toggle" or widget_table.type == "switch") then
|
|
Tercio@22
|
518 local switch = DF:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get(), nil, nil, nil, nil, switch_template)
|
|
Tercio@11
|
519 switch.tooltip = widget_table.desc
|
|
Tercio@20
|
520 switch._get = widget_table.get
|
|
Tercio@20
|
521 switch.widget_type = "toggle"
|
|
Tercio@11
|
522 switch.OnSwitch = widget_table.set
|
|
Tercio@11
|
523
|
|
Tercio@22
|
524 if (switch_is_box) then
|
|
Tercio@22
|
525 switch:SetAsCheckBox()
|
|
Tercio@22
|
526 end
|
|
Tercio@22
|
527
|
|
Tercio@22
|
528 local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
|
|
Tercio@11
|
529 switch:SetPoint ("left", label, "right", 2)
|
|
Tercio@11
|
530 label:SetPoint (cur_x, cur_y)
|
|
Tercio@11
|
531
|
|
Tercio@11
|
532 local size = label.widget:GetStringWidth() + 60 + 4
|
|
Tercio@11
|
533 if (size > max_x) then
|
|
Tercio@11
|
534 max_x = size
|
|
Tercio@11
|
535 end
|
|
Tercio@11
|
536
|
|
Tercio@20
|
537 tinsert (parent.widget_list, switch)
|
|
Tercio@20
|
538
|
|
Tercio@11
|
539 elseif (widget_table.type == "range" or widget_table.type == "slider") then
|
|
Tercio@11
|
540 local is_decimanls = widget_table.usedecimals
|
|
Tercio@22
|
541 local slider = DF:NewSlider (parent, nil, "$parentWidget" .. index, nil, 140, 20, widget_table.min, widget_table.max, widget_table.step, widget_table.get(), is_decimanls, nil, nil, slider_template)
|
|
Tercio@11
|
542 slider.tooltip = widget_table.desc
|
|
Tercio@20
|
543 slider._get = widget_table.get
|
|
Tercio@20
|
544 slider.widget_type = "range"
|
|
Tercio@11
|
545 slider:SetHook ("OnValueChange", widget_table.set)
|
|
Tercio@11
|
546
|
|
Tercio@22
|
547 local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
|
|
Tercio@11
|
548 slider:SetPoint ("left", label, "right", 2)
|
|
Tercio@11
|
549 label:SetPoint (cur_x, cur_y)
|
|
Tercio@11
|
550
|
|
Tercio@11
|
551 local size = label.widget:GetStringWidth() + 140 + 6
|
|
Tercio@11
|
552 if (size > max_x) then
|
|
Tercio@11
|
553 max_x = size
|
|
Tercio@11
|
554 end
|
|
Tercio@11
|
555
|
|
Tercio@20
|
556 tinsert (parent.widget_list, slider)
|
|
Tercio@20
|
557
|
|
Tercio@11
|
558 elseif (widget_table.type == "color" or widget_table.type == "color") then
|
|
Tercio@22
|
559 local colorpick = DF:NewColorPickButton (parent, "$parentWidget" .. index, nil, widget_table.set, nil, button_template)
|
|
Tercio@11
|
560 colorpick.tooltip = widget_table.desc
|
|
Tercio@20
|
561 colorpick._get = widget_table.get
|
|
Tercio@20
|
562 colorpick.widget_type = "color"
|
|
Tercio@11
|
563
|
|
Tercio@11
|
564 local default_value, g, b, a = widget_table.get()
|
|
Tercio@11
|
565 if (type (default_value) == "table") then
|
|
Tercio@11
|
566 colorpick:SetColor (unpack (default_value))
|
|
Tercio@11
|
567 else
|
|
Tercio@11
|
568 colorpick:SetColor (default_value, g, b, a)
|
|
Tercio@11
|
569 end
|
|
Tercio@11
|
570
|
|
Tercio@22
|
571 local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
|
|
Tercio@11
|
572 colorpick:SetPoint ("left", label, "right", 2)
|
|
Tercio@11
|
573 label:SetPoint (cur_x, cur_y)
|
|
Tercio@11
|
574
|
|
Tercio@11
|
575 local size = label.widget:GetStringWidth() + 60 + 4
|
|
Tercio@11
|
576 if (size > max_x) then
|
|
Tercio@11
|
577 max_x = size
|
|
Tercio@11
|
578 end
|
|
Tercio@11
|
579
|
|
Tercio@20
|
580 tinsert (parent.widget_list, colorpick)
|
|
Tercio@20
|
581
|
|
Tercio@11
|
582 elseif (widget_table.type == "execute" or widget_table.type == "button") then
|
|
Tercio@11
|
583
|
|
Tercio@22
|
584 local button = DF:NewButton (parent, nil, "$parentWidget" .. index, nil, 120, 18, widget_table.func, widget_table.param1, widget_table.param2, nil, widget_table.name, nil, button_template)
|
|
Tercio@22
|
585 if (not button_template) then
|
|
Tercio@22
|
586 button:InstallCustomTexture()
|
|
Tercio@22
|
587 end
|
|
Tercio@22
|
588
|
|
Tercio@11
|
589 button:SetPoint (cur_x, cur_y)
|
|
Tercio@11
|
590 button.tooltip = widget_table.desc
|
|
Tercio@20
|
591 button.widget_type = "execute"
|
|
Tercio@11
|
592
|
|
Tercio@11
|
593 local size = button:GetWidth() + 4
|
|
Tercio@11
|
594 if (size > max_x) then
|
|
Tercio@11
|
595 max_x = size
|
|
Tercio@11
|
596 end
|
|
Tercio@11
|
597
|
|
Tercio@20
|
598 tinsert (parent.widget_list, button)
|
|
Tercio@20
|
599
|
|
Tercio@11
|
600 end
|
|
Tercio@11
|
601
|
|
Tercio@11
|
602 if (widget_table.spacement) then
|
|
Tercio@11
|
603 cur_y = cur_y - 30
|
|
Tercio@11
|
604 else
|
|
Tercio@11
|
605 cur_y = cur_y - 20
|
|
Tercio@11
|
606 end
|
|
Tercio@11
|
607
|
|
Tercio@11
|
608 if (cur_y < height) then
|
|
Tercio@11
|
609 cur_y = y_offset
|
|
Tercio@11
|
610 cur_x = cur_x + max_x + 30
|
|
Tercio@11
|
611
|
|
Tercio@11
|
612 max_x = 0
|
|
Tercio@11
|
613 end
|
|
Tercio@11
|
614
|
|
Tercio@11
|
615 end
|
|
Tercio@11
|
616
|
|
Tercio@11
|
617 end
|
|
Tercio@11
|
618
|
|
Tercio@11
|
619 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
620 --> tutorials
|
|
Tercio@11
|
621
|
|
Tercio@11
|
622 function DF:ShowTutorialAlertFrame (maintext, desctext, clickfunc)
|
|
Tercio@11
|
623
|
|
Tercio@11
|
624 local TutorialAlertFrame = _G.DetailsFrameworkTutorialAlertFrame
|
|
Tercio@11
|
625
|
|
Tercio@11
|
626 if (not TutorialAlertFrame) then
|
|
Tercio@11
|
627
|
|
Tercio@11
|
628 TutorialAlertFrame = CreateFrame ("ScrollFrame", "DetailsFrameworkTutorialAlertFrame", UIParent, "DetailsFrameworkTutorialAlertFrameTemplate")
|
|
Tercio@11
|
629 TutorialAlertFrame.isFirst = true
|
|
Tercio@11
|
630 TutorialAlertFrame:SetPoint ("left", UIParent, "left", -20, 100)
|
|
Tercio@11
|
631
|
|
Tercio@11
|
632 TutorialAlertFrame:SetWidth (290)
|
|
Tercio@11
|
633 TutorialAlertFrame.ScrollChild:SetWidth (256)
|
|
Tercio@11
|
634
|
|
Tercio@11
|
635 local scrollname = TutorialAlertFrame.ScrollChild:GetName()
|
|
Tercio@11
|
636 _G [scrollname .. "BorderTopLeft"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
637 _G [scrollname .. "BorderTopRight"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
638 _G [scrollname .. "BorderBotLeft"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
639 _G [scrollname .. "BorderBotRight"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
640 _G [scrollname .. "BorderLeft"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
641 _G [scrollname .. "BorderRight"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
642 _G [scrollname .. "BorderBottom"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
643 _G [scrollname .. "BorderTop"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
644
|
|
Tercio@11
|
645 local iconbg = _G [scrollname .. "QuestIconBg"]
|
|
Tercio@11
|
646 iconbg:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
|
|
Tercio@11
|
647 iconbg:SetTexCoord (0, 1, 0, 1)
|
|
Tercio@11
|
648 iconbg:SetSize (100, 100)
|
|
Tercio@11
|
649 iconbg:ClearAllPoints()
|
|
Tercio@11
|
650 iconbg:SetPoint ("bottomleft", TutorialAlertFrame.ScrollChild, "bottomleft")
|
|
Tercio@11
|
651
|
|
Tercio@11
|
652 _G [scrollname .. "Exclamation"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
653 _G [scrollname .. "QuestionMark"]:SetVertexColor (1, 0.8, 0, 1)
|
|
Tercio@11
|
654
|
|
Tercio@11
|
655 _G [scrollname .. "TopText"]:SetText ("Details!") --string
|
|
Tercio@11
|
656 _G [scrollname .. "QuestName"]:SetText ("") --string
|
|
Tercio@11
|
657 _G [scrollname .. "BottomText"]:SetText ("") --string
|
|
Tercio@11
|
658
|
|
Tercio@11
|
659 TutorialAlertFrame.ScrollChild.IconShine:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
|
|
Tercio@11
|
660
|
|
Tercio@11
|
661 TutorialAlertFrame:SetScript ("OnMouseUp", function (self)
|
|
Tercio@11
|
662 if (self.clickfunc and type (self.clickfunc) == "function") then
|
|
Tercio@11
|
663 self.clickfunc()
|
|
Tercio@11
|
664 end
|
|
Tercio@11
|
665 self:Hide()
|
|
Tercio@11
|
666 end)
|
|
Tercio@11
|
667 TutorialAlertFrame:Hide()
|
|
Tercio@11
|
668 end
|
|
Tercio@11
|
669
|
|
Tercio@11
|
670 if (type (maintext) == "string") then
|
|
Tercio@11
|
671 TutorialAlertFrame.ScrollChild.QuestName:SetText (maintext)
|
|
Tercio@11
|
672 else
|
|
Tercio@11
|
673 TutorialAlertFrame.ScrollChild.QuestName:SetText ("")
|
|
Tercio@11
|
674 end
|
|
Tercio@11
|
675
|
|
Tercio@11
|
676 if (type (desctext) == "string") then
|
|
Tercio@11
|
677 TutorialAlertFrame.ScrollChild.BottomText:SetText (desctext)
|
|
Tercio@11
|
678 else
|
|
Tercio@11
|
679 TutorialAlertFrame.ScrollChild.BottomText:SetText ("")
|
|
Tercio@11
|
680 end
|
|
Tercio@11
|
681
|
|
Tercio@11
|
682 TutorialAlertFrame.clickfunc = clickfunc
|
|
Tercio@11
|
683 TutorialAlertFrame:Show()
|
|
Tercio@11
|
684 DetailsTutorialAlertFrame_SlideInFrame (TutorialAlertFrame, "AUTOQUEST")
|
|
Tercio@11
|
685 end
|
|
Tercio@11
|
686
|
|
Tercio@20
|
687 local refresh_options = function (self)
|
|
Tercio@20
|
688 for _, widget in ipairs (self.widget_list) do
|
|
Tercio@20
|
689 if (widget._get) then
|
|
Tercio@20
|
690 if (widget.widget_type == "label") then
|
|
Tercio@20
|
691 if (widget._get()) then
|
|
Tercio@20
|
692 widget:SetText (widget._get())
|
|
Tercio@20
|
693 end
|
|
Tercio@20
|
694 elseif (widget.widget_type == "select") then
|
|
Tercio@20
|
695 widget:Select (widget._get())
|
|
Tercio@20
|
696 elseif (widget.widget_type == "toggle" or widget.widget_type == "range") then
|
|
Tercio@20
|
697 widget:SetValue (widget._get())
|
|
Tercio@20
|
698 elseif (widget.widget_type == "color") then
|
|
Tercio@20
|
699 local default_value, g, b, a = widget._get()
|
|
Tercio@20
|
700 if (type (default_value) == "table") then
|
|
Tercio@20
|
701 widget:SetColor (unpack (default_value))
|
|
Tercio@20
|
702 else
|
|
Tercio@20
|
703 widget:SetColor (default_value, g, b, a)
|
|
Tercio@20
|
704 end
|
|
Tercio@20
|
705 end
|
|
Tercio@20
|
706 end
|
|
Tercio@20
|
707 end
|
|
Tercio@20
|
708 end
|
|
Tercio@20
|
709
|
|
Tercio@20
|
710 function DF:SetAsOptionsPanel (frame)
|
|
Tercio@20
|
711 frame.RefreshOptions = refresh_options
|
|
Tercio@20
|
712 frame.widget_list = {}
|
|
Tercio@20
|
713 end
|
|
Tercio@20
|
714
|
|
Tercio@11
|
715 function DF:CreateOptionsFrame (name, title, template)
|
|
Tercio@11
|
716
|
|
Tercio@11
|
717 template = template or 1
|
|
Tercio@11
|
718
|
|
Tercio@11
|
719 if (template == 2) then
|
|
Tercio@11
|
720 local options_frame = CreateFrame ("frame", name, UIParent, "ButtonFrameTemplate")
|
|
Tercio@11
|
721 tinsert (UISpecialFrames, name)
|
|
Tercio@11
|
722 options_frame:SetSize (500, 200)
|
|
Tercio@20
|
723 options_frame.RefreshOptions = refresh_options
|
|
Tercio@20
|
724 options_frame.widget_list = {}
|
|
Tercio@11
|
725
|
|
Tercio@11
|
726 options_frame:SetScript ("OnMouseDown", function(self, button)
|
|
Tercio@11
|
727 if (button == "RightButton") then
|
|
Tercio@11
|
728 if (self.moving) then
|
|
Tercio@11
|
729 self.moving = false
|
|
Tercio@11
|
730 self:StopMovingOrSizing()
|
|
Tercio@11
|
731 end
|
|
Tercio@11
|
732 return options_frame:Hide()
|
|
Tercio@11
|
733 elseif (button == "LeftButton" and not self.moving) then
|
|
Tercio@11
|
734 self.moving = true
|
|
Tercio@11
|
735 self:StartMoving()
|
|
Tercio@11
|
736 end
|
|
Tercio@11
|
737 end)
|
|
Tercio@11
|
738 options_frame:SetScript ("OnMouseUp", function(self)
|
|
Tercio@11
|
739 if (self.moving) then
|
|
Tercio@11
|
740 self.moving = false
|
|
Tercio@11
|
741 self:StopMovingOrSizing()
|
|
Tercio@11
|
742 end
|
|
Tercio@11
|
743 end)
|
|
Tercio@11
|
744
|
|
Tercio@11
|
745 options_frame:SetMovable (true)
|
|
Tercio@11
|
746 options_frame:EnableMouse (true)
|
|
Tercio@11
|
747 options_frame:SetFrameStrata ("DIALOG")
|
|
Tercio@11
|
748 options_frame:SetToplevel (true)
|
|
Tercio@11
|
749
|
|
Tercio@11
|
750 options_frame:Hide()
|
|
Tercio@11
|
751
|
|
Tercio@11
|
752 options_frame:SetPoint ("center", UIParent, "center")
|
|
Tercio@11
|
753 options_frame.TitleText:SetText (title)
|
|
Tercio@11
|
754 options_frame.portrait:SetTexture ([[Interface\CHARACTERFRAME\TEMPORARYPORTRAIT-FEMALE-BLOODELF]])
|
|
Tercio@11
|
755
|
|
Tercio@11
|
756 return options_frame
|
|
Tercio@11
|
757
|
|
Tercio@11
|
758 elseif (template == 1) then
|
|
Tercio@11
|
759
|
|
Tercio@11
|
760 local options_frame = CreateFrame ("frame", name, UIParent)
|
|
Tercio@11
|
761 tinsert (UISpecialFrames, name)
|
|
Tercio@11
|
762 options_frame:SetSize (500, 200)
|
|
Tercio@20
|
763 options_frame.RefreshOptions = refresh_options
|
|
Tercio@20
|
764 options_frame.widget_list = {}
|
|
Tercio@11
|
765
|
|
Tercio@11
|
766 options_frame:SetScript ("OnMouseDown", function(self, button)
|
|
Tercio@11
|
767 if (button == "RightButton") then
|
|
Tercio@11
|
768 if (self.moving) then
|
|
Tercio@11
|
769 self.moving = false
|
|
Tercio@11
|
770 self:StopMovingOrSizing()
|
|
Tercio@11
|
771 end
|
|
Tercio@11
|
772 return options_frame:Hide()
|
|
Tercio@11
|
773 elseif (button == "LeftButton" and not self.moving) then
|
|
Tercio@11
|
774 self.moving = true
|
|
Tercio@11
|
775 self:StartMoving()
|
|
Tercio@11
|
776 end
|
|
Tercio@11
|
777 end)
|
|
Tercio@11
|
778 options_frame:SetScript ("OnMouseUp", function(self)
|
|
Tercio@11
|
779 if (self.moving) then
|
|
Tercio@11
|
780 self.moving = false
|
|
Tercio@11
|
781 self:StopMovingOrSizing()
|
|
Tercio@11
|
782 end
|
|
Tercio@11
|
783 end)
|
|
Tercio@11
|
784
|
|
Tercio@11
|
785 options_frame:SetMovable (true)
|
|
Tercio@11
|
786 options_frame:EnableMouse (true)
|
|
Tercio@11
|
787 options_frame:SetFrameStrata ("DIALOG")
|
|
Tercio@11
|
788 options_frame:SetToplevel (true)
|
|
Tercio@11
|
789
|
|
Tercio@11
|
790 options_frame:Hide()
|
|
Tercio@11
|
791
|
|
Tercio@11
|
792 options_frame:SetPoint ("center", UIParent, "center")
|
|
Tercio@11
|
793
|
|
Tercio@11
|
794 options_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
|
|
Tercio@18
|
795 edgeFile = DF.folder .. "border_2", edgeSize = 32,
|
|
Tercio@11
|
796 insets = {left = 1, right = 1, top = 1, bottom = 1}})
|
|
Tercio@11
|
797 options_frame:SetBackdropColor (0, 0, 0, .7)
|
|
Tercio@11
|
798
|
|
Tercio@11
|
799 local texturetitle = options_frame:CreateTexture (nil, "artwork")
|
|
Tercio@11
|
800 texturetitle:SetTexture ([[Interface\CURSOR\Interact]])
|
|
Tercio@11
|
801 texturetitle:SetTexCoord (0, 1, 0, 1)
|
|
Tercio@11
|
802 texturetitle:SetVertexColor (1, 1, 1, 1)
|
|
Tercio@11
|
803 texturetitle:SetPoint ("topleft", options_frame, "topleft", 2, -3)
|
|
Tercio@11
|
804 texturetitle:SetWidth (36)
|
|
Tercio@11
|
805 texturetitle:SetHeight (36)
|
|
Tercio@11
|
806
|
|
Tercio@11
|
807 local title = DF:NewLabel (options_frame, nil, "$parentTitle", nil, title, nil, 20, "yellow")
|
|
Tercio@11
|
808 title:SetPoint ("left", texturetitle, "right", 2, -1)
|
|
Tercio@11
|
809 DF:SetFontOutline (title, true)
|
|
Tercio@11
|
810
|
|
Tercio@11
|
811 local c = CreateFrame ("Button", nil, options_frame, "UIPanelCloseButton")
|
|
Tercio@11
|
812 c:SetWidth (32)
|
|
Tercio@11
|
813 c:SetHeight (32)
|
|
Tercio@11
|
814 c:SetPoint ("TOPRIGHT", options_frame, "TOPRIGHT", -3, -3)
|
|
Tercio@11
|
815 c:SetFrameLevel (options_frame:GetFrameLevel()+1)
|
|
Tercio@11
|
816
|
|
Tercio@11
|
817 return options_frame
|
|
Tercio@11
|
818 end
|
|
Tercio@22
|
819 end
|
|
Tercio@22
|
820
|
|
Tercio@22
|
821 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@22
|
822 --> templates
|
|
Tercio@22
|
823
|
|
Tercio@22
|
824 DF.font_templates = {}
|
|
Tercio@22
|
825 DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 11, font = "Accidental Presidency"}
|
|
Tercio@22
|
826 DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 12, font = "Accidental Presidency"}
|
|
Tercio@22
|
827
|
|
Tercio@22
|
828 DF.dropdown_templates = {}
|
|
Tercio@22
|
829 DF.dropdown_templates ["OPTIONS_DROPDOWN_TEMPLATE"] = {
|
|
Tercio@22
|
830 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
|
|
Tercio@22
|
831 backdropcolor = {1, 1, 1, .5},
|
|
Tercio@22
|
832 backdropbordercolor = {0, 0, 0, 1},
|
|
Tercio@22
|
833 onentercolor = {1, 1, 1, .5},
|
|
Tercio@22
|
834 onenterbordercolor = {1, 1, 1, 1},
|
|
Tercio@22
|
835 }
|
|
Tercio@22
|
836
|
|
Tercio@22
|
837 DF.switch_templates = {}
|
|
Tercio@22
|
838 DF.switch_templates ["OPTIONS_CHECKBOX_TEMPLATE"] = {
|
|
Tercio@22
|
839 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
|
|
Tercio@22
|
840 backdropcolor = {1, 1, 1, .5},
|
|
Tercio@22
|
841 backdropbordercolor = {0, 0, 0, 1},
|
|
Tercio@22
|
842 width = 18,
|
|
Tercio@22
|
843 height = 18,
|
|
Tercio@22
|
844 enabled_backdropcolor = {1, 1, 1, .5},
|
|
Tercio@22
|
845 disabled_backdropcolor = {1, 1, 1, .2},
|
|
Tercio@22
|
846 onenterbordercolor = {1, 1, 1, 1},
|
|
Tercio@22
|
847 }
|
|
Tercio@22
|
848 DF.switch_templates ["OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"] = {
|
|
Tercio@22
|
849 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
|
|
Tercio@22
|
850 backdropcolor = {1, 1, 1, .5},
|
|
Tercio@22
|
851 backdropbordercolor = {0, 0, 0, 1},
|
|
Tercio@22
|
852 width = 18,
|
|
Tercio@22
|
853 height = 18,
|
|
Tercio@22
|
854 enabled_backdropcolor = {1, 1, 1, .5},
|
|
Tercio@22
|
855 disabled_backdropcolor = {1, 1, 1, .5},
|
|
Tercio@22
|
856 onenterbordercolor = {1, 1, 1, 1},
|
|
Tercio@22
|
857 }
|
|
Tercio@22
|
858
|
|
Tercio@22
|
859 DF.button_templates = {}
|
|
Tercio@22
|
860 DF.button_templates ["OPTIONS_BUTTON_TEMPLATE"] = {
|
|
Tercio@22
|
861 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
|
|
Tercio@22
|
862 backdropcolor = {1, 1, 1, .5},
|
|
Tercio@22
|
863 backdropbordercolor = {0, 0, 0, 1},
|
|
Tercio@22
|
864 }
|
|
Tercio@22
|
865
|
|
Tercio@22
|
866 DF.slider_templates = {}
|
|
Tercio@22
|
867 DF.slider_templates ["OPTIONS_SLIDER_TEMPLATE"] = {
|
|
Tercio@22
|
868 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
|
|
Tercio@22
|
869 backdropcolor = {1, 1, 1, .5},
|
|
Tercio@22
|
870 backdropbordercolor = {0, 0, 0, 1},
|
|
Tercio@22
|
871 onentercolor = {1, 1, 1, .5},
|
|
Tercio@22
|
872 onenterbordercolor = {1, 1, 1, 1},
|
|
Tercio@22
|
873 thumbtexture = [[Interface\Tooltips\UI-Tooltip-Background]],
|
|
Tercio@22
|
874 thumbwidth = 16,
|
|
Tercio@22
|
875 thumbheight = 14,
|
|
Tercio@22
|
876 thumbcolor = {0, 0, 0, 0.5},
|
|
Tercio@22
|
877 }
|
|
Tercio@22
|
878
|
|
Tercioo@29
|
879 function DF:InstallTemplate (widget_type, template_name, template)
|
|
Tercioo@29
|
880 widget_type = string.lower (widget_type)
|
|
Tercioo@29
|
881
|
|
Tercio@22
|
882 local template_table
|
|
Tercioo@29
|
883 if (widget_type == "font") then
|
|
Tercio@22
|
884 template_table = DF.font_templates
|
|
Tercioo@29
|
885 elseif (widget_type == "dropdown") then
|
|
Tercio@22
|
886 template_table = DF.dropdown_templates
|
|
Tercioo@29
|
887 elseif (widget_type == "button") then
|
|
Tercio@22
|
888 template_table = DF.button_templates
|
|
Tercioo@29
|
889 elseif (widget_type == "switch") then
|
|
Tercio@22
|
890 template_table = DF.switch_templates
|
|
Tercioo@29
|
891 elseif (widget_type == "slider") then
|
|
Tercioo@29
|
892 template_table = DF.slider_templates
|
|
Tercioo@29
|
893 end
|
|
Tercioo@29
|
894
|
|
Tercioo@29
|
895 template_table [template_name] = template
|
|
Tercioo@29
|
896
|
|
Tercioo@29
|
897 return template
|
|
Tercioo@29
|
898 end
|
|
Tercioo@29
|
899
|
|
Tercioo@29
|
900 function DF:GetTemplate (widget_type, template_name)
|
|
Tercioo@29
|
901 widget_type = string.lower (widget_type)
|
|
Tercioo@29
|
902
|
|
Tercioo@29
|
903 local template_table
|
|
Tercioo@29
|
904 if (widget_type == "font") then
|
|
Tercioo@29
|
905 template_table = DF.font_templates
|
|
Tercioo@29
|
906 elseif (widget_type == "dropdown") then
|
|
Tercioo@29
|
907 template_table = DF.dropdown_templates
|
|
Tercioo@29
|
908 elseif (widget_type == "button") then
|
|
Tercioo@29
|
909 template_table = DF.button_templates
|
|
Tercioo@29
|
910 elseif (widget_type == "switch") then
|
|
Tercioo@29
|
911 template_table = DF.switch_templates
|
|
Tercioo@29
|
912 elseif (widget_type == "slider") then
|
|
Tercio@22
|
913 template_table = DF.slider_templates
|
|
Tercio@22
|
914 end
|
|
Tercio@22
|
915 return template_table [template_name]
|
|
Tercio@22
|
916 end
|
|
Tercioo@28
|
917
|
|
Tercioo@28
|
918 function DF.GetParentName (frame)
|
|
Tercioo@28
|
919 local parentName = frame:GetName()
|
|
Tercioo@28
|
920 if (not parentName) then
|
|
Tercioo@28
|
921 error ("Details! FrameWork: called $parent but parent was no name.", 2)
|
|
Tercioo@28
|
922 end
|
|
Tercioo@28
|
923 return parentName
|
|
Tercioo@28
|
924 end
|