Browse Source

refine shopping group search handling

💘 Generated with Crush

Assisted-by: GPT-5.2-Codex via Crush <crush@charm.land>
dev
Jørgen Lien Sellæg 4 months ago
parent
commit
1435baa1d2
  1. 4
      TradeSkillMaster/Auction/AuctionControl.lua
  2. 10
      TradeSkillMaster_Crafting/Modules/Gather.lua
  3. 1
      TradeSkillMaster_Shopping/TradeSkillMaster_Shopping.lua
  4. 4
      TradeSkillMaster_Shopping/modules/Destroying.lua
  5. 3
      TradeSkillMaster_Shopping/modules/Search.lua
  6. 6
      TradeSkillMaster_Shopping/modules/Util.lua
  7. 1
      TradeSkillMaster_Shopping/sidebar/Groups.lua

4
TradeSkillMaster/Auction/AuctionControl.lua

@ -203,7 +203,7 @@ function private:DoBuyout()
TSM:Print("Max restock quantity reached for this item.") TSM:Print("Max restock quantity reached for this item.")
return return
end end
if private.module == "Shopping" and not ShoppingBuyoutAllowed(private.currentAuction.itemString, private.currentAuction.count, perItemBuyout) then if private.module == "Shopping" and TSM.shoppingGroupSearchActive and not ShoppingBuyoutAllowed(private.currentAuction.itemString, private.currentAuction.count, perItemBuyout) then
TSM:Print("Max restock quantity reached for this item.") TSM:Print("Max restock quantity reached for this item.")
return return
end end
@ -422,7 +422,7 @@ function private:ShowConfirmationWindow()
TSM:Print("Max restock quantity reached for this item.") TSM:Print("Max restock quantity reached for this item.")
return return
end end
if private.module == "Shopping" and not ShoppingBuyoutAllowed(private.currentAuction.itemString, private.currentAuction.count, perItemBuyout) then if private.module == "Shopping" and TSM.shoppingGroupSearchActive and not ShoppingBuyoutAllowed(private.currentAuction.itemString, private.currentAuction.count, perItemBuyout) then
TSM:Print("Max restock quantity reached for this item.") TSM:Print("Max restock quantity reached for this item.")
return return
end end

10
TradeSkillMaster_Crafting/Modules/Gather.lua

@ -186,23 +186,23 @@ function Gather:ShoppingSearch(itemString, need, ignoreMaxQty)
TSMAPI:ModuleAPI("Shopping", "runDestroySearch", TSMAPI:GetSafeItemInfo(itemString) .. "/x" .. need, ShoppingCallback) TSMAPI:ModuleAPI("Shopping", "runDestroySearch", TSMAPI:GetSafeItemInfo(itemString) .. "/x" .. need, ShoppingCallback)
end end
else else
TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact/x" .. need, ShoppingCallback) TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact/x" .. need, ShoppingCallback, true)
end end
else else
TSM.Inventory.gatherItem = nil TSM.Inventory.gatherItem = nil
if ignoreMaxQty then if ignoreMaxQty then
TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact", ShoppingCallback) TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact", ShoppingCallback, true)
else else
TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact/x" .. need, ShoppingCallback) TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact/x" .. need, ShoppingCallback, true)
end end
end end
else else
TSM.Inventory.gatherItem = nil TSM.Inventory.gatherItem = nil
if ignoreMaxQty then if ignoreMaxQty then
TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact", ShoppingCallback) TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact", ShoppingCallback, true)
else else
TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact/x" .. need, ShoppingCallback) TSMAPI:ModuleAPI("Shopping", "runSearch", TSMAPI:GetSafeItemInfo(itemString) .. "/exact/x" .. need, ShoppingCallback, true)
end end
end end
end end

1
TradeSkillMaster_Shopping/TradeSkillMaster_Shopping.lua

@ -95,6 +95,7 @@ end
function TSM:StartFilterSearch(searchQuery, callback) function TSM:StartFilterSearch(searchQuery, callback)
if not TSMAPI:AHTabIsVisible("Shopping") then return end if not TSMAPI:AHTabIsVisible("Shopping") then return end
TSM.Search:StartFilterSearch(searchQuery, nil, true) TSM.Search:StartFilterSearch(searchQuery, nil, true)
TSM.shoppingGroupSearchActive = nil
TSM.moduleAPICallback = callback TSM.moduleAPICallback = callback
end end

4
TradeSkillMaster_Shopping/modules/Destroying.lua

@ -62,7 +62,9 @@ function Destroying:StartDestroyingSearch(target, filter, isCrafting)
if not private.sources[target] then return TSM:Printf(L["Invalid destroy target: '%s'"], target) end if not private.sources[target] then return TSM:Printf(L["Invalid destroy target: '%s'"], target) end
TSM.isCrafting = isCrafting TSM.isCrafting = isCrafting
TSM.shoppingGroupSearchActive = nil
Destroying.maxQuantity = filter.maxQuantity Destroying.maxQuantity = filter.maxQuantity
filter.maxQuantity = nil
filter.maxPrice = nil filter.maxPrice = nil
if private.sources[target] == "mill" then if private.sources[target] == "mill" then
private:TryStarting(private.StartMillingSearch, target, filter) private:TryStarting(private.StartMillingSearch, target, filter)
@ -271,4 +273,4 @@ function private.ScanCallback(event, ...)
elseif event == "done" then elseif event == "done" then
TSM.Search:SetSearchBarDisabled(false) TSM.Search:SetSearchBarDisabled(false)
end end
end end

3
TradeSkillMaster_Shopping/modules/Search.lua

@ -325,6 +325,7 @@ end
function Search:StartFilterSearch(filter, callback, isCrafting) function Search:StartFilterSearch(filter, callback, isCrafting)
TSM.isCrafting = isCrafting TSM.isCrafting = isCrafting
TSM.searchCallback = callback TSM.searchCallback = callback
TSM.shoppingGroupSearchActive = nil
if strfind(filter, "item:([0-9]+):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*):?%-?([0-9]*)$") then --or strfind(filter, "battlepet:([0-9]+):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*)$") then if strfind(filter, "item:([0-9]+):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*):?%-?([0-9]*)$") then --or strfind(filter, "battlepet:([0-9]+):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*):?([0-9]*)$") then
filter = TSMAPI:GetSafeItemInfo(filter) or filter filter = TSMAPI:GetSafeItemInfo(filter) or filter
end end
@ -524,7 +525,7 @@ local function GetSearchFilterOptions(searchTerm)
minILevel = oldMaxILevel minILevel = oldMaxILevel
end end
return true, queryString or "", class or 0, subClass or 0, minLevel or 0, maxLevel or 0, minILevel or 0, maxILevel or 0, rarity or -1, usableOnly or 0, exactOnly or nil, evenOnly or nil, maxQuantity or 0, maxPrice return true, queryString or "", class or 0, subClass or 0, minLevel or 0, maxLevel or 0, minILevel or 0, maxILevel or 0, rarity or -1, usableOnly or 0, exactOnly or nil, evenOnly or nil, maxQuantity, maxPrice
--return true, queryString or "", class or 0, subClass or 0, minLevel or 0, maxLevel or 0, minILevel or 0, maxILevel or 0, rarity or 0, usableOnly or 0, exactOnly or nil, evenOnly or nil, maxQuantity or 0, maxPrice --return true, queryString or "", class or 0, subClass or 0, minLevel or 0, maxLevel or 0, minILevel or 0, maxILevel or 0, rarity or 0, usableOnly or 0, exactOnly or nil, evenOnly or nil, maxQuantity or 0, maxPrice
end end

6
TradeSkillMaster_Shopping/modules/Util.lua

@ -151,6 +151,7 @@ function Util:HideSearchFrame(forceStop)
TSMAPI.AuctionScan:ClearCache() TSMAPI.AuctionScan:ClearCache()
TSM.searchCallback = nil TSM.searchCallback = nil
TSM.groupBuyoutCheck = nil TSM.groupBuyoutCheck = nil
TSM.shoppingGroupSearchActive = nil
end end
@ -199,6 +200,9 @@ function private:PrepareForScan(callback, isLastPageScan)
private.isLastPageScan = isLastPageScan private.isLastPageScan = isLastPageScan
private.callback = callback private.callback = callback
wipe(private.auctions) wipe(private.auctions)
if not isLastPageScan and not TSM.shoppingGroupSearchActive then
TSM.groupBuyoutCheck = nil
end
if private.isLastPageScan then if private.isLastPageScan then
private.searchFrame.statusBar:SetStatusText("Scanning last page...") private.searchFrame.statusBar:SetStatusText("Scanning last page...")
else else
@ -466,7 +470,7 @@ function private:RemoveAuction(auction, event, itemString)
-- handle max quantities on queries -- handle max quantities on queries
local query = private.auctions[itemString].query local query = private.auctions[itemString].query
if event == "OnBuyout" and query then if event == "OnBuyout" and query then
if private.mode == "normal" and (query.maxQuantity or 0) > 0 then if private.mode == "normal" and query.maxQuantity and query.maxQuantity > 0 then
query.maxQuantity = query.maxQuantity - auction.count query.maxQuantity = query.maxQuantity - auction.count
if TSM.moduleAPICallback then TSM.moduleAPICallback(max(query.maxQuantity, 0), itemString, auction.count) end if TSM.moduleAPICallback then TSM.moduleAPICallback(max(query.maxQuantity, 0), itemString, auction.count) end
for item, auctionItem in pairs(private.auctions) do for item, auctionItem in pairs(private.auctions) do

1
TradeSkillMaster_Shopping/sidebar/Groups.lua

@ -122,6 +122,7 @@ end
function private.StartScan() function private.StartScan()
TSMAPI:FireEvent("SHOPPING:GROUPS:STARTSCAN") TSMAPI:FireEvent("SHOPPING:GROUPS:STARTSCAN")
TSM.shoppingGroupSearchActive = true
wipe(private.itemOperations) wipe(private.itemOperations)
wipe(private.purchasedCounts) wipe(private.purchasedCounts)
TSM.searchCallback = function(event, auction) TSM.searchCallback = function(event, auction)

Loading…
Cancel
Save