Add bar animation queues
This commit is contained in:
@@ -320,13 +320,17 @@ end
|
||||
-----------------------------------------------------------------------------
|
||||
-- Omen bar stuff
|
||||
|
||||
setmetatable(bars, {__index = function(self, barID)
|
||||
do
|
||||
local barCount = 0
|
||||
setmetatable(bars, {__index = function(self, barID)
|
||||
local bar = CreateFrame("Frame", nil, Omen.BarList)
|
||||
self[barID] = bar
|
||||
|
||||
barCount = barCount + 1
|
||||
|
||||
bar:SetWidth(Omen.BarList:GetWidth())
|
||||
bar:SetHeight(db.BarHeight)
|
||||
bar:SetPoint("TOPLEFT", Omen.BarList, "TOPLEFT", 0, (barID-1) * -db.BarHeight)
|
||||
bar:SetPoint("TOPLEFT", Omen.BarList, "TOPLEFT", 0, (barCount-1) * -db.BarHeight)
|
||||
|
||||
bar.Text1 = bar:CreateFontString(nil, nil, "GameFontNormalSmall")
|
||||
bar.Text1:SetPoint("LEFT", bar, "LEFT", 10, 0)
|
||||
@@ -343,8 +347,45 @@ setmetatable(bars, {__index = function(self, barID)
|
||||
bar.texture:SetTexture(1, 1, 1, 0.6)
|
||||
bar.texture:SetPoint("TOPLEFT", bar, "TOPLEFT")
|
||||
bar.texture:SetPoint("BOTTOMLEFT", bar, "BOTTOMLEFT")
|
||||
|
||||
bar.animations = {}
|
||||
bar.animationCursor = 0
|
||||
bar.animationTime = 0.25
|
||||
bar.animate = function(self, v)
|
||||
self.animationCursor = self.animationCursor + v
|
||||
if self.animationCursor > self.animationTime then
|
||||
self.texture:SetWidth(self.animations[1])
|
||||
tremove(self.animations, 1)
|
||||
tremove(self.animations, 1)
|
||||
tremove(self.animations, 1)
|
||||
self.animationCursor = self.animationCursor - self.animationTime
|
||||
if #self.animations == 0 then
|
||||
self:SetScript("OnUpdate", nil)
|
||||
end
|
||||
else
|
||||
self.texture:SetWidth(self.animations[2] + (self.animations[3] * (self.animationCursor / self.animationTime)))
|
||||
end
|
||||
end
|
||||
|
||||
bar.AnimateTo = function(self, val)
|
||||
if val == 1/0 or val == -1/0 then return end
|
||||
if #self.animations > 0 and self.animations[#self.animations-2] == val then
|
||||
return
|
||||
end
|
||||
local currentWidth = self.texture:GetWidth()
|
||||
local diff = (val - currentWidth)
|
||||
tinsert(self.animations, val)
|
||||
tinsert(self.animations, currentWidth)
|
||||
tinsert(self.animations, diff)
|
||||
|
||||
if #self.animations > 0 then
|
||||
self:SetScript("OnUpdate", self.animate)
|
||||
end
|
||||
end
|
||||
|
||||
return bar
|
||||
end})
|
||||
end})
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
@@ -608,7 +649,16 @@ function Omen:UpdateBars()
|
||||
bar.Text2:SetText(floor(threatTable[guid] / 100).." ["..floor(threatTable[guid] / tankThreat * 100).."%]")
|
||||
local c = (class == "PET" and pet_color) or RAID_CLASS_COLORS[class] or default_color
|
||||
bar.texture:SetVertexColor(c.r, c.g, c.b)
|
||||
bar.texture:SetWidth(w * threatTable[guid] / topthreat)
|
||||
|
||||
if topthreat == 0 then
|
||||
topthreat = threatTable[guid]
|
||||
if topthreat == 0 then
|
||||
topthreat = 1
|
||||
end
|
||||
end
|
||||
local width = w * threatTable[guid] / topthreat
|
||||
bar:AnimateTo(width)
|
||||
|
||||
bar:Show()
|
||||
i = i + 1
|
||||
if db.Autocollapse then
|
||||
|
||||
Reference in New Issue
Block a user