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

Save jukebox state #1346

Open
hhyyrylainen opened this issue Jun 2, 2020 · 7 comments
Open

Save jukebox state #1346

hhyyrylainen opened this issue Jun 2, 2020 · 7 comments

Comments

@hhyyrylainen
Copy link
Member

To resume the playing music when loading.

@DTanxxx
Copy link
Contributor

DTanxxx commented Nov 22, 2020

Hi hhyyrylainen,

I would like to work on this issue. Regarding saving the state of Jukebox class, should I use the same approach with the already-written RandomConverter class where I save Jukebox as a JSON object that saves the state-determining private fields of Jukebox?

@hhyyrylainen
Copy link
Member Author

I think there is no need for a custom converter here, just add a new property that on read: finds all the playing tracks and returns their positions, and on set stores that info in a temporary list. Then when the jukebox starts playing that temporary list is inspected and if found the tracks in it are set to play again from their existing positions.

@DTanxxx
Copy link
Contributor

DTanxxx commented Nov 27, 2020

Got it. Do you think it would be more suitable to make the property a type of Dictionary<string, float> to store tracks as strings with their corresponding PreviousPlayedPositions?
Also when you mentioned "to resume the playing music when loading", did you mean to carry over the main menu music throughout the loading screen when a saved file is loaded (I think there is a transition from main menu music to in-game music during loading)?

@hhyyrylainen
Copy link
Member Author

Got it. Do you think it would be more suitable to make the property a type of Dictionary<string, float> to store tracks as strings with their corresponding PreviousPlayedPositions?

Whatever data structure that contains enough information to restart the playing tracks should be used.
If I need to design the entire thing, I might as well code it myself.

Also when you mentioned "to resume the playing music when loading", did you mean to carry over the main menu music throughout the loading screen when a saved file is loaded (I think there is a transition from main menu music to in-game music during loading)?

I mean that once the game state is loaded, the jukebox should continue playing where it left off. Similarly to how the jukebox continues the microbe stage track when returning from the editor.

@DTanxxx
Copy link
Contributor

DTanxxx commented Nov 27, 2020

Ah I see. When I loaded into a save, I had set a breakpoint at SetupStreamsFromCategory method which had the foreach loops to check for any track that was previously playing.
Screen Shot 2020-11-28 at 12 12 03 PM

However the loops did find a previously playing track which also had the information on its position. Doesn't that mean the jukebox was already playing where it left off? Please let me know if I am misunderstanding something. Thanks.

@hhyyrylainen
Copy link
Member Author

On master I don't think the jukebox object is saved at all. Are you sure that is properly saved?
You should extract a save file (it's just a tar.gz file with json save in it) and look in it to see if the previous played positions are saved correctly and then loaded correctly.

@hhyyrylainen
Copy link
Member Author

What might be happening is that if you were in the stage, and then loaded a game, the jukebox may remember the tracks that were playing before you loaded the save and not the tracks that were playing when the save was made.

@hhyyrylainen hhyyrylainen removed this from the Release 0.5.3 milestone Dec 22, 2020
@hhyyrylainen hhyyrylainen moved this to Backburner in Thrive Planning Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backburner
Development

No branches or pull requests

2 participants