feat: bag counter tooltip

This commit is contained in:
Vati
2026-02-28 05:59:11 +04:00
parent 19a428dc8a
commit 87b752db00
+71 -8
View File
@@ -1556,15 +1556,25 @@ function BagFrame:UpdateMoney()
end
end
-- Update bag slots info text (excluding keyring)
-- Bag type display names
local BAG_TYPE_NAMES = {
soul = "Soul Bag",
herb = "Herb Bag",
enchant = "Enchanting Bag",
quiver = "Quiver",
ammo = "Ammo Pouch",
}
-- Update bag slots info text (show only regular bags, special bags in tooltip)
function BagFrame:UpdateBagSlotsInfo(bagData, isOtherChar)
local infoText = getglobal("Guda_BagFrame_Toolbar_BagSlotsInfo_Text")
if not infoText then return end
local totalSlots = 0
local usedSlots = 0
local regularTotal = 0
local regularUsed = 0
local specialBags = {} -- { [type] = { total, used, name } }
-- Count slots in regular bags only (0-4), exclude keyring (-2)
-- Count slots in bags 0-4, separating regular from special
for _, bagID in ipairs(addon.Constants.BAGS) do
local bag = bagData[bagID]
@@ -1577,22 +1587,75 @@ function BagFrame:UpdateBagSlotsInfo(bagData, isOtherChar)
end
if numSlots and numSlots > 0 then
totalSlots = totalSlots + numSlots
-- Determine if this is a special bag
local bagType = nil
if not isOtherChar then
bagType = addon.Modules.Utils:GetSpecializedBagType(bagID)
elseif bag and bag.bagType and bag.bagType ~= "regular" then
bagType = bag.bagType
end
-- Count used slots
local used = 0
if bag and bag.slots then
for slot = 1, numSlots do
if bag.slots[slot] then
usedSlots = usedSlots + 1
used = used + 1
end
end
end
if bagType then
-- Special bag
if not specialBags[bagType] then
specialBags[bagType] = { total = 0, used = 0, name = BAG_TYPE_NAMES[bagType] or bagType }
end
specialBags[bagType].total = specialBags[bagType].total + numSlots
specialBags[bagType].used = specialBags[bagType].used + used
else
-- Regular bag
regularTotal = regularTotal + numSlots
regularUsed = regularUsed + used
end
end
end
-- Format: "24 / 80" (used / total)
infoText:SetText(string.format("%d / %d", usedSlots, totalSlots))
-- Format: "24 / 80" (used / total) - regular bags only
infoText:SetText(string.format("%d / %d", regularUsed, regularTotal))
infoText:SetTextColor(0.7, 0.7, 0.7)
-- Store data for tooltip
local infoFrame = getglobal("Guda_BagFrame_Toolbar_BagSlotsInfo")
if infoFrame then
infoFrame.regularTotal = regularTotal
infoFrame.regularUsed = regularUsed
infoFrame.specialBags = specialBags
-- Setup tooltip scripts if not already done
if not infoFrame.tooltipSetup then
infoFrame:EnableMouse(true)
infoFrame:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_TOP")
GameTooltip:AddLine("Bag Slots", 1, 1, 1)
GameTooltip:AddLine(" ")
-- Regular bags
if this.regularTotal then
GameTooltip:AddDoubleLine("Regular Bags:", string.format("%d / %d", this.regularUsed, this.regularTotal), 1, 1, 1, 0.8, 0.8, 0.8)
end
-- Special bags
if this.specialBags then
for bagType, data in pairs(this.specialBags) do
GameTooltip:AddDoubleLine(data.name .. ":", string.format("%d / %d", data.used, data.total), 1, 0.82, 0, 0.8, 0.8, 0.8)
end
end
GameTooltip:Show()
end)
infoFrame:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
infoFrame.tooltipSetup = true
end
end
end
function BagFrame:CreateMoneyFrame()