From 601e46c6157fb2d42f56a31337ac2e5c9d673a30 Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Wed, 24 Dec 2025 23:01:43 +0400 Subject: [PATCH] fix: keyring bugs --- Core/Tooltip.lua | 3 ++- UI/BagFrame.lua | 34 ++++++++++++++++++++++++++++++++-- UI/BagFrame.xml | 4 +++- UI/ItemButton.lua | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Core/Tooltip.lua b/Core/Tooltip.lua index cad480d..8663ce8 100644 --- a/Core/Tooltip.lua +++ b/Core/Tooltip.lua @@ -16,7 +16,8 @@ local function CountCurrentCharacterItems(itemID) local equippedCount = 0 -- Count current character's bags in real-time - for bagID = 0, 4 do + local bagsToCount = {0, 1, 2, 3, 4, -2} + for _, bagID in ipairs(bagsToCount) do local numSlots = GetContainerNumSlots(bagID) for slot = 1, numSlots do local link = GetContainerItemLink(bagID, slot) diff --git a/UI/BagFrame.lua b/UI/BagFrame.lua index c8c8b39..1a57440 100644 --- a/UI/BagFrame.lua +++ b/UI/BagFrame.lua @@ -415,7 +415,7 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) -- Group items by category local categories = {} local categoryList = { - "Weapon", "Armor", "Consumable", "Food", "Drink", "Trade Goods", "Reagent", "Recipe", "Quiver", "Container", "Soul Bag", "Keyring", "Miscellaneous", "Quest", "Junk", "Class Items" + "Weapon", "Armor", "Consumable", "Food", "Drink", "Trade Goods", "Reagent", "Recipe", "Quiver", "Container", "Soul Bag", "Miscellaneous", "Quest", "Junk", "Class Items" } for _, cat in ipairs(categoryList) do categories[cat] = {} end @@ -641,11 +641,12 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) -- Update Y for bottom sections local y = currentY + rowMaxHeight - -- Special sections at bottom (Hearthstone, Mount, Tools, Empty) + -- Special sections at bottom (Hearthstone, Mount, Tools, Keyring, Empty) local bottomSections = { { name = "Home", items = specialItems.Hearthstone }, { name = "Mounts", items = specialItems.Mount }, { name = "Tools", items = specialItems.Tools }, + { name = "Keyring", items = categories["Keyring"] or {} }, { name = "Empty", items = {} } } @@ -671,6 +672,12 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) local numItems = table.getn(items) if sec.name == "Empty" then numItems = (totalFreeSlots > 0) and 1 or 0 + elseif sec.name == "Keyring" then + if showKeyring and not hiddenBags[-2] then + numItems = addon.Modules.Utils:GetBagSlotCount(-2) + else + numItems = 0 + end end if numItems > 0 then -- Sort Tools (Hearthstone/Mounts don't usually need it but good for consistency) @@ -731,6 +738,29 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) -- Ensure it's not actually read-only for drop behavior (it should still receive clicks/drops) button.isReadOnly = false button.inUse = true + elseif sec.name == "Keyring" then + local bagID = -2 + local bagParent = self:GetBagParent(bagID) + local bag = bagData[bagID] + for slot = 1, numItems do + local itemData = bag and bag.slots and bag.slots[slot] or nil + local button = Guda_GetItemButton(bagParent) + button:SetParent(bagParent) + button:SetWidth(buttonSize) + button:SetHeight(buttonSize) + button:ClearAllPoints() + button:SetPoint("TOPLEFT", itemContainer, "TOPLEFT", x + currentBottomX + (sCol * (buttonSize + spacing)), itemY - (sRow * (buttonSize + spacing))) + button:Show() + + Guda_ItemButton_SetItem(button, bagID, slot, itemData, false, isOtherChar and charName or nil, self:PassesSearchFilter(itemData), isOtherChar) + button.inUse = true + + sCol = sCol + 1 + if sCol >= blockCols then + sCol = 0 + sRow = sRow + 1 + end + end else for _, item in ipairs(items) do local bagParent = self:GetBagParent(item.bagID) diff --git a/UI/BagFrame.xml b/UI/BagFrame.xml index 6bf843a..aa887a5 100644 --- a/UI/BagFrame.xml +++ b/UI/BagFrame.xml @@ -499,6 +499,8 @@ -- Optionally tint it cyan to distinguish it SetItemButtonTextureVertexColor(this, 0.7, 1.0, 1.0) + + this:RegisterForClicks("LeftButtonUp", "RightButtonUp") Guda_BagFrame_ToggleKeyring() @@ -508,7 +510,7 @@ GameTooltip:SetText("Keyring", 1.0, 1.0, 1.0) local numSlots = GetContainerNumSlots(-2) or 0 GameTooltip:AddLine(string.format("%d Slots", numSlots), 0.8, 0.8, 0.8) - GameTooltip:AddLine("(Click to toggle)", 0.5, 0.8, 0.5) + GameTooltip:AddLine("(Right-click to toggle)", 0.5, 0.8, 0.5) GameTooltip:Show() Guda_BagFrame_HighlightBagSlots(-2) Guda_BagSlot_OnEnter(this, -2) diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index 1be41d8..cdfad54 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -929,7 +929,7 @@ function Guda_ItemButton_OnEnter(self) end -- Early return for empty slots (no tooltip needed) - if not self.hasItem or not self.itemData then + if not self.hasItem then return end