fix: quest item bar

This commit is contained in:
Salikh Gurgenidze
2025-12-24 01:20:32 +04:00
parent 20503a4d2e
commit e2c17ecf0a
+18 -52
View File
@@ -69,54 +69,11 @@ function QuestItemBar:ScanForQuestItems()
end end
end end
-- If no items found via direct scan, try fallback to database -- Disabled DB fallback: only show items actually present in bags and usable
if not foundAny then -- Fallback to database caused non-usable quest items to be shown in the bar
local playerName = UnitName("player") -- Returning early to ensure only real, usable items from bags are considered
local playerRealm = GetRealmName() return
local fullName = playerName .. "-" .. playerRealm
if Guda_DB and Guda_DB.characters and Guda_DB.characters[fullName] and Guda_DB.characters[fullName].bags then
local bags = Guda_DB.characters[fullName].bags
for bagID = 0, 4 do
if bags[bagID] and bags[bagID].slots then
for slotID, item in pairs(bags[bagID].slots) do
if item and item.texture then
-- We can't easily check tooltips for database items without them being in bags,
-- but if we're here, it means the bags ARE actually empty or not loaded yet.
-- However, the user said "if its hard to define what items I've got in bag you can get from database".
-- We'll try to validate them if possible.
local isQuest = false
-- Use ID-based check for DB items
if item.link then
local itemID = addon.Modules.Utils:ExtractItemID(item.link)
if itemID then
local _, _, _, _, itemCategory, itemType = addon.Modules.Utils:GetItemInfoSafe(itemID)
if itemCategory == "Quest" or itemType == "Quest" then
isQuest = true
-- Note: We can't easily know if it's usable from DB alone without tooltip scan,
-- but we'll assume it might be if it's a quest item.
-- To be safe, we only add it if we can verify it's a quest item.
end
end
end
if isQuest then
table.insert(questItems, {
bagID = bagID,
slotID = slotID,
texture = item.texture,
count = item.count or 1,
link = item.link,
fromDB = true
})
end
end
end
end
end
end
end
end end
-- Local implementation of IsQuestItem (similar to the one in ItemButton.lua) -- Local implementation of IsQuestItem (similar to the one in ItemButton.lua)
@@ -217,7 +174,8 @@ function QuestItemBar:Update()
-- Used to keep track of which bag items are already displayed -- Used to keep track of which bag items are already displayed
local usedBagSlots = {} local usedBagSlots = {}
for i = 1, 2 do local slots = math.min(2, table.getn(questItems or {}))
for i = 1, slots do
local index = i local index = i
local button = buttons[i] local button = buttons[i]
if not button then if not button then
@@ -402,8 +360,17 @@ function QuestItemBar:Update()
end end
end end
-- Fixed width for 2 slots -- Hide any extra buttons beyond current slots
local newWidth = xOffset * 2 + 2 * (buttonSize + spacing) - spacing for j = slots + 1, table.getn(buttons) do
local extra = buttons[j]
if extra then
extra:Hide()
extra.hasItem = false
end
end
-- Fixed width for current number of slots
local newWidth = xOffset * 2 + slots * (buttonSize + spacing) - spacing
frame:SetWidth(newWidth) frame:SetWidth(newWidth)
end end
@@ -486,8 +453,7 @@ function QuestItemBar:UpdateFlyout(parent)
-- Collect items not in main buttons -- Collect items not in main buttons
local displayItems = {} local displayItems = {}
local mainItemIDs = {} local mainItemIDs = {}
for i = 1, 2 do for _, btn in ipairs(buttons) do
local btn = buttons[i]
if btn and btn.hasItem and btn.itemData and btn.itemData.link then if btn and btn.hasItem and btn.itemData and btn.itemData.link then
local id = addon.Modules.Utils:ExtractItemID(btn.itemData.link) local id = addon.Modules.Utils:ExtractItemID(btn.itemData.link)
if id then mainItemIDs[id] = true end if id then mainItemIDs[id] = true end