Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WH attempt #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions BagValueTracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ local function UpdateBagValues(bagID)
end
end

-- Function to update the slots overlay for closed bags
-- Function to update the slots overlay for closed bags
-- Function to update the slots overlay for bags
local function UpdateBagSlotOverlays()
-- Update inventory bags
for bagID = 0, NUM_BAG_SLOTS do
local bagIcon = _G["CharacterBag" .. (bagID - 1) .. "Slot"]
if bagIcon then
Expand All @@ -124,6 +124,34 @@ local function UpdateBagSlotOverlays()
bagSlotTexts[bagID]:SetTextColor(1, 1, 1)
end
end

-- Update bank bags
if BankFrame:IsShown() then
for bagID = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do
local bankBagID = bagID - NUM_BAG_SLOTS
local bagIcon = _G["BankFrameBag" .. bankBagID]
if bagIcon then
local usedSlots = 0
local totalSlots = C_Container.GetContainerNumSlots(bagID)

if totalSlots and totalSlots > 0 then
for slotID = 1, totalSlots do
local itemInfo = C_Container.GetContainerItemInfo(bagID, slotID)
if itemInfo and itemInfo.itemID then
usedSlots = usedSlots + 1
end
end
end

if not bagSlotTexts[bagID] then
bagSlotTexts[bagID] = bagIcon:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
bagSlotTexts[bagID]:SetPoint("TOP", bagIcon, "TOP", 0, 15) -- Adjust vertical offset for spacing
end
bagSlotTexts[bagID]:SetText(string.format("%d/%d", usedSlots, totalSlots))
bagSlotTexts[bagID]:SetTextColor(1, 1, 1)
end
end
end
end

-- Event handler function
Expand All @@ -137,6 +165,10 @@ local function OnEvent(self, event, bagID)
UpdateBagSlotOverlays()
elseif event == "PLAYER_LOGIN" then
UpdateBagSlotOverlays()
elseif event == "BANKFRAME_OPENED" then
UpdateBagSlotOverlays()
elseif event == "BANKFRAME_CLOSED" then
UpdateBagSlotOverlays()
end
end

Expand All @@ -145,4 +177,6 @@ frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("BAG_OPEN")
frame:RegisterEvent("BAG_CLOSED")
frame:RegisterEvent("BAG_UPDATE")
frame:RegisterEvent("BANKFRAME_OPENED")
frame:RegisterEvent("BANKFRAME_CLOSED")
frame:SetScript("OnEvent", OnEvent)