fix: swap issue on bank frame
This commit is contained in:
+23
-8
@@ -960,21 +960,33 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
local itemQuality, itemLink, isLocked
|
local itemQuality, itemLink, isLocked
|
||||||
if not self.isReadOnly and bagID and slotID and self.hasItem then
|
if not self.isReadOnly and bagID and slotID and self.hasItem then
|
||||||
-- Query live game state for metadata
|
-- Query live game state for metadata
|
||||||
local _, _, locked, quality = GetContainerItemInfo(bagID, slotID)
|
-- Special handling for bank main bag (bagID == -1) which uses inventory slot API
|
||||||
itemLink = GetContainerItemLink(bagID, slotID)
|
if self.isBank and bagID == -1 then
|
||||||
itemQuality = quality
|
local invSlot = 39 + slotID
|
||||||
isLocked = locked
|
itemLink = GetInventoryItemLink("player", invSlot)
|
||||||
|
isLocked = IsInventoryItemLocked(invSlot)
|
||||||
|
-- Quality will be determined from GetItemInfo below
|
||||||
|
else
|
||||||
|
local _, _, locked, quality = GetContainerItemInfo(bagID, slotID)
|
||||||
|
itemLink = GetContainerItemLink(bagID, slotID)
|
||||||
|
itemQuality = quality
|
||||||
|
isLocked = locked
|
||||||
|
end
|
||||||
|
|
||||||
-- Ensure itemData is populated for live items (needed for ItemDetection)
|
-- Ensure itemData is populated for live items (needed for ItemDetection)
|
||||||
if itemLink then
|
if itemLink then
|
||||||
local itemName, _, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemLink)
|
local itemName, _, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemLink)
|
||||||
|
-- For bank main bag, get quality from GetItemInfo
|
||||||
|
if self.isBank and bagID == -1 then
|
||||||
|
itemQuality = itemRarity
|
||||||
|
end
|
||||||
if not itemData then
|
if not itemData then
|
||||||
-- Create new itemData
|
-- Create new itemData
|
||||||
if itemName then
|
if itemName then
|
||||||
itemData = {
|
itemData = {
|
||||||
link = itemLink,
|
link = itemLink,
|
||||||
name = itemName,
|
name = itemName,
|
||||||
quality = itemRarity or quality or 0,
|
quality = itemRarity or itemQuality or 0,
|
||||||
class = itemType,
|
class = itemType,
|
||||||
subclass = itemSubType,
|
subclass = itemSubType,
|
||||||
texture = itemTexture,
|
texture = itemTexture,
|
||||||
@@ -983,12 +995,15 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
self.itemData = itemData
|
self.itemData = itemData
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Update existing itemData with missing fields
|
-- ALWAYS update itemData.link with live link to ensure correct detection after swaps
|
||||||
if not itemData.link then itemData.link = itemLink end
|
-- This is critical: cached itemData might have stale link from before a swap
|
||||||
if itemData.quality == nil then itemData.quality = itemRarity or quality or 0 end
|
itemData.link = itemLink
|
||||||
|
-- Update other fields only if missing
|
||||||
|
if itemData.quality == nil then itemData.quality = itemRarity or itemQuality or 0 end
|
||||||
if not itemData.class and itemType then itemData.class = itemType end
|
if not itemData.class and itemType then itemData.class = itemType end
|
||||||
if not itemData.subclass and itemSubType then itemData.subclass = itemSubType end
|
if not itemData.subclass and itemSubType then itemData.subclass = itemSubType end
|
||||||
if not itemData.name and itemName then itemData.name = itemName end
|
if not itemData.name and itemName then itemData.name = itemName end
|
||||||
|
self.itemData = itemData
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif itemData then
|
elseif itemData then
|
||||||
|
|||||||
Reference in New Issue
Block a user