Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 2 | Wildbreath-135052 | --[[ |
2 | Wildbreath-135052 | Original codebase: |
|
3 | Wildbreath-135052 | oUF_Castbar by starlon. |
|
4 | Wildbreath-135052 | http://svn.wowace.com/wowace/trunk/oUF_Castbar/ |
|
5 | Wildbreath-135052 | ||
6 | Wildbreath-135052 | Elements handled: .Castbar |
|
7 | Wildbreath-135052 | Sub-elements: .Text, .Icon, .Time, .SafeZone, .Spark |
|
8 | Wildbreath-135052 | Notes: This element will not work on units that require a OnUpdate. |
|
9 | Wildbreath-135052 | (eventless units). |
|
10 | Wildbreath-135052 | ||
11 | Wildbreath-135052 | Functions that can be overridden from within a layout: |
|
12 | Wildbreath-135052 | - :CustomDelayText(duration) |
|
13 | Wildbreath-135052 | - :CustomTimeText(duration) |
|
14 | Wildbreath-135052 | ||
15 | Wildbreath-135052 | --]] |
|
16 | Wildbreath-135052 | local parent, ns = ... |
|
17 | Wildbreath-135052 | local oUF = ns.oUF |
|
18 | Wildbreath-135052 | ||
19 | Wildbreath-135052 | local noop = function() end |
|
20 | Wildbreath-135052 | local UnitName = UnitName |
|
21 | Wildbreath-135052 | local GetTime = GetTime |
|
22 | Wildbreath-135052 | local UnitCastingInfo = UnitCastingInfo |
|
23 | Wildbreath-135052 | local UnitChannelInfo = UnitChannelInfo |
|
24 | Wildbreath-135052 | ||
25 | Wildbreath-135052 | local UNIT_SPELLCAST_START = function(self, event, unit, spell, spellrank) |
|
26 | Wildbreath-135052 | if(self.unit ~= unit) then return end |
|
27 | Wildbreath-135052 | ||
28 | Wildbreath-135052 | local castbar = self.Castbar |
|
29 | Wildbreath-135052 | local name, rank, text, texture, startTime, endTime, _, castid, interrupt = UnitCastingInfo(unit) |
|
30 | Wildbreath-135052 | if(not name) then |
|
31 | Wildbreath-135052 | castbar:Hide() |
|
32 | Wildbreath-135052 | return |
|
33 | Wildbreath-135052 | end |
|
34 | Wildbreath-135052 | ||
35 | Wildbreath-135052 | endTime = endTime / 1e3 |
|
36 | Wildbreath-135052 | startTime = startTime / 1e3 |
|
37 | Wildbreath-135052 | local max = endTime - startTime |
|
38 | Wildbreath-135052 | ||
39 | Wildbreath-135052 | castbar.castid = castid |
|
40 | Wildbreath-135052 | castbar.duration = GetTime() - startTime |
|
41 | Wildbreath-135052 | castbar.max = max |
|
42 | Wildbreath-135052 | castbar.delay = 0 |
|
43 | Wildbreath-135052 | castbar.casting = true |
|
44 | Wildbreath-135052 | castbar.interrupt = interrupt |
|
45 | Wildbreath-135052 | ||
46 | Wildbreath-135052 | castbar:SetMinMaxValues(0, max) |
|
47 | Wildbreath-135052 | castbar:SetValue(0) |
|
48 | Wildbreath-135052 | ||
49 | Wildbreath-135052 | if(castbar.Text) then castbar.Text:SetText(text) end |
|
50 | Wildbreath-135052 | if(castbar.Icon) then castbar.Icon:SetTexture(texture) end |
|
51 | Wildbreath-135052 | if(castbar.Time) then castbar.Time:SetText() end |
|
52 | Wildbreath-135052 | ||
53 | Wildbreath-135052 | local sf = castbar.SafeZone |
|
54 | Wildbreath-135052 | if(sf) then |
|
55 | Wildbreath-135052 | sf:ClearAllPoints() |
|
56 | Wildbreath-135052 | sf:SetPoint'RIGHT' |
|
57 | Wildbreath-135052 | sf:SetPoint'TOP' |
|
58 | Wildbreath-135052 | sf:SetPoint'BOTTOM' |
|
59 | Wildbreath-135052 | end |
|
60 | Wildbreath-135052 | ||
61 | Wildbreath-135052 | if(self.PostCastStart) then self:PostCastStart(event, unit, name, rank, text, castid, interrupt) end |
|
62 | Wildbreath-135052 | castbar:Show() |
|
63 | Wildbreath-135052 | end |
|
64 | Wildbreath-135052 | ||
65 | Wildbreath-135052 | local UNIT_SPELLCAST_FAILED = function(self, event, unit, spellname, spellrank, castid) |
|
66 | Wildbreath-135052 | if(self.unit ~= unit) then return end |
|
67 | Wildbreath-135052 | ||
68 | Wildbreath-135052 | local castbar = self.Castbar |
|
69 | Wildbreath-135052 | if(castbar.castid ~= castid) then |
|
70 | Wildbreath-135052 | return |
|
71 | Wildbreath-135052 | end |
|
72 | Wildbreath-135052 | ||
73 | Wildbreath-135052 | castbar.casting = nil |
|
74 | Wildbreath-135052 | castbar.interrupt = nil |
|
75 | Wildbreath-135052 | castbar:SetValue(0) |
|
76 | Wildbreath-135052 | castbar:Hide() |
|
77 | Wildbreath-135052 | ||
78 | Wildbreath-135052 | if(self.PostCastFailed) then |
|
79 | Wildbreath-135052 | return self:PostCastFailed(event, unit, spellname, spellrank, castid) |
|
80 | Wildbreath-135052 | end |
|
81 | Wildbreath-135052 | end |
|
82 | Wildbreath-135052 | ||
83 | Wildbreath-135052 | local UNIT_SPELLCAST_INTERRUPTED = function(self, event, unit, spellname, spellrank, castid) |
|
84 | Wildbreath-135052 | if(self.unit ~= unit) then return end |
|
85 | Wildbreath-135052 | ||
86 | Wildbreath-135052 | local castbar = self.Castbar |
|
87 | Wildbreath-135052 | if(castbar.castid ~= castid) then |
|
88 | Wildbreath-135052 | return |
|
89 | Wildbreath-135052 | end |
|
90 | Wildbreath-135052 | castbar.casting = nil |
|
91 | Wildbreath-135052 | castbar.channeling = nil |
|
92 | Wildbreath-135052 | ||
93 | Wildbreath-135052 | castbar:SetValue(0) |
|
94 | Wildbreath-135052 | castbar:Hide() |
|
95 | Wildbreath-135052 | ||
96 | Wildbreath-135052 | if(self.PostCastInterrupted) then |
|
97 | Wildbreath-135052 | return self:PostCastInterrupted(event, unit, spellname, spellrank, castid) |
|
98 | Wildbreath-135052 | end |
|
99 | Wildbreath-135052 | end |
|
100 | Wildbreath-135052 | ||
101 | Wildbreath-135052 | local UNIT_SPELLCAST_DELAYED = function(self, event, unit, spellname, spellrank) |
|
102 | Wildbreath-135052 | if(self.unit ~= unit) then return end |
|
103 | Wildbreath-135052 | ||
104 | Wildbreath-135052 | local name, rank, text, texture, startTime, endTime = UnitCastingInfo(unit) |
|
105 | Wildbreath-135052 | if(not startTime) then return end |
|
106 | Wildbreath-135052 | ||
107 | Wildbreath-135052 | local castbar = self.Castbar |
|
108 | Wildbreath-135052 | local duration = GetTime() - (startTime / 1000) |
|
109 | Wildbreath-135052 | if(duration < 0) then duration = 0 end |
|
110 | Wildbreath-135052 | ||
111 | Wildbreath-135052 | castbar.delay = castbar.delay + castbar.duration - duration |
|
112 | Wildbreath-135052 | castbar.duration = duration |
|
113 | Wildbreath-135052 | ||
114 | Wildbreath-135052 | castbar:SetValue(duration) |
|
115 | Wildbreath-135052 | ||
116 | Wildbreath-135052 | if(self.PostCastDelayed) then |
|
117 | Wildbreath-135052 | return self:PostCastDelayed(event, unit, name, rank, text) |
|
118 | Wildbreath-135052 | end |
|
119 | Wildbreath-135052 | end |
|
120 | Wildbreath-135052 | ||
121 | Wildbreath-135052 | local UNIT_SPELLCAST_STOP = function(self, event, unit, spellname, spellrank, castid) |
|
122 | Wildbreath-135052 | if(self.unit ~= unit) then return end |
|
123 | Wildbreath-135052 | ||
124 | Wildbreath-135052 | local castbar = self.Castbar |
|
125 | Wildbreath-135052 | if(castbar.castid ~= castid) then |
|
126 | Wildbreath-135052 | return |
|
127 | Wildbreath-135052 | end |
|
128 | Wildbreath-135052 | ||
129 | Wildbreath-135052 | castbar.casting = nil |
|
130 | Wildbreath-135052 | castbar.interrupt = nil |
|
131 | Wildbreath-135052 | castbar:SetValue(0) |
|
132 | Wildbreath-135052 | castbar:Hide() |
|
133 | Wildbreath-135052 | ||
134 | Wildbreath-135052 | if(self.PostCastStop) then |
|
135 | Wildbreath-135052 | return self:PostCastStop(event, unit, spellname, spellrank, castid) |
|
136 | Wildbreath-135052 | end |
|
137 | Wildbreath-135052 | end |
|
138 | Wildbreath-135052 | ||
139 | Wildbreath-135052 | local UNIT_SPELLCAST_CHANNEL_START = function(self, event, unit, spellname, spellrank) |
|
140 | Wildbreath-135052 | if(self.unit ~= unit) then return end |
|
141 | Wildbreath-135052 | ||
142 | Wildbreath-135052 | local castbar = self.Castbar |
|
143 | Wildbreath-135052 | local name, rank, text, texture, startTime, endTime, isTrade, interrupt = UnitChannelInfo(unit) |
|
144 | Wildbreath-135052 | if(not name) then |
|
145 | Wildbreath-135052 | return |
|
146 | Wildbreath-135052 | end |
|
147 | Wildbreath-135052 | ||
148 | Wildbreath-135052 | endTime = endTime / 1e3 |
|
149 | Wildbreath-135052 | startTime = startTime / 1e3 |
|
150 | Wildbreath-135052 | local max = (endTime - startTime) |
|
151 | Wildbreath-135052 | local duration = endTime - GetTime() |
|
152 | Wildbreath-135052 | ||
153 | Wildbreath-135052 | castbar.duration = duration |
|
154 | Wildbreath-135052 | castbar.max = max |
|
155 | Wildbreath-135052 | castbar.delay = 0 |
|
156 | Wildbreath-135052 | castbar.channeling = true |
|
157 | Wildbreath-135052 | castbar.interrupt = interrupt |
|
158 | Wildbreath-135052 | ||
159 | Wildbreath-135052 | castbar:SetMinMaxValues(0, max) |
|
160 | Wildbreath-135052 | castbar:SetValue(duration) |
|
161 | Wildbreath-135052 | ||
162 | Wildbreath-135052 | if(castbar.Text) then castbar.Text:SetText(name) end |
|
163 | Wildbreath-135052 | if(castbar.Icon) then castbar.Icon:SetTexture(texture) end |
|
164 | Wildbreath-135052 | if(castbar.Time) then castbar.Time:SetText() end |
|
165 | Wildbreath-135052 | ||
166 | Wildbreath-135052 | local sf = castbar.SafeZone |
|
167 | Wildbreath-135052 | if(sf) then |
|
168 | Wildbreath-135052 | sf:ClearAllPoints() |
|
169 | Wildbreath-135052 | sf:SetPoint'LEFT' |
|
170 | Wildbreath-135052 | sf:SetPoint'TOP' |
|
171 | Wildbreath-135052 | sf:SetPoint'BOTTOM' |
|
172 | Wildbreath-135052 | end |
|
173 | Wildbreath-135052 | ||
174 | Wildbreath-135052 | if(self.PostChannelStart) then self:PostChannelStart(event, unit, name, rank, text, interrupt) end |
|
175 | Wildbreath-135052 | castbar:Show() |
|
176 | Wildbreath-135052 | end |
|
177 | Wildbreath-135052 | ||
178 | Wildbreath-135052 | local UNIT_SPELLCAST_CHANNEL_UPDATE = function(self, event, unit, spellname, spellrank) |
|
179 | Wildbreath-135052 | if(self.unit ~= unit) then return end |
|
180 | Wildbreath-135052 | ||
181 | Wildbreath-135052 | local name, rank, text, texture, startTime, endTime, oldStart = UnitChannelInfo(unit) |
|
182 | Wildbreath-135052 | if(not name) then |
|
183 | Wildbreath-135052 | return |
|
184 | Wildbreath-135052 | end |
|
185 | Wildbreath-135052 | ||
186 | Wildbreath-135052 | local castbar = self.Castbar |
|
187 | Wildbreath-135052 | local duration = (endTime / 1000) - GetTime() |
|
188 | Wildbreath-135052 | ||
189 | Wildbreath-135052 | castbar.delay = castbar.delay + castbar.duration - duration |
|
190 | Wildbreath-135052 | castbar.duration = duration |
|
191 | Wildbreath-135052 | castbar.max = (endTime - startTime) / 1000 |
|
192 | Wildbreath-135052 | ||
193 | Wildbreath-135052 | castbar:SetMinMaxValues(0, castbar.max) |
|
194 | Wildbreath-135052 | castbar:SetValue(duration) |
|
195 | Wildbreath-135052 | ||
196 | Wildbreath-135052 | if(self.PostChannelUpdate) then |
|
197 | Wildbreath-135052 | return self:PostChannelUpdate(event, unit, name, rank, text) |
|
198 | Wildbreath-135052 | end |
|
199 | Wildbreath-135052 | end |
|
200 | Wildbreath-135052 | ||
201 | Wildbreath-135052 | local UNIT_SPELLCAST_CHANNEL_STOP = function(self, event, unit, spellname, spellrank) |
|
202 | Wildbreath-135052 | if(self.unit ~= unit) then return end |
|
203 | Wildbreath-135052 | ||
204 | Wildbreath-135052 | local castbar = self.Castbar |
|
205 | Wildbreath-135052 | if(castbar:IsShown()) then |
|
206 | Wildbreath-135052 | castbar.channeling = nil |
|
207 | Wildbreath-135052 | castbar.interrupt = nil |
|
208 | Wildbreath-135052 | ||
209 | Wildbreath-135052 | castbar:SetValue(castbar.max) |
|
210 | Wildbreath-135052 | castbar:Hide() |
|
211 | Wildbreath-135052 | ||
212 | Wildbreath-135052 | if(self.PostChannelStop) then |
|
213 | Wildbreath-135052 | return self:PostChannelStop(event, unit, spellname, spellrank) |
|
214 | Wildbreath-135052 | end |
|
215 | Wildbreath-135052 | end |
|
216 | Wildbreath-135052 | end |
|
217 | Wildbreath-135052 | ||
218 | Wildbreath-135052 | local onUpdate = function(self, elapsed) |
|
219 | Wildbreath-135052 | if self.casting then |
|
220 | Wildbreath-135052 | local duration = self.duration + elapsed |
|
221 | Wildbreath-135052 | if (duration >= self.max) then |
|
222 | Wildbreath-135052 | self.casting = nil |
|
223 | Wildbreath-135052 | self:Hide() |
|
224 | Wildbreath-135052 | ||
225 | Wildbreath-135052 | -- We temporary get our parent to do this. |
|
226 | Wildbreath-135052 | local parent = self:GetParent() |
|
227 | Wildbreath-135052 | if(parent.PostCastStop) then parent:PostCastStop('OnUpdate', parent.unit) end |
|
228 | Wildbreath-135052 | ||
229 | Wildbreath-135052 | return |
|
230 | Wildbreath-135052 | end |
|
231 | Wildbreath-135052 | ||
232 | Wildbreath-135052 | if self.SafeZone then |
|
233 | Wildbreath-135052 | local width = self:GetWidth() |
|
234 | Wildbreath-135052 | local _, _, ms = GetNetStats() |
|
235 | Wildbreath-135052 | -- MADNESS! |
|
236 | Wildbreath-135052 | local safeZonePercent = (width / self.max) * (ms / 1e5) |
|
237 | Wildbreath-135052 | if(safeZonePercent > 1) then safeZonePercent = 1 end |
|
238 | Wildbreath-135052 | self.SafeZone:SetWidth(width * safeZonePercent) |
|
239 | Wildbreath-135052 | end |
|
240 | Wildbreath-135052 | ||
241 | Wildbreath-135052 | if self.Time then |
|
242 | Wildbreath-135052 | if self.delay ~= 0 then |
|
243 | Wildbreath-135052 | if(self.CustomDelayText) then |
|
244 | Wildbreath-135052 | self:CustomDelayText(duration) |
|
245 | Wildbreath-135052 | else |
|
246 | Wildbreath-135052 | self.Time:SetFormattedText("%.1f|cffff0000-%.1f|r", duration, self.delay) |
|
247 | Wildbreath-135052 | end |
|
248 | Wildbreath-135052 | else |
|
249 | Wildbreath-135052 | if(self.CustomTimeText) then |
|
250 | Wildbreath-135052 | self:CustomTimeText(duration) |
|
251 | Wildbreath-135052 | else |
|
252 | Wildbreath-135052 | self.Time:SetFormattedText("%.1f", duration) |
|
253 | Wildbreath-135052 | end |
|
254 | Wildbreath-135052 | end |
|
255 | Wildbreath-135052 | end |
|
256 | Wildbreath-135052 | ||
257 | Wildbreath-135052 | self.duration = duration |
|
258 | Wildbreath-135052 | self:SetValue(duration) |
|
259 | Wildbreath-135052 | ||
260 | Wildbreath-135052 | if self.Spark then |
|
261 | Wildbreath-135052 | self.Spark:SetPoint("CENTER", self, "LEFT", (duration / self.max) * self:GetWidth(), 0) |
|
262 | Wildbreath-135052 | end |
|
263 | Wildbreath-135052 | elseif self.channeling then |
|
264 | Wildbreath-135052 | local duration = self.duration - elapsed |
|
265 | Wildbreath-135052 | ||
266 | Wildbreath-135052 | if(duration <= 0) then |
|
267 | Wildbreath-135052 | self.channeling = nil |
|
268 | Wildbreath-135052 | self:Hide() |
|
269 | Wildbreath-135052 | ||
270 | Wildbreath-135052 | -- We temporary get our parent to do this. |
|
271 | Wildbreath-135052 | local parent = self:GetParent() |
|
272 | Wildbreath-135052 | if(parent.PostChannelStop) then parent:PostChannelStop('OnUpdate', parent.unit) end |
|
273 | Wildbreath-135052 | ||
274 | Wildbreath-135052 | return |
|
275 | Wildbreath-135052 | end |
|
276 | Wildbreath-135052 | ||
277 | Wildbreath-135052 | if(self.SafeZone) then |
|
278 | Wildbreath-135052 | local width = self:GetWidth() |
|
279 | Wildbreath-135052 | local _, _, ms = GetNetStats() |
|
280 | Wildbreath-135052 | -- MADNESS! |
|
281 | Wildbreath-135052 | local safeZonePercent = (width / self.max) * (ms / 1e5) |
|
282 | Wildbreath-135052 | if(safeZonePercent > 1) then safeZonePercent = 1 end |
|
283 | Wildbreath-135052 | self.SafeZone:SetWidth(width * safeZonePercent) |
|
284 | Wildbreath-135052 | end |
|
285 | Wildbreath-135052 | ||
286 | Wildbreath-135052 | ||
287 | Wildbreath-135052 | if self.Time then |
|
288 | Wildbreath-135052 | if self.delay ~= 0 then |
|
289 | Wildbreath-135052 | if(self.CustomDelayText) then |
|
290 | Wildbreath-135052 | self:CustomDelayText(duration) |
|
291 | Wildbreath-135052 | else |
|
292 | Wildbreath-135052 | self.Time:SetFormattedText("%.1f|cffff0000-%.1f|r", duration, self.delay) |
|
293 | Wildbreath-135052 | end |
|
294 | Wildbreath-135052 | else |
|
295 | Wildbreath-135052 | if(self.CustomTimeText) then |
|
296 | Wildbreath-135052 | self:CustomTimeText(duration) |
|
297 | Wildbreath-135052 | else |
|
298 | Wildbreath-135052 | self.Time:SetFormattedText("%.1f", duration) |
|
299 | Wildbreath-135052 | end |
|
300 | Wildbreath-135052 | end |
|
301 | Wildbreath-135052 | end |
|
302 | Wildbreath-135052 | ||
303 | Wildbreath-135052 | self.duration = duration |
|
304 | Wildbreath-135052 | self:SetValue(duration) |
|
305 | Wildbreath-135052 | if self.Spark then |
|
306 | Wildbreath-135052 | self.Spark:SetPoint("CENTER", self, "LEFT", (duration / self.max) * self:GetWidth(), 0) |
|
307 | Wildbreath-135052 | end |
|
308 | Wildbreath-135052 | else |
|
309 | Wildbreath-135052 | self.unitName = nil |
|
310 | Wildbreath-135052 | self.channeling = nil |
|
311 | Wildbreath-135052 | self:SetValue(1) |
|
312 | Wildbreath-135052 | self:Hide() |
|
313 | Wildbreath-135052 | end |
|
314 | Wildbreath-135052 | end |
|
315 | Wildbreath-135052 | ||
316 | Wildbreath-135052 | local Enable = function(object, unit) |
|
317 | Wildbreath-135052 | local castbar = object.Castbar |
|
318 | Wildbreath-135052 | ||
319 | Wildbreath-135052 | if(castbar) then |
|
320 | Wildbreath-135052 | if(not (unit and unit:match'%wtarget$')) then |
|
321 | Wildbreath-135052 | object:RegisterEvent("UNIT_SPELLCAST_START", UNIT_SPELLCAST_START) |
|
322 | Wildbreath-135052 | object:RegisterEvent("UNIT_SPELLCAST_FAILED", UNIT_SPELLCAST_FAILED) |
|
323 | Wildbreath-135052 | object:RegisterEvent("UNIT_SPELLCAST_STOP", UNIT_SPELLCAST_STOP) |
|
324 | Wildbreath-135052 | object:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED) |
|
325 | Wildbreath-135052 | object:RegisterEvent("UNIT_SPELLCAST_DELAYED", UNIT_SPELLCAST_DELAYED) |
|
326 | Wildbreath-135052 | object:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START", UNIT_SPELLCAST_CHANNEL_START) |
|
327 | Wildbreath-135052 | object:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", UNIT_SPELLCAST_CHANNEL_UPDATE) |
|
328 | Wildbreath-135052 | object:RegisterEvent("UNIT_SPELLCAST_CHANNEL_INTERRUPTED", 'UNIT_SPELLCAST_INTERRUPTED') |
|
329 | Wildbreath-135052 | object:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", UNIT_SPELLCAST_CHANNEL_STOP) |
|
330 | Wildbreath-135052 | end |
|
331 | Wildbreath-135052 | ||
332 | Wildbreath-135052 | castbar:SetScript("OnUpdate", object.OnCastbarUpdate or onUpdate) |
|
333 | Wildbreath-135052 | ||
334 | Wildbreath-135052 | if object.unit == "player" then |
|
335 | Wildbreath-135052 | CastingBarFrame:UnregisterAllEvents() |
|
336 | Wildbreath-135052 | CastingBarFrame.Show = noop |
|
337 | Wildbreath-135052 | CastingBarFrame:Hide() |
|
338 | Wildbreath-135052 | elseif(object.unit == 'pet') then |
|
339 | Wildbreath-135052 | PetCastingBarFrame:UnregisterAllEvents() |
|
340 | Wildbreath-135052 | PetCastingBarFrame.Show = noop |
|
341 | Wildbreath-135052 | PetCastingBarFrame:Hide() |
|
342 | Wildbreath-135052 | end |
|
343 | Wildbreath-135052 | ||
344 | Wildbreath-135052 | if(not castbar:GetStatusBarTexture()) then |
|
345 | Wildbreath-135052 | castbar:SetStatusBarTexture[[Interface\TargetingFrame\UI-StatusBar]] |
|
346 | Wildbreath-135052 | end |
|
347 | Wildbreath-135052 | ||
348 | Wildbreath-135052 | local spark = castbar.Spark |
|
349 | Wildbreath-135052 | if(spark and spark:IsObjectType'Texture' and not spark:GetTexture()) then |
|
350 | Wildbreath-135052 | spark:SetTexture[[Interface\CastingBar\UI-CastingBar-Spark]] |
|
351 | Wildbreath-135052 | end |
|
352 | Wildbreath-135052 | ||
353 | Wildbreath-135052 | local sz = castbar.SafeZone |
|
354 | Wildbreath-135052 | if(sz and sz:IsObjectType'Texture' and not sz:GetTexture()) then |
|
355 | Wildbreath-135052 | sz:SetTexture(1, 0, 0) |
|
356 | Wildbreath-135052 | end |
|
357 | Wildbreath-135052 | ||
358 | Wildbreath-135052 | castbar:Hide() |
|
359 | Wildbreath-135052 | ||
360 | Wildbreath-135052 | return true |
|
361 | Wildbreath-135052 | end |
|
362 | Wildbreath-135052 | end |
|
363 | Wildbreath-135052 | ||
364 | Wildbreath-135052 | local Disable = function(object, unit) |
|
365 | Wildbreath-135052 | local castbar = object.Castbar |
|
366 | Wildbreath-135052 | ||
367 | Wildbreath-135052 | if(castbar) then |
|
368 | Wildbreath-135052 | object:UnregisterEvent("UNIT_SPELLCAST_START", UNIT_SPELLCAST_START) |
|
369 | Wildbreath-135052 | object:UnregisterEvent("UNIT_SPELLCAST_FAILED", UNIT_SPELLCAST_FAILED) |
|
370 | Wildbreath-135052 | object:UnregisterEvent("UNIT_SPELLCAST_STOP", UNIT_SPELLCAST_STOP) |
|
371 | Wildbreath-135052 | object:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED) |
|
372 | Wildbreath-135052 | object:UnregisterEvent("UNIT_SPELLCAST_DELAYED", UNIT_SPELLCAST_DELAYED) |
|
373 | Wildbreath-135052 | object:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_START", UNIT_SPELLCAST_CHANNEL_START) |
|
374 | Wildbreath-135052 | object:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", UNIT_SPELLCAST_CHANNEL_UPDATE) |
|
375 | Wildbreath-135052 | object:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_INTERRUPTED", UNIT_SPELLCAST_CHANNEL_INTERRUPTED) |
|
376 | Wildbreath-135052 | object:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", UNIT_SPELLCAST_CHANNEL_STOP) |
|
377 | Wildbreath-135052 | ||
378 | Wildbreath-135052 | castbar:SetScript("OnUpdate", nil) |
|
379 | Wildbreath-135052 | end |
|
380 | Wildbreath-135052 | end |
|
381 | Wildbreath-135052 | ||
382 | Wildbreath-135052 | oUF:AddElement('Castbar', function(...) |
|
383 | Wildbreath-135052 | UNIT_SPELLCAST_START(...) |
|
384 | Wildbreath-135052 | return UNIT_SPELLCAST_CHANNEL_START(...) |
|
385 | Wildbreath-135052 | end, Enable, Disable) |