Skip to content

Commit

Permalink
FIXUP: Force recovery if holding Ctrl
Browse files Browse the repository at this point in the history
This allows to restore a save with the same version as the current one.
It seems like this might be useful if changes are made between versions
that cause saves to be incompatible.
  • Loading branch information
Gliese852 committed Jan 10, 2024
1 parent 1ccd9a2 commit 89fc2fe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions data/pigui/modules/saveloadgame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ local function shouldDisplayThisSave(f)
string.find(f.name, searchSave, 1, true) ~= nil
end

local function wantRecovery()
return ui.ctrlHeld() or not saveIsValid
end

local function closeAndClearCache()
ui.saveLoadWindow:close()
Expand All @@ -102,7 +105,7 @@ end
local function closeAndLoadOrSave()
if selectedSave ~= nil and selectedSave ~= '' then
if ui.saveLoadWindow.mode == "LOAD" then
if saveIsValid then
if not wantRecovery() then
Game.LoadGame(selectedSave)
closeAndClearCache()
else
Expand Down Expand Up @@ -177,7 +180,7 @@ local function drawOptionButtons(txt_width, saving)

-- for vertical center alignment
local txt_hshift = math.max(0, (optionButtonSize.y - ui.getFrameHeight()) / 2)
local mode = saving and lui.SAVE or saveIsValid and lui.LOAD or lui.RECOVER
local mode = saving and lui.SAVE or wantRecovery() and lui.RECOVER or lui.LOAD
ui.sameLine(txt_width + ui.getWindowPadding().x + ui.getItemSpacing().x)
ui.addCursorPos(Vector2(0, saving and -txt_hshift or txt_hshift))
optionTextButton(mode, selectedSave ~= nil and selectedSave ~= '', closeAndLoadOrSave)
Expand Down

0 comments on commit 89fc2fe

Please sign in to comment.