X Tutup
Skip to content

Make continue button load _quicksave if autosave not active#4758

Merged
sturnclaw merged 1 commit intopioneerspacesim:masterfrom
cwyss:contbutton
Feb 2, 2020
Merged

Make continue button load _quicksave if autosave not active#4758
sturnclaw merged 1 commit intopioneerspacesim:masterfrom
cwyss:contbutton

Conversation

@cwyss
Copy link
Contributor

@cwyss cwyss commented Dec 22, 2019

Simple additional feature for the continue button in main menu:

  • Load the _quicksave file if the autosave option is not activated (and _quicksave exists).
  • If autosave is active, then continue works as before and loads the autosave _exit file.

This added functionality could be handy whenever you are not using autosave.
In fact I did not use it for quite some time :)

@cwyss
Copy link
Contributor Author

cwyss commented Dec 28, 2019

In #4760 it was pointed out that the code from showMainMenu() in data/pigui/views/mainmenu.lua, which checks whether or not to make the Continue button active, polls the filesystem at every frame. This is -as I understand it- the case with all versions of showMainMenu(), both in upstream, in this PR, and in #4760. E.g., upstream checks for the existence of savefiles/_exit, while this PR checks for _exit and (if not found) _quicksave.

Some questions/thoughts about this:

  • Is showMainMenu() actually called if the main menu is not shown, i.e. when flying? If not then the FPS impact would happen only when showing the main menu (and could thus be acceptable?)
  • A simple alternative would be to have the Continue button always active and only upon clicking check for existence of whatever files, possibly giving the user a "Sorry. No game to continue from".

Opinions?

@impaktor
Copy link
Member

... polls the filesystem at every frame.

I think @johnbartholomew did some work on the save/load menu in the past, perhaps he's interested in voicing concerns about this.

end

local function canContinue()
if Game.CanLoadGame('_exit') or Game.CanLoadGame('_quicksave') then
Copy link
Member

@sturnclaw sturnclaw Feb 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I'd prefer you use idiomatic lua (see below), this style doesn't have any major problems and can be easily refactored later. Please do keep in mind for the future that there are much more elegant and simple ways to express a construct like this, though!

return Game.CanLoadGame('_exit') or Game.CanLoadGame('_quicksave')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint! Reminds me that I still need to learn lua properly :)

@sturnclaw sturnclaw merged commit 5299492 into pioneerspacesim:master Feb 2, 2020
@cwyss cwyss deleted the contbutton branch February 3, 2020 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup