-
Notifications
You must be signed in to change notification settings - Fork 0
/
LysCastingBarTimer.lua
77 lines (59 loc) · 2.51 KB
/
LysCastingBarTimer.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
--[[
Lysidia's Casting Bar Timer
Very simple addon to provide a timer to the standard casting bar frame, also support the "mirror" bar.
No Configuration, install and go.
]]
LCB_FontSize = 10; -- Size of Text Font
-- To change the precision of the display, change the .2 to how many decimal places you want.
CastingBarTimer_DisplayString = " (%0.2fs)";
-- Function: Add count down timer to the Cast/Channelling Bar Frame.
function LysCastingBarFrame_OnUpdate( self, ... )
local timerValue = self.maxValue - self.value;
local textDisplay = self.Text;
local _, text, displayName, tempText;
if ( self.casting ) then
text = CastingInfo(self.unit);
elseif ( self.channeling ) then
text = ChannelInfo(self.unit);
timerValue = self.value;
end
if ( text ) then
displayName = text..CastingBarTimer_DisplayString;
end
if (displayName ~= nil) then
if (timerValue) then
if (timerValue > 0.01) then
-- Shrink the font a little to fit more text in
local fontName, fontHeight, fontFlags = textDisplay:GetFont();
textDisplay:SetFont(fontName, LCB_FontSize, fontFlags);
-- Update with the new text
textDisplay:SetText( format(displayName, timerValue) );
end
end
end
end
-- Function: Add count down timer to the Mirror Bar Frame
function LysMirrorBarFrame_OnUpdate(self, elapsed)
local text = _G[self:GetName().."Text"];
local displayName = text:GetText();
-- DEFAULT_CHAT_FRAME:AddMessage("LCT DEBUG: I got called!", 1, 1, 1);
if (displayName) then
local tempName = string.gsub(displayName, "(.+)", "");
tempName = tempName..CastingBarTimer_DisplayString;
if ((self.value) and (self.value > 0.01)) then
-- Shrink the font a little to fit more text in
local fontName, fontHeight, fontFlags = text:GetFont();
text:SetFont(fontName, LCB_FontSize, fontFlags);
-- Update with the new text
text:SetText( format(tempName, self.value) );
end
end
end
-- Hook the Blizzard OnUpdate handlers, using hooksecurefunc, reduces the risk of tainting.
--hooksecurefunc("CastingBarFrame_OnUpdate", LysCastingBarFrame_OnUpdate);
CastingBarFrame:HookScript("OnUpdate", LysCastingBarFrame_OnUpdate)
CastingBarFrame:HookScript("OnUpdate", LysCastingBarFrame_OnUpdate)
--hooksecurefunc("MirrorTimerFrame_OnUpdate", LysMirrorBarFrame_OnUpdate);
MirrorTimer1:HookScript("OnUpdate", LysMirrorBarFrame_OnUpdate)
MirrorTimer2:HookScript("OnUpdate", LysMirrorBarFrame_OnUpdate)
MirrorTimer3:HookScript("OnUpdate", LysMirrorBarFrame_OnUpdate)