Disable screenshake by default

This commit is contained in:
David Vogel 2022-07-29 15:29:15 +02:00
parent 2f8a8b2718
commit b19c70c9d0
6 changed files with 37 additions and 8 deletions

View File

@ -77,6 +77,12 @@ function Check:Regular(interval)
Message:ShowSetNoitaSettings(Modification.AutoSet, string.format("Internal resolution is %s. Expected %s.", Coords.InternalResolution, expected)) Message:ShowSetNoitaSettings(Modification.AutoSet, string.format("Internal resolution is %s. Expected %s.", Coords.InternalResolution, expected))
end end
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. -- 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 if magic["VIRTUAL_RESOLUTION_X"] and magic["VIRTUAL_RESOLUTION_Y"] then

View File

@ -20,7 +20,7 @@
-- - Integer world coordinates map exactly to pixel borders. -- - 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 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 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 -- -- Load library modules --

View File

@ -52,6 +52,7 @@ function Message:ShowResetNoitaSettings()
Lines = { Lines = {
"You requested to reset some game settings like:", "You requested to reset some game settings like:",
"- Custom resolutions", "- Custom resolutions",
"- Screenshake intensity",
" ", " ",
"Press the following button to reset the settings and close Noita automatically:", "Press the following button to reset the settings and close Noita automatically:",
}, },

View File

@ -27,6 +27,21 @@ local Vec2 = require("noita-api.vec2")
-- Code -- -- Code --
---------- ----------
---Reads the current config from `config.xml` and returns it as table.
---@return table<string, string> 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. ---Will update Noita's `config.xml` with the values in the given table.
--- ---
---This will force close Noita! ---This will force close Noita!
@ -172,6 +187,9 @@ function Modification.RequiredChanges()
-- Capturing will not work in fullscreen. -- Capturing will not work in fullscreen.
config["fullscreen"] = "0" config["fullscreen"] = "0"
-- Also disable screenshake.
config["screenshake_intensity"] = "0"
magic["DRAW_PARALLAX_BACKGROUND"] = ModSettingGet("noita-mapcap.disable-background") and "0" or "1" 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_GRID_UPDATE"] = ModSettingGet("noita-mapcap.disable-physics") and "1" or "0"
magic["DEBUG_PAUSE_BOX2D"] = 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", internal_size_h = "720",
backbuffer_width = "1280", backbuffer_width = "1280",
backbuffer_height = "720", backbuffer_height = "720",
screenshake_intensity = "0.7",
} }
Modification.SetConfig(config) Modification.SetConfig(config)

View File

@ -55,6 +55,9 @@ dofile("mods/noita-mapcap/files/ui.lua")
---Called in order upon loading a new(?) game. ---Called in order upon loading a new(?) game.
function OnModPreInit() 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. -- Set magic numbers and other stuff based on mod settings.
local config, magic, memory, patches = Modification.RequiredChanges() local config, magic, memory, patches = Modification.RequiredChanges()
Modification.SetMagicNumbers(magic) Modification.SetMagicNumbers(magic)

View File

@ -284,18 +284,18 @@ modSettings = {
value_default = DebugAPI.IsDevBuild(), -- Defaults to true in dev build, false in regular Noita. value_default = DebugAPI.IsDevBuild(), -- Defaults to true in dev build, false in regular Noita.
scope = MOD_SETTING_SCOPE_RUNTIME_RESTART, 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", id = "disable-shaders-gui-ai",
ui_name = " Disable shaders, GUI and 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.", 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. 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, value_default = false,
scope = MOD_SETTING_SCOPE_RUNTIME, scope = MOD_SETTING_SCOPE_RUNTIME,
}, },