Merge pull request #13 from vatichild/fix/keyring-bugs

fix: keyring bugs
This commit is contained in:
Vati
2025-12-24 23:02:48 +04:00
committed by GitHub
4 changed files with 38 additions and 5 deletions
+2 -1
View File
@@ -16,7 +16,8 @@ local function CountCurrentCharacterItems(itemID)
local equippedCount = 0 local equippedCount = 0
-- Count current character's bags in real-time -- 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) local numSlots = GetContainerNumSlots(bagID)
for slot = 1, numSlots do for slot = 1, numSlots do
local link = GetContainerItemLink(bagID, slot) local link = GetContainerItemLink(bagID, slot)
+32 -2
View File
@@ -415,7 +415,7 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
-- Group items by category -- Group items by category
local categories = {} local categories = {}
local categoryList = { 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 for _, cat in ipairs(categoryList) do categories[cat] = {} end
@@ -641,11 +641,12 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
-- Update Y for bottom sections -- Update Y for bottom sections
local y = currentY + rowMaxHeight local y = currentY + rowMaxHeight
-- Special sections at bottom (Hearthstone, Mount, Tools, Empty) -- Special sections at bottom (Hearthstone, Mount, Tools, Keyring, Empty)
local bottomSections = { local bottomSections = {
{ name = "Home", items = specialItems.Hearthstone }, { name = "Home", items = specialItems.Hearthstone },
{ name = "Mounts", items = specialItems.Mount }, { name = "Mounts", items = specialItems.Mount },
{ name = "Tools", items = specialItems.Tools }, { name = "Tools", items = specialItems.Tools },
{ name = "Keyring", items = categories["Keyring"] or {} },
{ name = "Empty", items = {} } { name = "Empty", items = {} }
} }
@@ -671,6 +672,12 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
local numItems = table.getn(items) local numItems = table.getn(items)
if sec.name == "Empty" then if sec.name == "Empty" then
numItems = (totalFreeSlots > 0) and 1 or 0 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 end
if numItems > 0 then if numItems > 0 then
-- Sort Tools (Hearthstone/Mounts don't usually need it but good for consistency) -- 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) -- Ensure it's not actually read-only for drop behavior (it should still receive clicks/drops)
button.isReadOnly = false button.isReadOnly = false
button.inUse = true 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 else
for _, item in ipairs(items) do for _, item in ipairs(items) do
local bagParent = self:GetBagParent(item.bagID) local bagParent = self:GetBagParent(item.bagID)
+3 -1
View File
@@ -499,6 +499,8 @@
-- Optionally tint it cyan to distinguish it -- Optionally tint it cyan to distinguish it
SetItemButtonTextureVertexColor(this, 0.7, 1.0, 1.0) SetItemButtonTextureVertexColor(this, 0.7, 1.0, 1.0)
this:RegisterForClicks("LeftButtonUp", "RightButtonUp")
</OnLoad> </OnLoad>
<OnClick> <OnClick>
Guda_BagFrame_ToggleKeyring() Guda_BagFrame_ToggleKeyring()
@@ -508,7 +510,7 @@
GameTooltip:SetText("Keyring", 1.0, 1.0, 1.0) GameTooltip:SetText("Keyring", 1.0, 1.0, 1.0)
local numSlots = GetContainerNumSlots(-2) or 0 local numSlots = GetContainerNumSlots(-2) or 0
GameTooltip:AddLine(string.format("%d Slots", numSlots), 0.8, 0.8, 0.8) 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() GameTooltip:Show()
Guda_BagFrame_HighlightBagSlots(-2) Guda_BagFrame_HighlightBagSlots(-2)
Guda_BagSlot_OnEnter(this, -2) Guda_BagSlot_OnEnter(this, -2)
+1 -1
View File
@@ -929,7 +929,7 @@ function Guda_ItemButton_OnEnter(self)
end end
-- Early return for empty slots (no tooltip needed) -- Early return for empty slots (no tooltip needed)
if not self.hasItem or not self.itemData then if not self.hasItem then
return return
end end