Item detection issues

This commit is contained in:
Salikh Gurgenidze
2026-01-24 01:34:43 +04:00
parent e4e6e31072
commit cb5a0af096
9 changed files with 618 additions and 265 deletions
+17 -4
View File
@@ -1630,13 +1630,22 @@ function BankFrame:Initialize()
if currentViewChar then return end
if event == "PLAYERBANKSLOTS_CHANGED" and arg1 then
-- Mark specific slot as dirty in main bank (bagID = -1)
addon.Modules.BankScanner:MarkSlotDirty(-1, arg1)
-- Invalidate the entire main bank bag to ensure fresh data
-- (MarkSlotDirty was causing timing issues with item data)
addon.Modules.BankScanner:InvalidateBag(-1)
-- Clear ItemDetection cache to ensure fresh detection after item swap
if addon.Modules.ItemDetection then
addon.Modules.ItemDetection:ClearCache()
end
elseif event == "BAG_UPDATE" and arg1 then
-- Check if this is a bank bag (5-10)
if arg1 >= 5 and arg1 <= 10 then
-- Invalidate the specific bank bag (we don't know which slot)
-- Invalidate the specific bank bag
addon.Modules.BankScanner:InvalidateBag(arg1)
-- Clear ItemDetection cache to ensure fresh detection after item swap
if addon.Modules.ItemDetection then
addon.Modules.ItemDetection:ClearCache()
end
else
-- Not a bank bag, ignore for bank frame
return
@@ -1645,9 +1654,13 @@ function BankFrame:Initialize()
-- Bank container slot changed (bag added/removed)
-- Must clear entire cache since bag structure changed
addon.Modules.BankScanner:ClearCache()
if addon.Modules.ItemDetection then
addon.Modules.ItemDetection:ClearCache()
end
end
ScheduleBankFrameUpdate(0.1)
-- Slightly longer delay to ensure WoW API has updated
ScheduleBankFrameUpdate(0.15)
end)
end
+37 -4
View File
@@ -9,8 +9,14 @@ local scanTooltip = CreateFrame("GameTooltip", "Guda_QuestScanTooltip", nil, "Ga
scanTooltip:SetOwner(WorldFrame, "ANCHOR_NONE")
-- Helper function to check if an item is a quest item
-- Delegates to consolidated Utils:IsQuestItem() function
local function IsQuestItem(bagID, slotID, isBank)
-- Uses centralized ItemDetection module
local function IsQuestItem(bagID, slotID, isBank, itemData)
-- Use ItemDetection if available
if addon and addon.Modules and addon.Modules.ItemDetection then
local props = addon.Modules.ItemDetection:GetItemProperties(itemData, bagID, slotID)
return props.isQuestItem, props.isQuestStarter
end
-- Fallback to Utils
if addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.IsQuestItem then
return addon.Modules.Utils:IsQuestItem(bagID, slotID, nil, false, isBank)
end
@@ -363,7 +369,7 @@ function Guda_ItemButton_OnLoad(self)
if link and addon and addon.Modules and addon.Modules.Utils then
local itemID = addon.Modules.Utils:ExtractItemID(link)
if itemID then
local isQuest = IsQuestItem(this.bagID, this.slotID, this.isBank)
local isQuest = IsQuestItem(this.bagID, this.slotID, this.isBank, this.itemData)
local isUnique = addon.Modules.Utils:IsUniqueItem(this.bagID, this.slotID, link)
-- Only pin to QuestItemBar if it's a unique quest item
@@ -958,6 +964,33 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
itemLink = GetContainerItemLink(bagID, slotID)
itemQuality = quality
isLocked = locked
-- Ensure itemData is populated for live items (needed for ItemDetection)
if itemLink then
local itemName, _, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemLink)
if not itemData then
-- Create new itemData
if itemName then
itemData = {
link = itemLink,
name = itemName,
quality = itemRarity or quality or 0,
class = itemType,
subclass = itemSubType,
texture = itemTexture,
count = 1,
}
self.itemData = itemData
end
else
-- Update existing itemData with missing fields
if not itemData.link then itemData.link = itemLink end
if itemData.quality == nil then itemData.quality = itemRarity or quality or 0 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.name and itemName then itemData.name = itemName end
end
end
elseif itemData then
-- Use cached metadata from database
itemQuality = itemData.quality
@@ -1071,7 +1104,7 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
end
if not self.otherChar and not self.isReadOnly then
local isQuest, isQuestStarter = IsQuestItem(bagID, slotID)
local isQuest, isQuestStarter = IsQuestItem(bagID, slotID, self.isBank, itemData)
-- Update quest icon with the appropriate texture
Guda_ItemButton_UpdateQuestIcon(self, isQuest, isQuestStarter)
if self.questBorder then
+19 -87
View File
@@ -14,103 +14,35 @@ local questItems = {}
local flyoutButtons = {}
local flyoutFrame
-- Create a hidden tooltip for scanning
local scanTooltip
local function GetScanTooltip()
if not scanTooltip then
scanTooltip = CreateFrame("GameTooltip", "Guda_QuestBarScanTooltip", nil, "GameTooltipTemplate")
scanTooltip:SetOwner(WorldFrame, "ANCHOR_NONE")
end
return scanTooltip
end
--=====================================================
-- Quest Item Detection (using centralized ItemDetection)
--=====================================================
-- Combined function to check if an item is a quest item AND usable in ONE tooltip scan
-- This avoids the expensive double-scan that was causing lag
-- Combined function to check if an item is a quest item AND usable
-- Uses centralized ItemDetection module for consistent detection
function QuestItemBar:CheckQuestItemUsable(bagID, slotID)
if not bagID or not slotID then return false, false, false end
local tooltip = GetScanTooltip()
tooltip:ClearLines()
tooltip:SetBagItem(bagID, slotID)
local isQuestItem = false
local isQuestStarter = false
local isUsable = false
local isPermanentEnchant = false -- Track enchanting scrolls/vellums
for i = 1, tooltip:NumLines() do
local line = getglobal("Guda_QuestBarScanTooltipTextLeft" .. i)
if line then
local text = line:GetText()
if text then
local tl = string.lower(text)
-- Check for quest item indicators
if string.find(text, "Quest Starter") or
string.find(text, "This Item Begins a Quest") or
string.find(text, "Use: Starts a Quest") then
isQuestItem = true
isQuestStarter = true
isUsable = true -- Quest starters are always usable
elseif string.find(text, "Quest Item") then
isQuestItem = true
end
-- Check for usability (case-insensitive)
if string.find(tl, "use:") or string.find(tl, "begins a quest") or string.find(tl, "starts a quest") then
isUsable = true
end
-- Check for permanent enchant items (should NOT be quest items)
-- Just check for "permanently" anywhere (green text doesn't have "Use:" prefix)
if string.find(tl, "permanently") then
isPermanentEnchant = true
end
end
end
-- Get item data for ItemDetection
local itemData = nil
if addon.Modules.BagScanner then
itemData = addon.Modules.BagScanner:ScanSlot(bagID, slotID)
end
-- Permanent enchant items are NOT quest items, even if categorized as Quest
if isPermanentEnchant then
return false, false, false
-- Use centralized ItemDetection
if addon.Modules.ItemDetection and itemData then
local props = addon.Modules.ItemDetection:GetItemProperties(itemData, bagID, slotID)
return props.isQuestItem, props.isQuestStarter, props.isQuestUsable
end
-- Fallback check for quest category if not detected from tooltip
local link = GetContainerItemLink(bagID, slotID)
local itemID
local itemCategory, itemType
if link and addon.Modules.Utils and addon.Modules.Utils.ExtractItemID and addon.Modules.Utils.GetItemInfoSafe then
itemID = addon.Modules.Utils:ExtractItemID(link)
if itemID then
_, _, _, _, itemCategory, itemType = addon.Modules.Utils:GetItemInfoSafe(itemID)
end
-- Fallback to Utils if ItemDetection not available
if addon.Modules.Utils and addon.Modules.Utils.IsQuestItem then
local isQuestItem, isQuestStarter = addon.Modules.Utils:IsQuestItem(bagID, slotID, nil, false, false)
-- For usability fallback, check if it's a quest item (assume usable)
return isQuestItem, isQuestStarter, isQuestItem
end
-- If it's a Weapon or Armor, it shouldn't be a QuestItem unless it's specifically categorized as Quest
-- This avoids "Use:" equipment showing up in the quest bar
if itemCategory == "Weapon" or itemCategory == "Armor" or itemType == "Weapon" or itemType == "Armor" then
if itemCategory ~= "Quest" and itemType ~= "Quest" then
isQuestItem = false
isQuestStarter = false
end
end
if not isQuestItem then
if itemCategory == "Quest" or itemType == "Quest" then
isQuestItem = true
end
end
-- Check the QuestItemsDB for known faction-specific quest items
if not isQuestItem then
if itemID and addon.IsQuestItemByID then
local playerFaction = UnitFactionGroup("player")
local isDBQuestItem = addon:IsQuestItemByID(itemID, playerFaction)
if isDBQuestItem then
isQuestItem = true
end
end
end
return isQuestItem, isQuestStarter, isUsable
return false, false, false
end
-- Scan bags for quest items (optimized: single tooltip scan per item)