This commit is contained in:
Bunny67
2018-06-03 10:40:00 +03:00
parent a38ad77063
commit 5a7362015b
+15 -21
View File
@@ -142,13 +142,14 @@ end
local function SPELLCAST_DELAYED(self, event, delay) local function SPELLCAST_DELAYED(self, event, delay)
local element = self.Castbar local element = self.Castbar
local name, _, _, _, startTime = UnitCastingInfo(unit) if(not delay or not element:IsShown()) then return end
if(not startTime or not element:IsShown()) then return end
local duration = GetTime() - (self.startTime / 1000) delay = delay / 1000
local duration = GetTime() - (element.startTime / 1000)
if(duration < 0) then duration = 0 end if(duration < 0) then duration = 0 end
element.delay = element.delay + element.duration - duration element.startTime = element.startTime + delay
element.delay = delay
element.duration = duration element.duration = duration
element:SetValue(duration) element:SetValue(duration)
@@ -165,11 +166,10 @@ end
local function SPELLCAST_STOP(self, event) local function SPELLCAST_STOP(self, event)
local element = self.Castbar local element = self.Castbar
if(spellname and (element.castName ~= spellname)) then
return
end
element.casting = nil if(element:IsShown()) then
element.casting = nil
end
--[[ Callback: Castbar:PostCastStop(unit, name) --[[ Callback: Castbar:PostCastStop(unit, name)
Called after the element has been updated when a spell cast has finished. Called after the element has been updated when a spell cast has finished.
@@ -218,23 +218,17 @@ local function SPELLCAST_CHANNEL_START(self, event, endTime, name)
element:Show() element:Show()
end end
local function SPELLCAST_CHANNEL_UPDATE(self, event, unit) local function SPELLCAST_CHANNEL_UPDATE(self, event, delay)
if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar local element = self.Castbar
local name, _, _, _, startTime, endTime = UnitChannelInfo(unit) if(not element:IsShown()) then
if(not name or not element:IsShown()) then
return return
end end
local duration = (endTime / 1000) - GetTime() delay = delay / 1000
element.delay = element.delay + element.duration - duration local duration = element.startTime + (element.max - GetTime()) - delay
element.delay = element.delay - duration
element.duration = duration element.duration = duration
element.max = (endTime - startTime) / 1000 element.startTime = element.startTime - duration
element.startTime = startTime / 1000
element.endTime = endTime / 1000
element:SetMinMaxValues(0, element.max)
element:SetValue(duration) element:SetValue(duration)
--[[ Callback: Castbar:PostChannelUpdate(unit, name) --[[ Callback: Castbar:PostChannelUpdate(unit, name)
@@ -298,7 +292,7 @@ local function onUpdate(self, elapsed)
self.Spark:SetPoint("CENTER", self, "LEFT", (duration / ((self.startTime + self.max) - self.startTime)) * self:GetWidth(), 0) self.Spark:SetPoint("CENTER", self, "LEFT", (duration / ((self.startTime + self.max) - self.startTime)) * self:GetWidth(), 0)
end end
elseif(self.channeling) then elseif(self.channeling) then
local duration = (self.max + self.startTime) - GetTime() local duration = self.startTime + (self.max - GetTime())
if(duration <= 0) then if(duration <= 0) then
self.channeling = nil self.channeling = nil