diff --git a/files/capture.lua b/files/capture.lua index 2f9e7bd..05255fa 100644 --- a/files/capture.lua +++ b/files/capture.lua @@ -26,7 +26,8 @@ local function resetPlayer() end function startCapturing() - local ox, oy = getPlayerPos() + local ox, oy = GameGetCameraPos() + --getPlayerPos() 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 @@ -43,8 +44,11 @@ function startCapturing() local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then GameSetCameraPos(x, y) - wait(CAPTURE_DELAY) + wait(CAPTURE_DELAY - 1) + UiHide = true -- Hide UI while capturing the screenshot + wait(1) TriggerCapture(rx, ry) + UiHide = false end x, y = x + CAPTURE_GRID_SIZE, y end @@ -53,8 +57,11 @@ function startCapturing() local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then GameSetCameraPos(x, y) - wait(CAPTURE_DELAY) + wait(CAPTURE_DELAY - 1) + UiHide = true + wait(1) TriggerCapture(rx, ry) + UiHide = false end x, y = x, y + CAPTURE_GRID_SIZE end @@ -64,8 +71,11 @@ function startCapturing() local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then GameSetCameraPos(x, y) - wait(CAPTURE_DELAY) + wait(CAPTURE_DELAY - 1) + UiHide = true + wait(1) TriggerCapture(rx, ry) + UiHide = false end x, y = x - CAPTURE_GRID_SIZE, y end @@ -74,8 +84,11 @@ function startCapturing() local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then GameSetCameraPos(x, y) - wait(CAPTURE_DELAY) + wait(CAPTURE_DELAY - 1) + UiHide = true + wait(1) TriggerCapture(rx, ry) + UiHide = false end x, y = x, y - CAPTURE_GRID_SIZE end diff --git a/files/magic_numbers.xml b/files/magic_numbers.xml index 16b2487..b141d94 100644 --- a/files/magic_numbers.xml +++ b/files/magic_numbers.xml @@ -3,5 +3,10 @@ CAMERA_NO_MOVE_BUFFER_NEAR_VIEWPORT_EDGE="0.0" CAMERA_MOUSE_INTERPOLATION_SPEED="0.0" CAMERA_POSITION_INTERPOLATION_SPEED="50.0" - DRAW_PARALLAX_BACKGROUND="0"> + DRAW_PARALLAX_BACKGROUND="0" + DEBUG_FREE_CAMERA_SPEED="10" + DEBUG_NO_LOGO_SPLASHES="1" + DEBUG_PAUSE_GRID_UPDATE="1" + DEBUG_PAUSE_BOX2D="1" + DEBUG_DISABLE_POSTFX_DITHERING="1"> diff --git a/files/ui.lua b/files/ui.lua index 929f842..94648fa 100644 --- a/files/ui.lua +++ b/files/ui.lua @@ -3,31 +3,41 @@ -- This software is released under the MIT License. -- https://opensource.org/licenses/MIT +UiHide = false +local UiReduce = false + async_loop( function() if modGUI ~= nil then GuiStartFrame(modGUI) - GuiLayoutBeginVertical(modGUI, 50, 20) - if GuiButton(modGUI, 0, 0, "Start capturing map", 1) then - startCapturing() - GuiDestroy(modGUI) - modGUI = nil + GuiLayoutBeginVertical(modGUI, 50, 50) + if not UiReduce then + GuiTextCentered(modGUI, 0, 0, "You can freely look around and search a place to start capturing.") + GuiTextCentered(modGUI, 0, 0, "The mod will then take images in a spiral around your current view.") + GuiTextCentered(modGUI, 0, 0, "Use ESC and close the game to stop the process.") + GuiTextCentered( + modGUI, + 0, + 0, + 'You can resume capturing just by restarting noita and pressing "Start capturing map" again,' + ) + GuiTextCentered(modGUI, 0, 0, "the mod will skip already captured files.") + GuiTextCentered( + modGUI, + 0, + 0, + 'If you want to start a new map, you have to delete all images from the "output" folder!' + ) + if GuiButton(modGUI, 0, 0, ">> Start capturing map <<", 1) then + startCapturing() + UiReduce = true + end + end + if not UiHide then + local x, y = GameGetCameraPos() + GuiTextCentered(modGUI, 0, 0, string.format("Coordinates: %d, %d", x, y)) end - GuiTextCentered(modGUI, 0, 0, "Use ESC and close the game to stop the process.") - GuiTextCentered( - modGUI, - 0, - 0, - 'You can resume capturing just by restarting noita and pressing "Start capturing map" again,' - ) - GuiTextCentered(modGUI, 0, 0, "the mod will skip already captured files.") - GuiTextCentered( - modGUI, - 0, - 0, - 'If you want to start a new map, you have to delete all images from the "output" folder!' - ) GuiLayoutEnd(modGUI) end diff --git a/init.lua b/init.lua index 10fc426..b1947f6 100644 --- a/init.lua +++ b/init.lua @@ -3,6 +3,7 @@ dofile("mods/noita-mapcap/files/init.lua") function OnPlayerSpawned(player_entity) --EntityLoad("mods/noita-mapcap/files/luacomponent.xml") -- ffi isn't accessible from inside lua components, scrap that idea modGUI = GuiCreate() + GameSetCameraFree(true) end function OnWorldPostUpdate() -- this is called every time the game has finished updating the world @@ -10,6 +11,3 @@ function OnWorldPostUpdate() -- this is called every time the game has finished end ModMagicNumbersFileAdd("mods/noita-mapcap/files/magic_numbers.xml") -- override some game constants - --- Only works up to the 16-10-2019 version of noita. And even then, ffi and other nice stuff is only accessible here. ---ModLuaFileAppend("data/scripts/director_init.lua", "mods/noita-mapcap/files/init.lua")