From acc582c1b783c668b12f06dc7644f3528c8f7851 Mon Sep 17 00:00:00 2001 From: RSS90 Date: Fri, 3 May 2024 18:20:54 +0200 Subject: [PATCH] TSMAPI extension + support for Vanity Item search (#14) * GetItemPrice TSMAPI-Extension * Itemfilter Vanity Item Support * Rarity search extended up to heirloom * Rarity search extended up to heirloom --- TradeSkillMaster/TradeSkillMaster.lua | 46 +++++++++++++++++++ TradeSkillMaster_Shopping/modules/Search.lua | 4 +- .../sidebar/CustomFilter.lua | 4 +- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/TradeSkillMaster/TradeSkillMaster.lua b/TradeSkillMaster/TradeSkillMaster.lua index bc6ae51..5af31df 100644 --- a/TradeSkillMaster/TradeSkillMaster.lua +++ b/TradeSkillMaster/TradeSkillMaster.lua @@ -725,3 +725,49 @@ function TSMAPI:BulkQuery(items) end end) end + +-- GetItemPrice TSMAPI-Extension +function TSMAPI:GetItemPrices(itemLink) + if not itemLink then return nil end + + local prices = {} + + -- Get ItemString from ItemLink + local itemString = TSMAPI:GetItemString(itemLink) + if not itemString then return nil end + + -- Use TSM:GetCustomPrice to get DBMarket price + prices.DBMarket = TSM:GetCustomPrice("DBMarket", itemString) or 0 + + -- Use TSM:GetCustomPrice to get DBMinBuyout price + prices.DBMinBuyout = TSM:GetCustomPrice("DBMinBuyout", itemString) or 0 + + -- Use TSM:GetCustomPrice to get avgBuy price + prices.avgBuy = TSM:GetCustomPrice("avgBuy", itemString) or 0 + + -- Use TSM:GetCustomPrice to get avgSell price + prices.avgSell = TSM:GetCustomPrice("avgSell", itemString) or 0 + + -- Use TSM:GetCustomPrice to get maxBuy price + prices.maxBuy = TSM:GetCustomPrice("maxBuy", itemString) or 0 + + -- Use TSM:GetCustomPrice to get maxSell price + prices.maxSell = TSM:GetCustomPrice("maxSell", itemString) or 0 + + -- Use TSM:GetCustomPrice to get minBuy price + prices.minBuy = TSM:GetCustomPrice("minBuy", itemString) or 0 + + -- Use TSM:GetCustomPrice to get minSell price + prices.minSell = TSM:GetCustomPrice("minSell", itemString) or 0 + + -- Use TSM:GetCustomPrice to get Disenchant price + prices.Disenchant = TSM:GetCustomPrice("Disenchant", itemString) or 0 + + -- Use TSM:GetCustomPrice to get vendorBuy price + prices.vendorBuy = TSM:GetCustomPrice("vendorBuy", itemString) or 0 + + -- Use TSM:GetCustomPrice to get vendorSell price + prices.vendorSell = TSM:GetCustomPrice("vendorSell", itemString) or 0 + + return prices +end diff --git a/TradeSkillMaster_Shopping/modules/Search.lua b/TradeSkillMaster_Shopping/modules/Search.lua index d3de9a2..f193e8e 100644 --- a/TradeSkillMaster_Shopping/modules/Search.lua +++ b/TradeSkillMaster_Shopping/modules/Search.lua @@ -420,7 +420,7 @@ local function GetItemSubClass(str, class) end local function GetItemRarity(str) - for i=0, 4 do + for i=0, 7 do local text = _G["ITEM_QUALITY"..i.."_DESC"] if strlower(str) == strlower(text) then return i @@ -586,4 +586,4 @@ end function Search:GetCurrentSearchMode() return private.mode -end \ No newline at end of file +end diff --git a/TradeSkillMaster_Shopping/sidebar/CustomFilter.lua b/TradeSkillMaster_Shopping/sidebar/CustomFilter.lua index 9081d1e..5f2260d 100644 --- a/TradeSkillMaster_Shopping/sidebar/CustomFilter.lua +++ b/TradeSkillMaster_Shopping/sidebar/CustomFilter.lua @@ -106,7 +106,7 @@ function private.Create(parent) -- row 6 - rarity y = y + 60 local rarityList = {} - for i = 1, 4 do tinsert(rarityList, _G["ITEM_QUALITY"..i.."_DESC"]) end + for i = 1, 7 do tinsert(rarityList, _G["ITEM_QUALITY"..i.."_DESC"]) end local rarityDropdown = TSMAPI.GUI:CreateDropdown(frame, rarityList, "") rarityDropdown:SetLabel(L["Minimum Rarity"]) rarityDropdown:SetPoint("TOPLEFT", 5, -y) @@ -236,4 +236,4 @@ end do TSM:AddSidebarFeature(L["Custom Filter"], private.Create) -end \ No newline at end of file +end