- fixed SetBottomText1 to propertly set text colors on the upper text line

- eclipse bar now colors the numerical value to whatever direction the bar is heading
This commit is contained in:
Parnic
2010-10-20 03:49:34 +00:00
parent 1b86b760a3
commit 3cc7b1b1fb
2 changed files with 33 additions and 4 deletions

View File

@ -1,12 +1,20 @@
local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
local EclipseBar = IceCore_CreateClass(IceBarElement)
EclipseBar.prototype.barUpdateColor = "EclipseLunar"
EclipseBar.prototype.direction = "none"
local DirectionToColorMapping = {
none = "Text",
sun = "EclipseSolar",
moon = "EclipseLunar",
}
function EclipseBar.prototype:init()
EclipseBar.super.prototype.init(self, "EclipseBar")
self:SetDefaultColor("EclipseLunar", 31, 31, 231)
self:SetDefaultColor("EclipseLunarActive", 0, 0, 255)
self:SetDefaultColor("EclipseLunar", 35, 104, 231)
self:SetDefaultColor("EclipseLunarActive", 35, 104, 231)
self:SetDefaultColor("EclipseSolar", 190, 210, 31)
self:SetDefaultColor("EclipseSolarActive", 238, 251, 31)
end
@ -46,9 +54,12 @@ function EclipseBar.prototype:Enable(core)
self:RegisterEvent("PLAYER_TALENT_UPDATE", "UpdateShown")
self:RegisterEvent("MASTERY_UPDATE", "UpdateShown")
self:RegisterEvent("UNIT_AURA", "UpdateEclipseBuffs")
self:RegisterEvent("ECLIPSE_DIRECTION_CHANGE", "UpdateEclipseDirection")
self.frame:SetScript("OnUpdate", function() self:Update() end)
self:UpdateEclipseDirection(nil, GetEclipseDirection() == "sun", GetEclipseDirection() == "none")
self:UpdateEclipseBuffs()
self:UpdateShown()
end
@ -56,6 +67,12 @@ function EclipseBar.prototype:Disable(core)
EclipseBar.super.prototype.Disable(self, core)
end
-- note that isNone is not passed by the ECLIPSE_DIRECTION_CHANGE event, only manually via :Enable
function EclipseBar.prototype:UpdateEclipseDirection(event, isLunar, isNone)
self.direction = isLunar and "sun" or isNone and "none" or "moon"
self:UpdateEclipsePower()
end
function EclipseBar.prototype:SetBarVisibility(visible)
EclipseBar.super.prototype.SetBarVisibility(self, visible)
@ -170,8 +187,19 @@ function EclipseBar.prototype:UpdateEclipsePower()
return
end
self:SetBottomText1(abs((power/maxPower) * 100))
self:SetBottomText1(abs((power/maxPower) * 100), DirectionToColorMapping[self.direction])
-- i'm rather fond of this solution so i'm keeping it around...the correct fix was in IceBarElement to set the upper text color
-- but hey, this would have been sweet.
--[[
local r,g,b = self:GetColor(DirectionToColorMapping[self.direction])
self:SetBottomText1(string.format("|c%x%x%x%x%d|r",
self.alpha * 255,
r * 255,
g * 255,
b * 255,
abs((power/maxPower) * 100)))
]]
local pos = (power/maxPower) / 2
self:PositionMarker(1, pos)
end
@ -180,7 +208,7 @@ function EclipseBar.prototype:Update()
EclipseBar.super.prototype.Update(self)
self:UpdateEclipsePower()
self:UpdateBar(0.5, self.barUpdateColor)
self:UpdateBar(0.5, self.barUpdateColor, 1)
self:UpdateAlpha()
end