diff --git a/README.md b/README.md index 5c650d9..55c3b09 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,53 @@ You can also change how much the tiles overlap by adjusting the `CAPTURE_GRID_SI The rectangle for the full map capture mode is defined in `.../Noita/mods/noita-mapcap/files/capture.lua`. +## How to do a full map capture minimal trouble + +For the best experience and result, follow these steps: + +1. Change the following values inside of `.../Noita/mods/noita-mapcap/files/magic_numbers.xml`: + + ``` xml + + ``` + +2. Change the following values inside of `.../Noita/save_shared/config.xml`: (Not the one in AppData!) + + ``` xml + + ``` + +3. Start `.../Noita/noita_dev.exe` + - If it's not there, copy it from `.../Noita/tools_modding/noita_dev.exe` + - If it's there, check if it is recent. If not, also copy it. + - Click `Ignore always` on the `ASSERT FAILED!` requester. + +4. When the game is loaded (When you can control your character): + - Press `F5`, `F8` and `F12` (In that order). + - Press `F7`, and disable `mTrailerMode` in the menu. (This should reduce chunk loading problems) + - Press `F7` again to close the menu. + +5. Press the `>> Start capturing full map <<` button. + +6. Wait a few hours until it's complete. + +7. Stitch the image as described above. + ## License [MIT](LICENSE) diff --git a/bin/stitch/stitch.go b/bin/stitch/stitch.go index 9231c49..a616ca4 100644 --- a/bin/stitch/stitch.go +++ b/bin/stitch/stitch.go @@ -3,6 +3,8 @@ // This software is released under the MIT License. // https://opensource.org/licenses/MIT +// TODO: Fix transparent pixels at the output image border + package main import ( diff --git a/files/capture.lua b/files/capture.lua index 3051b58..746a67e 100644 --- a/files/capture.lua +++ b/files/capture.lua @@ -31,11 +31,42 @@ local function resetPlayer() setPlayerHP(CAPTURE_FORCE_HP) end +local xOld, yOld = 0, 0 +local function captureScreenshot(x, y, rx, ry) + -- "Larger than grid jump" delay + local delay = CAPTURE_DELAY - 1 + if math.abs(x - xOld) > CAPTURE_GRID_SIZE or math.abs(y - yOld) > CAPTURE_GRID_SIZE then + delay = delay + CAPTURE_BIGJUMP_DELAY + end + xOld, yOld = x, y + + -- Set pos several times, so that chunks will load even if nothing happens in the surrounding + -- This prevents black blocks in areas without entites + for i = 1, delay, 1 do + GameSetCameraPos(x, y) + wait(1) + end + GameSetCameraPos(x, y) + + UiHide = true -- Hide UI while capturing the screenshot + wait(1) + if not TriggerCapture(rx, ry) then + UiCaptureProblem = "Screen capture failed. Please restart Noita." + end + UiHide = false +end + function startCapturingSpiral() local ox, oy = GameGetCameraPos() ox, oy = math.floor(ox / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE, math.floor(oy / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE local x, y = ox, oy + local virtualWidth, virtualHeight = + tonumber(MagicNumbersGetValue("VIRTUAL_RESOLUTION_X")), + tonumber(MagicNumbersGetValue("VIRTUAL_RESOLUTION_Y")) + + local virtualHalfWidth, virtualHalfHeight = math.floor(virtualWidth / 2), math.floor(virtualHeight / 2) + preparePlayer() GameSetCameraFree(true) @@ -46,62 +77,34 @@ function startCapturingSpiral() function() -- +x for i = 1, i, 1 do - local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE + local rx, ry = x * CAPTURE_PIXEL_SIZE - virtualHalfWidth, y * CAPTURE_PIXEL_SIZE - virtualHalfHeight if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then - GameSetCameraPos(x, y) - wait(CAPTURE_DELAY - 1) - UiHide = true -- Hide UI while capturing the screenshot - wait(1) - if not TriggerCapture(rx, ry) then - UiCaptureProblem = "Screen capture failed. Please restart Noita." - end - UiHide = false + captureScreenshot(x, y, rx, ry) end x, y = x + CAPTURE_GRID_SIZE, y end -- +y for i = 1, i, 1 do - local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE + local rx, ry = x * CAPTURE_PIXEL_SIZE - virtualHalfWidth, y * CAPTURE_PIXEL_SIZE - virtualHalfHeight if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then - GameSetCameraPos(x, y) - wait(CAPTURE_DELAY - 1) - UiHide = true - wait(1) - if not TriggerCapture(rx, ry) then - UiCaptureProblem = "Screen capture failed. Please restart Noita." - end - UiHide = false + captureScreenshot(x, y, rx, ry) end x, y = x, y + CAPTURE_GRID_SIZE end i = i + 1 -- -x for i = 1, i, 1 do - local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE + local rx, ry = x * CAPTURE_PIXEL_SIZE - virtualHalfWidth, y * CAPTURE_PIXEL_SIZE - virtualHalfHeight if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then - GameSetCameraPos(x, y) - wait(CAPTURE_DELAY - 1) - UiHide = true - wait(1) - if not TriggerCapture(rx, ry) then - UiCaptureProblem = "Screen capture failed. Please restart Noita." - end - UiHide = false + captureScreenshot(x, y, rx, ry) end x, y = x - CAPTURE_GRID_SIZE, y end -- -y for i = 1, i, 1 do - local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE + local rx, ry = x * CAPTURE_PIXEL_SIZE - virtualHalfWidth, y * CAPTURE_PIXEL_SIZE - virtualHalfHeight if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then - GameSetCameraPos(x, y) - wait(CAPTURE_DELAY - 1) - UiHide = true - wait(1) - if not TriggerCapture(rx, ry) then - UiCaptureProblem = "Screen capture failed. Please restart Noita." - end - UiHide = false + captureScreenshot(x, y, rx, ry) end x, y = x, y - CAPTURE_GRID_SIZE end @@ -113,6 +116,12 @@ end function startCapturingHilbert() local ox, oy = GameGetCameraPos() + local virtualWidth, virtualHeight = + tonumber(MagicNumbersGetValue("VIRTUAL_RESOLUTION_X")), + tonumber(MagicNumbersGetValue("VIRTUAL_RESOLUTION_Y")) + + local virtualHalfWidth, virtualHalfHeight = math.floor(virtualWidth / 2), math.floor(virtualHeight / 2) + -- Get size of the rectangle in grid/chunk coordinates local gridLeft = math.floor(CAPTURE_LEFT / CAPTURE_GRID_SIZE) local gridTop = math.floor(CAPTURE_TOP / CAPTURE_GRID_SIZE) @@ -143,23 +152,9 @@ function startCapturingHilbert() local hx, hy = mapHilbert(t, gridPOTSize) if hx < gridWidth and hy < gridHeight then local x, y = (hx + gridLeft) * CAPTURE_GRID_SIZE, (hy + gridTop) * CAPTURE_GRID_SIZE - local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE + local rx, ry = x * CAPTURE_PIXEL_SIZE - virtualHalfWidth, y * CAPTURE_PIXEL_SIZE - virtualHalfHeight if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then - GameSetCameraPos(x, y) - - -- "Larger than grid jump" delay - if math.abs(x - ox) > CAPTURE_GRID_SIZE or math.abs(y - oy) > CAPTURE_GRID_SIZE then - wait(CAPTURE_BIGJUMP_DELAY) - end - ox, oy = x, y - - wait(CAPTURE_DELAY - 1) - UiHide = true -- Hide UI while capturing the screenshot - wait(1) - if not TriggerCapture(rx, ry) then - UiCaptureProblem = "Screen capture failed. Please restart Noita." - end - UiHide = false + captureScreenshot(x, y, rx, ry) end UiProgress.Progress = UiProgress.Progress + 1 end diff --git a/files/magic_numbers.xml b/files/magic_numbers.xml index d92cc88..87c7908 100644 --- a/files/magic_numbers.xml +++ b/files/magic_numbers.xml @@ -7,5 +7,13 @@ DEBUG_PAUSE_GRID_UPDATE="1" DEBUG_PAUSE_BOX2D="1" DEBUG_DISABLE_POSTFX_DITHERING="1" - DEBUG_NO_PAUSE_ON_WINDOW_FOCUS_LOST="1"> + DEBUG_NO_PAUSE_ON_WINDOW_FOCUS_LOST="1" + UI_IMPORTANT_MESSAGE_POS_Y="2000" + UI_STAT_BAR_ICON_OFFSET_Y="2000" + UI_STAT_BAR_TEXT_OFFSET_X="2000" + UI_STAT_BAR_TEXT_OFFSET_Y="2000" + UI_QUICKBAR_OFFSET_X="2000" + UI_QUICKBAR_OFFSET_Y="2000" + UI_BARS_POS_X="2000" + UI_BARS_POS_Y="2000">