mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 14:50:13 -05:00
- added an option to animate the lost/gained amounts on each individual bar with a tweak-able speed
This commit is contained in:
@ -13,6 +13,11 @@ IceBarElement.prototype.backroundAlpha = nil
|
|||||||
IceBarElement.prototype.combat = nil
|
IceBarElement.prototype.combat = nil
|
||||||
IceBarElement.prototype.target = nil
|
IceBarElement.prototype.target = nil
|
||||||
|
|
||||||
|
IceBarElement.prototype.CurrLerpTime = 0
|
||||||
|
IceBarElement.prototype.LastScale = 1
|
||||||
|
IceBarElement.prototype.DesiredScale = 1
|
||||||
|
IceBarElement.prototype.CurrScale = 1
|
||||||
|
|
||||||
|
|
||||||
-- Constructor --
|
-- Constructor --
|
||||||
function IceBarElement.prototype:init(name)
|
function IceBarElement.prototype:init(name)
|
||||||
@ -52,6 +57,8 @@ function IceBarElement.prototype:GetDefaultSettings()
|
|||||||
settings["lowerText"] = ''
|
settings["lowerText"] = ''
|
||||||
settings["textVerticalOffset"] = -1
|
settings["textVerticalOffset"] = -1
|
||||||
settings["textHorizontalOffset"] = 0
|
settings["textHorizontalOffset"] = 0
|
||||||
|
settings["shouldAnimate"] = false
|
||||||
|
settings["desiredLerpTime"] = 0.2
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
end
|
end
|
||||||
@ -131,6 +138,41 @@ function IceBarElement.prototype:GetOptions()
|
|||||||
order = 32
|
order = 32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opts["shouldAnimate"] =
|
||||||
|
{
|
||||||
|
type = 'toggle',
|
||||||
|
name = '|c' .. self.configColor .. 'Animate amount changes|r',
|
||||||
|
desc = 'Whether or not to animate the bar falloffs/gains',
|
||||||
|
get = function()
|
||||||
|
return self.moduleSettings.shouldAnimate
|
||||||
|
end,
|
||||||
|
set = function(value)
|
||||||
|
self.moduleSettings.shouldAnimate = value
|
||||||
|
self:Redraw()
|
||||||
|
end,
|
||||||
|
disabled = function()
|
||||||
|
return not self.moduleSettings.enabled
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
opts["desiredLerpTime"] =
|
||||||
|
{
|
||||||
|
type = 'range',
|
||||||
|
name = '|c' .. self.configColor .. 'Animation Duration|r',
|
||||||
|
min = 0,
|
||||||
|
max = 2,
|
||||||
|
step = 0.05,
|
||||||
|
get = function()
|
||||||
|
return self.moduleSettings.desiredLerpTime
|
||||||
|
end,
|
||||||
|
set = function(value)
|
||||||
|
self.moduleSettings.desiredLerpTime = value
|
||||||
|
end,
|
||||||
|
disabled = function()
|
||||||
|
return not self.moduleSettings.enabled or not self.moduleSettings.shouldAnimate
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
opts["textSettings"] =
|
opts["textSettings"] =
|
||||||
{
|
{
|
||||||
type = 'group',
|
type = 'group',
|
||||||
@ -318,6 +360,7 @@ function IceBarElement.prototype:CreateFrame()
|
|||||||
self:CreateTexts()
|
self:CreateTexts()
|
||||||
|
|
||||||
self.frame:SetScale(self.moduleSettings.scale)
|
self.frame:SetScale(self.moduleSettings.scale)
|
||||||
|
self.frame:SetScript("OnUpdate", function() self:MyOnUpdate() end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -472,10 +515,33 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function IceBarElement.prototype:SetScale(texture, scale)
|
function IceBarElement.prototype:SetScale(texture, scale)
|
||||||
|
self.CurrScale = self:LerpScale(scale)
|
||||||
|
|
||||||
if (self.moduleSettings.side == IceCore.Side.Left) then
|
if (self.moduleSettings.side == IceCore.Side.Left) then
|
||||||
texture:SetTexCoord(1, 0, 1-scale, 1)
|
texture:SetTexCoord(1, 0, 1-self.CurrScale, 1)
|
||||||
else
|
else
|
||||||
texture:SetTexCoord(0, 1, 1-scale, 1)
|
texture:SetTexCoord(0, 1, 1-self.CurrScale, 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function IceBarElement.prototype:LerpScale(scale)
|
||||||
|
if not self.moduleSettings.shouldAnimate then
|
||||||
|
return scale
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.CurrLerpTime < self.moduleSettings.desiredLerpTime then
|
||||||
|
self.CurrLerpTime = self.CurrLerpTime + (1 / GetFramerate());
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.CurrLerpTime > self.moduleSettings.desiredLerpTime then
|
||||||
|
self.CurrLerpTime = self.moduleSettings.desiredLerpTime
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.CurrLerpTime < self.moduleSettings.desiredLerpTime then
|
||||||
|
return self.LastScale + ((self.DesiredScale - self.LastScale) * (self.CurrLerpTime / self.moduleSettings.desiredLerpTime))
|
||||||
|
else
|
||||||
|
return scale
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -483,12 +549,12 @@ end
|
|||||||
function IceBarElement.prototype:UpdateBar(scale, color, alpha)
|
function IceBarElement.prototype:UpdateBar(scale, color, alpha)
|
||||||
alpha = alpha or 1
|
alpha = alpha or 1
|
||||||
self.frame:SetAlpha(alpha)
|
self.frame:SetAlpha(alpha)
|
||||||
|
|
||||||
local r, g, b = self.settings.backgroundColor.r, self.settings.backgroundColor.g, self.settings.backgroundColor.b
|
local r, g, b = self.settings.backgroundColor.r, self.settings.backgroundColor.g, self.settings.backgroundColor.b
|
||||||
if (self.settings.backgroundToggle) then
|
if (self.settings.backgroundToggle) then
|
||||||
r, g, b = self:GetColor(color)
|
r, g, b = self:GetColor(color)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.combat) then
|
if (self.combat) then
|
||||||
self.alpha = self.settings.alphaic
|
self.alpha = self.settings.alphaic
|
||||||
self.backgroundAlpha = self.settings.alphaicbg
|
self.backgroundAlpha = self.settings.alphaicbg
|
||||||
@ -502,8 +568,14 @@ function IceBarElement.prototype:UpdateBar(scale, color, alpha)
|
|||||||
|
|
||||||
self.frame:SetStatusBarColor(r, g, b, self.backgroundAlpha)
|
self.frame:SetStatusBarColor(r, g, b, self.backgroundAlpha)
|
||||||
self.barFrame:SetStatusBarColor(self:GetColor(color))
|
self.barFrame:SetStatusBarColor(self:GetColor(color))
|
||||||
|
|
||||||
self:SetScale(self.barFrame.bar, scale)
|
if self.DesiredScale ~= scale then
|
||||||
|
self.DesiredScale = scale
|
||||||
|
self.CurrLerpTime = 0
|
||||||
|
self.LastScale = self.CurrScale
|
||||||
|
end
|
||||||
|
|
||||||
|
self:SetScale(self.barFrame.bar, self.DesiredScale)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -590,7 +662,9 @@ end
|
|||||||
function IceBarElement.prototype:Update()
|
function IceBarElement.prototype:Update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function IceBarElement.prototype:MyOnUpdate()
|
||||||
|
self:SetScale(self.barFrame.bar, self.DesiredScale)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Combat event handlers ------------------------------------------------------
|
-- Combat event handlers ------------------------------------------------------
|
||||||
|
@ -110,6 +110,14 @@ function CastBar.prototype:GetOptions()
|
|||||||
order = 43
|
order = 43
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opts["shouldAnimate"] =
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
opts["desiredLerpTime"] =
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
opts["textSettings"] =
|
opts["textSettings"] =
|
||||||
{
|
{
|
||||||
type = 'group',
|
type = 'group',
|
||||||
|
@ -52,6 +52,21 @@ function TargetCast.prototype:TargetChanged(unit)
|
|||||||
self:StopBar()
|
self:StopBar()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TargetCast.prototype:GetOptions()
|
||||||
|
local opts = TargetCast.super.prototype.GetOptions(self)
|
||||||
|
|
||||||
|
opts["shouldAnimate"] =
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
opts["desiredLerpTime"] =
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return opts
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user