Skip to content

Commit

Permalink
castbar: Account for orientation and reverse fill for Spark repositio…
Browse files Browse the repository at this point in the history
…ning (#408)

Fixes #407
  • Loading branch information
p3lim committed Dec 20, 2017
1 parent 4e6684a commit 5a6cf97
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions elements/castbar.lua
Expand Up @@ -463,7 +463,15 @@ local function onUpdate(self, elapsed)
self:SetValue(duration)
if(self.Spark) then
self.Spark:SetPoint('CENTER', self, 'LEFT', (duration / self.max) * self:GetWidth(), 0)
local horiz = self.horizontal
local size = self[horiz and 'GetWidth' or 'GetHeight'](self)
local offset = (duration / self.max) * size
if(self:GetReverseFill()) then
offset = size - offset
end
self.Spark:SetPoint('CENTER', self, horiz and 'LEFT' or 'BOTTOM', horiz and offset or 0, horiz and 0 or offset)
end
elseif(self.channeling) then
local duration = self.duration - elapsed
Expand Down Expand Up @@ -495,7 +503,15 @@ local function onUpdate(self, elapsed)
self.duration = duration
self:SetValue(duration)
if(self.Spark) then
self.Spark:SetPoint('CENTER', self, 'LEFT', (duration / self.max) * self:GetWidth(), 0)
local horiz = self.horizontal
local size = self[horiz and 'GetWidth' or 'GetHeight'](self)
local offset = (duration / self.max) * size
if(self:GetReverseFill()) then
offset = size - offset
end
self.Spark:SetPoint('CENTER', self, horiz and 'LEFT' or 'BOTTOM', horiz and offset or 0, horiz and 0 or offset)
end
elseif(self.holdTime > 0) then
self.holdTime = self.holdTime - elapsed
Expand Down Expand Up @@ -536,6 +552,7 @@ local function Enable(self, unit)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', UNIT_SPELLCAST_CHANNEL_STOP)
end
element.horizontal = element:GetOrientation() == 'HORIZONTAL'
element.holdTime = 0
element:SetScript('OnUpdate', element.OnUpdate or onUpdate)
Expand Down

0 comments on commit 5a6cf97

Please sign in to comment.