From 4758fe06d89e50122f7a06e76e799f58ce8882be Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Fri, 19 Dec 2025 02:06:49 +0400 Subject: [PATCH] sorting herb bags are added , upgrade quest item detection --- Data/BagScanner.lua | 14 ++++---- Data/BankScanner.lua | 5 +++ UI/ItemButton.lua | 84 +++++++++++++++++++++++--------------------- 3 files changed, 56 insertions(+), 47 deletions(-) diff --git a/Data/BagScanner.lua b/Data/BagScanner.lua index 5ccebd4..192619c 100644 --- a/Data/BagScanner.lua +++ b/Data/BagScanner.lua @@ -110,13 +110,13 @@ function BagScanner:Initialize() -- Register bag update events eventFrame:RegisterEvent("BAG_UPDATE") eventFrame:RegisterEvent("BAG_UPDATE_DELAYED") - - eventFrame:SetScript("OnEvent", function() - if event == "BAG_UPDATE" or event == "BAG_UPDATE_DELAYED" then - addon:Debug("Bag update detected, saving data...") - self:SaveToDatabase() - end - end) + -- + --eventFrame:SetScript("OnEvent", function() + -- if event == "BAG_UPDATE" or event == "BAG_UPDATE_DELAYED" then + -- addon:Debug("Bag update detected, saving data...") + -- self:SaveToDatabase() + -- end + --end) addon:Debug("Bag scanner initialized with auto-save") end \ No newline at end of file diff --git a/Data/BankScanner.lua b/Data/BankScanner.lua index 904d77d..a525eeb 100644 --- a/Data/BankScanner.lua +++ b/Data/BankScanner.lua @@ -91,6 +91,11 @@ function BankScanner:Initialize() -- Bank closed addon.Modules.Events:OnBankClose(function() + -- Do a final save on close before marking bank as closed + -- so that any last changes are captured. + addon:Debug("Bank closing - performing final save") + BankScanner:SaveToDatabase() + bankOpen = false addon:Debug("Bank closed") end, "BankScanner") diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index 04de837..2c772da 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -42,24 +42,28 @@ local function IsQuestItem(bagID, slotID) end end - -- Also check if the item type is "Quest" - if not isQuestItem then - local link = GetContainerItemLink(bagID, slotID) - if link then - local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType = GetItemInfo(link) - if itemType == "Quest" then - isQuestItem = true - -- For quest type items, check if they're starters by name/description - if itemName and (string.find(itemName, "Note") or - string.find(itemName, "Letter") or - string.find(itemName, "Orders") or - string.find(itemName, "Rune") or - string.find(itemName, "Tablet")) then - isQuestStarter = true - end - end - end - end + -- Also check item category/type via GetItemInfo for "Quest" + -- Turtle WoW GetItemInfo returns: name, link, rarity, level, itemCategory, itemType, stack, subType, texture, equipLoc, sellPrice + if not isQuestItem then + local link = GetContainerItemLink(bagID, slotID) + if link and addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.ExtractItemID and addon.Modules.Utils.GetItemInfoSafe then + local itemID = addon.Modules.Utils:ExtractItemID(link) + if itemID then + local itemName, _, _, _, itemCategory, itemType = addon.Modules.Utils:GetItemInfoSafe(itemID) + if itemCategory == "Quest" or itemType == "Quest" then + isQuestItem = true + -- For quest items, try a light heuristic to flag starters by name + if itemName and (string.find(itemName, "Note") or + string.find(itemName, "Letter") or + string.find(itemName, "Orders") or + string.find(itemName, "Rune") or + string.find(itemName, "Tablet")) then + isQuestStarter = true + end + end + end + end + end return isQuestItem, isQuestStarter end @@ -879,28 +883,28 @@ function Guda_ItemButton_OnEnter(self) -- Debug: print hovered item's texture path to chat -- Uses GetItemInfo on the hovered item's ID - --if self.hasItem then - -- local link = nil - -- if self.itemData and self.itemData.link then - -- link = self.itemData.link - -- else - -- -- Fallback to live bag query - -- link = GetContainerItemLink(self.bagID, self.slotID) - -- end - -- if link and addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.ExtractItemID then - -- local itemID = addon.Modules.Utils:ExtractItemID(link) - -- if itemID and addon.Modules.Utils.GetItemInfoSafe then - -- local name, itemLink, itemRarity, itemLevel, itemCategory, itemType, itemStackCount, - -- itemSubType, itemTexture, itemEquipLoc, itemSellPrice = addon.Modules.Utils:GetItemInfoSafe(itemID) - -- if addon and addon.Print then - -- addon:Print("itemTexture: %s", tostring(itemTexture)) - -- addon:Print("itemCategory: %s", tostring(itemCategory)) - -- addon:Print("itemType: %s", tostring(itemType)) - -- addon:Print("itemType: %s", tostring(itemType)) - -- end - -- end - -- end - --end + if self.hasItem then + local link = nil + if self.itemData and self.itemData.link then + link = self.itemData.link + else + -- Fallback to live bag query + link = GetContainerItemLink(self.bagID, self.slotID) + end + if link and addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.ExtractItemID then + local itemID = addon.Modules.Utils:ExtractItemID(link) + if itemID and addon.Modules.Utils.GetItemInfoSafe then + local name, itemLink, itemRarity, itemLevel, itemCategory, itemType, itemStackCount, + itemSubType, itemTexture, itemEquipLoc, itemSellPrice = addon.Modules.Utils:GetItemInfoSafe(itemID) + if addon and addon.Print then + addon:Print("itemTexture: %s", tostring(itemTexture)) + addon:Print("itemCategory: %s", tostring(itemCategory)) + addon:Print("itemType: %s", tostring(itemType)) + addon:Print("itemType: %s", tostring(itemType)) + end + end + end + end -- Handle merchant sell cursor (same approach as BagShui) if MerchantFrame:IsShown() and not self.isBank and not self.otherChar and self.hasItem then ShowContainerSellCursor(self.bagID, self.slotID)