diff --git a/Core/Utils.lua b/Core/Utils.lua index 96fea88..000cda9 100644 --- a/Core/Utils.lua +++ b/Core/Utils.lua @@ -128,6 +128,14 @@ function Utils:GetBagSlotCount(bagID) if bagID == -1 then -- Bank has 24 slots in vanilla return 24 + elseif bagID == -2 then + -- Keyring - vanilla WoW has 12-32 slots depending on version + local slots = GetContainerNumSlots(bagID) + if not slots or slots == 0 then + -- Fallback: keyring typically has 12 slots in vanilla + return 12 + end + return slots else return GetContainerNumSlots(bagID) or 0 end @@ -135,7 +143,7 @@ end -- Check if bag is valid function Utils:IsBagValid(bagID) - if bagID == 0 or bagID == -1 then + if bagID == 0 or bagID == -1 or bagID == -2 then return true end return GetContainerNumSlots(bagID) and GetContainerNumSlots(bagID) > 0 diff --git a/Data/BagScanner.lua b/Data/BagScanner.lua index 12f8561..3e266d5 100644 --- a/Data/BagScanner.lua +++ b/Data/BagScanner.lua @@ -10,10 +10,14 @@ addon.Modules.BagScanner = BagScanner function BagScanner:ScanBags() local bagData = {} + -- Scan regular bags for _, bagID in ipairs(addon.Constants.BAGS) do bagData[bagID] = self:ScanBag(bagID) end + -- Also scan keyring (bagID -2) + bagData[-2] = self:ScanBag(-2) + return bagData end diff --git a/UI/BagFrame.lua b/UI/BagFrame.lua index 6b12d22..ce03aff 100644 --- a/UI/BagFrame.lua +++ b/UI/BagFrame.lua @@ -9,6 +9,7 @@ addon.Modules.BagFrame = BagFrame local currentViewChar = nil -- nil = current character local searchText = "" local itemButtons = {} +local showKeyring = false -- Toggle for keyring display -- Global click catcher for clearing search focus local clickCatcher = nil @@ -153,6 +154,9 @@ function BagFrame:Update() -- Update money self:UpdateMoney() + + -- Update bag slots info + self:UpdateBagSlotsInfo(bagData, isOtherChar) end -- Display items @@ -165,9 +169,32 @@ function BagFrame:DisplayItems(bagData, isOtherChar, charName) local perRow = addon.Modules.DB:GetSetting("bagColumns") or 10 local itemContainer = getglobal("Guda_BagFrame_ItemContainer") + -- Build bag list - include keyring if toggled on + local bagsToShow = {} for _, bagID in ipairs(addon.Constants.BAGS) do + table.insert(bagsToShow, bagID) + end + + -- Add keyring (-2) at the end if toggled on + if showKeyring then + table.insert(bagsToShow, -2) -- Insert at end + end + + for _, bagID in ipairs(bagsToShow) do local bag = bagData[bagID] + -- Add spacing before keyring section + if bagID == -2 then + -- Add spacing before keyring + if col > 0 then + -- Move to next row if not at start of row + col = 0 + row = row + 1 + end + -- Add extra spacing (1 row) + row = row + 1 + end + -- Get slot count for this bag local numSlots if isOtherChar and bag and bag.numSlots then @@ -380,6 +407,47 @@ function BagFrame:UpdateMoney() end end +-- Update bag slots info text (excluding keyring) +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 + + -- Count slots in regular bags only (0-4), exclude keyring (-2) + for _, bagID in ipairs(addon.Constants.BAGS) do + local bag = bagData[bagID] + + -- Get slot count for this bag + local numSlots + if isOtherChar and bag and bag.numSlots then + numSlots = bag.numSlots + else + numSlots = addon.Modules.Utils:GetBagSlotCount(bagID) + end + + if numSlots and numSlots > 0 then + totalSlots = totalSlots + numSlots + + -- Count used slots + if bag and bag.slots then + for slot = 1, numSlots do + if bag.slots[slot] then + usedSlots = usedSlots + 1 + end + end + end + end + end + + local freeSlots = totalSlots - usedSlots + + -- Format: "56 / 80" (free / total) + infoText:SetText(string.format("%d / %d", freeSlots, totalSlots)) + infoText:SetTextColor(0.7, 0.7, 0.7) +end + function BagFrame:CreateMoneyFrame() local moneyFrame = CreateFrame("Frame", "Guda_BagFrame_MoneyFrame", Guda_BagFrame, "SmallMoneyFrameTemplate") moneyFrame:SetPoint("BOTTOMRIGHT", Guda_BagFrame, "BOTTOMRIGHT", -15, 10) @@ -738,6 +806,29 @@ function Guda_BagFrame_OnSearchChanged(self) end end +-- Keyring toggle handler +function Guda_BagFrame_ToggleKeyring() + showKeyring = not showKeyring + + -- Update button appearance to show toggle state + local button = getglobal("Guda_BagFrame_Toolbar_KeyringButton") + if button then + local icon = getglobal(button:GetName().."_Icon") + if icon then + if showKeyring then + -- Highlighted when active + icon:SetVertexColor(1.0, 1.0, 0.5) + else + -- Normal color when inactive + icon:SetVertexColor(0.8, 0.8, 0.8) + end + end + end + + -- Refresh display + BagFrame:Update() +end + -- Sort button handler function Guda_BagFrame_Sort() if currentViewChar then diff --git a/UI/BagFrame.xml b/UI/BagFrame.xml index 66a0bd1..c1e7b46 100644 --- a/UI/BagFrame.xml +++ b/UI/BagFrame.xml @@ -273,7 +273,88 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + local text = getglobal(this:GetName().."_Text") + if text then + text:SetText("0 / 0") + text:SetTextColor(0.8, 0.8, 0.8) + end + + + diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index 4933a48..0c62310 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -164,8 +164,12 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha countText:Hide() end - -- Set quality border - if itemData.quality and itemData.quality > 1 then + -- Set quality border (or keyring border) + if bagID == -2 then + -- Special border for keyring items (cyan/blue) + qualityBorder:SetVertexColor(0.2, 0.8, 1.0, 1) + qualityBorder:Show() + elseif itemData.quality and itemData.quality > 1 then local r, g, b = addon.Modules.Utils:GetQualityColor(itemData.quality) qualityBorder:SetVertexColor(r, g, b, 1) qualityBorder:Show() @@ -202,7 +206,15 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha end countText:Hide() - qualityBorder:Hide() + + -- Show border for empty keyring slots + if bagID == -2 then + qualityBorder:SetVertexColor(0.2, 0.8, 1.0, 0.5) -- Dimmer cyan for empty slots + qualityBorder:Show() + else + qualityBorder:Hide() + end + self:Show() end