From c78f618149b92e7d82ac93eed4ba256f48314a00 Mon Sep 17 00:00:00 2001 From: Parnic Date: Sun, 7 Aug 2016 17:16:57 -0500 Subject: [PATCH] Fixed speed and reliability of absorb bars reacting to changes --- modules/PlayerAbsorb.lua | 6 ------ modules/TargetAbsorb.lua | 28 +++++++++++++--------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/modules/PlayerAbsorb.lua b/modules/PlayerAbsorb.lua index 878aa33..fd861d4 100644 --- a/modules/PlayerAbsorb.lua +++ b/modules/PlayerAbsorb.lua @@ -17,11 +17,5 @@ function PlayerAbsorb.prototype:GetDefaultSettings() return settings end -function PlayerAbsorb.prototype:MyRegisterCustomEvents() -end - -function PlayerAbsorb.prototype:MyUnregisterCustomEvents() -end - -- Load us up IceHUD.PlayerAbsorb = PlayerAbsorb:new() diff --git a/modules/TargetAbsorb.lua b/modules/TargetAbsorb.lua index 1833c95..083a80d 100644 --- a/modules/TargetAbsorb.lua +++ b/modules/TargetAbsorb.lua @@ -4,13 +4,8 @@ IceTargetAbsorb.prototype.highestAbsorbSinceLastZero = 0 IceTargetAbsorb.prototype.ColorName = "TargetAbsorb" local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs -if IceHUD.WowVer < 50200 then - UnitGetTotalAbsorbs = nil -end --- Constructor -- function IceTargetAbsorb.prototype:init(moduleName, unit, colorName) - -- not sure if this is necessary...i think it is...this way, we can instantiate this bar on its own or as a parent class if moduleName == nil or unit == nil then IceTargetAbsorb.super.prototype.init(self, "TargetAbsorb", "target") else @@ -29,45 +24,46 @@ function IceTargetAbsorb.prototype:GetDefaultSettings() settings["side"] = IceCore.Side.Right settings["offset"] = 3 - settings["upperText"] = "[TotalAbsorb]" + settings["upperText"] = "[TotalAbsorb:VeryShort]" return settings end --- OVERRIDE function IceTargetAbsorb.prototype:Enable(core) IceTargetAbsorb.super.prototype.Enable(self, core) self:RegisterEvent("UNIT_ABSORB_AMOUNT_CHANGED", "UpdateAbsorbAmount") self:MyRegisterCustomEvents() - self:UpdateAbsorbAmount("UNIT_ABSORB_AMOUNT_CHANGED", self.unit) + self:UpdateAbsorbAmount() self:Show(false) end function IceTargetAbsorb.prototype:MyRegisterCustomEvents() - self:RegisterEvent("PLAYER_TARGET_CHANGED", "UpdateAbsorbAmount") end function IceTargetAbsorb.prototype:MyUnregisterCustomEvents() - self:UnregisterEvent("PLAYER_TARGET_CHANGED") +end + +function IceTargetAbsorb.prototype:Update() + self:UpdateAbsorbAmount() end function IceTargetAbsorb.prototype:UpdateAbsorbAmount(event, unit) - if UnitGetTotalAbsorbs == nil or (event == "UNIT_ABSORB_AMOUNT_CHANGED" and unit ~= self.unit) then + if event == "UNIT_ABSORB_AMOUNT_CHANGED" and unit ~= self.unit then return end - local absorbAmount = UnitGetTotalAbsorbs(self.unit) + local absorbAmount = UnitGetTotalAbsorbs(self.unit) or 0 - if absorbAmount == nil or absorbAmount <= 0 then + if absorbAmount <= 0 then self.highestAbsorbSinceLastZero = 0 elseif absorbAmount > self.highestAbsorbSinceLastZero then self.highestAbsorbSinceLastZero = absorbAmount end - if absorbAmount == nil or absorbAmount <= 0 or self.highestAbsorbSinceLastZero <= 0 then + if absorbAmount <= 0 or self.highestAbsorbSinceLastZero <= 0 then self:Show(false) else self:Show(true) @@ -82,4 +78,6 @@ function IceTargetAbsorb.prototype:Disable(core) self:MyUnregisterCustomEvents() end -IceHUD.TargetAbsorb = IceTargetAbsorb:new() +if UnitGetTotalAbsorbs ~= nil then + IceHUD.TargetAbsorb = IceTargetAbsorb:new() +end