mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-22 21:17:33 +00:00
Fix output pixel scale option
- When set to 0, correctly use the actual pixel scaling factor - Scale player path by pixel scale factor
This commit is contained in:
parent
7d250d6405
commit
7a4dbeddf1
@ -59,7 +59,9 @@ end
|
|||||||
---@param ctx ProcessRunnerCtx|nil -- The process runner context this runs in.
|
---@param ctx ProcessRunnerCtx|nil -- The process runner context this runs in.
|
||||||
---@param outputPixelScale number|nil -- The resulting image pixel to world pixel ratio.
|
---@param outputPixelScale number|nil -- The resulting image pixel to world pixel ratio.
|
||||||
local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPixelScale)
|
local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPixelScale)
|
||||||
outputPixelScale = outputPixelScale or 0
|
if outputPixelScale == 0 or outputPixelScale == nil then
|
||||||
|
outputPixelScale = Coords:PixelScale()
|
||||||
|
end
|
||||||
|
|
||||||
local rectTopLeft, rectBottomRight = ScreenCapture.GetRect()
|
local rectTopLeft, rectBottomRight = ScreenCapture.GetRect()
|
||||||
if Coords.WindowResolution ~= rectBottomRight - rectTopLeft then
|
if Coords.WindowResolution ~= rectBottomRight - rectTopLeft then
|
||||||
@ -70,12 +72,7 @@ local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPi
|
|||||||
|
|
||||||
---Top left in output coordinates.
|
---Top left in output coordinates.
|
||||||
---@type Vec2
|
---@type Vec2
|
||||||
local outputTopLeft
|
local outputTopLeft = (topLeftWorld * outputPixelScale):Rounded()
|
||||||
if outputPixelScale > 0 then
|
|
||||||
outputTopLeft = (topLeftWorld * outputPixelScale):Rounded()
|
|
||||||
else
|
|
||||||
outputTopLeft = topLeftWorld
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check if the file exists, and if we are allowed to overwrite it.
|
-- Check if the file exists, and if we are allowed to overwrite it.
|
||||||
if dontOverwrite and Utils.FileExists(string.format("mods/noita-mapcap/output/%d,%d.png", outputTopLeft.x, outputTopLeft.y)) then
|
if dontOverwrite and Utils.FileExists(string.format("mods/noita-mapcap/output/%d,%d.png", outputTopLeft.x, outputTopLeft.y)) then
|
||||||
@ -554,9 +551,14 @@ end
|
|||||||
---Starts capturing the player path.
|
---Starts capturing the player path.
|
||||||
---Use `Capture.PlayerPathCapturingCtx` to stop, control or view the progress.
|
---Use `Capture.PlayerPathCapturingCtx` to stop, control or view the progress.
|
||||||
---@param interval integer|nil -- Wait time between captures in frames.
|
---@param interval integer|nil -- Wait time between captures in frames.
|
||||||
function Capture:StartCapturingPlayerPath(interval)
|
---@param outputPixelScale number|nil -- The resulting image pixel to world pixel ratio.
|
||||||
|
function Capture:StartCapturingPlayerPath(interval, outputPixelScale)
|
||||||
interval = interval or 20
|
interval = interval or 20
|
||||||
|
|
||||||
|
if outputPixelScale == 0 or outputPixelScale == nil then
|
||||||
|
outputPixelScale = Coords:PixelScale()
|
||||||
|
end
|
||||||
|
|
||||||
local file
|
local file
|
||||||
local oldPos
|
local oldPos
|
||||||
|
|
||||||
@ -601,7 +603,7 @@ function Capture:StartCapturingPlayerPath(interval)
|
|||||||
if playerEntity then
|
if playerEntity then
|
||||||
-- Get position.
|
-- Get position.
|
||||||
local x, y, rotation, scaleX, scaleY = playerEntity:GetTransform()
|
local x, y, rotation, scaleX, scaleY = playerEntity:GetTransform()
|
||||||
local pos = Vec2(x, y)
|
local pos = Vec2(x, y) * outputPixelScale
|
||||||
|
|
||||||
-- Get some other stats from the player.
|
-- Get some other stats from the player.
|
||||||
local damageModel = playerEntity:GetFirstComponent("DamageModelComponent")
|
local damageModel = playerEntity:GetFirstComponent("DamageModelComponent")
|
||||||
@ -647,7 +649,7 @@ function Capture:StartCapturing()
|
|||||||
|
|
||||||
if mode == "live" then
|
if mode == "live" then
|
||||||
self:StartCapturingLive(outputPixelScale)
|
self:StartCapturingLive(outputPixelScale)
|
||||||
self:StartCapturingPlayerPath(5) -- Capture player path with an interval of 5 frames.
|
self:StartCapturingPlayerPath(5, outputPixelScale) -- Capture player path with an interval of 5 frames.
|
||||||
elseif mode == "area" then
|
elseif mode == "area" then
|
||||||
local area = ModSettingGet("noita-mapcap.area")
|
local area = ModSettingGet("noita-mapcap.area")
|
||||||
if area == "custom" then
|
if area == "custom" then
|
||||||
|
Loading…
Reference in New Issue
Block a user