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

Fix music stop when loading saved game in title screen #2371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ilmoro93
Copy link
Contributor

This fixes #2341.

However something is not clear to me:

  1. Why loadGame() had Title::stop();? Maybe it was added thinking that the function was for loading the selected game and not for opening load game window.
  2. It seems that the Load saved game button is opening a PromptSaveWindow and closing it immediately. In fact the code calls Ui::WindowManager::close(Ui::WindowType::saveGamePrompt); and then 0x0043C577 onClose(). Why is that?

Audio::pauseSound();
if (!isTitleMode())
{
Audio::pauseSound();
Copy link
Contributor

@LeftofZen LeftofZen Mar 30, 2024

Choose a reason for hiding this comment

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

do we ever want to pause music when the browser window is open? maybe we just remove this entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In Locomotion music is paused when opening browser window in game. But now I realize that it is paused because the game is paused, not because the window is open. Then yes, I think we can remove it, but we have to pause music when game is paused. This is not working now if I remove Audio::pauseSound(); in this comment.

Copy link
Contributor Author

@ilmoro93 ilmoro93 Mar 30, 2024

Choose a reason for hiding this comment

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

I was partially wrong. By removing it, the music is still stopped in PromptSaveWindow::open() while pressing load game, but it is not stopped when pressing saving game.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, this is necessary because of the prompt window appearing and pausing the game before the actual load window does, but the prompt doesn't always show so we need it in both places.

@@ -130,11 +133,6 @@ namespace OpenLoco::Game
// 0x0043BFF8
void loadGame()
{
if (isTitleMode())
{
Title::stop();
Copy link
Contributor

Choose a reason for hiding this comment

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

without this - when does this otherwise get called? it needs to be called somewhere before the save-game is actually loaded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

loadGame() is called again when a game is loaded, and it goes into:

else if (!isNetworked())
{
    if (Game::loadSaveGameOpen())

where importSaveToGameState() in the end calls stopMusic().

@LeftofZen LeftofZen added the changelog Should get a changelog entry label Apr 25, 2024
@LeftofZen LeftofZen added this to the v24.04+ milestone Apr 25, 2024
Copy link
Contributor

@LeftofZen LeftofZen left a comment

Choose a reason for hiding this comment

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

Code looks good and does the correct thing, all we need is a changelog entry and this is good to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Should get a changelog entry pending improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Music stops when clicking Load Saved Game on title screen
3 participants