Add module showing Energy for Druids

This shows the player's current Energy amount when they're in a form that doesn't use Energy. For example, this could show the user how much energy they currently have while they're in Bear form so that they can shift away and wait on their energy to refill.

Note: requires a new version of LibDogTag-Unit for the bar text tags to function if DogTags are enabled.
This commit is contained in:
Parnic
2022-11-18 17:08:26 -06:00
parent 70bba2f186
commit d775603ec0
4 changed files with 126 additions and 0 deletions

View File

@ -100,6 +100,7 @@ modules\PlayerAltMana.lua
modules\ArcaneCharges.lua modules\ArcaneCharges.lua
modules\RollTheBones.lua modules\RollTheBones.lua
modules\EssencePower.lua modules\EssencePower.lua
modules\DruidEnergy.lua
#@do-not-package@ #@do-not-package@
IceHUD_Options\Json.lua IceHUD_Options\Json.lua

View File

@ -4,6 +4,7 @@ v1.14.6:
- Add ability for buff/debuff watchers to only display when the specified buff/debuff is missing. This also adds the ability to require that the given unit exists. So if you had Unit set to Target, Display mode set to Missing, and Only if unit exists checked, you'd show the bar if you have a target and they don't have the given buff/debuff. - Add ability for buff/debuff watchers to only display when the specified buff/debuff is missing. This also adds the ability to require that the given unit exists. So if you had Unit set to Target, Display mode set to Missing, and Only if unit exists checked, you'd show the bar if you have a target and they don't have the given buff/debuff.
- Don't flash the castbar for instant-cast spells that the player didn't cast (such as internal quest spells). - Don't flash the castbar for instant-cast spells that the player didn't cast (such as internal quest spells).
- Add DruidEnergy module (disabled by default). This module will show the player's Energy level if they're a Druid and currently shapeshifted to a non-energy-using form (eligible forms are configurable by the user).
v1.14.5: v1.14.5:

123
modules/DruidEnergy.lua Normal file
View File

@ -0,0 +1,123 @@
local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
local DruidEnergy = IceCore_CreateClass(IceUnitBar)
DruidEnergy.prototype.DruidEnergy = nil
DruidEnergy.prototype.DruidEnergyMax = nil
local _, unitClass = UnitClass("player")
local FORM_NONE = 0
local FORM_BEAR = 1
local FORM_TRAVEL = 3
local SPELL_POWER_ENERGY = SPELL_POWER_ENERGY
if Enum and Enum.PowerType then
SPELL_POWER_ENERGY = Enum.PowerType.Energy
end
local shapeshiftFormValues = {NONE = L["No form"], BEAR = L["Bear"], TRAVEL = L["Travel"], OTHER = L["Other"]}
local shapeshiftFormIds = {NONE = FORM_NONE, BEAR = FORM_BEAR, TRAVEL = FORM_TRAVEL}
function DruidEnergy.prototype:init()
DruidEnergy.super.prototype.init(self, "DruidEnergy", "player")
self.side = IceCore.Side.Left
self.offset = 5
self:SetDefaultColor("DruidEnergy", 218, 231, 31)
end
function DruidEnergy.prototype:GetDefaultSettings()
local settings = DruidEnergy.super.prototype.GetDefaultSettings(self)
settings["side"] = IceCore.Side.Left
settings["offset"] = 5
settings["textVisible"] = {upper = true, lower = false}
settings["upperText"] = "[PercentMP(type='Energy'):Round]"
settings["lowerText"] = "[FractionalMP(type='Energy'):Color('dae71f'):Bracket]"
settings.enabled = false
settings.whileInForm = {["BEAR"] = true}
return settings
end
function DruidEnergy.prototype:GetOptions()
local opts = DruidEnergy.super.prototype.GetOptions(self)
opts["whileInForm"] = {
type = 'multiselect',
values = shapeshiftFormValues,
name = L["Show in form"],
desc = L["When the player is in one of the chosen shapeshift forms the bar will be shown, otherwise it will be hidden."],
get = function(info, v)
for key, value in pairs(self.moduleSettings.whileInForm) do
if key == v then
return value
end
end
return false
end,
set = function(info, v, state)
self.moduleSettings.whileInForm[v] = state
self:Update()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
}
return opts
end
function DruidEnergy.prototype:Enable(core)
DruidEnergy.super.prototype.Enable(self, core)
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM", "Update")
self:RegisterEvent("UNIT_POWER_FREQUENT", "Update")
self:RegisterEvent("UNIT_MAXPOWER", "Update")
end
function DruidEnergy.prototype:GetElementDescription()
return L["Always shows the Druid's Energy level while in non-energy-using forms."]
end
function DruidEnergy.prototype:ShouldShow(unit)
local currentForm = GetShapeshiftForm()
for k, v in pairs(self.moduleSettings.whileInForm) do
if currentForm > FORM_TRAVEL and k == "OTHER" then
return v
elseif currentForm == shapeshiftFormIds[k] then
return v
end
end
return false
end
function DruidEnergy.prototype:Update()
DruidEnergy.super.prototype.Update(self)
self.DruidEnergy = UnitPower(self.unit, SPELL_POWER_ENERGY)
self.DruidEnergyMax = UnitPowerMax(self.unit, SPELL_POWER_ENERGY)
self.DruidEnergyPercentage = self.DruidEnergyMax ~= 0 and (self.DruidEnergy/self.DruidEnergyMax) or 0
if (not self.alive or not self:ShouldShow(self.unit) or not self.DruidEnergy or not self.DruidEnergyMax or self.DruidEnergyMax == 0) then
self:Show(false)
return
else
self:Show(true)
end
if not IceHUD.IceCore:ShouldUseDogTags() and self.frame:IsVisible() then
self:SetBottomText1(math.floor(self.DruidEnergyPercentage * 100))
self:SetBottomText2(self:GetFormattedText(self:Round(self.DruidEnergy), self:Round(self.DruidEnergyMax)), "DruidEnergy")
end
self:UpdateBar(self.DruidEnergyMax ~= 0 and self.DruidEnergy / self.DruidEnergyMax or 0, "DruidEnergy")
end
if unitClass == "DRUID" then
IceHUD.DruidEnergy = DruidEnergy:new()
end

View File

@ -4,6 +4,7 @@ v1.14.6:
- Add ability for buff/debuff watchers to only display when the specified buff/debuff is missing. This also adds the ability to require that the given unit exists. So if you had Unit set to Target, Display mode set to Missing, and Only if unit exists checked, you'd show the bar if you have a target and they don't have the given buff/debuff. - Add ability for buff/debuff watchers to only display when the specified buff/debuff is missing. This also adds the ability to require that the given unit exists. So if you had Unit set to Target, Display mode set to Missing, and Only if unit exists checked, you'd show the bar if you have a target and they don't have the given buff/debuff.
- Don't flash the castbar for instant-cast spells that the player didn't cast (such as internal quest spells). - Don't flash the castbar for instant-cast spells that the player didn't cast (such as internal quest spells).
- Add DruidEnergy module (disabled by default). This module will show the player's Energy level if they're a Druid and currently shapeshifted to a non-energy-using form (eligible forms are configurable by the user).
v1.14.5: v1.14.5: