From 1a4330f291a55c52e6661ea5f355aa3b953b0bd7 Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Wed, 16 Sep 2026 08:52:16 -0400 Subject: [PATCH] Open menu naturally via chapter events; M returns to menu; debounce M The menu state machine advances from the menu-intro state to the menu state only when the menu video crosses its chapter-2 marker (onChapter). Fire onChapter from the video loop as PTS crosses playlist markers. Also route the M key through the onMenu dispatcher so it returns to the menu video/title (not just drawing menu items), and debounce the key against auto-repeat. --- .../dev/quoije/umd/rco/vsmx/objects/MoviePlayer.java | 2 -- ui/src/main/java/dev/quoije/umd/ui/PlayerApp.java | 11 ++++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/dev/quoije/umd/rco/vsmx/objects/MoviePlayer.java b/core/src/main/java/dev/quoije/umd/rco/vsmx/objects/MoviePlayer.java index 05f26b2..6cfaf3b 100644 --- a/core/src/main/java/dev/quoije/umd/rco/vsmx/objects/MoviePlayer.java +++ b/core/src/main/java/dev/quoije/umd/rco/vsmx/objects/MoviePlayer.java @@ -80,8 +80,6 @@ public class MoviePlayer extends BaseNativeObject { if (!previousMenuMode && this.menuMode) { VsmxBaseObject callback = controller.getPropertyValue("onMenu"); - System.err.println("[menu] onMenu fires, callback=" + callback - + " (" + (callback == null ? "null" : callback.getClass().getSimpleName()) + ")"); if (callback instanceof VsmxFunction function) { interpreter.interpretFunction(function, null, new VsmxBaseObject[0]); } diff --git a/ui/src/main/java/dev/quoije/umd/ui/PlayerApp.java b/ui/src/main/java/dev/quoije/umd/ui/PlayerApp.java index 82c7d42..a183e29 100644 --- a/ui/src/main/java/dev/quoije/umd/ui/PlayerApp.java +++ b/ui/src/main/java/dev/quoije/umd/ui/PlayerApp.java @@ -69,8 +69,8 @@ public final class PlayerApp extends Application { private volatile boolean skipRequested = false; private volatile VsmxInterpreter menuInterpreter; - private volatile VsmxBaseObject mmActivate; private volatile VsmxNativeObject controllerObject; + private long lastMenuKeyNanos = 0; @Override public void start(Stage stage) { @@ -147,12 +147,18 @@ public final class PlayerApp extends Application { } private void openMenuDirectly() { + // Debounce key auto-repeat. + long now = System.nanoTime(); + if (now - lastMenuKeyNanos < 250_000_000L) { + return; + } + lastMenuKeyNanos = now; + VsmxInterpreter interpreter = menuInterpreter; VsmxNativeObject c = controllerObject; if (interpreter != null && c != null) { VsmxBaseObject callback = c.getPropertyValue("onMenu"); if (callback instanceof VsmxFunction function) { - System.err.println("[debug] returning to menu"); interpreter.interpretFunction(function, null, new VsmxBaseObject[0]); } } @@ -212,7 +218,6 @@ public final class PlayerApp extends Application { controller = (Controller) controllerObject.getObject(); moviePlayer = (MoviePlayer) movieplayer.getObject(); menuInterpreter = interpreter; - mmActivate = globals.getPropertyValue("mm_activate"); this.controllerObject = controllerObject; controller.callCallback(interpreter, "onAutoPlay", null); } catch (Exception e) {