/branches/preview/Aloft/AloftThreat
insets = { left = 0, right = 0, top = 0, bottom = 0 }, |
} |
local BORDER_INIT_ATTEMPTS = 2 |
-- NOTE: these textures are now registered via SharedMedia, in AloftGlow/AloftGlow.lua |
-- local flashTexture = |
-- ChatFrame7:AddMessage("AloftThreatBar:SetupThreatBar(): invoke") |
-- we only need to go through this rigamarole once |
if not threatBar or threatBar.init then return end |
if not threatBar or (threatBar.init and threatBar.init >= BORDER_INIT_ATTEMPTS) then return end |
local texture = SML:Fetch("statusbar", self.db.profile.texture) |
local inset, edgeFile = self:GetBorder(aloftData) |
local threatRegion = threatBar.threatRegion |
local threatRegionColor = (aloftData.threat < aloftData.maxThreat) and self.db.profile.commonThreatColor or self.db.profile.maximumThreatColor |
threatRegion:SetVertexColor(unpack(threatRegionColor)) -- the threat region color can change |
if not threatBar.init then |
if not threatBar.init or threatBar.init < BORDER_INIT_ATTEMPTS then |
threatRegion:SetWidth(1) -- width is initially bogus, updated after a frame delay below (only once, before the first frame delay) |
end |
threatRegion:Show() |
gainRegion:SetWidth(gainRegionWidth) |
gainRegion:Show() |
-- ChatFrame7:AddMessage("AloftThreatBar:Update(): " .. aloftData.name .. " gain width " .. gainRegion:GetWidth()) |
else |
threatBar.gainRegion:Hide() |
end |
-- the threat bar is constructed; show it, initially with bogus colors (only once, before the first frame-delay) |
if not threatBar.init then |
if not threatBar.init or threatBar.init < BORDER_INIT_ATTEMPTS then |
threatBar:SetBackdropColor(0, 0, 0, 0.1) |
threatBar:SetBackdropBorderColor(0, 0, 0, 0.1) |
threatBar:Show() |
end |
-- frame delay to flip the backdrop color(s); hopefully avoids the "malformed border" issue |
self:ScheduleTimer(function(arg) AloftThreatBar:DoShowThreatBar(arg) end, 0.15, { threatBar = threatBar, threatRegion = threatRegion, threatRegionWidth = threatRegionWidth, }) -- a bit more than one frame |
self:ScheduleTimer(function(arg) AloftThreatBar:DoShowThreatBar(arg) end, 0.15, { aloftData = aloftData, threatRegionWidth = threatRegionWidth, gainRegionWidth = gainRegionWidth, }) -- a bit more than one frame |
-- ChatFrame7:AddMessage("AloftThreatBar:Update(): show threat bar " .. tostring(aloftData.name)) |
-- if the nameplate's unit has maximum threat, show the flash bar as well |
end |
function AloftThreatBar:DoShowThreatBar(arg) |
local threatBar = arg.threatBar |
threatBar:SetBackdropColor(unpack(self.db.profile.backdropColor)) |
threatBar:SetBackdropBorderColor(unpack(self.db.profile.borderColor)) |
arg.threatRegion:SetWidth(arg.threatRegionWidth) |
threatBar:Show() |
local aloftData = arg.aloftData |
local threatBar = aloftData.layoutFrame and aloftData.layoutFrame.threatBar |
if threatBar then |
threatBar:SetBackdropColor(unpack(self.db.profile.backdropColor)) |
threatBar:SetBackdropBorderColor(unpack(self.db.profile.borderColor)) |
threatBar.threatRegion:SetWidth(arg.threatRegionWidth) |
threatBar:Show() |
if not arg.gainRegionWidth or arg.gainRegionWidth <= 0 then |
threatBar.gainRegion:Hide() |
end |
end |
-- flag as having been through the first frame-delay |
threatBar.init = true |
if not threatBar.init then |
threatBar.init = 0 |
else |
threatBar.init = threatBar.init + 1 |
end |
end |
----------------------------------------------------------------------------- |