feat(renpy): book-style Spanish menus and save/load register

- Ship the Spanish UI translation (common + screens) with the template,
  overlaid by the work's tl/, and force config.language so a stale
  persistent preference cannot fall back to English.
- Redesign main menu, game menu frame, save/load, preferences, history,
  help, about, confirm, notify and quick menu in the title-card style
  (gold rules, framed cards, deterministic PIL ornaments).
- Save slots: thumbnail, scene title, date and verse excerpt from save
  JSON metadata; four large slots per page, Roman-numeral pages,
  separate Autosaves/Quick saves tabs, per-slot delete, no Sync.
- Phone (small/touch) variants and e2e checks for save metadata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-20 12:45:46 +02:00
1 parent 92df74f0a5
commit d1236b470c
12 files changed
+2291 -302

No files matched your search

+63 -4
View File
@@ -1,5 +1,6 @@
import json
import os
import re
import subprocess
from pathlib import Path
@@ -434,22 +435,80 @@ def test_scan_and_copy_audio(work, tmp_path):
assert "audio/scenes/x.ogg" in audio.files
def test_copy_translations_and_default_language(work, tmp_path):
def test_copy_translations_and_forced_language(work, tmp_path):
root = tmp_path / "w"
(root / "tl/spanish").mkdir(parents=True)
(root / "tl/spanish/common.rpy").write_text("translate spanish strings:\n", encoding="utf-8")
work_common = "translate spanish strings:\n"
(root / "tl/spanish/common.rpy").write_text(work_common, encoding="utf-8")
(root / "tl/spanish/extra.rpy").write_text(work_common, encoding="utf-8")
data = {**work.data, "ui": {**work.data.get("ui", {}), "language": "spanish"}}
out = tmp_path / "out"
copied = renpy_gen.copy_translations(type(work)(root=root, data=data), out)
assert (out / "game/tl/spanish/common.rpy").is_file()
tl = out / "game/tl/spanish"
# vnpipe's own translation ships; a work file with the same path replaces it
shipped = renpy_gen.TEMPLATE_DIR / "tl/spanish/screens.rpy"
assert (tl / "screens.rpy").read_bytes() == shipped.read_bytes()
assert (tl / "common.rpy").read_text(encoding="utf-8") == work_common
assert (tl / "extra.rpy").is_file()
lang = out / "game/language.rpy"
assert lang in copied
assert lang.read_text(encoding="utf-8") == 'define config.default_language = "spanish"\n'
# config.language beats a persistent preference left by an older build
assert lang.read_text(encoding="utf-8") == (
'define config.default_language = "spanish"\ndefine config.language = "spanish"\n'
)
# Without [ui].language the stale file is removed.
renpy_gen.copy_translations(type(work)(root=tmp_path / "none", data=work.data), out)
assert not lang.exists()
def _tl_strings(path: Path) -> list[str]:
return re.findall(r'^\s*old "((?:[^"\\]|\\.)*)"$', path.read_text(encoding="utf-8"), re.M)
def test_shipped_spanish_covers_every_template_string():
"""Every _("...") string of the template screens has exactly one Spanish translation."""
template = ""
for path in sorted((renpy_gen.TEMPLATE_DIR / "game").glob("*.rpy")):
template += path.read_text(encoding="utf-8")
wanted = set(re.findall(r'(?<![\w.])_\("((?:[^"\\]|\\.)*)"\)', template))
wanted = {s for s in wanted if "@@" not in s} # work values (title) are already translated
assert len(wanted) > 70
olds = []
for path in sorted((renpy_gen.TEMPLATE_DIR / "tl/spanish").glob("*.rpy")):
olds += _tl_strings(path)
assert len(olds) == len(set(olds)), "a string translated twice breaks Ren'Py"
assert sorted(wanted - set(olds)) == []
def test_no_sync_buttons(project):
options = (project / "game/options.rpy").read_text(encoding="utf-8")
assert "define config.has_sync = False" in options
screens = (project / "game/screens.rpy").read_text(encoding="utf-8")
assert "UploadSync" not in screens and "DownloadSync" not in screens
def test_menu_ornaments_are_deterministic():
a, b = renpy_gen.gui_extra_images(), renpy_gen.gui_extra_images()
assert a.keys() == b.keys()
assert all(a[k].tobytes() == b[k].tobytes() for k in a)
for name in ("card_background", "card_hover_background", "rule", "nav_selected_background"):
assert f"gui/vn/{name}.png" in a
assert "gui/phone/vn/rule.png" not in a # ornaments are not looked up per variant
rule = a["gui/vn/rule.png"]
mid = rule.height // 2
# bright in the middle, faded at the ends
assert rule.getpixel((0, mid))[3] < 10 and rule.getpixel((rule.width // 3, mid))[3] == 255
def test_save_metadata_and_slots(project):
menus = (project / "game/menus.rpy").read_text(encoding="utf-8")
assert "config.save_json_callbacks.append(vn_save_json)" in menus
assert "store.vn_current_scene = label" in menus
screens = (project / "game/screens.rpy").read_text(encoding="utf-8")
assert 'info.get("vn_scene")' in screens and 'info["vn_line"]' in screens
assert "FileDelete(slot)" in screens and "vn_roman(page)" in screens
def test_mood_directory_is_a_playlist(work, annotated):
block = scene_block(renpy_gen.render_script(work, annotated, _audio()), "lyric")
assert _music_lines(block) == [