Browse Source

add scan pause resume

dev
Jørgen Lien Sellæg 4 months ago
parent
commit
b181ef7bc6
  1. 3
      AGENTS.md
  2. 33
      TradeSkillMaster/Auction/AuctionScanning.lua
  3. 4
      TradeSkillMaster_Auctioning/locale/enUS.lua
  4. 24
      TradeSkillMaster_Auctioning/modules/GUI.lua
  5. 18
      TradeSkillMaster_Auctioning/modules/manage.lua

3
AGENTS.md

@ -17,3 +17,6 @@ Recent commit messages are short and action-focused (for example “add group sc
## Agent Notes ## Agent Notes
When adding or renaming modules, update the `.toc` and matching `.lua` filenames together, and ensure any new files are listed in the `.toc` manifest. Keep changes scoped to the relevant module folder to avoid cross-module regressions. When adding or renaming modules, update the `.toc` and matching `.lua` filenames together, and ensure any new files are listed in the `.toc` manifest. Keep changes scoped to the relevant module folder to avoid cross-module regressions.
Local Ascension client paths used in this workspace:
- AddOns: `/home/zalox/Games/ascension-wow/drive_c/Program Files/Ascension Launcher/resources/client/Interface/AddOns`
- SavedVariables: `/home/zalox/Games/ascension-wow/drive_c/Program Files/Ascension Launcher/resources/client/WTF/Account/omanfred/SavedVariables`

33
TradeSkillMaster/Auction/AuctionScanning.lua

@ -14,7 +14,7 @@ TSMAPI.AuctionScan = {}
local RETRY_DELAY = 2 local RETRY_DELAY = 2
local MAX_RETRIES = 4 local MAX_RETRIES = 4
local BASE_DELAY = 0.10 -- time to delay for before trying to scan a page again when it isn't fully loaded local BASE_DELAY = 0.10 -- time to delay for before trying to scan a page again when it isn't fully loaded
local private = { callbackHandler = nil, query = {}, options = {}, data = {}, isScanning = nil } local private = { callbackHandler = nil, query = {}, options = {}, data = {}, isScanning = nil, isPaused = nil }
TSMAPI:RegisterForTracing(private, "TradeSkillMaster.AuctionScanning_private") TSMAPI:RegisterForTracing(private, "TradeSkillMaster.AuctionScanning_private")
local scanCache = {} local scanCache = {}
@ -147,6 +147,7 @@ function TSMAPI.AuctionScan:RunQuery(query, callbackHandler, resolveSellers, max
-- setup other stuff -- setup other stuff
wipe(private.data) wipe(private.data)
private.isScanning = true private.isScanning = true
private.isPaused = nil
private.callbackHandler = callbackHandler private.callbackHandler = callbackHandler
private.resolveSellers = resolveSellers private.resolveSellers = resolveSellers
private.scanType = "query" private.scanType = "query"
@ -179,6 +180,7 @@ function TSMAPI.AuctionScan:ScanLastPage(callbackHandler)
-- setup other stuff -- setup other stuff
wipe(private.data) wipe(private.data)
private.isScanning = true private.isScanning = true
private.isPaused = nil
private.callbackHandler = callbackHandler private.callbackHandler = callbackHandler
private.scanType = "lastPage" private.scanType = "lastPage"
@ -189,7 +191,7 @@ end
-- sends a query to the AH frame once it is ready to be queried (uses frame as a delay) -- sends a query to the AH frame once it is ready to be queried (uses frame as a delay)
function private:SendQuery() function private:SendQuery()
if not private.isScanning then return end if not private.isScanning or private.isPaused then return end
if CanSendAuctionQuery() then if CanSendAuctionQuery() then
-- stop delay timer -- stop delay timer
@ -208,7 +210,7 @@ end
--scans the currently shown page of auctions and collects all the data --scans the currently shown page of auctions and collects all the data
function private:ScanAuctions() function private:ScanAuctions()
if not private.isScanning then return end if not private.isScanning or private.isPaused then return end
local shown, total = GetNumAuctionItems("list") local shown, total = GetNumAuctionItems("list")
local totalPages = ceil(total / NUM_AUCTION_ITEMS_PER_PAGE) local totalPages = ceil(total / NUM_AUCTION_ITEMS_PER_PAGE)
@ -303,6 +305,9 @@ function private:ScanAuctions()
end end
-- query the next page and continue scanning -- query the next page and continue scanning
if private.isPaused then
return
end
private:SendQuery() private:SendQuery()
end end
@ -363,6 +368,7 @@ function private:StopScanning()
TSMAPI:CancelFrame("updateDelay") TSMAPI:CancelFrame("updateDelay")
AuctionScanning:UnregisterEvent("AUCTION_ITEM_LIST_UPDATE") AuctionScanning:UnregisterEvent("AUCTION_ITEM_LIST_UPDATE")
private.isScanning = nil private.isScanning = nil
private.isPaused = nil
private.pageTemp = nil private.pageTemp = nil
end end
@ -373,6 +379,26 @@ function TSMAPI.AuctionScan:StopScan()
TSM:StopGeneratingQueries() TSM:StopGeneratingQueries()
end end
function TSMAPI.AuctionScan:PauseScan()
if not private.isScanning or private.isPaused then return false end
private.isPaused = true
TSMAPI:CancelFrame("queryDelay")
TSMAPI:CancelFrame("updateDelay")
AuctionScanning:UnregisterEvent("AUCTION_ITEM_LIST_UPDATE")
return true
end
function TSMAPI.AuctionScan:ResumeScan()
if not private.isScanning or not private.isPaused then return false end
private.isPaused = nil
private:SendQuery()
return true
end
function TSMAPI.AuctionScan:IsPaused()
return private.isPaused and true or false
end
-- Gets the number of pages for a given query -- Gets the number of pages for a given query
function TSMAPI.AuctionScan:GetNumPages(query, callbackHandler) function TSMAPI.AuctionScan:GetNumPages(query, callbackHandler)
@ -422,6 +448,7 @@ function TSMAPI.AuctionScan:GetNumPages(query, callbackHandler)
-- setup other stuff -- setup other stuff
wipe(private.data) wipe(private.data)
private.isScanning = true private.isScanning = true
private.isPaused = nil
private.callbackHandler = callbackHandler private.callbackHandler = callbackHandler
private.scanType = "numPages" private.scanType = "numPages"

4
TradeSkillMaster_Auctioning/locale/enUS.lua

@ -184,6 +184,7 @@ L["Operation"] = true
L["Operations"] = true L["Operations"] = true
L["Options"] = true L["Options"] = true
L["Other Auctioning Searches"] = true L["Other Auctioning Searches"] = true
L["Pause"] = true
L["Percentage of the buyout as bid, if you set this to 90% then a 100g buyout will have a 90g bid."] = true L["Percentage of the buyout as bid, if you set this to 90% then a 100g buyout will have a 90g bid."] = true
L["Player name"] = true L["Player name"] = true
L["Play the selected sound when a post / cancel scan is complete and items are ready to be posted / canceled (the gray bar is all the way across).Select None to disable sounds"] = true L["Play the selected sound when a post / cancel scan is complete and items are ready to be posted / canceled (the gray bar is all the way across).Select None to disable sounds"] = true
@ -217,13 +218,16 @@ L["Reset Scan Finished"] = true
L["Reset Settings"] = true L["Reset Settings"] = true
L["Reset"] = true L["Reset"] = true
L["Resetting enabled."] = true L["Resetting enabled."] = true
L["Resume"] = true
L["Restart"] = true L["Restart"] = true
L["Return to Summary"] = true L["Return to Summary"] = true
L["Right-Click to add %s to your friends list."] = true L["Right-Click to add %s to your friends list."] = true
L["Round Normal Price"] = true L["Round Normal Price"] = true
L["Resuming Scan..."] = true
L["Running Scan..."] = true L["Running Scan..."] = true
L["Save New Price"] = true L["Save New Price"] = true
L["Scan Complete!"] = true L["Scan Complete!"] = true
L["Scan Paused"] = true
L["Scanning %d / %d (Page 1 / ?)"] = true L["Scanning %d / %d (Page 1 / ?)"] = true
L["Scanning %d / %d (Page %d / %d)"] = true L["Scanning %d / %d (Page %d / %d)"] = true
L["Scanning %d / %d"] = true L["Scanning %d / %d"] = true

24
TradeSkillMaster_Auctioning/modules/GUI.lua

@ -16,7 +16,7 @@ function private:CreateButtons(parent)
local height = 24 local height = 24
local frame = CreateFrame("Frame", nil, parent) local frame = CreateFrame("Frame", nil, parent)
frame:SetHeight(height) frame:SetHeight(height)
frame:SetWidth(210) frame:SetWidth(265)
frame:SetPoint("BOTTOMRIGHT", -92, 5) frame:SetPoint("BOTTOMRIGHT", -92, 5)
frame.Enable = function(self) frame.Enable = function(self)
@ -26,6 +26,7 @@ function private:CreateButtons(parent)
self.cancel:Enable() self.cancel:Enable()
end end
self.skip:Enable() self.skip:Enable()
self.pause:Disable()
self.stop:Enable() self.stop:Enable()
end end
@ -36,6 +37,7 @@ function private:CreateButtons(parent)
self.cancel:Disable() self.cancel:Disable()
end end
self.skip:Disable() self.skip:Disable()
self.pause:Enable()
end end
frame.UpdateMode = function(self) frame.UpdateMode = function(self)
@ -51,6 +53,11 @@ function private:CreateButtons(parent)
self.stop:Enable() self.stop:Enable()
end end
frame.SetPaused = function(self, isPaused)
self.pause:SetText(isPaused and L["Resume"] or L["Pause"])
self.pause.isPaused = isPaused
end
local function OnClick(self) local function OnClick(self)
if self.which == "stop" and self.isDone then if self.which == "stop" and self.isDone then
GUI:HideSelectionFrame() GUI:HideSelectionFrame()
@ -90,7 +97,16 @@ function private:CreateButtons(parent)
local button = TSMAPI.GUI:CreateButton(frame, 18) local button = TSMAPI.GUI:CreateButton(frame, 18)
button:SetPoint("TOPLEFT", frame.skip, "TOPRIGHT", 5, 0) button:SetPoint("TOPLEFT", frame.skip, "TOPRIGHT", 5, 0)
button:SetWidth(70) button:SetWidth(60)
button:SetHeight(height)
button:SetText(L["Pause"])
button.which = "pause"
button:SetScript("OnClick", OnClick)
frame.pause = button
local button = TSMAPI.GUI:CreateButton(frame, 18)
button:SetPoint("TOPLEFT", frame.pause, "TOPRIGHT", 5, 0)
button:SetWidth(60)
button:SetHeight(height) button:SetHeight(height)
button:SetText(L["Stop"]) button:SetText(L["Stop"])
button.which = "stop" button.which = "stop"
@ -681,6 +697,7 @@ function private:Stopped(notDone)
private.buttons:Disable(true) private.buttons:Disable(true)
private.statusBar:UpdateStatus(100, 100) private.statusBar:UpdateStatus(100, 100)
private.contentButtons.currAuctionsButton:Hide() private.contentButtons.currAuctionsButton:Hide()
private.buttons.pause:Disable()
if private.mode == "Post" then if private.mode == "Post" then
TSMAPI:CreateTimeDelay(0.5, SetGoldText) TSMAPI:CreateTimeDelay(0.5, SetGoldText)
@ -697,6 +714,7 @@ function private:Stopped(notDone)
end end
private.buttons.stop:SetText(L["Restart"]) private.buttons.stop:SetText(L["Restart"])
private.buttons.stop.isDone = true private.buttons.stop.isDone = true
private.buttons:SetPaused(false)
end end
@ -897,6 +915,8 @@ function GUI:StartScan(frame)
private.buttons:Show() private.buttons:Show()
private.buttons:UpdateMode() private.buttons:UpdateMode()
private.buttons:Disable() private.buttons:Disable()
private.buttons:SetPaused(false)
private.buttons.pause:Enable()
private.buttons.stop.isDone = nil private.buttons.stop.isDone = nil
private.buttons.stop:SetText(L["Stop"]) private.buttons.stop:SetText(L["Stop"])
private.contentButtons:Show() private.contentButtons:Show()

18
TradeSkillMaster_Auctioning/modules/manage.lua

@ -72,9 +72,25 @@ function Manage:OnGUIEvent(event)
end end
elseif event == "skip" then elseif event == "skip" then
Util:SkipItem() Util:SkipItem()
elseif event == "pause" then
if TSMAPI.AuctionScan:IsPaused() then
if TSMAPI.AuctionScan:ResumeScan() then
GUI.buttons:SetPaused(false)
GUI.statusBar:SetStatusText(L["Resuming Scan..."])
GUI.infoText:SetInfo(L["Running Scan..."])
end
else
if TSMAPI.AuctionScan:PauseScan() then
GUI.buttons:SetPaused(true)
GUI.statusBar:SetStatusText(L["Scan Paused"])
GUI.infoText:SetInfo(L["Scan Paused"])
end
end
elseif event == "stop" then elseif event == "stop" then
TSMAPI:CancelFrame("auctioningNoScanProcessing") TSMAPI:CancelFrame("auctioningNoScanProcessing")
TSMAPI.AuctionScan:StopScan() TSMAPI.AuctionScan:StopScan()
GUI.buttons:SetPaused(false)
GUI.buttons.pause:Disable()
Util:Stop() Util:Stop()
end end
TSMAPI:CreateTimeDelay("aucManageSTUpdate", 0.01, GUI.UpdateAuctionsSTData) TSMAPI:CreateTimeDelay("aucManageSTUpdate", 0.01, GUI.UpdateAuctionsSTData)
@ -88,6 +104,8 @@ function Manage:ProcessScannedItem(itemString, noUpdate)
end end
function Manage:ScanComplete(interrupted) function Manage:ScanComplete(interrupted)
GUI.buttons:SetPaused(false)
GUI.buttons.pause:Disable()
if interrupted then if interrupted then
-- If our scan has been interrupted by the Auction House closing, -- If our scan has been interrupted by the Auction House closing,
-- simply act as if the user clicked "Stop", but with an extra flag -- simply act as if the user clicked "Stop", but with an extra flag

Loading…
Cancel
Save