Add bar animation queues

This commit is contained in:
Chris Heald
2008-10-02 01:29:21 -07:00
parent 49895213a4
commit ddf28c2dd5
+73 -23
View File
@@ -320,31 +320,72 @@ end
-----------------------------------------------------------------------------
-- Omen bar stuff
setmetatable(bars, {__index = function(self, barID)
local bar = CreateFrame("Frame", nil, Omen.BarList)
self[barID] = bar
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:SetWidth(Omen.BarList:GetWidth())
bar:SetHeight(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)
bar.Text1:SetJustifyH("LEFT")
bar.Text1:SetTextColor(1, 1, 1, 1)
bar.Text1:SetText("abc")
bar.Text2 = bar:CreateFontString(nil, nil, "GameFontNormalSmall")
bar.Text2:SetPoint("RIGHT", bar, "RIGHT", -10, 0)
bar.Text2:SetJustifyH("RIGHT")
bar.Text2:SetTextColor(1, 1, 1, 1)
bar.Text2:SetText("def")
bar.Text1 = bar:CreateFontString(nil, nil, "GameFontNormalSmall")
bar.Text1:SetPoint("LEFT", bar, "LEFT", 10, 0)
bar.Text1:SetJustifyH("LEFT")
bar.Text1:SetTextColor(1, 1, 1, 1)
bar.Text1:SetText("abc")
bar.Text2 = bar:CreateFontString(nil, nil, "GameFontNormalSmall")
bar.Text2:SetPoint("RIGHT", bar, "RIGHT", -10, 0)
bar.Text2:SetJustifyH("RIGHT")
bar.Text2:SetTextColor(1, 1, 1, 1)
bar.Text2:SetText("def")
bar.texture = bar:CreateTexture()
bar.texture:SetTexture(1, 1, 1, 0.6)
bar.texture:SetPoint("TOPLEFT", bar, "TOPLEFT")
bar.texture:SetPoint("BOTTOMLEFT", bar, "BOTTOMLEFT")
return bar
end})
bar.texture = bar:CreateTexture()
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
-----------------------------------------------------------------------------
@@ -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