Rolled ClassMana bars into PlayerAltMana

There are too many classes that need to care about mana as a background resource in addition to whatever their primary resource is to keep creating class-specific bars, so let's just make one bar that does it all. I've done a one-time inherit of DruidMana's settings since it's the only bar that's been in a Release version that serves this purpose and should migrate its settings forward.
This commit is contained in:
Parnic
2016-05-28 02:16:26 -05:00
parent 6906f3545d
commit 7b3d910956
6 changed files with 96 additions and 201 deletions

View File

@ -167,6 +167,12 @@ function IceCore.prototype:CheckDisplayUpdateMessage()
self.settings.modules["LacerateCount"] = {}
end
end
if self.accountSettings.lastRunVersion <= 20160527053225 then
if self.settings.modules["DruidMana"] ~= nil then
self.settings.modules["PlayerAltMana"] = self.settings.modules["DruidMana"]
self.settings.modules["DruidMana"] = nil
end
end
self.accountSettings.lastRunVersion = thisVersion
end
end

View File

@ -36,7 +36,6 @@ modules\TargetHealth.lua
modules\TargetMana.lua
modules\PetHealth.lua
modules\PetMana.lua
modules\DruidMana.lua
modules\TargetInfo.lua
modules\TargetOfTarget.lua
modules\ComboPoints.lua
@ -83,13 +82,12 @@ modules\Vengeance.lua
modules\Resolve.lua
modules\PlayerAlternatePower.lua
modules\HarmonyPower.lua
modules\MonkManaBar.lua
modules\ShadowOrbs.lua
modules\TargetAbsorb.lua
modules\PlayerAbsorb.lua
modules\FocusAbsorb.lua
modules\Stagger.lua
modules\ShadowPriestMana.lua
modules\PlayerAltMana.lua
modules\ArcaneCharges.lua
#@do-not-package@

View File

@ -1,76 +0,0 @@
local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
local DruidMana = IceCore_CreateClass(IceUnitBar)
DruidMana.prototype.druidMana = nil
DruidMana.prototype.druidManaMax = nil
local MANA_POWER_INDEX = SPELL_POWER_MANA
-- Constructor --
function DruidMana.prototype:init()
DruidMana.super.prototype.init(self, "DruidMana", "player")
self.side = IceCore.Side.Right
self.offset = 0
self:SetDefaultColor("DruidMana", 87, 82, 141)
end
function DruidMana.prototype:GetDefaultSettings()
local settings = DruidMana.super.prototype.GetDefaultSettings(self)
settings["side"] = IceCore.Side.Right
settings["offset"] = 0
settings["textVisible"] = {upper = true, lower = false}
settings["upperText"] = "[PercentDruidMP:Round]"
settings["lowerText"] = "[FractionalDruidMP:Color('3071bf'):Bracket]"
return settings
end
function DruidMana.prototype:Enable(core)
DruidMana.super.prototype.Enable(self, core)
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM", "Update")
if IceHUD.WowVer >= 40000 then
self:RegisterEvent("UNIT_POWER", "Update")
self:RegisterEvent("UNIT_MAXPOWER", "Update")
else
self:RegisterEvent("UNIT_MAXMANA", "Update")
self:RegisterEvent("UNIT_MANA", "Update")
end
end
function DruidMana.prototype:Disable(core)
DruidMana.super.prototype.Disable(self, core)
end
function DruidMana.prototype:Update()
DruidMana.super.prototype.Update(self)
local forms = (UnitPowerType(self.unit) ~= 0)
self.druidMana = UnitPower(self.unit, MANA_POWER_INDEX)
self.druidManaMax = UnitPowerMax(self.unit, MANA_POWER_INDEX)
if (not self.alive or not forms or not self.druidMana or not self.druidManaMax or self.druidManaMax == 0) then
self:Show(false)
return
else
self:Show(true)
end
self:UpdateBar(self.druidManaMax ~= 0 and self.druidMana / self.druidManaMax or 0, "DruidMana")
end
-- Load us up (if we are a druid)
local _, unitClass = UnitClass("player")
if (unitClass == "DRUID") then
IceHUD.DruidMana = DruidMana:new()
end

View File

@ -1,53 +0,0 @@
local MonkManaBar = IceCore_CreateClass(IceHUDPlayerAlternatePower)
function MonkManaBar.prototype:init(moduleName, unit)
MonkManaBar.super.prototype.init(self, "MonkMana", unit)
self.bTreatEmptyAsFull = false
end
function MonkManaBar.prototype:GetDefaultSettings()
local settings = MonkManaBar.super.prototype.GetDefaultSettings(self)
settings["upperText"] = "[PercentMonkMP:Round]"
settings["lowerText"] = "[Concatenate(MonkMP:Short, \"/\", MaxMonkMP:Short):Bracket]"
return settings
end
function MonkManaBar.prototype:GetOptions()
local opts = MonkManaBar.super.prototype.GetOptions(self)
opts.showBlizz = nil
opts.hideBlizz = nil
return opts
end
function MonkManaBar.prototype:Enable(core)
self.specRestriction = SPEC_MONK_MISTWEAVER
self.powerIndex = SPELL_POWER_MANA
self:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED", "CheckShouldShowOnSpecChange")
self:RegisterEvent("UNIT_DISPLAYPOWER", "CheckShouldShowOnSpecChange")
MonkManaBar.super.prototype.Enable(self, core)
self:CheckShouldShowOnSpecChange(nil, self.unit)
end
function MonkManaBar.prototype:CheckShouldShowOnSpecChange(event, unit)
if unit ~= self.unit and event ~= "PLAYER_SPECIALIZATION_CHANGED" then
return
end
if GetSpecialization() == self.specRestriction then
self:PowerBarShow(event, self.unit)
else
self:PowerBarHide(event, self.unit)
end
end
-- Load us up
if select(2, UnitClass("player")) == "MONK" then
IceHUD.MonkManaBar = MonkManaBar:new()
end

89
modules/PlayerAltMana.lua Normal file
View File

@ -0,0 +1,89 @@
local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
local PlayerAltMana = IceCore_CreateClass(IceUnitBar)
PlayerAltMana.prototype.PlayerAltMana = nil
PlayerAltMana.prototype.PlayerAltManaMax = nil
local _, unitClass = UnitClass("player")
-- Constructor --
function PlayerAltMana.prototype:init()
PlayerAltMana.super.prototype.init(self, "PlayerAltMana", "player")
self.side = IceCore.Side.Right
self.offset = 0
self:SetDefaultColor("PlayerAltMana", 87, 82, 141)
end
function PlayerAltMana.prototype:GetDefaultSettings()
local settings = PlayerAltMana.super.prototype.GetDefaultSettings(self)
settings["side"] = IceCore.Side.Right
settings["offset"] = 0
settings["textVisible"] = {upper = true, lower = false}
settings["upperText"] = "[PercentMana:Round]"
settings["lowerText"] = "[FractionalMana:Color('3071bf'):Bracket]"
return settings
end
function GetEventsToRegister()
if unitClass == "PRIEST" then
return {"PLAYER_TALENT_UPDATE"}
elseif unitClass == "SHAMAN" then
return {"PLAYER_TALENT_UPDATE"}
elseif unitClass == "DRUID" then
return {"UPDATE_SHAPESHIFT_FORM"}
end
end
function PlayerAltMana.prototype:Enable(core)
PlayerAltMana.super.prototype.Enable(self, core)
local eventsToRegister = GetEventsToRegister()
for i = 1, #eventsToRegister do
self:RegisterEvent(eventsToRegister[i], "Update")
end
self:RegisterEvent("UNIT_POWER", "Update")
self:RegisterEvent("UNIT_MAXPOWER", "Update")
end
function PlayerAltMana.prototype:Disable(core)
PlayerAltMana.super.prototype.Disable(self, core)
end
function ShouldShow(unit)
return UnitPowerType(unit) ~= SPELL_POWER_MANA
--[[ if unitClass == "PRIEST" then
return UnitPowerType(unit) == SPELL_POWER_INSANITY
elseif unitClass == "SHAMAN" then
return GetSpecialization() ~= SPEC_SHAMAN_RESTORATION
elseif unitClass == "DRUID" then
return UnitPowerType(unit) ~= SPELL_POWER_MANA
end
]]-- probably not necessary, but could use as a fallback
end
function PlayerAltMana.prototype:Update()
PlayerAltMana.super.prototype.Update(self)
self.PlayerAltMana = UnitPower(self.unit, SPELL_POWER_MANA)
self.PlayerAltManaMax = UnitPowerMax(self.unit, SPELL_POWER_MANA)
if (not self.alive or not ShouldShow(self.unit) or not self.PlayerAltMana or not self.PlayerAltManaMax or self.PlayerAltManaMax == 0) then
self:Show(false)
return
else
self:Show(true)
end
self:UpdateBar(self.PlayerAltManaMax ~= 0 and self.PlayerAltMana / self.PlayerAltManaMax or 0, "PlayerAltMana")
end
if (unitClass == "PRIEST" and IceHUD.WowVer >= 70000)
or (unitClass == "DRUID")
or (unitClass == "SHAMAN" and IceHUD.WowVer >= 70000) then
IceHUD.PlayerAltMana = PlayerAltMana:new()
end

View File

@ -1,69 +0,0 @@
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 priest in 7.0+)
local _, unitClass = UnitClass("player")
if (unitClass == "PRIEST" and IceHUD.WowVer >= 70000) then
IceHUD.ShadowPriestMana = ShadowPriestMana:new()
end