mirror of
https://github.com/Dasemu/vnpipe.git
synced 2026-11-26 07:16:23 +00:00
fix(renpy): ship unlabelled placeholders, bigger title cards, translated music credits
Placeholders no longer print the internal asset id; title cards get larger spaced headings and a rule above the subtitle; credits.toml tracks may carry attribution_<language>; slot frame images are generated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d3e7816e65
commit
c759374e4d
5 files changed
+75
-19
No files matched your search
+3
-2
@@ -77,7 +77,8 @@ mood (`ann.music`), unless overridden:
|
||||
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`.
|
||||
the music from `<work>/audio/credits.toml` (`[[track]]` with `file`, `attribution`, optional
|
||||
`attribution_<language>` used instead when it matches `[work].language`; 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.
|
||||
+11
-5
@@ -317,8 +317,13 @@ def process_asset(work_root: Path, asset: dict[str, Any], style: str) -> None:
|
||||
rendition["status"] = "processed"
|
||||
|
||||
|
||||
def placeholder(asset: dict[str, Any], label_color: str = "#d8cfc0") -> Image.Image:
|
||||
"""Deterministic stand-in image so the game always runs."""
|
||||
def placeholder(
|
||||
asset: dict[str, Any], label_color: str = "#d8cfc0", label: bool = True
|
||||
) -> Image.Image:
|
||||
"""Deterministic stand-in image so the game always runs.
|
||||
|
||||
``label`` draws the asset id (for the art pipeline); the game ships it without, since
|
||||
the id is an internal name the player should not see."""
|
||||
if asset["kind"] == "background":
|
||||
img = Image.new("RGB", BG_SIZE, "#1d1a17")
|
||||
draw = ImageDraw.Draw(img)
|
||||
@@ -330,9 +335,10 @@ def placeholder(asset: dict[str, Any], label_color: str = "#d8cfc0") -> Image.Im
|
||||
draw = ImageDraw.Draw(img)
|
||||
draw.ellipse([170, 40, 330, 220], fill=(60, 52, 46, 230))
|
||||
draw.rounded_rectangle([110, 230, 390, SPRITE_HEIGHT], 60, fill=(60, 52, 46, 230))
|
||||
draw = ImageDraw.Draw(img)
|
||||
font = ImageFont.load_default(size=40)
|
||||
draw.text((30, 30), asset["id"], fill=label_color, font=font)
|
||||
if label:
|
||||
draw = ImageDraw.Draw(img)
|
||||
font = ImageFont.load_default(size=40)
|
||||
draw.text((30, 30), asset["id"], fill=label_color, font=font)
|
||||
return img
|
||||
|
||||
|
||||
|
||||
+22
-7
@@ -325,7 +325,8 @@ def collect_images(work: Work, manifest: dict[str, Any] | None) -> list[ImageEnt
|
||||
candidate = work.path("assets") / rel
|
||||
if style == default:
|
||||
# the fallback may also be a placeholder; otherwise one is generated
|
||||
ok = rendition and rendition["status"] in {"processed", "approved", "placeholder"}
|
||||
# (a placeholder is always regenerated, without the asset id label)
|
||||
ok = rendition and rendition["status"] in {"processed", "approved"}
|
||||
variants.append((style, rel, candidate if ok and candidate.is_file() else None))
|
||||
elif usable_rendition(asset, style) and candidate.is_file():
|
||||
variants.append((style, rel, candidate))
|
||||
@@ -671,12 +672,21 @@ def _check_image(selected: bool, round_: bool) -> Image.Image:
|
||||
return img
|
||||
|
||||
|
||||
def _slot_image(border_alpha: int, fill_alpha: int) -> Image.Image:
|
||||
"""Save-slot frame (Ren'Py scales it with gui.slot_button_borders): thin outline plus tint."""
|
||||
img = Image.new("RGBA", (48, 48), IVORY + (fill_alpha,))
|
||||
ImageDraw.Draw(img).rectangle([0, 0, 47, 47], outline=ACCENT + (border_alpha,), width=2)
|
||||
return img
|
||||
|
||||
|
||||
def gui_extra_images() -> dict[str, Image.Image]:
|
||||
"""Deterministic simple GUI images, keyed by path relative to ``game/``."""
|
||||
base: dict[str, Image.Image] = {
|
||||
"button/background.png": _solid((24, 24), (0, 0, 0, 0)),
|
||||
"button/hover_background.png": _solid((24, 24), ACCENT + (60,)),
|
||||
"button/selected_background.png": _solid((24, 24), ACCENT + (35,)),
|
||||
"button/slot_idle_background.png": _slot_image(110, 14),
|
||||
"button/slot_hover_background.png": _slot_image(255, 40),
|
||||
"button/check_foreground.png": _check_image(False, False),
|
||||
"button/check_selected_foreground.png": _check_image(True, False),
|
||||
"button/radio_foreground.png": _check_image(False, True),
|
||||
@@ -807,14 +817,15 @@ def title_cards(work: Work, annotated: dict[str, Any]) -> dict[str, tuple[str, s
|
||||
|
||||
|
||||
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"
|
||||
"""A spaced-out heading; with a subtitle, a thin gold rule and a smaller italic line below."""
|
||||
props = "size=76, kerning=3, text_align=0.5, xmaximum=1600"
|
||||
if not subtitle:
|
||||
return f'Text("{escape_text(heading)}", {props})'
|
||||
sub_props = 'size=30, italic=True, color="#c9a25b", text_align=0.5'
|
||||
sub_props = 'size=34, italic=True, color="#c9a25b", text_align=0.5, xmaximum=1600'
|
||||
return (
|
||||
f'VBox(Text("{escape_text(heading)}", {props}, xalign=0.5), '
|
||||
f'Text("{escape_text(subtitle)}", {sub_props}, xalign=0.5), spacing=28)'
|
||||
'Solid("#c9a25b", xsize=200, ysize=2, xalign=0.5), '
|
||||
f'Text("{escape_text(subtitle)}", {sub_props}, xalign=0.5), spacing=26)'
|
||||
)
|
||||
|
||||
|
||||
@@ -903,7 +914,11 @@ def credits_sections(work: Work, manifest: dict[str, Any] | None) -> list[tuple[
|
||||
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]))
|
||||
lang = info.get("language", "es")
|
||||
# `attribution_<language>` is the same credit translated, used when present
|
||||
sections.append(
|
||||
(ui["music"], [t.get(f"attribution_{lang}") or 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]
|
||||
@@ -1039,7 +1054,7 @@ def generate(
|
||||
if source:
|
||||
shutil.copyfile(source, dest)
|
||||
else:
|
||||
placeholder(e.asset).save(dest, "WEBP", quality=90)
|
||||
placeholder(e.asset, label=False).save(dest, "WEBP", quality=90)
|
||||
|
||||
return sorted(written)
|
||||
|
||||
|
||||
@@ -316,6 +316,7 @@ def test_renpy_condition_switch_and_fallback(work_root, tmp_path):
|
||||
assert 'default persistent.art_style = "paint"' in styles
|
||||
assert "define vn_art_styles = [('paint', 'Paint'), ('ink', 'Ink')]" in styles
|
||||
assert "@@" not in styles
|
||||
assert "$ quick_menu = False" in styles # the picker hides the in-game quick menu
|
||||
assert "call vn_pick_art_style" in (out / "game/script.rpy").read_text(encoding="utf-8")
|
||||
screens = (out / "game/screens.rpy").read_text(encoding="utf-8")
|
||||
assert "Estilo visual" in screens and 'SetField(persistent, "art_style", style_id)' in screens
|
||||
@@ -353,3 +354,26 @@ def test_two_style_project_lints_and_plays(work_root, tmp_path):
|
||||
report = lint.stdout + lint.stderr
|
||||
assert lint.returncode == 0 and "error" not in report.lower(), report
|
||||
test_renpy_gen.run_e2e(out, home)
|
||||
|
||||
|
||||
def test_placeholder_label_only_when_asked():
|
||||
from PIL import ImageChops
|
||||
|
||||
from vnpipe.assets import placeholder
|
||||
|
||||
asset = {"id": "bg_x", "kind": "background"}
|
||||
labelled, plain = placeholder(asset), placeholder(asset, label=False)
|
||||
assert ImageChops.difference(labelled, plain).getbbox() is not None
|
||||
# the shipped placeholder is the plain gradient: no pixel brighter than its last row
|
||||
assert plain.getpixel((0, 0)) != plain.getpixel((0, plain.height - 1)) # a bare gradient
|
||||
|
||||
|
||||
def test_renpy_regenerates_placeholders_and_adds_slot_frames(work_root, tmp_path):
|
||||
assets.ensure_placeholder(
|
||||
work_root, assets.find_asset(assets.load_manifest(work_root), "bg_theatre"), "paint"
|
||||
)
|
||||
out = gen(work_root, tmp_path)
|
||||
shipped = Image.open(out / "game/images/bg/paint/theatre.webp").convert("RGB")
|
||||
assert shipped.getpixel((0, 40)) == shipped.getpixel((300, 40)) # no label on the row
|
||||
assert (out / "game/gui/button/slot_idle_background.png").is_file()
|
||||
assert (out / "game/gui/button/slot_hover_background.png").is_file()
|
||||
+15
-5
@@ -175,7 +175,10 @@ def test_characters_and_images(project):
|
||||
|
||||
def test_title_card_images(project):
|
||||
images = (project / "game/images.rpy").read_text(encoding="utf-8")
|
||||
assert 'image card_talk = Text("CONVERSACIÓN", size=60, text_align=0.5)' in images
|
||||
assert (
|
||||
'image card_talk = Text("CONVERSACIÓN", size=76, kerning=3, text_align=0.5, xmaximum=1600)'
|
||||
in images
|
||||
)
|
||||
assert 'image card_end = Text("Continuará…"' in images
|
||||
|
||||
|
||||
@@ -498,9 +501,12 @@ 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
|
||||
assert 'image card_talk = VBox(Text("CONVERSACIÓN", size=76' in images
|
||||
assert 'Text("Escenario · Día", size=34, italic=True' in images
|
||||
assert (
|
||||
'image card_lyric = Text("LÍRICA", size=76, kerning=3, text_align=0.5, xmaximum=1600)'
|
||||
in images
|
||||
) # no subtitle
|
||||
|
||||
|
||||
def test_scene_labels_and_menus(project, script):
|
||||
@@ -528,8 +534,11 @@ 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/b.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/b.ogg"\nattribution = "Liszt. Performed by X."\n'
|
||||
'attribution_es = "Liszt. Interpretación de X."\n'
|
||||
'[[track]]\nfile = "audio/missing.ogg"\nattribution = "not shipped"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
@@ -547,7 +556,8 @@ def test_credits_from_work_audio_and_manifest(work, tmp_path):
|
||||
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
|
||||
# verbatim (markup-escaped only); a translated `attribution_<language>` wins when present
|
||||
assert sections["Música"] == ["Bach [[x]. CC BY-SA 4.0.", "Liszt. Interpretación de X."]
|
||||
|
||||
|
||||
def test_main_menu_background_from_ui(work, annotated, tmp_path):
|
||||
|
||||
Reference in new issue
Block a user