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

Wind Waker: Allow users to refresh, save/load, or share cutscene scenes at a specific point in time #726

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

themikelester
Copy link
Collaborator

The current demo time and pause state are now added to the save state string.

This allows users to refresh, save/load, or share demo scenes at a specific point in time. Since the pause state is also captured, if the demo was paused it will still be paused on load. This is also very useful for debugging. Pausing during certain actor animations will save the state, and then subsequent code changes will trigger refreshes which will load the demo back into the same state.

The big change here is that we need to a way to expose to the scene a way to play/pause noclip. I've done that by exposing the UI.togglePlayPause() method because of its simplicity, but there are several other alternatives.

@themikelester
Copy link
Collaborator Author

themikelester commented Nov 22, 2024

@magcius The main alternative to what I've done here would be to have WW demos have their own pause state, so the demos could be paused even if noclip is still reporting deltaTimes (and could also pause non-demo actors). But I think it makes more sense to use the master play/pause functionality and just expose that to the save/load state system. Thoughts?

Copy link
Owner

@magcius magcius left a comment

Choose a reason for hiding this comment

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

I'm not sure I see the utility of this? At one point I had the time and pause state in the save state, but removed it since people would get linked to a paused save state and end up confused.

src/viewer.ts Outdated Show resolved Hide resolved
@themikelester
Copy link
Collaborator Author

For developing, it's super useful to be able to save/load from a specific time in a cutscene (and it needs to load as paused to be useful).

For users, I could see utility in being able to share an interesting point in a cutscene. I wouldn't want to add time and pause state to all save states, but it feels important for demos.

@magcius
Copy link
Owner

magcius commented Nov 24, 2024

I'd be OK with something that saves the current pause state and time to localStorage if IS_DEVELOPMENT is enabled, and this could be done across all scenes if wanted, but I wouldn't want it on by default, and I don't think I'm ready to have it in a savestate yet.

@themikelester
Copy link
Collaborator Author

Oh wow I never knew about IS_DEVELOPMENT. Good thinking, that should work well for my purposes.

…class

No logic changes, this just moves all of those variables into a single class. This also does not change how individual scenes access the time data. E.g. `ViewerInput.time` and `ViewerInput.deltaTime` are unchanged
`time` is now public, so it doesn't make much sense for that function to exist
…t only)

Demo scenes will save their time/pause state when the demo is paused. If the page is reloaded (or code is modified), the scene will reload at the same time and maintain the paused state.

If the demo is resumed, the time/pause state is cleared. Reloading will then restart the demo. Very useful for debugging.
@themikelester
Copy link
Collaborator Author

I've updated this PR so that the scene's time/pause state is not included in the savestate. If requested, a scene can save and load the time/pause state to localStorage. ZWW demo scenes are currently the only scenes that do this.

Changes for all scenes:

  • Scenes can control their play/pause state via SceneContext.SceneTime.togglePlayPause()
  • Scenes can optionally save/load/delete their time/pause state via SceneContext.SceneTime

Changes for ZWW demo scenes:

  • The demo timeline is now synced to the scene's time. Setting the scene time before a demo is played will start the demo at the correct time.
  • In development mode: When a demo is paused, it's time/pause state is saved to localStorage. Reloading the page will load the demo at the same time and paused. Resuming the demo (or switching scenes) clears this state and reloading will restart the demo.

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.

2 participants