TourGuide: 12_17_Darkshore.lua: levels 12-14 confirmed working
[WoW-TourGuide.git] / WidgetWarlock.lua
blob1cbfc540b25c14ebaaa126f03c845503d30de069
3 WidgetWarlock = {}
6 WidgetWarlock.TooltipBorderBG = {
7 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
8 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
9 edgeSize = 16,
10 insets = {left = 4, right = 4, top = 4, bottom = 4}
14 function WidgetWarlock.SummonCheckBox(size, parent, ...)
15 local check = CreateFrame("CheckButton", nil, parent)
16 check:SetWidth(size)
17 check:SetHeight(size)
18 if select(1, ...) then check:SetPoint(...) end
20 check:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up")
21 check:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down")
22 check:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
23 check:SetDisabledCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled")
24 check:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check")
26 return check
27 end
30 function WidgetWarlock.SummonTexture(parent, layer, w, h, texture, ...)
31 local tex = parent:CreateTexture(nil, layer)
32 if w then tex:SetWidth(w) end
33 if h then tex:SetHeight(h) end
34 tex:SetTexture(texture)
35 if select(1, ...) then tex:SetPoint(...) end
36 return tex
37 end
40 function WidgetWarlock.SummonFontString(parent, layer, inherit, text, ...)
41 local fs = parent:CreateFontString(nil, layer, inherit)
42 fs:SetText(text)
43 if select(1, ...) then fs:SetPoint(...) end
44 return fs
45 end
48 -----------------------
49 -- Fade In --
50 -----------------------
52 local fadetimes = setmetatable({}, {__index = function() return 1 end})
53 local elapsed = setmetatable({}, {__index = function() return 0 end})
56 function WidgetWarlock.SetFadeTime(frame, time)
57 assert(frame, "No frame passed")
58 assert(type(time) == "number", "Time must be a number")
59 assert(time > 0, "Time must be positive")
60 fadetimes[frame] = time
61 end
64 function WidgetWarlock.FadeIn(frame, elap)
65 elapsed[frame] = elapsed[frame] + elap
66 if elapsed[frame] > fadetimes[frame] then
67 frame:SetScript("OnUpdate", nil)
68 frame:SetAlpha(1)
69 elapsed[frame] = 0
70 else frame:SetAlpha(elapsed[frame]/fadetimes[frame]) end
71 end