vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local MAJOR_VERSION = "1.0"
2 local MINOR_VERSION = tonumber(string.sub("$Revision: 1613 $", 12, -3))
3 if DewdropLib and DewdropLib.versions[MAJOR_VERSION] and DewdropLib.versions[MAJOR_VERSION].minor >= MINOR_VERSION then
4 return
5 end
6  
7 -------------IRIEL'S-STUB-CODE--------------
8 local stub = {};
9  
10 -- Instance replacement method, replace contents of old with that of new
11 function stub:ReplaceInstance(old, new)
12 for k,v in pairs(old) do old[k]=nil; end
13 for k,v in pairs(new) do old[k]=v; end
14 end
15  
16 -- Get a new copy of the stub
17 function stub:NewStub()
18 local newStub = {};
19 self:ReplaceInstance(newStub, self);
20 newStub.lastVersion = '';
21 newStub.versions = {};
22 return newStub;
23 end
24  
25 -- Get instance version
26 function stub:GetInstance(version)
27 if (not version) then version = self.lastVersion; end
28 local versionData = self.versions[version];
29 if (not versionData) then
30 message("Cannot find library instance with version '"
31 .. version .. "'");
32 return;
33 end
34 return versionData.instance;
35 end
36  
37 -- Register new instance
38 function stub:Register(newInstance)
39 local version,minor = newInstance:GetLibraryVersion();
40 self.lastVersion = version;
41 local versionData = self.versions[version];
42 if (not versionData) then
43 -- This one is new!
44 versionData = { instance = newInstance,
45 minor = minor,
46 old = {}
47 };
48 self.versions[version] = versionData;
49 newInstance:LibActivate(self);
50 return newInstance;
51 end
52 if (minor <= versionData.minor) then
53 -- This one is already obsolete
54 if (newInstance.LibDiscard) then
55 newInstance:LibDiscard();
56 end
57 return versionData.instance;
58 end
59 -- This is an update
60 local oldInstance = versionData.instance;
61 local oldList = versionData.old;
62 versionData.instance = newInstance;
63 versionData.minor = minor;
64 local skipCopy = newInstance:LibActivate(self, oldInstance, oldList);
65 table.insert(oldList, oldInstance);
66 if (not skipCopy) then
67 for i, old in ipairs(oldList) do
68 self:ReplaceInstance(old, newInstance);
69 end
70 end
71 return newInstance;
72 end
73  
74 -- Bind stub to global scope if it's not already there
75 if (not DewdropLib) then
76 DewdropLib = stub:NewStub();
77 end
78  
79 -- Nil stub for garbage collection
80 stub = nil;
81 -----------END-IRIEL'S-STUB-CODE------------
82  
83 local function assert(condition, message)
84 if not condition then
85 local stack = debugstack()
86 local first = string.gsub(stack, "\n.*", "")
87 local file = string.gsub(first, "^(.*\\.*)%.lua:%d+: .*", "%1")
88 if not message then
89 local _,_,second = string.find(stack, "\n(.-)\n")
90 message = "assertion failed! " .. second
91 end
92 local i = 1
93 for s in string.gfind(stack, "\n(.-)\n") do
94 i = i + 1
95 if not string.find(s, file .. "%.lua:%d+:") then
96 error(message, i)
97 return
98 end
99 end
100 error(message, 2)
101 return
102 end
103 return condition
104 end
105  
106 local lib = {}
107 local ipairs = ipairs
108 local tinsert = table.insert
109 local tremove = table.remove
110 local tgetn = table.getn
111 local function new(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
112 local t = {}
113 if k1 then t[k1] = v1
114 if k2 then t[k2] = v2
115 if k3 then t[k3] = v3
116 if k4 then t[k4] = v4
117 if k5 then t[k5] = v5
118 if k6 then t[k6] = v6
119 if k7 then t[k7] = v7
120 if k8 then t[k8] = v8
121 if k9 then t[k9] = v9
122 if k10 then t[k10] = v10
123 if k11 then t[k11] = v11
124 if k12 then t[k12] = v12
125 if k13 then t[k13] = v13
126 if k14 then t[k14] = v14
127 if k15 then t[k15] = v15
128 if k16 then t[k16] = v16
129 if k17 then t[k17] = v17
130 if k18 then t[k18] = v18
131 if k19 then t[k19] = v19
132 if k20 then t[k20] = v20
133 end end end end end end end end end end end end end end end end end end end end
134 return t
135 end
136 local tmp
137 do
138 local t
139 function tmp(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
140 for k in pairs(t) do
141 t[k] = nil
142 end
143 if k1 then t[k1] = v1
144 if k2 then t[k2] = v2
145 if k3 then t[k3] = v3
146 if k4 then t[k4] = v4
147 if k5 then t[k5] = v5
148 if k6 then t[k6] = v6
149 if k7 then t[k7] = v7
150 if k8 then t[k8] = v8
151 if k9 then t[k9] = v9
152 if k10 then t[k10] = v10
153 if k11 then t[k11] = v11
154 if k12 then t[k12] = v12
155 if k13 then t[k13] = v13
156 if k14 then t[k14] = v14
157 if k15 then t[k15] = v15
158 if k16 then t[k16] = v16
159 if k17 then t[k17] = v17
160 if k18 then t[k18] = v18
161 if k19 then t[k19] = v19
162 if k20 then t[k20] = v20
163 end end end end end end end end end end end end end end end end end end end end
164 return t
165 end
166 local x = tmp
167 function tmp(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
168 t = {}
169 tmp = x
170 x = nil
171 return tmp(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
172 end
173 end
174 local tmp2
175 do
176 local t
177 function tmp2(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
178 for k in pairs(t) do
179 t[k] = nil
180 end
181 if k1 then t[k1] = v1
182 if k2 then t[k2] = v2
183 if k3 then t[k3] = v3
184 if k4 then t[k4] = v4
185 if k5 then t[k5] = v5
186 if k6 then t[k6] = v6
187 if k7 then t[k7] = v7
188 if k8 then t[k8] = v8
189 if k9 then t[k9] = v9
190 if k10 then t[k10] = v10
191 if k11 then t[k11] = v11
192 if k12 then t[k12] = v12
193 if k13 then t[k13] = v13
194 if k14 then t[k14] = v14
195 if k15 then t[k15] = v15
196 if k16 then t[k16] = v16
197 if k17 then t[k17] = v17
198 if k18 then t[k18] = v18
199 if k19 then t[k19] = v19
200 if k20 then t[k20] = v20
201 end end end end end end end end end end end end end end end end end end end end
202 return t
203 end
204 local x = tmp2
205 function tmp2(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
206 t = {}
207 tmp2 = x
208 x = nil
209 return tmp2(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
210 end
211 end
212 --local levels
213 local buttons
214  
215 function lib:GetLibraryVersion()
216 return MAJOR_VERSION, MINOR_VERSION
217 end
218  
219 function lib:LibActivate(stub, oldLib, oldList)
220 if oldLib and oldLib.registry then
221 self.registry = oldLib.registry
222 self.onceRegistered = oldLib.onceRegistered
223 else
224 self.registry = {}
225 self.onceRegistered = {}
226  
227 local WorldFrame_OnMouseDown = WorldFrame:GetScript("OnMouseDown")
228 local WorldFrame_OnMouseUp = WorldFrame:GetScript("OnMouseUp")
229 local oldX, oldY, clickTime
230 WorldFrame:SetScript("OnMouseDown", function()
231 oldX,oldY = GetCursorPosition()
232 clickTime = GetTime()
233 if WorldFrame_OnMouseDown then
234 WorldFrame_OnMouseDown()
235 end
236 end)
237  
238 WorldFrame:SetScript("OnMouseUp", function()
239 local x,y = GetCursorPosition()
240 if not oldX or not oldY or not x or not y or not clickTime then
241 self:Close()
242 if WorldFrame_OnMouseUp then
243 WorldFrame_OnMouseUp()
244 end
245 return
246 end
247 local d = math.abs(x - oldX) + math.abs(y - oldY)
248 if d <= 5 and GetTime() - clickTime < 0.5 then
249 self:Close()
250 end
251 if WorldFrame_OnMouseUp then
252 WorldFrame_OnMouseUp()
253 end
254 end)
255  
256 local DropDownList1_Show = DropDownList1.Show
257 function DropDownList1.Show(DropDownList1)
258 if levels[1] and levels[1]:IsVisible() then
259 self:Close()
260 end
261 DropDownList1_Show(DropDownList1)
262 end
263  
264 local old_HideDropDownMenu = HideDropDownMenu
265 function HideDropDownMenu(num)
266 if levels[1] and levels[1]:IsVisible() then
267 self:Close()
268 end
269 old_HideDropDownMenu(num)
270 end
271  
272 local old_CloseDropDownMenus = CloseDropDownMenus
273 function CloseDropDownMenus(num)
274 if levels[1] and levels[1]:IsVisible() then
275 self:Close()
276 end
277 old_CloseDropDownMenus(num)
278 end
279 end
280 levels = {}
281 buttons = {}
282 end
283  
284 function lib:LibDeactivate(stub)
285 levels = nil
286 buttons = nil
287 end
288  
289 local function StartCounting(self, levelNum)
290 for i = levelNum, tgetn(levels) do
291 if levels[i] then
292 levels[i].count = 3
293 end
294 end
295 end
296  
297 local function StopCounting(self, level)
298 for i = level, 1, -1 do
299 if levels[i] then
300 levels[i].count = nil
301 end
302 end
303 end
304  
305 local function OnUpdate(self, arg1)
306 for _,level in ipairs(levels) do
307 if level.count then
308 level.count = level.count - arg1
309 if level.count < 0 then
310 level.count = nil
311 self:Close(level.num)
312 end
313 end
314 end
315 end
316  
317 local function CheckSize(self, level)
318 if not level.buttons then
319 return
320 end
321 local height = 20
322 for _, button in ipairs(level.buttons) do
323 height = height + button:GetHeight()
324 end
325 level:SetHeight(height)
326 local width = 160
327 for _, button in ipairs(level.buttons) do
328 local extra = 1
329 if button.hasArrow or button.hasColorSwatch then
330 extra = extra + 16
331 end
332 if not button.notCheckable then
333 extra = extra + 24
334 end
335 button.text:SetFont(STANDARD_TEXT_FONT, button.textHeight)
336 if button.text:GetWidth() + extra > width then
337 width = button.text:GetWidth() + extra
338 end
339 end
340 level:SetWidth(width + 20)
341 if level:GetLeft() and level:GetTop() and level:GetLeft() < 0 or level:GetRight() > GetScreenWidth() or level:GetTop() > GetScreenHeight() or level:GetBottom() < 0 then
342 level:ClearAllPoints()
343 if level.lastDirection == "RIGHT" then
344 if level.lastVDirection == "DOWN" then
345 level:SetPoint("TOPLEFT", level.parent or level:GetParent(), "TOPRIGHT", 5, 10)
346 else
347 level:SetPoint("BOTTOMLEFT", level.parent or level:GetParent(), "BOTTOMRIGHT", 5, -10)
348 end
349 else
350 if level.lastVDirection == "DOWN" then
351 level:SetPoint("TOPRIGHT", level.parent or level:GetParent(), "TOPLEFT", -5, 10)
352 else
353 level:SetPoint("BOTTOMRIGHT", level.parent or level:GetParent(), "BOTTOMLEFT", -5, -10)
354 end
355 end
356 end
357 local dirty = false
358 if not level:GetRight() then
359 self:Close()
360 return
361 end
362 if level:GetRight() > GetScreenWidth() and level.lastDirection == "RIGHT" then
363 level.lastDirection = "LEFT"
364 dirty = true
365 elseif level:GetLeft() < 0 and level.lastDirection == "LEFT" then
366 level.lastDirection = "RIGHT"
367 dirty = true
368 end
369 if level:GetTop() > GetScreenHeight() and level.lastVDirection == "UP" then
370 level.lastVDirection = "DOWN"
371 dirty = true
372 elseif level:GetBottom() < 0 and level.lastVDirection == "DOWN" then
373 level.lastVDirection = "UP"
374 dirty = true
375 end
376 if dirty then
377 level:ClearAllPoints()
378 if level.lastDirection == "RIGHT" then
379 if level.lastVDirection == "DOWN" then
380 level:SetPoint("TOPLEFT", level.parent or level:GetParent(), "TOPRIGHT", 5, 10)
381 else
382 level:SetPoint("BOTTOMLEFT", level.parent or level:GetParent(), "BOTTOMRIGHT", 5, -10)
383 end
384 else
385 if level.lastVDirection == "DOWN" then
386 level:SetPoint("TOPRIGHT", level.parent or level:GetParent(), "TOPLEFT", -5, 10)
387 else
388 level:SetPoint("BOTTOMRIGHT", level.parent or level:GetParent(), "BOTTOMLEFT", -5, -10)
389 end
390 end
391 end
392 if level:GetTop() > GetScreenHeight() then
393 local top = level:GetTop()
394 local point, parent, relativePoint, x, y = level:GetPoint(1)
395 level:ClearAllPoints()
396 level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) + GetScreenHeight() - top)
397 elseif level:GetBottom() < 0 then
398 local bottom = level:GetBottom()
399 local point, parent, relativePoint, x, y = level:GetPoint(1)
400 level:ClearAllPoints()
401 level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) - bottom)
402 end
403 local left, bottom = level:GetLeft(), level:GetBottom()
404 if mod(level.num, 5) == 0 then
405 level:ClearAllPoints()
406 level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
407 end
408 end
409  
410 local Open
411 local OpenSlider
412 local Refresh
413 local Clear
414 local function ReleaseButton(self, level, index)
415 if not level.buttons then
416 return
417 end
418 if not level.buttons[index] then
419 return
420 end
421 local button = level.buttons[index]
422 button:Hide()
423 if button.highlight then
424 button.highlight:Hide()
425 end
426 tremove(level.buttons, index)
427 tinsert(buttons, button)
428 for k in pairs(button) do
429 if k ~= 0 and k ~= "text" and k ~= "check" and k ~= "arrow" and k ~= "colorSwatch" and k ~= "highlight" and k ~= "radioHighlight" then
430 button[k] = nil
431 end
432 end
433 return true
434 end
435  
436 local function Scroll(self, level, down)
437 if down then
438 if level:GetBottom() < 0 then
439 local point, parent, relativePoint, x, y = level:GetPoint(1)
440 level:SetPoint(point, parent, relativePoint, x, y + 50)
441 if level:GetBottom() > 0 then
442 level:SetPoint(point, parent, relativePoint, x, y + 50 - level:GetBottom())
443 end
444 end
445 else
446 if level:GetTop() > GetScreenHeight() then
447 local point, parent, relativePoint, x, y = level:GetPoint(1)
448 level:SetPoint(point, parent, relativePoint, x, y - 50)
449 if level:GetTop() < GetScreenHeight() then
450 level:SetPoint(point, parent, relativePoint, x, y - 50 + GetScreenHeight() - level:GetTop())
451 end
452 end
453 end
454 end
455  
456 local sliderFrame
457  
458 local function AcquireButton(self, level)
459 if not levels[level] then
460 return
461 end
462 level = levels[level]
463 if not level.buttons then
464 level.buttons = {}
465 end
466 local button
467 if tgetn(buttons) == 0 then
468 button = CreateFrame("Button")
469 button:SetFrameStrata("FULLSCREEN_DIALOG")
470 button:SetHeight(16)
471 local highlight = button:CreateTexture(nil, "BACKGROUND")
472 highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
473 button.highlight = highlight
474 highlight:SetBlendMode("ADD")
475 highlight:SetAllPoints(button)
476 highlight:Hide()
477 local check = button:CreateTexture(nil, "ARTWORK")
478 button.check = check
479 check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
480 check:SetPoint("CENTER", button, "LEFT", 12, 0)
481 check:SetWidth(24)
482 check:SetHeight(24)
483 local radioHighlight = button:CreateTexture(nil, "ARTWORK")
484 button.radioHighlight = radioHighlight
485 radioHighlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
486 radioHighlight:SetAllPoints(check)
487 radioHighlight:SetBlendMode("ADD")
488 radioHighlight:SetTexCoord(0.5, 0.75, 0, 1)
489 radioHighlight:Hide()
490 button:SetScript("OnEnter", function()
491 if sliderFrame and sliderFrame:IsShown() and sliderFrame.mouseDown and sliderFrame.level == this.level.num + 1 then
492 Refresh(self, this.level)
493 return
494 end
495 self:Close(this.level.num + 1)
496 if this.hasSlider then
497 OpenSlider(self, this)
498 elseif this.hasArrow then
499 Open(self, this, nil, this.level.num + 1, this.value)
500 end
501 StopCounting(self, this.level.num + 1)
502 if not this.disabled then
503 highlight:Show()
504 if this.isRadio then
505 button.radioHighlight:Show()
506 end
507 end
508 if this.tooltipTitle then
509 GameTooltip_AddNewbieTip(this.tooltipTitle, 1.0, 1.0, 1.0, this.tooltipText, 1)
510 end
511 end)
512 button:SetScript("OnLeave", function()
513 highlight:Hide()
514 button.radioHighlight:Hide()
515 if this.level then
516 StartCounting(self, this.level.num)
517 end
518 GameTooltip:Hide()
519 end)
520 button:SetScript("OnClick", function()
521 if not this.disabled then
522 if this.hasColorSwatch then
523 local func = button.swatchFunc
524 ColorPickerFrame.func = function()
525 if func then
526 func(ColorPickerFrame:GetColorRGB())
527 end
528 end
529 ColorPickerFrame.hasOpacity = this.hasOpacity
530 local func = this.opacityFunc
531 ColorPickerFrame.opacityFunc = function()
532 if func then
533 func(1 - OpacitySliderFrame:GetValue())
534 end
535 end
536 ColorPickerFrame.opacity = 1 - this.opacity
537 ColorPickerFrame:SetColorRGB(this.r, this.g, this.b)
538 if this.cancelFunc then
539 local r, g, b, a = this.r, this.g, this.b, this.opacity
540 local func = this.cancelFunc
541 ColorPickerFrame.cancelFunc = function()
542 func(r, g, b, a)
543 end
544 end
545 self:Close(1)
546 ShowUIPanel(ColorPickerFrame)
547 elseif this.func then
548 local level = button.level
549 if type(this.func) == "string" then
550 assert(type(this.arg1[this.func]) == "function", "Cannot call method " .. this.func)
551 this.arg1[this.func](this.arg1, this.arg2, this.arg3)
552 else
553 this.func(this.arg1, this.arg2, this.arg3)
554 end
555 if this.closeWhenClicked then
556 self:Close()
557 elseif level:IsShown() then
558 Refresh(self, level)
559 end
560 elseif this.closeWhenClicked then
561 self:Close()
562 end
563 end
564 end)
565 local text = button:CreateFontString(nil, "ARTWORK")
566 button.text = text
567 text:SetFontObject(GameFontHighlightSmall)
568 button.text:SetFont(STANDARD_TEXT_FONT, UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT)
569 button:SetScript("OnMouseDown", function()
570 if not this.disabled and (this.func or this.swatchFunc or this.closeWhenClicked) then
571 text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 1 or 25, -1)
572 end
573 end)
574 button:SetScript("OnMouseUp", function()
575 if not this.disabled and (this.func or this.swatchFunc or this.closeWhenClicked) then
576 text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 0 or 24, 0)
577 end
578 end)
579 local arrow = button:CreateTexture(nil, "ARTWORK")
580 button.arrow = arrow
581 arrow:SetPoint("RIGHT", button, "RIGHT", 0, 0)
582 arrow:SetWidth(16)
583 arrow:SetHeight(16)
584 arrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
585 local colorSwatch = button:CreateTexture(nil, "OVERLAY")
586 button.colorSwatch = colorSwatch
587 colorSwatch:SetWidth(20)
588 colorSwatch:SetHeight(20)
589 colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
590 local texture = button:CreateTexture(nil, "OVERLAY")
591 colorSwatch.texture = texture
592 texture:SetTexture(1, 1, 1)
593 texture:SetWidth(11.5)
594 texture:SetHeight(11.5)
595 texture:Show()
596 texture:SetPoint("CENTER", colorSwatch, "CENTER")
597 colorSwatch:SetPoint("RIGHT", button, "RIGHT", 0, 0)
598 else
599 button = buttons[tgetn(buttons)]
600 tremove(buttons, tgetn(buttons))
601 end
602 button:SetParent(level)
603 button:SetFrameStrata(level:GetFrameStrata())
604 button:SetFrameLevel(level:GetFrameLevel() + 1)
605 button:SetPoint("LEFT", level, "LEFT", 10, 0)
606 button:SetPoint("RIGHT", level, "RIGHT", -10, 0)
607 if tgetn(level.buttons) == 0 then
608 button:SetPoint("TOP", level, "TOP", 0, -10)
609 else
610 button:SetPoint("TOP", level.buttons[tgetn(level.buttons)], "BOTTOM", 0, 0)
611 end
612 button.text:SetPoint("LEFT", button, "LEFT", 24, 0)
613 button:Show()
614 button.level = level
615 tinsert(level.buttons, button)
616 if not level.parented then
617 level.parented = true
618 level:ClearAllPoints()
619 if level.num == 1 then
620 if level.parent ~= UIParent then
621 level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT")
622 else
623 level:SetPoint("CENTER", level.parent, "CENTER")
624 end
625 else
626 if level.lastDirection == "RIGHT" then
627 if level.lastVDirection == "DOWN" then
628 level:SetPoint("TOPLEFT", level.parent, "TOPRIGHT", 5, 10)
629 else
630 level:SetPoint("BOTTOMLEFT", level.parent, "BOTTOMRIGHT", 5, -10)
631 end
632 else
633 if level.lastVDirection == "DOWN" then
634 level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT", -5, 10)
635 else
636 level:SetPoint("BOTTOMRIGHT", level.parent, "BOTTOMLEFT", -5, -10)
637 end
638 end
639 end
640 level:SetFrameStrata("TOOLTIP")
641 end
642 return button
643 end
644  
645 local function AcquireLevel(self, level)
646 if not levels[level] then
647 for i = tgetn(levels) + 1, level, -1 do
648 local i = i
649 local frame = CreateFrame("Button")
650 if i == 1 then
651 local old_CloseWindows = CloseWindows
652 function CloseWindows(ignoreCenter)
653 local found = old_CloseWindows(ignoreCenter)
654 if levels[1]:IsShown() then
655 self:Close()
656 return 1
657 end
658 return found
659 end
660 end
661 levels[i] = frame
662 frame.num = i
663 frame:SetParent(UIParent)
664 frame:SetFrameStrata("TOOLTIP")
665 frame:Hide()
666 frame:SetWidth(180)
667 frame:SetHeight(10)
668 frame:SetFrameLevel(i * 3)
669 frame:SetScript("OnHide", function()
670 self:Close(level + 1)
671 end)
672 frame:SetFrameStrata("FULLSCREEN_DIALOG")
673 if frame.SetTopLevel then
674 frame:SetTopLevel(true)
675 end
676 frame:EnableMouse(true)
677 frame:EnableMouseWheel(true)
678 local backdrop = CreateFrame("Frame", nil, frame)
679 backdrop:SetAllPoints(frame)
680 backdrop:SetBackdrop(tmp(
681 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
682 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
683 'tile', true,
684 'insets', tmp2(
685 'left', 5,
686 'right', 5,
687 'top', 5,
688 'bottom', 5
689 ),
690 'tileSize', 16,
691 'edgeSize', 16
692 ))
693 backdrop:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
694 backdrop:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
695 frame:SetScript("OnClick", function()
696 self:Close(i)
697 end)
698 frame:SetScript("OnEnter", function()
699 StopCounting(self, i)
700 end)
701 frame:SetScript("OnLeave", function()
702 StartCounting(self, i)
703 end)
704 frame:SetScript("OnMouseWheel", function()
705 Scroll(self, frame, arg1 < 0)
706 end)
707 if i == 1 then
708 frame:SetScript("OnUpdate", function()
709 OnUpdate(self, arg1)
710 end)
711 levels[1].lastDirection = "RIGHT"
712 levels[1].lastVDirection = "DOWN"
713 else
714 levels[i].lastDirection = levels[i - 1].lastDirection
715 levels[i].lastVDirection = levels[i - 1].lastVDirection
716 end
717 end
718 end
719 return levels[level]
720 end
721  
722 local baseFunc, currentLevel
723 function Refresh(self, level)
724 if type(level) == "number" then
725 level = levels[level]
726 end
727 if not level then
728 return
729 end
730 if baseFunc then
731 currentLevel = level.num
732 Clear(self, level)
733 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)
734 CheckSize(self, level)
735 end
736 end
737  
738 function lib:Refresh(level)
739 Refresh(self, levels[level])
740 end
741  
742 function OpenSlider(self, parent)
743 if not sliderFrame then
744 sliderFrame = CreateFrame("Frame", nil, UIParent)
745 sliderFrame:SetWidth(80)
746 sliderFrame:SetHeight(170)
747 sliderFrame:SetBackdrop(tmp(
748 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
749 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
750 'tile', true,
751 'insets', tmp2(
752 'left', 5,
753 'right', 5,
754 'top', 5,
755 'bottom', 5
756 ),
757 'tileSize', 16,
758 'edgeSize', 16
759 ))
760 sliderFrame:SetFrameStrata("TOOLTIP")
761 if sliderFrame.SetTopLevel then
762 sliderFrame:SetTopLevel(true)
763 end
764 sliderFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
765 sliderFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
766 sliderFrame:EnableMouse(TRUE)
767 sliderFrame:Hide()
768 sliderFrame:SetPoint("CENTER", UIParent, "CENTER")
769 local slider = CreateFrame("Slider", nil, sliderFrame)
770 sliderFrame.slider = slider
771 slider:SetOrientation("VERTICAL")
772 slider:SetMinMaxValues(0, 1)
773 slider:SetValueStep(0.01)
774 slider:SetValue(0.5)
775 slider:SetWidth(16)
776 slider:SetHeight(128)
777 slider:SetPoint("LEFT", sliderFrame, "LEFT", 15, 0)
778 slider:SetBackdrop(tmp(
779 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background",
780 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border",
781 'tile', true,
782 'edgeSize', 8,
783 'tileSize', 8,
784 'insets', tmp2(
785 'left', 3,
786 'right', 3,
787 'top', 3,
788 'bottom', 3
789 )
790 ))
791 local texture = slider:CreateTexture()
792 slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
793 local text = slider:CreateFontString(nil, "ARTWORK")
794 sliderFrame.topText = text
795 text:SetFontObject(GameFontGreenSmall)
796 text:SetText("100%")
797 text:SetPoint("BOTTOM", slider, "TOP")
798 local text = slider:CreateFontString(nil, "ARTWORK")
799 sliderFrame.bottomText = text
800 text:SetFontObject(GameFontGreenSmall)
801 text:SetText("0%")
802 text:SetPoint("TOP", slider, "BOTTOM")
803 local text = slider:CreateFontString(nil, "ARTWORK")
804 sliderFrame.currentText = text
805 text:SetFontObject(GameFontHighlightSmall)
806 text:SetText("50%")
807 text:SetPoint("LEFT", slider, "RIGHT")
808 text:SetPoint("RIGHT", sliderFrame, "RIGHT", -6, 0)
809 text:SetJustifyH("CENTER")
810 local changed = false
811 local inside = false
812 slider:SetScript("OnValueChanged", function()
813 if sliderFrame.changing then
814 return
815 end
816 changed = true
817 local done = false
818 if sliderFrame.parent then
819 if sliderFrame.parent.sliderFunc then
820 local text = sliderFrame.parent.sliderFunc(1 - slider:GetValue())
821 if text then
822 sliderFrame.currentText:SetText(text)
823 done = true
824 end
825 end
826 end
827 if not done then
828 sliderFrame.currentText:SetText(format("%.0f%%", (1 - slider:GetValue()) * 100))
829 end
830 end)
831 sliderFrame:SetScript("OnEnter", function()
832 StopCounting(self, sliderFrame.level)
833 end)
834 sliderFrame:SetScript("OnLeave", function()
835 StartCounting(self, sliderFrame.level)
836 end)
837 slider:SetScript("OnMouseDown", function()
838 sliderFrame.mouseDown = true
839 end)
840 slider:SetScript("OnMouseUp", function()
841 sliderFrame.mouseDown = false
842 if changed and not inside then
843 local parent = sliderFrame.parent
844 Refresh(self, levels[sliderFrame.level - 1])
845 OpenSlider(self, parent)
846 end
847 end)
848 slider:SetScript("OnEnter", function()
849 inside = true
850 StopCounting(self, sliderFrame.level)
851 end)
852 slider:SetScript("OnLeave", function()
853 inside = false
854 StartCounting(self, sliderFrame.level)
855 if changed and not sliderFrame.mouseDown then
856 local parent = sliderFrame.parent
857 Refresh(self, levels[sliderFrame.level - 1])
858 OpenSlider(self, parent)
859 end
860 end)
861 end
862 sliderFrame.parent = parent
863 sliderFrame.level = parent.level.num + 1
864 sliderFrame.parentValue = parent.level.value
865 sliderFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3)
866 sliderFrame.slider:SetFrameLevel(sliderFrame:GetFrameLevel() + 1)
867 sliderFrame.changing = true
868 if not parent.sliderValue then
869 parent.sliderValue = 0.5
870 end
871 sliderFrame.slider:SetValue(1 - parent.sliderValue)
872 sliderFrame.changing = false
873 sliderFrame.bottomText:SetText(parent.sliderBottom or "0%")
874 sliderFrame.topText:SetText(parent.sliderTop or "100%")
875 local text
876 if parent.sliderFunc then
877 text = parent.sliderFunc(parent.sliderValue)
878 end
879 sliderFrame.currentText:SetText(text or format("%.0f%%", parent.sliderValue * 100))
880  
881 local level = parent.level
882 sliderFrame:Show()
883 sliderFrame:ClearAllPoints()
884 if level.lastDirection == "RIGHT" then
885 if level.lastVDirection == "DOWN" then
886 sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
887 else
888 sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
889 end
890 else
891 if level.lastVDirection == "DOWN" then
892 sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
893 else
894 sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
895 end
896 end
897 local dirty
898 if level.lastDirection == "RIGHT" then
899 if sliderFrame:GetRight() > GetScreenWidth() then
900 level.lastDirection = "LEFT"
901 dirty = true
902 end
903 elseif sliderFrame:GetLeft() < 0 then
904 level.lastDirection = "RIGHT"
905 dirty = true
906 end
907 if level.lastVDirection == "DOWN" then
908 if sliderFrame:GetBottom() < 0 then
909 level.lastVDirection = "UP"
910 dirty = true
911 end
912 elseif sliderFrame:GetTop() > GetScreenWidth() then
913 level.lastVDirection = "DOWN"
914 dirty = true
915 end
916 if dirty then
917 sliderFrame:ClearAllPoints()
918 if level.lastDirection == "RIGHT" then
919 if level.lastVDirection == "DOWN" then
920 sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
921 else
922 sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
923 end
924 else
925 if level.lastVDirection == "DOWN" then
926 sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
927 else
928 sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
929 end
930 end
931 end
932 local left, bottom = sliderFrame:GetLeft(), sliderFrame:GetBottom()
933 sliderFrame:ClearAllPoints()
934 sliderFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
935 if mod(level.num, 5) == 0 then
936 local left, bottom = level:GetLeft(), level:GetBottom()
937 level:ClearAllPoints()
938 level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
939 end
940 end
941  
942 function lib:IsOpen(parent)
943 return levels[1] and levels[1]:IsShown() and (parent == levels[1].parent or parent == levels[1]:GetParent())
944 end
945  
946 function Open(self, parent, func, level, value, point, relativePoint, cursorX, cursorY)
947 self:Close(level)
948 local frame = AcquireLevel(self, level)
949 if level == 1 then
950 frame.lastDirection = "RIGHT"
951 frame.lastVDirection = "DOWN"
952 else
953 frame.lastDirection = levels[level - 1].lastDirection
954 frame.lastVDirection = levels[level - 1].lastVDirection
955 end
956 frame:SetFrameStrata("TOOLTIP")
957 frame:ClearAllPoints()
958 frame.parent = parent
959 frame:SetPoint("LEFT", UIParent, "RIGHT", 10000, 0)
960 frame:Show()
961 if level == 1 then
962 baseFunc = func
963 end
964 levels[level].value = value
965 relativePoint = relativePoint or point
966 Refresh(self, levels[level])
967 if point then
968 frame:ClearAllPoints()
969 frame:SetPoint(point, parent, relativePoint)
970 if cursorX then
971 local left = frame:GetLeft()
972 local width = frame:GetWidth()
973 local curX, curY = GetCursorPosition()
974 frame:ClearAllPoints()
975 relativePoint = relativePoint or point
976 if point == "BOTTOM" or point == "TOP" then
977 if curX < GetScreenWidth() / 2 then
978 point = point .. "LEFT"
979 else
980 point = point .. "RIGHT"
981 end
982 elseif point == "CENTER" then
983 if curX < GetScreenWidth() / 2 then
984 point = "LEFT"
985 else
986 point = "RIGHT"
987 end
988 end
989 frame:SetPoint(point, parent, relativePoint, curX - left - width / 2, 0)
990 if level == 1 then
991 frame.lastDirection = "RIGHT"
992 end
993 elseif cursorY then
994 local bottom = frame:GetBottom()
995 local height = frame:GetHeight()
996 local curX, curY = GetCursorPosition()
997 frame:ClearAllPoints()
998 relativePoint = relativePoint or point
999 if point == "LEFT" or point == "RIGHT" then
1000 if curX < GetScreenHeight() / 2 then
1001 point = point .. "BOTTOM"
1002 else
1003 point = point .. "TOP"
1004 end
1005 elseif point == "CENTER" then
1006 if curX < GetScreenHeight() / 2 then
1007 point = "BOTTOM"
1008 else
1009 point = "TOP"
1010 end
1011 end
1012 frame:SetPoint(point, parent, relativePoint, 0, curY - bottom - height / 2)
1013 if level == 1 then
1014 frame.lastDirection = "DOWN"
1015 end
1016 end
1017 if (strsub(point, 1, 3) ~= strsub(relativePoint, 1, 3)) then
1018 if frame:GetBottom() < 0 then
1019 local point, parent, relativePoint, x, y = frame:GetPoint(1)
1020 local change = GetScreenHeight() - frame:GetTop()
1021 local otherChange = -frame:GetBottom()
1022 if otherChange < change then
1023 change = otherChange
1024 end
1025 frame:SetPoint(point, parent, relativePoint, x, y + change)
1026 elseif frame:GetTop() > GetScreenHeight() then
1027 local point, parent, relativePoint, x, y = frame:GetPoint(1)
1028 local change = GetScreenHeight() - frame:GetTop()
1029 local otherChange = -frame:GetBottom()
1030 if otherChange < change then
1031 change = otherChange
1032 end
1033 frame:SetPoint(point, parent, relativePoint, x, y + change)
1034 end
1035 end
1036 end
1037 StartCounting(self, level)
1038 end
1039  
1040 function lib:IsRegistered(parent)
1041 assert(parent, "You must provide a parent frame to check")
1042 return not not self.registry[parent]
1043 end
1044  
1045 function lib:Register(parent, k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
1046 assert(parent, "You must provide a parent frame to register with")
1047 if self.registry[parent] then
1048 self:Unregister(parent)
1049 end
1050 local info = new(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
1051 self.registry[parent] = info
1052 if not info.dontHook and not self.onceRegistered[parent] then
1053 if parent:HasScript("OnMouseUp") then
1054 local script = parent:GetScript("OnMouseUp")
1055 parent:SetScript("OnMouseUp", function()
1056 if script then
1057 script()
1058 end
1059 if arg1 == "RightButton" and self.registry[parent] then
1060 if self:IsOpen(parent) then
1061 self:Close()
1062 else
1063 self:Open(parent)
1064 end
1065 end
1066 end)
1067 end
1068 if parent:HasScript("OnMouseDown") then
1069 local script = parent:GetScript("OnMouseDown")
1070 parent:SetScript("OnMouseDown", function()
1071 if script then
1072 script()
1073 end
1074 if self.registry[parent] then
1075 self:Close()
1076 end
1077 end)
1078 end
1079 end
1080 self.onceRegistered[parent] = true
1081 end
1082  
1083 function lib:Unregister(parent)
1084 assert(self.registry[parent], "You cannot unregister a parent frame if it has not been registered already.")
1085 self.registry[parent] = nil
1086 end
1087  
1088 function lib:Open(parent, k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
1089 local info
1090 if type(k1) == "table" and k1[0] and k1.IsFrameType and self.registry[k1] then
1091 info = tmp()
1092 for k,v in pairs(self.registry[k1]) do
1093 info[k] = v
1094 end
1095 else
1096 info = tmp(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
1097 if self.registry[parent] then
1098 for k,v in pairs(self.registry[parent]) do
1099 if info[k] == nil then
1100 info[k] = v
1101 end
1102 end
1103 end
1104 end
1105 local point = info.point
1106 local relativePoint = info.relativePoint
1107 local cursorX = info.cursorX
1108 local cursorY = info.cursorY
1109 if type(point) == "function" then
1110 local b
1111 point, b = point(parent)
1112 if b then
1113 relativePoint = b
1114 end
1115 end
1116 if type(relativePoint) == "function" then
1117 relativePoint = relativePoint(parent)
1118 end
1119 Open(self, parent, info.children, 1, nil, point, relativePoint, cursorX, cursorY)
1120 end
1121  
1122 function Clear(self, level)
1123 if level then
1124 if level.buttons then
1125 for i = tgetn(level.buttons), 1, -1 do
1126 ReleaseButton(self, level, i)
1127 end
1128 end
1129 end
1130 end
1131  
1132 function lib:Close(level)
1133 if DropDownList1:IsShown() then
1134 DropDownList1:Hide()
1135 end
1136 if not level then
1137 level = 1
1138 end
1139 if level == 1 and levels[level] then
1140 levels[level].parented = false
1141 end
1142 if sliderFrame and sliderFrame.level == level then
1143 sliderFrame:Hide()
1144 end
1145 if levels[level] and levels[level]:IsShown() then
1146 Clear(self, levels[level])
1147 levels[level]:Hide()
1148 end
1149 end
1150  
1151 function lib:AddLine(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
1152 local info = tmp(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10, k11, v11, k12, v12, k13, v13, k14, v14, k15, v15, k16, v16, k17, v17, k18, v18, k19, v19, k20, v20)
1153 local level = info.level or currentLevel
1154 info.level = nil
1155 local button = AcquireButton(self, level)
1156 if not next(info) then
1157 info.disabled = true
1158 end
1159 button.disabled = info.isTitle or info.notClickable or info.disabled
1160 button.isTitle = info.isTitle
1161 button.notClickable = info.notClickable
1162 if button.isTitle then
1163 button.text:SetFontObject(GameFontNormalSmall)
1164 elseif button.notClickable then
1165 button.text:SetFontObject(GameFontHighlightSmall)
1166 elseif button.disabled then
1167 button.text:SetFontObject(GameFontDisableSmall)
1168 else
1169 button.text:SetFontObject(GameFontHighlightSmall)
1170 end
1171 if info.textR and info.textG and info.textB then
1172 button.textR = info.textR
1173 button.textG = info.textG
1174 button.textB = info.textB
1175 button.text:SetTextColor(button.textR, button.textG, button.textB)
1176 else
1177 button.text:SetTextColor(button.text:GetFontObject():GetTextColor())
1178 end
1179 button.notCheckable = info.notCheckable
1180 button.text:SetPoint("LEFT", button, "LEFT", button.notCheckable and 0 or 24, 0)
1181 button.checked = not info.notCheckable and info.checked
1182 button.isRadio = not info.notCheckable and info.isRadio
1183 if info.isRadio then
1184 button.check:Show()
1185 button.check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
1186 if button.checked then
1187 button.check:SetTexCoord(0.25, 0.5, 0, 1)
1188 button.check:SetVertexColor(1, 1, 1, 1)
1189 else
1190 button.check:SetTexCoord(0, 0.25, 0, 1)
1191 button.check:SetVertexColor(1, 1, 1, 0.5)
1192 end
1193 button.radioHighlight:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
1194 button.check:SetWidth(16)
1195 button.check:SetHeight(16)
1196 else
1197 if button.checked then
1198 button.check:SetTexCoord(0, 1, 0, 1)
1199 if info.checkIcon then
1200 button.check:SetWidth(16)
1201 button.check:SetHeight(16)
1202 button.check:SetTexture(info.checkIcon)
1203 else
1204 button.check:SetWidth(24)
1205 button.check:SetHeight(24)
1206 button.check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
1207 end
1208 button.check:SetVertexColor(1, 1, 1, 1)
1209 else
1210 button.check:SetVertexColor(1, 1, 1, 0)
1211 end
1212 end
1213 if not button.disabled then
1214 button.func = info.func
1215 end
1216 button.hasColorSwatch = info.hasColorSwatch
1217 if button.hasColorSwatch then
1218 button.colorSwatch:Show()
1219 button.colorSwatch.texture:Show()
1220 button.r = info.r or 1
1221 button.g = info.g or 1
1222 button.b = info.b or 1
1223 button.colorSwatch.texture:SetTexture(button.r, button.g, button.b)
1224 button.checked = false
1225 button.func = nil
1226 button.swatchFunc = info.swatchFunc
1227 button.hasOpacity = info.hasOpacity
1228 button.opacityFunc = info.opacityFunc
1229 button.opacity = info.opacity or 1
1230 button.cancelFunc = info.cancelFunc
1231 else
1232 button.colorSwatch:Hide()
1233 button.colorSwatch.texture:Hide()
1234 end
1235 button.hasArrow = not button.hasColorSwatch and (info.value or info.hasSlider) and info.hasArrow
1236 if button.hasArrow then
1237 button.arrow:SetAlpha(1)
1238 if info.hasSlider then
1239 button.hasSlider = info.hasSlider
1240 button.sliderTop = info.sliderTop or "100%"
1241 button.sliderBottom = info.sliderBottom or "0%"
1242 button.sliderFunc = info.sliderFunc
1243 button.sliderValue = info.sliderValue
1244 else
1245 button.value = info.value
1246 end
1247 else
1248 button.arrow:SetAlpha(0)
1249 end
1250 button.arg1 = info.arg1
1251 button.arg2 = info.arg2
1252 button.arg3 = info.arg3
1253 button.closeWhenClicked = info.closeWhenClicked
1254 button.textHeight = info.textHeight or UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT
1255 local font,_ = button.text:GetFont()
1256 button.text:SetFont(STANDARD_TEXT_FONT, button.textHeight)
1257 button:SetHeight(button.textHeight + 6)
1258 button.text:SetPoint("RIGHT", button.arrow, (button.hasColorSwatch or button.hasArrow) and "LEFT" or "RIGHT")
1259 button.text:SetJustifyH(info.justifyH or "LEFT")
1260 button.text:SetText(info.text)
1261 button.tooltipTitle = info.tooltipTitle
1262 button.tooltipText = info.tooltipText
1263 if type(button.func) == "string" then
1264 assert(type(button.arg1) == "table", "Cannot call method " .. button.func .. " on a non-table")
1265 assert(type(button.arg1[button.func]) == "function", "Method " .. button.func .. " nonexistant.")
1266 end
1267 end
1268  
1269 DewdropLib:Register(lib)
1270 lib = nil