fix: category view, lock out items when in mail or trade

This commit is contained in:
Salikh Gurgenidze
2026-01-03 21:44:22 +04:00
parent 9da2428f97
commit ed3db25ff1
3 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
## Title: Guda ## Title: Guda
## Notes: All-in-one bag and bank addon for World of Warcraft 1.12.1 (Turtle WoW) ## Notes: All-in-one bag and bank addon for World of Warcraft 1.12.1 (Turtle WoW)
## Author: Vati ## Author: Vati
## Version: 1.5.3 ## Version: 1.5.4
## SavedVariables: Guda_DB ## SavedVariables: Guda_DB
## SavedVariablesPerCharacter: Guda_CharDB ## SavedVariablesPerCharacter: Guda_CharDB
+8
View File
@@ -325,6 +325,11 @@ function BagFrame:Update()
-- Display items -- Display items
local viewType = addon.Modules.DB:GetSetting("bagViewType") or "single" local viewType = addon.Modules.DB:GetSetting("bagViewType") or "single"
-- Clear itemButtons table before rebuilding (prevents stale references)
for k in pairs(itemButtons) do
itemButtons[k] = nil
end
-- Reset all section headers before displaying items -- Reset all section headers before displaying items
local i = 1 local i = 1
while true do while true do
@@ -610,6 +615,7 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
local matchesFilter = self:PassesSearchFilter(itemData) local matchesFilter = self:PassesSearchFilter(itemData)
Guda_ItemButton_SetItem(button, bagID, slot, itemData, false, isOtherChar and charName or nil, matchesFilter, isOtherChar) Guda_ItemButton_SetItem(button, bagID, slot, itemData, false, isOtherChar and charName or nil, matchesFilter, isOtherChar)
button.inUse = true button.inUse = true
table.insert(itemButtons, button)
col = col + 1 col = col + 1
if col >= blockCols then if col >= blockCols then
@@ -716,6 +722,7 @@ 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
table.insert(itemButtons, button)
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)
@@ -728,6 +735,7 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
button:Show() button:Show()
Guda_ItemButton_SetItem(button, item.bagID, item.slotID, item.itemData, false, isOtherChar and charName or nil, self:PassesSearchFilter(item.itemData), isOtherChar) Guda_ItemButton_SetItem(button, item.bagID, item.slotID, item.itemData, false, isOtherChar and charName or nil, self:PassesSearchFilter(item.itemData), isOtherChar)
button.inUse = true button.inUse = true
table.insert(itemButtons, button)
sCol = sCol + 1 sCol = sCol + 1
if sCol >= blockCols then if sCol >= blockCols then
+5 -13
View File
@@ -54,19 +54,11 @@ function Guda_UpdateLockStates(parentsTable)
local buttons = { parent:GetChildren() } local buttons = { parent:GetChildren() }
for _, button in ipairs(buttons) do for _, button in ipairs(buttons) do
if button.hasItem ~= nil and button:IsShown() and button.bagID and button.slotID then if button.hasItem ~= nil and button:IsShown() and button.bagID and button.slotID then
local ok, name, texture, count, quality, canUse = pcall(function() return GetContainerItemInfo(button.bagID, button.slotID) end) -- GetContainerItemInfo returns: texture, itemCount, locked, quality, readable
local _, _, locked = nil, nil, nil -- The 3rd return value is the lock state (boolean or nil)
if ok then local _, _, locked = GetContainerItemInfo(button.bagID, button.slotID)
-- older GetContainerItemInfo returns texture, count, locked etc in different orders; try to call a safe wrapper if available if not button.otherChar and not button.isReadOnly and SetItemButtonDesaturated then
local infoOk, iName, iTexture, iCount, iQuality, iCanUse, iLocked = pcall(function() return GetContainerItemInfo(button.bagID, button.slotID) end) -- locked can be true/1 (locked) or nil/false (unlocked)
if infoOk then
-- Try to find 'locked' boolean among returned values (best-effort)
for _, val in ipairs({iName, iTexture, iCount, iQuality, iCanUse, iLocked}) do
if type(val) == "boolean" then locked = val; break end
end
end
end
if not button.otherChar and not button.isReadOnly and SetItemButtonDesaturated and locked ~= nil then
SetItemButtonDesaturated(button, locked, 0.5, 0.5, 0.5) SetItemButtonDesaturated(button, locked, 0.5, 0.5, 0.5)
end end
end end