Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause menu sets last time acceleration after closing #5646

Merged

Conversation

Max5377
Copy link
Contributor

@Max5377 Max5377 commented Oct 10, 2023

The pause menu now sets the last time acceleration that was before it was opened. Its behavior will be the same as when setting up time acceleration without pressing CTRL.
Added two events onPauseMenuClosed and onPauseMenuOpen that will set input binding and last time acceleration.
Edit:

Pause.menu.sets.last.time.acceleration.mp4

@Max5377 Max5377 changed the title Pause menu sets last time acceleration Pause menu sets last time acceleration after closing Oct 11, 2023
@Web-eWorks
Copy link
Member

Web-eWorks commented Oct 14, 2023

I don't think restoring forced time acceleration is in scope for the pause menu. On resuming from pause, the game should attempt to restore the previous time acceleration according to the game's limits, and ignore the "forced" time acceleration set by the player.

Consider for example a player who hits the ESC key out of desperation because they are about to crash into a planet during forced time acceleration; they would not be able to resume a "safe" time acceleration out of the pause menu due to the need to close the menu and then click on a time acceleration button.

While your code currently addresses this correctly, the ability to Ctrl+Click the "close" button to restore time acceleration is very non-obvious to the player, and I think is better handled by simply allowing the player to Ctrl+Click the time acceleration buttons after resuming gameplay to select their desired time acceleration override, rather than attempting to "intelligently" determine when to break the game's self-imposed limits.

@Max5377
Copy link
Contributor Author

Max5377 commented Oct 15, 2023

@Web-eWorks The original plan was to Ctrl+Esc to force time acceleration but right now if you do that, it will just open Start Menu on Windows and not close pause menu. I will delete bit about forcing time acceleration through Ctrl+Click Close button.

@Max5377 Max5377 force-pushed the pause-menu-remembers-acceleration branch 2 times, most recently from 288efb5 to dea4310 Compare October 15, 2023 05:04
@impaktor
Copy link
Member

Not directly related to this PR, but I had a thought when reading the discussion:
what if when you hold down Ctrl-key, the time accel button icons shift to red or something, indicating a new mode / layer?
(and similarly for other buttons that change their function when combined with modifier key).

data/pigui/views/game.lua Outdated Show resolved Hide resolved
@Max5377 Max5377 force-pushed the pause-menu-remembers-acceleration branch from dea4310 to e0e9284 Compare October 15, 2023 17:58
The pause menu now sets the last time acceleration that was before it was opened. Its behavior will be the same as when setting up time acceleration without pressing CTRL.
Added two events onPauseMenuClosed and onPauseMenuOpen that will set input binding and last time acceleration.
@Max5377 Max5377 force-pushed the pause-menu-remembers-acceleration branch from e0e9284 to 881c58a Compare October 15, 2023 18:28
@Web-eWorks Web-eWorks merged commit 1c3ddff into pioneerspacesim:master Oct 15, 2023
@Max5377 Max5377 deleted the pause-menu-remembers-acceleration branch October 15, 2023 18:36
@Max5377
Copy link
Contributor Author

Max5377 commented Oct 16, 2023

Found some oversight. If the game was already paused, onPauseMenuOpen will not be executed. Instead, it will be executed when pause menu gets closed and acceleration will be set to 1x. Then onPauseMenuClosed will be queued and also be executed.

[11:50:57.116714] Info:     onPauseMenuOpen
[11:50:57.116825] Info:     onPauseMenuClosed

Still works fine, but onPauseMenuOpen has Input.EnableBindings(false). Comment about this function:

// Call EnableBindings() to temporarily disable handling input bindings while
// you're recording a new input binding or are in a modal window.

Also, when you press End game onPauseMenuClosed will not be executed and Input.EnableBindings() will not be called.
I still can assign keys and I can't control ship in the pause menu, but can this cause problems in the future?
Edit: If it will, maybe it's better to return to first approach with settingsMenuWasOpened variable?

@Web-eWorks
Copy link
Member

EnableBindings() should probably be called at the beginning of the game and menu lifecycle in Pi.cpp. I'd prefer we have a consistent input state entering the menu. You don't need to move back to the old way of handling things if you do the above; I'll look at adding the separate event queue for "game"/"application" events as it will handle both this case and some other workarounds in the codebase.

@impaktor
Copy link
Member

I've only skimmed the above post-merge comment, but if there's (potential) bug / "fix-me", that needs to be documented, I'd advice to either open an issue, or push a fix-me comment to the code.

(This issue tracker is filled with "roger that, I'll fix it shortly", then a decade passes. Which is not a criticism, I just prefer to have TO-DOs documented somewhere so they don't get lost, especially a comment in a merged PR).

@Max5377
Copy link
Contributor Author

Max5377 commented Oct 17, 2023

Done some rewrite on my computer. Grouped ui.optionsWindow:open() and ui.optionsWindow:close() into one method ui.optionsWindow:changeState() and events onPauseMenuOpen and onPauseMenuClosed will be queued in said methods, so EnableBindings() in Pi.cpp is not needed. Will do update of this PR once event queue will be separated for "game"/"application" events.
P.S.: Now I only wish I had done this before the merge...

@Web-eWorks
Copy link
Member

No worries, sometimes subtle issues like this sneak past the first round of PR review and testing. Feel free to open another PR with the fixes.

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