Skip to content

Commit

Permalink
[Feature] Add "classification:icon" tag (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Dec 17, 2024
1 parent 3831d72 commit 0349dbb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Util/Utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ function Util:GetUnitSubgroup(unit)
end
end

---@param unit UnitToken
---@param localized boolean
---@return string? classification
function Util:GetUnitClassification(unit, localized)
local classification = UnitClassification(unit)
if localized then
Expand All @@ -675,6 +678,15 @@ function Util:GetUnitClassification(unit, localized)
return classification
end

local gold, silver = "|A:nameplates-icon-elite-gold:16:16|a", "|A:nameplates-icon-elite-silver:16:16|a"
local typeIcon = { elite = gold, worldboss = gold, rareelite = silver, rare = silver }

---@param unit UnitToken
---@return string? icon
function Util:GetUnitClassificationIcon(unit)
return typeIcon[UnitClassification(unit)]
end

-------------------------------------------------
-- MARK: Frames
-------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions Widgets/Texts/CustomFormats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,10 @@ end, "Group", "1-8")
W:AddTag("classification", "UNIT_CLASSIFICATION_CHANGED", function(unit)
return Util:GetUnitClassification(unit, true)
end, "Classification", (L.rare .. ", " .. L.rareelite .. ", " .. L.elite .. ", " .. L.worldboss))
W:AddTag("classification:icon", "UNIT_CLASSIFICATION_CHANGED", function(unit)
if UnitIsPlayer(unit) then return end
return Util:GetUnitClassificationIcon(unit)
end, "Classification")

-- MARK: Name
for type, length in pairs(nameLengths) do
Expand Down

0 comments on commit 0349dbb

Please sign in to comment.