fix: category view, lock out items when in mail or trade
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
## Title: Guda
|
||||
## Notes: All-in-one bag and bank addon for World of Warcraft 1.12.1 (Turtle WoW)
|
||||
## Author: Vati
|
||||
## Version: 1.5.3
|
||||
## Version: 1.5.4
|
||||
## SavedVariables: Guda_DB
|
||||
## SavedVariablesPerCharacter: Guda_CharDB
|
||||
|
||||
|
||||
+11
-3
@@ -324,7 +324,12 @@ function BagFrame:Update()
|
||||
|
||||
-- Display items
|
||||
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
|
||||
local i = 1
|
||||
while true do
|
||||
@@ -610,7 +615,8 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
||||
local matchesFilter = self:PassesSearchFilter(itemData)
|
||||
Guda_ItemButton_SetItem(button, bagID, slot, itemData, false, isOtherChar and charName or nil, matchesFilter, isOtherChar)
|
||||
button.inUse = true
|
||||
|
||||
table.insert(itemButtons, button)
|
||||
|
||||
col = col + 1
|
||||
if col >= blockCols then
|
||||
col = 0
|
||||
@@ -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)
|
||||
button.isReadOnly = false
|
||||
button.inUse = true
|
||||
table.insert(itemButtons, button)
|
||||
else
|
||||
for _, item in ipairs(items) do
|
||||
local bagParent = self:GetBagParent(item.bagID)
|
||||
@@ -728,7 +735,8 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
||||
button:Show()
|
||||
Guda_ItemButton_SetItem(button, item.bagID, item.slotID, item.itemData, false, isOtherChar and charName or nil, self:PassesSearchFilter(item.itemData), isOtherChar)
|
||||
button.inUse = true
|
||||
|
||||
table.insert(itemButtons, button)
|
||||
|
||||
sCol = sCol + 1
|
||||
if sCol >= blockCols then
|
||||
sCol = 0
|
||||
|
||||
+5
-13
@@ -54,19 +54,11 @@ function Guda_UpdateLockStates(parentsTable)
|
||||
local buttons = { parent:GetChildren() }
|
||||
for _, button in ipairs(buttons) do
|
||||
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)
|
||||
local _, _, locked = nil, nil, nil
|
||||
if ok then
|
||||
-- older GetContainerItemInfo returns texture, count, locked etc in different orders; try to call a safe wrapper if available
|
||||
local infoOk, iName, iTexture, iCount, iQuality, iCanUse, iLocked = pcall(function() return GetContainerItemInfo(button.bagID, button.slotID) end)
|
||||
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
|
||||
-- GetContainerItemInfo returns: texture, itemCount, locked, quality, readable
|
||||
-- The 3rd return value is the lock state (boolean or nil)
|
||||
local _, _, locked = GetContainerItemInfo(button.bagID, button.slotID)
|
||||
if not button.otherChar and not button.isReadOnly and SetItemButtonDesaturated then
|
||||
-- locked can be true/1 (locked) or nil/false (unlocked)
|
||||
SetItemButtonDesaturated(button, locked, 0.5, 0.5, 0.5)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user