Files
ice-hud/modules/TargetOfTargetMana.lua
Parnic c5c44edf64 Fix several issues with low thresholds
This addresses a user-reported issue where Low Threshold was not usable with Color By Health/Mana % disabled, due to some internal technical reasons. This was exacerbated by the recent fix that allowed Low Threshold and Color By Health % to work together.

This also fixes the low threshold flash to apply immediately when changing the option, and fixes the Low Threshold % slider to be usable without the Low Flash option set.

Finally, it hides the Low Flash option for bars that don't support it (right now that's just PlayerMana, I think because it only sets the low threshold to the Min Mana Color even if the class uses a different power type...something for future me...).

Fixes wowace ticket #334
2022-12-13 20:48:02 -06:00

109 lines
3.1 KiB
Lua

local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
local TargetTargetMana = IceCore_CreateClass(IceTargetMana)
TargetTargetMana.prototype.scheduledEvent = nil
local SelfDisplayModeOptions = {"Hide", "Normal"}
-- Constructor --
function TargetTargetMana.prototype:init()
TargetTargetMana.super.prototype.init(self, "TargetTargetMana", "targettarget")
self:SetDefaultColor("TargetTargetMana", 52, 64, 221)
self:SetDefaultColor("TargetTargetRage", 235, 44, 26)
self:SetDefaultColor("TargetTargetEnergy", 228, 242, 31)
self:SetDefaultColor("TargetTargetFocus", 242, 149, 98)
self:SetDefaultColor("TargetTargetRunicPower", 52, 64, 221)
end
function TargetTargetMana.prototype:GetDefaultSettings()
local settings = TargetTargetMana.super.prototype.GetDefaultSettings(self)
settings["side"] = IceCore.Side.Right
settings["offset"] = 11
settings["upperText"] = "[PercentMP:Round]"
settings["lowerText"] = "[FractionalMP:Short:PowerColor]"
settings["barVerticalOffset"] = 35
settings["scale"] = 0.7
settings["enabled"] = false
settings["selfDisplayMode"] = "Normal"
return settings
end
function TargetTargetMana.prototype:GetOptions()
local opts = TargetTargetMana.super.prototype.GetOptions(self)
opts["selfDisplayMode"] = {
type = 'select',
name = L["Self Display Mode"],
desc = L["What this bar should do whenever the player is the TargetOfTarget"],
get = function(info)
return IceHUD:GetSelectValue(info, self.moduleSettings.selfDisplayMode)
end,
set = function(info, value)
self.moduleSettings.selfDisplayMode = info.option.values[value]
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
values = SelfDisplayModeOptions,
order = 44,
}
return opts
end
function TargetTargetMana.prototype:Enable(core)
self.registerEvents = false
-- make sure the super class doesn't override our color selection
self.determineColor = false
TargetTargetMana.super.prototype.Enable(self, core)
self.scheduledEvent = self:ScheduleRepeatingTimer("Update", 0.1, "targettarget")
end
function TargetTargetMana.prototype:Disable(core)
TargetTargetMana.super.prototype.Disable(self, core)
self:CancelTimer(self.scheduledEvent, true)
end
function TargetTargetMana.prototype:Update(unit)
self.color = "TargetTargetMana"
if self.moduleSettings.selfDisplayMode == "Hide" and UnitIsUnit("player", self.unit) then
self:Show(false)
return
end
self:Show(true)
local manaType = UnitPowerType(self.unit)
if (self.moduleSettings.scaleManaColor) then
self.color = "ScaledManaColor"
elseif self.moduleSettings.lowThresholdColor and self.manaPercentage <= self.moduleSettings.lowThreshold then
self.color = "ScaledManaColor"
end
if (manaType == 1) then
self.color = "TargetTargetRage"
elseif (manaType == 2) then
self.color = "TargetTargetFocus"
elseif (manaType == 3) then
self.color = "TargetTargetEnergy"
elseif (manaType == 6) then
self.color = "TargetTargetRunicPower"
end
if (self.tapped) then
self.color = "Tapped"
end
TargetTargetMana.super.prototype.Update(self, unit)
end
-- Load us up
IceHUD.TargetTargetMana = TargetTargetMana:new()