Skip to content

Commit ed6326a

Browse files
committed
refactor: improve Collections pet display with icons, health percentage, and visual spacing
Rework pet tooltip lines to show pet icons instead of raw numbers, return healthPct from API instead of separate health/maxHealth values, display "Dead" label for 0% health, and add an empty line separator before the pet list. Remove unused L["X / Y HP"] locale string.
1 parent e2c2323 commit ed6326a

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

GameAPI/Collections.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ function Collections:GetLoadedPetsInfo()
6666
pets = pets or {}
6767
pets[#pets + 1] = {
6868
name = (customName and customName ~= "") and customName or name,
69-
health = health,
70-
maxHealth = maxHealth,
69+
healthPct = (maxHealth > 0) and (health / maxHealth) or 0,
7170
icon = icon
7271
}
7372
end
@@ -83,7 +82,7 @@ function Collections:HasDeadPets()
8382
end
8483
local deadCount = 0
8584
for _, pet in ipairs(pets) do
86-
if pet.health == 0 then
85+
if pet.healthPct == 0 then
8786
deadCount = deadCount + 1
8887
end
8988
end

Locales/enUS.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ L["N/A"] = "N/A"
3737
L["None"] = "|cffa0a0a0None|r"
3838
L["Dead Pets!"] = "|cffff0000Dead Pets!|r"
3939
L["Pets: X"] = "Pets: |cffffffff%d|r"
40-
L["X / Y HP"] = "%d / %d HP"
4140
L["Player vs. Player (Preseason)"] = "Player vs. Player (Preseason)"
4241
L["Professions:"] = "Professions:"
4342
L["PvP Progress:"] = "PvP Progress:"

UI/Tooltips/Collections.lua

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local Tooltip = addon:NewTooltip("Collections")
66
local L = addon.L
77

88
local ACHIEVEMENT_LINE_FORMAT = "- %s: |cffffffff%d|r / |cff20ff20%d|r"
9+
local PET_LINE_FORMAT = "|T%s:0|t %s"
910

1011
function Tooltip:AddAchievementLine(callback)
1112
local name, currAmount, reqAmount = callback()
@@ -38,13 +39,17 @@ Tooltip.target = {
3839

3940
local pets = Collections:GetLoadedPetsInfo()
4041
if pets then
42+
Tooltip:AddEmptyLine()
4143
for _, pet in ipairs(pets) do
42-
local healthText = L["X / Y HP"]:format(pet.health, pet.maxHealth)
43-
Tooltip:SetDoubleLine(pet.name, healthText)
44-
if pet.health == 0 then
45-
Tooltip:SetRedColor()
46-
elseif pet.health == pet.maxHealth then
47-
Tooltip:SetGreenColor()
44+
Tooltip
45+
:SetFormattedLine(PET_LINE_FORMAT, pet.icon, pet.name)
46+
:Indent()
47+
if pet.healthPct == 0 then
48+
Tooltip:SetLine(DEAD):SetRedColor()
49+
elseif pet.healthPct == 1 then
50+
Tooltip:SetLine(FormatPercentage(pet.healthPct)):SetGreenColor()
51+
else
52+
Tooltip:SetLine(FormatPercentage(pet.healthPct))
4853
end
4954
Tooltip:ToLine()
5055
end

0 commit comments

Comments
 (0)