Skip to content

Commit

Permalink
Make Power tags use generic FormatText fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Feb 10, 2025
1 parent 7e10da8 commit 0257f1d
Showing 1 changed file with 20 additions and 36 deletions.
56 changes: 20 additions & 36 deletions Widgets/Texts/CustomFormats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -610,62 +610,46 @@ end, "Health", "40%")

-- MARK: Power
W:AddTag("curpp", "UNIT_POWER_FREQUENT UNIT_DISPLAYPOWER", function(unit)
local powerType = UnitPowerType(unit)
local power = UnitPower(unit, powerType)
return FormatNumber(power)
return FormatText(UnitPower(unit))
end, "Power", "12000")
W:AddTag("curpp:short", "UNIT_POWER_FREQUENT UNIT_DISPLAYPOWER", function(unit)
local powerType = UnitPowerType(unit)
local power = UnitPower(unit, powerType)
return FormatNumberShort(power)
return FormatText(UnitPower(unit), nil, false, true)
end, "Power", "12K")
W:AddTag("perpp", "UNIT_POWER_FREQUENT UNIT_DISPLAYPOWER UNIT_MAXPOWER", function(unit)
local powerType = UnitPowerType(unit)
local power = UnitPower(unit, powerType)
local maxPower = UnitPowerMax(unit, powerType)
return FormatPercent(maxPower, power)
return FormatText(UnitPowerMax(unit), UnitPower(unit), true)
end, "Power", "80.20%")
W:AddTag("perpp:short", "UNIT_POWER_FREQUENT UNIT_DISPLAYPOWER UNIT_MAXPOWER", function(unit)
local powerType = UnitPowerType(unit)
local power = UnitPower(unit, powerType)
local maxPower = UnitPowerMax(unit, powerType)
return FormatPercentShort(maxPower, power)
return FormatText(UnitPowerMax(unit), UnitPower(unit), true, true)
end, "Power", "80%")

W:AddTag("maxpp", "UNIT_DISPLAYPOWER UNIT_MAXPOWER", function(unit)
local powerType = UnitPowerType(unit)
local maxPower = UnitPowerMax(unit, powerType)
return FormatNumber(maxPower)
return FormatText(UnitPowerMax(unit))
end, "Power", "15000")
W:AddTag("maxpp:short", "UNIT_DISPLAYPOWER UNIT_MAXPOWER", function(unit)
local powerType = UnitPowerType(unit)
local maxPower = UnitPowerMax(unit, powerType)
return FormatNumberShort(maxPower)
return FormatText(UnitPowerMax(unit), nil, false, true)
end, "Power", "15K")

W:AddTag("defpp", "UNIT_POWER_FREQUENT UNIT_DISPLAYPOWER UNIT_MAXPOWER", function(unit)
local powerType = UnitPowerType(unit)
local power = UnitPower(unit, powerType)
local maxPower = UnitPowerMax(unit, powerType)
return FormatNumberNoZeroes(power - maxPower)
local deficit = UnitPower(unit) - UnitPowerMax(unit)
if not deficit or deficit == 0 then return end
return FormatText(deficit)
end, "Power", "-3000")
W:AddTag("defpp:short", "UNIT_POWER_FREQUENT UNIT_DISPLAYPOWER UNIT_MAXPOWER", function(unit)
local powerType = UnitPowerType(unit)
local power = UnitPower(unit, powerType)
local maxPower = UnitPowerMax(unit, powerType)
return FormatNumberShortNoZeroes(power - maxPower)
local deficit = UnitPower(unit) - UnitPowerMax(unit)
if not deficit or deficit == 0 then return end
return FormatText(deficit, nil, false, true)
end, "Power", "-3K")
W:AddTag("perdefpp", "UNIT_POWER_FREQUENT UNIT_DISPLAYPOWER UNIT_MAXPOWER", function(unit)
local powerType = UnitPowerType(unit)
local power = UnitPower(unit, powerType)
local maxPower = UnitPowerMax(unit, powerType)
return FormatPercentNoZeroes(maxPower, (power - maxPower))
local max = UnitPowerMax(unit)
local deficit = UnitPower(unit) - max
if not deficit or deficit == 0 then return end
return FormatText(max, deficit, true)
end, "Power", "-20.20%")
W:AddTag("perdefpp:short", "UNIT_POWER_FREQUENT UNIT_DISPLAYPOWER UNIT_MAXPOWER", function(unit)
local powerType = UnitPowerType(unit)
local power = UnitPower(unit, powerType)
local maxPower = UnitPowerMax(unit, powerType)
return FormatPercentShortNoZeroes(maxPower, (power - maxPower))
local max = UnitPowerMax(unit)
local deficit = UnitPower(unit) - max
if not deficit or deficit == 0 then return end
return FormatText(max, deficit, true, true)
end, "Power", "-20%")

-- MARK: Group
Expand Down

0 comments on commit 0257f1d

Please sign in to comment.