Skip to content

Modernise Pause functionality - Use GameSpeed instead of dedicated Pause states#3187

Closed
LeftofZen wants to merge 8 commits intoOpenLoco:masterfrom
LeftofZen:promptSaveNoFlags
Closed

Modernise Pause functionality - Use GameSpeed instead of dedicated Pause states#3187
LeftofZen wants to merge 8 commits intoOpenLoco:masterfrom
LeftofZen:promptSaveNoFlags

Conversation

@LeftofZen
Copy link
Copy Markdown
Contributor

@LeftofZen LeftofZen commented Aug 6, 2025

  • Moved Pause state/flags into the GameSpeed enum
  • Removed TogglePause game command and functionality and replaced with GameSpeed game command
  • Moved audio-pause-on-game-pause into the GameSpeed setter

@LeftofZen LeftofZen changed the title use enum instead of bit flags Pause - use enum instead of bit flags Aug 6, 2025
@AaronVanGeffen
Copy link
Copy Markdown
Member

This conflicts with #3186. Did you intend to offer an alternative solution?

@LeftofZen
Copy link
Copy Markdown
Contributor Author

This conflicts with #3186. Did you intend to offer an alternative solution?

yes there was a discussion on discord about it

@LeftofZen LeftofZen changed the title Pause - use enum instead of bit flags Modernise Pause functionality - Use GameSpeed instead of decidated Pause states Aug 7, 2025
@LeftofZen LeftofZen changed the title Modernise Pause functionality - Use GameSpeed instead of decidated Pause states Modernise Pause functionality - Use GameSpeed instead of dedicated Pause states Aug 7, 2025
Audio::unpauseSound();
WindowManager::invalidate(WindowType::timeToolbar);
}
{ }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this functionality is now all handled by the setGameSpeed command/method

@duncanspumpkin
Copy link
Copy Markdown
Contributor

I'm not sure this will work in the long term and we will probably need to undo parts of it in the future. There are parts that depends on us having the mini ui processing loops which is something we've wanted to remove for a long time. It would be best we design assuming that mini ui processing loops disappear and there is only the main processing loop. How will this work in multiplayer as well? Need to account for game commands not being run immediately.

Its hard to work out at the moment if this will make it harder in the future to make the bigger improvements we want to make. Also unsure if anything we haven't implemented is still accessing these variables there shouldn't be but can't be 100% sure.

@ZehMatt
Copy link
Copy Markdown
Contributor

ZehMatt commented Aug 7, 2025

I'm also not a fan of this, this removes the ability to toggle pause and have the game speed not changed.

@LeftofZen
Copy link
Copy Markdown
Contributor Author

LeftofZen commented Aug 8, 2025

There are parts that depends on us having the mini ui processing loops which is something we've wanted to remove for a long time.

I don't understand what you mean. What "mini processing loops" are there and how does this change rely on them, that the previous code doesn't? I would put the pause/unpause functionality into the OnOpen and OnClose of the window, except that this code need to be copied and pasted for each window that wants to support that, and I'm sure you understand copy/paste is bad design. If there was an OO style window it'd be easy to put it in the base class's OnOpen and OnClose so that all child windows inherit the behaviour, but the code currently isn't structured li ke that. I'd love to know what you would do here.

How will this work in multiplayer as well?

The same as it does now? I don't understand the problem, I didn't change any of the actual semantics of things, its just pause is now communicated through the SetGameSpeed command, not the TogglePause command

Its hard to work out at the moment if this will make it harder in the future to make the bigger improvements we want to make.

This comment doesn't help in any way to determine what I've done wrong or how I should fix it. Can you elaborate and suggest a better way?

Also unsure if anything we haven't implemented is still accessing these variables there shouldn't be but can't be 100% sure.

This is fair, I can probably remove/undo this change

@LeftofZen
Copy link
Copy Markdown
Contributor Author

LeftofZen commented Aug 8, 2025

I'm also not a fan of this, this removes the ability to toggle pause and have the game speed not changed.

Yep it does remove that functionality. Because there is no use for this functionality and no way to trigger it in-game. So my questions are:

  • When/how do you use this functionality? Because no other players use it, or even can use it.
  • What can you achieve with this functionality that you can't with just a single pause/speed state?
  • Why is it a good design to have independent pause and speed states, that aren't used except to check if a specific window was opened, for the sole purpose of not unpausing the game when that window closes. That's window-specific behaviour, not an all-encompassing feature of pausing/game speed


namespace OpenLoco::Game
{
static loco_global<LoadOrQuitMode, 0x0050A002> _savePromptType;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this file was accidentally reformatted using tabs instead of spaces. Could you correct this?

@AaronVanGeffen
Copy link
Copy Markdown
Member

Closing this in favour of #3186

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.

5 participants