From 321208ba8a01e1a7e2a99b9f3f05e5100c75bd4e Mon Sep 17 00:00:00 2001 From: David Vogel Date: Thu, 28 Jul 2022 14:01:44 +0200 Subject: [PATCH] Query live capture settings while capturing - Change default capture interval to 30 frames - Add todo comments --- files/capture.lua | 28 +++++++++++++++------------- files/check.lua | 1 + files/ui.lua | 1 + settings.lua | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/files/capture.lua b/files/capture.lua index e7670cf..9eae818 100644 --- a/files/capture.lua +++ b/files/capture.lua @@ -263,14 +263,19 @@ end ---Starts the live capturing process. ---Use `Capture.MapCapturingCtx` to stop, control or view the process. ----@param interval integer|nil -- The interval length in frames. Defaults to 60. ----@param minDistance number|nil -- The minimum distance between screenshots. This will prevent screenshots if the player doesn't move much. ----@param maxDistance number|nil -- The maximum distance between screenshots. This will allow more screenshots per interval if the player moves fast. ---@param outputPixelScale number|nil -- The resulting image pixel to world pixel ratio. -function Capture:StartCapturingLive(interval, minDistance, maxDistance, outputPixelScale) - interval = interval or 60 - minDistance = minDistance or 10 - maxDistance = maxDistance or 50 +function Capture:StartCapturingLive(outputPixelScale) + + ---Queries the mod settings for the live capture parameters. + ---@return integer interval -- The interval length in frames. Defaults to 30. + ---@return number minDistanceSqr -- The minimum (squared) distance between screenshots. This will prevent screenshots if the player doesn't move much. + ---@return number maxDistanceSqr -- The maximum (squared) distance between screenshots. This will allow more screenshots per interval if the player moves fast. + local function querySettings() + local interval = tonumber(ModSettingGet("noita-mapcap.live-interval")) or 30 + local minDistance = tonumber(ModSettingGet("noita-mapcap.live-min-distance")) or 10 + local maxDistance = tonumber(ModSettingGet("noita-mapcap.live-max-distance")) or 50 + return interval, minDistance ^ 2, maxDistance ^ 2 + end -- Create file that signals that there are files in the output directory. local file = io.open("mods/noita-mapcap/output/nonempty", "a") @@ -282,9 +287,10 @@ function Capture:StartCapturingLive(interval, minDistance, maxDistance, outputPi Modification.SetCameraFree(false) local oldPos - local minDistanceSqr, maxDistanceSqr = minDistance ^ 2, maxDistance ^ 2 repeat + local interval, minDistanceSqr, maxDistanceSqr = querySettings() + -- Wait until we are allowed to take a new screenshot. local delayFrames = 0 repeat @@ -489,11 +495,7 @@ function Capture:StartCapturing() local captureGridSize = tonumber(ModSettingGet("noita-mapcap.grid-size")) if mode == "live" then - local interval = ModSettingGet("noita-mapcap.live-interval") - local minDistance = ModSettingGet("noita-mapcap.live-min-distance") - local maxDistance = ModSettingGet("noita-mapcap.live-max-distance") - - self:StartCapturingLive(interval, minDistance, maxDistance, outputPixelScale) + self:StartCapturingLive(outputPixelScale) elseif mode == "area" then local area = ModSettingGet("noita-mapcap.area") if area == "custom" then diff --git a/files/check.lua b/files/check.lua index 8df81ec..1dc7abc 100644 --- a/files/check.lua +++ b/files/check.lua @@ -83,5 +83,6 @@ function Check:Resolutions(interval) Message:ShowSetNoitaSettings(Modification.AutoSet, string.format("Expected virtual resolution is %s. But got %s.", expected, Coords.VirtualResolution)) end end + -- TODO: Check virtual resolution offset end diff --git a/files/ui.lua b/files/ui.lua index c2946e5..556b3c1 100644 --- a/files/ui.lua +++ b/files/ui.lua @@ -128,6 +128,7 @@ function UI:Draw() local gui = self.gui -- Skip drawing if we are asked to do so. + -- TODO: Find a way to susped UI drawing, but still being able to receive events if self.suspendFrames and self.suspendFrames > 0 then self.suspendFrames = self.suspendFrames - 1 return end self.suspendFrames = nil diff --git a/settings.lua b/settings.lua index a662211..dd5e965 100644 --- a/settings.lua +++ b/settings.lua @@ -210,7 +210,7 @@ modSettings = { id = "live-interval", ui_name = "Capture interval", ui_description = "Capturing interval in frames.", - value_default = 60, + value_default = 30, value_min = 5, value_max = 240, value_display_multiplier = 1,