feat(renpy): credits, scene select, main menu, title card subtitles and reading comfort

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-19 04:56:26 +02:00
1 parent d275093654
commit ce7888e4bc
8 files changed
+384 -24

No files matched your search

+2 -1
View File
@@ -105,7 +105,8 @@ The expected result is a statistics block with no warnings above it.
Lint does not catch runtime errors (missing GUI images, display bugs). `--with-test` also Lint does not catch runtime errors (missing GUI images, display bugs). `--with-test` also
writes `game/e2e_test.rpy`, a Ren'Py `testcase` that clicks "Start", advances through the writes `game/e2e_test.rpy`, a Ren'Py `testcase` that clicks "Start", advances through the
whole game up to the final card (`label the_end`) and back to the main menu, failing on any whole game up to the final card (`label the_end`) and back to the main menu (then opens and
closes the Scenes and Credits screens), failing on any
exception (`traceback.txt`). Use a throw-away output directory so the test file never ends exception (`traceback.txt`). Use a throw-away output directory so the test file never ends
up in `vn/` or in a build: up in `vn/` or in a build:
+19 -2
View File
@@ -6,11 +6,12 @@ A work is a directory containing `work.toml`, plus the folders the pipeline fill
| Table | Keys | | Table | Keys |
|---|---| |---|---|
| `[work]` | `id`, `title`, `subtitle`, `author`, `translator`, `language` (`es`/`en`, used for the About text), `lyric_voice` (cast id for verse nobody speaks; default `poet_voice`), `end_text`, `menu_bg` (background asset id for the main menu; default: first staged `bg`). | | `[work]` | `id`, `title`, `subtitle`, `author`, `translator`, `language` (`es`/`en`: About, menu and credits texts), `lyric_voice` (cast id for verse nobody speaks; default `poet_voice`), `end_text`, `menu_bg` (legacy alias of `[ui].main_menu_bg`). |
| `[ui]` | `main_menu_bg` (background asset id of the main menu and, darker, the game menu; default: `[work].menu_bg`, else the first staged `bg`). |
| `[source]` | `gutenberg_id`, `url`, `raw_file` (cache path, relative to the work root, gitignored). | | `[source]` | `gutenberg_id`, `url`, `raw_file` (cache path, relative to the work root, gitignored). |
| `[scope]` | `start_marker`, `end_marker` (whole stripped lines), `end_occurrence` (1-based, searched after the start; the end marker itself is excluded). | | `[scope]` | `start_marker`, `end_marker` (whole stripped lines), `end_occurrence` (1-based, searched after the start; the end marker itself is excluded). |
| `[speakers]` | Speaker heading as printed (upper case, without its italic note) → cast id. Several headings may share one id (anonymous crowd speakers). A key with punctuation or markup (`"CORO, TUTTI"`) is matched against the whole printed line first. An unknown speaker is a parse error. | | `[speakers]` | Speaker heading as printed (upper case, without its italic note) → cast id. Several headings may share one id (anonymous crowd speakers). A key with punctuation or markup (`"CORO, TUTTI"`) is matched against the whole printed line first. An unknown speaker is a parse error. |
| `[[scenes]]` | `heading` (as printed), `id`, `location`, `time_of_day`, optional `occurrence` and `format` (below). | | `[[scenes]]` | `heading` (as printed), `id`, `location`, `time_of_day`, optional `occurrence`, `format` (below) and `subtitle` (a short, already localized place/time line shown under the heading on the title card; absent = heading only). |
| `[parser]` | `direction_headings`: whole lines in capitals that are stage directions or section titles (`"ENTRA FAUSTO"`), not speakers. Each becomes a `direction` line once the scene's first speech has started (before it, the line is treated as cast/setting). | | `[parser]` | `direction_headings`: whole lines in capitals that are stage directions or section titles (`"ENTRA FAUSTO"`), not speakers. Each becomes a `direction` line once the scene's first speech has started (before it, the line is treated as cast/setting). |
| `[cast.<id>]` | `name` (shown in the dialogue box), `color`, `sprite` (default `true`; `false` = never drawn), `expressions` (annotation emotion → sprite expression; needs `neutral`). | | `[cast.<id>]` | `name` (shown in the dialogue box), `color`, `sprite` (default `true`; `false` = never drawn), `expressions` (annotation emotion → sprite expression; needs `neutral`). |
| `[staging.<scene id>]` | `bg` (background shown after the title card), `mode` (`adv` or `nvl`), `cast = { <char> = "left\|center\|right" }` pins sprite characters for the whole scene, `music` (see Audio; ignores the annotation moods for this scene). | | `[staging.<scene id>]` | `bg` (background shown after the title card), `mode` (`adv` or `nvl`), `cast = { <char> = "left\|center\|right" }` pins sprite characters for the whole scene, `music` (see Audio; ignores the annotation moods for this scene). |
@@ -64,3 +65,19 @@ mood (`ann.music`), unless overridden:
- A track that is already playing is never restarted (`if_changed`); the first music statement - A track that is already playing is never restarted (`if_changed`); the first music statement
of each scene is always emitted so a scene entered from the scene select has music. of each scene is always emitted so a scene entered from the scene select has music.
- Unknown `track:` paths, and moods with no audio when the work has audio, are errors. - Unknown `track:` paths, and moods with no audio when the work has audio, are errors.
### Menus, credits and reading comfort
- **Main menu**: the `[ui].main_menu_bg` background, darkened, with `[work].title` large and
`[work].subtitle` below it; entries Start, Scenes, Load, Preferences, About, Credits, Help, Quit.
The game menu uses the same background, darker.
- **Scenes** (main menu only): every scene the player has reached (a persistent set updated
when the scene starts), listed by heading; selecting one starts the game from that scene.
Unreached scenes show as an em dash. A heading shared by several scenes is told apart by
the scene's `subtitle` (else its number).
- **Credits**: text author/translator/Gutenberg source from `[work]` and `[source]`; the art
line from the manifest's renditions (non-placeholder `source`, e.g. "ChatGPT (OpenAI)");
the music from `<work>/audio/credits.toml` (`[[track]]` with `file`, `attribution`; only
tracks whose file exists). Attributions are printed verbatim. Labels follow `[work].language`.
- Defaults: `preferences.text_cps = 40`, `afm_time = 15`, `window auto`, a blinking
click-to-continue arrow. Verse boxes stay at 4 lines; NVL keeps stanza pages.
+167 -11
View File
@@ -12,6 +12,7 @@ import argparse
import hashlib import hashlib
import json import json
import shutil import shutil
import tomllib
from dataclasses import dataclass, field from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
@@ -62,6 +63,34 @@ ABOUT_LABELS = {
"es": ("Texto", "Traducción", "Adaptación a novela visual generada con vnpipe."), "es": ("Texto", "Traducción", "Adaptación a novela visual generada con vnpipe."),
"en": ("Text", "Translation", "Visual novel adaptation generated with vnpipe."), "en": ("Text", "Translation", "Visual novel adaptation generated with vnpipe."),
} }
# Menu/credits strings per work language: scenes, credits, text, translation, source, music,
# illustrations, "illustrations generated with X", Gutenberg line, "no scene reached yet".
UI_LABELS = {
"es": {
"scenes": "Escenas",
"credits": "Créditos",
"text": "Texto",
"translation": "Traducción",
"source": "Fuente",
"music": "Música",
"art": "Ilustraciones",
"art_with": "Ilustraciones generadas con {}",
"gutenberg": "Proyecto Gutenberg, n.º {id}",
},
"en": {
"scenes": "Scenes",
"credits": "Credits",
"text": "Text",
"translation": "Translation",
"source": "Source",
"music": "Music",
"art": "Illustrations",
"art_with": "Illustrations generated with {}",
"gutenberg": "Project Gutenberg #{id}",
},
}
ART_SOURCE_NAMES = {"chatgpt-web": "ChatGPT (OpenAI)"} # manifest `source` -> display name
LOCKED_SCENE = "—"
# (preferences title and picker heading, picker hint) per work language # (preferences title and picker heading, picker hint) per work language
ART_STYLE_LABELS = { ART_STYLE_LABELS = {
"es": ("Estilo visual", "Puedes cambiarlo más tarde en Preferencias."), "es": ("Estilo visual", "Puedes cambiarlo más tarde en Preferencias."),
@@ -499,6 +528,8 @@ class SceneWriter:
def render(self) -> list[str]: def render(self) -> list[str]:
scene = self.scene scene = self.scene
self.out.append(f"label scene_{scene['id']}:") self.out.append(f"label scene_{scene['id']}:")
self.emit(f'$ vn_mark_scene("scene_{scene["id"]}")') # unlocks it in the scene select
self.emit("window auto") # also when entered from the scene select, not via `start`
self.emit("scene black") self.emit("scene black")
self.emit(f"show card_{scene['id']} at truecenter") self.emit(f"show card_{scene['id']} at truecenter")
self.emit("with fade") self.emit("with fade")
@@ -679,15 +710,16 @@ testsuite global:
testcase default: testcase default:
$ _test.transition_timeout = 0.05 $ _test.transition_timeout = 0.05
$ _test.timeout = 30.0 $ _test.timeout = 30.0
$ preferences.text_cps = 0
pause 1.0 pause 1.0
click "Start" click "Start"
@@PICK@@ advance until eval (e2e_state["end"]) timeout 900 @@PICK@@ advance until eval (e2e_state["end"]) timeout 900
advance until screen "main_menu" timeout 60 advance until screen "main_menu" timeout 60
assert eval (e2e_state["end"]) @@MENUS@@ assert eval (e2e_state["end"])
""" """
def render_e2e(styles: dict[str, Any]) -> str: def render_e2e(styles: dict[str, Any], ui: dict[str, str]) -> str:
"""The playthrough testcase; with a style choice it also exercises the first-launch picker """The playthrough testcase; with a style choice it also exercises the first-launch picker
(picking the last style, so the non-default switch branch is the one in use).""" (picking the last style, so the non-default switch branch is the one in use)."""
pick = "" pick = ""
@@ -699,7 +731,17 @@ def render_e2e(styles: dict[str, Any]) -> str:
f" click {_plain_quote(cfg['label'])}\n" f" click {_plain_quote(cfg['label'])}\n"
f" assert eval (persistent.art_style == {sid!r})\n" f" assert eval (persistent.art_style == {sid!r})\n"
) )
return E2E_TESTCASE.replace("@@PICK@@", pick) menus = (
f" click {_plain_quote(ui['credits'])}\n"
' assert screen "vn_credits"\n'
' click "Return"\n'
' assert screen "main_menu"\n'
f" click {_plain_quote(ui['scenes'])}\n"
' assert screen "vn_scene_select"\n'
' click "Return"\n'
' assert screen "main_menu"\n'
)
return E2E_TESTCASE.replace("@@PICK@@", pick).replace("@@MENUS@@", menus)
# --- static project files ----------------------------------------------------------------- # --- static project files -----------------------------------------------------------------
@@ -720,6 +762,7 @@ def render_characters(work: Work) -> str:
props.append(f"what_color={_plain_quote(color)}") props.append(f"what_color={_plain_quote(color)}")
if cid == "narrator": if cid == "narrator":
props.append("what_italic=True") props.append("what_italic=True")
props += ['ctc="vn_ctc"', 'ctc_position="nestled"']
adv = ", ".join([who, *props]) adv = ", ".join([who, *props])
nvl_props = ["kind=nvl", *props] nvl_props = ["kind=nvl", *props]
if not name: if not name:
@@ -730,12 +773,28 @@ def render_characters(work: Work) -> str:
return "\n".join(out) return "\n".join(out)
def title_cards(work: Work, annotated: dict[str, Any]) -> dict[str, str]: def title_cards(work: Work, annotated: dict[str, Any]) -> dict[str, tuple[str, str | None]]:
cards = {f"card_{sc['id']}": sc["heading"] for sc in annotated["scenes"]} """Image name -> (heading, optional subtitle line: place/time, from ``[[scenes]].subtitle``)."""
cards["card_end"] = work.data["work"].get("end_text", DEFAULT_END_TEXT) subtitles = {sc["id"]: sc.get("subtitle") for sc in work.data.get("scenes", [])}
cards: dict[str, tuple[str, str | None]] = {
f"card_{sc['id']}": (sc["heading"], subtitles.get(sc["id"])) for sc in annotated["scenes"]
}
cards["card_end"] = (work.data["work"].get("end_text", DEFAULT_END_TEXT), None)
return cards return cards
def render_card(heading: str, subtitle: str | None) -> str:
"""A heading, plus a smaller italic line below it when the scene has a subtitle."""
props = "size=60, text_align=0.5"
if not subtitle:
return f'Text("{escape_text(heading)}", {props})'
sub_props = 'size=30, italic=True, color="#c9a25b", text_align=0.5'
return (
f'VBox(Text("{escape_text(heading)}", {props}, xalign=0.5), '
f'Text("{escape_text(subtitle)}", {sub_props}, xalign=0.5), spacing=28)'
)
def render_image_entry(e: ImageEntry) -> str: def render_image_entry(e: ImageEntry) -> str:
"""Plain image, or a ConditionSwitch on ``persistent.art_style`` with the default last.""" """Plain image, or a ConditionSwitch on ``persistent.art_style`` with the default last."""
default_rel = e.variants[0][1] default_rel = e.variants[0][1]
@@ -750,10 +809,10 @@ def render_image_entry(e: ImageEntry) -> str:
return f"image {e.name} = ConditionSwitch({', '.join(parts)})" return f"image {e.name} = ConditionSwitch({', '.join(parts)})"
def render_images(entries: list[ImageEntry], cards: dict[str, str]) -> str: def render_images(entries: list[ImageEntry], cards: dict[str, tuple[str, str | None]]) -> str:
out = ["## Generated by `vnpipe renpy`. Do not edit: regenerate instead.", ""] out = ["## Generated by `vnpipe renpy`. Do not edit: regenerate instead.", ""]
for name, text in cards.items(): # title cards: plain images, not `show text` for name, (heading, subtitle) in cards.items(): # title cards: plain images, not `show text`
out.append(f'image {name} = Text("{escape_text(text)}", size=60, text_align=0.5)') out.append(f"image {name} = {render_card(heading, subtitle)}")
out.extend(render_image_entry(e) for e in entries) out.extend(render_image_entry(e) for e in entries)
out.append("") out.append("")
return "\n".join(out) return "\n".join(out)
@@ -771,6 +830,94 @@ def _about(work: Work) -> str:
return "\\n\\n".join(escape_text(p) for p in parts if p) return "\\n\\n".join(escape_text(p) for p in parts if p)
def ui_labels(work: Work) -> dict[str, str]:
return UI_LABELS.get(work.data["work"].get("language", "es"), UI_LABELS["en"])
def _markup(text: str) -> str:
"""Escape Ren'Py text markup only (for strings shown by `text`, not quoted in a script)."""
return text.replace("[", "[[").replace("{", "{{")
def credit_tracks(work: Work) -> list[dict[str, Any]]:
"""Tracks of ``<work>/audio/credits.toml`` whose file ships with the game."""
path = work.path("audio/credits.toml")
if not path.is_file():
return []
with path.open("rb") as fh:
tracks = tomllib.load(fh).get("track", [])
return [t for t in tracks if work.path(t["file"]).is_file()]
def art_sources(manifest: dict[str, Any] | None) -> list[str]:
"""Display names of the generators behind the shipped (non-placeholder) renditions."""
found = set()
for asset in (manifest or {}).get("assets", []):
for rendition in asset["renditions"].values():
source = rendition.get("source")
if source and source != "placeholder" and rendition["status"] != "placeholder":
found.add(ART_SOURCE_NAMES.get(source, source))
return sorted(found)
def credits_sections(work: Work, manifest: dict[str, Any] | None) -> list[tuple[str, list[str]]]:
info = work.data["work"]
ui = ui_labels(work)
sections: list[tuple[str, list[str]]] = []
text = [info["author"]] if info.get("author") else []
if info.get("translator"):
text.append(f"{ui['translation']}: {info['translator']}")
gutenberg = work.data.get("source", {}).get("gutenberg_id")
if gutenberg:
text.append(
f"{ui['source']}: {ui['gutenberg'].format(id=gutenberg)}"
f" (https://www.gutenberg.org/ebooks/{gutenberg})"
)
if text:
sections.append((ui["text"], text))
sources = art_sources(manifest)
if sources:
sections.append((ui["art"], [ui["art_with"].format(", ".join(sources))]))
tracks = credit_tracks(work)
if tracks: # attributions are printed verbatim (CC BY-SA requires them)
sections.append((ui["music"], [t["attribution"] for t in tracks]))
about_tail = ABOUT_LABELS.get(info.get("language", "es"), ABOUT_LABELS["en"])[2]
sections.append(("vnpipe", [about_tail]))
return [(title, [_markup(e) for e in entries]) for title, entries in sections]
def scene_menu_titles(work: Work, annotated: dict[str, Any]) -> list[tuple[str, str]]:
"""(label, title) per scene; a repeated heading gets its subtitle, else its number."""
subtitles = {sc["id"]: sc.get("subtitle") for sc in work.data.get("scenes", [])}
headings = [sc["heading"] for sc in annotated["scenes"]]
seen: dict[str, int] = {}
result = []
for sc in annotated["scenes"]:
title = sc["heading"]
if headings.count(title) > 1:
seen[title] = seen.get(title, 0) + 1
title += f" ({subtitles.get(sc['id']) or seen[title]})"
result.append((f"scene_{sc['id']}", _markup(title)))
return result
def render_menu_data(work: Work, annotated: dict[str, Any], manifest: dict[str, Any] | None) -> str:
def py(value: Any) -> str: # JSON strings are valid Python literals
return json.dumps(value, ensure_ascii=False)
subtitle = _markup(work.data["work"].get("subtitle", ""))
return "\n".join(
[
"## Generated by `vnpipe renpy`. Do not edit: regenerate instead.",
"",
f"define vn_subtitle = {py(subtitle)}",
f"define vn_scenes = {py(scene_menu_titles(work, annotated))}",
f"define vn_credits = {py(credits_sections(work, manifest))}",
"",
]
)
def _substitute(text: str, values: dict[str, str]) -> str: def _substitute(text: str, values: dict[str, str]) -> str:
for key, value in values.items(): for key, value in values.items():
text = text.replace(f"@@{key}@@", value) text = text.replace(f"@@{key}@@", value)
@@ -800,13 +947,18 @@ def generate(
# GUI template: copy binaries, substitute tokens in .rpy files. # GUI template: copy binaries, substitute tokens in .rpy files.
menu_bg = MENU_BG_FALLBACK menu_bg = MENU_BG_FALLBACK
staging = work.data.get("staging", {}) staging = work.data.get("staging", {})
first_bg = info.get("menu_bg") or next((c["bg"] for c in staging.values() if c.get("bg")), None) first_bg = (
work.data.get("ui", {}).get("main_menu_bg")
or info.get("menu_bg")
or next((c["bg"] for c in staging.values() if c.get("bg")), None)
)
if first_bg: if first_bg:
menu_bg = bg_image_name(first_bg) menu_bg = bg_image_name(first_bg)
styles, default_style = art_styles(manifest) styles, default_style = art_styles(manifest)
picker_title, picker_hint = ART_STYLE_LABELS.get( picker_title, picker_hint = ART_STYLE_LABELS.get(
info.get("language", "es"), ART_STYLE_LABELS["en"] info.get("language", "es"), ART_STYLE_LABELS["en"]
) )
ui = ui_labels(work)
values = { values = {
"ART_STYLES": repr([(sid, cfg["label"]) for sid, cfg in styles.items()]), "ART_STYLES": repr([(sid, cfg["label"]) for sid, cfg in styles.items()]),
"DEFAULT_STYLE": default_style, "DEFAULT_STYLE": default_style,
@@ -818,6 +970,9 @@ def generate(
"BUILD_NAME": f"{info['id']}-vn", "BUILD_NAME": f"{info['id']}-vn",
"SAVE_DIR": f"{info['id']}-vn", "SAVE_DIR": f"{info['id']}-vn",
"MENU_BG": menu_bg, "MENU_BG": menu_bg,
"UI_SCENES": ui["scenes"],
"UI_CREDITS": ui["credits"],
"LOCKED": LOCKED_SCENE,
} }
written: list[Path] = [] written: list[Path] = []
for src in sorted((TEMPLATE_DIR / "game").rglob("*")): for src in sorted((TEMPLATE_DIR / "game").rglob("*")):
@@ -841,11 +996,12 @@ def generate(
test_file = game / E2E_FILE test_file = game / E2E_FILE
test_file.unlink(missing_ok=True) test_file.unlink(missing_ok=True)
if with_test: if with_test:
write_text(test_file, render_e2e(styles)) write_text(test_file, render_e2e(styles, ui))
written.append(test_file) written.append(test_file)
for name, text in ( for name, text in (
("characters.rpy", render_characters(work)), ("characters.rpy", render_characters(work)),
("images.rpy", render_images(entries, title_cards(work, annotated))), ("images.rpy", render_images(entries, title_cards(work, annotated))),
("menu_data.rpy", render_menu_data(work, annotated, manifest)),
("script.rpy", render_script(work, annotated, scan_audio(out))), ("script.rpy", render_script(work, annotated, scan_audio(out))),
): ):
write_text(game / name, text) write_text(game / name, text)
+68
View File
@@ -0,0 +1,68 @@
## Scene select and credits screens, reached from the main menu. The data they show
## (`vn_scenes`, `vn_credits`) is generated in menu_data.rpy; static otherwise.
## Labels of the scenes the player has reached; updated when a scene starts.
default persistent.vn_seen_scenes = set()
init python:
def vn_mark_scene(label):
if label not in persistent.vn_seen_scenes:
persistent.vn_seen_scenes.add(label)
renpy.save_persistent()
screen vn_scene_select():
tag menu
use game_menu("@@UI_SCENES@@", scroll="viewport"):
style_prefix "vn_scenes"
vbox:
spacing 6
for scene_label, scene_title in vn_scenes:
if scene_label in persistent.vn_seen_scenes:
textbutton scene_title action Start(scene_label)
else:
textbutton "@@LOCKED@@" action NullAction() sensitive False
style vn_scenes_button is gui_button
style vn_scenes_button_text is gui_button_text
style vn_scenes_button:
properties gui.button_properties("navigation_button")
xalign 0.0
style vn_scenes_button_text:
properties gui.text_properties("navigation_button")
xalign 0.0
size 30
screen vn_credits():
tag menu
use game_menu("@@UI_CREDITS@@", scroll="viewport"):
style_prefix "vn_credits"
vbox:
spacing 6
for section_title, entries in vn_credits:
null height 20
label section_title
for entry in entries:
text entry
style vn_credits_label is gui_label
style vn_credits_label_text is gui_label_text
style vn_credits_text is gui_text
style vn_credits_label_text:
size gui.label_text_size
style vn_credits_text:
size 26
xmaximum 1100
+1 -1
View File
@@ -119,7 +119,7 @@ define config.window_hide_transition = Dissolve(.2)
## Controls the default text speed. The default, 0, is infinite, while any other ## Controls the default text speed. The default, 0, is infinite, while any other
## number is the number of characters per second to type out. ## number is the number of characters per second to type out.
default preferences.text_cps = 0 default preferences.text_cps = 40
## The default auto-forward delay. Larger numbers lead to longer waits, with 0 ## The default auto-forward delay. Larger numbers lead to longer waits, with 0
+37 -8
View File
@@ -301,6 +301,8 @@ screen navigation():
textbutton _("Start") action Start() textbutton _("Start") action Start()
textbutton "@@UI_SCENES@@" action ShowMenu("vn_scene_select")
else: else:
textbutton _("History") action ShowMenu("history") textbutton _("History") action ShowMenu("history")
@@ -321,6 +323,8 @@ screen navigation():
textbutton _("About") action ShowMenu("about") textbutton _("About") action ShowMenu("about")
textbutton "@@UI_CREDITS@@" action ShowMenu("vn_credits")
if renpy.variant("pc") or (renpy.variant("web") and not renpy.variant("mobile")): if renpy.variant("pc") or (renpy.variant("web") and not renpy.variant("mobile")):
## Help isn't necessary or relevant to mobile devices. ## Help isn't necessary or relevant to mobile devices.
@@ -357,12 +361,14 @@ screen main_menu():
add gui.main_menu_background add gui.main_menu_background
## This empty frame darkens the main menu. ## Darkens the background so the title reads well.
add Solid("#000000a8")
## The left strip behind the navigation.
frame: frame:
style "main_menu_frame" style "main_menu_frame"
## The use statement includes another screen inside this one. The actual ## The actual contents of the main menu are in the navigation screen.
## contents of the main menu are in the navigation screen.
use navigation use navigation
if gui.show_name: if gui.show_name:
@@ -373,6 +379,10 @@ screen main_menu():
text "[config.name!t]": text "[config.name!t]":
style "main_menu_title" style "main_menu_title"
if vn_subtitle:
text "[vn_subtitle!t]":
style "main_menu_subtitle"
text "[config.version]": text "[config.version]":
style "main_menu_version" style "main_menu_version"
@@ -381,6 +391,7 @@ style main_menu_frame is empty
style main_menu_vbox is vbox style main_menu_vbox is vbox
style main_menu_text is gui_text style main_menu_text is gui_text
style main_menu_title is main_menu_text style main_menu_title is main_menu_text
style main_menu_subtitle is main_menu_text
style main_menu_version is main_menu_text style main_menu_version is main_menu_text
style main_menu_frame: style main_menu_frame:
@@ -390,20 +401,35 @@ style main_menu_frame:
background "gui/overlay/main_menu.png" background "gui/overlay/main_menu.png"
style main_menu_vbox: style main_menu_vbox:
xalign 1.0 xpos 420
xoffset -30 xsize 1500
xmaximum 1200 yalign 0.42
yalign 1.0 spacing 36
yoffset -30
style main_menu_text: style main_menu_text:
properties gui.text_properties("main_menu", accent=True) properties gui.text_properties("main_menu", accent=True)
style main_menu_title: style main_menu_title:
properties gui.text_properties("title") properties gui.text_properties("title")
size 132
kerning 10
xalign 0.5
text_align 0.5
color "#efe6d2"
outlines [(4, "#000000b0", 0, 3)]
style main_menu_subtitle:
size 46
italic True
kerning 3
xalign 0.5
text_align 0.5
color "#c9a25b"
outlines [(3, "#000000b0", 0, 2)]
style main_menu_version: style main_menu_version:
properties gui.text_properties("version") properties gui.text_properties("version")
xalign 0.5
## Game Menu screen ############################################################ ## Game Menu screen ############################################################
@@ -424,6 +450,9 @@ screen game_menu(title, scroll=None, yinitial=0.0, spacing=0):
else: else:
add gui.game_menu_background add gui.game_menu_background
## The game menu is darker than the main menu so text stays legible.
add Solid("#000000d0")
frame: frame:
style "game_menu_outer_frame" style "game_menu_outer_frame"
@@ -36,3 +36,13 @@ init python:
"fonts/RobotoSlab-Bold.ttf", False, False) "fonts/RobotoSlab-Bold.ttf", False, False)
define vn_move = MoveTransition(0.8) define vn_move = MoveTransition(0.8)
## Click-to-continue indicator: a blinking arrow at the end of the text (every Character
## uses it, see characters.rpy).
transform vn_ctc_blink:
alpha 1.0
linear 0.7 alpha 0.2
linear 0.7 alpha 1.0
repeat
image vn_ctc = At(Text("▾", font="DejaVuSans.ttf", size=34, color="#c9a25b"), vn_ctc_blink)
+80 -1
View File
@@ -155,8 +155,12 @@ def test_sprite_false_never_shown(script):
def test_characters_and_images(project): def test_characters_and_images(project):
chars = (project / "game/characters.rpy").read_text(encoding="utf-8") chars = (project / "game/characters.rpy").read_text(encoding="utf-8")
assert 'define c_director = Character("El Director", who_color="#c9a25b")' in chars assert (
'define c_director = Character("El Director", who_color="#c9a25b", '
'ctc="vn_ctc", ctc_position="nestled")' in chars
)
assert 'define c_director_nvl = Character("El Director", kind=nvl' in chars assert 'define c_director_nvl = Character("El Director", kind=nvl' in chars
assert chars.count('ctc="vn_ctc"') == chars.count("Character(")
assert "define c_narrator = Character(None, what_color=" in chars assert "define c_narrator = Character(None, what_color=" in chars
assert "what_italic=True" in chars assert "what_italic=True" in chars
nameless_nvl = next(ln for ln in chars.split("\n") if ln.startswith("define c_poet_voice_nvl")) nameless_nvl = next(ln for ln in chars.split("\n") if ln.startswith("define c_poet_voice_nvl"))
@@ -466,3 +470,78 @@ def test_music_config_errors(work, annotated):
w = _with_cfg(work, staging={"talk": {"music": "loud"}}) w = _with_cfg(work, staging={"talk": {"music": "loud"}})
with pytest.raises(ValueError, match="no audio for music mood"): with pytest.raises(ValueError, match="no audio for music mood"):
renpy_gen.render_script(w, annotated, _audio()) renpy_gen.render_script(w, annotated, _audio())
def _project(work, annotated, tmp_path, **cfg):
out = tmp_path / "p"
renpy_gen.generate(_with_cfg(work, **cfg) if cfg else work, annotated, out)
return out
def test_title_card_subtitle(work, annotated, tmp_path):
scenes = [{"heading": "CONVERSACIÓN", "id": "talk", "subtitle": "Escenario · Día"}]
out = _project(work, annotated, tmp_path, scenes=scenes)
images = (out / "game/images.rpy").read_text(encoding="utf-8")
assert 'image card_talk = VBox(Text("CONVERSACIÓN", size=60' in images
assert 'Text("Escenario · Día", size=30, italic=True' in images
assert 'image card_lyric = Text("LÍRICA", size=60, text_align=0.5)' in images # no subtitle
def test_scene_labels_and_menus(project, script):
assert 'label scene_talk:\n $ vn_mark_scene("scene_talk")\n window auto' in script
data = (project / "game/menu_data.rpy").read_text(encoding="utf-8")
assert 'define vn_scenes = [["scene_lyric", "LÍRICA"], ["scene_talk", "CONVERSACIÓN"]]' in data
assert 'define vn_subtitle = "Fixture work"' in data
menus = (project / "game/menus.rpy").read_text(encoding="utf-8")
assert "Start(scene_label)" in menus and "@@" not in menus
screens = (project / "game/screens.rpy").read_text(encoding="utf-8")
assert 'textbutton "Escenas" action ShowMenu("vn_scene_select")' in screens
assert 'textbutton "Créditos" action ShowMenu("vn_credits")' in screens
assert "@@" not in screens
def test_repeated_headings_are_told_apart(work, annotated):
ann = json.loads(json.dumps(annotated))
ann["scenes"][1]["heading"] = ann["scenes"][0]["heading"]
scenes = [{"id": "talk", "heading": "x", "subtitle": "Día"}]
titles = renpy_gen.scene_menu_titles(_with_cfg(work, scenes=scenes), ann)
assert [t for _, t in titles] == ["LÍRICA (1)", "LÍRICA (Día)"]
def test_credits_from_work_audio_and_manifest(work, tmp_path):
root = tmp_path / "w"
(root / "audio").mkdir(parents=True)
(root / "audio/a.ogg").write_bytes(b"OggS")
(root / "audio/credits.toml").write_text(
'[[track]]\nfile = "audio/a.ogg"\nattribution = "Bach [x]. CC BY-SA 4.0."\n'
'[[track]]\nfile = "audio/missing.ogg"\nattribution = "not shipped"\n',
encoding="utf-8",
)
data = json.loads(json.dumps(work.data))
data["source"] = {"gutenberg_id": 42}
w = type(work)(root=root, data=data)
manifest = {
"assets": [
{"renditions": {"s": {"source": "chatgpt-web", "status": "approved"}}},
{"renditions": {"s": {"source": "placeholder", "status": "placeholder"}}},
]
}
sections = dict(renpy_gen.credits_sections(w, manifest))
assert sections["Texto"][0] == "A. Author"
assert sections["Texto"][1] == "Traducción: T. Translator"
assert "Proyecto Gutenberg, n.º 42" in sections["Texto"][2]
assert sections["Ilustraciones"] == ["Ilustraciones generadas con ChatGPT (OpenAI)"]
assert sections["Música"] == ["Bach [[x]. CC BY-SA 4.0."] # verbatim, markup-escaped only
def test_main_menu_background_from_ui(work, annotated, tmp_path):
out = _project(work, annotated, tmp_path, ui={"main_menu_bg": "bg_theatre"})
gui = (out / "game/gui.rpy").read_text(encoding="utf-8")
assert 'gui.main_menu_background = "bg theatre"' in gui
def test_reading_comfort_defaults(project):
options = (project / "game/options.rpy").read_text(encoding="utf-8")
assert "default preferences.text_cps = 40" in options
assert "default preferences.afm_time = 15" in options
assert "define config.has_music = True" in options