- minor cleanup of the animation/scale-setting code to avoid duplicating chunks of code

This commit is contained in:
Parnic
2010-03-31 16:31:38 +00:00
parent 87cf1d74c6
commit ca4107446e
3 changed files with 25 additions and 40 deletions

View File

@ -176,12 +176,7 @@ function IceBarElement.prototype:GetOptions()
end, end,
set = function(value) set = function(value)
self.moduleSettings.reverse = value self.moduleSettings.reverse = value
self.barFrame:ClearAllPoints() self:SetBarFramePoints()
if (self.moduleSettings.reverse) then
self.barFrame:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
else
self.barFrame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
end
self:Redraw() self:Redraw()
end, end,
disabled = function() disabled = function()
@ -548,6 +543,14 @@ end
return opts return opts
end end
function IceBarElement.prototype:SetBarFramePoints()
self.barFrame:ClearAllPoints()
if (self.moduleSettings.reverse) then
self.barFrame:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
else
self.barFrame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
end
end
-- OVERRIDE -- OVERRIDE
@ -648,12 +651,7 @@ function IceBarElement.prototype:CreateBar()
end end
self.barFrame:SetFrameStrata("LOW") self.barFrame:SetFrameStrata("LOW")
self.barFrame:ClearAllPoints() self:SetBarFramePoints()
if (self.moduleSettings.reverse) then
self.barFrame:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
else
self.barFrame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
end
self.barFrame:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0)) self.barFrame:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
self.barFrame:SetHeight(self.settings.barHeight) self.barFrame:SetHeight(self.settings.barHeight)
@ -664,18 +662,7 @@ function IceBarElement.prototype:CreateBar()
self.barFrame.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture()) self.barFrame.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
self.barFrame.bar:SetBlendMode(self.settings.barBlendMode) self.barFrame.bar:SetBlendMode(self.settings.barBlendMode)
self.barFrame.bar:SetAllPoints(self.barFrame) self.barFrame.bar:SetAllPoints(self.barFrame)
if (self.moduleSettings.reverse) then self:SetScale(self.CurrScale, true)
min_y = 0;
max_y = self.CurrScale;
else
min_y = 1-self.CurrScale;
max_y = 1;
end
if (self.moduleSettings.side == IceCore.Side.Left) then
self.barFrame.bar:SetTexCoord(1, 0, min_y, max_y)
else
self.barFrame.bar:SetTexCoord(0, 1, min_y, max_y)
end
self:UpdateBar(1, "undef") self:UpdateBar(1, "undef")
end end
@ -774,26 +761,24 @@ function IceBarElement.prototype:Flip(side)
end end
function IceBarElement.prototype:SetScale(texture, scale) function IceBarElement.prototype:SetScale(scale, force)
local oldScale = self.CurrScale local oldScale = self.CurrScale
local min_y, max_y; local min_y, max_y;
self.CurrScale = IceHUD:Clamp(self:LerpScale(scale), 0, 1) self.CurrScale = IceHUD:Clamp(self:LerpScale(scale), 0, 1)
if oldScale ~= self.CurrScale then if force or oldScale ~= self.CurrScale then
if (texture == self.barFrame.bar) then if (self.moduleSettings.reverse) then
if (self.moduleSettings.reverse) then min_y = 0;
min_y = 0; max_y = self.CurrScale;
max_y = self.CurrScale; else
else min_y = 1-self.CurrScale;
min_y = 1-self.CurrScale; max_y = 1;
max_y = 1;
end
end end
if (self.moduleSettings.side == IceCore.Side.Left) then if (self.moduleSettings.side == IceCore.Side.Left) then
texture:SetTexCoord(1, 0, min_y, max_y) self.barFrame.bar:SetTexCoord(1, 0, min_y, max_y)
else else
texture:SetTexCoord(0, 1, min_y, max_y) self.barFrame.bar:SetTexCoord(0, 1, min_y, max_y)
end end
self.barFrame:SetHeight(self.settings.barHeight * self.CurrScale) self.barFrame:SetHeight(self.settings.barHeight * self.CurrScale)
@ -865,7 +850,7 @@ function IceBarElement.prototype:UpdateBar(scale, color, alpha)
self.LastScale = self.CurrScale self.LastScale = self.CurrScale
end end
self:SetScale(self.barFrame.bar, self.DesiredScale) self:SetScale(self.DesiredScale)
if not self.moduleSettings.barVisible['bg'] then if not self.moduleSettings.barVisible['bg'] then
self.frame.bg:Hide() self.frame.bg:Hide()
@ -984,5 +969,5 @@ function IceBarElement.prototype:Update()
end end
function IceBarElement.prototype:MyOnUpdate() function IceBarElement.prototype:MyOnUpdate()
self:SetScale(self.barFrame.bar, self.DesiredScale) self:SetScale(self.DesiredScale)
end end

View File

@ -201,7 +201,7 @@ function IceCastBar.prototype:FlashBar(color, alpha, text, textColor)
self.frame.bg:SetVertexColor(r, g, b, 0.3) self.frame.bg:SetVertexColor(r, g, b, 0.3)
self.barFrame.bar:SetVertexColor(self:GetColor(color, 0.8)) self.barFrame.bar:SetVertexColor(self:GetColor(color, 0.8))
self:SetScale(self.barFrame.bar, 1) self:SetScale(1)
self:SetBottomText1(text, textColor or "Text") self:SetBottomText1(text, textColor or "Text")
end end

View File

@ -178,7 +178,7 @@ function IceUnitBar.prototype:CreateFlashFrame()
self.flashFrame.flash:SetBlendMode("ADD") self.flashFrame.flash:SetBlendMode("ADD")
self.flashFrame.flash:SetAllPoints(self.flashFrame) self.flashFrame.flash:SetAllPoints(self.flashFrame)
self:SetScale(self.flashFrame.flash, 1) --self:SetScale(self.flashFrame.flash, 1)
self.flashFrame:SetAlpha(0) self.flashFrame:SetAlpha(0)
self.flashFrame:ClearAllPoints() self.flashFrame:ClearAllPoints()