From 1b3b9a1bb99272b28c5dff1248dbee8e051f77b6 Mon Sep 17 00:00:00 2001 From: Parnic Date: Thu, 26 May 2016 01:09:13 -0500 Subject: [PATCH] Added support for Insanity Legion's Shadow Priests have a new default power type called Insanity, so now we need an additional bar to show the player's mana (which all priests still have) while in shadow spec as a priest. --- IceHUD.toc | 1 + modules/PlayerMana.lua | 5 +++ modules/ShadowPriestMana.lua | 69 ++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 modules/ShadowPriestMana.lua diff --git a/IceHUD.toc b/IceHUD.toc index b311c4f..36b1c6c 100644 --- a/IceHUD.toc +++ b/IceHUD.toc @@ -89,6 +89,7 @@ modules\TargetAbsorb.lua modules\PlayerAbsorb.lua modules\FocusAbsorb.lua modules\Stagger.lua +modules\ShadowPriestMana.lua #@do-not-package@ IceHUD_Options\Options.lua diff --git a/modules/PlayerMana.lua b/modules/PlayerMana.lua index 5b7e3cd..87f699b 100644 --- a/modules/PlayerMana.lua +++ b/modules/PlayerMana.lua @@ -16,6 +16,9 @@ function PlayerMana.prototype:init() self:SetDefaultColor("PlayerEnergy", 218, 231, 31) self:SetDefaultColor("PlayerFocus", 242, 149, 98) self:SetDefaultColor("PlayerRunicPower", 62, 54, 152) + if IceHUD.WowVer >= 70000 then + self:SetDefaultColor("PlayerInsanity", 150, 50, 255) + end end @@ -289,6 +292,8 @@ function PlayerMana.prototype:Update(unit, powertype) color = "PlayerRunicPower" elseif (self.manaType == SPELL_POWER_FOCUS) then color = "PlayerFocus" + elseif (IceHUD.WowVer >= 70000 and self.manaType == SPELL_POWER_INSANITY) then + color = "PlayerInsanity" end end diff --git a/modules/ShadowPriestMana.lua b/modules/ShadowPriestMana.lua new file mode 100644 index 0000000..4da1efe --- /dev/null +++ b/modules/ShadowPriestMana.lua @@ -0,0 +1,69 @@ +local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false) +local ShadowPriestMana = IceCore_CreateClass(IceUnitBar) + +ShadowPriestMana.prototype.shadowPriestMana = nil +ShadowPriestMana.prototype.shadowPriestManaMax = nil + +local MANA_POWER_INDEX = SPELL_POWER_MANA + +-- Constructor -- +function ShadowPriestMana.prototype:init() + ShadowPriestMana.super.prototype.init(self, "ShadowPriestMana", "player") + + self.side = IceCore.Side.Right + self.offset = 0 + + self:SetDefaultColor("ShadowPriestMana", 87, 82, 141) +end + + +function ShadowPriestMana.prototype:GetDefaultSettings() + local settings = ShadowPriestMana.super.prototype.GetDefaultSettings(self) + + settings["side"] = IceCore.Side.Right + settings["offset"] = 0 + settings["textVisible"] = {upper = true, lower = false} + settings["upperText"] = "[PercentShadowPriestMP:Round]" + settings["lowerText"] = "[FractionalShadowPriestMP:Color('3071bf'):Bracket]" + + return settings +end + + +function ShadowPriestMana.prototype:Enable(core) + ShadowPriestMana.super.prototype.Enable(self, core) + + self:RegisterEvent("PLAYER_TALENT_UPDATE", "Update") + self:RegisterEvent("UNIT_POWER", "Update") + self:RegisterEvent("UNIT_MAXPOWER", "Update") +end + + +function ShadowPriestMana.prototype:Disable(core) + ShadowPriestMana.super.prototype.Disable(self, core) +end + + +function ShadowPriestMana.prototype:Update() + ShadowPriestMana.super.prototype.Update(self) + + local shadow = (UnitPowerType(self.unit) == SPELL_POWER_INSANITY) + + self.shadowPriestMana = UnitPower(self.unit, MANA_POWER_INDEX) + self.shadowPriestManaMax = UnitPowerMax(self.unit, MANA_POWER_INDEX) + + if (not self.alive or not shadow or not self.shadowPriestMana or not self.shadowPriestManaMax or self.shadowPriestManaMax == 0) then + self:Show(false) + return + else + self:Show(true) + end + + self:UpdateBar(self.shadowPriestManaMax ~= 0 and self.shadowPriestMana / self.shadowPriestManaMax or 0, "ShadowPriestMana") +end + +-- Load us up (if we are a shadow priest in 7.0+) +local _, unitClass = UnitClass("player") +if (unitClass == "PRIEST" and IceHUD.WowVer >= 70000) then + IceHUD.ShadowPriestMana = ShadowPriestMana:new() +end