fix: category view, lock out items when in mail or trade
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
+11
-3
@@ -324,7 +324,12 @@ 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,7 +615,8 @@ 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
|
||||||
col = 0
|
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)
|
-- 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,7 +735,8 @@ 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
|
||||||
sCol = 0
|
sCol = 0
|
||||||
|
|||||||
+5
-13
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user