From ace1ab145a40827202ea47da35679c3372a9f1c5 Mon Sep 17 00:00:00 2001 From: David Vogel Date: Tue, 30 Jan 2024 15:01:20 +0100 Subject: [PATCH] More QOL updates - Give user the option to reapply resolution settings on detected mismatch - Tell user to apply some modifications manually, if the mod can't do it automatically - Always set mTrailerMode when DEBUG_PAUSE_GRID_UPDATE is set to prevent chunks from not rendering --- files/message.lua | 52 ++++++++++++++++++++++++++++++++++-------- files/modification.lua | 7 ++++-- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/files/message.lua b/files/message.lua index 57e254a..1260415 100644 --- a/files/message.lua +++ b/files/message.lua @@ -12,6 +12,7 @@ -------------------------- local Coords = require("coordinates") +local DebugAPI = require("noita-api.debug") ---------- -- Code -- @@ -127,11 +128,13 @@ function Message:ShowWrongResolution(callback, desc) "The resolution changed:", desc or "", " ", - "To fix:", - "- restart Noita or revert the resolution change." + "Press the button at the bottom to set up and close Noita automatically.", + " ", + "You can always reset any custom settings by right clicking the `start capture`", + "button at the top left.", }, Actions = { - { Name = "Query settings again", Hint = nil, HintDesc = nil, Callback = function() Coords:ReadResolutions() end }, + { Name = "Setup and close (May corrupt current save!)", Hint = nil, HintDesc = nil, Callback = callback }, }, AutoClose = true, -- This message will automatically close. } @@ -185,13 +188,42 @@ end function Message:ShowModificationUnsupported(realm, name, value) self.List = self.List or {} - self.List["ModificationFailed"] = { + self.List["ModificationFailed"] = self.List["ModificationFailed"] or { Type = "warning", - Lines = { - string.format("Couldn't modify %q in %q realm.", name, realm), - " ", - "This simply means that this modification is not supported for the Noita version you are using.", - "Feel free to open an issue at https://github.com/Dadido3/noita-mapcap.", - }, } + + self.List["ModificationFailed"].ModificationEntries = self.List["ModificationFailed"].ModificationEntries or {} + table.insert(self.List["ModificationFailed"].ModificationEntries, {realm = realm, name = name, value = value}) + + -- Build message lines. + self.List["ModificationFailed"].Lines = {"The mod couldn't apply the following changes:"} + table.insert(self.List["ModificationFailed"].Lines, " ") + for _, modEntry in ipairs(self.List["ModificationFailed"].ModificationEntries) do + table.insert(self.List["ModificationFailed"].Lines, string.format("- %q in %q realm", modEntry.name, modEntry.realm)) + end + + table.insert(self.List["ModificationFailed"].Lines, " ") + table.insert(self.List["ModificationFailed"].Lines, "This simply means that the mod can't automatically apply this change in the Noita version you are using.") + table.insert(self.List["ModificationFailed"].Lines, "If you are running a non-beta version of Noita, feel free to open an issue at https://github.com/Dadido3/noita-mapcap.") + + -- Tell the user to change some settings manually, if possible. + local manuallyWithF7 = {} + local possibleManualWithF7 = {mPostFxDisabled = true, mGuiDisabled = true, mGuiHalfSize = true, mFogOfWarOpenEverywhere = true, mTrailerMode = true, mDayTimeRotationPause = true, mPlayerNeverDies = true, mFreezeAI = true} + for _, modEntry in ipairs(self.List["ModificationFailed"].ModificationEntries) do + if modEntry.realm == "processMemory" and possibleManualWithF7[modEntry.name] then + table.insert(manuallyWithF7, modEntry) + end + end + + if #manuallyWithF7 > 0 then + table.insert(self.List["ModificationFailed"].Lines, " ") + table.insert(self.List["ModificationFailed"].Lines, "You can apply the setting manually:") + table.insert(self.List["ModificationFailed"].Lines, " ") + table.insert(self.List["ModificationFailed"].Lines, "- Press F7 to open the debug menu.") + for _, modEntry in ipairs(manuallyWithF7) do + table.insert(self.List["ModificationFailed"].Lines, string.format("- Change %q to %q.", modEntry.name, modEntry.value)) + end + table.insert(self.List["ModificationFailed"].Lines, "- Press F7 again to close the menu.") + table.insert(self.List["ModificationFailed"].Lines, "- Close this warning when you are done.") + end end diff --git a/files/modification.lua b/files/modification.lua index 6f344b1..3349e8f 100644 --- a/files/modification.lua +++ b/files/modification.lua @@ -254,7 +254,7 @@ function Modification.SetMemoryOptions(memory) -- Look up the tree and set options accordingly. - local level1 = lookup[DebugGetIsDevBuild()] + local level1 = lookup[DebugAPI.IsDevBuild()] level1 = level1 or {} local level2 = level1[ffi.os] @@ -367,7 +367,10 @@ function Modification.RequiredChanges() memory["mPostFxDisabled"] = 1 memory["mGuiDisabled"] = 1 memory["mFreezeAI"] = 1 - memory["mTrailerMode"] = 1 -- Is necessary for chunks to correctly load when DEBUG_PAUSE_GRID_UPDATE is enabled. + end + + if DebugAPI.IsDevBuild() and magic["DEBUG_PAUSE_GRID_UPDATE"] == "1" then + memory["mTrailerMode"] = 1 -- This is necessary for chunks to correctly load when DEBUG_PAUSE_GRID_UPDATE is enabled. end if ModSettingGet("noita-mapcap.disable-mod-detection") and not DebugAPI.IsDevBuild() then