Fix ctx.progressCurrent not being set

This commit is contained in:
David Vogel 2022-07-28 11:57:47 +02:00
parent 78b2812593
commit 84dba8a9fa

View File

@ -223,7 +223,7 @@ function Capture:StartCapturingArea(topLeft, bottomRight, captureGridSize, outpu
---@param ctx ProcessRunnerCtx ---@param ctx ProcessRunnerCtx
local function handleDo(ctx) local function handleDo(ctx)
CameraAPI.SetCameraFree(true) CameraAPI.SetCameraFree(true)
ctx.progressEnd = gridSize.x * gridSize.y ctx.progressCurrent, ctx.progressEnd = 0, gridSize.x * gridSize.y
while t < tLimit do while t < tLimit do
-- Prematurely stop capturing if that is requested by the context. -- Prematurely stop capturing if that is requested by the context.
@ -461,18 +461,46 @@ end
---Starts the capturing process based on user/mod settings. ---Starts the capturing process based on user/mod settings.
function Capture:StartCapturing() function Capture:StartCapturing()
local mode = ModSettingGet("noita-mapcap.capture-mode") Message:CatchException("Capture:StartCapturing", function()
local outputPixelScale = ModSettingGet("noita-mapcap.pixel-scale")
if mode == "live" then local mode = ModSettingGet("noita-mapcap.capture-mode")
local interval = ModSettingGet("noita-mapcap.live-interval") local outputPixelScale = ModSettingGet("noita-mapcap.pixel-scale")
local minDistance = ModSettingGet("noita-mapcap.live-min-distance") local captureGridSize = tonumber(ModSettingGet("noita-mapcap.grid-size"))
local maxDistance = ModSettingGet("noita-mapcap.live-max-distance")
self:StartCapturingLive(interval, minDistance, maxDistance, outputPixelScale) if mode == "live" then
else local interval = ModSettingGet("noita-mapcap.live-interval")
Message:ShowRuntimeError("StartCapturing", string.format("Unknown capturing mode %q", tostring(mode))) local minDistance = ModSettingGet("noita-mapcap.live-min-distance")
end local maxDistance = ModSettingGet("noita-mapcap.live-max-distance")
self:StartCapturingLive(interval, minDistance, maxDistance, outputPixelScale)
elseif mode == "area" then
local area = ModSettingGet("noita-mapcap.area")
if area == "custom" then
local topLeft = Vec2(ModSettingGet("noita-mapcap.area-top-left"))
local bottomRight = Vec2(ModSettingGet("noita-mapcap.area-bottom-right"))
self:StartCapturingArea(topLeft, bottomRight, captureGridSize, outputPixelScale)
else
local predefinedArea = Config.CaptureArea[area]
if predefinedArea then
self:StartCapturingArea(predefinedArea.TopLeft, predefinedArea.BottomRight, captureGridSize, outputPixelScale)
else
Message:ShowRuntimeError("PredefinedArea", string.format("Unknown predefined capturing area %q", tostring(area)))
end
end
elseif mode == "spiral" then
local origin = ModSettingGet("noita-mapcap.capture-mode-spiral-origin")
if origin == "custom" then
local originVec = Vec2(ModSettingGet("noita-mapcap.capture-mode-spiral-origin-vector"))
self:StartCapturingSpiral(originVec, captureGridSize, outputPixelScale)
else
Message:ShowRuntimeError("SpiralOrigin", string.format("Unknown spiral origin %q", tostring(origin)))
end
else
Message:ShowRuntimeError("StartCapturing", string.format("Unknown capturing mode %q", tostring(mode)))
end
end)
end end
---Stops all capturing processes. ---Stops all capturing processes.