-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTotemTimer.lua
191 lines (175 loc) · 6.82 KB
/
TotemTimer.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
local _G = getfenv(0)
local Dragging = 0;
function TotemTimer_OnUpdate(arg1)
if( this.element ) then
local data = TTActiveTotems[this.element];
if ( data and data.active ) then
if ( data.duration < 0 ) then
TotemTimers_TotemDeath(data.totem);
else
data.duration = data.duration - arg1;
getglobal(this:GetName().."Time"):SetText(TotemTimer_FormatTime(data.duration));
if( TTData.Totems[data.totem] ) then
if( data.warningTime ) then
if ( data.duration <= data.warningTime ) then
data.warningTime = nil;
TotemTimers_TotemWarn(data.totem);
end
end
end
if( data.duration <= 60 ) then
getglobal(this:GetName().."Time"):SetTextColor(1.0,1.0,1.0);
else
getglobal(this:GetName().."Time"):SetTextColor(1.0,.8,0);
end
if( data.duration <= TTData.flash ) then
data.flashTime = data.flashTime - arg1;
if ( data.flashTime < 0 ) then
if ( data.flashState == 1 ) then
data.flashState = 0;
data.flashTime = BUFF_FLASH_TIME_OFF;
else
data.flashState = 1;
data.flashTime = BUFF_FLASH_TIME_ON;
end
end
if ( data.flashState == 1 ) then
totemAlphaValue = (BUFF_FLASH_TIME_ON - data.flashTime) / BUFF_FLASH_TIME_ON;
totemAlphaValue = totemAlphaValue * (1 - BUFF_MIN_ALPHA) + BUFF_MIN_ALPHA
else
totemAlphaValue = data.flashTime / BUFF_FLASH_TIME_ON;
totemAlphaValue = (data.flashTime * (1 - BUFF_MIN_ALPHA)) + BUFF_MIN_ALPHA;
getglobal(this:GetName().."Icon"):SetAlpha(data.flashTime / BUFF_FLASH_TIME_ON);
end
getglobal(this:GetName().."Icon"):SetAlpha(totemAlphaValue);
end
-- update tick here
if (this.element == "Air" and TT_AirTotem.previous == "Windfury" and
TT_AirTotem.previous ~= TT_AirTotem.current) then
-- windfury update logic
wf_data = TTActiveTotems["Windfury"]
wf_data.duration = wf_data.duration - arg1;
if wf_data.duration < (TotemData["Windfury"].duration - TotemData["Windfury"].tick) then
getglobal(this:GetName().."Tick"):SetText("")
return
end
if wf_data.ticks and wf_data.ticks[1] then
if wf_data.ticks[1]<= wf_data.duration then
if not IsAddOnLoaded("!OmniCC") then
-- i noticed that omnicc is overwriting the cooldown template and creates a timer itself
local dif = wf_data.duration - wf_data.ticks[1]
dif = math.floor(10*dif)/10
if _G[this:GetName().."Tick"]:GetText() ~= dif then
getglobal(this:GetName().."Tick"):SetText(dif)
end
end
if not getglobal(this:GetName().."Cooldown"):IsVisible() then
getglobal(this:GetName().."Cooldown"):Show()
end
else
tremove(TTActiveTotems["Windfury"].ticks,1)
--if not _G[this:GetName().."Cooldown"]:IsVisible() then
CooldownFrame_SetTimer(_G[this:GetName().."Cooldown"], GetTime(), TotemData["Windfury"].tick, 1)
--end
end
end
else
-- default update logic below
if data.ticks and data.ticks[1] then
if data.ticks[1]<= data.duration then
if not IsAddOnLoaded("!OmniCC") then
-- i noticed that omnicc is overwriting the cooldown template and creates a timer itself
local dif = data.duration - data.ticks[1]
dif = math.floor(10*dif)/10
if _G[this:GetName().."Tick"]:GetText() ~= dif then
getglobal(this:GetName().."Tick"):SetText(dif)
end
end
if not getglobal(this:GetName().."Cooldown"):IsVisible() then
getglobal(this:GetName().."Cooldown"):Show()
end
else
tremove(TTActiveTotems[this.element].ticks,1)
--if not _G[this:GetName().."Cooldown"]:IsVisible() then
CooldownFrame_SetTimer(_G[this:GetName().."Cooldown"], GetTime(), TotemData[data.totem].tick, 1)
--end
end
end
end
end
end
end
end
function TotemTimer_ReCast()
if( TTData.lock == 1 ) then
local data = TTActiveTotems[this.element];
--DEFAULT_CHAT_FRAME:AddMessage(TTActiveTotems[this.element]);
--DEFAULT_CHAT_FRAME:AddMessage(data);
if( data ) then
if( data["action"] ) then
UseAction(data["action"], data["number"], data["target"]);
elseif( data["spell"] ) then
CastSpell(data["spell"], data["book"]);
elseif ( data["Slot_Id"] ) then
--DEFAULT_CHAT_FRAME:AddMessage(data["Slot_Id"])
UseInventoryItem( data["Slot_Id"] );
end
end
end
end
function TotemTimer_OnDragStart()
if( TTData.lock ~= 1 ) then
TotemTimersFrame:StartMoving();
end
end
function TotemTimer_OnDragStop()
TotemTimersFrame:StopMovingOrSizing();
end
function TotemTimer_OnEnter()
local data = TTActiveTotems[this.element];
if( data ) then
if ( this:GetCenter() < UIParent:GetCenter() ) then
GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
else
GameTooltip:SetOwner(this, "ANCHOR_LEFT");
end
if( data["action"] ) then
GameTooltip:SetAction(data["action"]);
elseif( data["spell"] ) then
GameTooltip:SetSpell(data["spell"], data["book"]);
elseif( data["Slot_Id"] ) then
GameTooltip:SetInventoryItem("player", data["Slot_Id"]);
end
end
end
function TotemTimer_OnLoad()
this:RegisterForClicks("LeftButtonUp","RightButtonUp");
end
-- Functions ripped from TotemTimer
function TotemTimer_FormatTime(seconds)
local d, h, m, s;
local text;
if( TTData[TT_TIME] == TT_BLIZZARD ) then
if(seconds <= 0) then
text = "";
elseif(seconds < 60) then
d, h, m, s = ChatFrame_TimeBreakDown(seconds);
text = format("%d s", s);
elseif(seconds < 3600) then
d, h, m, s = ChatFrame_TimeBreakDown(seconds);
text = format("%d m", m);
else
text = "1 hr+";
end
else
if(seconds <= 0) then
text = "";
elseif(seconds < 3600) then
d, h, m, s = ChatFrame_TimeBreakDown(seconds);
text = format("%02d:%02d", m, s);
else
text = "1 hr+";
end
end
return text;
end