diff --git a/files/check.lua b/files/check.lua index 564367c..c7f6c3b 100644 --- a/files/check.lua +++ b/files/check.lua @@ -77,6 +77,12 @@ function Check:Regular(interval) Message:ShowSetNoitaSettings(Modification.AutoSet, string.format("Internal resolution is %s. Expected %s.", Coords.InternalResolution, expected)) end end + if config["screenshake_intensity"] then + local expected = config.screenshake_intensity + if expected ~= self.StartupConfig.screenshake_intensity then + Message:ShowSetNoitaSettings(Modification.AutoSet, string.format("Screenshake intensity is %s, expected %s.", self.StartupConfig.screenshake_intensity, expected)) + end + end -- Magic numbers stuff doesn't need a forced restart, just a normal restart by the user. if magic["VIRTUAL_RESOLUTION_X"] and magic["VIRTUAL_RESOLUTION_Y"] then diff --git a/files/libraries/coordinates.lua b/files/libraries/coordinates.lua index 02d982a..9b19966 100644 --- a/files/libraries/coordinates.lua +++ b/files/libraries/coordinates.lua @@ -20,7 +20,7 @@ -- - Integer world coordinates map exactly to pixel borders. -- - The default image ratios of the virtual and internal rectangles don't exactly match, which causes a small line of not correctly rendered pixels at the bottom window. -- - The GRID_RENDER_BORDER magic number adds the given amount of world pixels to the virtual rectangle's width. This happens after fitting, so a positive value will make it wider than the internal rectangle. The virtual rectangle will always be aligned to start at the left side of the internal rectangle, though. --- - The virtual offset needs to be [-GRID_RENDER_BORDER, 0] for the viewport center to be exactly centered, and chunks to align perfectly with the window. +-- - The virtual offset needs to be [-GRID_RENDER_BORDER, 0] for the viewport center to be exactly centered to the window or virtual rectangle. -------------------------- -- Load library modules -- diff --git a/files/message.lua b/files/message.lua index 5506154..bb69813 100644 --- a/files/message.lua +++ b/files/message.lua @@ -52,6 +52,7 @@ function Message:ShowResetNoitaSettings() Lines = { "You requested to reset some game settings like:", "- Custom resolutions", + "- Screenshake intensity", " ", "Press the following button to reset the settings and close Noita automatically:", }, diff --git a/files/modification.lua b/files/modification.lua index 7b00dcd..d65c5bf 100644 --- a/files/modification.lua +++ b/files/modification.lua @@ -27,6 +27,21 @@ local Vec2 = require("noita-api.vec2") -- Code -- ---------- +---Reads the current config from `config.xml` and returns it as table. +---@return table config +function Modification.GetConfig() + local configFilename = Utils.GetSpecialDirectory("save-shared") .. "config.xml" + + -- Read and modify config. + local f, err = io.open(configFilename, "r") + if not f then error(string.format("failed to read config file: %s", err)) end + local xml = NXML.parse(f:read("*a")) + + f:close() + + return xml.attr +end + ---Will update Noita's `config.xml` with the values in the given table. --- ---This will force close Noita! @@ -172,6 +187,9 @@ function Modification.RequiredChanges() -- Capturing will not work in fullscreen. config["fullscreen"] = "0" + -- Also disable screenshake. + config["screenshake_intensity"] = "0" + magic["DRAW_PARALLAX_BACKGROUND"] = ModSettingGet("noita-mapcap.disable-background") and "0" or "1" magic["DEBUG_PAUSE_GRID_UPDATE"] = ModSettingGet("noita-mapcap.disable-physics") and "1" or "0" magic["DEBUG_PAUSE_BOX2D"] = ModSettingGet("noita-mapcap.disable-physics") and "1" or "0" @@ -233,6 +251,7 @@ function Modification.Reset() internal_size_h = "720", backbuffer_width = "1280", backbuffer_height = "720", + screenshake_intensity = "0.7", } Modification.SetConfig(config) diff --git a/init.lua b/init.lua index c8cfcd6..31369e7 100644 --- a/init.lua +++ b/init.lua @@ -55,6 +55,9 @@ dofile("mods/noita-mapcap/files/ui.lua") ---Called in order upon loading a new(?) game. function OnModPreInit() + -- Read Noita's config to be used in checks later on. + Check.StartupConfig = Modification.GetConfig() + -- Set magic numbers and other stuff based on mod settings. local config, magic, memory, patches = Modification.RequiredChanges() Modification.SetMagicNumbers(magic) diff --git a/settings.lua b/settings.lua index fe1efcc..951a782 100644 --- a/settings.lua +++ b/settings.lua @@ -284,18 +284,18 @@ modSettings = { value_default = DebugAPI.IsDevBuild(), -- Defaults to true in dev build, false in regular Noita. scope = MOD_SETTING_SCOPE_RUNTIME_RESTART, }, - { - id = "modify-entities", - ui_name = " Disable entity logic", - ui_description = "If enabled, the mod will disable some components of all encountered entities.\nThis will:\n- Disable AI\n- Disable falling\n- Disable hovering and rotation animations\n- Reduce explosions\n \nThis may slow down things a bit.\nAnd it may make Noita more likely to crash.\nUse at your own risk.", - value_default = false, - scope = MOD_SETTING_SCOPE_RUNTIME, - }, { id = "disable-shaders-gui-ai", ui_name = " Disable shaders, GUI and AI", ui_description = "It has the same effect as pressing F5, F8 and F12 in the Noita dev build.\nDoesn't work outside the dev build.", hidden = not DebugAPI:IsDevBuild(), -- Hide in anything else than the dev build. + value_default = DebugAPI.IsDevBuild(), -- Defaults to true in dev build, false in regular Noita. + scope = MOD_SETTING_SCOPE_RUNTIME, + }, + { + id = "modify-entities", + ui_name = " Disable entity logic", + ui_description = "If enabled, the mod will disable some components of all encountered entities.\nThis will:\n- Disable AI\n- Disable falling\n- Disable hovering and rotation animations\n- Reduce explosions\n \nThis may slow down things a bit.\nAnd it may make Noita more likely to crash.\nUse at your own risk.", value_default = false, scope = MOD_SETTING_SCOPE_RUNTIME, },