Added checks for rune count changing mid-session

Right now most ClassPowerCounter child classes are doing this work themselves, but they don't need to be. Some cleanup could be done there if anyone ever felt like doing it. (I did a tiny bit with Shards and Chi, but there's more to be done)
This commit is contained in:
Parnic
2016-05-28 22:57:25 -05:00
parent a8b6f53a68
commit 2235364df9
3 changed files with 15 additions and 12 deletions

View File

@ -17,6 +17,7 @@ IceClassPowerCounter.prototype.DesiredAnimPause = 0.5
IceClassPowerCounter.prototype.requiredSpec = nil IceClassPowerCounter.prototype.requiredSpec = nil
IceClassPowerCounter.prototype.shouldShowUnmodified = false IceClassPowerCounter.prototype.shouldShowUnmodified = false
IceClassPowerCounter.prototype.unmodifiedMaxPerRune = 10 IceClassPowerCounter.prototype.unmodifiedMaxPerRune = 10
IceClassPowerCounter.prototype.unit = "player"
IceClassPowerCounter.prototype.growModes = { width = 1, height = 2 } IceClassPowerCounter.prototype.growModes = { width = 1, height = 2 }
IceClassPowerCounter.prototype.currentGrowMode = nil IceClassPowerCounter.prototype.currentGrowMode = nil
@ -418,6 +419,9 @@ end
function IceClassPowerCounter.prototype:Enable(core) function IceClassPowerCounter.prototype:Enable(core)
IceClassPowerCounter.super.prototype.Enable(self, core) IceClassPowerCounter.super.prototype.Enable(self, core)
self.numRunes = UnitPowerMax(self.unit, self.unitPower)
self:CreateFrame()
self:CheckValidLevel(nil, UnitLevel("player")) self:CheckValidLevel(nil, UnitLevel("player"))
end end
@ -483,6 +487,12 @@ function IceClassPowerCounter.prototype:UpdateRunePower(event, arg1, arg2)
return return
end end
local numMax = UnitPowerMax(self.unit, self.unitPower)
if numMax ~= self.numRunes then
self.numRunes = numMax
CreateFrame()
end
local numReady = UnitPower("player", self.unitPower) local numReady = UnitPower("player", self.unitPower)
local percentReady = self.shouldShowUnmodified and (UnitPower("player", self.unitPower, true) / self.unmodifiedMaxPerRune) or numReady local percentReady = self.shouldShowUnmodified and (UnitPower("player", self.unitPower, true) / self.unmodifiedMaxPerRune) or numReady

View File

@ -33,9 +33,6 @@ function HarmonyPower.prototype:init()
end end
function HarmonyPower.prototype:Enable(core) function HarmonyPower.prototype:Enable(core)
self.numRunes = UnitPowerMax(self.unit, self.unitPower)
self:CreateFrame()
HarmonyPower.super.prototype.Enable(self, core) HarmonyPower.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_POWER_FREQUENT", "UpdateRunePower") self:RegisterEvent("UNIT_POWER_FREQUENT", "UpdateRunePower")
@ -52,10 +49,6 @@ function HarmonyPower.prototype:UpdateRunePower(event, arg1, arg2)
return return
end end
if self.fakeNumRunes ~= nil and self.fakeNumRunes > 0 then
numRunes = self.fakeNumRunes
end
if numRunes ~= self.numRunes then if numRunes ~= self.numRunes then
if numRunes < self.numRunes and #self.frame.graphical >= numRunes then if numRunes < self.numRunes and #self.frame.graphical >= numRunes then
for i=numRunes + 1, #self.frame.graphical do for i=numRunes + 1, #self.frame.graphical do

View File

@ -38,13 +38,13 @@ function ShardCounter.prototype:init()
self.runeWidth = 26 self.runeWidth = 26
self.runeCoords = AfflictionCoords self.runeCoords = AfflictionCoords
self.unitPower = SPELL_POWER_SOUL_SHARDS self.unitPower = SPELL_POWER_SOUL_SHARDS
self.unit = "player"
end end
end end
function ShardCounter.prototype:Enable(core) function ShardCounter.prototype:Enable(core)
if IceHUD.WowVer >= 70000 then if IceHUD.WowVer >= 70000 then
self.numRunes = UnitPowerMax("player", self.unitPower) self.numRunes = UnitPowerMax(self.unit, self.unitPower)
self:CreateFrame()
end end
ShardCounter.super.prototype.Enable(self, core) ShardCounter.super.prototype.Enable(self, core)
@ -64,7 +64,7 @@ end
function ShardCounter.prototype:UpdateRunePower(event, arg1, arg2) function ShardCounter.prototype:UpdateRunePower(event, arg1, arg2)
if IceHUD.WowVer >= 50000 and IceHUD.WowVer < 70000 then if IceHUD.WowVer >= 50000 and IceHUD.WowVer < 70000 then
if event == "UNIT_POWER_FREQUENT" and arg1 == "player" then if event == "UNIT_POWER_FREQUENT" and arg1 == self.unit then
if CurrentSpec == SPEC_WARLOCK_DESTRUCTION and arg2 ~= "BURNING_EMBERS" then if CurrentSpec == SPEC_WARLOCK_DESTRUCTION and arg2 ~= "BURNING_EMBERS" then
return return
elseif CurrentSpec == SPEC_WARLOCK_DEMONOLOGY and arg2 ~= "DEMONIC_FURY" then elseif CurrentSpec == SPEC_WARLOCK_DEMONOLOGY and arg2 ~= "DEMONIC_FURY" then
@ -105,7 +105,7 @@ function ShardCounter.prototype:UpdatePowerType(event)
self.runeCoords = AfflictionCoords self.runeCoords = AfflictionCoords
self.unitPower = SPELL_POWER_SOUL_SHARDS self.unitPower = SPELL_POWER_SOUL_SHARDS
local powerMax = UnitPowerMax("player", self.unitPower) local powerMax = UnitPowerMax(self.unit, self.unitPower)
if powerMax == 0 then -- abort abort! this is bad. if powerMax == 0 then -- abort abort! this is bad.
return return
end end
@ -127,7 +127,7 @@ function ShardCounter.prototype:UpdatePowerType(event)
self.runeCoords = DestructionCoords self.runeCoords = DestructionCoords
self.unitPower = SPELL_POWER_BURNING_EMBERS self.unitPower = SPELL_POWER_BURNING_EMBERS
local powerMax = UnitPowerMax("player", self.unitPower) local powerMax = UnitPowerMax(self.unit, self.unitPower)
if powerMax == 0 then -- abort abort! this is bad. if powerMax == 0 then -- abort abort! this is bad.
return return
end end