-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMrSunderBars.lua
83 lines (78 loc) · 2.47 KB
/
MrSunderBars.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
MrSunderBars = {};
function MrSunder_CreateBars()
for i=1,5 do
MrSunder["Timestamp" .. i] = 0;
local f = CreateFrame("StatusBar", "SunderBar" .. i, UIParent);
f = getglobal("SunderBar" .. i);
f:SetWidth(200);
f:SetHeight(20);
f:SetPoint("CENTER", UIParent, "CENTER",
MrSunderOffsetX - MrSunderBarXPadding * (i - 1),
MrSunderOffsetY - MrSunderBarYPadding * (i - 1));
f:SetBackdrop({bgFile = [[Interface\ChatFrame\ChatFrameBackground]]})
f:SetStatusBarColor(0, 0, 0, 0.7)
f:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
f:SetBackdropColor(0, 0.5, 1)
f:SetMinMaxValues(0, 30);
local l = f:CreateFontString("SunderBarLabel" .. i, "OVERLAY", "GameFontHighlight");
l = getglobal("SunderBarLabel" .. i);
l:SetWidth(200);
l:SetPoint("TOPLEFT", 0, -20);
l:SetTextColor(0.3, 0.51, 0.77);
l:SetText("MRSUNDER_DEFAULT_BAR_TEXT" .. i);
local l = f:CreateFontString("SunderBarTimer" .. i, "OVERLAY", "GameFontHighlight");
l = getglobal("SunderBarTimer" .. i);
l:SetWidth(200);
l:SetPoint("TOPLEFT", 0, 0);
l:SetTextColor(1, 0.2, 0.2);
l:SetText("MRSUNDER_DEFAULT_BAR_TEXT" .. i);
f:Hide();
f.Index = i;
--debugging
f:SetScript("OnUpdate", function(self)
local timestamp = MrSunder_GetTimeLeft(f.Index);
l:SetText(30 - floor(timestamp + .5));
if(timestamp >= 30) then
f:Hide();
MrSunder["Timestamp" .. f.Index] = 0;
end
f:SetValue(timestamp)
end)
end
end
function MrSunder_Populate(name, time)
if(MrSunderBars[1] == nil) then
MrSunder_CreateBars();
end
if(not MrSunder_PlayerInstanced) then
return;
end
for i=1,5 do
if(MrSunderBars[i] == name) then
MrSunder["Timestamp" .. i] = time;
getglobal("SunderBarLabel" .. i):SetText(name);
getglobal("SunderBar" .. i):Show();
return;
end
end
for i=1,5 do
local bar = getglobal("SunderBar" .. i);
if(not bar:IsVisible()) then
MrSunderBars[i] = name;
MrSunder["Timestamp" .. i] = time;
getglobal("SunderBarLabel" .. i):SetText(name);
getglobal("SunderBar" .. i):Show();
return;
end
end
end
function MrSunder_RemoveBar(name)
for i=1,5 do
if(MrSunderBars[i] == name) then
getglobal("SunderBar" .. i):Hide();
end
end
end
function MrSunder_GetTimeLeft(index)
return GetTime() - MrSunder["Timestamp" .. index];
end