Skip to content

Commit 7574b50

Browse files
authored
feat(menu): add a credits screen generated from ASSETS_LICENSES.md (#85)
* feat(menu): add a credits screen generated from ASSETS_LICENSES.md [Agent: Claude Code | Model: Opus 5.5 | Thinking: High | Acting on behalf of: Erik | Skill: none] Closes #51. Players need a credits screen, and #51 asks for one built from ASSETS_LICENSES.md so the two can't drift. - tools/credits/build_credits.py turns the Third-party table into scenes/credits/asset_credits.json: one credit per asset in use, grouped into Music, Sound effects and Art, with the table's attribution line, license, and source and license links. --check runs in CI; CONTRIBUTING says to rerun it after editing the table. - scenes/credits/credits.json holds hand-written sections shown first, each a title with optional lines and tracks. It opens with "Original music: Music by Erik Thorelli" and an empty tracks list, so the soundtrack's track list can be added as data. - scenes/credits/credits.tscn (route credits, a menu route for the controller service) scrolls by itself, pauses at the end and after manual scrolling, scrolls with Up/Down or the wheel, and returns to the hub with Esc, B or its button. It touches no audio. - The hub gains a Credits button after Settings and Quit Game, appended last so buttons[3] and [4] are unchanged; the three utility buttons are 160 px with a 28 px gap so the focus arrow clears its neighbour. - Tests: tests/credits_screen.gd and tools/credits/test_build_credits.py. * fix(menu): harden the credits parser and screen [Agent: Claude Code | Model: Opus 5.5 | Thinking: High | Acting on behalf of: Erik | Skill: none] Addresses CodeRabbit review 5542532934 on #85: - build_credits.py splits cells on unescaped pipes only (\| stays in the cell) and fails on a row with the wrong number of cells instead of dropping it. A credit line ends at a semicolon or a sentence's period, not after an initial or a common abbreviation. A link on the asset's name is its source when the License cell has none. An art pack whose music is also used (Cyberpunk Street, the runner BGM) is credited under Art and Music. - The credits screen keeps scrolling while Up or Down is held (polled, since held D-pad buttons send no repeats), and a route change back to the hub that fails lets the player try again. - Tests: an escaped-pipe row, a malformed row, initials, an asset-name link, the mixed section, and a row count taken from the raw table lines rather than the parser. The screen suite waits on a wall-clock deadline, checks the pause by position and covers held scrolling. - docs/main-menu.md says links appear where the table gives them. * fix(menu): one credits step per press, ignoring keyboard echo [Agent: Claude Code | Model: Opus 5.5 | Thinking: High | Acting on behalf of: Erik | Skill: none] Addresses CodeRabbit review 5542623607 on #85: holding Up or Down already scrolls continuously in _process(), so the one-step handler no longer accepts keyboard echo, which added extra steps on top.
1 parent 02fdfba commit 7574b50

15 files changed

Lines changed: 756 additions & 5 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ jobs:
110110
run: |
111111
command -v shellcheck >/dev/null || sudo apt-get install -y shellcheck
112112
shellcheck tools/booth/watchdog.sh tools/booth/macos/setup.sh
113+
# The credits screen shows tools/credits/build_credits.py's output; it must match the table.
114+
- name: Credits match ASSETS_LICENSES.md
115+
run: python tools/credits/build_credits.py --check
116+
- name: Credits unit tests
117+
run: python -m unittest discover -s tools/credits -v
113118

114119
gitleaks:
115120
name: gitleaks

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Every new asset must be redistributable in a public repository.
6666
- Accepted: third-party assets under **CC0** or **CC BY 4.0**.
6767
- Original art, audio or models made for the project: please **open an issue first**. The license for project-original assets hasn't been finalized yet (see [`ASSETS_LICENSES.md`](ASSETS_LICENSES.md#project-original)), so we can't merge original-art contributions until it is. Procedural assets generated in GDScript count as code and fall under the MIT license.
6868
- Not accepted: "free for use but no redistribution" packs, which covers most free marketplace packs. Also not accepted: NC/ND licenses, and assets of unknown origin.
69-
- Add a row to [`ASSETS_LICENSES.md`](ASSETS_LICENSES.md) in the same PR, and include the upstream license file next to the asset.
69+
- Add a row to [`ASSETS_LICENSES.md`](ASSETS_LICENSES.md) in the same PR, and include the upstream license file next to the asset. Then run `python3 tools/credits/build_credits.py`, which regenerates the in-game credits from that table; CI fails if they differ.
7070
- AI-generated assets: record the tool and prompts, following the existing `PROMPTS.md` / `generation.json` convention. Don't record local machine paths.
7171

7272
## Reporting bugs and security issues

‎docs/main-menu.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ Arrow keys, Tab, D-pad, or left stick navigate; Enter / gamepad A activates; Esc
2525
- Quit asks for confirmation and fades to black for 1 second.
2626
- At exit, however the app quits, AudioService stops every audio player, the current scene's included, and waits up to 0.5 s for two audio mixes (about 25 ms with a sound card). Godot frees a stopped voice only after the mixer has run, and reports any voice it still holds at shutdown as "ObjectDB instances were leaked" / "resources still in use". `tools/checks/exit_leak.py` covers this in CI.
2727

28+
## Credits
29+
30+
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.
31+
32+
- **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.
33+
- **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.
34+
2835
## Art and replacement points
2936

3037
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.

‎hoppys-adventure-arcade/app/app_router.gd‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const ROUTES := {
1313
"platformer": "res://scenes/platformer/platformer_menu.tscn",
1414
"runner": "res://scenes/runner/runner_menu.tscn",
1515
"runner_game": "res://scenes/runner/runner_game.tscn",
16-
"beatem_up": "res://scenes/beatem_up/beatem_menu.tscn"
16+
"beatem_up": "res://scenes/beatem_up/beatem_menu.tscn",
17+
"credits": "res://scenes/credits/credits.tscn"
1718
}
1819
## Packaged-build check (`<game> --headless -- --smoke-routes`): load every route, then quit
1920
## nonzero on the first failure. tools/build/export_game.py runs it against each export.

‎hoppys-adventure-arcade/app/controller_service.gd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const PLAYER := &"p1"
2020
## tests/controller_service.gd fails when a route is in neither list.
2121
const GAMEPLAY_ROUTES: Array[String] = [
2222
"heroes_vs_villains", "code_city_brawl", "enchanted_repo", "orbital_ops", "bay_area_blitz", "runner_game"]
23-
const MENU_ROUTES: Array[String] = ["hub", "platformer", "runner", "beatem_up"]
23+
const MENU_ROUTES: Array[String] = ["hub", "platformer", "runner", "beatem_up", "credits"]
2424
## Godot ships ui_accept and ui_cancel without pad buttons, so a pad could not confirm or go back
2525
## in menus. These match the prompts: the bottom face button confirms, the right one goes back.
2626
const MENU_BINDINGS := {
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"generated_by": "tools/credits/build_credits.py from ASSETS_LICENSES.md; do not edit by hand",
3+
"sections": [
4+
{
5+
"title": "Music",
6+
"credits": [
7+
{
8+
"asset": "Cyberpunk Street (layers + BGM)",
9+
"credit": "\"Cyberpunk Street (layers + BGM)\" by Luis Zuno (ansimuz.com); music composer not credited",
10+
"creator": "Luis Zuno (ansimuz.com); music composer not credited",
11+
"license": "CC0",
12+
"license_url": "",
13+
"source_url": "https://ansimuz.itch.io/cyberpunk-street-environment",
14+
"used_by": "Main menu preview, runner BGM"
15+
},
16+
{
17+
"asset": "MERGE SUCCESSFUL jingle and victory loop",
18+
"credit": "\"MERGE SUCCESSFUL jingle and victory loop\" by Original project compositions and square-wave synthesis; no third-party samples",
19+
"creator": "Original project compositions and square-wave synthesis; no third-party samples",
20+
"license": "CC0 1.0",
21+
"license_url": "https://creativecommons.org/publicdomain/zero/1.0/",
22+
"source_url": "",
23+
"used_by": "Code City Brawl: celebration, ending pages and results"
24+
}
25+
]
26+
},
27+
{
28+
"title": "Sound effects",
29+
"credits": [
30+
{
31+
"asset": "The Essential Retro Video Game Sound Effects Collection",
32+
"credit": "\"The Essential Retro Video Game Sound Effects Collection\" by Juhani Junkala",
33+
"creator": "Juhani Junkala",
34+
"license": "CC0",
35+
"license_url": "",
36+
"source_url": "",
37+
"used_by": "SFX"
38+
},
39+
{
40+
"asset": "Sunny Land forest (art, demo SFX)",
41+
"credit": "\"Sunny Land forest (art, demo SFX)\" by Luis Zuno (@ansimuz); music by Pascal Belisle",
42+
"creator": "Luis Zuno (@ansimuz); music by Pascal Belisle",
43+
"license": "Art: public domain. Music: free with credit",
44+
"license_url": "",
45+
"source_url": "",
46+
"used_by": "Platformer jump/hurt SFX"
47+
}
48+
]
49+
},
50+
{
51+
"title": "Art",
52+
"credits": [
53+
{
54+
"asset": "Parallax forest",
55+
"credit": "\"Parallax forest\" by Luis Zuno (@ansimuz)",
56+
"creator": "Luis Zuno (@ansimuz)",
57+
"license": "CC0",
58+
"license_url": "",
59+
"source_url": "",
60+
"used_by": "Main menu preview"
61+
},
62+
{
63+
"asset": "Space background",
64+
"credit": "\"Space background\" by Luis Zuno (@ansimuz)",
65+
"creator": "Luis Zuno (@ansimuz)",
66+
"license": "CC0",
67+
"license_url": "",
68+
"source_url": "",
69+
"used_by": "Main menu preview"
70+
},
71+
{
72+
"asset": "Cyberpunk Street (layers + BGM)",
73+
"credit": "\"Cyberpunk Street (layers + BGM)\" by Luis Zuno (ansimuz.com); music composer not credited",
74+
"creator": "Luis Zuno (ansimuz.com); music composer not credited",
75+
"license": "CC0",
76+
"license_url": "",
77+
"source_url": "https://ansimuz.itch.io/cyberpunk-street-environment",
78+
"used_by": "Main menu preview, runner BGM"
79+
},
80+
{
81+
"asset": "Parallax City Night",
82+
"credit": "\"Parallax City Night\" by FisherG (@TheFish523); \"Ghost (Vibrant)\" palette by PixelCod",
83+
"creator": "FisherG (@TheFish523); \"Ghost (Vibrant)\" palette by PixelCod",
84+
"license": "CC0",
85+
"license_url": "",
86+
"source_url": "https://opengameart.org/content/parallax-city-night-4-colors",
87+
"used_by": "Main menu preview"
88+
}
89+
]
90+
}
91+
]
92+
}
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
extends Control
2+
## The credits screen. It shows the hand-written sections in credits.json first (original music
3+
## and anything else people add there as data), then the asset credits that
4+
## tools/credits/build_credits.py generates from ASSETS_LICENSES.md. The list scrolls by itself;
5+
## Up and Down (or the mouse wheel) scroll it by hand, and Back or Esc / B return to the hub.
6+
const Style = preload("res://scenes/main_menu/menu_style.gd")
7+
const Prompts := preload("res://app/controller_prompts.gd")
8+
## Hand-written sections: {"title", "lines": [String], "tracks": [{"title", "used_by"}]}.
9+
const CREDITS := "res://scenes/credits/credits.json"
10+
## Generated; do not edit. Sections of credits:
11+
## {"credit", "license", "used_by", "source_url", "license_url"}.
12+
const ASSET_CREDITS := "res://scenes/credits/asset_credits.json"
13+
const SCROLL_SPEED := 36.0
14+
## After a manual scroll, the list waits this long before scrolling by itself again.
15+
const MANUAL_HOLD := 4.0
16+
## One press of Up or Down moves the list this far; holding it scrolls this fast. Held D-pad
17+
## buttons send no repeat events, so holding is polled each frame.
18+
const STEP := 90.0
19+
const HELD_SPEED := 540.0
20+
const HELD_AFTER := 0.3
21+
## At the bottom, the list waits this long, then starts again from the top.
22+
const END_HOLD := 3.0
23+
const MUTED := Color("afbdc9")
24+
var scroll: ScrollContainer
25+
var list: VBoxContainer
26+
var back: Button
27+
var offset := 0.0
28+
var hold := 1.5
29+
var leaving := false
30+
## How long Up or Down has been held, to start continuous scrolling after HELD_AFTER.
31+
var held := 0.0
32+
33+
func _ready() -> void:
34+
theme = Style.theme()
35+
var background := ColorRect.new()
36+
background.color = Color("101d2d")
37+
background.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
38+
add_child(background)
39+
var margin := MarginContainer.new()
40+
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
41+
for side in ["left", "right"]:
42+
margin.add_theme_constant_override("margin_" + side, 76)
43+
for side in ["top", "bottom"]:
44+
margin.add_theme_constant_override("margin_" + side, 36)
45+
add_child(margin)
46+
var column := VBoxContainer.new()
47+
column.add_theme_constant_override("separation", 14)
48+
margin.add_child(column)
49+
column.add_child(Style.label("HOPPY'S ADVENTURE ARCADE", 16, Color("ff9a43")))
50+
column.add_child(Style.label("CREDITS", 38))
51+
scroll = ScrollContainer.new()
52+
scroll.name = "Scroll"
53+
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
54+
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
55+
scroll.vertical_scroll_mode = ScrollContainer.SCROLL_MODE_SHOW_NEVER
56+
column.add_child(scroll)
57+
list = VBoxContainer.new()
58+
list.name = "List"
59+
list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
60+
list.add_theme_constant_override("separation", 6)
61+
scroll.add_child(list)
62+
for section in sections():
63+
_add_section(section)
64+
_add_gap(18)
65+
_add_text("Source code: MIT License. CodeRabbit and the Hoppy mascot are trademarks of"
66+
+ " CodeRabbit, Inc.", 15, MUTED)
67+
var footer := HBoxContainer.new()
68+
footer.add_theme_constant_override("separation", 24)
69+
column.add_child(footer)
70+
back = Style.button("Return to Main Menu", 48)
71+
back.name = "BackButton"
72+
footer.add_child(back)
73+
back.pressed.connect(leave)
74+
var hint := Style.label("", 14, MUTED)
75+
hint.size_flags_vertical = Control.SIZE_SHRINK_CENTER
76+
Prompts.track(hint, func() -> String:
77+
return "%s: scroll %s: back" % [Prompts.keys_or_pad("↑ ↓", Prompts.if_pad("D-pad")),
78+
Prompts.either("Esc", &"ui_cancel")])
79+
footer.add_child(hint)
80+
back.grab_focus()
81+
82+
## Every section in display order: the hand-written ones, then the generated asset credits.
83+
static func sections() -> Array[Dictionary]:
84+
var result: Array[Dictionary] = []
85+
result.append_array(read_sections(CREDITS))
86+
result.append_array(read_sections(ASSET_CREDITS))
87+
return result
88+
89+
## The "sections" array of a credits file, keeping only dictionaries with a title.
90+
static func read_sections(path: String) -> Array[Dictionary]:
91+
var result: Array[Dictionary] = []
92+
var data: Variant = JSON.parse_string(FileAccess.get_file_as_string(path))
93+
if not (data is Dictionary and data.get("sections") is Array):
94+
push_error("Credits: %s is missing or has no sections array" % path)
95+
return result
96+
for section: Variant in data.sections:
97+
if section is Dictionary and str(section.get("title", "")) != "":
98+
result.append(section)
99+
return result
100+
101+
func _add_section(section: Dictionary) -> void:
102+
_add_gap(18)
103+
_add_text(str(section.title).to_upper(), 22, Style.MINT)
104+
for line: Variant in section.get("lines", []):
105+
_add_text(str(line), 19)
106+
for track: Variant in section.get("tracks", []):
107+
if track is Dictionary:
108+
var used_by := str(track.get("used_by", ""))
109+
_add_text(str(track.get("title", "")) + (" · " + used_by if used_by != "" else ""), 17)
110+
for entry: Variant in section.get("credits", []):
111+
if not entry is Dictionary:
112+
continue
113+
_add_gap(4)
114+
_add_text(str(entry.get("credit", "")), 18)
115+
var details := PackedStringArray()
116+
for key in ["license", "used_by"]:
117+
if str(entry.get(key, "")) != "":
118+
details.append(str(entry[key]))
119+
_add_text(" · ".join(details), 14, MUTED)
120+
var links := PackedStringArray()
121+
for key in ["source_url", "license_url"]:
122+
if str(entry.get(key, "")) != "":
123+
links.append(str(entry[key]))
124+
if not links.is_empty():
125+
_add_text(" ".join(links), 13, MUTED)
126+
127+
func _add_text(text: String, font_size: int, color: Color = Style.CREAM) -> void:
128+
var label := Style.label(text, font_size, color)
129+
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
130+
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
131+
list.add_child(label)
132+
133+
func _add_gap(height: float) -> void:
134+
var gap := Control.new()
135+
gap.custom_minimum_size.y = height
136+
list.add_child(gap)
137+
138+
func _process(delta: float) -> void:
139+
# A scroll that didn't come from here (the mouse wheel) counts as a manual one.
140+
if scroll.scroll_vertical != int(offset):
141+
offset = scroll.scroll_vertical
142+
hold = MANUAL_HOLD
143+
var direction := Input.get_axis(&"ui_up", &"ui_down")
144+
held = held + delta if absf(direction) > 0.5 else 0.0
145+
if held > HELD_AFTER:
146+
_scroll_by(signf(direction) * HELD_SPEED * delta)
147+
return
148+
if hold > 0.0:
149+
hold -= delta
150+
return
151+
var bottom := maxf(0.0, list.size.y - scroll.size.y)
152+
if offset >= bottom:
153+
offset = 0.0
154+
hold = END_HOLD
155+
else:
156+
offset = minf(bottom, offset + SCROLL_SPEED * delta)
157+
if offset >= bottom:
158+
hold = END_HOLD
159+
scroll.scroll_vertical = int(offset)
160+
161+
func _input(event: InputEvent) -> void:
162+
# One step per press; keyboard echo is ignored, since holding is handled in _process().
163+
for action in [&"ui_up", &"ui_down"]:
164+
if event.is_action_pressed(action):
165+
_scroll_by(STEP if action == &"ui_down" else -STEP)
166+
get_viewport().set_input_as_handled()
167+
return
168+
if event.is_action_pressed("ui_cancel"):
169+
leave()
170+
get_viewport().set_input_as_handled()
171+
172+
## Move the list by `pixels` within its bounds; a manual scroll pauses the automatic one.
173+
func _scroll_by(pixels: float) -> void:
174+
offset = clampf(offset + pixels, 0.0, maxf(0.0, list.size.y - scroll.size.y))
175+
scroll.scroll_vertical = int(offset)
176+
hold = MANUAL_HOLD
177+
178+
## AppRouter ignores go() mid-transition, so a press then is dropped rather than latched, and a
179+
## route change that fails lets the player try again. The autoload is looked up by path: suites
180+
## preload this script before autoloads exist.
181+
func leave() -> void:
182+
var router := get_node(^"/root/AppRouter")
183+
if leaving or router.busy:
184+
return
185+
leaving = true
186+
if not await router.go("hub"):
187+
leaving = false
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://cydku6vi25d8k
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"about": "Hand-written credits, shown before the asset credits that tools/credits/build_credits.py generates from ASSETS_LICENSES.md (asset_credits.json). Each section has a title, optional lines, and optional tracks: {\"title\": ..., \"used_by\": ...}. Add a section, or add tracks to one.",
3+
"sections": [
4+
{
5+
"title": "Original music",
6+
"lines": [
7+
"Music by Erik Thorelli"
8+
],
9+
"tracks": []
10+
}
11+
]
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[gd_scene load_steps=2 format=3]
2+
[ext_resource type="Script" path="res://scenes/credits/credits.gd" id="1"]
3+
[node name="Credits" type="Control"]
4+
layout_mode = 3
5+
anchors_preset = 15
6+
anchor_right = 1.0
7+
anchor_bottom = 1.0
8+
grow_horizontal = 2
9+
grow_vertical = 2
10+
script = ExtResource("1")

0 commit comments

Comments
 (0)