Repository navigation
Cutscenes: don't let the key that started a movie skip it - #8063
AdmiralTolwyn wants to merge 2 commits into
Conversation
Movies are skipped on the release of Escape, Enter or Space. When a movie is started by one of those keys, for example Enter in the tech room cutscene list, its release arrives once playback has begun and skips the movie at once. scp-fs2open#4461 already dropped deferred releases from the loading screen, but a live release still gets through. Skip only on the release of a key whose press arrived during playback, ignoring auto-repeat. The press listener only observes, so the other key listeners and the On Key Pressed hook still see presses, and it runs ahead of them so none can hide a press from it. Only the release that stops playback is consumed; other releases pass on, so a key held from before the movie is not left marked as down. Deferred key-downs are now dropped together with their releases, since a replayed down would count as a press.
dustinspace217
left a comment
There was a problem hiding this comment.
Reviewed at 9f9d1e9, and I could reproduce the fix.
Tested (Debug builds of master 5af50bd and this head, retail FS2 data, no mods, Linux, OpenGL): tech room cutscene list with every cutscene shown, Enter held for one second on the intro and then released. The keys were real X key events, not injected SDL events.
- master: three seconds after the release, the cutscene list is back.
- this PR: the intro is still playing. An Escape tap then returns to the list.
From reading: every movie the engine plays full screen, and so every movie a key can skip, goes through movie::play: the tech room, campaign and mission paths, and the Lua testing library's playCutscene. A script that drives its own player through gr.openMovie doesn't use these listeners. Nothing else listens for key-downs ahead of weight -20. key_flush() after the movie clears held keys. The record of presses is local to one play() call, which gives the back-to-back behavior the description lists.
Three small things, none blocking:
- The release listener's weight (inline).
- A third change mods could notice, beside the two listed: Enter or Space pressed on the loading screen and released during the movie now fires On Key Released with no On Key Pressed before it, since the deferred press is dropped. Master did the reverse.
- Escape isn't in the deferred filter in
os_remove_deferred_cutscene_key_events(), so an Escape tapped on a loading screen still skips the movie that follows, the same as master. The new comment there reads as if it covers every skip key.
Not tested: campaign and mission cutscenes, a key held through a loading screen, a scripted-UI mod, the script hooks, real key repeat, Windows and macOS.
| auto key_down_handle = | ||
| os::events::addEventListener(SDL_EVENT_KEY_DOWN, os::events::DEFAULT_LISTENER_WEIGHT - 20, key_down_listener); | ||
| auto key_up_handle = | ||
| os::events::addEventListener(SDL_EVENT_KEY_UP, os::events::DEFAULT_LISTENER_WEIGHT - 10, key_up_listener); |
There was a problem hiding this comment.
The press listener moved to -20, but this one stays at -10, the same weight as the scripted UI's key-up listener (rocket_ui.cpp:626). Listeners are ordered by std::sort on the weight, so which of the two runs first isn't defined. The scripted UI's handler consumes the event while its context is active, so if it sorts first, the release never gets here and the key can't skip. Master has the same tie, so this isn't new, but -20 here too would settle it. I read this from the code and did not run a scripted-UI mod.
Run the key-up listener at -20, before the scripted UI listener at -10 can consume the release. Equal weights have no defined order, so the old tie could hide a skip release from movie playback. Document the ordering beside the registration so the weight is not mistaken for an interchangeable priority.
|
Thanks for testing it. The release listener now runs at -20 too (1a0aa74), with a comment on why, so it always runs before the scripted UI's key-up listener. Build and unit tests pass, and the tech-room repro behaves as before: holding, repeating and releasing the Enter that started the movie leaves it playing, and a fresh Enter skips it. I don't have a scripted-UI mod to test the consuming case directly. I've also added the loading-screen press/release difference you found to the description. |
Movies are skipped on the release of Escape, Enter or Space. If one of those keys starts the movie, its release arrives once playback has begun and skips the movie at once. The easiest way to see it is the tech room cutscene list: select a cutscene, press Enter, and the movie is gone as soon as you let go of Enter. #4461 (for #4419) fixed the same thing for releases queued during the loading screen, but a live release still gets through.
This PR skips only on the release of a key whose press arrived during playback (auto-repeat doesn't count):
DEFAULT_LISTENER_WEIGHT - 20so that no other listener can consume a press before it's recorded.os_remove_deferred_cutscene_key_events()now drops deferred key-downs along with their releases. Otherwise a down queued during the loading screen would be replayed into the movie, count as a press, and its live release would skip it.Pressing and releasing Escape, Enter or Space during a movie still skips it. Three small changes mods could notice: On Key Released now fires during a movie for a skip key that was held from before it started (master swallowed that release); a skip key pressed during the loading screen and released during playback now fires On Key Released without a preceding On Key Pressed, because the deferred press is dropped (master fired the press and swallowed the release); and a key pressed during the first movie of a back-to-back pair no longer skips the second one if the first ends before the key is released.
Testing
OptionsManagerOverride.ShadowRenderMethodDefaultFollowsTheGlobal, which is unrelated.