- now fully compatible with blizzard's "predicted power" system to constantly show energy/mana gains instead of ticking them

This commit is contained in:
Parnic
2008-08-14 05:17:07 +00:00
parent 5667cb0cc6
commit 4cc00dde52
2 changed files with 66 additions and 38 deletions

View File

@ -35,6 +35,7 @@ end
function PlayerMana.prototype:GetOptions()
local opts = PlayerMana.super.prototype.GetOptions(self)
if self:ShouldUseTicker() then
opts["tickerEnabled"] = {
type = "toggle",
name = "Show rogue/cat energy ticker",
@ -72,7 +73,7 @@ function PlayerMana.prototype:GetOptions()
end,
order = 52
}
end
opts["scaleManaColor"] = {
type = "toggle",
name = "Color bar by mana %",
@ -99,20 +100,26 @@ function PlayerMana.prototype:Enable(core)
self:CreateTickerFrame()
self:RegisterEvent("UNIT_MANA", "Update")
self:RegisterEvent("UNIT_MAXMANA", "Update")
self:RegisterEvent("UNIT_RAGE", "Update")
self:RegisterEvent("UNIT_MAXRAGE", "Update")
self:RegisterEvent("UNIT_ENERGY", "UpdateEnergy")
self:RegisterEvent("UNIT_MAXENERGY", "Update")
-- DK rune stuff
-- DK rune / wotlk stuff
if IceHUD.WowVer >= 30000 then
-- if GetCVarBool("predictedPower") and self.frame then
-- self.frame:SetScript("OnUpdate", function() self:Update(self.unit) end)
-- else
-- allow new 'predicted power' stuff to show the power updates constantly instead of ticking
if GetCVarBool("predictedPower") and self.frame then
self.frame:SetScript("OnUpdate", function() self:Update(self.unit) end)
else
self:RegisterEvent("UNIT_MANA", "Update")
self:RegisterEvent("UNIT_RAGE", "Update")
self:RegisterEvent("UNIT_ENERGY", "UpdateEnergy")
self:RegisterEvent("UNIT_RUNIC_POWER", "Update")
-- end
end
self:RegisterEvent("UNIT_MAXRUNIC_POWER", "Update")
else
self:RegisterEvent("UNIT_MANA", "Update")
self:RegisterEvent("UNIT_RAGE", "Update")
self:RegisterEvent("UNIT_ENERGY", "UpdateEnergy")
end
self:RegisterEvent("UNIT_DISPLAYPOWER", "ManaType")
@ -120,6 +127,10 @@ function PlayerMana.prototype:Enable(core)
self:ManaType(self.unit)
end
function PlayerMana.prototype:ShouldUseTicker()
return IceHUD.WowVer < 30000 or not GetCVarBool("predictedPower")
end
-- OVERRIDE
function PlayerMana.prototype:Redraw()
@ -148,6 +159,7 @@ function PlayerMana.prototype:ManaType(unit)
self.manaType = UnitPowerType(self.unit)
if self:ShouldUseTicker() then
-- register ticker for rogue energy
if (self.moduleSettings.tickerEnabled and (self.manaType == 3) and self.alive) then
self.tickerFrame:Show()
@ -156,6 +168,7 @@ function PlayerMana.prototype:ManaType(unit)
self.tickerFrame:Hide()
self.tickerFrame:SetScript("OnUpdate", nil)
end
end
self:Update(self.unit)
end
@ -167,7 +180,7 @@ function PlayerMana.prototype:Update(unit)
return
end
if (self.manaType ~= 3) then
if (self.manaType ~= 3 and self:ShouldUseTicker()) then
self.tickerFrame:Hide()
end
@ -187,12 +200,14 @@ function PlayerMana.prototype:Update(unit)
self:UpdateBar(self.mana/self.maxMana, color)
if self:ShouldUseTicker() then
-- hide ticker if rest of the bar is not visible
if (self.alpha == 0) then
self.tickerFrame:SetStatusBarColor(self:GetColor("PlayerEnergy", 0))
else
self.tickerFrame:SetStatusBarColor(self:GetColor("PlayerEnergy", self.moduleSettings.tickerAlpha))
end
end
if not AceLibrary:HasInstance("LibDogTag-3.0") then
-- extra hack for whiny rogues (are there other kind?)
@ -226,11 +241,10 @@ end
function PlayerMana.prototype:UpdateEnergy(unit)
if (unit and (unit ~= "player")) then
if (unit and (unit ~= "player")) or (not self:ShouldUseTicker()) then
return
end
if ((not (self.previousEnergy) or (self.previousEnergy <= UnitMana(self.unit))) and
(self.moduleSettings.tickerEnabled)) then
self.tickStart = GetTime()
@ -243,6 +257,10 @@ end
function PlayerMana.prototype:EnergyTick()
if not self:ShouldUseTicker() then
return
end
if not (self.tickStart) then
self.tickerFrame:Hide()
return
@ -269,6 +287,10 @@ end
function PlayerMana.prototype:CreateTickerFrame()
if not self:ShouldUseTicker() then
return
end
if not (self.tickerFrame) then
self.tickerFrame = CreateFrame("StatusBar", nil, self.barFrame)
end

View File

@ -29,24 +29,30 @@ end
function TargetMana.prototype:Enable(core)
TargetMana.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_MANA", "Update")
self:RegisterEvent("UNIT_MAXMANA", "Update")
self:RegisterEvent("UNIT_RAGE", "Update")
self:RegisterEvent("UNIT_MAXRAGE", "Update")
self:RegisterEvent("UNIT_ENERGY", "Update")
self:RegisterEvent("UNIT_MAXENERGY", "Update")
self:RegisterEvent("UNIT_FOCUS", "Update")
self:RegisterEvent("UNIT_MAXFOCUS", "Update")
self:RegisterEvent("UNIT_AURA", "Update")
self:RegisterEvent("UNIT_FLAGS", "Update")
-- DK rune stuff
if IceHUD.WowVer >= 30000 then
-- if GetCVarBool("predictedPower") and self.frame then
-- self.frame:SetScript("OnUpdate", function() self:Update(self.unit) end)
-- else
if GetCVarBool("predictedPower") and self.frame then
self.frame:SetScript("OnUpdate", function() self:Update(self.unit) end)
else
self:RegisterEvent("UNIT_MANA", "Update")
self:RegisterEvent("UNIT_RAGE", "Update")
self:RegisterEvent("UNIT_ENERGY", "Update")
self:RegisterEvent("UNIT_FOCUS", "Update")
self:RegisterEvent("UNIT_RUNIC_POWER", "Update")
-- end
end
self:RegisterEvent("UNIT_MAXRUNIC_POWER", "Update")
else
self:RegisterEvent("UNIT_MANA", "Update")
self:RegisterEvent("UNIT_RAGE", "Update")
self:RegisterEvent("UNIT_ENERGY", "Update")
self:RegisterEvent("UNIT_FOCUS", "Update")
end
self:Update("target")