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