mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
- minor cleanup of the animation/scale-setting code to avoid duplicating chunks of code
This commit is contained in:
@ -176,12 +176,7 @@ function IceBarElement.prototype:GetOptions()
|
||||
end,
|
||||
set = function(value)
|
||||
self.moduleSettings.reverse = value
|
||||
self.barFrame:ClearAllPoints()
|
||||
if (self.moduleSettings.reverse) then
|
||||
self.barFrame:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
|
||||
else
|
||||
self.barFrame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
|
||||
end
|
||||
self:SetBarFramePoints()
|
||||
self:Redraw()
|
||||
end,
|
||||
disabled = function()
|
||||
@ -548,6 +543,14 @@ end
|
||||
return opts
|
||||
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
|
||||
@ -648,12 +651,7 @@ function IceBarElement.prototype:CreateBar()
|
||||
end
|
||||
|
||||
self.barFrame:SetFrameStrata("LOW")
|
||||
self.barFrame:ClearAllPoints()
|
||||
if (self.moduleSettings.reverse) then
|
||||
self.barFrame:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
|
||||
else
|
||||
self.barFrame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
|
||||
end
|
||||
self:SetBarFramePoints()
|
||||
self.barFrame:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
|
||||
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:SetBlendMode(self.settings.barBlendMode)
|
||||
self.barFrame.bar:SetAllPoints(self.barFrame)
|
||||
if (self.moduleSettings.reverse) then
|
||||
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:SetScale(self.CurrScale, true)
|
||||
|
||||
self:UpdateBar(1, "undef")
|
||||
end
|
||||
@ -774,14 +761,13 @@ function IceBarElement.prototype:Flip(side)
|
||||
end
|
||||
|
||||
|
||||
function IceBarElement.prototype:SetScale(texture, scale)
|
||||
function IceBarElement.prototype:SetScale(scale, force)
|
||||
local oldScale = self.CurrScale
|
||||
local min_y, max_y;
|
||||
|
||||
self.CurrScale = IceHUD:Clamp(self:LerpScale(scale), 0, 1)
|
||||
|
||||
if oldScale ~= self.CurrScale then
|
||||
if (texture == self.barFrame.bar) then
|
||||
if force or oldScale ~= self.CurrScale then
|
||||
if (self.moduleSettings.reverse) then
|
||||
min_y = 0;
|
||||
max_y = self.CurrScale;
|
||||
@ -789,11 +775,10 @@ function IceBarElement.prototype:SetScale(texture, scale)
|
||||
min_y = 1-self.CurrScale;
|
||||
max_y = 1;
|
||||
end
|
||||
end
|
||||
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
|
||||
texture:SetTexCoord(0, 1, min_y, max_y)
|
||||
self.barFrame.bar:SetTexCoord(0, 1, min_y, max_y)
|
||||
end
|
||||
|
||||
self.barFrame:SetHeight(self.settings.barHeight * self.CurrScale)
|
||||
@ -865,7 +850,7 @@ function IceBarElement.prototype:UpdateBar(scale, color, alpha)
|
||||
self.LastScale = self.CurrScale
|
||||
end
|
||||
|
||||
self:SetScale(self.barFrame.bar, self.DesiredScale)
|
||||
self:SetScale(self.DesiredScale)
|
||||
|
||||
if not self.moduleSettings.barVisible['bg'] then
|
||||
self.frame.bg:Hide()
|
||||
@ -984,5 +969,5 @@ function IceBarElement.prototype:Update()
|
||||
end
|
||||
|
||||
function IceBarElement.prototype:MyOnUpdate()
|
||||
self:SetScale(self.barFrame.bar, self.DesiredScale)
|
||||
self:SetScale(self.DesiredScale)
|
||||
end
|
||||
|
@ -201,7 +201,7 @@ function IceCastBar.prototype:FlashBar(color, alpha, text, textColor)
|
||||
self.frame.bg:SetVertexColor(r, g, b, 0.3)
|
||||
self.barFrame.bar:SetVertexColor(self:GetColor(color, 0.8))
|
||||
|
||||
self:SetScale(self.barFrame.bar, 1)
|
||||
self:SetScale(1)
|
||||
self:SetBottomText1(text, textColor or "Text")
|
||||
end
|
||||
|
||||
|
@ -178,7 +178,7 @@ function IceUnitBar.prototype:CreateFlashFrame()
|
||||
self.flashFrame.flash:SetBlendMode("ADD")
|
||||
self.flashFrame.flash:SetAllPoints(self.flashFrame)
|
||||
|
||||
self:SetScale(self.flashFrame.flash, 1)
|
||||
--self:SetScale(self.flashFrame.flash, 1)
|
||||
self.flashFrame:SetAlpha(0)
|
||||
|
||||
self.flashFrame:ClearAllPoints()
|
||||
|
Reference in New Issue
Block a user