- made custom bars/counters work with alpha settings properly

- made multiple custom bars work together nicely...bad programmer for making local properties instead of class properties
This commit is contained in:
Parnic
2009-04-10 05:00:27 +00:00
parent c9fc0bcf89
commit ab27807fa8
3 changed files with 22 additions and 23 deletions

View File

@ -522,7 +522,8 @@ function IceBarElement.prototype:CreateFrame()
-- never register the OnUpdate for the mirror bar since it's handled internally -- never register the OnUpdate for the mirror bar since it's handled internally
-- in addition, do not register OnUpdate if predictedPower is set and this is the player mana or target mana bar -- in addition, do not register OnUpdate if predictedPower is set and this is the player mana or target mana bar
if not string.find(self.elementName, "MirrorBar") if not string.find(self.elementName, "MirrorBar")
and ((IceHUD.WowVer < 30000 or not GetCVarBool("predictedPower")) or (not string.find(self.elementName, "PlayerMana"))) then and ((IceHUD.WowVer < 30000 or not GetCVarBool("predictedPower")) or (not string.find(self.elementName, "PlayerMana")))
and not self.moduleSettings.isCustomBar then
self.frame:SetScript("OnUpdate", function() self:MyOnUpdate() end) self.frame:SetScript("OnUpdate", function() self:MyOnUpdate() end)
end end
end end

View File

@ -5,9 +5,9 @@ IceCustomBar = AceOO.Class(IceUnitBar)
local validUnits = {"player", "target"} local validUnits = {"player", "target"}
local buffOrDebuff = {"buff", "debuff"} local buffOrDebuff = {"buff", "debuff"}
local auraDuration = 0 IceCustomBar.prototype.auraDuration = 0
local auraCount = 0 IceCustomBar.prototype.auraCount = 0
local auraEndTime = 0 IceCustomBar.prototype.auraEndTime = 0
-- Constructor -- -- Constructor --
function IceCustomBar.prototype:init() function IceCustomBar.prototype:init()
@ -20,7 +20,7 @@ end
function IceCustomBar.prototype:Enable(core) function IceCustomBar.prototype:Enable(core)
IceCustomBar.super.prototype.Enable(self, core) IceCustomBar.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_AURA", "Update") self:RegisterEvent("UNIT_AURA", "UpdateCustomBar")
self:Show(true) self:Show(true)
@ -29,11 +29,11 @@ function IceCustomBar.prototype:Enable(core)
self.unit = self.moduleSettings.myUnit self.unit = self.moduleSettings.myUnit
self:Update(self.unit) self:UpdateCustomBar(self.unit)
end end
function IceCustomBar.prototype:TargetChanged() function IceCustomBar.prototype:TargetChanged()
self:Update(self.unit) self:UpdateCustomBar(self.unit)
end end
function IceCustomBar.prototype:Disable(core) function IceCustomBar.prototype:Disable(core)
@ -210,7 +210,7 @@ function IceCustomBar.prototype:GetOptions()
end end
function IceCustomBar.prototype:GetBarColor() function IceCustomBar.prototype:GetBarColor()
return self.moduleSettings.barColor.r, self.moduleSettings.barColor.g, self.moduleSettings.barColor.b return self.moduleSettings.barColor.r, self.moduleSettings.barColor.g, self.moduleSettings.barColor.b, self.alpha
end end
-- 'Protected' methods -------------------------------------------------------- -- 'Protected' methods --------------------------------------------------------
@ -238,40 +238,38 @@ function IceCustomBar.prototype:GetAuraDuration(unitName, buffName)
return nil, nil, nil return nil, nil, nil
end end
function IceCustomBar.prototype:Update(unit, fromUpdate) function IceCustomBar.prototype:UpdateCustomBar(unit, fromUpdate)
if unit and unit ~= self.unit then if unit and unit ~= self.unit then
return return
end end
IceCustomBar.super.prototype.Update(self, unit)
local now = GetTime() local now = GetTime()
local remaining = nil local remaining = nil
if not fromUpdate then if not fromUpdate then
auraDuration, remaining, auraCount = self.auraDuration, remaining, self.auraCount =
self:GetAuraDuration(self.unit, self.moduleSettings.buffToTrack) self:GetAuraDuration(self.unit, self.moduleSettings.buffToTrack)
if not remaining then if not remaining then
auraEndTime = 0 self.auraEndTime = 0
auraCount = 0 self.auraCount = 0
else else
auraEndTime = remaining + now self.auraEndTime = remaining + now
end end
end end
if auraEndTime and auraEndTime >= now then if self.auraEndTime and self.auraEndTime >= now then
if not fromUpdate then if not fromUpdate then
self.frame:SetScript("OnUpdate", function() self:Update(self.unit, true) end) self.frame:SetScript("OnUpdate", function() self:UpdateCustomBar(self.unit, true) end)
end end
self:Show(true) self:Show(true)
if not remaining then if not remaining then
remaining = auraEndTime - now remaining = self.auraEndTime - now
end end
self:UpdateBar(remaining / auraDuration, "undef") self:UpdateBar(remaining / self.auraDuration, "undef")
else else
self:UpdateBar(0, "undef") self:UpdateBar(0, "undef")
self:Show(false) self:Show(false)
@ -280,7 +278,7 @@ function IceCustomBar.prototype:Update(unit, fromUpdate)
if (remaining ~= nil) then if (remaining ~= nil) then
self:SetBottomText1(self.moduleSettings.upperText .. " " .. tostring(ceil(remaining or 0)) .. "s") self:SetBottomText1(self.moduleSettings.upperText .. " " .. tostring(ceil(remaining or 0)) .. "s")
else else
auraBuffCount = 0 self.auraBuffCount = 0
self:SetBottomText1("") self:SetBottomText1("")
self:SetBottomText2("") self:SetBottomText2("")
end end
@ -291,5 +289,5 @@ end
function IceCustomBar.prototype:OutCombat() function IceCustomBar.prototype:OutCombat()
IceCustomBar.super.prototype.OutCombat(self) IceCustomBar.super.prototype.OutCombat(self)
self:Update(self.unit) self:UpdateCustomBar(self.unit)
end end

View File

@ -329,11 +329,11 @@ function IceCustomCount.prototype:GetOptions()
end end
function IceCustomCount.prototype:GetCustomColor() function IceCustomCount.prototype:GetCustomColor()
return self.moduleSettings.countColor.r, self.moduleSettings.countColor.g, self.moduleSettings.countColor.b, self.moduleSettings.countColor.a return self.moduleSettings.countColor.r, self.moduleSettings.countColor.g, self.moduleSettings.countColor.b, self.alpha
end end
function IceCustomCount.prototype:GetCustomMinColor() function IceCustomCount.prototype:GetCustomMinColor()
return self.moduleSettings.countMinColor.r, self.moduleSettings.countMinColor.g, self.moduleSettings.countMinColor.b, self.moduleSettings.countMinColor.a return self.moduleSettings.countMinColor.r, self.moduleSettings.countMinColor.g, self.moduleSettings.countMinColor.b, self.alpha
end end