flickerstreak@33
|
1 --[[
|
flickerstreak@33
|
2 Name: Dewdrop-2.0
|
flickerstreak@33
|
3 Revision: $Rev: 48630 $
|
flickerstreak@33
|
4 Author(s): ckknight (ckknight@gmail.com)
|
flickerstreak@33
|
5 Website: http://ckknight.wowinterface.com/
|
flickerstreak@33
|
6 Documentation: http://wiki.wowace.com/index.php/Dewdrop-2.0
|
flickerstreak@33
|
7 SVN: http://svn.wowace.com/root/trunk/DewdropLib/Dewdrop-2.0
|
flickerstreak@33
|
8 Description: A library to provide a clean dropdown menu interface.
|
flickerstreak@33
|
9 Dependencies: AceLibrary
|
flickerstreak@33
|
10 License: LGPL v2.1
|
flickerstreak@33
|
11 ]]
|
flickerstreak@33
|
12
|
flickerstreak@33
|
13 local MAJOR_VERSION = "Dewdrop-2.0"
|
flickerstreak@33
|
14 local MINOR_VERSION = "$Revision: 48630 $"
|
flickerstreak@33
|
15
|
flickerstreak@33
|
16 if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
|
flickerstreak@33
|
17 if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
|
flickerstreak@33
|
18
|
flickerstreak@33
|
19 local Dewdrop = {}
|
flickerstreak@33
|
20
|
flickerstreak@33
|
21 local SharedMedia
|
flickerstreak@33
|
22
|
flickerstreak@33
|
23 local CLOSE = "Close"
|
flickerstreak@33
|
24 local CLOSE_DESC = "Close the menu."
|
flickerstreak@33
|
25 local VALIDATION_ERROR = "Validation error."
|
flickerstreak@33
|
26 local USAGE_TOOLTIP = "Usage: %s."
|
flickerstreak@33
|
27 local RANGE_TOOLTIP = "Note that you can scroll your mouse wheel while over the slider to step by one."
|
flickerstreak@33
|
28 local RESET_KEYBINDING_DESC = "Hit escape to clear the keybinding."
|
flickerstreak@33
|
29 local KEY_BUTTON1 = "Left Mouse"
|
flickerstreak@33
|
30 local KEY_BUTTON2 = "Right Mouse"
|
flickerstreak@33
|
31 local DISABLED = "Disabled"
|
flickerstreak@33
|
32 local DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?"
|
flickerstreak@33
|
33
|
flickerstreak@33
|
34 if GetLocale() == "deDE" then
|
flickerstreak@33
|
35 CLOSE = "Schlie\195\159en"
|
flickerstreak@33
|
36 CLOSE_DESC = "Men\195\188 schlie\195\159en."
|
flickerstreak@33
|
37 VALIDATION_ERROR = "Validierungsfehler."
|
flickerstreak@33
|
38 USAGE_TOOLTIP = "Benutzung: %s."
|
flickerstreak@33
|
39 RANGE_TOOLTIP = "Beachte das du mit dem Mausrad scrollen kannst solange du \195\188ber dem Schieberegler bist, um 10er Spr\195\188nge zu machen."
|
flickerstreak@33
|
40 RESET_KEYBINDING_DESC = "Escape dr\195\188cken, um die Tastenbelegung zu l\195\182schen."
|
flickerstreak@33
|
41 KEY_BUTTON1 = "Linke Maustaste"
|
flickerstreak@33
|
42 KEY_BUTTON2 = "Rechte Maustaste"
|
flickerstreak@33
|
43 DISABLED = "Deaktiviert"
|
flickerstreak@33
|
44 DEFAULT_CONFIRM_MESSAGE = "Bist du sicher das du `%s' machen willst?"
|
flickerstreak@33
|
45 elseif GetLocale() == "koKR" then
|
flickerstreak@33
|
46 CLOSE = "닫기"
|
flickerstreak@33
|
47 CLOSE_DESC = "메뉴를 닫습니다."
|
flickerstreak@33
|
48 VALIDATION_ERROR = "오류 확인."
|
flickerstreak@33
|
49 USAGE_TOOLTIP = "사용법: %s."
|
flickerstreak@33
|
50 RANGE_TOOLTIP = "알림 : 슬라이더 위에서 마우스 휠을 사용하면 한단계씩 조절할 수 있습니다."
|
flickerstreak@33
|
51 RESET_KEYBINDING_DESC = "단축키를 해제하려면 ESC키를 누르세요."
|
flickerstreak@33
|
52 KEY_BUTTON1 = "왼쪽 마우스"
|
flickerstreak@33
|
53 KEY_BUTTON2 = "오른쪽 마우스"
|
flickerstreak@33
|
54 DISABLED = "비활성화됨"
|
flickerstreak@33
|
55 DEFAULT_CONFIRM_MESSAGE = "정말로 `%s' 실행을 하시겠습니까 ?"
|
flickerstreak@33
|
56 elseif GetLocale() == "frFR" then
|
flickerstreak@33
|
57 CLOSE = "Fermer"
|
flickerstreak@33
|
58 CLOSE_DESC = "Ferme le menu."
|
flickerstreak@33
|
59 VALIDATION_ERROR = "Erreur de validation."
|
flickerstreak@33
|
60 USAGE_TOOLTIP = "Utilisation : %s."
|
flickerstreak@33
|
61 RANGE_TOOLTIP = "Vous pouvez aussi utiliser la molette de la souris pour pour modifier progressivement."
|
flickerstreak@33
|
62 RESET_KEYBINDING_DESC = "Appuyez sur la touche Echappement pour effacer le raccourci."
|
flickerstreak@33
|
63 KEY_BUTTON1 = "Clic gauche"
|
flickerstreak@33
|
64 KEY_BUTTON2 = "Clic droit"
|
flickerstreak@33
|
65 DISABLED = "D\195\169sactiv\195\169"
|
flickerstreak@33
|
66 DEFAULT_CONFIRM_MESSAGE = "\195\138tes-vous s\195\187r de vouloir effectuer '%s' ?"
|
flickerstreak@33
|
67 elseif GetLocale() == "esES" then
|
flickerstreak@33
|
68 CLOSE = "Cerrar"
|
flickerstreak@33
|
69 CLOSE_DESC = "Cierra el menú."
|
flickerstreak@33
|
70 VALIDATION_ERROR = "Error de validación."
|
flickerstreak@33
|
71 USAGE_TOOLTIP = "Uso: %s."
|
flickerstreak@33
|
72 RANGE_TOOLTIP = "Puedes desplazarte verticalmente con la rueda del ratón sobre el desplazador."
|
flickerstreak@33
|
73 RESET_KEYBINDING_DESC = "Pulsa Escape para borrar la asignación de tecla."
|
flickerstreak@33
|
74 KEY_BUTTON1 = "Clic Izquierdo"
|
flickerstreak@33
|
75 KEY_BUTTON2 = "Clic Derecho"
|
flickerstreak@33
|
76 DISABLED = "Desactivado"
|
flickerstreak@33
|
77 DEFAULT_CONFIRM_MESSAGE = "¿Estás seguro de querer realizar `%s'?"
|
flickerstreak@33
|
78 elseif GetLocale() == "zhTW" then
|
flickerstreak@33
|
79 CLOSE = "關閉"
|
flickerstreak@33
|
80 CLOSE_DESC = "關閉選單。"
|
flickerstreak@33
|
81 VALIDATION_ERROR = "驗證錯誤。"
|
flickerstreak@33
|
82 USAGE_TOOLTIP = "用法: %s。"
|
flickerstreak@33
|
83 RANGE_TOOLTIP = "你可以在捲動條上使用滑鼠滾輪來捲動。"
|
flickerstreak@33
|
84 RESET_KEYBINDING_DESC = "按Esc鍵清除快捷鍵。"
|
flickerstreak@33
|
85 KEY_BUTTON1 = "滑鼠左鍵"
|
flickerstreak@33
|
86 KEY_BUTTON2 = "滑鼠右鍵"
|
flickerstreak@33
|
87 DISABLED = "停用"
|
flickerstreak@33
|
88 DEFAULT_CONFIRM_MESSAGE = "是否執行「%s」?"
|
flickerstreak@33
|
89 elseif GetLocale() == "zhCN" then
|
flickerstreak@33
|
90 CLOSE = "关闭"
|
flickerstreak@33
|
91 CLOSE_DESC = "关闭菜单"
|
flickerstreak@33
|
92 VALIDATION_ERROR = "验证错误."
|
flickerstreak@33
|
93 USAGE_TOOLTIP = "用法: %s."
|
flickerstreak@33
|
94 RANGE_TOOLTIP = "你可以在滚动条上使用鼠标滚轮来翻页."
|
flickerstreak@33
|
95 RESET_KEYBINDING_DESC = "按ESC键清除按键绑定"
|
flickerstreak@33
|
96 KEY_BUTTON1 = "鼠标左键"
|
flickerstreak@33
|
97 KEY_BUTTON2 = "鼠标右键"
|
flickerstreak@33
|
98 DISABLED = "禁用"
|
flickerstreak@33
|
99 DEFAULT_CONFIRM_MESSAGE = "是否执行'%s'?"
|
flickerstreak@33
|
100 end
|
flickerstreak@33
|
101
|
flickerstreak@33
|
102 Dewdrop.KEY_BUTTON1 = KEY_BUTTON1
|
flickerstreak@33
|
103 Dewdrop.KEY_BUTTON2 = KEY_BUTTON2
|
flickerstreak@33
|
104
|
flickerstreak@33
|
105 local function new(...)
|
flickerstreak@33
|
106 local t = {}
|
flickerstreak@33
|
107 for i = 1, select('#', ...), 2 do
|
flickerstreak@33
|
108 local k = select(i, ...)
|
flickerstreak@33
|
109 if k then
|
flickerstreak@33
|
110 t[k] = select(i+1, ...)
|
flickerstreak@33
|
111 else
|
flickerstreak@33
|
112 break
|
flickerstreak@33
|
113 end
|
flickerstreak@33
|
114 end
|
flickerstreak@33
|
115 return t
|
flickerstreak@33
|
116 end
|
flickerstreak@33
|
117
|
flickerstreak@33
|
118 local tmp
|
flickerstreak@33
|
119 do
|
flickerstreak@33
|
120 local t = {}
|
flickerstreak@33
|
121 function tmp(...)
|
flickerstreak@33
|
122 for k in pairs(t) do
|
flickerstreak@33
|
123 t[k] = nil
|
flickerstreak@33
|
124 end
|
flickerstreak@33
|
125 for i = 1, select('#', ...), 2 do
|
flickerstreak@33
|
126 local k = select(i, ...)
|
flickerstreak@33
|
127 if k then
|
flickerstreak@33
|
128 t[k] = select(i+1, ...)
|
flickerstreak@33
|
129 else
|
flickerstreak@33
|
130 break
|
flickerstreak@33
|
131 end
|
flickerstreak@33
|
132 end
|
flickerstreak@33
|
133 return t
|
flickerstreak@33
|
134 end
|
flickerstreak@33
|
135 end
|
flickerstreak@33
|
136 local tmp2
|
flickerstreak@33
|
137 do
|
flickerstreak@33
|
138 local t = {}
|
flickerstreak@33
|
139 function tmp2(...)
|
flickerstreak@33
|
140 for k in pairs(t) do
|
flickerstreak@33
|
141 t[k] = nil
|
flickerstreak@33
|
142 end
|
flickerstreak@33
|
143 for i = 1, select('#', ...), 2 do
|
flickerstreak@33
|
144 local k = select(i, ...)
|
flickerstreak@33
|
145 if k then
|
flickerstreak@33
|
146 t[k] = select(i+1, ...)
|
flickerstreak@33
|
147 else
|
flickerstreak@33
|
148 break
|
flickerstreak@33
|
149 end
|
flickerstreak@33
|
150 end
|
flickerstreak@33
|
151 return t
|
flickerstreak@33
|
152 end
|
flickerstreak@33
|
153 end
|
flickerstreak@33
|
154 local levels
|
flickerstreak@33
|
155 local buttons
|
flickerstreak@33
|
156
|
flickerstreak@33
|
157
|
flickerstreak@33
|
158 -- Secure frame handling:
|
flickerstreak@33
|
159 -- Rather than using secure buttons in the menu (has problems), we have one
|
flickerstreak@33
|
160 -- master secureframe that we pop onto menu items on mouseover. This requires
|
flickerstreak@33
|
161 -- some dark magic with OnLeave etc, but it's not too bad.
|
flickerstreak@33
|
162
|
flickerstreak@33
|
163 local secureFrame = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate")
|
flickerstreak@33
|
164 secureFrame:Hide()
|
flickerstreak@33
|
165
|
flickerstreak@33
|
166 local function secureFrame_Show(self)
|
flickerstreak@33
|
167 local owner = self.owner
|
flickerstreak@33
|
168
|
flickerstreak@33
|
169 if self.secure then -- Leftovers from previos owner, clean up! ("Shouldn't" happen but does..)
|
flickerstreak@33
|
170 for k,v in pairs(self.secure) do
|
flickerstreak@33
|
171 self:SetAttribute(k, nil)
|
flickerstreak@33
|
172 end
|
flickerstreak@33
|
173 end
|
flickerstreak@33
|
174 self.secure = owner.secure; -- Grab hold of new secure data
|
flickerstreak@33
|
175
|
flickerstreak@33
|
176 local scale = owner:GetEffectiveScale()
|
flickerstreak@33
|
177
|
flickerstreak@33
|
178 self:SetPoint("TOPLEFT", nil, "BOTTOMLEFT", owner:GetLeft() * scale, owner:GetTop() * scale)
|
flickerstreak@33
|
179 self:SetPoint("BOTTOMRIGHT", nil, "BOTTOMLEFT", owner:GetRight() * scale, owner:GetBottom() * scale)
|
flickerstreak@33
|
180 self:EnableMouse(true)
|
flickerstreak@33
|
181 for k,v in pairs(self.secure) do
|
flickerstreak@33
|
182 self:SetAttribute(k, v)
|
flickerstreak@33
|
183 end
|
flickerstreak@33
|
184
|
flickerstreak@33
|
185 secureFrame:SetFrameStrata(owner:GetFrameStrata())
|
flickerstreak@33
|
186 secureFrame:SetFrameLevel(owner:GetFrameLevel()+1)
|
flickerstreak@33
|
187
|
flickerstreak@33
|
188 self:Show()
|
flickerstreak@33
|
189 end
|
flickerstreak@33
|
190
|
flickerstreak@33
|
191 local function secureFrame_Hide(self)
|
flickerstreak@33
|
192 self:Hide()
|
flickerstreak@33
|
193 if self.secure then
|
flickerstreak@33
|
194 for k,v in pairs(self.secure) do
|
flickerstreak@33
|
195 self:SetAttribute(k, nil)
|
flickerstreak@33
|
196 end
|
flickerstreak@33
|
197 end
|
flickerstreak@33
|
198 self.secure = nil
|
flickerstreak@33
|
199 end
|
flickerstreak@33
|
200
|
flickerstreak@33
|
201 secureFrame:SetScript("OnEvent",
|
flickerstreak@33
|
202 function()
|
flickerstreak@33
|
203 if event=="PLAYER_REGEN_ENABLED" then
|
flickerstreak@33
|
204 this.combat = false
|
flickerstreak@33
|
205 if not this:IsShown() and this.owner then
|
flickerstreak@33
|
206 secureFrame_Show(this)
|
flickerstreak@33
|
207 end
|
flickerstreak@33
|
208 elseif event=="PLAYER_REGEN_DISABLED" then
|
flickerstreak@33
|
209 this.combat = true
|
flickerstreak@33
|
210 if this:IsShown() then
|
flickerstreak@33
|
211 secureFrame_Hide(this)
|
flickerstreak@33
|
212 end
|
flickerstreak@33
|
213 end
|
flickerstreak@33
|
214 end
|
flickerstreak@33
|
215 )
|
flickerstreak@33
|
216 secureFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
|
flickerstreak@33
|
217 secureFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
|
flickerstreak@33
|
218
|
flickerstreak@33
|
219 secureFrame:SetScript("OnLeave",
|
flickerstreak@33
|
220 function()
|
flickerstreak@33
|
221 local owner=this.owner
|
flickerstreak@33
|
222 this:Deactivate()
|
flickerstreak@33
|
223 owner:GetScript("OnLeave")()
|
flickerstreak@33
|
224 end
|
flickerstreak@33
|
225 )
|
flickerstreak@33
|
226
|
flickerstreak@33
|
227 secureFrame:HookScript("OnClick",
|
flickerstreak@33
|
228 function()
|
flickerstreak@33
|
229 local realthis = this
|
flickerstreak@33
|
230 this = this.owner
|
flickerstreak@33
|
231 this:GetScript("OnClick")()
|
flickerstreak@33
|
232 end
|
flickerstreak@33
|
233 )
|
flickerstreak@33
|
234
|
flickerstreak@33
|
235 function secureFrame:IsOwnedBy(frame)
|
flickerstreak@33
|
236 return self.owner == frame
|
flickerstreak@33
|
237 end
|
flickerstreak@33
|
238
|
flickerstreak@33
|
239 function secureFrame:Activate(owner)
|
flickerstreak@33
|
240 if self.owner then -- "Shouldn't" happen but apparently it does and I cba to troubleshoot...
|
flickerstreak@33
|
241 if not self.combat then
|
flickerstreak@33
|
242 secureFrame_Hide(self)
|
flickerstreak@33
|
243 end
|
flickerstreak@33
|
244 end
|
flickerstreak@33
|
245 self.owner = owner
|
flickerstreak@33
|
246 if not self.combat then
|
flickerstreak@33
|
247 secureFrame_Show(self)
|
flickerstreak@33
|
248 end
|
flickerstreak@33
|
249 end
|
flickerstreak@33
|
250
|
flickerstreak@33
|
251 function secureFrame:Deactivate()
|
flickerstreak@33
|
252 if not self.combat then
|
flickerstreak@33
|
253 secureFrame_Hide(self)
|
flickerstreak@33
|
254 end
|
flickerstreak@33
|
255 self.owner = nil
|
flickerstreak@33
|
256 end
|
flickerstreak@33
|
257
|
flickerstreak@33
|
258 -- END secure frame utilities
|
flickerstreak@33
|
259
|
flickerstreak@33
|
260
|
flickerstreak@33
|
261 -- Underline on mouseover - use a single global underline that we move around, no point in creating lots of copies
|
flickerstreak@33
|
262 local underlineFrame = CreateFrame("Frame", nil)
|
flickerstreak@33
|
263 underlineFrame.tx = underlineFrame:CreateTexture()
|
flickerstreak@33
|
264 underlineFrame.tx:SetTexture(1,1,0.5,0.75)
|
flickerstreak@33
|
265 underlineFrame:SetScript("OnHide", function(this) this:Hide(); end)
|
flickerstreak@33
|
266 underlineFrame:SetScript("OnShow", function(this) -- change sizing on the fly to catch runtime uiscale changes
|
flickerstreak@33
|
267 underlineFrame.tx:SetPoint("TOPLEFT", -1, -2/this:GetEffectiveScale())
|
flickerstreak@33
|
268 underlineFrame.tx:SetPoint("RIGHT", 1,0)
|
flickerstreak@33
|
269 underlineFrame.tx:SetHeight(0.6 / this:GetEffectiveScale());
|
flickerstreak@33
|
270 end)
|
flickerstreak@33
|
271 underlineFrame:SetHeight(1)
|
flickerstreak@33
|
272
|
flickerstreak@33
|
273 -- END underline on mouseover
|
flickerstreak@33
|
274
|
flickerstreak@33
|
275
|
flickerstreak@33
|
276 local function GetScaledCursorPosition()
|
flickerstreak@33
|
277 local x, y = GetCursorPosition()
|
flickerstreak@33
|
278 local scale = UIParent:GetEffectiveScale()
|
flickerstreak@33
|
279 return x / scale, y / scale
|
flickerstreak@33
|
280 end
|
flickerstreak@33
|
281
|
flickerstreak@33
|
282 local function StartCounting(self, level)
|
flickerstreak@33
|
283 for i = level, 1, -1 do
|
flickerstreak@33
|
284 if levels[i] then
|
flickerstreak@33
|
285 levels[i].count = 3
|
flickerstreak@33
|
286 end
|
flickerstreak@33
|
287 end
|
flickerstreak@33
|
288 end
|
flickerstreak@33
|
289
|
flickerstreak@33
|
290 local function StopCounting(self, level)
|
flickerstreak@33
|
291 for i = level, 1, -1 do
|
flickerstreak@33
|
292 if levels[i] then
|
flickerstreak@33
|
293 levels[i].count = nil
|
flickerstreak@33
|
294 end
|
flickerstreak@33
|
295 end
|
flickerstreak@33
|
296 end
|
flickerstreak@33
|
297
|
flickerstreak@33
|
298 local function OnUpdate(self, elapsed)
|
flickerstreak@33
|
299 for _,level in ipairs(levels) do
|
flickerstreak@33
|
300 local count = level.count
|
flickerstreak@33
|
301 if count then
|
flickerstreak@33
|
302 count = count - elapsed
|
flickerstreak@33
|
303 if count < 0 then
|
flickerstreak@33
|
304 level.count = nil
|
flickerstreak@33
|
305 self:Close(level.num)
|
flickerstreak@33
|
306 else
|
flickerstreak@33
|
307 level.count = count
|
flickerstreak@33
|
308 end
|
flickerstreak@33
|
309 end
|
flickerstreak@33
|
310 end
|
flickerstreak@33
|
311 end
|
flickerstreak@33
|
312
|
flickerstreak@33
|
313 local function CheckDualMonitor(self, frame)
|
flickerstreak@33
|
314 local ratio = GetScreenWidth() / GetScreenHeight()
|
flickerstreak@33
|
315 if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then
|
flickerstreak@33
|
316 local offsetx
|
flickerstreak@33
|
317 if GetCursorPosition() / GetScreenHeight() * 768 < GetScreenWidth() / 2 then
|
flickerstreak@33
|
318 offsetx = GetScreenWidth() / 2 - frame:GetRight()
|
flickerstreak@33
|
319 else
|
flickerstreak@33
|
320 offsetx = GetScreenWidth() / 2 - frame:GetLeft()
|
flickerstreak@33
|
321 end
|
flickerstreak@33
|
322 local point, parent, relativePoint, x, y = frame:GetPoint(1)
|
flickerstreak@33
|
323 frame:SetPoint(point, parent, relativePoint, (x or 0) + offsetx, y or 0)
|
flickerstreak@33
|
324 end
|
flickerstreak@33
|
325 end
|
flickerstreak@33
|
326
|
flickerstreak@33
|
327 local function CheckSize(self, level)
|
flickerstreak@33
|
328 if not level.buttons then
|
flickerstreak@33
|
329 return
|
flickerstreak@33
|
330 end
|
flickerstreak@33
|
331 local height = 20
|
flickerstreak@33
|
332 for _, button in ipairs(level.buttons) do
|
flickerstreak@33
|
333 height = height + button:GetHeight()
|
flickerstreak@33
|
334 end
|
flickerstreak@33
|
335 level:SetHeight(height)
|
flickerstreak@33
|
336 local width = 160
|
flickerstreak@33
|
337 for _, button in ipairs(level.buttons) do
|
flickerstreak@33
|
338 local extra = 1
|
flickerstreak@33
|
339 if button.hasArrow or button.hasColorSwatch then
|
flickerstreak@33
|
340 extra = extra + 16
|
flickerstreak@33
|
341 end
|
flickerstreak@33
|
342 if not button.notCheckable then
|
flickerstreak@33
|
343 extra = extra + 24
|
flickerstreak@33
|
344 end
|
flickerstreak@33
|
345 button.text:SetFont(STANDARD_TEXT_FONT, button.textHeight)
|
flickerstreak@33
|
346 if button.text:GetWidth() + extra > width then
|
flickerstreak@33
|
347 width = button.text:GetWidth() + extra
|
flickerstreak@33
|
348 end
|
flickerstreak@33
|
349 end
|
flickerstreak@33
|
350 level:SetWidth(width + 20)
|
flickerstreak@33
|
351 if level:GetLeft() and level:GetRight() and level:GetTop() and level:GetBottom() and (level:GetLeft() < 0 or level:GetRight() > GetScreenWidth() or level:GetTop() > GetScreenHeight() or level:GetBottom() < 0) then
|
flickerstreak@33
|
352 level:ClearAllPoints()
|
flickerstreak@33
|
353 local parent = level.parent or level:GetParent()
|
flickerstreak@33
|
354 if type(parent) ~= "table" then
|
flickerstreak@33
|
355 parent = UIParent
|
flickerstreak@33
|
356 end
|
flickerstreak@33
|
357 if level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
358 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
359 level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
|
flickerstreak@33
|
360 else
|
flickerstreak@33
|
361 level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
|
flickerstreak@33
|
362 end
|
flickerstreak@33
|
363 else
|
flickerstreak@33
|
364 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
365 level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
|
flickerstreak@33
|
366 else
|
flickerstreak@33
|
367 level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
|
flickerstreak@33
|
368 end
|
flickerstreak@33
|
369 end
|
flickerstreak@33
|
370 end
|
flickerstreak@33
|
371 local dirty = false
|
flickerstreak@33
|
372 if not level:GetRight() then
|
flickerstreak@33
|
373 self:Close()
|
flickerstreak@33
|
374 return
|
flickerstreak@33
|
375 end
|
flickerstreak@33
|
376 if level:GetRight() > GetScreenWidth() and level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
377 level.lastDirection = "LEFT"
|
flickerstreak@33
|
378 dirty = true
|
flickerstreak@33
|
379 elseif level:GetLeft() < 0 and level.lastDirection == "LEFT" then
|
flickerstreak@33
|
380 level.lastDirection = "RIGHT"
|
flickerstreak@33
|
381 dirty = true
|
flickerstreak@33
|
382 end
|
flickerstreak@33
|
383 if level:GetTop() > GetScreenHeight() and level.lastVDirection == "UP" then
|
flickerstreak@33
|
384 level.lastVDirection = "DOWN"
|
flickerstreak@33
|
385 dirty = true
|
flickerstreak@33
|
386 elseif level:GetBottom() < 0 and level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
387 level.lastVDirection = "UP"
|
flickerstreak@33
|
388 dirty = true
|
flickerstreak@33
|
389 end
|
flickerstreak@33
|
390 if dirty then
|
flickerstreak@33
|
391 level:ClearAllPoints()
|
flickerstreak@33
|
392 local parent = level.parent or level:GetParent()
|
flickerstreak@33
|
393 if type(parent) ~= "table" then
|
flickerstreak@33
|
394 parent = UIParent
|
flickerstreak@33
|
395 end
|
flickerstreak@33
|
396 if level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
397 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
398 level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
|
flickerstreak@33
|
399 else
|
flickerstreak@33
|
400 level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
|
flickerstreak@33
|
401 end
|
flickerstreak@33
|
402 else
|
flickerstreak@33
|
403 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
404 level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
|
flickerstreak@33
|
405 else
|
flickerstreak@33
|
406 level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
|
flickerstreak@33
|
407 end
|
flickerstreak@33
|
408 end
|
flickerstreak@33
|
409 end
|
flickerstreak@33
|
410 if level:GetTop() > GetScreenHeight() then
|
flickerstreak@33
|
411 local top = level:GetTop()
|
flickerstreak@33
|
412 local point, parent, relativePoint, x, y = level:GetPoint(1)
|
flickerstreak@33
|
413 level:ClearAllPoints()
|
flickerstreak@33
|
414 level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) + GetScreenHeight() - top)
|
flickerstreak@33
|
415 elseif level:GetBottom() < 0 then
|
flickerstreak@33
|
416 local bottom = level:GetBottom()
|
flickerstreak@33
|
417 local point, parent, relativePoint, x, y = level:GetPoint(1)
|
flickerstreak@33
|
418 level:ClearAllPoints()
|
flickerstreak@33
|
419 level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) - bottom)
|
flickerstreak@33
|
420 end
|
flickerstreak@33
|
421 CheckDualMonitor(self, level)
|
flickerstreak@33
|
422 if mod(level.num, 5) == 0 then
|
flickerstreak@33
|
423 local left, bottom = level:GetLeft(), level:GetBottom()
|
flickerstreak@33
|
424 level:ClearAllPoints()
|
flickerstreak@33
|
425 level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
|
flickerstreak@33
|
426 end
|
flickerstreak@33
|
427 end
|
flickerstreak@33
|
428
|
flickerstreak@33
|
429 local Open
|
flickerstreak@33
|
430 local OpenSlider
|
flickerstreak@33
|
431 local OpenEditBox
|
flickerstreak@33
|
432 local Refresh
|
flickerstreak@33
|
433 local Clear
|
flickerstreak@33
|
434 local function ReleaseButton(self, level, index)
|
flickerstreak@33
|
435 if not level.buttons then
|
flickerstreak@33
|
436 return
|
flickerstreak@33
|
437 end
|
flickerstreak@33
|
438 if not level.buttons[index] then
|
flickerstreak@33
|
439 return
|
flickerstreak@33
|
440 end
|
flickerstreak@33
|
441 local button = level.buttons[index]
|
flickerstreak@33
|
442 button:Hide()
|
flickerstreak@33
|
443 if button.highlight then
|
flickerstreak@33
|
444 button.highlight:Hide()
|
flickerstreak@33
|
445 end
|
flickerstreak@33
|
446 -- button.arrow:SetVertexColor(1, 1, 1)
|
flickerstreak@33
|
447 -- button.arrow:SetHeight(16)
|
flickerstreak@33
|
448 -- button.arrow:SetWidth(16)
|
flickerstreak@33
|
449 table.remove(level.buttons, index)
|
flickerstreak@33
|
450 table.insert(buttons, button)
|
flickerstreak@33
|
451 for k in pairs(button) do
|
flickerstreak@33
|
452 if k ~= 0 and k ~= "text" and k ~= "check" and k ~= "arrow" and k ~= "colorSwatch" and k ~= "highlight" and k ~= "radioHighlight" then
|
flickerstreak@33
|
453 button[k] = nil
|
flickerstreak@33
|
454 end
|
flickerstreak@33
|
455 end
|
flickerstreak@33
|
456 return true
|
flickerstreak@33
|
457 end
|
flickerstreak@33
|
458
|
flickerstreak@33
|
459 local function Scroll(self, level, down)
|
flickerstreak@33
|
460 if down then
|
flickerstreak@33
|
461 if level:GetBottom() < 0 then
|
flickerstreak@33
|
462 local point, parent, relativePoint, x, y = level:GetPoint(1)
|
flickerstreak@33
|
463 level:SetPoint(point, parent, relativePoint, x, y + 50)
|
flickerstreak@33
|
464 if level:GetBottom() > 0 then
|
flickerstreak@33
|
465 level:SetPoint(point, parent, relativePoint, x, y + 50 - level:GetBottom())
|
flickerstreak@33
|
466 end
|
flickerstreak@33
|
467 end
|
flickerstreak@33
|
468 else
|
flickerstreak@33
|
469 if level:GetTop() > GetScreenHeight() then
|
flickerstreak@33
|
470 local point, parent, relativePoint, x, y = level:GetPoint(1)
|
flickerstreak@33
|
471 level:SetPoint(point, parent, relativePoint, x, y - 50)
|
flickerstreak@33
|
472 if level:GetTop() < GetScreenHeight() then
|
flickerstreak@33
|
473 level:SetPoint(point, parent, relativePoint, x, y - 50 + GetScreenHeight() - level:GetTop())
|
flickerstreak@33
|
474 end
|
flickerstreak@33
|
475 end
|
flickerstreak@33
|
476 end
|
flickerstreak@33
|
477 end
|
flickerstreak@33
|
478
|
flickerstreak@33
|
479 local function getArgs(t, str, num, ...)
|
flickerstreak@33
|
480 local x = t[str .. num]
|
flickerstreak@33
|
481 if x == nil then
|
flickerstreak@33
|
482 return ...
|
flickerstreak@33
|
483 else
|
flickerstreak@33
|
484 return x, getArgs(t, str, num + 1, ...)
|
flickerstreak@33
|
485 end
|
flickerstreak@33
|
486 end
|
flickerstreak@33
|
487
|
flickerstreak@33
|
488 local sliderFrame
|
flickerstreak@33
|
489 local editBoxFrame
|
flickerstreak@33
|
490
|
flickerstreak@33
|
491 local normalFont
|
flickerstreak@33
|
492 local lastSetFont
|
flickerstreak@33
|
493 local justSetFont = false
|
flickerstreak@33
|
494 local regionTmp = {}
|
flickerstreak@33
|
495 local function fillRegionTmp(...)
|
flickerstreak@33
|
496 for i = 1, select('#', ...) do
|
flickerstreak@33
|
497 regionTmp[i] = select(i, ...)
|
flickerstreak@33
|
498 end
|
flickerstreak@33
|
499 end
|
flickerstreak@33
|
500
|
flickerstreak@33
|
501 local function showGameTooltip(this)
|
flickerstreak@33
|
502 if this.tooltipTitle or this.tooltipText then
|
flickerstreak@33
|
503 GameTooltip_SetDefaultAnchor(GameTooltip, this)
|
flickerstreak@33
|
504 local disabled = not this.isTitle and this.disabled
|
flickerstreak@33
|
505 local font
|
flickerstreak@33
|
506 if this.tooltipTitle then
|
flickerstreak@33
|
507 if SharedMedia and SharedMedia:IsValid("font", this.tooltipTitle) then
|
flickerstreak@33
|
508 font = SharedMedia:Fetch("font", this.tooltipTitle)
|
flickerstreak@33
|
509 end
|
flickerstreak@33
|
510 if disabled then
|
flickerstreak@33
|
511 GameTooltip:SetText(this.tooltipTitle, 0.5, 0.5, 0.5, 1)
|
flickerstreak@33
|
512 else
|
flickerstreak@33
|
513 GameTooltip:SetText(this.tooltipTitle, 1, 1, 1, 1)
|
flickerstreak@33
|
514 end
|
flickerstreak@33
|
515 if this.tooltipText then
|
flickerstreak@33
|
516 if not font and SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then
|
flickerstreak@33
|
517 font = SharedMedia:Fetch("font", this.tooltipText)
|
flickerstreak@33
|
518 end
|
flickerstreak@33
|
519 if disabled then
|
flickerstreak@33
|
520 GameTooltip:AddLine(this.tooltipText, (NORMAL_FONT_COLOR.r + 0.5) / 2, (NORMAL_FONT_COLOR.g + 0.5) / 2, (NORMAL_FONT_COLOR.b + 0.5) / 2, 1)
|
flickerstreak@33
|
521 else
|
flickerstreak@33
|
522 GameTooltip:AddLine(this.tooltipText, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
|
flickerstreak@33
|
523 end
|
flickerstreak@33
|
524 end
|
flickerstreak@33
|
525 else
|
flickerstreak@33
|
526 if SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then
|
flickerstreak@33
|
527 font = SharedMedia:Fetch("font", this.tooltipText)
|
flickerstreak@33
|
528 end
|
flickerstreak@33
|
529 if disabled then
|
flickerstreak@33
|
530 GameTooltip:SetText(this.tooltipText, 0.5, 0.5, 0.5, 1)
|
flickerstreak@33
|
531 else
|
flickerstreak@33
|
532 GameTooltip:SetText(this.tooltipText, 1, 1, 1, 1)
|
flickerstreak@33
|
533 end
|
flickerstreak@33
|
534 end
|
flickerstreak@33
|
535 if font then
|
flickerstreak@33
|
536 fillRegionTmp(GameTooltip:GetRegions())
|
flickerstreak@33
|
537 lastSetFont = font
|
flickerstreak@33
|
538 justSetFont = true
|
flickerstreak@33
|
539 for i,v in ipairs(regionTmp) do
|
flickerstreak@33
|
540 if v.SetFont then
|
flickerstreak@33
|
541 local norm,size,outline = v:GetFont()
|
flickerstreak@33
|
542 v:SetFont(font, size, outline)
|
flickerstreak@33
|
543 if not normalFont then
|
flickerstreak@33
|
544 normalFont = norm
|
flickerstreak@33
|
545 end
|
flickerstreak@33
|
546 end
|
flickerstreak@33
|
547 regionTmp[i] = nil
|
flickerstreak@33
|
548 end
|
flickerstreak@33
|
549 elseif not normalFont then
|
flickerstreak@33
|
550 fillRegionTmp(GameTooltip:GetRegions())
|
flickerstreak@33
|
551 for i,v in ipairs(regionTmp) do
|
flickerstreak@33
|
552 if v.GetFont and not normalFont then
|
flickerstreak@33
|
553 normalFont = v:GetFont()
|
flickerstreak@33
|
554 end
|
flickerstreak@33
|
555 regionTmp[i] = nil
|
flickerstreak@33
|
556 end
|
flickerstreak@33
|
557 end
|
flickerstreak@33
|
558 GameTooltip:Show()
|
flickerstreak@33
|
559 end
|
flickerstreak@33
|
560 if this.tooltipFunc then
|
flickerstreak@33
|
561 GameTooltip:SetOwner(this, "ANCHOR_NONE")
|
flickerstreak@33
|
562 GameTooltip:SetPoint("TOPLEFT", this, "TOPRIGHT", 5, 0)
|
flickerstreak@33
|
563 this.tooltipFunc(getArgs(this, 'tooltipArg', 1))
|
flickerstreak@33
|
564 GameTooltip:Show()
|
flickerstreak@33
|
565 end
|
flickerstreak@33
|
566 end
|
flickerstreak@33
|
567
|
flickerstreak@33
|
568 local tmpt = setmetatable({}, {mode='v'})
|
flickerstreak@33
|
569 local numButtons = 0
|
flickerstreak@33
|
570 local function AcquireButton(self, level)
|
flickerstreak@33
|
571 if not levels[level] then
|
flickerstreak@33
|
572 return
|
flickerstreak@33
|
573 end
|
flickerstreak@33
|
574 level = levels[level]
|
flickerstreak@33
|
575 if not level.buttons then
|
flickerstreak@33
|
576 level.buttons = {}
|
flickerstreak@33
|
577 end
|
flickerstreak@33
|
578 local button
|
flickerstreak@33
|
579 if #buttons == 0 then
|
flickerstreak@33
|
580 numButtons = numButtons + 1
|
flickerstreak@33
|
581 button = CreateFrame("Button", "Dewdrop20Button" .. numButtons, nil)
|
flickerstreak@33
|
582 button:SetFrameStrata("FULLSCREEN_DIALOG")
|
flickerstreak@33
|
583 button:SetHeight(16)
|
flickerstreak@33
|
584 local highlight = button:CreateTexture(nil, "BACKGROUND")
|
flickerstreak@33
|
585 highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
|
flickerstreak@33
|
586 button.highlight = highlight
|
flickerstreak@33
|
587 highlight:SetBlendMode("ADD")
|
flickerstreak@33
|
588 highlight:SetAllPoints(button)
|
flickerstreak@33
|
589 highlight:Hide()
|
flickerstreak@33
|
590 local check = button:CreateTexture(nil, "ARTWORK")
|
flickerstreak@33
|
591 button.check = check
|
flickerstreak@33
|
592 check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
|
flickerstreak@33
|
593 check:SetPoint("CENTER", button, "LEFT", 12, 0)
|
flickerstreak@33
|
594 check:SetWidth(24)
|
flickerstreak@33
|
595 check:SetHeight(24)
|
flickerstreak@33
|
596 local radioHighlight = button:CreateTexture(nil, "ARTWORK")
|
flickerstreak@33
|
597 button.radioHighlight = radioHighlight
|
flickerstreak@33
|
598 radioHighlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
|
flickerstreak@33
|
599 radioHighlight:SetAllPoints(check)
|
flickerstreak@33
|
600 radioHighlight:SetBlendMode("ADD")
|
flickerstreak@33
|
601 radioHighlight:SetTexCoord(0.5, 0.75, 0, 1)
|
flickerstreak@33
|
602 radioHighlight:Hide()
|
flickerstreak@33
|
603 button:SetScript("OnEnter", function()
|
flickerstreak@33
|
604 if (sliderFrame and sliderFrame:IsShown() and sliderFrame.mouseDown and sliderFrame.level == this.level.num + 1) or (editBoxFrame and editBoxFrame:IsShown() and editBoxFrame.mouseDown and editBoxFrame.level == this.level.num + 1) then
|
flickerstreak@33
|
605 for i = 1, this.level.num do
|
flickerstreak@33
|
606 Refresh(self, levels[i])
|
flickerstreak@33
|
607 end
|
flickerstreak@33
|
608 return
|
flickerstreak@33
|
609 end
|
flickerstreak@33
|
610 self:Close(this.level.num + 1)
|
flickerstreak@33
|
611 if not this.disabled then
|
flickerstreak@33
|
612 if this.secure then
|
flickerstreak@33
|
613 secureFrame:Activate(this)
|
flickerstreak@33
|
614 elseif this.hasSlider then
|
flickerstreak@33
|
615 OpenSlider(self, this)
|
flickerstreak@33
|
616 elseif this.hasEditBox then
|
flickerstreak@33
|
617 OpenEditBox(self, this)
|
flickerstreak@33
|
618 elseif this.hasArrow then
|
flickerstreak@33
|
619 Open(self, this, nil, this.level.num + 1, this.value)
|
flickerstreak@33
|
620 end
|
flickerstreak@33
|
621 end
|
flickerstreak@33
|
622 if not this.level then -- button reclaimed
|
flickerstreak@33
|
623 return
|
flickerstreak@33
|
624 end
|
flickerstreak@33
|
625 StopCounting(self, this.level.num + 1)
|
flickerstreak@33
|
626 if not this.disabled then
|
flickerstreak@33
|
627 highlight:Show()
|
flickerstreak@33
|
628 if this.isRadio then
|
flickerstreak@33
|
629 button.radioHighlight:Show()
|
flickerstreak@33
|
630 end
|
flickerstreak@33
|
631 if this.mouseoverUnderline then
|
flickerstreak@33
|
632 underlineFrame:SetParent(this)
|
flickerstreak@33
|
633 underlineFrame:SetPoint("BOTTOMLEFT",this.text,0,0)
|
flickerstreak@33
|
634 underlineFrame:SetWidth(this.text:GetWidth())
|
flickerstreak@33
|
635 underlineFrame:Show()
|
flickerstreak@33
|
636 end
|
flickerstreak@33
|
637 end
|
flickerstreak@33
|
638 showGameTooltip(this)
|
flickerstreak@33
|
639 end)
|
flickerstreak@33
|
640 button:SetScript("OnHide", function()
|
flickerstreak@33
|
641 if this.secure and secureFrame:IsOwnedBy(this) then
|
flickerstreak@33
|
642 secureFrame:Deactivate()
|
flickerstreak@33
|
643 end
|
flickerstreak@33
|
644 end)
|
flickerstreak@33
|
645 button:SetScript("OnLeave", function()
|
flickerstreak@33
|
646 if this.secure and secureFrame:IsShown() then
|
flickerstreak@33
|
647 return; -- it's ok, we didn't actually mouse out of the button, only onto the secure frame on top of it
|
flickerstreak@33
|
648 end
|
flickerstreak@33
|
649 underlineFrame:Hide()
|
flickerstreak@33
|
650 if not this.selected then
|
flickerstreak@33
|
651 highlight:Hide()
|
flickerstreak@33
|
652 end
|
flickerstreak@33
|
653 button.radioHighlight:Hide()
|
flickerstreak@33
|
654 if this.level then
|
flickerstreak@33
|
655 StartCounting(self, this.level.num)
|
flickerstreak@33
|
656 end
|
flickerstreak@33
|
657 GameTooltip:Hide()
|
flickerstreak@33
|
658 end)
|
flickerstreak@33
|
659 local first = true
|
flickerstreak@33
|
660 button:SetScript("OnClick", function()
|
flickerstreak@33
|
661 if not this.disabled then
|
flickerstreak@33
|
662 if this.hasColorSwatch then
|
flickerstreak@33
|
663 local func = button.colorFunc
|
flickerstreak@33
|
664 local hasOpacity = this.hasOpacity
|
flickerstreak@33
|
665 local this = this
|
flickerstreak@33
|
666 for k in pairs(tmpt) do
|
flickerstreak@33
|
667 tmpt[k] = nil
|
flickerstreak@33
|
668 end
|
flickerstreak@33
|
669 for i = 1, 1000 do
|
flickerstreak@33
|
670 local x = this['colorArg'..i]
|
flickerstreak@33
|
671 if x == nil then
|
flickerstreak@33
|
672 break
|
flickerstreak@33
|
673 else
|
flickerstreak@33
|
674 tmpt[i] = x
|
flickerstreak@33
|
675 end
|
flickerstreak@33
|
676 end
|
flickerstreak@33
|
677 ColorPickerFrame.func = function()
|
flickerstreak@33
|
678 if func then
|
flickerstreak@33
|
679 local r,g,b = ColorPickerFrame:GetColorRGB()
|
flickerstreak@33
|
680 local a = hasOpacity and 1 - OpacitySliderFrame:GetValue() or nil
|
flickerstreak@33
|
681 local n = #tmpt
|
flickerstreak@33
|
682 tmpt[n+1] = r
|
flickerstreak@33
|
683 tmpt[n+2] = g
|
flickerstreak@33
|
684 tmpt[n+3] = b
|
flickerstreak@33
|
685 tmpt[n+4] = a
|
flickerstreak@33
|
686 func(unpack(tmpt))
|
flickerstreak@33
|
687 tmpt[n+1] = nil
|
flickerstreak@33
|
688 tmpt[n+2] = nil
|
flickerstreak@33
|
689 tmpt[n+3] = nil
|
flickerstreak@33
|
690 tmpt[n+4] = nil
|
flickerstreak@33
|
691 end
|
flickerstreak@33
|
692 end
|
flickerstreak@33
|
693 ColorPickerFrame.hasOpacity = this.hasOpacity
|
flickerstreak@33
|
694 ColorPickerFrame.opacityFunc = ColorPickerFrame.func
|
flickerstreak@33
|
695 ColorPickerFrame.opacity = 1 - this.opacity
|
flickerstreak@33
|
696 ColorPickerFrame:SetColorRGB(this.r, this.g, this.b)
|
flickerstreak@33
|
697 local r, g, b, a = this.r, this.g, this.b, this.opacity
|
flickerstreak@33
|
698 ColorPickerFrame.cancelFunc = function()
|
flickerstreak@33
|
699 if func then
|
flickerstreak@33
|
700 local n = #tmpt
|
flickerstreak@33
|
701 tmpt[n+1] = r
|
flickerstreak@33
|
702 tmpt[n+2] = g
|
flickerstreak@33
|
703 tmpt[n+3] = b
|
flickerstreak@33
|
704 tmpt[n+4] = a
|
flickerstreak@33
|
705 func(unpack(tmpt))
|
flickerstreak@33
|
706 for i = 1, n+4 do
|
flickerstreak@33
|
707 tmpt[i] = nil
|
flickerstreak@33
|
708 end
|
flickerstreak@33
|
709 end
|
flickerstreak@33
|
710 end
|
flickerstreak@33
|
711 self:Close(1)
|
flickerstreak@33
|
712 ShowUIPanel(ColorPickerFrame)
|
flickerstreak@33
|
713 elseif this.func then
|
flickerstreak@33
|
714 local level = this.level
|
flickerstreak@33
|
715 if type(this.func) == "string" then
|
flickerstreak@33
|
716 if type(this.arg1[this.func]) ~= "function" then
|
flickerstreak@33
|
717 self:error("Cannot call method %q", this.func)
|
flickerstreak@33
|
718 end
|
flickerstreak@33
|
719 this.arg1[this.func](this.arg1, getArgs(this, 'arg', 2))
|
flickerstreak@33
|
720 else
|
flickerstreak@33
|
721 this.func(getArgs(this, 'arg', 1))
|
flickerstreak@33
|
722 end
|
flickerstreak@33
|
723 if this.closeWhenClicked then
|
flickerstreak@33
|
724 self:Close()
|
flickerstreak@33
|
725 elseif level:IsShown() then
|
flickerstreak@33
|
726 for i = 1, level.num do
|
flickerstreak@33
|
727 Refresh(self, levels[i])
|
flickerstreak@33
|
728 end
|
flickerstreak@33
|
729 local value = levels[level.num].value
|
flickerstreak@33
|
730 for i = level.num-1, 1, -1 do
|
flickerstreak@33
|
731 local level = levels[i]
|
flickerstreak@33
|
732 local good = false
|
flickerstreak@33
|
733 for _,button in ipairs(level.buttons) do
|
flickerstreak@33
|
734 if button.value == value then
|
flickerstreak@33
|
735 good = true
|
flickerstreak@33
|
736 break
|
flickerstreak@33
|
737 end
|
flickerstreak@33
|
738 end
|
flickerstreak@33
|
739 if not good then
|
flickerstreak@33
|
740 Dewdrop:Close(i+1)
|
flickerstreak@33
|
741 end
|
flickerstreak@33
|
742 value = levels[i].value
|
flickerstreak@33
|
743 end
|
flickerstreak@33
|
744 end
|
flickerstreak@33
|
745 elseif this.closeWhenClicked then
|
flickerstreak@33
|
746 self:Close()
|
flickerstreak@33
|
747 end
|
flickerstreak@33
|
748 end
|
flickerstreak@33
|
749 end)
|
flickerstreak@33
|
750 local text = button:CreateFontString(nil, "ARTWORK")
|
flickerstreak@33
|
751 button.text = text
|
flickerstreak@33
|
752 text:SetFontObject(GameFontHighlightSmall)
|
flickerstreak@33
|
753 button.text:SetFont(STANDARD_TEXT_FONT, UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT)
|
flickerstreak@33
|
754 button:SetScript("OnMouseDown", function()
|
flickerstreak@33
|
755 if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then
|
flickerstreak@33
|
756 text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 1 or 25, -1)
|
flickerstreak@33
|
757 end
|
flickerstreak@33
|
758 end)
|
flickerstreak@33
|
759 button:SetScript("OnMouseUp", function()
|
flickerstreak@33
|
760 if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then
|
flickerstreak@33
|
761 text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 0 or 24, 0)
|
flickerstreak@33
|
762 end
|
flickerstreak@33
|
763 end)
|
flickerstreak@33
|
764 local arrow = button:CreateTexture(nil, "ARTWORK")
|
flickerstreak@33
|
765 button.arrow = arrow
|
flickerstreak@33
|
766 arrow:SetPoint("LEFT", button, "RIGHT", -16, 0)
|
flickerstreak@33
|
767 arrow:SetWidth(16)
|
flickerstreak@33
|
768 arrow:SetHeight(16)
|
flickerstreak@33
|
769 arrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
|
flickerstreak@33
|
770 local colorSwatch = button:CreateTexture(nil, "ARTWORK")
|
flickerstreak@33
|
771 button.colorSwatch = colorSwatch
|
flickerstreak@33
|
772 colorSwatch:SetWidth(20)
|
flickerstreak@33
|
773 colorSwatch:SetHeight(20)
|
flickerstreak@33
|
774 colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
|
flickerstreak@33
|
775 local texture = button:CreateTexture(nil, "OVERLAY")
|
flickerstreak@33
|
776 colorSwatch.texture = texture
|
flickerstreak@33
|
777 texture:SetTexture("Interface\\Buttons\\WHITE8X8")
|
flickerstreak@33
|
778 texture:SetWidth(11.5)
|
flickerstreak@33
|
779 texture:SetHeight(11.5)
|
flickerstreak@33
|
780 texture:Show()
|
flickerstreak@33
|
781 texture:SetPoint("CENTER", colorSwatch, "CENTER")
|
flickerstreak@33
|
782 colorSwatch:SetPoint("RIGHT", button, "RIGHT", 0, 0)
|
flickerstreak@33
|
783 else
|
flickerstreak@33
|
784 button = table.remove(buttons)
|
flickerstreak@33
|
785 end
|
flickerstreak@33
|
786 button:ClearAllPoints()
|
flickerstreak@33
|
787 button:SetParent(level)
|
flickerstreak@33
|
788 button:SetFrameStrata(level:GetFrameStrata())
|
flickerstreak@33
|
789 button:SetFrameLevel(level:GetFrameLevel() + 1)
|
flickerstreak@33
|
790 button:SetPoint("LEFT", level, "LEFT", 10, 0)
|
flickerstreak@33
|
791 button:SetPoint("RIGHT", level, "RIGHT", -10, 0)
|
flickerstreak@33
|
792 if #level.buttons == 0 then
|
flickerstreak@33
|
793 button:SetPoint("TOP", level, "TOP", 0, -10)
|
flickerstreak@33
|
794 else
|
flickerstreak@33
|
795 button:SetPoint("TOP", level.buttons[#level.buttons], "BOTTOM", 0, 0)
|
flickerstreak@33
|
796 end
|
flickerstreak@33
|
797 button.text:SetPoint("LEFT", button, "LEFT", 24, 0)
|
flickerstreak@33
|
798 button:Show()
|
flickerstreak@33
|
799 button.level = level
|
flickerstreak@33
|
800 table.insert(level.buttons, button)
|
flickerstreak@33
|
801 if not level.parented then
|
flickerstreak@33
|
802 level.parented = true
|
flickerstreak@33
|
803 level:ClearAllPoints()
|
flickerstreak@33
|
804 if level.num == 1 then
|
flickerstreak@33
|
805 if level.parent ~= UIParent and type(level.parent) == "table" then
|
flickerstreak@33
|
806 level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT")
|
flickerstreak@33
|
807 else
|
flickerstreak@33
|
808 level:SetPoint("CENTER", UIParent, "CENTER")
|
flickerstreak@33
|
809 end
|
flickerstreak@33
|
810 else
|
flickerstreak@33
|
811 if level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
812 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
813 level:SetPoint("TOPLEFT", level.parent, "TOPRIGHT", 5, 10)
|
flickerstreak@33
|
814 else
|
flickerstreak@33
|
815 level:SetPoint("BOTTOMLEFT", level.parent, "BOTTOMRIGHT", 5, -10)
|
flickerstreak@33
|
816 end
|
flickerstreak@33
|
817 else
|
flickerstreak@33
|
818 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
819 level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT", -5, 10)
|
flickerstreak@33
|
820 else
|
flickerstreak@33
|
821 level:SetPoint("BOTTOMRIGHT", level.parent, "BOTTOMLEFT", -5, -10)
|
flickerstreak@33
|
822 end
|
flickerstreak@33
|
823 end
|
flickerstreak@33
|
824 end
|
flickerstreak@33
|
825 level:SetFrameStrata("FULLSCREEN_DIALOG")
|
flickerstreak@33
|
826 end
|
flickerstreak@33
|
827 button:SetAlpha(1)
|
flickerstreak@33
|
828 return button
|
flickerstreak@33
|
829 end
|
flickerstreak@33
|
830
|
flickerstreak@33
|
831 local numLevels = 0
|
flickerstreak@33
|
832 local function AcquireLevel(self, level)
|
flickerstreak@33
|
833 if not levels[level] then
|
flickerstreak@33
|
834 for i = #levels + 1, level, -1 do
|
flickerstreak@33
|
835 local i = i
|
flickerstreak@33
|
836 numLevels = numLevels + 1
|
flickerstreak@33
|
837 local frame = CreateFrame("Button", "Dewdrop20Level" .. numLevels, nil)
|
flickerstreak@33
|
838 if i == 1 then
|
flickerstreak@33
|
839 local old_CloseSpecialWindows = CloseSpecialWindows
|
flickerstreak@33
|
840 function CloseSpecialWindows()
|
flickerstreak@33
|
841 local found = old_CloseSpecialWindows()
|
flickerstreak@33
|
842 if levels[1]:IsShown() then
|
flickerstreak@33
|
843 self:Close()
|
flickerstreak@33
|
844 return 1
|
flickerstreak@33
|
845 end
|
flickerstreak@33
|
846 return found
|
flickerstreak@33
|
847 end
|
flickerstreak@33
|
848 end
|
flickerstreak@33
|
849 levels[i] = frame
|
flickerstreak@33
|
850 frame.num = i
|
flickerstreak@33
|
851 frame:SetParent(UIParent)
|
flickerstreak@33
|
852 frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
flickerstreak@33
|
853 frame:Hide()
|
flickerstreak@33
|
854 frame:SetWidth(180)
|
flickerstreak@33
|
855 frame:SetHeight(10)
|
flickerstreak@33
|
856 frame:SetFrameLevel(i * 3)
|
flickerstreak@33
|
857 frame:SetScript("OnHide", function()
|
flickerstreak@33
|
858 self:Close(level + 1)
|
flickerstreak@33
|
859 end)
|
flickerstreak@33
|
860 if frame.SetTopLevel then
|
flickerstreak@33
|
861 frame:SetTopLevel(true)
|
flickerstreak@33
|
862 end
|
flickerstreak@33
|
863 frame:EnableMouse(true)
|
flickerstreak@33
|
864 frame:EnableMouseWheel(true)
|
flickerstreak@33
|
865 local backdrop = CreateFrame("Frame", nil, frame)
|
flickerstreak@33
|
866 backdrop:SetAllPoints(frame)
|
flickerstreak@33
|
867 backdrop:SetBackdrop(tmp(
|
flickerstreak@33
|
868 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
|
flickerstreak@33
|
869 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
|
flickerstreak@33
|
870 'tile', true,
|
flickerstreak@33
|
871 'insets', tmp2(
|
flickerstreak@33
|
872 'left', 5,
|
flickerstreak@33
|
873 'right', 5,
|
flickerstreak@33
|
874 'top', 5,
|
flickerstreak@33
|
875 'bottom', 5
|
flickerstreak@33
|
876 ),
|
flickerstreak@33
|
877 'tileSize', 16,
|
flickerstreak@33
|
878 'edgeSize', 16
|
flickerstreak@33
|
879 ))
|
flickerstreak@33
|
880 backdrop:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
|
flickerstreak@33
|
881 backdrop:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
|
flickerstreak@33
|
882 frame:SetScript("OnClick", function()
|
flickerstreak@33
|
883 self:Close(i)
|
flickerstreak@33
|
884 end)
|
flickerstreak@33
|
885 frame:SetScript("OnEnter", function()
|
flickerstreak@33
|
886 StopCounting(self, i)
|
flickerstreak@33
|
887 end)
|
flickerstreak@33
|
888 frame:SetScript("OnLeave", function()
|
flickerstreak@33
|
889 StartCounting(self, i)
|
flickerstreak@33
|
890 end)
|
flickerstreak@33
|
891 frame:SetScript("OnMouseWheel", function()
|
flickerstreak@33
|
892 Scroll(self, frame, arg1 < 0)
|
flickerstreak@33
|
893 end)
|
flickerstreak@33
|
894 if i == 1 then
|
flickerstreak@33
|
895 frame:SetScript("OnUpdate", function(this, arg1)
|
flickerstreak@33
|
896 OnUpdate(self, arg1)
|
flickerstreak@33
|
897 end)
|
flickerstreak@33
|
898 levels[1].lastDirection = "RIGHT"
|
flickerstreak@33
|
899 levels[1].lastVDirection = "DOWN"
|
flickerstreak@33
|
900 else
|
flickerstreak@33
|
901 levels[i].lastDirection = levels[i - 1].lastDirection
|
flickerstreak@33
|
902 levels[i].lastVDirection = levels[i - 1].lastVDirection
|
flickerstreak@33
|
903 end
|
flickerstreak@33
|
904 end
|
flickerstreak@33
|
905 end
|
flickerstreak@33
|
906 local fullscreenFrame = GetUIPanel("fullscreen")
|
flickerstreak@33
|
907 local l = levels[level]
|
flickerstreak@33
|
908 local strata, framelevel = l:GetFrameStrata(), l:GetFrameLevel()
|
flickerstreak@33
|
909 if fullscreenFrame then
|
flickerstreak@33
|
910 l:SetParent(fullscreenFrame)
|
flickerstreak@33
|
911 else
|
flickerstreak@33
|
912 l:SetParent(UIParent)
|
flickerstreak@33
|
913 end
|
flickerstreak@33
|
914 l:SetFrameStrata(strata)
|
flickerstreak@33
|
915 l:SetFrameLevel(framelevel)
|
flickerstreak@33
|
916 l:SetAlpha(1)
|
flickerstreak@33
|
917 return l
|
flickerstreak@33
|
918 end
|
flickerstreak@33
|
919
|
flickerstreak@33
|
920 local function validateOptions(options, position, baseOptions, fromPass)
|
flickerstreak@33
|
921 if not baseOptions then
|
flickerstreak@33
|
922 baseOptions = options
|
flickerstreak@33
|
923 end
|
flickerstreak@33
|
924 if type(options) ~= "table" then
|
flickerstreak@33
|
925 return "Options must be a table.", position
|
flickerstreak@33
|
926 end
|
flickerstreak@33
|
927 local kind = options.type
|
flickerstreak@33
|
928 if type(kind) ~= "string" then
|
flickerstreak@33
|
929 return '"type" must be a string.', position
|
flickerstreak@33
|
930 elseif kind ~= "group" and kind ~= "range" and kind ~= "text" and kind ~= "execute" and kind ~= "toggle" and kind ~= "color" and kind ~= "dragLink" and kind ~= "header" then
|
flickerstreak@33
|
931 return '"type" must either be "range", "text", "group", "toggle", "execute", "color", "dragLink", or "header".', position
|
flickerstreak@33
|
932 end
|
flickerstreak@33
|
933 if options.aliases then
|
flickerstreak@33
|
934 if type(options.aliases) ~= "table" and type(options.aliases) ~= "string" then
|
flickerstreak@33
|
935 return '"alias" must be a table or string', position
|
flickerstreak@33
|
936 end
|
flickerstreak@33
|
937 end
|
flickerstreak@33
|
938 if not fromPass then
|
flickerstreak@33
|
939 if kind == "execute" then
|
flickerstreak@33
|
940 if type(options.func) ~= "string" and type(options.func) ~= "function" then
|
flickerstreak@33
|
941 return '"func" must be a string or function', position
|
flickerstreak@33
|
942 end
|
flickerstreak@33
|
943 elseif kind == "range" or kind == "text" or kind == "toggle" then
|
flickerstreak@33
|
944 if type(options.set) ~= "string" and type(options.set) ~= "function" then
|
flickerstreak@33
|
945 return '"set" must be a string or function', position
|
flickerstreak@33
|
946 end
|
flickerstreak@33
|
947 if kind == "text" and options.get == false then
|
flickerstreak@33
|
948 elseif type(options.get) ~= "string" and type(options.get) ~= "function" then
|
flickerstreak@33
|
949 return '"get" must be a string or function', position
|
flickerstreak@33
|
950 end
|
flickerstreak@33
|
951 elseif kind == "group" and options.pass then
|
flickerstreak@33
|
952 if options.pass ~= true then
|
flickerstreak@33
|
953 return '"pass" must be either nil, true, or false', position
|
flickerstreak@33
|
954 end
|
flickerstreak@33
|
955 if not options.func then
|
flickerstreak@33
|
956 if type(options.set) ~= "string" and type(options.set) ~= "function" then
|
flickerstreak@33
|
957 return '"set" must be a string or function', position
|
flickerstreak@33
|
958 end
|
flickerstreak@33
|
959 if type(options.get) ~= "string" and type(options.get) ~= "function" then
|
flickerstreak@33
|
960 return '"get" must be a string or function', position
|
flickerstreak@33
|
961 end
|
flickerstreak@33
|
962 elseif type(options.func) ~= "string" and type(options.func) ~= "function" then
|
flickerstreak@33
|
963 return '"func" must be a string or function', position
|
flickerstreak@33
|
964 end
|
flickerstreak@33
|
965 end
|
flickerstreak@33
|
966 end
|
flickerstreak@33
|
967 if options ~= baseOptions then
|
flickerstreak@33
|
968 if kind == "header" then
|
flickerstreak@33
|
969 elseif type(options.desc) ~= "string" then
|
flickerstreak@33
|
970 return '"desc" must be a string', position
|
flickerstreak@33
|
971 elseif options.desc:len() == 0 then
|
flickerstreak@33
|
972 return '"desc" cannot be a 0-length string', position
|
flickerstreak@33
|
973 end
|
flickerstreak@33
|
974 end
|
flickerstreak@33
|
975 if options ~= baseOptions or kind == "range" or kind == "text" or kind == "toggle" or kind == "color" then
|
flickerstreak@33
|
976 if options.type == "header" and not options.cmdName and not options.name then
|
flickerstreak@33
|
977 elseif options.cmdName then
|
flickerstreak@33
|
978 if type(options.cmdName) ~= "string" then
|
flickerstreak@33
|
979 return '"cmdName" must be a string or nil', position
|
flickerstreak@33
|
980 elseif options.cmdName:len() == 0 then
|
flickerstreak@33
|
981 return '"cmdName" cannot be a 0-length string', position
|
flickerstreak@33
|
982 end
|
flickerstreak@33
|
983 if type(options.guiName) ~= "string" then
|
flickerstreak@33
|
984 if not options.guiNameIsMap then
|
flickerstreak@33
|
985 return '"guiName" must be a string or nil', position
|
flickerstreak@33
|
986 end
|
flickerstreak@33
|
987 elseif options.guiName:len() == 0 then
|
flickerstreak@33
|
988 return '"guiName" cannot be a 0-length string', position
|
flickerstreak@33
|
989 end
|
flickerstreak@33
|
990 else
|
flickerstreak@33
|
991 if type(options.name) ~= "string" then
|
flickerstreak@33
|
992 return '"name" must be a string', position
|
flickerstreak@33
|
993 elseif options.name:len() == 0 then
|
flickerstreak@33
|
994 return '"name" cannot be a 0-length string', position
|
flickerstreak@33
|
995 end
|
flickerstreak@33
|
996 end
|
flickerstreak@33
|
997 end
|
flickerstreak@33
|
998 if options.guiNameIsMap then
|
flickerstreak@33
|
999 if type(options.guiNameIsMap) ~= "boolean" then
|
flickerstreak@33
|
1000 return '"guiNameIsMap" must be a boolean or nil', position
|
flickerstreak@33
|
1001 elseif options.type ~= "toggle" then
|
flickerstreak@33
|
1002 return 'if "guiNameIsMap" is true, then "type" must be set to \'toggle\'', position
|
flickerstreak@33
|
1003 elseif type(options.map) ~= "table" then
|
flickerstreak@33
|
1004 return '"map" must be a table', position
|
flickerstreak@33
|
1005 end
|
flickerstreak@33
|
1006 end
|
flickerstreak@33
|
1007 if options.message and type(options.message) ~= "string" then
|
flickerstreak@33
|
1008 return '"message" must be a string or nil', position
|
flickerstreak@33
|
1009 end
|
flickerstreak@33
|
1010 if options.error and type(options.error) ~= "string" then
|
flickerstreak@33
|
1011 return '"error" must be a string or nil', position
|
flickerstreak@33
|
1012 end
|
flickerstreak@33
|
1013 if options.current and type(options.current) ~= "string" then
|
flickerstreak@33
|
1014 return '"current" must be a string or nil', position
|
flickerstreak@33
|
1015 end
|
flickerstreak@33
|
1016 if options.order then
|
flickerstreak@33
|
1017 if type(options.order) ~= "number" or (-1 < options.order and options.order < 0.999) then
|
flickerstreak@33
|
1018 return '"order" must be a non-zero number or nil', position
|
flickerstreak@33
|
1019 end
|
flickerstreak@33
|
1020 end
|
flickerstreak@33
|
1021 if options.disabled then
|
flickerstreak@33
|
1022 if type(options.disabled) ~= "function" and type(options.disabled) ~= "string" and options.disabled ~= true then
|
flickerstreak@33
|
1023 return '"disabled" must be a function, string, or boolean', position
|
flickerstreak@33
|
1024 end
|
flickerstreak@33
|
1025 end
|
flickerstreak@33
|
1026 if options.cmdHidden then
|
flickerstreak@33
|
1027 if type(options.cmdHidden) ~= "function" and type(options.cmdHidden) ~= "string" and options.cmdHidden ~= true then
|
flickerstreak@33
|
1028 return '"cmdHidden" must be a function, string, or boolean', position
|
flickerstreak@33
|
1029 end
|
flickerstreak@33
|
1030 end
|
flickerstreak@33
|
1031 if options.guiHidden then
|
flickerstreak@33
|
1032 if type(options.guiHidden) ~= "function" and type(options.guiHidden) ~= "string" and options.guiHidden ~= true then
|
flickerstreak@33
|
1033 return '"guiHidden" must be a function, string, or boolean', position
|
flickerstreak@33
|
1034 end
|
flickerstreak@33
|
1035 end
|
flickerstreak@33
|
1036 if options.hidden then
|
flickerstreak@33
|
1037 if type(options.hidden) ~= "function" and type(options.hidden) ~= "string" and options.hidden ~= true then
|
flickerstreak@33
|
1038 return '"hidden" must be a function, string, or boolean', position
|
flickerstreak@33
|
1039 end
|
flickerstreak@33
|
1040 end
|
flickerstreak@33
|
1041 if kind == "text" then
|
flickerstreak@33
|
1042 if type(options.validate) == "table" then
|
flickerstreak@33
|
1043 local t = options.validate
|
flickerstreak@33
|
1044 local iTable = nil
|
flickerstreak@33
|
1045 for k,v in pairs(t) do
|
flickerstreak@33
|
1046 if type(k) == "number" then
|
flickerstreak@33
|
1047 if iTable == nil then
|
flickerstreak@33
|
1048 iTable = true
|
flickerstreak@33
|
1049 elseif not iTable then
|
flickerstreak@33
|
1050 return '"validate" must either have all keys be indexed numbers or strings', position
|
flickerstreak@33
|
1051 elseif k < 1 or k > #t then
|
flickerstreak@33
|
1052 return '"validate" numeric keys must be indexed properly. >= 1 and <= #t', position
|
flickerstreak@33
|
1053 end
|
flickerstreak@33
|
1054 else
|
flickerstreak@33
|
1055 if iTable == nil then
|
flickerstreak@33
|
1056 iTable = false
|
flickerstreak@33
|
1057 elseif iTable then
|
flickerstreak@33
|
1058 return '"validate" must either have all keys be indexed numbers or strings', position
|
flickerstreak@33
|
1059 end
|
flickerstreak@33
|
1060 end
|
flickerstreak@33
|
1061 if type(v) ~= "string" then
|
flickerstreak@33
|
1062 return '"validate" values must all be strings', position
|
flickerstreak@33
|
1063 end
|
flickerstreak@33
|
1064 end
|
flickerstreak@33
|
1065 if options.multiToggle and options.multiToggle ~= true then
|
flickerstreak@33
|
1066 return '"multiToggle" must be a boolean or nil if "validate" is a table', position
|
flickerstreak@33
|
1067 end
|
flickerstreak@33
|
1068 elseif options.validate == "keybinding" then
|
flickerstreak@33
|
1069 -- no other checks
|
flickerstreak@33
|
1070 else
|
flickerstreak@33
|
1071 if type(options.usage) ~= "string" then
|
flickerstreak@33
|
1072 return '"usage" must be a string', position
|
flickerstreak@33
|
1073 elseif options.validate and type(options.validate) ~= "string" and type(options.validate) ~= "function" then
|
flickerstreak@33
|
1074 return '"validate" must be a string, function, or table', position
|
flickerstreak@33
|
1075 end
|
flickerstreak@33
|
1076 end
|
flickerstreak@33
|
1077 if options.multiToggle and type(options.validate) ~= "table" then
|
flickerstreak@33
|
1078 return '"validate" must be a table if "multiToggle" is true', position
|
flickerstreak@33
|
1079 end
|
flickerstreak@33
|
1080 elseif kind == "range" then
|
flickerstreak@33
|
1081 if options.min or options.max then
|
flickerstreak@33
|
1082 if type(options.min) ~= "number" then
|
flickerstreak@33
|
1083 return '"min" must be a number', position
|
flickerstreak@33
|
1084 elseif type(options.max) ~= "number" then
|
flickerstreak@33
|
1085 return '"max" must be a number', position
|
flickerstreak@33
|
1086 elseif options.min >= options.max then
|
flickerstreak@33
|
1087 return '"min" must be less than "max"', position
|
flickerstreak@33
|
1088 end
|
flickerstreak@33
|
1089 end
|
flickerstreak@33
|
1090 if options.step then
|
flickerstreak@33
|
1091 if type(options.step) ~= "number" then
|
flickerstreak@33
|
1092 return '"step" must be a number', position
|
flickerstreak@33
|
1093 elseif options.step < 0 then
|
flickerstreak@33
|
1094 return '"step" must be nonnegative', position
|
flickerstreak@33
|
1095 end
|
flickerstreak@33
|
1096 end
|
flickerstreak@33
|
1097 if options.bigStep then
|
flickerstreak@33
|
1098 if type(options.bigStep) ~= "number" then
|
flickerstreak@33
|
1099 return '"bigStep" must be a number', position
|
flickerstreak@33
|
1100 elseif options.bigStep < 0 then
|
flickerstreak@33
|
1101 return '"bigStep" must be nonnegative', position
|
flickerstreak@33
|
1102 end
|
flickerstreak@33
|
1103 end
|
flickerstreak@33
|
1104 if options.isPercent and options.isPercent ~= true then
|
flickerstreak@33
|
1105 return '"isPercent" must either be nil, true, or false', position
|
flickerstreak@33
|
1106 end
|
flickerstreak@33
|
1107 elseif kind == "toggle" then
|
flickerstreak@33
|
1108 if options.map then
|
flickerstreak@33
|
1109 if type(options.map) ~= "table" then
|
flickerstreak@33
|
1110 return '"map" must be a table', position
|
flickerstreak@33
|
1111 elseif type(options.map[true]) ~= "string" then
|
flickerstreak@33
|
1112 return '"map[true]" must be a string', position
|
flickerstreak@33
|
1113 elseif type(options.map[false]) ~= "string" then
|
flickerstreak@33
|
1114 return '"map[false]" must be a string', position
|
flickerstreak@33
|
1115 end
|
flickerstreak@33
|
1116 end
|
flickerstreak@33
|
1117 elseif kind == "color" then
|
flickerstreak@33
|
1118 if options.hasAlpha and options.hasAlpha ~= true then
|
flickerstreak@33
|
1119 return '"hasAlpha" must be nil, true, or false', position
|
flickerstreak@33
|
1120 end
|
flickerstreak@33
|
1121 elseif kind == "group" then
|
flickerstreak@33
|
1122 if options.pass and options.pass ~= true then
|
flickerstreak@33
|
1123 return '"pass" must be nil, true, or false', position
|
flickerstreak@33
|
1124 end
|
flickerstreak@33
|
1125 if type(options.args) ~= "table" then
|
flickerstreak@33
|
1126 return '"args" must be a table', position
|
flickerstreak@33
|
1127 end
|
flickerstreak@33
|
1128 for k,v in pairs(options.args) do
|
flickerstreak@33
|
1129 if type(k) ~= "number" then
|
flickerstreak@33
|
1130 if type(k) ~= "string" then
|
flickerstreak@33
|
1131 return '"args" keys must be strings or numbers', position
|
flickerstreak@33
|
1132 elseif k:len() == 0 then
|
flickerstreak@33
|
1133 return '"args" keys must not be 0-length strings.', position
|
flickerstreak@33
|
1134 end
|
flickerstreak@33
|
1135 end
|
flickerstreak@33
|
1136 if type(v) ~= "table" then
|
flickerstreak@33
|
1137 return '"args" values must be tables', position and position .. "." .. k or k
|
flickerstreak@33
|
1138 end
|
flickerstreak@33
|
1139 local newposition
|
flickerstreak@33
|
1140 if position then
|
flickerstreak@33
|
1141 newposition = position .. ".args." .. k
|
flickerstreak@33
|
1142 else
|
flickerstreak@33
|
1143 newposition = "args." .. k
|
flickerstreak@33
|
1144 end
|
flickerstreak@33
|
1145 local err, pos = validateOptions(v, newposition, baseOptions, options.pass)
|
flickerstreak@33
|
1146 if err then
|
flickerstreak@33
|
1147 return err, pos
|
flickerstreak@33
|
1148 end
|
flickerstreak@33
|
1149 end
|
flickerstreak@33
|
1150 elseif kind == "execute" then
|
flickerstreak@33
|
1151 if type(options.confirm) ~= "string" and type(options.confirm) ~= "boolean" and type(options.confirm) ~= "nil" then
|
flickerstreak@33
|
1152 return '"confirm" must be a string, boolean, or nil', position
|
flickerstreak@33
|
1153 end
|
flickerstreak@33
|
1154 end
|
flickerstreak@33
|
1155 if options.icon and type(options.icon) ~= "string" then
|
flickerstreak@33
|
1156 return'"icon" must be a string', position
|
flickerstreak@33
|
1157 end
|
flickerstreak@33
|
1158 if options.iconWidth or options.iconHeight then
|
flickerstreak@33
|
1159 if type(options.iconWidth) ~= "number" or type(options.iconHeight) ~= "number" then
|
flickerstreak@33
|
1160 return '"iconHeight" and "iconWidth" must be numbers', position
|
flickerstreak@33
|
1161 end
|
flickerstreak@33
|
1162 end
|
flickerstreak@33
|
1163 if options.iconCoordLeft or options.iconCoordRight or options.iconCoordTop or options.iconCoordBottom then
|
flickerstreak@33
|
1164 if type(options.iconCoordLeft) ~= "number" or type(options.iconCoordRight) ~= "number" or type(options.iconCoordTop) ~= "number" or type(options.iconCoordBottom) ~= "number" then
|
flickerstreak@33
|
1165 return '"iconCoordLeft", "iconCoordRight", "iconCoordTop", and "iconCoordBottom" must be numbers', position
|
flickerstreak@33
|
1166 end
|
flickerstreak@33
|
1167 end
|
flickerstreak@33
|
1168 end
|
flickerstreak@33
|
1169
|
flickerstreak@33
|
1170 local validatedOptions
|
flickerstreak@33
|
1171
|
flickerstreak@33
|
1172 local values
|
flickerstreak@33
|
1173 local mysort_args
|
flickerstreak@33
|
1174 local mysort
|
flickerstreak@33
|
1175 local othersort
|
flickerstreak@33
|
1176 local othersort_validate
|
flickerstreak@33
|
1177
|
flickerstreak@33
|
1178 local baseFunc, currentLevel
|
flickerstreak@33
|
1179
|
flickerstreak@33
|
1180 local function confirmPopup(message, func, ...)
|
flickerstreak@33
|
1181 if not StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] then
|
flickerstreak@33
|
1182 StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] = {}
|
flickerstreak@33
|
1183 end
|
flickerstreak@33
|
1184 local t = StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"]
|
flickerstreak@33
|
1185 for k in pairs(t) do
|
flickerstreak@33
|
1186 t[k] = nil
|
flickerstreak@33
|
1187 end
|
flickerstreak@33
|
1188 t.text = message
|
flickerstreak@33
|
1189 t.button1 = ACCEPT or "Accept"
|
flickerstreak@33
|
1190 t.button2 = CANCEL or "Cancel"
|
flickerstreak@33
|
1191 t.OnAccept = function()
|
flickerstreak@33
|
1192 func(unpack(t))
|
flickerstreak@33
|
1193 end
|
flickerstreak@33
|
1194 for i = 1, select('#', ...) do
|
flickerstreak@33
|
1195 t[i] = select(i, ...)
|
flickerstreak@33
|
1196 end
|
flickerstreak@33
|
1197 t.timeout = 0
|
flickerstreak@33
|
1198 t.whileDead = 1
|
flickerstreak@33
|
1199 t.hideOnEscape = 1
|
flickerstreak@33
|
1200
|
flickerstreak@33
|
1201 Dewdrop:Close()
|
flickerstreak@33
|
1202 StaticPopup_Show("DEWDROP20_CONFIRM_DIALOG")
|
flickerstreak@33
|
1203 end
|
flickerstreak@33
|
1204
|
flickerstreak@33
|
1205
|
flickerstreak@33
|
1206 local function getMethod(settingname, handler, v, methodName, ...) -- "..." is simply returned straight out cause you can't do "a,b,c = 111,f(),222"
|
flickerstreak@33
|
1207 assert(v and type(v)=="table")
|
flickerstreak@33
|
1208 assert(methodName and type(methodName)=="string")
|
flickerstreak@33
|
1209
|
flickerstreak@33
|
1210 local method = v[methodName]
|
flickerstreak@33
|
1211 if type(method)=="function" then
|
flickerstreak@33
|
1212 return method, ...
|
flickerstreak@33
|
1213 elseif type(method)=="string" then
|
flickerstreak@33
|
1214 if not handler then
|
flickerstreak@33
|
1215 Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method)
|
flickerstreak@33
|
1216 elseif not handler[method] then
|
flickerstreak@33
|
1217 Dewdrop:error("[%s] 'handler' method %q not defined", tostring(settingname), method)
|
flickerstreak@33
|
1218 end
|
flickerstreak@33
|
1219 return handler[method], handler, ...
|
flickerstreak@33
|
1220 end
|
flickerstreak@33
|
1221
|
flickerstreak@33
|
1222 Dewdrop:error("[%s] Missing %q directive", tostring(settingname), methodName)
|
flickerstreak@33
|
1223 end
|
flickerstreak@33
|
1224
|
flickerstreak@33
|
1225 local function callMethod(settingname, handler, v, methodName, ...)
|
flickerstreak@33
|
1226 assert(v and type(v)=="table")
|
flickerstreak@33
|
1227 assert(methodName and type(methodName)=="string")
|
flickerstreak@33
|
1228
|
flickerstreak@33
|
1229 local method = v[methodName]
|
flickerstreak@33
|
1230 if type(method)=="function" then
|
flickerstreak@33
|
1231 local success, ret,ret2,ret3,ret4 = pcall(v[methodName], ...)
|
flickerstreak@33
|
1232 if not success then
|
flickerstreak@33
|
1233 geterrorhandler()(ret)
|
flickerstreak@33
|
1234 return nil
|
flickerstreak@33
|
1235 end
|
flickerstreak@33
|
1236 return ret,ret2,ret3,ret4
|
flickerstreak@33
|
1237
|
flickerstreak@33
|
1238 elseif type(method)=="string" then
|
flickerstreak@33
|
1239
|
flickerstreak@33
|
1240 local neg = method:match("^~(.-)$")
|
flickerstreak@33
|
1241 if neg then
|
flickerstreak@33
|
1242 method = neg
|
flickerstreak@33
|
1243 end
|
flickerstreak@33
|
1244 if not handler then
|
flickerstreak@33
|
1245 Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method)
|
flickerstreak@33
|
1246 elseif not handler[method] then
|
flickerstreak@33
|
1247 Dewdrop:error("[%s] 'handler' (%q) method %q not defined", tostring(settingname), handler.name or "(unnamed)", method)
|
flickerstreak@33
|
1248 end
|
flickerstreak@33
|
1249 local success, ret,ret2,ret3,ret4 = pcall(handler[method], handler, ...)
|
flickerstreak@33
|
1250 if not success then
|
flickerstreak@33
|
1251 geterrorhandler()(ret)
|
flickerstreak@33
|
1252 return nil
|
flickerstreak@33
|
1253 end
|
flickerstreak@33
|
1254 if neg then
|
flickerstreak@33
|
1255 return not ret
|
flickerstreak@33
|
1256 end
|
flickerstreak@33
|
1257 return ret,ret2,ret3,ret4
|
flickerstreak@33
|
1258 elseif method == false then
|
flickerstreak@33
|
1259 return nil
|
flickerstreak@33
|
1260 end
|
flickerstreak@33
|
1261
|
flickerstreak@33
|
1262 Dewdrop:error("[%s] Missing %q directive in %q", tostring(settingname), methodName, v.name or "(unnamed)")
|
flickerstreak@33
|
1263 end
|
flickerstreak@33
|
1264
|
flickerstreak@33
|
1265 local function skip1Nil(...)
|
flickerstreak@33
|
1266 if select(1,...)==nil then
|
flickerstreak@33
|
1267 return select(2,...)
|
flickerstreak@33
|
1268 end
|
flickerstreak@33
|
1269 return ...
|
flickerstreak@33
|
1270 end
|
flickerstreak@33
|
1271
|
flickerstreak@33
|
1272 function Dewdrop:FeedAceOptionsTable(options, difference)
|
flickerstreak@33
|
1273 self:argCheck(options, 2, "table")
|
flickerstreak@33
|
1274 self:argCheck(difference, 3, "nil", "number")
|
flickerstreak@33
|
1275 if not currentLevel then
|
flickerstreak@33
|
1276 self:error("Cannot call `FeedAceOptionsTable' outside of a Dewdrop declaration")
|
flickerstreak@33
|
1277 end
|
flickerstreak@33
|
1278 if not difference then
|
flickerstreak@33
|
1279 difference = 0
|
flickerstreak@33
|
1280 end
|
flickerstreak@33
|
1281 if not validatedOptions then
|
flickerstreak@33
|
1282 validatedOptions = {}
|
flickerstreak@33
|
1283 end
|
flickerstreak@33
|
1284 if not validatedOptions[options] then
|
flickerstreak@33
|
1285 local err, position = validateOptions(options)
|
flickerstreak@33
|
1286
|
flickerstreak@33
|
1287 if err then
|
flickerstreak@33
|
1288 if position then
|
flickerstreak@33
|
1289 Dewdrop:error(position .. ": " .. err)
|
flickerstreak@33
|
1290 else
|
flickerstreak@33
|
1291 Dewdrop:error(err)
|
flickerstreak@33
|
1292 end
|
flickerstreak@33
|
1293 end
|
flickerstreak@33
|
1294
|
flickerstreak@33
|
1295 validatedOptions[options] = true
|
flickerstreak@33
|
1296 end
|
flickerstreak@33
|
1297 local level = levels[currentLevel]
|
flickerstreak@33
|
1298 if not level then
|
flickerstreak@33
|
1299 self:error("Improper level given")
|
flickerstreak@33
|
1300 end
|
flickerstreak@33
|
1301 if not values then
|
flickerstreak@33
|
1302 values = {}
|
flickerstreak@33
|
1303 else
|
flickerstreak@33
|
1304 for k,v in pairs(values) do
|
flickerstreak@33
|
1305 values[k] = nil
|
flickerstreak@33
|
1306 end
|
flickerstreak@33
|
1307 end
|
flickerstreak@33
|
1308
|
flickerstreak@33
|
1309 local current = level
|
flickerstreak@33
|
1310 while current do -- this traverses from higher level numbers to lower, building "values" with leaf nodes first and trunk nodes later
|
flickerstreak@33
|
1311 if current.num == difference + 1 then
|
flickerstreak@33
|
1312 break
|
flickerstreak@33
|
1313 end
|
flickerstreak@33
|
1314 table.insert(values, current.value)
|
flickerstreak@33
|
1315 current = levels[current.num - 1]
|
flickerstreak@33
|
1316 end
|
flickerstreak@33
|
1317
|
flickerstreak@33
|
1318 local realOptions = options
|
flickerstreak@33
|
1319 local handler = options.handler
|
flickerstreak@33
|
1320 local passTable
|
flickerstreak@33
|
1321 local passValue
|
flickerstreak@33
|
1322 while #values > 0 do -- This loop traverses values from the END (trunk nodes first, then onto leaf nodes)
|
flickerstreak@33
|
1323 if options.pass then
|
flickerstreak@33
|
1324 if options.get and options.set then
|
flickerstreak@33
|
1325 passTable = options
|
flickerstreak@33
|
1326 elseif not passTable then
|
flickerstreak@33
|
1327 passTable = options
|
flickerstreak@33
|
1328 end
|
flickerstreak@33
|
1329 else
|
flickerstreak@33
|
1330 passTable = nil
|
flickerstreak@33
|
1331 end
|
flickerstreak@33
|
1332 local value = table.remove(values)
|
flickerstreak@33
|
1333 options = options.args and options.args[value]
|
flickerstreak@33
|
1334 if not options then
|
flickerstreak@33
|
1335 return
|
flickerstreak@33
|
1336 end
|
flickerstreak@33
|
1337 handler = options.handler or handler
|
flickerstreak@33
|
1338 passValue = passTable and value or nil
|
flickerstreak@33
|
1339 end
|
flickerstreak@33
|
1340
|
flickerstreak@33
|
1341 if options.type == "group" then
|
flickerstreak@33
|
1342 local hidden = options.hidden
|
flickerstreak@33
|
1343 if type(hidden) == "function" or type(hidden) == "string" then
|
flickerstreak@33
|
1344 hidden = callMethod(options.name or "(options root)", handler, options, "hidden", options.passValue) or false
|
flickerstreak@33
|
1345 end
|
flickerstreak@33
|
1346 if hidden then
|
flickerstreak@33
|
1347 return
|
flickerstreak@33
|
1348 end
|
flickerstreak@33
|
1349 local disabled = options.disabled
|
flickerstreak@33
|
1350 if type(disabled) == "function" or type(disabled) == "string" then
|
flickerstreak@33
|
1351 disabled = callMethod(options.name or "(options root)", handler, options, "disabled", options.passValue) or false
|
flickerstreak@33
|
1352 end
|
flickerstreak@33
|
1353 if disabled then
|
flickerstreak@33
|
1354 self:AddLine(
|
flickerstreak@33
|
1355 'text', DISABLED,
|
flickerstreak@33
|
1356 'disabled', true
|
flickerstreak@33
|
1357 )
|
flickerstreak@33
|
1358 return
|
flickerstreak@33
|
1359 end
|
flickerstreak@33
|
1360 for k in pairs(options.args) do
|
flickerstreak@33
|
1361 table.insert(values, k)
|
flickerstreak@33
|
1362 end
|
flickerstreak@33
|
1363 if options.pass then
|
flickerstreak@33
|
1364 if options.get and options.set then
|
flickerstreak@33
|
1365 passTable = options
|
flickerstreak@33
|
1366 elseif not passTable then
|
flickerstreak@33
|
1367 passTable = options
|
flickerstreak@33
|
1368 end
|
flickerstreak@33
|
1369 else
|
flickerstreak@33
|
1370 passTable = nil
|
flickerstreak@33
|
1371 end
|
flickerstreak@33
|
1372 if not mysort then
|
flickerstreak@33
|
1373 mysort = function(a, b)
|
flickerstreak@33
|
1374 local alpha, bravo = mysort_args[a], mysort_args[b]
|
flickerstreak@33
|
1375 local alpha_order = alpha.order or 100
|
flickerstreak@33
|
1376 local bravo_order = bravo.order or 100
|
flickerstreak@33
|
1377 local alpha_name = alpha.guiName or alpha.name
|
flickerstreak@33
|
1378 local bravo_name = bravo.guiName or bravo.name
|
flickerstreak@33
|
1379 if alpha_order == bravo_order then
|
flickerstreak@33
|
1380 if not alpha_name then
|
flickerstreak@33
|
1381 return bravo_name
|
flickerstreak@33
|
1382 elseif not bravo_name then
|
flickerstreak@33
|
1383 return false
|
flickerstreak@33
|
1384 else
|
flickerstreak@33
|
1385 return alpha_name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() < bravo_name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper()
|
flickerstreak@33
|
1386 end
|
flickerstreak@33
|
1387 else
|
flickerstreak@33
|
1388 if alpha_order < 0 then
|
flickerstreak@33
|
1389 if bravo_order > 0 then
|
flickerstreak@33
|
1390 return false
|
flickerstreak@33
|
1391 end
|
flickerstreak@33
|
1392 else
|
flickerstreak@33
|
1393 if bravo_order < 0 then
|
flickerstreak@33
|
1394 return true
|
flickerstreak@33
|
1395 end
|
flickerstreak@33
|
1396 end
|
flickerstreak@33
|
1397 return alpha_order < bravo_order
|
flickerstreak@33
|
1398 end
|
flickerstreak@33
|
1399 end
|
flickerstreak@33
|
1400 end
|
flickerstreak@33
|
1401 mysort_args = options.args
|
flickerstreak@33
|
1402 table.sort(values, mysort)
|
flickerstreak@33
|
1403 mysort_args = nil
|
flickerstreak@33
|
1404 local hasBoth = #values >= 1 and (options.args[values[1]].order or 100) > 0 and (options.args[values[#values]].order or 100) < 0
|
flickerstreak@33
|
1405 local last_order = 1
|
flickerstreak@33
|
1406 for _,k in ipairs(values) do
|
flickerstreak@33
|
1407 local v = options.args[k]
|
flickerstreak@33
|
1408 local handler = v.handler or handler
|
flickerstreak@33
|
1409 if hasBoth and last_order > 0 and (v.order or 100) < 0 then
|
flickerstreak@33
|
1410 hasBoth = false
|
flickerstreak@33
|
1411 self:AddLine()
|
flickerstreak@33
|
1412 end
|
flickerstreak@33
|
1413 local hidden, disabled = v.guiHidden or v.hidden, v.disabled
|
flickerstreak@33
|
1414
|
flickerstreak@33
|
1415 if type(hidden) == "function" or type(hidden) == "string" then
|
flickerstreak@33
|
1416 hidden = callMethod(k, handler, v, "hidden", v.passValue) or false
|
flickerstreak@33
|
1417 end
|
flickerstreak@33
|
1418 if not hidden then
|
flickerstreak@33
|
1419 if type(disabled) == "function" or type(disabled) == "string" then
|
flickerstreak@33
|
1420 disabled = callMethod(k, handler, v, "disabled", v.passValue) or false
|
flickerstreak@33
|
1421 end
|
flickerstreak@33
|
1422 local name = (v.guiIconOnly and v.icon) and "" or (v.guiName or v.name)
|
flickerstreak@33
|
1423 local desc = v.guiDesc or v.desc
|
flickerstreak@33
|
1424 local iconHeight = v.iconHeight or 16
|
flickerstreak@33
|
1425 local iconWidth = v.iconWidth or 16
|
flickerstreak@33
|
1426 local iconCoordLeft = v.iconCoordLeft
|
flickerstreak@33
|
1427 local iconCoordRight = v.iconCoordRight
|
flickerstreak@33
|
1428 local iconCoordBottom = v.iconCoordBottom
|
flickerstreak@33
|
1429 local iconCoordTop = v.iconCoordTop
|
flickerstreak@33
|
1430 local tooltipTitle, tooltipText
|
flickerstreak@33
|
1431 tooltipTitle = name
|
flickerstreak@33
|
1432 if name ~= desc then
|
flickerstreak@33
|
1433 tooltipText = desc
|
flickerstreak@33
|
1434 end
|
flickerstreak@33
|
1435 if type(v.usage) == "string" and v.usage:trim():len() > 0 then
|
flickerstreak@33
|
1436 if tooltipText then
|
flickerstreak@33
|
1437 tooltipText = tooltipText .. "\n\n" .. USAGE_TOOLTIP:format(v.usage)
|
flickerstreak@33
|
1438 else
|
flickerstreak@33
|
1439 tooltipText = USAGE_TOOLTIP:format(v.usage)
|
flickerstreak@33
|
1440 end
|
flickerstreak@33
|
1441 end
|
flickerstreak@33
|
1442 local v_p = passTable
|
flickerstreak@33
|
1443 if not v_p or (v.type ~= "execute" and v.get and v.set) or (v.type == "execute" and v.func) then
|
flickerstreak@33
|
1444 v_p = v
|
flickerstreak@33
|
1445 end
|
flickerstreak@33
|
1446 local passValue = v.passValue or (v_p~=v and k) or nil
|
flickerstreak@33
|
1447 if v.type == "toggle" then
|
flickerstreak@33
|
1448 local checked = callMethod(name, handler, v_p, "get", passValue) or false
|
flickerstreak@33
|
1449 local checked_arg = checked
|
flickerstreak@33
|
1450 if type(v_p.get)=="string" and v_p.get:match("^~") then
|
flickerstreak@33
|
1451 checked_arg = not checked
|
flickerstreak@33
|
1452 end
|
flickerstreak@33
|
1453 local func, arg1, arg2, arg3 = getMethod(name, handler, v_p, "set", skip1Nil(passValue, not checked_arg))
|
flickerstreak@33
|
1454 if v.guiNameIsMap then
|
flickerstreak@33
|
1455 checked = checked and true or false
|
flickerstreak@33
|
1456 name = tostring(v.map and v.map[checked]):gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
|
flickerstreak@33
|
1457 tooltipTitle = name
|
flickerstreak@33
|
1458 checked = true--nil
|
flickerstreak@33
|
1459 end
|
flickerstreak@33
|
1460 self:AddLine(
|
flickerstreak@33
|
1461 'text', name,
|
flickerstreak@33
|
1462 'checked', checked,
|
flickerstreak@33
|
1463 'isRadio', v.isRadio,
|
flickerstreak@33
|
1464 'func', func,
|
flickerstreak@33
|
1465 'arg1', arg1,
|
flickerstreak@33
|
1466 'arg2', arg2,
|
flickerstreak@33
|
1467 'arg3', arg3,
|
flickerstreak@33
|
1468 'disabled', disabled,
|
flickerstreak@33
|
1469 'tooltipTitle', tooltipTitle,
|
flickerstreak@33
|
1470 'tooltipText', tooltipText
|
flickerstreak@33
|
1471 )
|
flickerstreak@33
|
1472 elseif v.type == "execute" then
|
flickerstreak@33
|
1473 local func, arg1, arg2, arg3, arg4
|
flickerstreak@33
|
1474 local confirm = v.confirm
|
flickerstreak@33
|
1475 if confirm == true then
|
flickerstreak@33
|
1476 confirm = DEFAULT_CONFIRM_MESSAGE:format(tooltipText or tooltipTitle)
|
flickerstreak@33
|
1477 func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue)
|
flickerstreak@33
|
1478 elseif type(confirm) == "string" then
|
flickerstreak@33
|
1479 func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue)
|
flickerstreak@33
|
1480 else
|
flickerstreak@33
|
1481 func,arg1,arg2 = getMethod(name, handler, v_p, "func", passValue)
|
flickerstreak@33
|
1482 end
|
flickerstreak@33
|
1483 self:AddLine(
|
flickerstreak@33
|
1484 'text', name,
|
flickerstreak@33
|
1485 'checked', checked,
|
flickerstreak@33
|
1486 'func', func,
|
flickerstreak@33
|
1487 'arg1', arg1,
|
flickerstreak@33
|
1488 'arg2', arg2,
|
flickerstreak@33
|
1489 'arg3', arg3,
|
flickerstreak@33
|
1490 'arg4', arg4,
|
flickerstreak@33
|
1491 'disabled', disabled,
|
flickerstreak@33
|
1492 'tooltipTitle', tooltipTitle,
|
flickerstreak@33
|
1493 'tooltipText', tooltipText,
|
flickerstreak@33
|
1494 'icon', v.icon,
|
flickerstreak@33
|
1495 'iconHeight', iconHeight,
|
flickerstreak@33
|
1496 'iconWidth', iconWidth,
|
flickerstreak@33
|
1497 'iconCoordLeft', iconCoordLeft,
|
flickerstreak@33
|
1498 'iconCoordRight', iconCoordRight,
|
flickerstreak@33
|
1499 'iconCoordTop', iconCoordTop,
|
flickerstreak@33
|
1500 'iconCoordBottom', iconCoordBottom
|
flickerstreak@33
|
1501 )
|
flickerstreak@33
|
1502 elseif v.type == "range" then
|
flickerstreak@33
|
1503 local sliderValue
|
flickerstreak@33
|
1504 sliderValue = callMethod(name, handler, v_p, "get", passValue) or 0
|
flickerstreak@33
|
1505 local sliderFunc, sliderArg1, sliderArg2 = getMethod(name, handler, v_p, "set", passValue)
|
flickerstreak@33
|
1506 if tooltipText then
|
flickerstreak@33
|
1507 tooltipText = format("%s\n\n%s", tooltipText, RANGE_TOOLTIP)
|
flickerstreak@33
|
1508 else
|
flickerstreak@33
|
1509 tooltipText = RANGE_TOOLTIP
|
flickerstreak@33
|
1510 end
|
flickerstreak@33
|
1511 self:AddLine(
|
flickerstreak@33
|
1512 'text', name,
|
flickerstreak@33
|
1513 'hasArrow', true,
|
flickerstreak@33
|
1514 'hasSlider', true,
|
flickerstreak@33
|
1515 'sliderMin', v.min or 0,
|
flickerstreak@33
|
1516 'sliderMax', v.max or 1,
|
flickerstreak@33
|
1517 'sliderStep', v.step or 0,
|
flickerstreak@33
|
1518 'sliderBigStep', v.bigStep or nil,
|
flickerstreak@33
|
1519 'sliderIsPercent', v.isPercent or false,
|
flickerstreak@33
|
1520 'sliderValue', sliderValue,
|
flickerstreak@33
|
1521 'sliderFunc', sliderFunc,
|
flickerstreak@33
|
1522 'sliderArg1', sliderArg1,
|
flickerstreak@33
|
1523 'sliderArg2', sliderArg2,
|
flickerstreak@33
|
1524 'fromAceOptions', true,
|
flickerstreak@33
|
1525 'disabled', disabled,
|
flickerstreak@33
|
1526 'tooltipTitle', tooltipTitle,
|
flickerstreak@33
|
1527 'tooltipText', tooltipText,
|
flickerstreak@33
|
1528 'icon', v.icon,
|
flickerstreak@33
|
1529 'iconHeight', iconHeight,
|
flickerstreak@33
|
1530 'iconWidth', iconWidth,
|
flickerstreak@33
|
1531 'iconCoordLeft', iconCoordLeft,
|
flickerstreak@33
|
1532 'iconCoordRight', iconCoordRight,
|
flickerstreak@33
|
1533 'iconCoordTop', iconCoordTop,
|
flickerstreak@33
|
1534 'iconCoordBottom', iconCoordBottom
|
flickerstreak@33
|
1535 )
|
flickerstreak@33
|
1536 elseif v.type == "color" then
|
flickerstreak@33
|
1537 local r,g,b,a = callMethod(name, handler, v_p, "get", passValue)
|
flickerstreak@33
|
1538 if not r then
|
flickerstreak@33
|
1539 r,g,b,a = 0,0,0,0
|
flickerstreak@33
|
1540 end
|
flickerstreak@33
|
1541 local colorFunc, colorArg1, colorArg2 = getMethod(name, handler, v_p, "set", passValue)
|
flickerstreak@33
|
1542 self:AddLine(
|
flickerstreak@33
|
1543 'text', name,
|
flickerstreak@33
|
1544 'hasArrow', true,
|
flickerstreak@33
|
1545 'hasColorSwatch', true,
|
flickerstreak@33
|
1546 'r', r,
|
flickerstreak@33
|
1547 'g', g,
|
flickerstreak@33
|
1548 'b', b,
|
flickerstreak@33
|
1549 'opacity', v.hasAlpha and a or nil,
|
flickerstreak@33
|
1550 'hasOpacity', v.hasAlpha,
|
flickerstreak@33
|
1551 'colorFunc', colorFunc,
|
flickerstreak@33
|
1552 'colorArg1', colorArg1,
|
flickerstreak@33
|
1553 'colorArg2', colorArg2,
|
flickerstreak@33
|
1554 'disabled', disabled,
|
flickerstreak@33
|
1555 'tooltipTitle', tooltipTitle,
|
flickerstreak@33
|
1556 'tooltipText', tooltipText
|
flickerstreak@33
|
1557 )
|
flickerstreak@33
|
1558 elseif v.type == "text" then
|
flickerstreak@33
|
1559 if type(v.validate) == "table" then
|
flickerstreak@33
|
1560 local func,arg1,arg2
|
flickerstreak@33
|
1561 if v.onClick then
|
flickerstreak@33
|
1562 func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue)
|
flickerstreak@33
|
1563 end
|
flickerstreak@33
|
1564 local checked
|
flickerstreak@33
|
1565 if v.isChecked then
|
flickerstreak@33
|
1566 checked = callMethod(name, handler, v, "isChecked", passValue) or false
|
flickerstreak@33
|
1567 end
|
flickerstreak@33
|
1568 self:AddLine(
|
flickerstreak@33
|
1569 'text', name,
|
flickerstreak@33
|
1570 'hasArrow', true,
|
flickerstreak@33
|
1571 'value', k,
|
flickerstreak@33
|
1572 'func', func,
|
flickerstreak@33
|
1573 'arg1', arg1,
|
flickerstreak@33
|
1574 'arg2', arg2,
|
flickerstreak@33
|
1575 'mouseoverUnderline', func and true or nil,
|
flickerstreak@33
|
1576 'disabled', disabled,
|
flickerstreak@33
|
1577 'checked', checked,
|
flickerstreak@33
|
1578 'tooltipTitle', tooltipTitle,
|
flickerstreak@33
|
1579 'tooltipText', tooltipText,
|
flickerstreak@33
|
1580 'icon', v.icon,
|
flickerstreak@33
|
1581 'iconHeight', iconHeight,
|
flickerstreak@33
|
1582 'iconWidth', iconWidth,
|
flickerstreak@33
|
1583 'iconCoordLeft', iconCoordLeft,
|
flickerstreak@33
|
1584 'iconCoordRight', iconCoordRight,
|
flickerstreak@33
|
1585 'iconCoordTop', iconCoordTop,
|
flickerstreak@33
|
1586 'iconCoordBottom', iconCoordBottom
|
flickerstreak@33
|
1587 )
|
flickerstreak@33
|
1588 else
|
flickerstreak@33
|
1589 local editBoxText
|
flickerstreak@33
|
1590 editBoxText = callMethod(name, handler, v_p, "get", passValue) or ""
|
flickerstreak@33
|
1591 local editBoxFunc, editBoxArg1, editBoxArg2 = getMethod(name, handler, v_p, "set", passValue)
|
flickerstreak@33
|
1592
|
flickerstreak@33
|
1593 local editBoxValidateFunc, editBoxValidateArg1
|
flickerstreak@33
|
1594
|
flickerstreak@33
|
1595 if v.validate and v.validate ~= "keybinding" then
|
flickerstreak@33
|
1596 if v.validate == "keybinding" then
|
flickerstreak@33
|
1597 if tooltipText then
|
flickerstreak@33
|
1598 tooltipText = format("%s\n\n%s", tooltipText, RESET_KEYBINDING_DESC)
|
flickerstreak@33
|
1599 else
|
flickerstreak@33
|
1600 tooltipText = RESET_KEYBINDING_DESC
|
flickerstreak@33
|
1601 end
|
flickerstreak@33
|
1602 else
|
flickerstreak@33
|
1603 editBoxValidateFunc, editBoxValidateArg1 = getMethod(name, handler, v, "validate") -- no passvalue!
|
flickerstreak@33
|
1604 end
|
flickerstreak@33
|
1605 end
|
flickerstreak@33
|
1606
|
flickerstreak@33
|
1607 self:AddLine(
|
flickerstreak@33
|
1608 'text', name,
|
flickerstreak@33
|
1609 'hasArrow', true,
|
flickerstreak@33
|
1610 'icon', v.icon,
|
flickerstreak@33
|
1611 'iconHeight', iconHeight,
|
flickerstreak@33
|
1612 'iconWidth', iconWidth,
|
flickerstreak@33
|
1613 'iconCoordLeft', iconCoordLeft,
|
flickerstreak@33
|
1614 'iconCoordRight', iconCoordRight,
|
flickerstreak@33
|
1615 'iconCoordTop', iconCoordTop,
|
flickerstreak@33
|
1616 'iconCoordBottom', iconCoordBottom,
|
flickerstreak@33
|
1617 'hasEditBox', true,
|
flickerstreak@33
|
1618 'editBoxText', editBoxText,
|
flickerstreak@33
|
1619 'editBoxFunc', editBoxFunc,
|
flickerstreak@33
|
1620 'editBoxArg1', editBoxArg1,
|
flickerstreak@33
|
1621 'editBoxArg2', editBoxArg2,
|
flickerstreak@33
|
1622 'editBoxValidateFunc', editBoxValidateFunc,
|
flickerstreak@33
|
1623 'editBoxValidateArg1', editBoxValidateArg1,
|
flickerstreak@33
|
1624 'editBoxIsKeybinding', v.validate == "keybinding",
|
flickerstreak@33
|
1625 'editBoxKeybindingOnly', v.keybindingOnly,
|
flickerstreak@33
|
1626 'editBoxKeybindingExcept', v.keybindingExcept,
|
flickerstreak@33
|
1627 'disabled', disabled,
|
flickerstreak@33
|
1628 'tooltipTitle', tooltipTitle,
|
flickerstreak@33
|
1629 'tooltipText', tooltipText
|
flickerstreak@33
|
1630 )
|
flickerstreak@33
|
1631 end
|
flickerstreak@33
|
1632 elseif v.type == "group" then
|
flickerstreak@33
|
1633 local func,arg1,arg2
|
flickerstreak@33
|
1634 if v.onClick then
|
flickerstreak@33
|
1635 func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue)
|
flickerstreak@33
|
1636 end
|
flickerstreak@33
|
1637 local checked
|
flickerstreak@33
|
1638 if v.isChecked then
|
flickerstreak@33
|
1639 checked = callMethod(name, handler, v, "isChecked", passValue) or false
|
flickerstreak@33
|
1640 end
|
flickerstreak@33
|
1641 self:AddLine(
|
flickerstreak@33
|
1642 'text', name,
|
flickerstreak@33
|
1643 'hasArrow', true,
|
flickerstreak@33
|
1644 'value', k,
|
flickerstreak@33
|
1645 'func', func,
|
flickerstreak@33
|
1646 'arg1', arg1,
|
flickerstreak@33
|
1647 'arg2', arg2,
|
flickerstreak@33
|
1648 'mouseoverUnderline', func and true or nil,
|
flickerstreak@33
|
1649 'disabled', disabled,
|
flickerstreak@33
|
1650 'checked', checked,
|
flickerstreak@33
|
1651 'tooltipTitle', tooltipTitle,
|
flickerstreak@33
|
1652 'tooltipText', tooltipText,
|
flickerstreak@33
|
1653 'icon', v.icon,
|
flickerstreak@33
|
1654 'iconHeight', iconHeight,
|
flickerstreak@33
|
1655 'iconWidth', iconWidth,
|
flickerstreak@33
|
1656 'iconCoordLeft', iconCoordLeft,
|
flickerstreak@33
|
1657 'iconCoordRight', iconCoordRight,
|
flickerstreak@33
|
1658 'iconCoordTop', iconCoordTop,
|
flickerstreak@33
|
1659 'iconCoordBottom', iconCoordBottom
|
flickerstreak@33
|
1660 )
|
flickerstreak@33
|
1661 elseif v.type == "header" then
|
flickerstreak@33
|
1662 if name == "" or not name then
|
flickerstreak@33
|
1663 self:AddLine(
|
flickerstreak@33
|
1664 'isTitle', true,
|
flickerstreak@33
|
1665 'icon', v.icon,
|
flickerstreak@33
|
1666 'iconHeight', iconHeight,
|
flickerstreak@33
|
1667 'iconWidth', iconWidth,
|
flickerstreak@33
|
1668 'iconCoordLeft', iconCoordLeft,
|
flickerstreak@33
|
1669 'iconCoordRight', iconCoordRight,
|
flickerstreak@33
|
1670 'iconCoordTop', iconCoordTop,
|
flickerstreak@33
|
1671 'iconCoordBottom', iconCoordBottom
|
flickerstreak@33
|
1672 )
|
flickerstreak@33
|
1673 else
|
flickerstreak@33
|
1674 self:AddLine(
|
flickerstreak@33
|
1675 'text', name,
|
flickerstreak@33
|
1676 'isTitle', true,
|
flickerstreak@33
|
1677 'icon', v.icon,
|
flickerstreak@33
|
1678 'iconHeight', iconHeight,
|
flickerstreak@33
|
1679 'iconWidth', iconWidth,
|
flickerstreak@33
|
1680 'iconCoordLeft', iconCoordLeft,
|
flickerstreak@33
|
1681 'iconCoordRight', iconCoordRight,
|
flickerstreak@33
|
1682 'iconCoordTop', iconCoordTop,
|
flickerstreak@33
|
1683 'iconCoordBottom', iconCoordBottom
|
flickerstreak@33
|
1684 )
|
flickerstreak@33
|
1685 end
|
flickerstreak@33
|
1686 end
|
flickerstreak@33
|
1687 end
|
flickerstreak@33
|
1688 last_order = v.order or 100
|
flickerstreak@33
|
1689 end
|
flickerstreak@33
|
1690 elseif options.type == "text" and type(options.validate) == "table" then
|
flickerstreak@33
|
1691 local current
|
flickerstreak@33
|
1692 local options_p = passTable
|
flickerstreak@33
|
1693 if not options_p or (options.get and options.set) then
|
flickerstreak@33
|
1694 options_p = options
|
flickerstreak@33
|
1695 passTable = nil
|
flickerstreak@33
|
1696 passValue = nil
|
flickerstreak@33
|
1697 end
|
flickerstreak@33
|
1698 local multiToggle = options.multiToggle
|
flickerstreak@33
|
1699 local passValue = options.passValue or passValue
|
flickerstreak@33
|
1700 if not multiToggle then
|
flickerstreak@33
|
1701 current = callMethod(k, handler, options_p, "get", passValue)
|
flickerstreak@33
|
1702 end
|
flickerstreak@33
|
1703 local indexed = true
|
flickerstreak@33
|
1704 for k,v in pairs(options.validate) do
|
flickerstreak@33
|
1705 if type(k) ~= "number" then
|
flickerstreak@33
|
1706 indexed = false
|
flickerstreak@33
|
1707 end
|
flickerstreak@33
|
1708 table.insert(values, k)
|
flickerstreak@33
|
1709 end
|
flickerstreak@33
|
1710 if not indexed then
|
flickerstreak@33
|
1711 if not othersort then
|
flickerstreak@33
|
1712 othersort = function(alpha, bravo)
|
flickerstreak@33
|
1713 return othersort_validate[alpha]:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() < othersort_validate[bravo]:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper()
|
flickerstreak@33
|
1714 end
|
flickerstreak@33
|
1715 end
|
flickerstreak@33
|
1716 othersort_validate = options.validate
|
flickerstreak@33
|
1717 table.sort(values, othersort)
|
flickerstreak@33
|
1718 othersort_validate = nil
|
flickerstreak@33
|
1719 end
|
flickerstreak@33
|
1720 for _,k in ipairs(values) do
|
flickerstreak@33
|
1721 local v = options.validate[k]
|
flickerstreak@33
|
1722 if type(k) == "number" then
|
flickerstreak@33
|
1723 k = v
|
flickerstreak@33
|
1724 end
|
flickerstreak@33
|
1725 local func, arg1, arg2, arg3, arg4 = getMethod(k, handler, options_p, "set", skip1Nil(passValue, k))
|
flickerstreak@33
|
1726 local checked
|
flickerstreak@33
|
1727 if multiToggle then
|
flickerstreak@33
|
1728 checked = callMethod(k, handler, options_p, "get", skip1Nil(passValue, k)) or false
|
flickerstreak@33
|
1729 if arg2 == nil then
|
flickerstreak@33
|
1730 arg2 = not checked
|
flickerstreak@33
|
1731 elseif arg3 == nil then
|
flickerstreak@33
|
1732 arg3 = not checked
|
flickerstreak@33
|
1733 else
|
flickerstreak@33
|
1734 arg4 = not checked
|
flickerstreak@33
|
1735 end
|
flickerstreak@33
|
1736 else
|
flickerstreak@33
|
1737 checked = (k == current or (type(k) == "string" and type(current) == "string" and k:lower() == current:lower()))
|
flickerstreak@33
|
1738 if checked then
|
flickerstreak@33
|
1739 func, arg1, arg2, arg3, arg4 = nil, nil, nil, nil, nil
|
flickerstreak@33
|
1740 end
|
flickerstreak@33
|
1741 end
|
flickerstreak@33
|
1742 local tooltipTitle
|
flickerstreak@33
|
1743 local tooltipText
|
flickerstreak@33
|
1744 if options.validateDesc then
|
flickerstreak@33
|
1745 tooltipTitle = v
|
flickerstreak@33
|
1746 tooltipText = options.validateDesc[k]
|
flickerstreak@33
|
1747 else
|
flickerstreak@33
|
1748 tooltipTitle = options.guiName or options.name
|
flickerstreak@33
|
1749 tooltipText = v
|
flickerstreak@33
|
1750 end
|
flickerstreak@33
|
1751 self:AddLine(
|
flickerstreak@33
|
1752 'text', v,
|
flickerstreak@33
|
1753 'func', func,
|
flickerstreak@33
|
1754 'arg1', arg1,
|
flickerstreak@33
|
1755 'arg2', arg2,
|
flickerstreak@33
|
1756 'arg3', arg3,
|
flickerstreak@33
|
1757 'arg4', arg4,
|
flickerstreak@33
|
1758 'isRadio', not multiToggle,
|
flickerstreak@33
|
1759 'checked', checked,
|
flickerstreak@33
|
1760 'tooltipTitle', tooltipTitle,
|
flickerstreak@33
|
1761 'tooltipText', tooltipText
|
flickerstreak@33
|
1762 )
|
flickerstreak@33
|
1763 end
|
flickerstreak@33
|
1764 for k in pairs(values) do
|
flickerstreak@33
|
1765 values[k] = nil
|
flickerstreak@33
|
1766 end
|
flickerstreak@33
|
1767 else
|
flickerstreak@33
|
1768 return false
|
flickerstreak@33
|
1769 end
|
flickerstreak@33
|
1770 return true
|
flickerstreak@33
|
1771 end
|
flickerstreak@33
|
1772
|
flickerstreak@33
|
1773 function Dewdrop:FeedTable(s, difference)
|
flickerstreak@33
|
1774 self:argCheck(s, 2, "table")
|
flickerstreak@33
|
1775 self:argCheck(difference, 3, "nil", "number")
|
flickerstreak@33
|
1776 if not currentLevel then
|
flickerstreak@33
|
1777 self:error("Cannot call `FeedTable' outside of a Dewdrop declaration")
|
flickerstreak@33
|
1778 end
|
flickerstreak@33
|
1779 if not difference then
|
flickerstreak@33
|
1780 difference = 0
|
flickerstreak@33
|
1781 end
|
flickerstreak@33
|
1782 local level = levels[currentLevel]
|
flickerstreak@33
|
1783 if not level then
|
flickerstreak@33
|
1784 self:error("Improper level given")
|
flickerstreak@33
|
1785 end
|
flickerstreak@33
|
1786 if not values then
|
flickerstreak@33
|
1787 values = {}
|
flickerstreak@33
|
1788 else
|
flickerstreak@33
|
1789 for k,v in pairs(values) do
|
flickerstreak@33
|
1790 values[k] = nil
|
flickerstreak@33
|
1791 end
|
flickerstreak@33
|
1792 end
|
flickerstreak@33
|
1793 local t = s.subMenu and s or {subMenu = s}
|
flickerstreak@33
|
1794 local current = level
|
flickerstreak@33
|
1795 while current do
|
flickerstreak@33
|
1796 if current.num == difference + 1 then
|
flickerstreak@33
|
1797 break
|
flickerstreak@33
|
1798 end
|
flickerstreak@33
|
1799 table.insert(values, current.value)
|
flickerstreak@33
|
1800 current = levels[current.num - 1]
|
flickerstreak@33
|
1801 end
|
flickerstreak@33
|
1802
|
flickerstreak@33
|
1803 while #values > 0 do
|
flickerstreak@33
|
1804 local value = table.remove(values)
|
flickerstreak@33
|
1805 t = t.subMenu and t.subMenu[value]
|
flickerstreak@33
|
1806 if not t then
|
flickerstreak@33
|
1807 return
|
flickerstreak@33
|
1808 end
|
flickerstreak@33
|
1809 end
|
flickerstreak@33
|
1810
|
flickerstreak@33
|
1811 if t.subMenu or current.num == 1 then
|
flickerstreak@33
|
1812 for k in pairs(t.subMenu) do
|
flickerstreak@33
|
1813 table.insert(values, k)
|
flickerstreak@33
|
1814 end
|
flickerstreak@33
|
1815 table.sort(values)
|
flickerstreak@33
|
1816 for _,k in ipairs(values) do
|
flickerstreak@33
|
1817 local argTable = {"value", k}
|
flickerstreak@33
|
1818 for key, val in pairs(t.subMenu[k]) do
|
flickerstreak@33
|
1819 table.insert(argTable, key)
|
flickerstreak@33
|
1820 table.insert(argTable, val)
|
flickerstreak@33
|
1821 end
|
flickerstreak@33
|
1822 self:AddLine(unpack(argTable))
|
flickerstreak@33
|
1823 end
|
flickerstreak@33
|
1824 for k in pairs(values) do
|
flickerstreak@33
|
1825 values[k] = nil
|
flickerstreak@33
|
1826 end
|
flickerstreak@33
|
1827 return false
|
flickerstreak@33
|
1828 end
|
flickerstreak@33
|
1829 return true
|
flickerstreak@33
|
1830 end
|
flickerstreak@33
|
1831
|
flickerstreak@33
|
1832 function Refresh(self, level)
|
flickerstreak@33
|
1833 if type(level) == "number" then
|
flickerstreak@33
|
1834 level = levels[level]
|
flickerstreak@33
|
1835 end
|
flickerstreak@33
|
1836 if not level then
|
flickerstreak@33
|
1837 return
|
flickerstreak@33
|
1838 end
|
flickerstreak@33
|
1839 if baseFunc then
|
flickerstreak@33
|
1840 Clear(self, level)
|
flickerstreak@33
|
1841 currentLevel = level.num
|
flickerstreak@33
|
1842 if type(baseFunc) == "table" then
|
flickerstreak@33
|
1843 if currentLevel == 1 then
|
flickerstreak@33
|
1844 local handler = baseFunc.handler
|
flickerstreak@33
|
1845 if handler then
|
flickerstreak@33
|
1846 local name = tostring(handler)
|
flickerstreak@33
|
1847 if not name:find('^table:') and not handler.hideMenuTitle then
|
flickerstreak@33
|
1848 name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
|
flickerstreak@33
|
1849 self:AddLine(
|
flickerstreak@33
|
1850 'text', name,
|
flickerstreak@33
|
1851 'isTitle', true
|
flickerstreak@33
|
1852 )
|
flickerstreak@33
|
1853 end
|
flickerstreak@33
|
1854 end
|
flickerstreak@33
|
1855 -- elseif level.parentText then
|
flickerstreak@33
|
1856 -- self:AddLine(
|
flickerstreak@33
|
1857 -- 'text', level.parentText,
|
flickerstreak@33
|
1858 -- 'tooltipTitle', level.parentTooltipTitle,
|
flickerstreak@33
|
1859 -- 'tooltipText', level.parentTooltipText,
|
flickerstreak@33
|
1860 -- 'tooltipFunc', level.parentTooltipFunc,
|
flickerstreak@33
|
1861 -- 'isTitle', true
|
flickerstreak@33
|
1862 -- )
|
flickerstreak@33
|
1863 end
|
flickerstreak@33
|
1864 self:FeedAceOptionsTable(baseFunc)
|
flickerstreak@33
|
1865 if currentLevel == 1 then
|
flickerstreak@33
|
1866 self:AddLine(
|
flickerstreak@33
|
1867 'text', CLOSE,
|
flickerstreak@33
|
1868 'tooltipTitle', CLOSE,
|
flickerstreak@33
|
1869 'tooltipText', CLOSE_DESC,
|
flickerstreak@33
|
1870 'closeWhenClicked', true
|
flickerstreak@33
|
1871 )
|
flickerstreak@33
|
1872 end
|
flickerstreak@33
|
1873 else
|
flickerstreak@33
|
1874 -- if level.parentText then
|
flickerstreak@33
|
1875 -- self:AddLine(
|
flickerstreak@33
|
1876 -- 'text', level.parentText,
|
flickerstreak@33
|
1877 -- 'tooltipTitle', level.parentTooltipTitle,
|
flickerstreak@33
|
1878 -- 'tooltipText', level.parentTooltipText,
|
flickerstreak@33
|
1879 -- 'tooltipFunc', level.parentTooltipFunc,
|
flickerstreak@33
|
1880 -- 'isTitle', true
|
flickerstreak@33
|
1881 -- )
|
flickerstreak@33
|
1882 -- end
|
flickerstreak@33
|
1883 baseFunc(currentLevel, level.value, levels[level.num - 1] and levels[level.num - 1].value, levels[level.num - 2] and levels[level.num - 2].value, levels[level.num - 3] and levels[level.num - 3].value, levels[level.num - 4] and levels[level.num - 4].value)
|
flickerstreak@33
|
1884 end
|
flickerstreak@33
|
1885 currentLevel = nil
|
flickerstreak@33
|
1886 CheckSize(self, level)
|
flickerstreak@33
|
1887 end
|
flickerstreak@33
|
1888 end
|
flickerstreak@33
|
1889
|
flickerstreak@33
|
1890 function Dewdrop:Refresh(level)
|
flickerstreak@33
|
1891 self:argCheck(level, 2, "number", "nil")
|
flickerstreak@33
|
1892 if not level then
|
flickerstreak@33
|
1893 for k,v in pairs(levels) do
|
flickerstreak@33
|
1894 Refresh(self, v)
|
flickerstreak@33
|
1895 end
|
flickerstreak@33
|
1896 else
|
flickerstreak@33
|
1897 Refresh(self, levels[level])
|
flickerstreak@33
|
1898 end
|
flickerstreak@33
|
1899 end
|
flickerstreak@33
|
1900
|
flickerstreak@33
|
1901 function OpenSlider(self, parent)
|
flickerstreak@33
|
1902 if not sliderFrame then
|
flickerstreak@33
|
1903 sliderFrame = CreateFrame("Frame", nil, nil)
|
flickerstreak@33
|
1904 sliderFrame:SetWidth(100)
|
flickerstreak@33
|
1905 sliderFrame:SetHeight(170)
|
flickerstreak@33
|
1906 sliderFrame:SetScale(UIParent:GetScale())
|
flickerstreak@33
|
1907 sliderFrame:SetBackdrop(tmp(
|
flickerstreak@33
|
1908 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
|
flickerstreak@33
|
1909 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
|
flickerstreak@33
|
1910 'tile', true,
|
flickerstreak@33
|
1911 'insets', tmp2(
|
flickerstreak@33
|
1912 'left', 5,
|
flickerstreak@33
|
1913 'right', 5,
|
flickerstreak@33
|
1914 'top', 5,
|
flickerstreak@33
|
1915 'bottom', 5
|
flickerstreak@33
|
1916 ),
|
flickerstreak@33
|
1917 'tileSize', 16,
|
flickerstreak@33
|
1918 'edgeSize', 16
|
flickerstreak@33
|
1919 ))
|
flickerstreak@33
|
1920 sliderFrame:SetFrameStrata("FULLSCREEN_DIALOG")
|
flickerstreak@33
|
1921 if sliderFrame.SetTopLevel then
|
flickerstreak@33
|
1922 sliderFrame:SetTopLevel(true)
|
flickerstreak@33
|
1923 end
|
flickerstreak@33
|
1924 sliderFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
|
flickerstreak@33
|
1925 sliderFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
|
flickerstreak@33
|
1926 sliderFrame:EnableMouse(true)
|
flickerstreak@33
|
1927 sliderFrame:EnableMouseWheel(true)
|
flickerstreak@33
|
1928 sliderFrame:Hide()
|
flickerstreak@33
|
1929 sliderFrame:SetPoint("CENTER", UIParent, "CENTER")
|
flickerstreak@33
|
1930 local slider = CreateFrame("Slider", nil, sliderFrame)
|
flickerstreak@33
|
1931 sliderFrame.slider = slider
|
flickerstreak@33
|
1932 slider:SetOrientation("VERTICAL")
|
flickerstreak@33
|
1933 slider:SetMinMaxValues(0, 1)
|
flickerstreak@33
|
1934 slider:SetValueStep(0.000000001)
|
flickerstreak@33
|
1935 slider:SetValue(0.5)
|
flickerstreak@33
|
1936 slider:SetWidth(16)
|
flickerstreak@33
|
1937 slider:SetHeight(128)
|
flickerstreak@33
|
1938 slider:SetPoint("LEFT", sliderFrame, "LEFT", 15, 0)
|
flickerstreak@33
|
1939 slider:SetBackdrop(tmp(
|
flickerstreak@33
|
1940 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background",
|
flickerstreak@33
|
1941 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border",
|
flickerstreak@33
|
1942 'tile', true,
|
flickerstreak@33
|
1943 'edgeSize', 8,
|
flickerstreak@33
|
1944 'tileSize', 8,
|
flickerstreak@33
|
1945 'insets', tmp2(
|
flickerstreak@33
|
1946 'left', 3,
|
flickerstreak@33
|
1947 'right', 3,
|
flickerstreak@33
|
1948 'top', 3,
|
flickerstreak@33
|
1949 'bottom', 3
|
flickerstreak@33
|
1950 )
|
flickerstreak@33
|
1951 ))
|
flickerstreak@33
|
1952 local texture = slider:CreateTexture()
|
flickerstreak@33
|
1953 slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
|
flickerstreak@33
|
1954 local text = slider:CreateFontString(nil, "ARTWORK")
|
flickerstreak@33
|
1955 sliderFrame.topText = text
|
flickerstreak@33
|
1956 text:SetFontObject(GameFontGreenSmall)
|
flickerstreak@33
|
1957 text:SetText("100%")
|
flickerstreak@33
|
1958 text:SetPoint("BOTTOM", slider, "TOP")
|
flickerstreak@33
|
1959 local text = slider:CreateFontString(nil, "ARTWORK")
|
flickerstreak@33
|
1960 sliderFrame.bottomText = text
|
flickerstreak@33
|
1961 text:SetFontObject(GameFontGreenSmall)
|
flickerstreak@33
|
1962 text:SetText("0%")
|
flickerstreak@33
|
1963 text:SetPoint("TOP", slider, "BOTTOM")
|
flickerstreak@33
|
1964 local editBox = CreateFrame("EditBox", nil, sliderFrame)
|
flickerstreak@33
|
1965 sliderFrame.currentText = editBox
|
flickerstreak@33
|
1966 editBox:SetFontObject(ChatFontNormal)
|
flickerstreak@33
|
1967 editBox:SetHeight(13)
|
flickerstreak@33
|
1968 editBox:SetPoint("RIGHT", sliderFrame, "RIGHT", -16, 0)
|
flickerstreak@33
|
1969 editBox:SetPoint("LEFT", slider, "RIGHT", 12, 0)
|
flickerstreak@33
|
1970 editBox:SetText("50%")
|
flickerstreak@33
|
1971 editBox:SetJustifyH("CENTER")
|
flickerstreak@33
|
1972
|
flickerstreak@33
|
1973 local width = editBox:GetWidth()/2 + 10
|
flickerstreak@33
|
1974 local left = editBox:CreateTexture(nil, "BACKGROUND")
|
flickerstreak@33
|
1975 left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left")
|
flickerstreak@33
|
1976 left:SetTexCoord(0, width / 256, 0, 1)
|
flickerstreak@33
|
1977 left:SetWidth(width)
|
flickerstreak@33
|
1978 left:SetHeight(32)
|
flickerstreak@33
|
1979 left:SetPoint("LEFT", editBox, "LEFT", -10, 0)
|
flickerstreak@33
|
1980 local right = editBox:CreateTexture(nil, "BACKGROUND")
|
flickerstreak@33
|
1981 right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right")
|
flickerstreak@33
|
1982 right:SetTexCoord(1 - width / 256, 1, 0, 1)
|
flickerstreak@33
|
1983 right:SetWidth(width)
|
flickerstreak@33
|
1984 right:SetHeight(32)
|
flickerstreak@33
|
1985 right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0)
|
flickerstreak@33
|
1986
|
flickerstreak@33
|
1987 local changed = false
|
flickerstreak@33
|
1988 local inside = false
|
flickerstreak@33
|
1989 slider:SetScript("OnValueChanged", function()
|
flickerstreak@33
|
1990 if sliderFrame.changing then
|
flickerstreak@33
|
1991 return
|
flickerstreak@33
|
1992 end
|
flickerstreak@33
|
1993 changed = true
|
flickerstreak@33
|
1994 local done = false
|
flickerstreak@33
|
1995 if sliderFrame.parent and sliderFrame.parent.sliderFunc then
|
flickerstreak@33
|
1996 local min = sliderFrame.parent.sliderMin or 0
|
flickerstreak@33
|
1997 local max = sliderFrame.parent.sliderMax or 1
|
flickerstreak@33
|
1998 local step
|
flickerstreak@33
|
1999 if sliderFrame.fineStep then
|
flickerstreak@33
|
2000 step = sliderFrame.parent.sliderStep or (max - min) / 100
|
flickerstreak@33
|
2001 else
|
flickerstreak@33
|
2002 step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100
|
flickerstreak@33
|
2003 end
|
flickerstreak@33
|
2004 local value = (1 - slider:GetValue()) * (max - min) + min
|
flickerstreak@33
|
2005 if step > 0 then
|
flickerstreak@33
|
2006 value = math.floor((value - min) / step + 0.5) * step + min
|
flickerstreak@33
|
2007 if value > max then
|
flickerstreak@33
|
2008 value = max
|
flickerstreak@33
|
2009 elseif value < min then
|
flickerstreak@33
|
2010 value = min
|
flickerstreak@33
|
2011 end
|
flickerstreak@33
|
2012 end
|
flickerstreak@33
|
2013 if value == sliderFrame.lastValue then
|
flickerstreak@33
|
2014 return
|
flickerstreak@33
|
2015 end
|
flickerstreak@33
|
2016 sliderFrame.lastValue = value
|
flickerstreak@33
|
2017 local text = sliderFrame.parent.sliderFunc(getArgs(sliderFrame.parent, 'sliderArg', 1, value))
|
flickerstreak@33
|
2018 if sliderFrame.parent.fromAceOptions then
|
flickerstreak@33
|
2019 text = nil
|
flickerstreak@33
|
2020 elseif type(text) == "string" or type(text) == "number" then
|
flickerstreak@33
|
2021 sliderFrame.currentText:SetText(text)
|
flickerstreak@33
|
2022 done = true
|
flickerstreak@33
|
2023 end
|
flickerstreak@33
|
2024 end
|
flickerstreak@33
|
2025 if not done then
|
flickerstreak@33
|
2026 local min = sliderFrame.parent.sliderMin or 0
|
flickerstreak@33
|
2027 local max = sliderFrame.parent.sliderMax or 1
|
flickerstreak@33
|
2028 local step
|
flickerstreak@33
|
2029 if sliderFrame.fineStep then
|
flickerstreak@33
|
2030 step = sliderFrame.parent.sliderStep or (max - min) / 100
|
flickerstreak@33
|
2031 else
|
flickerstreak@33
|
2032 step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100
|
flickerstreak@33
|
2033 end
|
flickerstreak@33
|
2034 local value = (1 - slider:GetValue()) * (max - min) + min
|
flickerstreak@33
|
2035 if step > 0 then
|
flickerstreak@33
|
2036 value = math.floor((value - min) / step + 0.5) * step + min
|
flickerstreak@33
|
2037 if value > max then
|
flickerstreak@33
|
2038 value = max
|
flickerstreak@33
|
2039 elseif value < min then
|
flickerstreak@33
|
2040 value = min
|
flickerstreak@33
|
2041 end
|
flickerstreak@33
|
2042 end
|
flickerstreak@33
|
2043 if sliderFrame.parent.sliderIsPercent then
|
flickerstreak@33
|
2044 sliderFrame.currentText:SetText(string.format("%.0f%%", value * 100))
|
flickerstreak@33
|
2045 else
|
flickerstreak@33
|
2046 if step < 0.1 then
|
flickerstreak@33
|
2047 sliderFrame.currentText:SetText(string.format("%.2f", value))
|
flickerstreak@33
|
2048 elseif step < 1 then
|
flickerstreak@33
|
2049 sliderFrame.currentText:SetText(string.format("%.1f", value))
|
flickerstreak@33
|
2050 else
|
flickerstreak@33
|
2051 sliderFrame.currentText:SetText(string.format("%.0f", value))
|
flickerstreak@33
|
2052 end
|
flickerstreak@33
|
2053 end
|
flickerstreak@33
|
2054 end
|
flickerstreak@33
|
2055 end)
|
flickerstreak@33
|
2056 local function onEnter()
|
flickerstreak@33
|
2057 StopCounting(self, sliderFrame.level)
|
flickerstreak@33
|
2058 showGameTooltip(sliderFrame.parent)
|
flickerstreak@33
|
2059 end
|
flickerstreak@33
|
2060 local function onLeave()
|
flickerstreak@33
|
2061 GameTooltip:Hide()
|
flickerstreak@33
|
2062 end
|
flickerstreak@33
|
2063 sliderFrame:SetScript("OnEnter", onEnter)
|
flickerstreak@33
|
2064 sliderFrame:SetScript("OnLeave", function()
|
flickerstreak@33
|
2065 GameTooltip:Hide()
|
flickerstreak@33
|
2066 if changed then
|
flickerstreak@33
|
2067 local parent = sliderFrame.parent
|
flickerstreak@33
|
2068 local sliderFunc = parent.sliderFunc
|
flickerstreak@33
|
2069 for i = 1, sliderFrame.level - 1 do
|
flickerstreak@33
|
2070 Refresh(self, levels[i])
|
flickerstreak@33
|
2071 end
|
flickerstreak@33
|
2072 local newParent
|
flickerstreak@33
|
2073 for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
|
flickerstreak@33
|
2074 if button.sliderFunc == sliderFunc then
|
flickerstreak@33
|
2075 newParent = button
|
flickerstreak@33
|
2076 break
|
flickerstreak@33
|
2077 end
|
flickerstreak@33
|
2078 end
|
flickerstreak@33
|
2079 if newParent then
|
flickerstreak@33
|
2080 OpenSlider(self, newParent)
|
flickerstreak@33
|
2081 else
|
flickerstreak@33
|
2082 sliderFrame:Hide()
|
flickerstreak@33
|
2083 end
|
flickerstreak@33
|
2084 end
|
flickerstreak@33
|
2085 end)
|
flickerstreak@33
|
2086 editBox:SetScript("OnEnter", onEnter)
|
flickerstreak@33
|
2087 editBox:SetScript("OnLeave", onLeave)
|
flickerstreak@33
|
2088 slider:SetScript("OnMouseDown", function()
|
flickerstreak@33
|
2089 sliderFrame.mouseDown = true
|
flickerstreak@33
|
2090 GameTooltip:Hide()
|
flickerstreak@33
|
2091 end)
|
flickerstreak@33
|
2092 slider:SetScript("OnMouseUp", function()
|
flickerstreak@33
|
2093 sliderFrame.mouseDown = false
|
flickerstreak@33
|
2094 if changed--[[ and not inside]] then
|
flickerstreak@33
|
2095 local parent = sliderFrame.parent
|
flickerstreak@33
|
2096 local sliderFunc = parent.sliderFunc
|
flickerstreak@33
|
2097 for i = 1, sliderFrame.level - 1 do
|
flickerstreak@33
|
2098 Refresh(self, levels[i])
|
flickerstreak@33
|
2099 end
|
flickerstreak@33
|
2100 local newParent
|
flickerstreak@33
|
2101 for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
|
flickerstreak@33
|
2102 if button.sliderFunc == sliderFunc then
|
flickerstreak@33
|
2103 newParent = button
|
flickerstreak@33
|
2104 break
|
flickerstreak@33
|
2105 end
|
flickerstreak@33
|
2106 end
|
flickerstreak@33
|
2107 if newParent then
|
flickerstreak@33
|
2108 OpenSlider(self, newParent)
|
flickerstreak@33
|
2109 else
|
flickerstreak@33
|
2110 sliderFrame:Hide()
|
flickerstreak@33
|
2111 end
|
flickerstreak@33
|
2112 end
|
flickerstreak@33
|
2113 if inside then
|
flickerstreak@33
|
2114 showGameTooltip(sliderFrame.parent)
|
flickerstreak@33
|
2115 end
|
flickerstreak@33
|
2116 end)
|
flickerstreak@33
|
2117 slider:SetScript("OnEnter", function()
|
flickerstreak@33
|
2118 inside = true
|
flickerstreak@33
|
2119 StopCounting(self, sliderFrame.level)
|
flickerstreak@33
|
2120 showGameTooltip(sliderFrame.parent)
|
flickerstreak@33
|
2121 end)
|
flickerstreak@33
|
2122 slider:SetScript("OnLeave", function()
|
flickerstreak@33
|
2123 inside = false
|
flickerstreak@33
|
2124 GameTooltip:Hide()
|
flickerstreak@33
|
2125 if changed and not sliderFrame.mouseDown then
|
flickerstreak@33
|
2126 local parent = sliderFrame.parent
|
flickerstreak@33
|
2127 local sliderFunc = parent.sliderFunc
|
flickerstreak@33
|
2128 for i = 1, sliderFrame.level - 1 do
|
flickerstreak@33
|
2129 Refresh(self, levels[i])
|
flickerstreak@33
|
2130 end
|
flickerstreak@33
|
2131 local newParent
|
flickerstreak@33
|
2132 for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
|
flickerstreak@33
|
2133 if button.sliderFunc == sliderFunc then
|
flickerstreak@33
|
2134 newParent = button
|
flickerstreak@33
|
2135 break
|
flickerstreak@33
|
2136 end
|
flickerstreak@33
|
2137 end
|
flickerstreak@33
|
2138 if newParent then
|
flickerstreak@33
|
2139 OpenSlider(self, newParent)
|
flickerstreak@33
|
2140 else
|
flickerstreak@33
|
2141 sliderFrame:Hide()
|
flickerstreak@33
|
2142 end
|
flickerstreak@33
|
2143
|
flickerstreak@33
|
2144 changed = false
|
flickerstreak@33
|
2145 end
|
flickerstreak@33
|
2146 end)
|
flickerstreak@33
|
2147 sliderFrame:SetScript("OnMouseWheel", function(t, a1)
|
flickerstreak@33
|
2148 local arg1 = a1 or arg1
|
flickerstreak@33
|
2149 local up = arg1 > 0
|
flickerstreak@33
|
2150
|
flickerstreak@33
|
2151 local min = sliderFrame.parent.sliderMin or 0
|
flickerstreak@33
|
2152 local max = sliderFrame.parent.sliderMax or 1
|
flickerstreak@33
|
2153 local step = sliderFrame.parent.sliderStep or (max - min) / 100
|
flickerstreak@33
|
2154 if step <= 0 then
|
flickerstreak@33
|
2155 step = (max - min) / 100
|
flickerstreak@33
|
2156 end
|
flickerstreak@33
|
2157
|
flickerstreak@33
|
2158 local value = (1 - slider:GetValue()) * (max - min) + min
|
flickerstreak@33
|
2159 if up then
|
flickerstreak@33
|
2160 value = value + step
|
flickerstreak@33
|
2161 else
|
flickerstreak@33
|
2162 value = value - step
|
flickerstreak@33
|
2163 end
|
flickerstreak@33
|
2164 if value > max then
|
flickerstreak@33
|
2165 value = max
|
flickerstreak@33
|
2166 elseif value < min then
|
flickerstreak@33
|
2167 value = min
|
flickerstreak@33
|
2168 end
|
flickerstreak@33
|
2169 sliderFrame.fineStep = true
|
flickerstreak@33
|
2170 if max<=min then
|
flickerstreak@33
|
2171 slider:SetValue(0)
|
flickerstreak@33
|
2172 else
|
flickerstreak@33
|
2173 slider:SetValue(1 - (value - min) / (max - min))
|
flickerstreak@33
|
2174 end
|
flickerstreak@33
|
2175 sliderFrame.fineStep = nil
|
flickerstreak@33
|
2176 end)
|
flickerstreak@33
|
2177 slider:SetScript("OnMouseWheel", sliderFrame:GetScript("OnMouseWheel"))
|
flickerstreak@33
|
2178 editBox:SetScript("OnEnterPressed", function(t, a1)
|
flickerstreak@33
|
2179 local value = editBox:GetNumber()
|
flickerstreak@33
|
2180
|
flickerstreak@33
|
2181 if sliderFrame.parent.sliderIsPercent then
|
flickerstreak@33
|
2182 value = value / 100
|
flickerstreak@33
|
2183 end
|
flickerstreak@33
|
2184
|
flickerstreak@33
|
2185 local min = sliderFrame.parent.sliderMin or 0
|
flickerstreak@33
|
2186 local max = sliderFrame.parent.sliderMax or 1
|
flickerstreak@33
|
2187
|
flickerstreak@33
|
2188 if value > max then
|
flickerstreak@33
|
2189 value = max
|
flickerstreak@33
|
2190 elseif value < min then
|
flickerstreak@33
|
2191 value = min
|
flickerstreak@33
|
2192 end
|
flickerstreak@33
|
2193 sliderFrame.fineStep = true
|
flickerstreak@33
|
2194 if max <= min then
|
flickerstreak@33
|
2195 slider:SetValue(0)
|
flickerstreak@33
|
2196 else
|
flickerstreak@33
|
2197 slider:SetValue(1 - (value - min) / (max - min))
|
flickerstreak@33
|
2198 end
|
flickerstreak@33
|
2199 sliderFrame.fineStep = nil
|
flickerstreak@33
|
2200
|
flickerstreak@33
|
2201 StartCounting(self, sliderFrame.level)
|
flickerstreak@33
|
2202 end)
|
flickerstreak@33
|
2203 editBox:SetScript("OnEscapePressed", function()
|
flickerstreak@33
|
2204 self:Close(sliderFrame.level)
|
flickerstreak@33
|
2205 StartCounting(self, sliderFrame.level)
|
flickerstreak@33
|
2206 end)
|
flickerstreak@33
|
2207 editBox:SetAutoFocus(false)
|
flickerstreak@33
|
2208 end
|
flickerstreak@33
|
2209 sliderFrame.parent = parent
|
flickerstreak@33
|
2210 sliderFrame.level = parent.level.num + 1
|
flickerstreak@33
|
2211 sliderFrame.parentValue = parent.level.value
|
flickerstreak@33
|
2212 sliderFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3)
|
flickerstreak@33
|
2213 sliderFrame.slider:SetFrameLevel(sliderFrame:GetFrameLevel() + 1)
|
flickerstreak@33
|
2214 sliderFrame.currentText:SetFrameLevel(sliderFrame:GetFrameLevel() + 1)
|
flickerstreak@33
|
2215 sliderFrame.currentText:ClearFocus()
|
flickerstreak@33
|
2216 sliderFrame.changing = true
|
flickerstreak@33
|
2217 if not parent.sliderMin or not parent.sliderMax then
|
flickerstreak@33
|
2218 return
|
flickerstreak@33
|
2219 end
|
flickerstreak@33
|
2220
|
flickerstreak@33
|
2221 if parent.arrow then
|
flickerstreak@33
|
2222 -- parent.arrow:SetVertexColor(0.2, 0.6, 0)
|
flickerstreak@33
|
2223 -- parent.arrow:SetHeight(24)
|
flickerstreak@33
|
2224 -- parent.arrow:SetWidth(24)
|
flickerstreak@33
|
2225 parent.selected = true
|
flickerstreak@33
|
2226 parent.highlight:Show()
|
flickerstreak@33
|
2227 end
|
flickerstreak@33
|
2228
|
flickerstreak@33
|
2229 sliderFrame:SetClampedToScreen(false)
|
flickerstreak@33
|
2230 if not parent.sliderValue then
|
flickerstreak@33
|
2231 parent.sliderValue = (parent.sliderMin + parent.sliderMax) / 2
|
flickerstreak@33
|
2232 end
|
flickerstreak@33
|
2233 if parent.sliderMax <= parent.sliderMin then
|
flickerstreak@33
|
2234 sliderFrame.slider:SetValue(0)
|
flickerstreak@33
|
2235 else
|
flickerstreak@33
|
2236 sliderFrame.slider:SetValue(1 - (parent.sliderValue - parent.sliderMin) / (parent.sliderMax - parent.sliderMin))
|
flickerstreak@33
|
2237 end
|
flickerstreak@33
|
2238 sliderFrame.changing = false
|
flickerstreak@33
|
2239 sliderFrame.bottomText:SetText(parent.sliderMinText or "0")
|
flickerstreak@33
|
2240 sliderFrame.topText:SetText(parent.sliderMaxText or "1")
|
flickerstreak@33
|
2241 local text
|
flickerstreak@33
|
2242 if parent.sliderFunc and not parent.fromAceOptions then
|
flickerstreak@33
|
2243 text = parent.sliderFunc(getArgs(parent, 'sliderArg', 1, parent.sliderValue))
|
flickerstreak@33
|
2244 end
|
flickerstreak@33
|
2245 if type(text) == "number" or type(text) == "string" then
|
flickerstreak@33
|
2246 sliderFrame.currentText:SetText(text)
|
flickerstreak@33
|
2247 elseif parent.sliderIsPercent then
|
flickerstreak@33
|
2248 sliderFrame.currentText:SetText(string.format("%.0f%%", parent.sliderValue * 100))
|
flickerstreak@33
|
2249 else
|
flickerstreak@33
|
2250 if parent.sliderStep < 0.1 then
|
flickerstreak@33
|
2251 sliderFrame.currentText:SetText(string.format("%.2f", parent.sliderValue))
|
flickerstreak@33
|
2252 elseif parent.sliderStep < 1 then
|
flickerstreak@33
|
2253 sliderFrame.currentText:SetText(string.format("%.1f", parent.sliderValue))
|
flickerstreak@33
|
2254 else
|
flickerstreak@33
|
2255 sliderFrame.currentText:SetText(string.format("%.0f", parent.sliderValue))
|
flickerstreak@33
|
2256 end
|
flickerstreak@33
|
2257 end
|
flickerstreak@33
|
2258
|
flickerstreak@33
|
2259
|
flickerstreak@33
|
2260 sliderFrame.lastValue = parent.sliderValue
|
flickerstreak@33
|
2261
|
flickerstreak@33
|
2262 local level = parent.level
|
flickerstreak@33
|
2263 sliderFrame:Show()
|
flickerstreak@33
|
2264 sliderFrame:ClearAllPoints()
|
flickerstreak@33
|
2265 if level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
2266 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2267 sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
|
flickerstreak@33
|
2268 else
|
flickerstreak@33
|
2269 sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
|
flickerstreak@33
|
2270 end
|
flickerstreak@33
|
2271 else
|
flickerstreak@33
|
2272 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2273 sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
|
flickerstreak@33
|
2274 else
|
flickerstreak@33
|
2275 sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
|
flickerstreak@33
|
2276 end
|
flickerstreak@33
|
2277 end
|
flickerstreak@33
|
2278 local dirty
|
flickerstreak@33
|
2279 if level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
2280 if sliderFrame:GetRight() > GetScreenWidth() then
|
flickerstreak@33
|
2281 level.lastDirection = "LEFT"
|
flickerstreak@33
|
2282 dirty = true
|
flickerstreak@33
|
2283 end
|
flickerstreak@33
|
2284 elseif sliderFrame:GetLeft() < 0 then
|
flickerstreak@33
|
2285 level.lastDirection = "RIGHT"
|
flickerstreak@33
|
2286 dirty = true
|
flickerstreak@33
|
2287 end
|
flickerstreak@33
|
2288 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2289 if sliderFrame:GetBottom() < 0 then
|
flickerstreak@33
|
2290 level.lastVDirection = "UP"
|
flickerstreak@33
|
2291 dirty = true
|
flickerstreak@33
|
2292 end
|
flickerstreak@33
|
2293 elseif sliderFrame:GetTop() > GetScreenWidth() then
|
flickerstreak@33
|
2294 level.lastVDirection = "DOWN"
|
flickerstreak@33
|
2295 dirty = true
|
flickerstreak@33
|
2296 end
|
flickerstreak@33
|
2297 if dirty then
|
flickerstreak@33
|
2298 sliderFrame:ClearAllPoints()
|
flickerstreak@33
|
2299 if level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
2300 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2301 sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
|
flickerstreak@33
|
2302 else
|
flickerstreak@33
|
2303 sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
|
flickerstreak@33
|
2304 end
|
flickerstreak@33
|
2305 else
|
flickerstreak@33
|
2306 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2307 sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
|
flickerstreak@33
|
2308 else
|
flickerstreak@33
|
2309 sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
|
flickerstreak@33
|
2310 end
|
flickerstreak@33
|
2311 end
|
flickerstreak@33
|
2312 end
|
flickerstreak@33
|
2313 local left, bottom = sliderFrame:GetLeft(), sliderFrame:GetBottom()
|
flickerstreak@33
|
2314 sliderFrame:ClearAllPoints()
|
flickerstreak@33
|
2315 sliderFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
|
flickerstreak@33
|
2316 if mod(level.num, 5) == 0 then
|
flickerstreak@33
|
2317 local left, bottom = level:GetLeft(), level:GetBottom()
|
flickerstreak@33
|
2318 level:ClearAllPoints()
|
flickerstreak@33
|
2319 level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
|
flickerstreak@33
|
2320 end
|
flickerstreak@33
|
2321 sliderFrame:SetClampedToScreen(true)
|
flickerstreak@33
|
2322 end
|
flickerstreak@33
|
2323
|
flickerstreak@33
|
2324 function OpenEditBox(self, parent)
|
flickerstreak@33
|
2325 if not editBoxFrame then
|
flickerstreak@33
|
2326 editBoxFrame = CreateFrame("Frame", nil, nil)
|
flickerstreak@33
|
2327 editBoxFrame:SetWidth(200)
|
flickerstreak@33
|
2328 editBoxFrame:SetHeight(40)
|
flickerstreak@33
|
2329 editBoxFrame:SetScale(UIParent:GetScale())
|
flickerstreak@33
|
2330 editBoxFrame:SetBackdrop(tmp(
|
flickerstreak@33
|
2331 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
|
flickerstreak@33
|
2332 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
|
flickerstreak@33
|
2333 'tile', true,
|
flickerstreak@33
|
2334 'insets', tmp2(
|
flickerstreak@33
|
2335 'left', 5,
|
flickerstreak@33
|
2336 'right', 5,
|
flickerstreak@33
|
2337 'top', 5,
|
flickerstreak@33
|
2338 'bottom', 5
|
flickerstreak@33
|
2339 ),
|
flickerstreak@33
|
2340 'tileSize', 16,
|
flickerstreak@33
|
2341 'edgeSize', 16
|
flickerstreak@33
|
2342 ))
|
flickerstreak@33
|
2343 editBoxFrame:SetFrameStrata("FULLSCREEN_DIALOG")
|
flickerstreak@33
|
2344 if editBoxFrame.SetTopLevel then
|
flickerstreak@33
|
2345 editBoxFrame:SetTopLevel(true)
|
flickerstreak@33
|
2346 end
|
flickerstreak@33
|
2347 editBoxFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
|
flickerstreak@33
|
2348 editBoxFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
|
flickerstreak@33
|
2349 editBoxFrame:EnableMouse(true)
|
flickerstreak@33
|
2350 editBoxFrame:EnableMouseWheel(true)
|
flickerstreak@33
|
2351 editBoxFrame:Hide()
|
flickerstreak@33
|
2352 editBoxFrame:SetPoint("CENTER", UIParent, "CENTER")
|
flickerstreak@33
|
2353
|
flickerstreak@33
|
2354 local editBox = CreateFrame("EditBox", nil, editBoxFrame)
|
flickerstreak@33
|
2355 editBoxFrame.editBox = editBox
|
flickerstreak@33
|
2356 editBox:SetFontObject(ChatFontNormal)
|
flickerstreak@33
|
2357 editBox:SetWidth(160)
|
flickerstreak@33
|
2358 editBox:SetHeight(13)
|
flickerstreak@33
|
2359 editBox:SetPoint("CENTER", editBoxFrame, "CENTER", 0, 0)
|
flickerstreak@33
|
2360
|
flickerstreak@33
|
2361 local left = editBox:CreateTexture(nil, "BACKGROUND")
|
flickerstreak@33
|
2362 left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left")
|
flickerstreak@33
|
2363 left:SetTexCoord(0, 100 / 256, 0, 1)
|
flickerstreak@33
|
2364 left:SetWidth(100)
|
flickerstreak@33
|
2365 left:SetHeight(32)
|
flickerstreak@33
|
2366 left:SetPoint("LEFT", editBox, "LEFT", -10, 0)
|
flickerstreak@33
|
2367 local right = editBox:CreateTexture(nil, "BACKGROUND")
|
flickerstreak@33
|
2368 right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right")
|
flickerstreak@33
|
2369 right:SetTexCoord(156/256, 1, 0, 1)
|
flickerstreak@33
|
2370 right:SetWidth(100)
|
flickerstreak@33
|
2371 right:SetHeight(32)
|
flickerstreak@33
|
2372 right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0)
|
flickerstreak@33
|
2373
|
flickerstreak@33
|
2374 editBox:SetScript("OnEnterPressed", function()
|
flickerstreak@33
|
2375 if editBoxFrame.parent and editBoxFrame.parent.editBoxValidateFunc then
|
flickerstreak@33
|
2376 local t = editBox.realText or editBox:GetText() or ""
|
flickerstreak@33
|
2377 local result = editBoxFrame.parent.editBoxValidateFunc(getArgs(editBoxFrame.parent, 'editBoxValidateArg', 1, t))
|
flickerstreak@33
|
2378 if not result then
|
flickerstreak@33
|
2379 UIErrorsFrame:AddMessage(VALIDATION_ERROR, 1, 0, 0)
|
flickerstreak@33
|
2380 return
|
flickerstreak@33
|
2381 end
|
flickerstreak@33
|
2382 end
|
flickerstreak@33
|
2383 if editBoxFrame.parent and editBoxFrame.parent.editBoxFunc then
|
flickerstreak@33
|
2384 local t
|
flickerstreak@33
|
2385 if editBox.realText ~= "NONE" then
|
flickerstreak@33
|
2386 t = editBox.realText or editBox:GetText() or ""
|
flickerstreak@33
|
2387 end
|
flickerstreak@33
|
2388 editBoxFrame.parent.editBoxFunc(getArgs(editBoxFrame.parent, 'editBoxArg', 1, t))
|
flickerstreak@33
|
2389 end
|
flickerstreak@33
|
2390 self:Close(editBoxFrame.level)
|
flickerstreak@33
|
2391 for i = 1, editBoxFrame.level - 1 do
|
flickerstreak@33
|
2392 Refresh(self, levels[i])
|
flickerstreak@33
|
2393 end
|
flickerstreak@33
|
2394 StartCounting(self, editBoxFrame.level-1)
|
flickerstreak@33
|
2395 end)
|
flickerstreak@33
|
2396 editBox:SetScript("OnEscapePressed", function()
|
flickerstreak@33
|
2397 self:Close(editBoxFrame.level)
|
flickerstreak@33
|
2398 StartCounting(self, editBoxFrame.level-1)
|
flickerstreak@33
|
2399 end)
|
flickerstreak@33
|
2400 editBox:SetScript("OnReceiveDrag", function(this)
|
flickerstreak@33
|
2401 if GetCursorInfo then
|
flickerstreak@33
|
2402 local type, alpha, bravo = GetCursorInfo()
|
flickerstreak@33
|
2403 local text
|
flickerstreak@33
|
2404 if type == "spell" then
|
flickerstreak@33
|
2405 text = GetSpellName(alpha, bravo)
|
flickerstreak@33
|
2406 elseif type == "item" then
|
flickerstreak@33
|
2407 text = bravo
|
flickerstreak@33
|
2408 end
|
flickerstreak@33
|
2409 if not text then
|
flickerstreak@33
|
2410 return
|
flickerstreak@33
|
2411 end
|
flickerstreak@33
|
2412 ClearCursor()
|
flickerstreak@33
|
2413 editBox:SetText(text)
|
flickerstreak@33
|
2414 end
|
flickerstreak@33
|
2415 end)
|
flickerstreak@33
|
2416 local changing = false
|
flickerstreak@33
|
2417 local skipNext = false
|
flickerstreak@33
|
2418
|
flickerstreak@33
|
2419 function editBox:SpecialSetText(text)
|
flickerstreak@33
|
2420 local oldText = editBox:GetText() or ""
|
flickerstreak@33
|
2421 if not text then
|
flickerstreak@33
|
2422 text = ""
|
flickerstreak@33
|
2423 end
|
flickerstreak@33
|
2424 if text ~= oldText then
|
flickerstreak@33
|
2425 changing = true
|
flickerstreak@33
|
2426 self:SetText(tostring(text))
|
flickerstreak@33
|
2427 changing = false
|
flickerstreak@33
|
2428 skipNext = true
|
flickerstreak@33
|
2429 end
|
flickerstreak@33
|
2430 end
|
flickerstreak@33
|
2431
|
flickerstreak@33
|
2432 editBox:SetScript("OnTextChanged", function()
|
flickerstreak@33
|
2433 if skipNext then
|
flickerstreak@33
|
2434 skipNext = false
|
flickerstreak@33
|
2435 elseif not changing and editBoxFrame.parent and editBoxFrame.parent.editBoxChangeFunc then
|
flickerstreak@33
|
2436 local t
|
flickerstreak@33
|
2437 if editBox.realText ~= "NONE" then
|
flickerstreak@33
|
2438 t = editBox.realText or editBox:GetText() or ""
|
flickerstreak@33
|
2439 end
|
flickerstreak@33
|
2440 local text = editBoxFrame.parent.editBoxChangeFunc(getArgs(editBoxFrame.parent, 'editBoxChangeArg', 1, t))
|
flickerstreak@33
|
2441 if text then
|
flickerstreak@33
|
2442 editBox:SpecialSetText(text)
|
flickerstreak@33
|
2443 end
|
flickerstreak@33
|
2444 end
|
flickerstreak@33
|
2445 end)
|
flickerstreak@33
|
2446 editBoxFrame:SetScript("OnEnter", function()
|
flickerstreak@33
|
2447 StopCounting(self, editBoxFrame.level)
|
flickerstreak@33
|
2448 showGameTooltip(editBoxFrame.parent)
|
flickerstreak@33
|
2449 end)
|
flickerstreak@33
|
2450 editBoxFrame:SetScript("OnLeave", function()
|
flickerstreak@33
|
2451 GameTooltip:Hide()
|
flickerstreak@33
|
2452 end)
|
flickerstreak@33
|
2453 editBox:SetScript("OnEnter", function()
|
flickerstreak@33
|
2454 StopCounting(self, editBoxFrame.level)
|
flickerstreak@33
|
2455 showGameTooltip(editBoxFrame.parent)
|
flickerstreak@33
|
2456 end)
|
flickerstreak@33
|
2457 editBox:SetScript("OnLeave", function()
|
flickerstreak@33
|
2458 GameTooltip:Hide()
|
flickerstreak@33
|
2459 end)
|
flickerstreak@33
|
2460 editBoxFrame:SetScript("OnKeyDown", function(this, a1)
|
flickerstreak@33
|
2461 if not editBox.keybinding then
|
flickerstreak@33
|
2462 return
|
flickerstreak@33
|
2463 end
|
flickerstreak@33
|
2464 local arg1 = a1 or arg1
|
flickerstreak@33
|
2465 local screenshotKey = GetBindingKey("SCREENSHOT")
|
flickerstreak@33
|
2466 if screenshotKey and arg1 == screenshotKey then
|
flickerstreak@33
|
2467 Screenshot()
|
flickerstreak@33
|
2468 return
|
flickerstreak@33
|
2469 end
|
flickerstreak@33
|
2470
|
flickerstreak@33
|
2471 if arg1 == "LeftButton" then
|
flickerstreak@33
|
2472 arg1 = "BUTTON1"
|
flickerstreak@33
|
2473 elseif arg1 == "RightButton" then
|
flickerstreak@33
|
2474 arg1 = "BUTTON2"
|
flickerstreak@33
|
2475 elseif arg1 == "MiddleButton" then
|
flickerstreak@33
|
2476 arg1 = "BUTTON3"
|
flickerstreak@33
|
2477 elseif arg1 == "Button4" then
|
flickerstreak@33
|
2478 arg1 = "BUTTON4"
|
flickerstreak@33
|
2479 elseif arg1 == "Button5" then
|
flickerstreak@33
|
2480 arg1 = "BUTTON5"
|
flickerstreak@33
|
2481 end
|
flickerstreak@33
|
2482 if arg1 == "UNKNOWN" then
|
flickerstreak@33
|
2483 return
|
flickerstreak@33
|
2484 elseif arg1 == "SHIFT" or arg1 == "CTRL" or arg1 == "ALT" then
|
flickerstreak@33
|
2485 return
|
flickerstreak@33
|
2486 elseif arg1 == "ENTER" then
|
flickerstreak@33
|
2487 if editBox.keybindingOnly and not editBox.keybindingOnly[editBox.realText] then
|
flickerstreak@33
|
2488 return editBox:GetScript("OnEscapePressed")()
|
flickerstreak@33
|
2489 elseif editBox.keybindingExcept and editBox.keybindingExcept[editBox.realText] then
|
flickerstreak@33
|
2490 return editBox:GetScript("OnEscapePressed")()
|
flickerstreak@33
|
2491 else
|
flickerstreak@33
|
2492 return editBox:GetScript("OnEnterPressed")()
|
flickerstreak@33
|
2493 end
|
flickerstreak@33
|
2494 elseif arg1 == "ESCAPE" then
|
flickerstreak@33
|
2495 if editBox.realText == "NONE" then
|
flickerstreak@33
|
2496 return editBox:GetScript("OnEscapePressed")()
|
flickerstreak@33
|
2497 else
|
flickerstreak@33
|
2498 editBox:SpecialSetText(NONE or "NONE")
|
flickerstreak@33
|
2499 editBox.realText = "NONE"
|
flickerstreak@33
|
2500 return
|
flickerstreak@33
|
2501 end
|
flickerstreak@33
|
2502 elseif editBox.keybindingOnly and not editBox.keybindingOnly[arg1] then
|
flickerstreak@33
|
2503 return
|
flickerstreak@33
|
2504 elseif editBox.keybindingExcept and editBox.keybindingExcept[arg1] then
|
flickerstreak@33
|
2505 return
|
flickerstreak@33
|
2506 end
|
flickerstreak@33
|
2507 local s = GetBindingText(arg1, "KEY_")
|
flickerstreak@33
|
2508 if s == "BUTTON1" then
|
flickerstreak@33
|
2509 s = KEY_BUTTON1
|
flickerstreak@33
|
2510 elseif s == "BUTTON2" then
|
flickerstreak@33
|
2511 s = KEY_BUTTON2
|
flickerstreak@33
|
2512 end
|
flickerstreak@33
|
2513 local real = arg1
|
flickerstreak@33
|
2514 if IsShiftKeyDown() then
|
flickerstreak@33
|
2515 s = "Shift-" .. s
|
flickerstreak@33
|
2516 real = "SHIFT-" .. real
|
flickerstreak@33
|
2517 end
|
flickerstreak@33
|
2518 if IsControlKeyDown() then
|
flickerstreak@33
|
2519 s = "Ctrl-" .. s
|
flickerstreak@33
|
2520 real = "CTRL-" .. real
|
flickerstreak@33
|
2521 end
|
flickerstreak@33
|
2522 if IsAltKeyDown() then
|
flickerstreak@33
|
2523 s = "Alt-" .. s
|
flickerstreak@33
|
2524 real = "ALT-" .. real
|
flickerstreak@33
|
2525 end
|
flickerstreak@33
|
2526 if editBox:GetText() ~= s then
|
flickerstreak@33
|
2527 editBox:SpecialSetText("-")
|
flickerstreak@33
|
2528 editBox:SpecialSetText(s)
|
flickerstreak@33
|
2529 editBox.realText = real
|
flickerstreak@33
|
2530 return editBox:GetScript("OnTextChanged")()
|
flickerstreak@33
|
2531 end
|
flickerstreak@33
|
2532 end)
|
flickerstreak@33
|
2533 editBoxFrame:SetScript("OnMouseDown", editBoxFrame:GetScript("OnKeyDown"))
|
flickerstreak@33
|
2534 editBox:SetScript("OnMouseDown", function(this, ...)
|
flickerstreak@33
|
2535 if GetCursorInfo and (CursorHasItem() or CursorHasSpell()) then
|
flickerstreak@33
|
2536 return editBox:GetScript("OnReceiveDrag")(this, ...)
|
flickerstreak@33
|
2537 end
|
flickerstreak@33
|
2538 return editBoxFrame:GetScript("OnKeyDown")(this, ...)
|
flickerstreak@33
|
2539 end)
|
flickerstreak@33
|
2540 editBoxFrame:SetScript("OnMouseWheel", function(t, a1)
|
flickerstreak@33
|
2541 local arg1 = a1 or arg1
|
flickerstreak@33
|
2542 local up = arg1 > 0
|
flickerstreak@33
|
2543 arg1 = up and "MOUSEWHEELUP" or "MOUSEWHEELDOWN"
|
flickerstreak@33
|
2544 return editBoxFrame:GetScript("OnKeyDown")(t or this, arg1)
|
flickerstreak@33
|
2545 end)
|
flickerstreak@33
|
2546 editBox:SetScript("OnMouseWheel", editBoxFrame:GetScript("OnMouseWheel"))
|
flickerstreak@33
|
2547 end
|
flickerstreak@33
|
2548 editBoxFrame.parent = parent
|
flickerstreak@33
|
2549 editBoxFrame.level = parent.level.num + 1
|
flickerstreak@33
|
2550 editBoxFrame.parentValue = parent.level.value
|
flickerstreak@33
|
2551 editBoxFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3)
|
flickerstreak@33
|
2552 editBoxFrame.editBox:SetFrameLevel(editBoxFrame:GetFrameLevel() + 1)
|
flickerstreak@33
|
2553 editBoxFrame.editBox.realText = nil
|
flickerstreak@33
|
2554 editBoxFrame:SetClampedToScreen(false)
|
flickerstreak@33
|
2555
|
flickerstreak@33
|
2556 editBoxFrame.editBox:SpecialSetText("")
|
flickerstreak@33
|
2557 if parent.editBoxIsKeybinding then
|
flickerstreak@33
|
2558 local s = parent.editBoxText
|
flickerstreak@33
|
2559 if s == "" then
|
flickerstreak@33
|
2560 s = "NONE"
|
flickerstreak@33
|
2561 end
|
flickerstreak@33
|
2562 editBoxFrame.editBox.realText = s
|
flickerstreak@33
|
2563 if s and s ~= "NONE" then
|
flickerstreak@33
|
2564 local alpha,bravo = s:match("^(.+)%-(.+)$")
|
flickerstreak@33
|
2565 if not bravo then
|
flickerstreak@33
|
2566 alpha = nil
|
flickerstreak@33
|
2567 bravo = s
|
flickerstreak@33
|
2568 end
|
flickerstreak@33
|
2569 bravo = GetBindingText(bravo, "KEY_")
|
flickerstreak@33
|
2570 if alpha then
|
flickerstreak@33
|
2571 editBoxFrame.editBox:SpecialSetText(alpha:upper() .. "-" .. bravo)
|
flickerstreak@33
|
2572 else
|
flickerstreak@33
|
2573 editBoxFrame.editBox:SpecialSetText(bravo)
|
flickerstreak@33
|
2574 end
|
flickerstreak@33
|
2575 else
|
flickerstreak@33
|
2576 editBoxFrame.editBox:SpecialSetText(NONE or "NONE")
|
flickerstreak@33
|
2577 end
|
flickerstreak@33
|
2578 else
|
flickerstreak@33
|
2579 editBoxFrame.editBox:SpecialSetText(parent.editBoxText)
|
flickerstreak@33
|
2580 end
|
flickerstreak@33
|
2581
|
flickerstreak@33
|
2582 editBoxFrame.editBox.keybinding = parent.editBoxIsKeybinding
|
flickerstreak@33
|
2583 editBoxFrame.editBox.keybindingOnly = parent.editBoxKeybindingOnly
|
flickerstreak@33
|
2584 editBoxFrame.editBox.keybindingExcept = parent.editBoxKeybindingExcept
|
flickerstreak@33
|
2585 editBoxFrame.editBox:EnableKeyboard(not parent.editBoxIsKeybinding)
|
flickerstreak@33
|
2586 editBoxFrame:EnableKeyboard(parent.editBoxIsKeybinding)
|
flickerstreak@33
|
2587
|
flickerstreak@33
|
2588 if parent.arrow then
|
flickerstreak@33
|
2589 -- parent.arrow:SetVertexColor(0.2, 0.6, 0)
|
flickerstreak@33
|
2590 -- parent.arrow:SetHeight(24)
|
flickerstreak@33
|
2591 -- parent.arrow:SetWidth(24)
|
flickerstreak@33
|
2592 parent.selected = true
|
flickerstreak@33
|
2593 parent.highlight:Show()
|
flickerstreak@33
|
2594 end
|
flickerstreak@33
|
2595
|
flickerstreak@33
|
2596 local level = parent.level
|
flickerstreak@33
|
2597 editBoxFrame:Show()
|
flickerstreak@33
|
2598 editBoxFrame:ClearAllPoints()
|
flickerstreak@33
|
2599 if level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
2600 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2601 editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
|
flickerstreak@33
|
2602 else
|
flickerstreak@33
|
2603 editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
|
flickerstreak@33
|
2604 end
|
flickerstreak@33
|
2605 else
|
flickerstreak@33
|
2606 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2607 editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
|
flickerstreak@33
|
2608 else
|
flickerstreak@33
|
2609 editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
|
flickerstreak@33
|
2610 end
|
flickerstreak@33
|
2611 end
|
flickerstreak@33
|
2612 local dirty
|
flickerstreak@33
|
2613 if level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
2614 if editBoxFrame:GetRight() > GetScreenWidth() then
|
flickerstreak@33
|
2615 level.lastDirection = "LEFT"
|
flickerstreak@33
|
2616 dirty = true
|
flickerstreak@33
|
2617 end
|
flickerstreak@33
|
2618 elseif editBoxFrame:GetLeft() < 0 then
|
flickerstreak@33
|
2619 level.lastDirection = "RIGHT"
|
flickerstreak@33
|
2620 dirty = true
|
flickerstreak@33
|
2621 end
|
flickerstreak@33
|
2622 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2623 if editBoxFrame:GetBottom() < 0 then
|
flickerstreak@33
|
2624 level.lastVDirection = "UP"
|
flickerstreak@33
|
2625 dirty = true
|
flickerstreak@33
|
2626 end
|
flickerstreak@33
|
2627 elseif editBoxFrame:GetTop() > GetScreenWidth() then
|
flickerstreak@33
|
2628 level.lastVDirection = "DOWN"
|
flickerstreak@33
|
2629 dirty = true
|
flickerstreak@33
|
2630 end
|
flickerstreak@33
|
2631 if dirty then
|
flickerstreak@33
|
2632 editBoxFrame:ClearAllPoints()
|
flickerstreak@33
|
2633 if level.lastDirection == "RIGHT" then
|
flickerstreak@33
|
2634 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2635 editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
|
flickerstreak@33
|
2636 else
|
flickerstreak@33
|
2637 editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
|
flickerstreak@33
|
2638 end
|
flickerstreak@33
|
2639 else
|
flickerstreak@33
|
2640 if level.lastVDirection == "DOWN" then
|
flickerstreak@33
|
2641 editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
|
flickerstreak@33
|
2642 else
|
flickerstreak@33
|
2643 editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
|
flickerstreak@33
|
2644 end
|
flickerstreak@33
|
2645 end
|
flickerstreak@33
|
2646 end
|
flickerstreak@33
|
2647 local left, bottom = editBoxFrame:GetLeft(), editBoxFrame:GetBottom()
|
flickerstreak@33
|
2648 editBoxFrame:ClearAllPoints()
|
flickerstreak@33
|
2649 editBoxFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
|
flickerstreak@33
|
2650 if mod(level.num, 5) == 0 then
|
flickerstreak@33
|
2651 local left, bottom = level:GetLeft(), level:GetBottom()
|
flickerstreak@33
|
2652 level:ClearAllPoints()
|
flickerstreak@33
|
2653 level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
|
flickerstreak@33
|
2654 end
|
flickerstreak@33
|
2655 editBoxFrame:SetClampedToScreen(true)
|
flickerstreak@33
|
2656 end
|
flickerstreak@33
|
2657
|
flickerstreak@33
|
2658 function Dewdrop:EncodeKeybinding(text)
|
flickerstreak@33
|
2659 if text == nil or text == "NONE" then
|
flickerstreak@33
|
2660 return nil
|
flickerstreak@33
|
2661 end
|
flickerstreak@33
|
2662 text = tostring(text):upper()
|
flickerstreak@33
|
2663 local shift, ctrl, alt
|
flickerstreak@33
|
2664 local modifier
|
flickerstreak@33
|
2665 while true do
|
flickerstreak@33
|
2666 if text == "-" then
|
flickerstreak@33
|
2667 break
|
flickerstreak@33
|
2668 end
|
flickerstreak@33
|
2669 modifier, text = strsplit('-', text, 2)
|
flickerstreak@33
|
2670 if text then
|
flickerstreak@33
|
2671 if modifier ~= "SHIFT" and modifier ~= "CTRL" and modifier ~= "ALT" then
|
flickerstreak@33
|
2672 return false
|
flickerstreak@33
|
2673 end
|
flickerstreak@33
|
2674 if modifier == "SHIFT" then
|
flickerstreak@33
|
2675 if shift then
|
flickerstreak@33
|
2676 return false
|
flickerstreak@33
|
2677 end
|
flickerstreak@33
|
2678 shift = true
|
flickerstreak@33
|
2679 end
|
flickerstreak@33
|
2680 if modifier == "CTRL" then
|
flickerstreak@33
|
2681 if ctrl then
|
flickerstreak@33
|
2682 return false
|
flickerstreak@33
|
2683 end
|
flickerstreak@33
|
2684 ctrl = true
|
flickerstreak@33
|
2685 end
|
flickerstreak@33
|
2686 if modifier == "ALT" then
|
flickerstreak@33
|
2687 if alt then
|
flickerstreak@33
|
2688 return false
|
flickerstreak@33
|
2689 end
|
flickerstreak@33
|
2690 alt = true
|
flickerstreak@33
|
2691 end
|
flickerstreak@33
|
2692 else
|
flickerstreak@33
|
2693 text = modifier
|
flickerstreak@33
|
2694 break
|
flickerstreak@33
|
2695 end
|
flickerstreak@33
|
2696 end
|
flickerstreak@33
|
2697 if not text:find("^F%d+$") and text ~= "CAPSLOCK" and text:len() ~= 1 and (text:len() == 0 or text:byte() < 128 or text:len() > 4) and not _G["KEY_" .. text] and text ~= "BUTTON1" and text ~= "BUTTON2" then
|
flickerstreak@33
|
2698 return false
|
flickerstreak@33
|
2699 end
|
flickerstreak@33
|
2700 local s = GetBindingText(text, "KEY_")
|
flickerstreak@33
|
2701 if s == "BUTTON1" then
|
flickerstreak@33
|
2702 s = KEY_BUTTON1
|
flickerstreak@33
|
2703 elseif s == "BUTTON2" then
|
flickerstreak@33
|
2704 s = KEY_BUTTON2
|
flickerstreak@33
|
2705 end
|
flickerstreak@33
|
2706 if shift then
|
flickerstreak@33
|
2707 s = "Shift-" .. s
|
flickerstreak@33
|
2708 end
|
flickerstreak@33
|
2709 if ctrl then
|
flickerstreak@33
|
2710 s = "Ctrl-" .. s
|
flickerstreak@33
|
2711 end
|
flickerstreak@33
|
2712 if alt then
|
flickerstreak@33
|
2713 s = "Alt-" .. s
|
flickerstreak@33
|
2714 end
|
flickerstreak@33
|
2715 return s
|
flickerstreak@33
|
2716 end
|
flickerstreak@33
|
2717
|
flickerstreak@33
|
2718 function Dewdrop:IsOpen(parent)
|
flickerstreak@33
|
2719 self:argCheck(parent, 2, "table", "string", "nil")
|
flickerstreak@33
|
2720 return levels[1] and levels[1]:IsShown() and (not parent or parent == levels[1].parent or parent == levels[1]:GetParent())
|
flickerstreak@33
|
2721 end
|
flickerstreak@33
|
2722
|
flickerstreak@33
|
2723 function Dewdrop:GetOpenedParent()
|
flickerstreak@33
|
2724 return (levels[1] and levels[1]:IsShown()) and (levels[1].parent or levels[1]:GetParent())
|
flickerstreak@33
|
2725 end
|
flickerstreak@33
|
2726
|
flickerstreak@33
|
2727 function Open(self, parent, func, level, value, point, relativePoint, cursorX, cursorY)
|
flickerstreak@33
|
2728 self:Close(level)
|
flickerstreak@33
|
2729 if DewdropLib then
|
flickerstreak@33
|
2730 local d = DewdropLib:GetInstance('1.0')
|
flickerstreak@33
|
2731 local ret, val = pcall(d, IsOpen, d)
|
flickerstreak@33
|
2732 if ret and val then
|
flickerstreak@33
|
2733 DewdropLib:GetInstance('1.0'):Close()
|
flickerstreak@33
|
2734 end
|
flickerstreak@33
|
2735 end
|
flickerstreak@33
|
2736 if type(parent) == "table" then
|
flickerstreak@33
|
2737 parent:GetCenter()
|
flickerstreak@33
|
2738 end
|
flickerstreak@33
|
2739 local frame = AcquireLevel(self, level)
|
flickerstreak@33
|
2740 if level == 1 then
|
flickerstreak@33
|
2741 frame.lastDirection = "RIGHT"
|
flickerstreak@33
|
2742 frame.lastVDirection = "DOWN"
|
flickerstreak@33
|
2743 else
|
flickerstreak@33
|
2744 frame.lastDirection = levels[level - 1].lastDirection
|
flickerstreak@33
|
2745 frame.lastVDirection = levels[level - 1].lastVDirection
|
flickerstreak@33
|
2746 end
|
flickerstreak@33
|
2747 frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
flickerstreak@33
|
2748 frame:ClearAllPoints()
|
flickerstreak@33
|
2749 frame.parent = parent
|
flickerstreak@33
|
2750 frame:SetPoint("LEFT", UIParent, "RIGHT", 10000, 0)
|
flickerstreak@33
|
2751 frame:Show()
|
flickerstreak@33
|
2752 if level == 1 then
|
flickerstreak@33
|
2753 baseFunc = func
|
flickerstreak@33
|
2754 end
|
flickerstreak@33
|
2755 levels[level].value = value
|
flickerstreak@33
|
2756 -- levels[level].parentText = parent.text and parent.text:GetText() or nil
|
flickerstreak@33
|
2757 -- levels[level].parentTooltipTitle = parent.tooltipTitle
|
flickerstreak@33
|
2758 -- levels[level].parentTooltipText = parent.tooltipText
|
flickerstreak@33
|
2759 -- levels[level].parentTooltipFunc = parent.tooltipFunc
|
flickerstreak@33
|
2760 if type(parent) == "table" and parent.arrow then
|
flickerstreak@33
|
2761 -- parent.arrow:SetVertexColor(0.2, 0.6, 0)
|
flickerstreak@33
|
2762 -- parent.arrow:SetHeight(24)
|
flickerstreak@33
|
2763 -- parent.arrow:SetWidth(24)
|
flickerstreak@33
|
2764 parent.selected = true
|
flickerstreak@33
|
2765 parent.highlight:Show()
|
flickerstreak@33
|
2766 end
|
flickerstreak@33
|
2767 relativePoint = relativePoint or point
|
flickerstreak@33
|
2768 Refresh(self, levels[level])
|
flickerstreak@33
|
2769 if point or (cursorX and cursorY) then
|
flickerstreak@33
|
2770 frame:ClearAllPoints()
|
flickerstreak@33
|
2771 if cursorX and cursorY then
|
flickerstreak@33
|
2772 local curX, curY = GetScaledCursorPosition()
|
flickerstreak@33
|
2773 if curY < GetScreenHeight() / 2 then
|
flickerstreak@33
|
2774 point, relativePoint = "BOTTOM", "BOTTOM"
|
flickerstreak@33
|
2775 else
|
flickerstreak@33
|
2776 point, relativePoint = "TOP", "TOP"
|
flickerstreak@33
|
2777 end
|
flickerstreak@33
|
2778 if curX < GetScreenWidth() / 2 then
|
flickerstreak@33
|
2779 point, relativePoint = point .. "LEFT", relativePoint .. "RIGHT"
|
flickerstreak@33
|
2780 else
|
flickerstreak@33
|
2781 point, relativePoint = point .. "RIGHT", relativePoint .. "LEFT"
|
flickerstreak@33
|
2782 end
|
flickerstreak@33
|
2783 end
|
flickerstreak@33
|
2784 frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint)
|
flickerstreak@33
|
2785 if cursorX and cursorY then
|
flickerstreak@33
|
2786 local left = frame:GetLeft()
|
flickerstreak@33
|
2787 local width = frame:GetWidth()
|
flickerstreak@33
|
2788 local bottom = frame:GetBottom()
|
flickerstreak@33
|
2789 local height = frame:GetHeight()
|
flickerstreak@33
|
2790 local curX, curY = GetScaledCursorPosition()
|
flickerstreak@33
|
2791 frame:ClearAllPoints()
|
flickerstreak@33
|
2792 relativePoint = relativePoint or point
|
flickerstreak@33
|
2793 if point == "BOTTOM" or point == "TOP" then
|
flickerstreak@33
|
2794 if curX < GetScreenWidth() / 2 then
|
flickerstreak@33
|
2795 point = point .. "LEFT"
|
flickerstreak@33
|
2796 else
|
flickerstreak@33
|
2797 point = point .. "RIGHT"
|
flickerstreak@33
|
2798 end
|
flickerstreak@33
|
2799 elseif point == "CENTER" then
|
flickerstreak@33
|
2800 if curX < GetScreenWidth() / 2 then
|
flickerstreak@33
|
2801 point = "LEFT"
|
flickerstreak@33
|
2802 else
|
flickerstreak@33
|
2803 point = "RIGHT"
|
flickerstreak@33
|
2804 end
|
flickerstreak@33
|
2805 end
|
flickerstreak@33
|
2806 local xOffset, yOffset = 0, 0
|
flickerstreak@33
|
2807 if curY > GetScreenHeight() / 2 then
|
flickerstreak@33
|
2808 yOffset = -height
|
flickerstreak@33
|
2809 end
|
flickerstreak@33
|
2810 if curX > GetScreenWidth() / 2 then
|
flickerstreak@33
|
2811 xOffset = -width
|
flickerstreak@33
|
2812 end
|
flickerstreak@33
|
2813 frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left + xOffset, curY - bottom + yOffset)
|
flickerstreak@33
|
2814 if level == 1 then
|
flickerstreak@33
|
2815 frame.lastDirection = "RIGHT"
|
flickerstreak@33
|
2816 end
|
flickerstreak@33
|
2817 elseif cursorX then
|
flickerstreak@33
|
2818 local left = frame:GetLeft()
|
flickerstreak@33
|
2819 local width = frame:GetWidth()
|
flickerstreak@33
|
2820 local curX, curY = GetScaledCursorPosition()
|
flickerstreak@33
|
2821 frame:ClearAllPoints()
|
flickerstreak@33
|
2822 relativePoint = relativePoint or point
|
flickerstreak@33
|
2823 if point == "BOTTOM" or point == "TOP" then
|
flickerstreak@33
|
2824 if curX < GetScreenWidth() / 2 then
|
flickerstreak@33
|
2825 point = point .. "LEFT"
|
flickerstreak@33
|
2826 else
|
flickerstreak@33
|
2827 point = point .. "RIGHT"
|
flickerstreak@33
|
2828 end
|
flickerstreak@33
|
2829 elseif point == "CENTER" then
|
flickerstreak@33
|
2830 if curX < GetScreenWidth() / 2 then
|
flickerstreak@33
|
2831 point = "LEFT"
|
flickerstreak@33
|
2832 else
|
flickerstreak@33
|
2833 point = "RIGHT"
|
flickerstreak@33
|
2834 end
|
flickerstreak@33
|
2835 end
|
flickerstreak@33
|
2836 frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left - width / 2, 0)
|
flickerstreak@33
|
2837 if level == 1 then
|
flickerstreak@33
|
2838 frame.lastDirection = "RIGHT"
|
flickerstreak@33
|
2839 end
|
flickerstreak@33
|
2840 elseif cursorY then
|
flickerstreak@33
|
2841 local bottom = frame:GetBottom()
|
flickerstreak@33
|
2842 local height = frame:GetHeight()
|
flickerstreak@33
|
2843 local curX, curY = GetScaledCursorPosition()
|
flickerstreak@33
|
2844 frame:ClearAllPoints()
|
flickerstreak@33
|
2845 relativePoint = relativePoint or point
|
flickerstreak@33
|
2846 if point == "LEFT" or point == "RIGHT" then
|
flickerstreak@33
|
2847 if curX < GetScreenHeight() / 2 then
|
flickerstreak@33
|
2848 point = point .. "BOTTOM"
|
flickerstreak@33
|
2849 else
|
flickerstreak@33
|
2850 point = point .. "TOP"
|
flickerstreak@33
|
2851 end
|
flickerstreak@33
|
2852 elseif point == "CENTER" then
|
flickerstreak@33
|
2853 if curX < GetScreenHeight() / 2 then
|
flickerstreak@33
|
2854 point = "BOTTOM"
|
flickerstreak@33
|
2855 else
|
flickerstreak@33
|
2856 point = "TOP"
|
flickerstreak@33
|
2857 end
|
flickerstreak@33
|
2858 end
|
flickerstreak@33
|
2859 frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, 0, curY - bottom - height / 2)
|
flickerstreak@33
|
2860 if level == 1 then
|
flickerstreak@33
|
2861 frame.lastDirection = "DOWN"
|
flickerstreak@33
|
2862 end
|
flickerstreak@33
|
2863 end
|
flickerstreak@33
|
2864 if (strsub(point, 1, 3) ~= strsub(relativePoint, 1, 3)) then
|
flickerstreak@33
|
2865 if frame:GetBottom() < 0 then
|
flickerstreak@33
|
2866 local point, parent, relativePoint, x, y = frame:GetPoint(1)
|
flickerstreak@33
|
2867 local change = GetScreenHeight() - frame:GetTop()
|
flickerstreak@33
|
2868 local otherChange = -frame:GetBottom()
|
flickerstreak@33
|
2869 if otherChange < change then
|
flickerstreak@33
|
2870 change = otherChange
|
flickerstreak@33
|
2871 end
|
flickerstreak@33
|
2872 frame:SetPoint(point, parent, relativePoint, x, y + change)
|
flickerstreak@33
|
2873 elseif frame:GetTop() > GetScreenHeight() then
|
flickerstreak@33
|
2874 local point, parent, relativePoint, x, y = frame:GetPoint(1)
|
flickerstreak@33
|
2875 local change = GetScreenHeight() - frame:GetTop()
|
flickerstreak@33
|
2876 local otherChange = -frame:GetBottom()
|
flickerstreak@33
|
2877 if otherChange < change then
|
flickerstreak@33
|
2878 change = otherChange
|
flickerstreak@33
|
2879 end
|
flickerstreak@33
|
2880 frame:SetPoint(point, parent, relativePoint, x, y + change)
|
flickerstreak@33
|
2881 end
|
flickerstreak@33
|
2882 end
|
flickerstreak@33
|
2883 end
|
flickerstreak@33
|
2884 CheckDualMonitor(self, frame)
|
flickerstreak@33
|
2885 frame:SetClampedToScreen(true)
|
flickerstreak@33
|
2886 frame:SetClampedToScreen(false)
|
flickerstreak@33
|
2887 StartCounting(self, level)
|
flickerstreak@33
|
2888 end
|
flickerstreak@33
|
2889
|
flickerstreak@33
|
2890 function Dewdrop:IsRegistered(parent)
|
flickerstreak@33
|
2891 self:argCheck(parent, 2, "table", "string")
|
flickerstreak@33
|
2892 return not not self.registry[parent]
|
flickerstreak@33
|
2893 end
|
flickerstreak@33
|
2894
|
flickerstreak@33
|
2895 function Dewdrop:Register(parent, ...)
|
flickerstreak@33
|
2896 self:argCheck(parent, 2, "table", "string")
|
flickerstreak@33
|
2897 if self.registry[parent] then
|
flickerstreak@33
|
2898 self:Unregister(parent)
|
flickerstreak@33
|
2899 end
|
flickerstreak@33
|
2900 local info = new(...)
|
flickerstreak@33
|
2901 if type(info.children) == "table" then
|
flickerstreak@33
|
2902 local err, position = validateOptions(info.children)
|
flickerstreak@33
|
2903
|
flickerstreak@33
|
2904 if err then
|
flickerstreak@33
|
2905 if position then
|
flickerstreak@33
|
2906 Dewdrop:error(position .. ": " .. err)
|
flickerstreak@33
|
2907 else
|
flickerstreak@33
|
2908 Dewdrop:error(err)
|
flickerstreak@33
|
2909 end
|
flickerstreak@33
|
2910 end
|
flickerstreak@33
|
2911 end
|
flickerstreak@33
|
2912 self.registry[parent] = info
|
flickerstreak@33
|
2913 if not info.dontHook and not self.onceRegistered[parent] and type(parent) == "table" then
|
flickerstreak@33
|
2914 if parent:HasScript("OnMouseUp") then
|
flickerstreak@33
|
2915 local script = parent:GetScript("OnMouseUp")
|
flickerstreak@33
|
2916 parent:SetScript("OnMouseUp", function(this, ...)
|
flickerstreak@33
|
2917 if script then
|
flickerstreak@33
|
2918 script(this, ...)
|
flickerstreak@33
|
2919 end
|
flickerstreak@33
|
2920 if arg1 == "RightButton" and self.registry[parent] then
|
flickerstreak@33
|
2921 if self:IsOpen(parent) then
|
flickerstreak@33
|
2922 self:Close()
|
flickerstreak@33
|
2923 else
|
flickerstreak@33
|
2924 self:Open(parent)
|
flickerstreak@33
|
2925 end
|
flickerstreak@33
|
2926 end
|
flickerstreak@33
|
2927 end)
|
flickerstreak@33
|
2928 end
|
flickerstreak@33
|
2929 if parent:HasScript("OnMouseDown") then
|
flickerstreak@33
|
2930 local script = parent:GetScript("OnMouseDown")
|
flickerstreak@33
|
2931 parent:SetScript("OnMouseDown", function(this, ...)
|
flickerstreak@33
|
2932 if script then
|
flickerstreak@33
|
2933 script(this, ...)
|
flickerstreak@33
|
2934 end
|
flickerstreak@33
|
2935 if self.registry[parent] then
|
flickerstreak@33
|
2936 self:Close()
|
flickerstreak@33
|
2937 end
|
flickerstreak@33
|
2938 end)
|
flickerstreak@33
|
2939 end
|
flickerstreak@33
|
2940 end
|
flickerstreak@33
|
2941 self.onceRegistered[parent] = true
|
flickerstreak@33
|
2942 end
|
flickerstreak@33
|
2943
|
flickerstreak@33
|
2944 function Dewdrop:Unregister(parent)
|
flickerstreak@33
|
2945 self:argCheck(parent, 2, "table", "string")
|
flickerstreak@33
|
2946 self.registry[parent] = nil
|
flickerstreak@33
|
2947 end
|
flickerstreak@33
|
2948
|
flickerstreak@33
|
2949 function Dewdrop:Open(parent, ...)
|
flickerstreak@33
|
2950 self:argCheck(parent, 2, "table", "string")
|
flickerstreak@33
|
2951 local info
|
flickerstreak@33
|
2952 local k1 = ...
|
flickerstreak@33
|
2953 if type(k1) == "table" and k1[0] and k1.IsFrameType and self.registry[k1] then
|
flickerstreak@33
|
2954 info = tmp(select(2, ...))
|
flickerstreak@33
|
2955 for k,v in pairs(self.registry[k1]) do
|
flickerstreak@33
|
2956 if info[k] == nil then
|
flickerstreak@33
|
2957 info[k] = v
|
flickerstreak@33
|
2958 end
|
flickerstreak@33
|
2959 end
|
flickerstreak@33
|
2960 else
|
flickerstreak@33
|
2961 info = tmp(...)
|
flickerstreak@33
|
2962 if self.registry[parent] then
|
flickerstreak@33
|
2963 for k,v in pairs(self.registry[parent]) do
|
flickerstreak@33
|
2964 if info[k] == nil then
|
flickerstreak@33
|
2965 info[k] = v
|
flickerstreak@33
|
2966 end
|
flickerstreak@33
|
2967 end
|
flickerstreak@33
|
2968 end
|
flickerstreak@33
|
2969 end
|
flickerstreak@33
|
2970 local point = info.point
|
flickerstreak@33
|
2971 local relativePoint = info.relativePoint
|
flickerstreak@33
|
2972 local cursorX = info.cursorX
|
flickerstreak@33
|
2973 local cursorY = info.cursorY
|
flickerstreak@33
|
2974 if type(point) == "function" then
|
flickerstreak@33
|
2975 local b
|
flickerstreak@33
|
2976 point, b = point(parent)
|
flickerstreak@33
|
2977 if b then
|
flickerstreak@33
|
2978 relativePoint = b
|
flickerstreak@33
|
2979 end
|
flickerstreak@33
|
2980 end
|
flickerstreak@33
|
2981 if type(relativePoint) == "function" then
|
flickerstreak@33
|
2982 relativePoint = relativePoint(parent)
|
flickerstreak@33
|
2983 end
|
flickerstreak@33
|
2984 Open(self, parent, info.children, 1, nil, point, relativePoint, cursorX, cursorY)
|
flickerstreak@33
|
2985 end
|
flickerstreak@33
|
2986
|
flickerstreak@33
|
2987 function Clear(self, level)
|
flickerstreak@33
|
2988 if level then
|
flickerstreak@33
|
2989 if level.buttons then
|
flickerstreak@33
|
2990 for i = #level.buttons, 1, -1 do
|
flickerstreak@33
|
2991 ReleaseButton(self, level, i)
|
flickerstreak@33
|
2992 end
|
flickerstreak@33
|
2993 end
|
flickerstreak@33
|
2994 end
|
flickerstreak@33
|
2995 end
|
flickerstreak@33
|
2996
|
flickerstreak@33
|
2997 function Dewdrop:Close(level)
|
flickerstreak@33
|
2998 if DropDownList1:IsShown() then
|
flickerstreak@33
|
2999 DropDownList1:Hide()
|
flickerstreak@33
|
3000 end
|
flickerstreak@33
|
3001 if DewdropLib then
|
flickerstreak@33
|
3002 local d = DewdropLib:GetInstance('1.0')
|
flickerstreak@33
|
3003 local ret, val = pcall(d, IsOpen, d)
|
flickerstreak@33
|
3004 if ret and val then
|
flickerstreak@33
|
3005 DewdropLib:GetInstance('1.0'):Close()
|
flickerstreak@33
|
3006 end
|
flickerstreak@33
|
3007 end
|
flickerstreak@33
|
3008 self:argCheck(level, 2, "number", "nil")
|
flickerstreak@33
|
3009 if not level then
|
flickerstreak@33
|
3010 level = 1
|
flickerstreak@33
|
3011 end
|
flickerstreak@33
|
3012 if level == 1 and levels[level] then
|
flickerstreak@33
|
3013 levels[level].parented = false
|
flickerstreak@33
|
3014 end
|
flickerstreak@33
|
3015 if level > 1 and levels[level-1].buttons then
|
flickerstreak@33
|
3016 local buttons = levels[level-1].buttons
|
flickerstreak@33
|
3017 for _,button in ipairs(buttons) do
|
flickerstreak@33
|
3018 -- button.arrow:SetWidth(16)
|
flickerstreak@33
|
3019 -- button.arrow:SetHeight(16)
|
flickerstreak@33
|
3020 button.selected = nil
|
flickerstreak@33
|
3021 button.highlight:Hide()
|
flickerstreak@33
|
3022 -- button.arrow:SetVertexColor(1, 1, 1)
|
flickerstreak@33
|
3023 end
|
flickerstreak@33
|
3024 end
|
flickerstreak@33
|
3025 if sliderFrame and sliderFrame.level >= level then
|
flickerstreak@33
|
3026 sliderFrame:Hide()
|
flickerstreak@33
|
3027 end
|
flickerstreak@33
|
3028 if editBoxFrame and editBoxFrame.level >= level then
|
flickerstreak@33
|
3029 editBoxFrame:Hide()
|
flickerstreak@33
|
3030 end
|
flickerstreak@33
|
3031 for i = level, #levels do
|
flickerstreak@33
|
3032 Clear(self, levels[level])
|
flickerstreak@33
|
3033 levels[i]:Hide()
|
flickerstreak@33
|
3034 levels[i]:ClearAllPoints()
|
flickerstreak@33
|
3035 levels[i]:SetPoint("CENTER", UIParent, "CENTER")
|
flickerstreak@33
|
3036 levels[i].value = nil
|
flickerstreak@33
|
3037 end
|
flickerstreak@33
|
3038 end
|
flickerstreak@33
|
3039
|
flickerstreak@33
|
3040 function Dewdrop:AddSeparator(level)
|
flickerstreak@33
|
3041 level = levels[level or currentLevel]
|
flickerstreak@33
|
3042 if not level or not level.buttons then return; end
|
flickerstreak@33
|
3043
|
flickerstreak@33
|
3044 local prevbutton = level.buttons[#level.buttons]
|
flickerstreak@33
|
3045 if not prevbutton then return; end
|
flickerstreak@33
|
3046
|
flickerstreak@33
|
3047 if prevbutton.disabled and prevbutton.text:GetText() == "" then
|
flickerstreak@33
|
3048 return
|
flickerstreak@33
|
3049 end
|
flickerstreak@33
|
3050 self:AddLine("text", "", "disabled", true)
|
flickerstreak@33
|
3051 end
|
flickerstreak@33
|
3052
|
flickerstreak@33
|
3053 function Dewdrop:AddLine(...)
|
flickerstreak@33
|
3054 local info = tmp(...)
|
flickerstreak@33
|
3055 local level = info.level or currentLevel
|
flickerstreak@33
|
3056 info.level = nil
|
flickerstreak@33
|
3057 local button = AcquireButton(self, level)
|
flickerstreak@33
|
3058 if not next(info) then
|
flickerstreak@33
|
3059 info.disabled = true
|
flickerstreak@33
|
3060 end
|
flickerstreak@33
|
3061 button.disabled = info.isTitle or info.notClickable or info.disabled or (self.combat and info.secure)
|
flickerstreak@33
|
3062 button.isTitle = info.isTitle
|
flickerstreak@33
|
3063 button.notClickable = info.notClickable
|
flickerstreak@33
|
3064 if button.isTitle then
|
flickerstreak@33
|
3065 button.text:SetFontObject(GameFontNormalSmall)
|
flickerstreak@33
|
3066 elseif button.notClickable then
|
flickerstreak@33
|
3067 button.text:SetFontObject(GameFontHighlightSmall)
|
flickerstreak@33
|
3068 elseif button.disabled then
|
flickerstreak@33
|
3069 button.text:SetFontObject(GameFontDisableSmall)
|
flickerstreak@33
|
3070 else
|
flickerstreak@33
|
3071 button.text:SetFontObject(GameFontHighlightSmall)
|
flickerstreak@33
|
3072 end
|
flickerstreak@33
|
3073 if info.disabled then
|
flickerstreak@33
|
3074 button.arrow:SetDesaturated(true)
|
flickerstreak@33
|
3075 button.check:SetDesaturated(true)
|
flickerstreak@33
|
3076 else
|
flickerstreak@33
|
3077 button.arrow:SetDesaturated(false)
|
flickerstreak@33
|
3078 button.check:SetDesaturated(false)
|
flickerstreak@33
|
3079 end
|
flickerstreak@33
|
3080 if info.textR and info.textG and info.textB then
|
flickerstreak@33
|
3081 button.textR = info.textR
|
flickerstreak@33
|
3082 button.textG = info.textG
|
flickerstreak@33
|
3083 button.textB = info.textB
|
flickerstreak@33
|
3084 button.text:SetTextColor(button.textR, button.textG, button.textB)
|
flickerstreak@33
|
3085 else
|
flickerstreak@33
|
3086 button.text:SetTextColor(button.text:GetFontObject():GetTextColor())
|
flickerstreak@33
|
3087 end
|
flickerstreak@33
|
3088 button.notCheckable = info.notCheckable
|
flickerstreak@33
|
3089 button.text:SetPoint("LEFT", button, "LEFT", button.notCheckable and 0 or 24, 0)
|
flickerstreak@33
|
3090 button.checked = not info.notCheckable and info.checked
|
flickerstreak@33
|
3091 button.mouseoverUnderline = info.mouseoverUnderline
|
flickerstreak@33
|
3092 button.isRadio = not info.notCheckable and info.isRadio
|
flickerstreak@33
|
3093 if info.isRadio then
|
flickerstreak@33
|
3094 button.check:Show()
|
flickerstreak@33
|
3095 button.check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
|
flickerstreak@33
|
3096 if button.checked then
|
flickerstreak@33
|
3097 button.check:SetTexCoord(0.25, 0.5, 0, 1)
|
flickerstreak@33
|
3098 button.check:SetVertexColor(1, 1, 1, 1)
|
flickerstreak@33
|
3099 else
|
flickerstreak@33
|
3100 button.check:SetTexCoord(0, 0.25, 0, 1)
|
flickerstreak@33
|
3101 button.check:SetVertexColor(1, 1, 1, 0.5)
|
flickerstreak@33
|
3102 end
|
flickerstreak@33
|
3103 button.radioHighlight:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
|
flickerstreak@33
|
3104 button.check:SetWidth(16)
|
flickerstreak@33
|
3105 button.check:SetHeight(16)
|
flickerstreak@33
|
3106 elseif info.icon then
|
flickerstreak@33
|
3107 button.check:Show()
|
flickerstreak@33
|
3108 button.check:SetTexture(info.icon)
|
flickerstreak@33
|
3109 if info.iconWidth and info.iconHeight then
|
flickerstreak@33
|
3110 button.check:SetWidth(info.iconWidth)
|
flickerstreak@33
|
3111 button.check:SetHeight(info.iconHeight)
|
flickerstreak@33
|
3112 else
|
flickerstreak@33
|
3113 button.check:SetWidth(16)
|
flickerstreak@33
|
3114 button.check:SetHeight(16)
|
flickerstreak@33
|
3115 end
|
flickerstreak@33
|
3116 if info.iconCoordLeft and info.iconCoordRight and info.iconCoordTop and info.iconCoordBottom then
|
flickerstreak@33
|
3117 button.check:SetTexCoord(info.iconCoordLeft, info.iconCoordRight, info.iconCoordTop, info.iconCoordBottom)
|
flickerstreak@33
|
3118 elseif info.icon:find("^Interface\\Icons\\") then
|
flickerstreak@33
|
3119 button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95)
|
flickerstreak@33
|
3120 else
|
flickerstreak@33
|
3121 button.check:SetTexCoord(0, 1, 0, 1)
|
flickerstreak@33
|
3122 end
|
flickerstreak@33
|
3123 button.check:SetVertexColor(1, 1, 1, 1)
|
flickerstreak@33
|
3124 else
|
flickerstreak@33
|
3125 if button.checked then
|
flickerstreak@33
|
3126 if info.checkIcon then
|
flickerstreak@33
|
3127 button.check:SetWidth(16)
|
flickerstreak@33
|
3128 button.check:SetHeight(16)
|
flickerstreak@33
|
3129 button.check:SetTexture(info.checkIcon)
|
flickerstreak@33
|
3130 if info.checkIcon:find("^Interface\\Icons\\") then
|
flickerstreak@33
|
3131 button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95)
|
flickerstreak@33
|
3132 else
|
flickerstreak@33
|
3133 button.check:SetTexCoord(0, 1, 0, 1)
|
flickerstreak@33
|
3134 end
|
flickerstreak@33
|
3135 else
|
flickerstreak@33
|
3136 button.check:SetWidth(24)
|
flickerstreak@33
|
3137 button.check:SetHeight(24)
|
flickerstreak@33
|
3138 button.check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
|
flickerstreak@33
|
3139 button.check:SetTexCoord(0, 1, 0, 1)
|
flickerstreak@33
|
3140 end
|
flickerstreak@33
|
3141 button.check:SetVertexColor(1, 1, 1, 1)
|
flickerstreak@33
|
3142 else
|
flickerstreak@33
|
3143 button.check:SetVertexColor(1, 1, 1, 0)
|
flickerstreak@33
|
3144 end
|
flickerstreak@33
|
3145 end
|
flickerstreak@33
|
3146 if not button.disabled then
|
flickerstreak@33
|
3147 button.func = info.func
|
flickerstreak@33
|
3148 button.secure = info.secure
|
flickerstreak@33
|
3149 end
|
flickerstreak@33
|
3150 button.hasColorSwatch = info.hasColorSwatch
|
flickerstreak@33
|
3151 if button.hasColorSwatch then
|
flickerstreak@33
|
3152 button.colorSwatch:Show()
|
flickerstreak@33
|
3153 button.colorSwatch.texture:Show()
|
flickerstreak@33
|
3154 button.r = info.r or 1
|
flickerstreak@33
|
3155 button.g = info.g or 1
|
flickerstreak@33
|
3156 button.b = info.b or 1
|
flickerstreak@33
|
3157 button.colorSwatch.texture:SetVertexColor(button.r, button.g, button.b)
|
flickerstreak@33
|
3158 button.checked = false
|
flickerstreak@33
|
3159 button.func = nil
|
flickerstreak@33
|
3160 button.colorFunc = info.colorFunc
|
flickerstreak@33
|
3161 local i = 1
|
flickerstreak@33
|
3162 while true do
|
flickerstreak@33
|
3163 local k = "colorArg" .. i
|
flickerstreak@33
|
3164 local x = info[k]
|
flickerstreak@33
|
3165 if x == nil then
|
flickerstreak@33
|
3166 break
|
flickerstreak@33
|
3167 end
|
flickerstreak@33
|
3168 button[k] = x
|
flickerstreak@33
|
3169 i = i + 1
|
flickerstreak@33
|
3170 end
|
flickerstreak@33
|
3171 button.hasOpacity = info.hasOpacity
|
flickerstreak@33
|
3172 button.opacity = info.opacity or 1
|
flickerstreak@33
|
3173 else
|
flickerstreak@33
|
3174 button.colorSwatch:Hide()
|
flickerstreak@33
|
3175 button.colorSwatch.texture:Hide()
|
flickerstreak@33
|
3176 end
|
flickerstreak@33
|
3177 button.hasArrow = not button.hasColorSwatch and (info.value or info.hasSlider or info.hasEditBox) and info.hasArrow
|
flickerstreak@33
|
3178 if button.hasArrow then
|
flickerstreak@33
|
3179 button.arrow:SetAlpha(1)
|
flickerstreak@33
|
3180 if info.hasSlider then
|
flickerstreak@33
|
3181 button.hasSlider = true
|
flickerstreak@33
|
3182 button.sliderMin = info.sliderMin or 0
|
flickerstreak@33
|
3183 button.sliderMax = info.sliderMax or 1
|
flickerstreak@33
|
3184 button.sliderStep = info.sliderStep or 0
|
flickerstreak@33
|
3185 button.sliderBigStep = info.sliderBigStep or button.sliderStep
|
flickerstreak@33
|
3186 if button.sliderBigStep < button.sliderStep then
|
flickerstreak@33
|
3187 button.sliderBigStep = button.sliderStep
|
flickerstreak@33
|
3188 end
|
flickerstreak@33
|
3189 button.sliderIsPercent = info.sliderIsPercent and true or false
|
flickerstreak@33
|
3190 button.sliderMinText = info.sliderMinText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMin * 100) or button.sliderMin
|
flickerstreak@33
|
3191 button.sliderMaxText = info.sliderMaxText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMax * 100) or button.sliderMax
|
flickerstreak@33
|
3192 button.sliderFunc = info.sliderFunc
|
flickerstreak@33
|
3193 button.sliderValue = info.sliderValue
|
flickerstreak@33
|
3194 button.fromAceOptions = info.fromAceOptions
|
flickerstreak@33
|
3195 local i = 1
|
flickerstreak@33
|
3196 while true do
|
flickerstreak@33
|
3197 local k = "sliderArg" .. i
|
flickerstreak@33
|
3198 local x = info[k]
|
flickerstreak@33
|
3199 if x == nil then
|
flickerstreak@33
|
3200 break
|
flickerstreak@33
|
3201 end
|
flickerstreak@33
|
3202 button[k] = x
|
flickerstreak@33
|
3203 i = i + 1
|
flickerstreak@33
|
3204 end
|
flickerstreak@33
|
3205 elseif info.hasEditBox then
|
flickerstreak@33
|
3206 button.hasEditBox = true
|
flickerstreak@33
|
3207 button.editBoxText = info.editBoxText or ""
|
flickerstreak@33
|
3208 button.editBoxFunc = info.editBoxFunc
|
flickerstreak@33
|
3209 local i = 1
|
flickerstreak@33
|
3210 while true do
|
flickerstreak@33
|
3211 local k = "editBoxArg" .. i
|
flickerstreak@33
|
3212 local x = info[k]
|
flickerstreak@33
|
3213 if x == nil then
|
flickerstreak@33
|
3214 break
|
flickerstreak@33
|
3215 end
|
flickerstreak@33
|
3216 button[k] = x
|
flickerstreak@33
|
3217 i = i + 1
|
flickerstreak@33
|
3218 end
|
flickerstreak@33
|
3219 button.editBoxChangeFunc = info.editBoxChangeFunc
|
flickerstreak@33
|
3220 local i = 1
|
flickerstreak@33
|
3221 while true do
|
flickerstreak@33
|
3222 local k = "editBoxChangeArg" .. i
|
flickerstreak@33
|
3223 local x = info[k]
|
flickerstreak@33
|
3224 if x == nil then
|
flickerstreak@33
|
3225 break
|
flickerstreak@33
|
3226 end
|
flickerstreak@33
|
3227 button[k] = x
|
flickerstreak@33
|
3228 i = i + 1
|
flickerstreak@33
|
3229 end
|
flickerstreak@33
|
3230 button.editBoxValidateFunc = info.editBoxValidateFunc
|
flickerstreak@33
|
3231 local i = 1
|
flickerstreak@33
|
3232 while true do
|
flickerstreak@33
|
3233 local k = "editBoxValidateArg" .. i
|
flickerstreak@33
|
3234 local x = info[k]
|
flickerstreak@33
|
3235 if x == nil then
|
flickerstreak@33
|
3236 break
|
flickerstreak@33
|
3237 end
|
flickerstreak@33
|
3238 button[k] = x
|
flickerstreak@33
|
3239 i = i + 1
|
flickerstreak@33
|
3240 end
|
flickerstreak@33
|
3241 button.editBoxIsKeybinding = info.editBoxIsKeybinding
|
flickerstreak@33
|
3242 button.editBoxKeybindingOnly = info.editBoxKeybindingOnly
|
flickerstreak@33
|
3243 button.editBoxKeybindingExcept = info.editBoxKeybindingExcept
|
flickerstreak@33
|
3244 else
|
flickerstreak@33
|
3245 button.value = info.value
|
flickerstreak@33
|
3246 local l = levels[level+1]
|
flickerstreak@33
|
3247 if l and info.value == l.value then
|
flickerstreak@33
|
3248 -- button.arrow:SetWidth(24)
|
flickerstreak@33
|
3249 -- button.arrow:SetHeight(24)
|
flickerstreak@33
|
3250 button.selected = true
|
flickerstreak@33
|
3251 button.highlight:Show()
|
flickerstreak@33
|
3252 end
|
flickerstreak@33
|
3253 end
|
flickerstreak@33
|
3254 else
|
flickerstreak@33
|
3255 button.arrow:SetAlpha(0)
|
flickerstreak@33
|
3256 end
|
flickerstreak@33
|
3257 local i = 1
|
flickerstreak@33
|
3258 while true do
|
flickerstreak@33
|
3259 local k = "arg" .. i
|
flickerstreak@33
|
3260 local x = info[k]
|
flickerstreak@33
|
3261 if x == nil then
|
flickerstreak@33
|
3262 break
|
flickerstreak@33
|
3263 end
|
flickerstreak@33
|
3264 button[k] = x
|
flickerstreak@33
|
3265 i = i + 1
|
flickerstreak@33
|
3266 end
|
flickerstreak@33
|
3267 button.closeWhenClicked = info.closeWhenClicked
|
flickerstreak@33
|
3268 button.textHeight = info.textHeight or UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT or 10
|
flickerstreak@33
|
3269 local font,_ = button.text:GetFont()
|
flickerstreak@33
|
3270 button.text:SetFont(STANDARD_TEXT_FONT or "Fonts\\FRIZQT__.TTF", button.textHeight)
|
flickerstreak@33
|
3271 button:SetHeight(button.textHeight + 6)
|
flickerstreak@33
|
3272 button.text:SetPoint("RIGHT", button.arrow, (button.hasColorSwatch or button.hasArrow) and "LEFT" or "RIGHT")
|
flickerstreak@33
|
3273 button.text:SetJustifyH(info.justifyH or "LEFT")
|
flickerstreak@33
|
3274 button.text:SetText(info.text)
|
flickerstreak@33
|
3275 button.tooltipTitle = info.tooltipTitle
|
flickerstreak@33
|
3276 button.tooltipText = info.tooltipText
|
flickerstreak@33
|
3277 button.tooltipFunc = info.tooltipFunc
|
flickerstreak@33
|
3278 local i = 1
|
flickerstreak@33
|
3279 while true do
|
flickerstreak@33
|
3280 local k = "tooltipArg" .. i
|
flickerstreak@33
|
3281 local x = info[k]
|
flickerstreak@33
|
3282 if x == nil then
|
flickerstreak@33
|
3283 break
|
flickerstreak@33
|
3284 end
|
flickerstreak@33
|
3285 button[k] = x
|
flickerstreak@33
|
3286 i = i + 1
|
flickerstreak@33
|
3287 end
|
flickerstreak@33
|
3288 if not button.tooltipTitle and not button.tooltipText and not button.tooltipFunc and not info.isTitle then
|
flickerstreak@33
|
3289 button.tooltipTitle = info.text
|
flickerstreak@33
|
3290 end
|
flickerstreak@33
|
3291 if type(button.func) == "string" then
|
flickerstreak@33
|
3292 if type(button.arg1) ~= "table" then
|
flickerstreak@33
|
3293 self:error("Cannot call method %q on a non-table", button.func)
|
flickerstreak@33
|
3294 end
|
flickerstreak@33
|
3295 if type(button.arg1[button.func]) ~= "function" then
|
flickerstreak@33
|
3296 self:error("Method %q nonexistant.", button.func)
|
flickerstreak@33
|
3297 end
|
flickerstreak@33
|
3298 end
|
flickerstreak@33
|
3299 end
|
flickerstreak@33
|
3300
|
flickerstreak@33
|
3301 function Dewdrop:InjectAceOptionsTable(handler, options)
|
flickerstreak@33
|
3302 self:argCheck(handler, 2, "table")
|
flickerstreak@33
|
3303 self:argCheck(options, 3, "table")
|
flickerstreak@33
|
3304 if tostring(options.type):lower() ~= "group" then
|
flickerstreak@33
|
3305 self:error('Cannot inject into options table argument #3 if its type is not "group"')
|
flickerstreak@33
|
3306 end
|
flickerstreak@33
|
3307 if options.handler ~= nil and options.handler ~= handler then
|
flickerstreak@33
|
3308 self:error("Cannot inject into options table argument #3 if it has a different handler than argument #2")
|
flickerstreak@33
|
3309 end
|
flickerstreak@33
|
3310 options.handler = handler
|
flickerstreak@33
|
3311 local class = handler.class
|
flickerstreak@33
|
3312 if not AceLibrary:HasInstance("AceOO-2.0") or not class then
|
flickerstreak@33
|
3313 if Rock then
|
flickerstreak@33
|
3314 -- possible Rock object
|
flickerstreak@33
|
3315 for mixin in Rock:IterateObjectMixins(handler) do
|
flickerstreak@33
|
3316 if type(mixin.GetAceOptionsDataTable) == "function" then
|
flickerstreak@33
|
3317 local t = mixin:GetAceOptionsDataTable(handler)
|
flickerstreak@33
|
3318 for k,v in pairs(t) do
|
flickerstreak@33
|
3319 if type(options.args) ~= "table" then
|
flickerstreak@33
|
3320 options.args = {}
|
flickerstreak@33
|
3321 end
|
flickerstreak@33
|
3322 if options.args[k] == nil then
|
flickerstreak@33
|
3323 options.args[k] = v
|
flickerstreak@33
|
3324 end
|
flickerstreak@33
|
3325 end
|
flickerstreak@33
|
3326 end
|
flickerstreak@33
|
3327 end
|
flickerstreak@33
|
3328 end
|
flickerstreak@33
|
3329 else
|
flickerstreak@33
|
3330 -- Ace2 object
|
flickerstreak@33
|
3331 while class and class ~= AceLibrary("AceOO-2.0").Class do
|
flickerstreak@33
|
3332 if type(class.GetAceOptionsDataTable) == "function" then
|
flickerstreak@33
|
3333 local t = class:GetAceOptionsDataTable(handler)
|
flickerstreak@33
|
3334 for k,v in pairs(t) do
|
flickerstreak@33
|
3335 if type(options.args) ~= "table" then
|
flickerstreak@33
|
3336 options.args = {}
|
flickerstreak@33
|
3337 end
|
flickerstreak@33
|
3338 if options.args[k] == nil then
|
flickerstreak@33
|
3339 options.args[k] = v
|
flickerstreak@33
|
3340 end
|
flickerstreak@33
|
3341 end
|
flickerstreak@33
|
3342 end
|
flickerstreak@33
|
3343 local mixins = class.mixins
|
flickerstreak@33
|
3344 if mixins then
|
flickerstreak@33
|
3345 for mixin in pairs(mixins) do
|
flickerstreak@33
|
3346 if type(mixin.GetAceOptionsDataTable) == "function" then
|
flickerstreak@33
|
3347 local t = mixin:GetAceOptionsDataTable(handler)
|
flickerstreak@33
|
3348 for k,v in pairs(t) do
|
flickerstreak@33
|
3349 if type(options.args) ~= "table" then
|
flickerstreak@33
|
3350 options.args = {}
|
flickerstreak@33
|
3351 end
|
flickerstreak@33
|
3352 if options.args[k] == nil then
|
flickerstreak@33
|
3353 options.args[k] = v
|
flickerstreak@33
|
3354 end
|
flickerstreak@33
|
3355 end
|
flickerstreak@33
|
3356 end
|
flickerstreak@33
|
3357 end
|
flickerstreak@33
|
3358 end
|
flickerstreak@33
|
3359 class = class.super
|
flickerstreak@33
|
3360 end
|
flickerstreak@33
|
3361 end
|
flickerstreak@33
|
3362 return options
|
flickerstreak@33
|
3363 end
|
flickerstreak@33
|
3364
|
flickerstreak@33
|
3365 function Dewdrop:OnTooltipHide()
|
flickerstreak@33
|
3366 if lastSetFont then
|
flickerstreak@33
|
3367 if lastSetFont == normalFont then
|
flickerstreak@33
|
3368 lastSetFont = nil
|
flickerstreak@33
|
3369 return
|
flickerstreak@33
|
3370 end
|
flickerstreak@33
|
3371 fillRegionTmp(GameTooltip:GetRegions())
|
flickerstreak@33
|
3372 for i,v in ipairs(regionTmp) do
|
flickerstreak@33
|
3373 if v.GetFont then
|
flickerstreak@33
|
3374 local font,size,outline = v:GetFont()
|
flickerstreak@33
|
3375 if font == lastSetFont then
|
flickerstreak@33
|
3376 v:SetFont(normalFont, size, outline)
|
flickerstreak@33
|
3377 end
|
flickerstreak@33
|
3378 end
|
flickerstreak@33
|
3379 regionTmp[i] = nil
|
flickerstreak@33
|
3380 end
|
flickerstreak@33
|
3381 lastSetFont = nil
|
flickerstreak@33
|
3382 end
|
flickerstreak@33
|
3383 end
|
flickerstreak@33
|
3384
|
flickerstreak@33
|
3385 local function activate(self, oldLib, oldDeactivate)
|
flickerstreak@33
|
3386 Dewdrop = self
|
flickerstreak@33
|
3387 if oldLib and oldLib.registry then
|
flickerstreak@33
|
3388 self.registry = oldLib.registry
|
flickerstreak@33
|
3389 self.onceRegistered = oldLib.onceRegistered
|
flickerstreak@33
|
3390 else
|
flickerstreak@33
|
3391 self.registry = {}
|
flickerstreak@33
|
3392 self.onceRegistered = {}
|
flickerstreak@33
|
3393
|
flickerstreak@33
|
3394 local WorldFrame_OnMouseDown = WorldFrame:GetScript("OnMouseDown")
|
flickerstreak@33
|
3395 local WorldFrame_OnMouseUp = WorldFrame:GetScript("OnMouseUp")
|
flickerstreak@33
|
3396 local oldX, oldY, clickTime
|
flickerstreak@33
|
3397 WorldFrame:SetScript("OnMouseDown", function(this, ...)
|
flickerstreak@33
|
3398 oldX,oldY = GetCursorPosition()
|
flickerstreak@33
|
3399 clickTime = GetTime()
|
flickerstreak@33
|
3400 if WorldFrame_OnMouseDown then
|
flickerstreak@33
|
3401 WorldFrame_OnMouseDown(this, ...)
|
flickerstreak@33
|
3402 end
|
flickerstreak@33
|
3403 end)
|
flickerstreak@33
|
3404
|
flickerstreak@33
|
3405 WorldFrame:SetScript("OnMouseUp", function(this, ...)
|
flickerstreak@33
|
3406 local x,y = GetCursorPosition()
|
flickerstreak@33
|
3407 if not oldX or not oldY or not x or not y or not clickTime then
|
flickerstreak@33
|
3408 self:Close()
|
flickerstreak@33
|
3409 if WorldFrame_OnMouseUp then
|
flickerstreak@33
|
3410 WorldFrame_OnMouseUp(this, ...)
|
flickerstreak@33
|
3411 end
|
flickerstreak@33
|
3412 return
|
flickerstreak@33
|
3413 end
|
flickerstreak@33
|
3414 local d = math.abs(x - oldX) + math.abs(y - oldY)
|
flickerstreak@33
|
3415 if d <= 5 and GetTime() - clickTime < 0.5 then
|
flickerstreak@33
|
3416 self:Close()
|
flickerstreak@33
|
3417 end
|
flickerstreak@33
|
3418 if WorldFrame_OnMouseUp then
|
flickerstreak@33
|
3419 WorldFrame_OnMouseUp(this, ...)
|
flickerstreak@33
|
3420 end
|
flickerstreak@33
|
3421 end)
|
flickerstreak@33
|
3422
|
flickerstreak@33
|
3423 hooksecurefunc(DropDownList1, "Show", function()
|
flickerstreak@33
|
3424 if levels[1] and levels[1]:IsVisible() then
|
flickerstreak@33
|
3425 self:Close()
|
flickerstreak@33
|
3426 end
|
flickerstreak@33
|
3427 end)
|
flickerstreak@33
|
3428
|
flickerstreak@33
|
3429 hooksecurefunc("HideDropDownMenu", function()
|
flickerstreak@33
|
3430 if levels[1] and levels[1]:IsVisible() then
|
flickerstreak@33
|
3431 self:Close()
|
flickerstreak@33
|
3432 end
|
flickerstreak@33
|
3433 end)
|
flickerstreak@33
|
3434
|
flickerstreak@33
|
3435 hooksecurefunc("CloseDropDownMenus", function()
|
flickerstreak@33
|
3436 if levels[1] and levels[1]:IsVisible() then
|
flickerstreak@33
|
3437 local stack = debugstack()
|
flickerstreak@33
|
3438 if not stack:find("`TargetFrame_OnHide'") then
|
flickerstreak@33
|
3439 self:Close()
|
flickerstreak@33
|
3440 end
|
flickerstreak@33
|
3441 end
|
flickerstreak@33
|
3442 end)
|
flickerstreak@33
|
3443 end
|
flickerstreak@33
|
3444 self.frame = oldLib and oldLib.frame or CreateFrame("Frame")
|
flickerstreak@33
|
3445 self.frame:UnregisterAllEvents()
|
flickerstreak@33
|
3446 self.frame:RegisterEvent("PLAYER_REGEN_ENABLED")
|
flickerstreak@33
|
3447 self.frame:RegisterEvent("PLAYER_REGEN_DISABLED")
|
flickerstreak@33
|
3448 self.frame:Hide()
|
flickerstreak@33
|
3449 self.frame:SetScript("OnEvent", function(this, event)
|
flickerstreak@33
|
3450 this:Show()
|
flickerstreak@33
|
3451 if event=="PLAYER_REGEN_ENABLED" then -- track combat state for secure frame operations
|
flickerstreak@33
|
3452 self.combat = false
|
flickerstreak@33
|
3453 elseif event=="PLAYER_REGEN_DISABLED" then
|
flickerstreak@33
|
3454 self.combat = true
|
flickerstreak@33
|
3455 end
|
flickerstreak@33
|
3456 end)
|
flickerstreak@33
|
3457 self.frame:SetScript("OnUpdate", function(this)
|
flickerstreak@33
|
3458 this:Hide()
|
flickerstreak@33
|
3459 self:Refresh(1)
|
flickerstreak@33
|
3460 end)
|
flickerstreak@33
|
3461 self.hookedTooltip = true
|
flickerstreak@33
|
3462 if not oldLib or not oldLib.hookedTooltip then
|
flickerstreak@33
|
3463 local OnTooltipHide = GameTooltip:GetScript("OnHide")
|
flickerstreak@33
|
3464 GameTooltip:SetScript("OnHide", function(this, ...)
|
flickerstreak@33
|
3465 if OnTooltipHide then
|
flickerstreak@33
|
3466 OnTooltipHide(this, ...)
|
flickerstreak@33
|
3467 end
|
flickerstreak@33
|
3468 if type(self.OnTooltipHide) == "function" then
|
flickerstreak@33
|
3469 self:OnTooltipHide()
|
flickerstreak@33
|
3470 end
|
flickerstreak@33
|
3471 end)
|
flickerstreak@33
|
3472 end
|
flickerstreak@33
|
3473 levels = {}
|
flickerstreak@33
|
3474 buttons = {}
|
flickerstreak@33
|
3475
|
flickerstreak@33
|
3476 if oldDeactivate then
|
flickerstreak@33
|
3477 oldDeactivate(oldLib)
|
flickerstreak@33
|
3478 end
|
flickerstreak@33
|
3479 end
|
flickerstreak@33
|
3480
|
flickerstreak@33
|
3481 local function external(lib, major, instance)
|
flickerstreak@33
|
3482 if major == "SharedMedia-1.0" then
|
flickerstreak@33
|
3483 SharedMedia = instance
|
flickerstreak@33
|
3484 end
|
flickerstreak@33
|
3485 end
|
flickerstreak@33
|
3486
|
flickerstreak@33
|
3487 AceLibrary:Register(Dewdrop, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
|