view live mode on current character bag
This commit is contained in:
+2
-1
@@ -312,7 +312,8 @@ function BagFrame:DisplayItems(bagData, isOtherChar, charName)
|
|||||||
button:SetPoint("TOPLEFT", itemContainer, "TOPLEFT", xPos, yPos)
|
button:SetPoint("TOPLEFT", itemContainer, "TOPLEFT", xPos, yPos)
|
||||||
|
|
||||||
-- Set item data with filter match info
|
-- Set item data with filter match info
|
||||||
Guda_ItemButton_SetItem(button, bagID, slot, itemData, false, isOtherChar and charName or nil, matchesFilter)
|
-- isReadOnly = true when viewing other characters (can't interact with their items)
|
||||||
|
Guda_ItemButton_SetItem(button, bagID, slot, itemData, false, isOtherChar and charName or nil, matchesFilter, isOtherChar)
|
||||||
|
|
||||||
table.insert(itemButtons, button)
|
table.insert(itemButtons, button)
|
||||||
|
|
||||||
|
|||||||
+110
-29
@@ -119,9 +119,16 @@ function Guda_ItemButton_OnLoad(self)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Enable mouse and register for drag/drop (crucial for Classic/Vanilla WoW)
|
||||||
if self.EnableMouse then
|
if self.EnableMouse then
|
||||||
self:EnableMouse(true)
|
self:EnableMouse(true)
|
||||||
end
|
end
|
||||||
|
if self.RegisterForDrag then
|
||||||
|
self:RegisterForDrag("LeftButton")
|
||||||
|
end
|
||||||
|
if self.RegisterForClicks then
|
||||||
|
self:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set item data
|
-- Set item data
|
||||||
@@ -137,6 +144,27 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
self.otherChar = otherCharName
|
self.otherChar = otherCharName
|
||||||
self.isReadOnly = isReadOnly or false -- Track if this is read-only mode
|
self.isReadOnly = isReadOnly or false -- Track if this is read-only mode
|
||||||
|
|
||||||
|
-- Re-register for drag/drop every time (crucial for button reuse in Classic/Vanilla)
|
||||||
|
if not self.isReadOnly and not self.otherChar then
|
||||||
|
if self.RegisterForDrag then
|
||||||
|
self:RegisterForDrag("LeftButton")
|
||||||
|
end
|
||||||
|
if self.RegisterForClicks then
|
||||||
|
self:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
||||||
|
end
|
||||||
|
if self.EnableMouse then
|
||||||
|
self:EnableMouse(true)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Disable drag for read-only or other character items
|
||||||
|
if self.RegisterForDrag then
|
||||||
|
self:RegisterForDrag() -- Clear drag registration
|
||||||
|
end
|
||||||
|
if self.EnableMouse then
|
||||||
|
self:EnableMouse(true) -- Still enable mouse for tooltips
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Default to true if not specified (for non-filtered displays)
|
-- Default to true if not specified (for non-filtered displays)
|
||||||
if matchesFilter == nil then
|
if matchesFilter == nil then
|
||||||
matchesFilter = true
|
matchesFilter = true
|
||||||
@@ -159,16 +187,53 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
self:SetWidth(iconSize)
|
self:SetWidth(iconSize)
|
||||||
self:SetHeight(iconSize)
|
self:SetHeight(iconSize)
|
||||||
|
|
||||||
-- Rollback behavior: drive visuals from cached itemData (DB) only
|
-- In live mode (readOnly=false), query real-time game state instead of cached DB
|
||||||
if itemData and itemData.texture then
|
-- In read-only mode (readOnly=true), use cached itemData from DB
|
||||||
self.hasItem = true
|
local displayTexture, displayCount
|
||||||
if SetItemButtonTexture then SetItemButtonTexture(self, itemData.texture) end
|
|
||||||
if SetItemButtonCount then SetItemButtonCount(self, itemData.count or 1) end
|
if not self.isReadOnly then
|
||||||
|
-- LIVE MODE: Always query game state directly, never use cached itemData
|
||||||
|
local liveTexture, liveCount = GetContainerItemInfo(bagID, slotID)
|
||||||
|
if liveTexture then
|
||||||
|
displayTexture = liveTexture
|
||||||
|
displayCount = liveCount
|
||||||
|
self.hasItem = true
|
||||||
|
else
|
||||||
|
-- No item in this slot (even if itemData has cached data)
|
||||||
|
self.hasItem = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- READ-ONLY MODE: Use cached itemData from DB (can't query other characters)
|
||||||
|
if itemData and itemData.texture then
|
||||||
|
displayTexture = itemData.texture
|
||||||
|
displayCount = itemData.count
|
||||||
|
self.hasItem = true
|
||||||
|
else
|
||||||
|
self.hasItem = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Apply the determined texture and count
|
||||||
|
if self.hasItem then
|
||||||
|
if SetItemButtonTexture then SetItemButtonTexture(self, displayTexture) end
|
||||||
|
if SetItemButtonCount then SetItemButtonCount(self, displayCount or 1) end
|
||||||
if emptySlotBg then emptySlotBg:Hide() end
|
if emptySlotBg then emptySlotBg:Hide() end
|
||||||
else
|
else
|
||||||
self.hasItem = false
|
-- Fully clear all item button state for empty slots
|
||||||
if SetItemButtonTexture then SetItemButtonTexture(self, nil) end
|
if SetItemButtonTexture then SetItemButtonTexture(self, nil) end
|
||||||
if SetItemButtonCount then SetItemButtonCount(self, 0) end
|
if SetItemButtonCount then SetItemButtonCount(self, 0) end
|
||||||
|
if SetItemButtonDesaturated then SetItemButtonDesaturated(self, false) end
|
||||||
|
|
||||||
|
-- Also clear the icon texture directly
|
||||||
|
local iconTexture = getglobal(self:GetName().."IconTexture")
|
||||||
|
if not iconTexture then
|
||||||
|
iconTexture = getglobal(self:GetName().."Icon") or self.icon or self.Icon
|
||||||
|
end
|
||||||
|
if iconTexture then
|
||||||
|
iconTexture:SetTexture(nil)
|
||||||
|
iconTexture:Hide()
|
||||||
|
end
|
||||||
|
|
||||||
if emptySlotBg then emptySlotBg:Show() end
|
if emptySlotBg then emptySlotBg:Show() end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -249,16 +314,28 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if itemData then
|
-- Get live metadata if in live mode (quality, link, lock status)
|
||||||
self.hasItem = true
|
local itemQuality, itemLink, isLocked
|
||||||
|
if not self.isReadOnly and bagID and slotID and self.hasItem then
|
||||||
|
-- Query live game state for metadata
|
||||||
|
local _, _, locked, quality = GetContainerItemInfo(bagID, slotID)
|
||||||
|
itemLink = GetContainerItemLink(bagID, slotID)
|
||||||
|
itemQuality = quality
|
||||||
|
isLocked = locked
|
||||||
|
elseif itemData then
|
||||||
|
-- Use cached metadata from database
|
||||||
|
itemQuality = itemData.quality
|
||||||
|
itemLink = itemData.link
|
||||||
|
isLocked = itemData.locked
|
||||||
|
end
|
||||||
|
|
||||||
-- Set icon
|
if self.hasItem then
|
||||||
SetItemButtonTexture(self, itemData.texture)
|
-- Icon already set above based on mode (live vs cached)
|
||||||
|
|
||||||
-- Gray out locked items (being traded, mailed, or auctioned) - BagShui style
|
-- Gray out locked items (being traded, mailed, or auctioned) - BagShui style
|
||||||
-- Don't desaturate items from other characters since they're read-only anyway
|
-- Don't desaturate items from other characters since they're read-only anyway
|
||||||
if not self.otherChar and not self.isReadOnly then
|
if not self.otherChar and not self.isReadOnly then
|
||||||
SetItemButtonDesaturated(self, itemData.locked, 0.5, 0.5, 0.5)
|
SetItemButtonDesaturated(self, isLocked, 0.5, 0.5, 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hide NormalTexture for filled slots (pfUI style)
|
-- Hide NormalTexture for filled slots (pfUI style)
|
||||||
@@ -283,9 +360,9 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
self:SetAlpha(0.25)
|
self:SetAlpha(0.25)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set count
|
-- Set count (use displayCount which was determined above based on mode)
|
||||||
if itemData.count and itemData.count > 1 then
|
if displayCount and displayCount > 1 then
|
||||||
countText:SetText(itemData.count)
|
countText:SetText(displayCount)
|
||||||
countText:Show()
|
countText:Show()
|
||||||
else
|
else
|
||||||
countText:Hide()
|
countText:Hide()
|
||||||
@@ -297,7 +374,7 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
-- Special border for keyring items (cyan/blue)
|
-- Special border for keyring items (cyan/blue)
|
||||||
self.qualityBorder:SetBackdropBorderColor(0.2, 0.8, 1.0, 1)
|
self.qualityBorder:SetBackdropBorderColor(0.2, 0.8, 1.0, 1)
|
||||||
self.qualityBorder:Show()
|
self.qualityBorder:Show()
|
||||||
elseif itemData.quality and itemData.link then
|
elseif itemQuality and itemLink then
|
||||||
-- Check settings to determine if we should show borders (nil-safe)
|
-- Check settings to determine if we should show borders (nil-safe)
|
||||||
local showEquipmentBorder, showOtherBorder
|
local showEquipmentBorder, showOtherBorder
|
||||||
if addon and addon.Modules and addon.Modules.DB and addon.Modules.DB.GetSetting then
|
if addon and addon.Modules and addon.Modules.DB and addon.Modules.DB.GetSetting then
|
||||||
@@ -319,9 +396,9 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
-- Check if item is equipment (nil-safe)
|
-- Check if item is equipment (nil-safe)
|
||||||
local isEquipment = false
|
local isEquipment = false
|
||||||
if addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.IsEquipment then
|
if addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.IsEquipment then
|
||||||
isEquipment = addon.Modules.Utils:IsEquipment(itemData.link)
|
isEquipment = addon.Modules.Utils:IsEquipment(itemLink)
|
||||||
elseif Guda and Guda.Modules and Guda.Modules.Utils and Guda.Modules.Utils.IsEquipment then
|
elseif Guda and Guda.Modules and Guda.Modules.Utils and Guda.Modules.Utils.IsEquipment then
|
||||||
isEquipment = Guda.Modules.Utils:IsEquipment(itemData.link)
|
isEquipment = Guda.Modules.Utils:IsEquipment(itemLink)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Determine if we should show the border based on item type and settings
|
-- Determine if we should show the border based on item type and settings
|
||||||
@@ -331,9 +408,9 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
-- Show colored border for all items (Poor, Common, Uncommon, Rare, Epic, etc.)
|
-- Show colored border for all items (Poor, Common, Uncommon, Rare, Epic, etc.)
|
||||||
local r, g, b = 1, 1, 1
|
local r, g, b = 1, 1, 1
|
||||||
if addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.GetQualityColor then
|
if addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.GetQualityColor then
|
||||||
r, g, b = addon.Modules.Utils:GetQualityColor(itemData.quality)
|
r, g, b = addon.Modules.Utils:GetQualityColor(itemQuality)
|
||||||
elseif Guda and Guda.Modules and Guda.Modules.Utils and Guda.Modules.Utils.GetQualityColor then
|
elseif Guda and Guda.Modules and Guda.Modules.Utils and Guda.Modules.Utils.GetQualityColor then
|
||||||
r, g, b = Guda.Modules.Utils:GetQualityColor(itemData.quality)
|
r, g, b = Guda.Modules.Utils:GetQualityColor(itemQuality)
|
||||||
end
|
end
|
||||||
self.qualityBorder:SetBackdropBorderColor(r, g, b, 1)
|
self.qualityBorder:SetBackdropBorderColor(r, g, b, 1)
|
||||||
self.qualityBorder:Show()
|
self.qualityBorder:Show()
|
||||||
@@ -597,24 +674,28 @@ function Guda_ItemButton_OnClick(self, button)
|
|||||||
-- Modified clicks
|
-- Modified clicks
|
||||||
if IsShiftKeyDown() then
|
if IsShiftKeyDown() then
|
||||||
if button == "LeftButton" and self.hasItem then
|
if button == "LeftButton" and self.hasItem then
|
||||||
|
-- Get live count and link
|
||||||
|
local _, count = GetContainerItemInfo(self.bagID, self.slotID)
|
||||||
|
local itemLink = GetContainerItemLink(self.bagID, self.slotID)
|
||||||
|
|
||||||
-- Shift+Left Click on stackable item: Show split stack dialog
|
-- Shift+Left Click on stackable item: Show split stack dialog
|
||||||
if self.itemData and self.itemData.count and self.itemData.count > 1 then
|
if count and count > 1 then
|
||||||
local _, count = GetContainerItemInfo(self.bagID, self.slotID)
|
OpenStackSplitFrame(count, self, "BOTTOMRIGHT", "TOPRIGHT")
|
||||||
if count and count > 1 then
|
return
|
||||||
OpenStackSplitFrame(count, self, "BOTTOMRIGHT", "TOPRIGHT")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
-- If not stackable or only 1 item, link to chat
|
-- If not stackable or only 1 item, link to chat
|
||||||
if self.itemData and self.itemData.link and ChatFrameEditBox:IsVisible() then
|
if itemLink and ChatFrameEditBox:IsVisible() then
|
||||||
ChatFrameEditBox:Insert(self.itemData.link)
|
ChatFrameEditBox:Insert(itemLink)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
elseif IsControlKeyDown() then
|
elseif IsControlKeyDown() then
|
||||||
-- Ctrl+Click: Dress up (if applicable)
|
-- Ctrl+Click: Dress up (if applicable)
|
||||||
if self.hasItem and self.itemData and self.itemData.link then
|
if self.hasItem then
|
||||||
DressUpItemLink(self.itemData.link)
|
local itemLink = GetContainerItemLink(self.bagID, self.slotID)
|
||||||
|
if itemLink then
|
||||||
|
DressUpItemLink(itemLink)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user