diff --git a/docs/booth-runbook.md b/docs/booth-runbook.md index f6a2bb7b..5ec67e97 100644 --- a/docs/booth-runbook.md +++ b/docs/booth-runbook.md @@ -45,7 +45,7 @@ Booth mode itself runs fullscreen and ignores the menu's **Quit Game**. A game n | The game freezes | The watchdog restarts it within about a minute. | | Someone presses Cmd+Q | The game closes, and the watchdog opens it again. | | The player's controller disconnects | The game pauses and asks for the controller. Plug it back in, or press Start on another controller. | -| You want to clear the Endless Runner scores | **Endless Runner → Leaderboard → Reset scores**. | +| You want to clear the Endless Runner scores | Start the Endless Runner tile, pause and choose **Runner Menu**, then **Leaderboard → Reset scores**. (Or start the game once with `--route=runner`.) | ## Stop the game for maintenance diff --git a/docs/main-menu.md b/docs/main-menu.md index 2be6492e..239b79c8 100644 --- a/docs/main-menu.md +++ b/docs/main-menu.md @@ -1,6 +1,6 @@ # Main menu — implementation notes -Implemented 2026-09-17 from the Main Menu section of the GDD and §6 of the technical baseline. Engine verified: Godot 4.7.1.stable.official.a13da4feb. Scope is the central menu only. +Implemented 2026-09-17 from the Main Menu section of the GDD and §6 of the technical baseline; redesigned 2026-11-13 as a grid of game tiles. Engine verified: Godot 4.7.1.stable.official.a13da4feb. Scope is the central menu only. ## Run @@ -10,16 +10,31 @@ Open `hoppys-adventure-arcade/project.godot` in Godot 4.7.1 and press F6 from th /Applications/Godot.app/Contents/MacOS/Godot --path hoppys-adventure-arcade ``` -Arrow keys, Tab, D-pad, or left stick navigate; Enter / gamepad A activates; Escape / B closes overlays. Mouse hover takes preview control from keyboard/gamepad until the next intentional keyboard/gamepad input. +Arrow keys, Tab, D-pad, or left stick navigate; Enter / gamepad A activates; Escape / B closes overlays, and on the hub itself asks before quitting. Mouse hover takes preview control from keyboard/gamepad until the next intentional keyboard/gamepad input. + +## The grid + +The hub shows every game as a tile, three columns by two rows, so a visitor starts a game with one press: + +| | | | +| --- | --- | --- | +| Bay Area Blitz (`bay_area_blitz`) | Orbital Ops (`orbital_ops`) | The Enchanted Repo (`enchanted_repo`) | +| Endless Runner (`runner_game`) | Code City Brawl (`code_city_brawl`) | Heroes vs. Villains (`heroes_vs_villains`) | + +- **Catalog.** `scenes/main_menu/game_catalog.gd` lists the tiles in grid order: route, family eyebrow (Platformer, Endless Runner, Beat'em Up), one-line tagline, the `preview.gd` indices the tile and the showcase use (the first is the tile's art), and the Hoppy reaction. Adding a game means adding an entry there; the grid, the showcase groups and the focus map follow. +- **Tile.** `game_tile.gd` is a Button (it extends `menu_button.gd`, so it grows 5% on focus or hover) with its stage art cover-cropped inside the border, a lower scrim, the family, title and tagline, and an "ENTER / A PLAY" prompt while focused or hovered. The art is the same stage plates and runner stills the background previews use, loaded once through `preview.gd`; no separate tile art exists. +- **Navigation.** Left and right wrap within a row. Up and down step between the rows and, past them, to the utility button in the same column (Settings, Quit Game, Credits), which lead back onto the grid. Tab follows the order tiles, Settings, Quit Game, Credits (`main_menu.gd` `buttons`). Mouse hover focuses nothing but drives the preview and Hoppy; a click launches. +- **Launch.** A tile calls `AppRouter.go()` with its gameplay route, so the first entry opens the game's how-to-play card as before. The per-mode menus (`platformer_menu`, `runner_menu`, `beatem_menu`) are no longer on the hub's path: the games still return to them from their pause and results screens ("Return to Platformer Menu", the brawlers' and the runner's menu), and `--route=` / `--attract=` still name them. The runner's leaderboard lives in `runner_menu`, reached from a run's pause or game-over **Runner Menu** button or with `--route=runner`. +- **Hoppy.** The menu mascot stands top right, beside the title, at two thirds of its old size. The hovered tile's family picks the reaction: platformer jump, 3D runner, brawler jab. ## Behavior and ownership -- Scene-local showcase: idle previews 0–12 every 9 seconds; 1.2-second fades. Focusing a mode cycles its previews every 3 seconds with 0.6-second fades: Platformer cycles three themes; Beat’em Up cycles all three Code City Brawl stages followed by all three Heroes vs. Villains stages, and the Endless Runner cycles four in-game stills (corridor, power-ups, a jump over a hazard, boss). +- Scene-local showcase, behind the grid: idle previews 0–12 every 9 seconds; 1.2-second fades. Focusing or hovering a tile shows that game's previews, cycling every 3 seconds with 0.6-second fades where it has more than one: each platformer level holds its own plate, the Endless Runner cycles four in-game stills (corridor, power-ups, a jump over a hazard, boss), Code City Brawl its three districts and Heroes vs. Villains its three stages. The groups come from the catalog (`showcase_controller.GROUPS`). - Focus exit waits 2 seconds, then restores the idle index and remaining dwell. Modals pause showcase timing. Parallax continues behind overlays. - At most two preview nodes exist. During a fade, requests coalesce to the latest selection; the outgoing node is freed before another fade begins. Each preview is a `CanvasGroup`, so a fade blends the flattened scene instead of letting its parallax layers show through each other. Preview textures are loaded once and kept, so transitions never read from disk. -- Layout recenters on viewport resize (not every frame). Menu buttons grow 5% around their centre on hover/focus and keep that scale when their container re-sorts. +- Layout recenters on viewport resize (not every frame). Tiles and menu buttons grow 5% around their centre on hover/focus and keep that scale when their container re-sorts; the grid's 20 px gaps are wider than that growth, so grown tiles never cover their neighbours. Modals draw above a grown tile. - The UI uses a 1280×720 reference with expanding viewport coverage and centered composition. Backgrounds fill taller and wider windows. Pixel scenery uses nearest filtering. -- AppRouter validates known routes and prevents duplicate transitions. Mode buttons open their existing game menus. This graphics pass does not modify gameplay. +- AppRouter validates known routes and prevents duplicate transitions. Tiles open their games directly. The menu does not modify gameplay. - AudioService owns a single looping music player and one UI sound player. Music and SFX independently feed Master. The hub plays a calm lo-fi 8-bit loop (`Assets/Audio/Main Menu/hub_chiptune_loop.wav`, built by `tools/build_hub_chiptune.py`), whose `.import` loops the whole file. It plays at `AudioService.HUB_MUSIC_DB` (−15 dB), below the games' −10 dB, so a booth screen can run it all day. Booth mode (`AppRouter.set_booth` → `AudioService.set_attract`) keeps the same track. Synthesized UI blips are generated in code. Design and loop notes are in that folder's `PROMPTS.md`. - SaveService stores validated volume and fullscreen values in `user://settings.cfg`. Sliders apply immediately; closing settings persists them. Save failures appear in the UI. - Quit asks for confirmation and fades to black for 1 second. @@ -27,7 +42,7 @@ Arrow keys, Tab, D-pad, or left stick navigate; Enter / gamepad A activates; Esc ## Credits -The **Credits** button, after Settings and Quit Game, opens `scenes/credits/credits.tscn` (route `credits`). It shows the hand-written sections in `scenes/credits/credits.json` first. Then come the asset credits from the Third-party table of `ASSETS_LICENSES.md`, grouped into Music, Sound effects and Art, each with its license and, where the table gives them, its source and license links. An art pack whose music the game also uses appears under Art and Music; assets marked "Not referenced" are left out. The list scrolls by itself. Up and Down (held, for continuous scrolling) or the mouse wheel scroll it by hand, and Esc, B or **Return to Main Menu** go back to the hub. +The **Credits** button, after Settings and Quit Game under the grid, opens `scenes/credits/credits.tscn` (route `credits`). It shows the hand-written sections in `scenes/credits/credits.json` first. Then come the asset credits from the Third-party table of `ASSETS_LICENSES.md`, grouped into Music, Sound effects and Art, each with its license and, where the table gives them, its source and license links. An art pack whose music the game also uses appears under Art and Music; assets marked "Not referenced" are left out. The list scrolls by itself. Up and Down (held, for continuous scrolling) or the mouse wheel scroll it by hand, and Esc, B or **Return to Main Menu** go back to the hub. - **Asset credits** are generated. `tools/credits/build_credits.py` writes `scenes/credits/asset_credits.json` from `ASSETS_LICENSES.md`. After changing that table, run `python3 tools/credits/build_credits.py`; CI fails if the two differ. - **Hand-written credits** live in `credits.json`: a list of sections, each with a `title`, optional `lines` and optional `tracks` (`{"title": …, "used_by": …}`). Original music goes in the "Original music" section. To credit something else, add a track there or add a section. @@ -47,7 +62,9 @@ The first time a visitor enters a game, `AppRouter.go()` opens that game's how-t ## Art and replacement points -As of 2026-09-30, `hoppy.gd` uses the supplied `Assets/Character/Hoppy/2D/hoppy-sprite-pack/hoppy` SpriteFrames: idle by default, one jump on Platformer selection, and one jab then the default idle on Beat’em Up selection. Endless Runner hover or keyboard/gamepad focus crossfades to the existing `hoppy_runner_visual.tscn` rig running in place, rendered through a transparent, isolated 512×512 SubViewport. Leaving that selection restores 2D immediately through a 0.22-second fade; idle background cycling does not switch the character. Hidden 3D rendering and rig processing are disabled. Both versions face toward the buttons and share a ground anchor. `sprite_scale` and `transition_seconds` are exposed on the Hoppy node for iteration. The title uses a system monospace fallback; no final pixel font or logo was supplied. +As of 2026-09-30, `hoppy.gd` uses the supplied `Assets/Character/Hoppy/2D/hoppy-sprite-pack/hoppy` SpriteFrames: idle by default, one jump on a platformer tile, and one jab then the default idle on a beat 'em up tile. Hovering or focusing the Endless Runner tile crossfades to the existing `hoppy_runner_visual.tscn` rig running in place, rendered through a transparent, isolated 512×512 SubViewport. Leaving that selection restores 2D immediately through a 0.22-second fade; idle background cycling does not switch the character. Hidden 3D rendering and rig processing are disabled. Both versions face toward the grid and share a ground anchor. `sprite_scale` and `transition_seconds` are exposed on the Hoppy node for iteration. The title uses a system monospace fallback; no final pixel font or logo was supplied. + +The tiles and the background previews share the artwork below; the first row of each game's previews is its tile. | Preview | Source | | --- | --- | @@ -68,8 +85,8 @@ Updated 2026-10-08: all menu previews now use current stage artwork or captured /Applications/Godot.app/Contents/MacOS/Godot --path hoppys-adventure-arcade --script res://tests/menu_smoke.gd ``` -The behavioral smoke test covers preview timing and preservation, rapid input coalescing, bounded preview count, all thirteen previews, modal focus restoration, invalid routes, duplicate navigation, all three mode round trips, and audio player counts. It also dispatches keyboard, simulated gamepad, and mouse events. Mouse hover goes through `tests/support/pointer.gd`, so it and the character check below run headless in CI. A rendered run writes menu/settings screenshots to `/tmp` for layout inspection. It uses the normal settings path, so run against a disposable user profile if preserving settings during tests matters. +The behavioral smoke test covers preview timing and preservation, rapid input coalescing, bounded preview count, all thirteen previews, modal focus restoration and stacking, the Esc quit prompt, invalid routes, duplicate navigation, every tile's catalog entry (a real gameplay route with a how-to-play card, art, family, title and tagline), a launch-and-return round trip through every tile, and audio player counts. It also dispatches keyboard, simulated gamepad (across rows, into the utility buttons and wrapping), and mouse events. Mouse hover goes through `tests/support/pointer.gd`, so it and the character check below run headless in CI. A rendered run writes menu/settings screenshots to `/tmp` for layout inspection. It uses the normal settings path, so run against a disposable user profile if preserving settings during tests matters. Physical controller feel, audio loop quality, and Windows/Linux exports require later hands-on checks; no export presets or platform builds were added. -Character-specific check: run `--script res://tests/menu_hoppy_smoke.gd` to verify default idle, mouse-triggered 3D, keyboard-triggered brawler reaction, one-shot completion, rapid switching, and hidden-rig suspension. Graphical runs save both character states and modal coverage to `/tmp/menu-hoppy-*.png`. +Character-specific check: run `--script res://tests/menu_hoppy_smoke.gd` to verify default idle, mouse-triggered 3D on the runner tile, keyboard-triggered brawler reaction, one-shot completion, rapid switching, and hidden-rig suspension. Graphical runs save both character states and modal coverage to `/tmp/menu-hoppy-*.png`. diff --git a/docs/previews/main-menu.png b/docs/previews/main-menu.png index 4031ea96..0adbc4ca 100644 Binary files a/docs/previews/main-menu.png and b/docs/previews/main-menu.png differ diff --git a/docs/previews/settings.png b/docs/previews/settings.png index 2b636ffd..982000b5 100644 Binary files a/docs/previews/settings.png and b/docs/previews/settings.png differ diff --git a/hoppys-adventure-arcade/scenes/main_menu/game_catalog.gd b/hoppys-adventure-arcade/scenes/main_menu/game_catalog.gd new file mode 100644 index 00000000..2a9211ac --- /dev/null +++ b/hoppys-adventure-arcade/scenes/main_menu/game_catalog.gd @@ -0,0 +1,24 @@ +extends RefCounted +## The six games the hub shows as tiles, in grid order (three columns, two rows). Each entry names +## its AppRouter route, the family eyebrow, a one-line tagline, the preview.gd indices its tile and +## the showcase cycle through (the first is the tile's art), and the Hoppy reaction it triggers +## (hoppy.gd: 0 platformer jump, 1 runner 3D, 2 brawler jab). +const GAMES: Array[Dictionary] = [ + {"route": "bay_area_blitz", "title": "BAY AREA BLITZ", "family": "PLATFORMER", + "tagline": "Cable cars. Code critters. Chaos.", "previews": [0], "reaction": 0}, + {"route": "orbital_ops", "title": "ORBITAL OPS", "family": "PLATFORMER", + "tagline": "Zero gravity. Broken legacy routines.", "previews": [1], "reaction": 0}, + {"route": "enchanted_repo", "title": "THE ENCHANTED REPO", "family": "PLATFORMER", + "tagline": "Ancient armor. Unstable branches.", "previews": [2], "reaction": 0}, + {"route": "runner_game", "title": "ENDLESS RUNNER", "family": "ENDLESS RUNNER", + "tagline": "Outrun the unreviewed backlog.", "previews": [3, 4, 5, 6], "reaction": 1}, + {"route": "code_city_brawl", "title": "CODE CITY BRAWL", "family": "BEAT'EM UP", + "tagline": "Three districts. One final merge.", "previews": [7, 8, 9], "reaction": 2}, + {"route": "heroes_vs_villains", "title": "HEROES VS. VILLAINS", "family": "BEAT'EM UP", + "tagline": "Four villains. Review, triage, secure.", "previews": [10, 11, 12], "reaction": 2}, +] +const COLUMNS := 3 + +## The preview indices each tile cycles through, in grid order (the showcase's groups). +static func preview_groups() -> Array: + return GAMES.map(func(game: Dictionary) -> Array: return game.previews) diff --git a/hoppys-adventure-arcade/scenes/main_menu/game_catalog.gd.uid b/hoppys-adventure-arcade/scenes/main_menu/game_catalog.gd.uid new file mode 100644 index 00000000..9dad202c --- /dev/null +++ b/hoppys-adventure-arcade/scenes/main_menu/game_catalog.gd.uid @@ -0,0 +1 @@ +uid://ccak0l33thxks diff --git a/hoppys-adventure-arcade/scenes/main_menu/game_tile.gd b/hoppys-adventure-arcade/scenes/main_menu/game_tile.gd new file mode 100644 index 00000000..10baf422 --- /dev/null +++ b/hoppys-adventure-arcade/scenes/main_menu/game_tile.gd @@ -0,0 +1,92 @@ +extends "res://scenes/main_menu/menu_button.gd" +## One game on the hub grid: its stage art cover-cropped behind a lower scrim, the family, title +## and tagline, and a PLAY prompt that appears while the tile is focused or hovered. The Button +## itself owns focus, hover and pressed; every child ignores the mouse, so the tile reacts as one +## control. The grow on focus comes from menu_button.gd. +const Style := preload("res://scenes/main_menu/menu_style.gd") +const Preview := preload("res://scenes/main_menu/preview.gd") +const Prompts := preload("res://app/controller_prompts.gd") +const TILE_SIZE := Vector2(362, 188) +const BORDER := 3 +var route := "" +var game_index := -1 +var art: Array[TextureRect] = [] +var play_prompt: Label + +func setup(index: int, game: Dictionary) -> void: + game_index = index + route = game.route + name = String(game.route).to_pascal_case() + "Tile" + text = "" + custom_minimum_size = TILE_SIZE + clip_contents = true + for state in ["normal", "hover", "pressed", "focus"]: + var box := StyleBoxFlat.new() + box.bg_color = Color("10182b") + box.border_color = Color("435464") if state == "normal" else Style.MINT + box.set_border_width_all(BORDER) + add_theme_stylebox_override(state, box) + var first: int = game.previews[0] + for texture in Preview.textures(first): + var plate := TextureRect.new() + plate.texture = texture + plate.expand_mode = TextureRect.EXPAND_IGNORE_SIZE + plate.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_COVERED + plate.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR if Preview.STILLS.has(first) \ + else CanvasItem.TEXTURE_FILTER_NEAREST + _fill(plate) + art.append(plate) + var scrim := TextureRect.new() + var gradient := Gradient.new() + gradient.set_color(0, Color(0.025, 0.045, 0.08, 0.0)) + gradient.set_color(1, Color(0.025, 0.045, 0.08, 0.92)) + var scrim_texture := GradientTexture2D.new() + scrim_texture.gradient = gradient + scrim_texture.fill_from = Vector2(0, 0.4) + scrim_texture.fill_to = Vector2(0, 1.0) + scrim.texture = scrim_texture + _fill(scrim) + var column := VBoxContainer.new() + column.add_theme_constant_override("separation", 0) + column.mouse_filter = Control.MOUSE_FILTER_IGNORE + # Anchored to the bottom-left corner and growing upward, so the text block hugs the bottom + # whatever its height. + column.set_anchors_and_offsets_preset(Control.PRESET_BOTTOM_LEFT) + column.grow_vertical = Control.GROW_DIRECTION_BEGIN + column.offset_left = 16 + column.offset_top = -14 + column.offset_bottom = -14 + add_child(column) + for label: Label in [Style.label(game.family, 11, Style.MINT), Style.label(game.title, 21), + Style.label(game.tagline, 12, Color("afbdc9"))]: + label.mouse_filter = Control.MOUSE_FILTER_IGNORE + column.add_child(label) + play_prompt = Style.label("", 12, Style.MINT) + play_prompt.mouse_filter = Control.MOUSE_FILTER_IGNORE + play_prompt.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT + # Bright stage ceilings sit behind the prompt, so it carries its own dark edge. + play_prompt.add_theme_color_override("font_outline_color", Color(0.025, 0.045, 0.08, 0.9)) + play_prompt.add_theme_constant_override("outline_size", 5) + play_prompt.set_anchors_and_offsets_preset(Control.PRESET_TOP_RIGHT) + play_prompt.offset_left = -176 + play_prompt.offset_right = -16 + play_prompt.offset_top = 12 + play_prompt.offset_bottom = 36 + play_prompt.visible = false + Prompts.track(play_prompt, func() -> String: + return "%s PLAY" % Prompts.either("ENTER", &"ui_accept", true)) + add_child(play_prompt) + for signal_name in ["mouse_entered", "mouse_exited", "focus_entered", "focus_exited"]: + connect(signal_name, _update_prompt) + +func _fill(node: Control) -> void: + node.mouse_filter = Control.MOUSE_FILTER_IGNORE + node.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) + node.offset_left = BORDER + node.offset_top = BORDER + node.offset_right = -BORDER + node.offset_bottom = -BORDER + add_child(node) + +func _update_prompt() -> void: + play_prompt.visible = is_hovered() or has_focus() diff --git a/hoppys-adventure-arcade/scenes/main_menu/game_tile.gd.uid b/hoppys-adventure-arcade/scenes/main_menu/game_tile.gd.uid new file mode 100644 index 00000000..1281e7e8 --- /dev/null +++ b/hoppys-adventure-arcade/scenes/main_menu/game_tile.gd.uid @@ -0,0 +1 @@ +uid://c2buvyk1dgv22 diff --git a/hoppys-adventure-arcade/scenes/main_menu/main_menu.gd b/hoppys-adventure-arcade/scenes/main_menu/main_menu.gd index e3790f43..d54f2317 100644 --- a/hoppys-adventure-arcade/scenes/main_menu/main_menu.gd +++ b/hoppys-adventure-arcade/scenes/main_menu/main_menu.gd @@ -2,10 +2,16 @@ extends Node2D const Style = preload("res://scenes/main_menu/menu_style.gd") const Preview = preload("res://scenes/main_menu/preview.gd") const Prompts := preload("res://app/controller_prompts.gd") +const GameCatalog = preload("res://scenes/main_menu/game_catalog.gd") +const GameTile = preload("res://scenes/main_menu/game_tile.gd") +const TITLE_Y := 46.0 @onready var showcase = $Showcase @onready var hoppy = $Interface/Hoppy var ui: Control +## The six game tiles in grid order, then Settings, Quit Game and Credits. var buttons: Array[Button] = [] +var tiles: Array[Button] = [] +var utilities: Array[Button] = [] var preview_note: Label var caption: Label var dots: Label @@ -29,7 +35,7 @@ func _ready() -> void: shade = TextureRect.new() var gradient := Gradient.new() gradient.set_color(0, Color(0.025, 0.045, 0.08, 0.97)) - gradient.set_color(1, Color(0.025, 0.045, 0.08, 0.15)) + gradient.set_color(1, Color(0.025, 0.045, 0.08, 0.35)) var texture := GradientTexture2D.new() texture.gradient = gradient texture.fill_from = Vector2(0, 0) @@ -45,78 +51,84 @@ func _ready() -> void: footer_gradient.set_color(1, Color(0.025, 0.045, 0.08, 0.9)) var footer_texture := GradientTexture2D.new() footer_texture.gradient = footer_gradient - footer_texture.fill_from = Vector2(0, 0.65) - footer_texture.fill_to = Vector2(0, 0.92) + footer_texture.fill_from = Vector2(0, 0.7) + footer_texture.fill_to = Vector2(0, 0.95) footer_shade.texture = footer_texture footer_shade.mouse_filter = Control.MOUSE_FILTER_IGNORE ui.add_child(footer_shade) hoppy.reparent(ui) - var eyebrow := Style.label("C O D E R A B B I T / A R C A D E", 14, Style.MINT) - eyebrow.position = Vector2(76, 39) + var eyebrow := Style.label("C O D E R A B B I T / A R C A D E", 13, Style.MINT) + eyebrow.position = Vector2(76, 30) ui.add_child(eyebrow) title = VBoxContainer.new() - title.position = Vector2(72, 96) - title.add_theme_constant_override("separation", -12) + title.position = Vector2(72, TITLE_Y) + title.add_theme_constant_override("separation", -8) ui.add_child(title) - title.add_child(Style.label("HOPPY'S", 68)) - title.add_child(Style.label("ADVENTURE", 49)) - title.add_child(Style.label("A R C A D E", 30, Color("f5a568"))) - var subtitle := Style.label("THREE WAYS TO PLAY. ONE HOPPY.", 13, Color("afbdc9")) - subtitle.position = Vector2(77, 284) + title.add_child(Style.label("HOPPY'S ADVENTURE", 44)) + title.add_child(Style.label("A R C A D E", 24, Color("f5a568"))) + var subtitle := Style.label("SIX GAMES. ONE HOPPY. PICK A TILE TO PLAY.", 13, Color("afbdc9")) + subtitle.position = Vector2(77, 128) ui.add_child(subtitle) - var column := VBoxContainer.new() - column.position = Vector2(76, 328) - column.add_theme_constant_override("separation", 12) - ui.add_child(column) - var names := ["01 Platformer Game", "02 Endless Runner", "03 Beat'em Up"] - var routes := ["platformer", "runner", "beatem_up"] - for i in 3: - var button := Style.button(names[i]) - column.add_child(button) - buttons.append(button) - _connect_button(button, i) - button.pressed.connect(_launch.bind(routes[i])) - var utilities := HBoxContainer.new() - utilities.position = Vector2(76, 568) + var grid := GridContainer.new() + grid.name = "Games" + grid.columns = GameCatalog.COLUMNS + grid.position = Vector2(77, 160) + # Wider than the 1.05 grow of a focused tile, so grown tiles never cover their neighbours. + grid.add_theme_constant_override("h_separation", 20) + grid.add_theme_constant_override("v_separation", 20) + ui.add_child(grid) + for i in GameCatalog.GAMES.size(): + var game: Dictionary = GameCatalog.GAMES[i] + var tile := Button.new() + tile.set_script(GameTile) + grid.add_child(tile) + tile.setup(i, game) + tiles.append(tile) + buttons.append(tile) + _connect_button(tile, i, false) + tile.pressed.connect(_launch.bind(game.route)) + var utility_row := HBoxContainer.new() + utility_row.position = Vector2(76, 584) # Wider than the focus arrow's 25 px reach, so it never sits on the neighbouring button. - utilities.add_theme_constant_override("separation", 28) - ui.add_child(utilities) + utility_row.add_theme_constant_override("separation", 28) + ui.add_child(utility_row) for i in 2: var button := Style.button("Settings" if i == 0 else "Quit Game", 46) button.custom_minimum_size.x = 160 - utilities.add_child(button) + utility_row.add_child(button) buttons.append(button) + utilities.append(button) _connect_button(button, -1) button.pressed.connect(_open_settings.bind(button) if i == 0 else _open_quit.bind(button)) - # Last in `buttons`, so buttons[3] and buttons[4] stay Settings and Quit Game. + # Last in `buttons`, so the tiles come first and Settings and Quit Game keep their places. var credits := Style.button("Credits", 46) credits.name = "CreditsButton" credits.custom_minimum_size.x = 160 - utilities.add_child(credits) + utility_row.add_child(credits) buttons.append(credits) + utilities.append(credits) _connect_button(credits, -1) credits.pressed.connect(_launch.bind("credits")) - for i in buttons.size(): - buttons[i].focus_neighbor_top = buttons[i].get_path_to(buttons[(i - 1 + buttons.size()) % buttons.size()]) - buttons[i].focus_neighbor_bottom = buttons[i].get_path_to(buttons[(i + 1) % buttons.size()]) + _wire_focus() var footer := Style.label("", 12, Color("9baebc")) Prompts.track(footer, func() -> String: - return "↑ ↓ SELECT %s CONFIRM" % Prompts.either("ENTER", &"ui_accept", true)) - footer.position = Vector2(76, 670) + return "← → ↑ ↓ SELECT %s PLAY %s QUIT" % [ + Prompts.either("ENTER", &"ui_accept", true), Prompts.either("ESC", &"ui_cancel", true)]) + footer.position = Vector2(76, 672) ui.add_child(footer) - caption = Style.label("", 21) + caption = Style.label("", 18) caption.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT - caption.position = Vector2(640, 592) - caption.size.x = 560 + caption.position = Vector2(640, 594) + caption.size.x = 563 ui.add_child(caption) - dots = Style.label("", 15, Style.MINT) + dots = Style.label("", 13, Style.MINT) dots.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT - dots.position = Vector2(640, 628) - dots.size.x = 560 + dots.position = Vector2(640, 624) + dots.size.x = 563 ui.add_child(dots) - preview_note = Style.label("WORLD PREVIEW", 12, Color("afbdc9")) - preview_note.position = Vector2(640, 566) - preview_note.size.x = 560 + preview_note = Style.label("WORLD PREVIEW", 11, Color("afbdc9")) + preview_note.position = Vector2(640, 578) + preview_note.size.x = 563 preview_note.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT ui.add_child(preview_note) showcase.preview_changed.connect(_preview_changed) @@ -126,9 +138,35 @@ func _ready() -> void: _layout.call_deferred() buttons[0].grab_focus() +## Arrows and the D-pad move across the grid: left and right wrap within a row, up and down step +## between the two rows and, past them, to the utility button in the same column (Settings, Quit +## Game, Credits), which lead back onto the grid. Tab follows `buttons` order. +func _wire_focus() -> void: + var columns := GameCatalog.COLUMNS + var rows := ceili(tiles.size() / float(columns)) + for i in tiles.size(): + var column := i % columns + var row := i / columns + var tile := tiles[i] + tile.focus_neighbor_left = tile.get_path_to(tiles[row * columns + (column + columns - 1) % columns]) + tile.focus_neighbor_right = tile.get_path_to(tiles[row * columns + (column + 1) % columns]) + var utility := utilities[mini(column, utilities.size() - 1)] + tile.focus_neighbor_top = tile.get_path_to(tiles[i - columns] if row > 0 else utility) + tile.focus_neighbor_bottom = tile.get_path_to(tiles[i + columns] if row < rows - 1 else utility) + for u in utilities.size(): + var button := utilities[u] + button.focus_neighbor_left = button.get_path_to(utilities[(u + utilities.size() - 1) % utilities.size()]) + button.focus_neighbor_right = button.get_path_to(utilities[(u + 1) % utilities.size()]) + var column := mini(u, columns - 1) + button.focus_neighbor_top = button.get_path_to(tiles[(rows - 1) * columns + column]) + button.focus_neighbor_bottom = button.get_path_to(tiles[column]) + for i in buttons.size(): + buttons[i].focus_previous = buttons[i].get_path_to(buttons[(i - 1 + buttons.size()) % buttons.size()]) + buttons[i].focus_next = buttons[i].get_path_to(buttons[(i + 1) % buttons.size()]) + func _process(delta: float) -> void: elapsed += delta - title.position.y = 96 + sin(elapsed * PI) * 3 + title.position.y = TITLE_Y + sin(elapsed * PI) * 2 # Keep composition centered as expand stretch exposes extra width or height. Runs on resize only: # rewriting sizes every frame forces the button containers to re-sort (and reset their scale). @@ -143,7 +181,8 @@ func _layout() -> void: if modal: modal.get_child(0).position = -extra modal.get_child(0).size = get_viewport_rect().size - hoppy.position = Vector2(964, 552) + hoppy.position = Vector2(1160, 150) + hoppy.scale = Vector2.ONE * 0.66 func _input(event: InputEvent) -> void: if AppRouter.busy: @@ -156,22 +195,23 @@ func _input(event: InputEvent) -> void: if not modal: var focused := get_viewport().gui_get_focus_owner() var id := buttons.find(focused) - _select(id if id < 3 else -1) + _select(id if id < tiles.size() else -1) if event.is_action_pressed("ui_cancel"): if modal: _close_modal() else: - _open_quit(buttons[4]) + _open_quit(utilities[1]) get_viewport().set_input_as_handled() -func _connect_button(button: Button, group: int) -> void: - var arrow := Style.label("›", 26, Style.MINT) - arrow.position = Vector2(-25, 13) - arrow.mouse_filter = Control.MOUSE_FILTER_IGNORE - arrow.visible = false - button.add_child(arrow) - button.focus_entered.connect(func(): arrow.visible = true) - button.focus_exited.connect(func(): arrow.visible = false) +func _connect_button(button: Button, group: int, arrow_marker := true) -> void: + if arrow_marker: + var arrow := Style.label("›", 26, Style.MINT) + arrow.position = Vector2(-25, 13) + arrow.mouse_filter = Control.MOUSE_FILTER_IGNORE + arrow.visible = false + button.add_child(arrow) + button.focus_entered.connect(func(): arrow.visible = true) + button.focus_exited.connect(func(): arrow.visible = false) button.mouse_entered.connect(func(): if modal or AppRouter.busy: return keyboard_input = false @@ -192,9 +232,10 @@ func _launch(route: String) -> void: AudioService.play_ui(1) AppRouter.go(route) +## `group` is a tile's index in GameCatalog.GAMES, or -1 for none. func _select(group: int) -> void: showcase.select_group(group) - hoppy.reaction = group + hoppy.reaction = GameCatalog.GAMES[group].reaction if group >= 0 else -1 func _preview_changed(index: int) -> void: caption.text = Preview.TITLES[index] @@ -211,6 +252,8 @@ func _make_modal(invoker: Control, heading: String) -> VBoxContainer: button.focus_mode = Control.FOCUS_NONE modal = Control.new() modal.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) + # Above a hovered tile, which menu_button.gd raises to z 1 so it grows over its neighbours. + modal.z_index = 2 ui.add_child(modal) var dim := ColorRect.new() dim.color = Color(0.01, 0.02, 0.04, 0.9) diff --git a/hoppys-adventure-arcade/scenes/main_menu/main_menu.tscn b/hoppys-adventure-arcade/scenes/main_menu/main_menu.tscn index 284f2735..9bc30f51 100644 --- a/hoppys-adventure-arcade/scenes/main_menu/main_menu.tscn +++ b/hoppys-adventure-arcade/scenes/main_menu/main_menu.tscn @@ -14,5 +14,6 @@ script = ExtResource("2") layer = 1 [node name="Hoppy" type="Node2D" parent="Interface"] -position = Vector2(964, 562) +position = Vector2(1160, 150) +scale = Vector2(0.66, 0.66) script = ExtResource("3") diff --git a/hoppys-adventure-arcade/scenes/main_menu/mode_portal.gd b/hoppys-adventure-arcade/scenes/main_menu/mode_portal.gd deleted file mode 100644 index b51e6146..00000000 --- a/hoppys-adventure-arcade/scenes/main_menu/mode_portal.gd +++ /dev/null @@ -1,29 +0,0 @@ -extends Control -## Honest navigation endpoint until each microgame is implemented. -const Style = preload("res://scenes/main_menu/menu_style.gd") -@export var mode_title := "Platformer Game" -@export var description := "Bay Area Blitz · Orbital Ops · Enchanted Repo" -func _ready() -> void: - theme = Style.theme() - var background := ColorRect.new() - background.color = Color("101d2d") - background.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) - add_child(background) - var center := CenterContainer.new() - center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) - add_child(center) - var column := VBoxContainer.new() - column.add_theme_constant_override("separation", 25) - center.add_child(column) - column.add_child(Style.label("NEXT ADVENTURE", 16, Style.MINT)) - column.add_child(Style.label(mode_title.to_upper(), 42)) - column.add_child(Style.label(description, 17)) - column.add_child(Style.label("Coming soon — this mode is not playable yet.", 17, Color("afbdc9"))) - var back := Style.button("Return to Main Menu") - column.add_child(back) - back.pressed.connect(func(): AppRouter.go("hub")) - back.grab_focus() -func _unhandled_input(event: InputEvent) -> void: - if event.is_action_pressed("ui_cancel"): - AppRouter.go("hub") - get_viewport().set_input_as_handled() diff --git a/hoppys-adventure-arcade/scenes/main_menu/mode_portal.gd.uid b/hoppys-adventure-arcade/scenes/main_menu/mode_portal.gd.uid deleted file mode 100644 index 31c2f70a..00000000 --- a/hoppys-adventure-arcade/scenes/main_menu/mode_portal.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://chw0cs632jkvq diff --git a/hoppys-adventure-arcade/scenes/main_menu/preview.gd b/hoppys-adventure-arcade/scenes/main_menu/preview.gd index f565e3d6..c468d308 100644 --- a/hoppys-adventure-arcade/scenes/main_menu/preview.gd +++ b/hoppys-adventure-arcade/scenes/main_menu/preview.gd @@ -44,6 +44,15 @@ static func warm() -> void: for path in STILLS.values(): _texture(path) +## The plates (or still) preview `index` draws, back to front, for a hub tile's art. +static func textures(index: int) -> Array[Texture2D]: + var result: Array[Texture2D] = [] + for path in LAYERS.get(index, [STILLS.get(index, "")]): + var tex := _texture(path) + if tex != null: + result.append(tex) + return result + static func _texture(path: String) -> Texture2D: if not _textures.has(path): _textures[path] = load(path) if ResourceLoader.exists(path) else null diff --git a/hoppys-adventure-arcade/scenes/main_menu/showcase_controller.gd b/hoppys-adventure-arcade/scenes/main_menu/showcase_controller.gd index fd1d1925..495ffea7 100644 --- a/hoppys-adventure-arcade/scenes/main_menu/showcase_controller.gd +++ b/hoppys-adventure-arcade/scenes/main_menu/showcase_controller.gd @@ -1,7 +1,9 @@ extends Node2D signal preview_changed(index: int) const Preview = preload("res://scenes/main_menu/preview.gd") -const GROUPS = [[0, 1, 2], [3, 4, 5, 6], [7, 8, 9, 10, 11, 12]] +const GameCatalog = preload("res://scenes/main_menu/game_catalog.gd") +## One group per hub tile, in grid order: the previews a focused tile cycles through. +static var GROUPS: Array = GameCatalog.preview_groups() const COUNT := 13 var idle_index := 0 var idle_remaining := 9.0 diff --git a/hoppys-adventure-arcade/tests/credits_screen.gd b/hoppys-adventure-arcade/tests/credits_screen.gd index 6d99e760..b18005e6 100644 --- a/hoppys-adventure-arcade/tests/credits_screen.gd +++ b/hoppys-adventure-arcade/tests/credits_screen.gd @@ -83,8 +83,8 @@ func run() -> void: await wait(0.4) var menu := current_scene var credits_button: Button = menu.buttons[menu.buttons.size() - 1] - check(menu.buttons.size() == 6 and credits_button.text == "Credits" - and menu.buttons[3].text == "Settings" and menu.buttons[4].text == "Quit Game", + check(menu.buttons.size() == 9 and credits_button.text == "Credits" + and menu.buttons[6].text == "Settings" and menu.buttons[7].text == "Quit Game", "The hub's Credits button follows Settings and Quit Game") credits_button.pressed.emit() await settle_route() diff --git a/hoppys-adventure-arcade/tests/menu_hoppy_smoke.gd b/hoppys-adventure-arcade/tests/menu_hoppy_smoke.gd index 1f4546de..a8b52b2b 100644 --- a/hoppys-adventure-arcade/tests/menu_hoppy_smoke.gd +++ b/hoppys-adventure-arcade/tests/menu_hoppy_smoke.gd @@ -23,18 +23,18 @@ func run() -> void: check(hoppy.sprite.animation == &"idle", "Default Hoppy idles in 2D") check(hoppy.runner_view.render_target_update_mode == SubViewport.UPDATE_DISABLED, "Hidden 3D render disabled") await capture("/tmp/menu-hoppy-2d.png") - Pointer.hover(menu.buttons[1]) + Pointer.hover(menu.buttons[3]) # Endless Runner tile await wait(1) check(hoppy.runner_image.visible and hoppy.runner_image.modulate.a == 1, "Runner shows 3D") check(hoppy.sprite.modulate.a == 0, "2D fades away") check(hoppy.runner.anim_state == &"run", "3D run animation active") await capture("/tmp/menu-hoppy-3d.png") - menu._open_settings(menu.buttons[3]) + menu._open_settings(menu.buttons[6]) await wait(0.2) await capture("/tmp/menu-hoppy-modal.png") menu._close_modal() menu.keyboard_input = true - menu.buttons[2].grab_focus() + menu.buttons[4].grab_focus() # Code City Brawl tile await wait(0.7) check(hoppy.sprite.animation == &"idle" and hoppy.sprite.sprite_frames == hoppy.PLATFORMER, "Brawler jab returns to default idle") await wait(1.0) @@ -43,7 +43,7 @@ func run() -> void: await wait(0.8) check(hoppy.sprite.animation == &"idle", "Platformer jump returns to idle") for i in 20: - menu._select(i % 3) + menu._select(i % 6) await wait(0.03) menu._select(-1) await wait(0.4) diff --git a/hoppys-adventure-arcade/tests/menu_return_layout.gd b/hoppys-adventure-arcade/tests/menu_return_layout.gd index f206dce5..945ccdd2 100644 --- a/hoppys-adventure-arcade/tests/menu_return_layout.gd +++ b/hoppys-adventure-arcade/tests/menu_return_layout.gd @@ -50,10 +50,10 @@ func check_menu(label: String) -> void: if DisplayServer.get_name() != "headless": await RenderingServer.frame_post_draw root.get_texture().get_image().save_png("/tmp/hoppy-return-%s.png" % label) -func park_mouse_on(menu_index: int) -> void: - # Leave the pointer where the menu button will appear, as a player's mouse would be. +func park_mouse_on(tile_index: int) -> void: + # Leave the pointer where a game tile will appear, as a player's mouse would be. var motion := InputEventMouseMotion.new() - motion.position = Vector2(200, 360 + menu_index * 74) + motion.position = Vector2(258 + (tile_index % 3) * 382, 254 + (tile_index / 3) * 208) motion.relative = Vector2(1, 1) Input.parse_input_event(motion) func run() -> void: diff --git a/hoppys-adventure-arcade/tests/menu_smoke.gd b/hoppys-adventure-arcade/tests/menu_smoke.gd index e29e5b44..53f2ef8b 100644 --- a/hoppys-adventure-arcade/tests/menu_smoke.gd +++ b/hoppys-adventure-arcade/tests/menu_smoke.gd @@ -1,7 +1,12 @@ extends SceneTree ## Run with --path --script res://tests/menu_smoke.gd. Runs headless in CI; a rendered run ## also saves screenshots. Pointer moves go through tests/support/pointer.gd so they hover headless. +## The hub is a grid of six game tiles (scenes/main_menu/game_catalog.gd), then Settings, Quit Game +## and Credits: `buttons[0..5]` are the tiles, `buttons[6]` Settings, `buttons[7]` Quit Game. const Pointer := preload("res://tests/support/pointer.gd") +const GameCatalog := preload("res://scenes/main_menu/game_catalog.gd") +const HowToPlayData := preload("res://app/how_to_play_data.gd") +const SETTINGS := 6 var failures := 0 func _initialize() -> void: call_deferred("run") @@ -11,6 +16,14 @@ func check(condition: bool, message: String) -> void: push_error(message) func wait(seconds: float) -> void: await create_timer(seconds).timeout +## One press and release of a pad button, each its own event, dispatched through Godot's input. +func pad_press(button: JoyButton) -> void: + for pressed in [true, false]: + var pad := InputEventJoypadButton.new() + pad.button_index = button + pad.pressed = pressed + Input.parse_input_event(pad) + await process_frame func run() -> void: change_scene_to_file("res://scenes/main_menu/main_menu.tscn") await wait(0.2) @@ -19,9 +32,9 @@ func run() -> void: check(showcase.active_index == 0, "Initial preview") showcase.set_process(false) showcase.idle_remaining = 4.0 - showcase.select_group(1) + showcase.select_group(3) await wait(0.9) - check(showcase.active_index == 3, "Runner selects corridor") + check(showcase.active_index == 3, "Runner tile selects corridor") showcase._process(3.1) await wait(0.7) check(showcase.active_index == 4, "Runner cycles its gameplay previews") @@ -32,48 +45,93 @@ func run() -> void: showcase._process(1.1) await wait(1.3) check(showcase.active_index == 0, "Resume restores idle index") - showcase.select_group(0) + showcase.select_group(1) + await wait(0.7) + # A rendered run can still be finishing the 1.2 s resume fade here; let it land first. + while showcase.fade and showcase.fade.is_running(): + await process_frame showcase._process(3.1) await wait(0.7) - check(showcase.active_index == 1, "Platformer cycles") - showcase.select_group(2) + check(showcase.active_index == 1, "A one-stage platformer tile holds its preview") + showcase.select_group(4) await wait(0.7) showcase._process(3.1) await wait(0.7) - check(showcase.active_index == 8, "Brawler cycles") - for expected in [9, 10, 11, 12, 7]: + check(showcase.active_index == 8, "Code City Brawl cycles its districts") + for expected in [9, 7]: + showcase._process(3.0) + await wait(0.7) + check(showcase.active_index == expected, "Code City Brawl wraps its districts") + showcase.select_group(5) + await wait(0.7) + for expected in [11, 12, 10]: showcase._process(3.0) await wait(0.7) - check(showcase.active_index == expected, "Brawler includes both campaigns and wraps") + check(showcase.active_index == expected, "Heroes vs. Villains cycles its stages and wraps") + check(showcase.GROUPS.size() == GameCatalog.GAMES.size(), "One showcase group per tile") for i in 30: - showcase.select_group(i % 3) + showcase.select_group(i % showcase.GROUPS.size()) check(showcase.get_child_count() <= 2, "Preview count bounded during rapid input") - showcase.select_group(1) + showcase.select_group(3) await wait(1.8) check(showcase.active_index == 3 and showcase.get_child_count() == 1, "Latest focus wins and settles") for i in showcase.COUNT: showcase.transition_to(i, 0) check(showcase.active_index == i, "All configured previews instantiate") check(not showcase.active.plates.is_empty(), "Preview has stage artwork: %d" % i) - menu._open_settings(menu.buttons[3]) + menu._open_settings(menu.buttons[SETTINGS]) check(menu.modal != null and showcase.suspended, "Settings pauses showcase") check(menu.modal.is_ancestor_of(root.gui_get_focus_owner()), "Settings captures focus") + check(menu.modal.z_index > menu.buttons[0].z_index, "Settings draws over a grown tile") menu._close_modal() await process_frame check(menu.modal == null and not showcase.suspended, "Settings closes cleanly") - check(root.gui_get_focus_owner() == menu.buttons[3], "Settings restores focus") + check(root.gui_get_focus_owner() == menu.buttons[SETTINGS], "Settings restores focus") + # Esc on the hub asks before quitting; Esc again keeps playing. + var escape := InputEventAction.new() + escape.action = "ui_cancel" + escape.pressed = true + Input.parse_input_event(escape) + await process_frame + check(menu.modal != null and menu.modal_return == menu.buttons[7], "Esc opens the quit prompt") + Input.parse_input_event(escape) + await process_frame + check(menu.modal == null and root.gui_get_focus_owner() == menu.buttons[7], "Esc closes it again") var router = root.get_node("AppRouter") router.go("invalid") check(not router.busy, "Invalid routes do not lock UI") - for route in ["platformer", "runner", "beatem_up"]: - router.go(route) + # Every tile names a real gameplay route with a how-to-play card and shows its own art and copy. + check(menu.buttons.size() == GameCatalog.GAMES.size() + 3, "Six tiles, then Settings, Quit Game and Credits") + check(menu.buttons[SETTINGS].text == "Settings" and menu.buttons[7].text == "Quit Game" + and menu.buttons[8].text == "Credits", "Utility buttons keep their order") + for i in GameCatalog.GAMES.size(): + var game: Dictionary = GameCatalog.GAMES[i] + var tile = menu.buttons[i] + check(tile.route == game.route and router.ROUTES.has(game.route) and HowToPlayData.has_game(game.route), + "Tile %d routes to a gameplay route with a card: %s" % [i, game.route]) + check(not tile.art.is_empty() and tile.art[0].texture != null, "Tile has art: " + game.title) + var texts: Array = tile.find_children("*", "Label", true, false).map(func(label: Label) -> String: return label.text) + check(game.title in texts and game.tagline in texts and game.family in texts, + "Tile shows its family, title and tagline: " + game.title) + check(tile.get_parent() == menu.buttons[0].get_parent() and tile.get_parent() is GridContainer, + "Tiles share one grid") + # Every tile launches its game and the game's scene gives the hub back. + for i in GameCatalog.GAMES.size(): + var route: String = GameCatalog.GAMES[i].route + current_scene.buttons[i].pressed.emit() router.go("runner") - await wait(0.65) - check(current_scene.scene_file_path == router.ROUTES[route], "Mode route loads: " + route) + for frame in 300: + if not router.busy: break + await process_frame + await wait(0.3) + check(current_scene.scene_file_path == router.ROUTES[route], "Tile launches its game: " + route) check(not router.busy, "Navigation unlocks") router.go("hub") - await wait(0.65) - check(current_scene.name == "MainMenu", "Mode route returns") + for frame in 300: + if not router.busy: break + await process_frame + await wait(0.3) + check(current_scene.name == "MainMenu", "Game returns to the hub: " + route) # Nullable, like runner_smoke.gd: a missing autoload is a failed check with a clear message, not # a crash. Still exactly one check, so the documented 4.7.0 baseline count is unchanged. var audio := root.get_node_or_null("AudioService") @@ -88,20 +146,29 @@ func run() -> void: await process_frame down.pressed = false Input.parse_input_event(down) - check(root.gui_get_focus_owner() == current_scene.buttons[1], "Keyboard moves focus") - check(current_scene.showcase.focus_group == 1, "Keyboard focus selects runner") + check(root.gui_get_focus_owner() == current_scene.buttons[3], "Keyboard Down moves to the second row") + check(current_scene.showcase.focus_group == 3, "Keyboard focus selects the runner") var pad := InputEventJoypadButton.new() - pad.button_index = JOY_BUTTON_DPAD_DOWN + pad.button_index = JOY_BUTTON_DPAD_RIGHT pad.pressed = true Input.parse_input_event(pad) await process_frame pad.pressed = false Input.parse_input_event(pad) - check(root.gui_get_focus_owner() == current_scene.buttons[2], "Gamepad D-pad moves focus") - check(current_scene.showcase.focus_group == 2, "Gamepad focus selects brawler") - Pointer.hover(current_scene.buttons[1]) + check(root.gui_get_focus_owner() == current_scene.buttons[4], "Gamepad D-pad Right moves along the row") + check(current_scene.showcase.focus_group == 4, "Gamepad focus selects Code City Brawl") + await pad_press(JOY_BUTTON_DPAD_DOWN) + check(root.gui_get_focus_owner() == current_scene.buttons[7], "D-pad Down from the bottom row reaches Quit Game") + check(current_scene.showcase.focus_group == -1, "A utility button releases the game preview") + await pad_press(JOY_BUTTON_DPAD_DOWN) + check(root.gui_get_focus_owner() == current_scene.buttons[1], "D-pad Down from Quit Game wraps to the top row") + await pad_press(JOY_BUTTON_DPAD_LEFT) + check(root.gui_get_focus_owner() == current_scene.buttons[0], "D-pad Left moves along the row") + await pad_press(JOY_BUTTON_DPAD_LEFT) + check(root.gui_get_focus_owner() == current_scene.buttons[2], "D-pad Left wraps within the row") + Pointer.hover(current_scene.buttons[3]) await process_frame - check(current_scene.showcase.focus_group == 1, "Mouse hover overrides old gamepad focus") + check(current_scene.showcase.focus_group == 3, "Mouse hover overrides old gamepad focus") Pointer.move(root, Pointer.corner(root), Vector2(420, 250)) await process_frame check(current_scene.showcase.focus_group == -1, "Pointer exit releases mode preview") @@ -112,7 +179,7 @@ func run() -> void: await wait(0.3) await RenderingServer.frame_post_draw root.get_texture().get_image().save_png("/tmp/hoppy-main-menu.png") - current_scene._open_settings(current_scene.buttons[3]) + current_scene._open_settings(current_scene.buttons[SETTINGS]) await wait(0.2) await RenderingServer.frame_post_draw root.get_texture().get_image().save_png("/tmp/hoppy-settings.png")