mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
Add capture grid size check
- Check if capture grid size is smaller than the virtual resolution - Automatically close resolved messages
This commit is contained in:
parent
a2cb806ffa
commit
3fa95de8e6
@ -46,6 +46,9 @@ function Check:Regular(interval)
|
|||||||
if self.Counter > 0 then return end
|
if self.Counter > 0 then return end
|
||||||
self.Counter = interval
|
self.Counter = interval
|
||||||
|
|
||||||
|
-- Remove some messages, so they will automatically disappear when the problem is solved.
|
||||||
|
Message:CloseAutoclose()
|
||||||
|
|
||||||
-- Compare Noita config and actual window resolution.
|
-- Compare Noita config and actual window resolution.
|
||||||
local topLeft, bottomRight = ScreenCap.GetRect() -- Actual window client area.
|
local topLeft, bottomRight = ScreenCap.GetRect() -- Actual window client area.
|
||||||
if topLeft and bottomRight then
|
if topLeft and bottomRight then
|
||||||
@ -107,4 +110,20 @@ function Check:Regular(interval)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check if capture grid size is smaller than the virtual resolution.
|
||||||
|
-- This is not perfect, as it doesn't take rounding and cropping into account, so the actual captured area may be a few pixels smaller.
|
||||||
|
local mode = ModSettingGet("noita-mapcap.capture-mode")
|
||||||
|
local captureGridSize = tonumber(ModSettingGet("noita-mapcap.grid-size"))
|
||||||
|
if mode ~= "live" and (Coords.VirtualResolution.x < captureGridSize or Coords.VirtualResolution.y < captureGridSize) then
|
||||||
|
Message:ShowGeneralSettingsProblem(
|
||||||
|
"The virtual resolution is smaller than the capture grid size.",
|
||||||
|
"This means that you will get black areas in your final stitched image.",
|
||||||
|
" ",
|
||||||
|
"Apply either of the following in the mod settings:",
|
||||||
|
string.format("- Set the grid size to at most %s.", math.min(Coords.VirtualResolution.x, Coords.VirtualResolution.y)),
|
||||||
|
string.format("- Increase the custom resolutions to at least %s in any direction.", captureGridSize),
|
||||||
|
"- Change capture mode to `live`."
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -17,6 +17,18 @@ local Coords = require("coordinates")
|
|||||||
-- Code --
|
-- Code --
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
---Removes all messages with the autoclose flag.
|
||||||
|
---Use this before you recreate all auto closing messages.
|
||||||
|
function Message:CloseAutoclose()
|
||||||
|
self.List = self.List or {}
|
||||||
|
|
||||||
|
for k, message in pairs(self.List) do
|
||||||
|
if message.Autoclose then
|
||||||
|
self.List[k] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---Add a general runtime error message to the message list.
|
---Add a general runtime error message to the message list.
|
||||||
---This will always overwrite the last runtime error with the same id.
|
---This will always overwrite the last runtime error with the same id.
|
||||||
---@param id string
|
---@param id string
|
||||||
@ -82,6 +94,7 @@ function Message:ShowSetNoitaSettings(callback, desc)
|
|||||||
Actions = {
|
Actions = {
|
||||||
{ Name = "Setup and close (May corrupt current save!)", Hint = nil, HintDesc = nil, Callback = callback },
|
{ Name = "Setup and close (May corrupt current save!)", Hint = nil, HintDesc = nil, Callback = callback },
|
||||||
},
|
},
|
||||||
|
Autoclose = true, -- This message will automatically close.
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -98,6 +111,7 @@ function Message:ShowRequestRestart(desc)
|
|||||||
" ",
|
" ",
|
||||||
"To resolve this issue, restart the game.",
|
"To resolve this issue, restart the game.",
|
||||||
},
|
},
|
||||||
|
Autoclose = true, -- This message will automatically close.
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -118,6 +132,7 @@ function Message:ShowWrongResolution(callback, desc)
|
|||||||
Actions = {
|
Actions = {
|
||||||
{ Name = "Query settings again", Hint = nil, HintDesc = nil, Callback = function() Coords:ReadResolutions() end },
|
{ Name = "Query settings again", Hint = nil, HintDesc = nil, Callback = function() Coords:ReadResolutions() end },
|
||||||
},
|
},
|
||||||
|
Autoclose = true, -- This message will automatically close.
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -139,6 +154,18 @@ function Message:ShowOutputNonEmpty()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Tell the user that some settings are not optimal.
|
||||||
|
---@param ... string
|
||||||
|
function Message:ShowGeneralSettingsProblem(...)
|
||||||
|
self.List = self.List or {}
|
||||||
|
|
||||||
|
self.List["GeneralSettingsProblem"] = {
|
||||||
|
Type = "hint",
|
||||||
|
Lines = { ... },
|
||||||
|
Autoclose = true, -- This message will automatically close.
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
---Tell the user that there is something wrong with the mod installation.
|
---Tell the user that there is something wrong with the mod installation.
|
||||||
---@param ... string
|
---@param ... string
|
||||||
function Message:ShowGeneralInstallationProblem(...)
|
function Message:ShowGeneralInstallationProblem(...)
|
||||||
|
@ -114,9 +114,11 @@ function UI:_DrawMessages(messages)
|
|||||||
end
|
end
|
||||||
GuiLayoutEnd(gui)
|
GuiLayoutEnd(gui)
|
||||||
|
|
||||||
|
if not message.Autoclose then
|
||||||
local clicked = GuiImageButton(gui, self:_GenID(), 5, 0, "", "mods/noita-mapcap/files/ui-gfx/dismiss-8x8.png")
|
local clicked = GuiImageButton(gui, self:_GenID(), 5, 0, "", "mods/noita-mapcap/files/ui-gfx/dismiss-8x8.png")
|
||||||
--GuiTooltip(gui, "Dismiss message", "")
|
--GuiTooltip(gui, "Dismiss message", "")
|
||||||
if clicked then messages[key] = nil end
|
if clicked then messages[key] = nil end
|
||||||
|
end
|
||||||
|
|
||||||
GuiLayoutEnd(gui)
|
GuiLayoutEnd(gui)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user