From 67b3c4a8cdb2f362df1a7605be4b7cfe186a2e5c Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Tue, 15 Sep 2026 23:26:22 -0400 Subject: [PATCH] Add fullscreen toggle (F11) with aspect-preserving 16:9 video scaling Windowed mode still stretches the anamorphic frame to fill 480x272 like the PSP. In fullscreen the video scales to fit the screen while keeping its 16:9 display ratio, letterboxing as needed. --- .../java/dev/quoije/umd/ui/PlayerApp.java | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) 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 8dbf232..56378c8 100644 --- a/ui/src/main/java/dev/quoije/umd/ui/PlayerApp.java +++ b/ui/src/main/java/dev/quoije/umd/ui/PlayerApp.java @@ -43,6 +43,7 @@ public final class PlayerApp extends Application { private RcoRenderer renderer; private volatile Controller controller; private volatile MoviePlayer moviePlayer; + private Stage stage; @Override public void start(Stage stage) { @@ -51,17 +52,30 @@ public final class PlayerApp extends Application { ? null : String.join(" ", getParameters().getRaw()); - menuCanvas = new Canvas(WIDTH, HEIGHT); - videoCanvas = new Canvas(WIDTH, HEIGHT); + this.stage = stage; + + menuCanvas = new Canvas(); + videoCanvas = new Canvas(); StackPane root = new StackPane(videoCanvas, menuCanvas); + menuCanvas.widthProperty().bind(root.widthProperty()); + menuCanvas.heightProperty().bind(root.heightProperty()); + videoCanvas.widthProperty().bind(root.widthProperty()); + videoCanvas.heightProperty().bind(root.heightProperty()); + Scene scene = new Scene(root, WIDTH, HEIGHT); scene.setFill(Color.BLACK); stage.setTitle("useless-umd-player"); stage.setScene(scene); stage.show(); - scene.setOnKeyPressed(event -> handleKey(event.getCode())); + scene.setOnKeyPressed(event -> { + if (event.getCode() == KeyCode.F11) { + stage.setFullScreen(!stage.isFullScreen()); + return; + } + handleKey(event.getCode()); + }); if (isoPath != null) { String path = isoPath; @@ -198,8 +212,26 @@ public final class PlayerApp extends Application { g.setFill(Color.BLACK); g.fillRect(0, 0, canvasWidth, canvasHeight); - // The PSP stretches the anamorphic 720x480 frame to fill 480x272. - g.drawImage(image, 0, 0, canvasWidth, canvasHeight); + if (stage.isFullScreen()) { + // Scale up to fill the screen but keep the 16:9 display ratio. + double aspect = 16.0 / 9.0; + double canvasAspect = canvasWidth / canvasHeight; + double drawW; + double drawH; + if (canvasAspect > aspect) { + drawH = canvasHeight; + drawW = canvasHeight * aspect; + } else { + drawW = canvasWidth; + drawH = canvasWidth / aspect; + } + double x = (canvasWidth - drawW) / 2.0; + double y = (canvasHeight - drawH) / 2.0; + g.drawImage(image, x, y, drawW, drawH); + } else { + // The PSP stretches the anamorphic 720x480 frame to fill 480x272. + g.drawImage(image, 0, 0, canvasWidth, canvasHeight); + } }); }