From 5a102f600f6970d8b3e68a086d9a0dfde7115b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Thu, 15 Jan 2026 00:34:02 +0100 Subject: [PATCH] allow multiple shopping and crafting ops --- TradeSkillMaster/TradeSkillMaster.toc | 2 +- .../TradeSkillMaster_AuctionDB.toc | 4 +- TradeSkillMaster_Crafting/Modules/Queue.lua | 26 +++++-- .../TradeSkillMaster_Crafting.lua | 2 +- .../TradeSkillMaster_Shopping.lua | 33 +++++---- TradeSkillMaster_Shopping/sidebar/Groups.lua | 71 ++++++++++++++----- TradeSkillMaster_Shopping/sidebar/Other.lua | 12 +++- 7 files changed, 108 insertions(+), 42 deletions(-) diff --git a/TradeSkillMaster/TradeSkillMaster.toc b/TradeSkillMaster/TradeSkillMaster.toc index 5f29078..cc5e2db 100644 --- a/TradeSkillMaster/TradeSkillMaster.toc +++ b/TradeSkillMaster/TradeSkillMaster.toc @@ -2,7 +2,7 @@ ## Title: |cff00fe00TradeSkillMaster: Revived|r ## Notes: Core addon for the TradeSkillMaster suite, revived for Wrath of the Lich King. Does nothing without modules installed. ## Author: Sapu94, Bart39, Gnomezilla [Warmane-Icecrown(A)], BlueAo [Warmane], andrew6180, Yoshiyuka, DimaSheiko, and other contributors... -## Version: 2.3.30 +## Version: 2.3.33 ## SavedVariables: TradeSkillMasterAppDB, AscensionTSMDB ## OptionalDeps: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0, SharedMedia, TheUndermineJournal, TheUndermineJournalGE ## X-Embeds: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0 diff --git a/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc b/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc index dcdeeaf..5fa20f7 100644 --- a/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc +++ b/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc @@ -2,10 +2,10 @@ ## Title: |cff00ff00TradeSkillMaster_AuctionDB|r ## Notes: Stores auction house data and calculates market prices. ## Author: Sapu94, Bart39 -## Version: 2.3.30 +## Version: 2.3.33 ## SavedVariables: AscensionTSM_AuctionDB ## Dependency: TradeSkillMaster -## X-Curse-Packaged-Version: 2.3.30 +## X-Curse-Packaged-Version: 2.3.33 ## X-Curse-Project-Name: TradeSkillMaster_AuctionDB ## X-Curse-Project-ID: tradeskillmaster_auctiondb ## X-Curse-Repository-ID: wow/tradeskillmaster_auctiondb/mainline diff --git a/TradeSkillMaster_Crafting/Modules/Queue.lua b/TradeSkillMaster_Crafting/Modules/Queue.lua index 82532b9..55567df 100644 --- a/TradeSkillMaster_Crafting/Modules/Queue.lua +++ b/TradeSkillMaster_Crafting/Modules/Queue.lua @@ -33,6 +33,9 @@ end function Queue:CreateRestockQueue(groupInfo) TSM:UpdateCraftReverseLookup() local numItems = 0 + local bestQueued = {} + local bestSpellID = {} + local seenItems = {} for _, data in pairs(groupInfo) do for _, opName in ipairs(data.operations) do @@ -42,6 +45,7 @@ function Queue:CreateRestockQueue(groupInfo) -- it's a valid operation for itemString in pairs(data.items) do itemString = TSMAPI:GetItemString(itemString) + seenItems[itemString] = true local spellID = TSM.craftReverseLookup[itemString] and TSM.craftReverseLookup[itemString][1] if spellID and TSM.db.realm.crafts[spellID] then local maxQueueCount = max(opSettings.maxRestock - TSM.Inventory:GetTotalQuantity(itemString), 0) @@ -61,16 +65,28 @@ function Queue:CreateRestockQueue(groupInfo) end local craft = TSM.db.realm.crafts[spellID] - craft.queued = floor(numToQueue / craft.numResult) - craft.queued = craft.queued >= opSettings.minRestock and craft.queued or 0 - if craft.queued > 0 then - numItems = numItems + 1 + local queued = floor(numToQueue / craft.numResult) + queued = queued >= opSettings.minRestock and queued or 0 + if queued > 0 and queued > (bestQueued[itemString] or 0) then + bestQueued[itemString] = queued + bestSpellID[itemString] = spellID end end end end end end + + for itemString in pairs(seenItems) do + local queued = bestQueued[itemString] or 0 + local spellID = bestSpellID[itemString] or (TSM.craftReverseLookup[itemString] and TSM.craftReverseLookup[itemString][1]) + if spellID and TSM.db.realm.crafts[spellID] then + TSM.db.realm.crafts[spellID].queued = queued + if queued > 0 then + numItems = numItems + 1 + end + end + end if numItems==0 then TSM:Printf("There are no items to restock.") @@ -254,4 +270,4 @@ end function Queue:getQueue(spellID) local craft = TSM.db.realm.crafts[spellID] return craft.queued -end \ No newline at end of file +end diff --git a/TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua b/TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua index d941911..d111f9e 100644 --- a/TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua +++ b/TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua @@ -105,7 +105,7 @@ end -- registers this module with TSM by first setting all fields and then calling TSMAPI:NewModule(). function TSM:RegisterModule() TSM.icons = { { side = "module", desc = "Crafting", slashCommand = "crafting", callback = "Options:LoadCrafting", icon = "Interface\\Icons\\INV_Misc_Gear_08" } } - TSM.operations = { maxOperations = 1, callbackOptions = "Options:Load", callbackInfo = "GetOperationInfo" } + TSM.operations = { maxOperations = 5, callbackOptions = "Options:Load", callbackInfo = "GetOperationInfo" } TSM.priceSources = { { key = "Crafting", label = L["Crafting Cost"], callback = "GetCraftingCost" }, { key = "matPrice", label = L["Crafting Material Cost"], callback = "GetCraftingMatCost" }, diff --git a/TradeSkillMaster_Shopping/TradeSkillMaster_Shopping.lua b/TradeSkillMaster_Shopping/TradeSkillMaster_Shopping.lua index 41daf91..6d3322f 100644 --- a/TradeSkillMaster_Shopping/TradeSkillMaster_Shopping.lua +++ b/TradeSkillMaster_Shopping/TradeSkillMaster_Shopping.lua @@ -53,7 +53,7 @@ end -- registers this module with TSM by first setting all fields and then calling TSMAPI:NewModule(). function TSM:RegisterModule() - TSM.operations = { maxOperations = 1, callbackOptions = "Options:Load", callbackInfo = "GetOperationInfo" } + TSM.operations = { maxOperations = 5, callbackOptions = "Options:Load", callbackInfo = "GetOperationInfo" } TSM.auctionTab = { callbackShow = "Search:Show", callbackHide = "Search:Hide" } TSM.tooltipOptions = { callback = "Options:LoadTooltipOptions" } TSM.moduleAPIs = { @@ -136,23 +136,28 @@ function TSM:GetTooltip(itemString) itemString = TSMAPI:GetBaseItemString(itemString, true) local operations = TSMAPI:GetItemOperation(itemString, "Shopping") if not operations then return end - local operationName = operations[1] - TSMAPI:UpdateOperation("Shopping", operationName) - local operation = TSM.operations[operationName] - if operation then - local maxPrice = TSM:GetMaxPrice(operation.maxPrice, itemString) - if maxPrice then - local priceText - if moneyCoinsTooltip then - priceText = (TSMAPI:FormatTextMoneyIcon(maxPrice, "|cffffffff", true) or "|cffffffff---|r") - else - priceText = (TSMAPI:FormatTextMoney(maxPrice, "|cffffffff", true) or "|cffffffff---|r") + local maxPrice + for _, operationName in ipairs(operations) do + TSMAPI:UpdateOperation("Shopping", operationName) + local operation = TSM.operations[operationName] + if operation then + local price = TSM:GetMaxPrice(operation.maxPrice, itemString) + if price then + maxPrice = maxPrice and max(maxPrice, price) or price end - tinsert(text, { left = " " .. L["Max Shopping Price:"], right = format("%s", priceText) }) end end + if maxPrice then + local priceText + if moneyCoinsTooltip then + priceText = (TSMAPI:FormatTextMoneyIcon(maxPrice, "|cffffffff", true) or "|cffffffff---|r") + else + priceText = (TSMAPI:FormatTextMoney(maxPrice, "|cffffffff", true) or "|cffffffff---|r") + end + tinsert(text, { left = " " .. L["Max Shopping Price:"], right = format("%s", priceText) }) + end if #text > 0 then tinsert(text, 1, "|cffffff00" .. "TSM Shopping:") return text end -end \ No newline at end of file +end diff --git a/TradeSkillMaster_Shopping/sidebar/Groups.lua b/TradeSkillMaster_Shopping/sidebar/Groups.lua index 48a04a2..96edec9 100644 --- a/TradeSkillMaster_Shopping/sidebar/Groups.lua +++ b/TradeSkillMaster_Shopping/sidebar/Groups.lua @@ -3,6 +3,19 @@ local L = LibStub("AceLocale-3.0"):GetLocale("TradeSkillMaster_Shopping") -- loa local private = {itemOperations={}} +local function GetActiveOperations(itemString, operations) + if not operations or #operations == 0 then return end + local active = {} + for _, opName in ipairs(operations) do + TSMAPI:UpdateOperation("Shopping", opName) + local opSettings = TSM.operations[opName] + if opSettings then + tinsert(active, opSettings) + end + end + return active +end + function private.Create(parent) local frame = CreateFrame("Frame", nil, parent) frame:SetAllPoints() @@ -39,33 +52,57 @@ function private.ScanCallback(event, ...) local filter = ... local maxPrice for _, itemString in ipairs(filter.items) do - local operation = private.itemOperations[itemString] - local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString) - if not operationPrice then return end - if operation.showAboveMaxPrice then + local operations = GetActiveOperations(itemString, private.itemOperations[itemString]) + if not operations or #operations == 0 then return end + local itemMaxPrice + for _, operation in ipairs(operations) do + if operation.showAboveMaxPrice then + itemMaxPrice = nil + break + end + local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString) + if operationPrice then + itemMaxPrice = itemMaxPrice and max(itemMaxPrice, operationPrice) or operationPrice + end + end + if itemMaxPrice == nil then maxPrice = nil break end - maxPrice = maxPrice and max(maxPrice, operationPrice) or operationPrice + if not itemMaxPrice then return end + maxPrice = maxPrice and max(maxPrice, itemMaxPrice) or itemMaxPrice end return maxPrice elseif event == "process" then local itemString, auctionItem = ... -- filter out auctions according to operation settings itemString = TSMAPI:GetBaseItemString(itemString, true) - local operation = private.itemOperations[itemString] - if not operation then return end - local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString) - if not operationPrice then return end + local operations = GetActiveOperations(itemString, private.itemOperations[itemString]) + if not operations or #operations == 0 then return end auctionItem:FilterRecords(function(record) + local buyout = record:GetItemBuyout() or 0 + for _, operation in ipairs(operations) do if operation.evenStacks and record.count % 5 ~= 0 then - return true - end - if not operation.showAboveMaxPrice then - return (record:GetItemBuyout() or 0) > operationPrice + -- not an even stack for this operation + elseif operation.showAboveMaxPrice then + return false + else + local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString) + if operationPrice and buyout <= operationPrice then + return false + end end + end + return true end) - auctionItem:SetMarketValue(operationPrice) + local marketValue + for _, operation in ipairs(operations) do + local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString) + if operationPrice then + marketValue = marketValue and max(marketValue, operationPrice) or operationPrice + end + end + auctionItem:SetMarketValue(marketValue) return auctionItem elseif event == "done" then TSM.Search:SetSearchBarDisabled(false) @@ -87,11 +124,13 @@ function private.StartScan() else -- it's a valid operation for itemString in pairs(data.items) do + local baseItemString = TSMAPI:GetBaseItemString(itemString, true) or itemString local _, err = TSM:GetMaxPrice(opSettings.maxPrice, itemString) if err then TSM:Printf(L["Invalid custom price source for %s. %s"], TSMAPI:GetSafeItemInfo(itemString) or itemString, err) else - private.itemOperations[itemString] = opSettings + private.itemOperations[baseItemString] = private.itemOperations[baseItemString] or {} + tinsert(private.itemOperations[baseItemString], opName) end end end @@ -110,4 +149,4 @@ end do TSM:AddSidebarFeature(L["TSM Groups"], private.Create) -end \ No newline at end of file +end diff --git a/TradeSkillMaster_Shopping/sidebar/Other.lua b/TradeSkillMaster_Shopping/sidebar/Other.lua index a9d0901..15b9e24 100644 --- a/TradeSkillMaster_Shopping/sidebar/Other.lua +++ b/TradeSkillMaster_Shopping/sidebar/Other.lua @@ -230,9 +230,15 @@ function private.SniperScanCallback(event, itemString, auctionItem) vendorPrice = vendor end local operations = TSMAPI:GetItemOperation(itemString, "Shopping") - local opSettings = operations and operations[1] and TSM.operations[operations[1]] - if opSettings and opSettings.maxPrice then - maxPrice = TSM:GetMaxPrice(opSettings.maxPrice, itemString) + for _, opName in ipairs(operations or {}) do + TSMAPI:UpdateOperation("Shopping", opName) + local opSettings = TSM.operations[opName] + if opSettings and opSettings.maxPrice then + local opPrice = TSM:GetMaxPrice(opSettings.maxPrice, itemString) + if opPrice then + maxPrice = maxPrice and max(maxPrice, opPrice) or opPrice + end + end end customPrice = TSM:GetMaxPrice(TSM.db.global.sniperCustomPrice, itemString) end