feat: add Ren'Py project generator with SDK-derived GUI template
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No files matched your search
@@ -25,3 +25,4 @@ build/
|
||||
.mcp.json
|
||||
# Original generated images are large; final processed assets are committed instead
|
||||
works/*/assets/raw/
|
||||
vn/*/progressive_download.txt
|
||||
@@ -0,0 +1,81 @@
|
||||
# Running, linting and building the game
|
||||
|
||||
The Ren'Py project in `vn/faust/` is generated; never edit it by hand. All commands run
|
||||
from the repository root.
|
||||
|
||||
## 1. Ren'Py SDK
|
||||
|
||||
The SDK is not committed (`tools/` is gitignored). Install **Ren'Py 8.5.3** (SDK
|
||||
archive from <https://www.renpy.org/latest.html>, `renpy-8.5.3-sdk.tar.bz2`) so that
|
||||
`tools/renpy-sdk/renpy.sh` exists:
|
||||
|
||||
```sh
|
||||
mkdir -p tools && tar -xjf renpy-8.5.3-sdk.tar.bz2 -C tools && mv tools/renpy-8.5.3-sdk tools/renpy-sdk
|
||||
```
|
||||
|
||||
The SDK already contains the web runtime (`tools/renpy-sdk/web`) and the Linux, Windows
|
||||
and macOS distribution templates. Inside the sandbox set `HOME=$TMPDIR/renpy-home` for
|
||||
SDK commands, since Ren'Py writes to `~/.renpy`.
|
||||
|
||||
## 2. Regenerate the project
|
||||
|
||||
```sh
|
||||
uv run vnpipe renpy # from works/faust/data/annotated.json
|
||||
uv run vnpipe renpy --from-parsed # trivial annotations built from parsed.json
|
||||
uv run vnpipe renpy --out some/dir # default output: vn/<work id>
|
||||
```
|
||||
|
||||
Generation is deterministic: running it twice gives identical files (no timestamps).
|
||||
It rewrites `game/{options,gui,screens,support,characters,images,script}.rpy`,
|
||||
`game/gui/`, `game/fonts/` and `game/images/`; anything else (for example `game/audio/`)
|
||||
is left alone. Music only appears in the script for moods that have a matching
|
||||
`game/audio/<mood>.ogg`, so drop files there and regenerate.
|
||||
|
||||
Images come from `works/<id>/assets/assets.json` (statuses `processed`, `approved`,
|
||||
`placeholder`); anything missing or unusable is replaced by a generated placeholder so
|
||||
the game always runs.
|
||||
|
||||
### GUI template and licences
|
||||
|
||||
`src/vnpipe/renpy_templates/` holds the default Ren'Py GUI (`gui.rpy`, `screens.rpy`,
|
||||
`options.rpy` and `gui/*.png`). It was generated once with the SDK's own command and then
|
||||
edited minimally (dark palette, ivory text, accent `#c9a25b`, Roboto Slab font, NVL
|
||||
tweaks, `@@TOKEN@@` placeholders for title/build name/about text/menu background):
|
||||
|
||||
```sh
|
||||
tools/renpy-sdk/renpy.sh tools/renpy-sdk/launcher generate_gui OUT --width 1920 --height 1080 \
|
||||
--accent '#c9a25b' --boring '#14110e' --template "$PWD/tools/renpy-sdk/gui" --start
|
||||
```
|
||||
|
||||
These files are part of Ren'Py (MIT licence, Tom Rothamel and contributors). The font
|
||||
`game/fonts/RobotoSlab-*.ttf` is Roboto Slab (Apache 2.0), taken from the SDK
|
||||
documentation assets.
|
||||
|
||||
## 3. Lint
|
||||
|
||||
```sh
|
||||
HOME=$TMPDIR/renpy-home tools/renpy-sdk/renpy.sh vn/faust lint
|
||||
```
|
||||
|
||||
The expected result is a statistics block with no warnings above it.
|
||||
|
||||
## 4. Play
|
||||
|
||||
```sh
|
||||
tools/renpy-sdk/renpy.sh vn/faust
|
||||
```
|
||||
|
||||
## 5. Builds (output under `build/`, gitignored)
|
||||
|
||||
```sh
|
||||
# Web (HTML5)
|
||||
tools/renpy-sdk/renpy.sh tools/renpy-sdk/launcher web_build vn/faust --destination build/web
|
||||
python3 -m http.server -d build/web 8000 # then open http://localhost:8000
|
||||
|
||||
# Linux desktop
|
||||
tools/renpy-sdk/renpy.sh tools/renpy-sdk/launcher distribute vn/faust --package linux --destination build/dist
|
||||
```
|
||||
|
||||
`--package` also accepts `win` and `mac`; omit it to build every package. The web build
|
||||
also leaves a `build/web.zip` next to the folder. A web build writes
|
||||
`vn/faust/progressive_download.txt`; delete it (it is not part of the generated project).
|
||||
@@ -0,0 +1,577 @@
|
||||
"""Ren'Py generator: annotated play + asset manifest -> a complete Ren'Py 8 project.
|
||||
|
||||
The output is deterministic (no timestamps, sorted iteration, copied bytes), so
|
||||
re-running the command yields identical files. Staging rules are documented in
|
||||
``docs/adaptation-rules.md``; work-specific choices come from ``work.toml``.
|
||||
|
||||
The GUI files in ``renpy_templates/`` were produced once with the Ren'Py SDK's
|
||||
``generate_gui`` command and are MIT-licensed Ren'Py files (see ``docs/running.md``).
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import shutil
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from vnpipe import PACKAGE_DIR
|
||||
from vnpipe.assets import USABLE, load_manifest, placeholder
|
||||
from vnpipe.config import Work, load_work
|
||||
from vnpipe.schema import validate
|
||||
|
||||
TEMPLATE_DIR = PACKAGE_DIR / "renpy_templates"
|
||||
USABLE_STATUS = USABLE | {"placeholder"}
|
||||
|
||||
ADV_MAX_LINES = 4
|
||||
NVL_MAX_LINES = 8
|
||||
SPLIT_INDENT = 6 # parsed `indent` at or above this marks a split verse line
|
||||
TITLE_PAUSE = 2.0
|
||||
END_PAUSE = 3.0
|
||||
|
||||
POSITIONS = ("left", "right", "center") # order in which --from-parsed assigns positions
|
||||
TRANSITIONS = {
|
||||
"dissolve": "dissolve",
|
||||
"fade": "fade",
|
||||
"slow": "vn_slow",
|
||||
"flash": "vn_flash",
|
||||
}
|
||||
TINTS = ("none", "dark", "red")
|
||||
DEFAULT_LYRIC_VOICE = "poet_voice"
|
||||
DEFAULT_END_TEXT = "Continuará…"
|
||||
MENU_BG_FALLBACK = "gui/main_menu.png"
|
||||
|
||||
ABOUT_LABELS = {
|
||||
"es": ("Texto", "Traducción", "Adaptación a novela visual generada con vnpipe."),
|
||||
"en": ("Text", "Translation", "Visual novel adaptation generated with vnpipe."),
|
||||
}
|
||||
|
||||
|
||||
# --- text helpers -------------------------------------------------------------
|
||||
|
||||
|
||||
def escape_text(text: str) -> str:
|
||||
"""Escape a text for use inside a double-quoted Ren'Py say/define string."""
|
||||
return (
|
||||
text.replace("\\", "\\\\")
|
||||
.replace('"', '\\"')
|
||||
.replace("[", "[[")
|
||||
.replace("{", "{{")
|
||||
.replace("\n", "\\n")
|
||||
)
|
||||
|
||||
|
||||
def quote(text: str) -> str:
|
||||
return f'"{escape_text(text)}"'
|
||||
|
||||
|
||||
def _plain_quote(text: str) -> str:
|
||||
"""Quote a path or identifier-like string (no Ren'Py text markup)."""
|
||||
return '"' + text.replace("\\", "\\\\").replace('"', '\\"') + '"'
|
||||
|
||||
|
||||
def char_var(cast_id: str, nvl: bool = False) -> str:
|
||||
"""Ren'Py variable of a cast member's Character (prefixed: `director` etc. are built-ins)."""
|
||||
return f"c_{cast_id}" + ("_nvl" if nvl else "")
|
||||
|
||||
|
||||
def bg_image_name(asset_id: str) -> str:
|
||||
"""``bg_heaven_lord`` -> ``bg heaven_lord`` (tag ``bg``, attribute ``heaven_lord``)."""
|
||||
return "bg " + asset_id.removeprefix("bg_")
|
||||
|
||||
|
||||
# --- annotations ----------------------------------------------------------------
|
||||
|
||||
|
||||
def lyric_voice(work: Work) -> str:
|
||||
return work.data["work"].get("lyric_voice", DEFAULT_LYRIC_VOICE)
|
||||
|
||||
|
||||
def annotations_from_parsed(work: Work, parsed: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Trivial in-memory annotations (used before the LLM annotations exist)."""
|
||||
voice = lyric_voice(work)
|
||||
scene_cfg = {s["id"]: s for s in work.scenes}
|
||||
digest = hashlib.sha256(
|
||||
json.dumps(parsed, sort_keys=True, ensure_ascii=False).encode("utf-8")
|
||||
).hexdigest()
|
||||
scenes = []
|
||||
for scene in parsed["scenes"]:
|
||||
cfg = scene_cfg.get(scene["id"], {})
|
||||
spoken: list[str] = []
|
||||
positions: dict[str, str] = {}
|
||||
lines = []
|
||||
for line in scene["lines"]:
|
||||
speaker = line["speaker"]
|
||||
if line["kind"] == "direction":
|
||||
ann_speaker, kind = "narrator", "stage_direction"
|
||||
elif speaker:
|
||||
ann_speaker, kind = speaker, "dialogue"
|
||||
else:
|
||||
ann_speaker, kind = voice, "narration"
|
||||
if line["kind"] == "verse" and speaker and work.cast.get(speaker, {}).get("sprite"):
|
||||
if speaker not in positions:
|
||||
positions[speaker] = POSITIONS[len(positions) % len(POSITIONS)]
|
||||
if speaker not in spoken:
|
||||
spoken.append(speaker)
|
||||
lines.append(
|
||||
{
|
||||
**line,
|
||||
"ann": {
|
||||
"speaker": ann_speaker,
|
||||
"kind": kind,
|
||||
"emotion": "neutral",
|
||||
"location": cfg.get("location", "unknown"),
|
||||
"time_of_day": cfg.get("time_of_day", "timeless"),
|
||||
"on_stage": [{"character": c, "position": positions[c]} for c in spoken],
|
||||
},
|
||||
}
|
||||
)
|
||||
scenes.append({"id": scene["id"], "heading": scene["heading"], "lines": lines})
|
||||
return {
|
||||
"work": parsed["work"],
|
||||
"parsed_sha256": digest,
|
||||
"fallback_chunks": [],
|
||||
"scenes": scenes,
|
||||
}
|
||||
|
||||
|
||||
# --- assets -----------------------------------------------------------------------
|
||||
|
||||
|
||||
@dataclass
|
||||
class ImageEntry:
|
||||
name: str # Ren'Py image name, e.g. "bg heaven" or "faust neutral"
|
||||
rel: str # path below game/images/
|
||||
asset: dict[str, Any]
|
||||
source: Path | None # file to copy, or None to generate a placeholder
|
||||
|
||||
|
||||
def _sprite_asset(character: str, expression: str) -> dict[str, Any]:
|
||||
return {
|
||||
"id": f"sprite_{character}_{expression}",
|
||||
"kind": "sprite",
|
||||
"character": character,
|
||||
"expression": expression,
|
||||
"file": f"sprites/{character}_{expression}.webp",
|
||||
}
|
||||
|
||||
|
||||
def _bg_asset(asset_id: str) -> dict[str, Any]:
|
||||
return {
|
||||
"id": asset_id,
|
||||
"kind": "background",
|
||||
"file": f"bg/{asset_id.removeprefix('bg_')}.webp",
|
||||
}
|
||||
|
||||
|
||||
def _needed_bg_ids(work: Work) -> list[str]:
|
||||
ids = [cfg["bg"] for cfg in work.data.get("staging", {}).values() if cfg.get("bg")]
|
||||
ids += [cue["bg"] for cue in work.data.get("cues", []) if cue.get("bg")]
|
||||
return ids
|
||||
|
||||
|
||||
def collect_images(work: Work, manifest: dict[str, Any] | None) -> list[ImageEntry]:
|
||||
"""Every image the project declares: manifest assets plus anything the staging needs."""
|
||||
assets: dict[str, dict[str, Any]] = {}
|
||||
for asset in (manifest or {}).get("assets", []):
|
||||
assets[asset["id"]] = asset
|
||||
for asset_id in _needed_bg_ids(work):
|
||||
assets.setdefault(asset_id, _bg_asset(asset_id))
|
||||
for cid, info in work.cast.items():
|
||||
if not info.get("sprite"):
|
||||
continue
|
||||
for expression in sorted(set(info.get("expressions", {}).values())):
|
||||
sprite = _sprite_asset(cid, expression)
|
||||
assets.setdefault(sprite["id"], sprite)
|
||||
entries = []
|
||||
for asset_id in sorted(assets):
|
||||
asset = assets[asset_id]
|
||||
if asset["kind"] == "background":
|
||||
name = bg_image_name(asset_id)
|
||||
else:
|
||||
name = f"{asset['character']} {asset['expression']}"
|
||||
source = None
|
||||
if asset.get("status") in USABLE_STATUS and asset.get("file"):
|
||||
candidate = work.path("assets") / asset["file"]
|
||||
if candidate.is_file():
|
||||
source = candidate
|
||||
entries.append(ImageEntry(name, asset["file"], asset, source))
|
||||
return entries
|
||||
|
||||
|
||||
# --- script generation ----------------------------------------------------------------
|
||||
|
||||
|
||||
@dataclass
|
||||
class Box:
|
||||
lines: list[dict[str, Any]] = field(default_factory=list)
|
||||
key: tuple | None = None
|
||||
speaker: str = ""
|
||||
is_direction: bool = False
|
||||
|
||||
|
||||
def _is_direction(line: dict[str, Any]) -> bool:
|
||||
return line["kind"] == "direction" or line["ann"]["kind"] == "stage_direction"
|
||||
|
||||
|
||||
class SceneWriter:
|
||||
"""Turns one scene's lines into Ren'Py statements, tracking staging state."""
|
||||
|
||||
def __init__(
|
||||
self, work: Work, scene: dict[str, Any], moods: set[str], music_state: dict[str, str | None]
|
||||
):
|
||||
self.work = work
|
||||
self.scene = scene
|
||||
self.moods = moods
|
||||
self.voice = lyric_voice(work)
|
||||
self.cues = {c["at"]: c for c in work.data.get("cues", [])}
|
||||
staging = work.data.get("staging", {}).get(scene["id"], {})
|
||||
self.mode: str = staging.get("mode", "adv")
|
||||
self.bg: str | None = staging.get("bg")
|
||||
self.tint = "none"
|
||||
self.music_state = music_state # {'playing': mood}, shared across scenes
|
||||
self.shown: dict[str, str] = {} # character -> expression currently shown
|
||||
self.positions: dict[str, str] = {} # character -> stable position for this scene
|
||||
self.out: list[str] = []
|
||||
self.box: Box | None = None
|
||||
|
||||
def emit(self, text: str = "") -> None:
|
||||
self.out.append((" " + text) if text else "")
|
||||
|
||||
# -- speakers ---------------------------------------------------------------
|
||||
|
||||
def speaker_of(self, line: dict[str, Any]) -> str:
|
||||
if _is_direction(line):
|
||||
return "narrator"
|
||||
speaker = line["ann"]["speaker"] or self.voice
|
||||
if speaker != "narrator" and speaker not in self.work.cast:
|
||||
raise ValueError(f"{line['id']}: speaker {speaker!r} is not in [cast]")
|
||||
return speaker
|
||||
|
||||
# -- cues ----------------------------------------------------------------------
|
||||
|
||||
def apply_cue(self, cue: dict[str, Any]) -> None:
|
||||
changes = False
|
||||
new_mode = cue.get("mode", self.mode)
|
||||
if self.mode == "nvl" and new_mode != "nvl":
|
||||
self.emit("nvl hide dissolve")
|
||||
if new_mode == "nvl" or cue.get("hide_all"):
|
||||
changes |= self.hide_sprites(list(self.shown))
|
||||
self.mode = new_mode
|
||||
if cue.get("tint") is not None:
|
||||
if cue["tint"] not in TINTS:
|
||||
raise ValueError(f"cue at {cue['at']}: unknown tint {cue['tint']!r}")
|
||||
self.tint = cue["tint"]
|
||||
if cue.get("bg") or cue.get("tint") is not None:
|
||||
self.bg = cue.get("bg") or self.bg
|
||||
self.emit(f"show {bg_image_name(self.bg)} at tint_{self.tint}")
|
||||
changes = True
|
||||
if changes:
|
||||
transition = cue.get("transition", "dissolve")
|
||||
if transition not in TRANSITIONS:
|
||||
raise ValueError(f"cue at {cue['at']}: unknown transition {transition!r}")
|
||||
self.emit(f"with {TRANSITIONS[transition]}")
|
||||
if cue.get("shake"):
|
||||
self.emit("show layer master at vn_shake")
|
||||
|
||||
def hide_sprites(self, characters: list[str]) -> bool:
|
||||
for cid in characters:
|
||||
self.emit(f"hide {cid}")
|
||||
del self.shown[cid]
|
||||
return bool(characters)
|
||||
|
||||
# -- boxes ----------------------------------------------------------------------
|
||||
|
||||
def limit(self) -> int:
|
||||
return NVL_MAX_LINES if self.mode == "nvl" else ADV_MAX_LINES
|
||||
|
||||
def feed(self, line: dict[str, Any]) -> None:
|
||||
if line["kind"] == "cast":
|
||||
return
|
||||
cue = self.cues.get(line["id"])
|
||||
if cue:
|
||||
self.flush()
|
||||
self.apply_cue(cue)
|
||||
direction = _is_direction(line)
|
||||
key = (self.speaker_of(line), line["speech"], line["stanza"])
|
||||
split = self.mode == "adv" and not direction and line["indent"] >= SPLIT_INDENT
|
||||
box = self.box
|
||||
if box and (
|
||||
direction
|
||||
or box.is_direction
|
||||
or key != box.key
|
||||
or len(box.lines) >= self.limit()
|
||||
or split
|
||||
or (self.mode == "adv" and box.lines[-1]["indent"] >= SPLIT_INDENT)
|
||||
):
|
||||
self.flush()
|
||||
if self.box is None:
|
||||
self.box = Box(key=key, speaker=key[0], is_direction=direction)
|
||||
self.box.lines.append(line)
|
||||
|
||||
def flush(self) -> None:
|
||||
box = self.box
|
||||
if not box:
|
||||
return
|
||||
self.box = None
|
||||
first, last = box.lines[0], box.lines[-1]
|
||||
ids = first["id"] if first is last else f"{first['id']} .. {last['id']}"
|
||||
self.emit(f"# {ids}")
|
||||
self.music(first["ann"].get("music"))
|
||||
if self.mode == "adv":
|
||||
self.stage(box)
|
||||
text = "\\n".join(escape_text(line["text"]) for line in box.lines)
|
||||
variable = char_var(box.speaker, nvl=self.mode == "nvl")
|
||||
self.emit(f'{variable} "{text}"')
|
||||
if self.mode == "nvl":
|
||||
self.emit("nvl clear")
|
||||
|
||||
def music(self, mood: str | None) -> None:
|
||||
if mood is None:
|
||||
return
|
||||
if mood == "none":
|
||||
if self.music_state["playing"]:
|
||||
self.emit("stop music fadeout 1.0")
|
||||
self.music_state["playing"] = None
|
||||
elif mood in self.moods and self.music_state["playing"] != mood:
|
||||
self.emit(f'play music "audio/{mood}.ogg" fadeout 1.0 fadein 1.0')
|
||||
self.music_state["playing"] = mood
|
||||
|
||||
# -- sprites ---------------------------------------------------------------------
|
||||
|
||||
def stage(self, box: Box) -> None:
|
||||
first = box.lines[0]
|
||||
ann = first["ann"]
|
||||
desired: list[str] = []
|
||||
for entry in ann["on_stage"]:
|
||||
cid = entry["character"]
|
||||
if cid not in self.work.cast:
|
||||
raise ValueError(f"{first['id']}: on_stage character {cid!r} is not in [cast]")
|
||||
if not self.work.cast[cid].get("sprite"):
|
||||
continue
|
||||
self.positions.setdefault(cid, entry["position"])
|
||||
desired.append(cid)
|
||||
changed = self.hide_sprites([c for c in list(self.shown) if c not in desired])
|
||||
for cid in desired:
|
||||
expressions = self.work.cast[cid].get("expressions", {})
|
||||
neutral = expressions.get("neutral", "neutral")
|
||||
if cid == box.speaker:
|
||||
expression = expressions.get(ann["emotion"], neutral)
|
||||
else:
|
||||
expression = self.shown.get(cid, neutral)
|
||||
if self.shown.get(cid) != expression:
|
||||
self.emit(f"show {cid} {expression} at vn_{self.positions[cid]}")
|
||||
self.shown[cid] = expression
|
||||
changed = True
|
||||
if changed:
|
||||
self.emit("with dissolve")
|
||||
|
||||
# -- scene ---------------------------------------------------------------------------
|
||||
|
||||
def render(self) -> list[str]:
|
||||
scene = self.scene
|
||||
self.out.append(f"label scene_{scene['id']}:")
|
||||
self.emit("scene black")
|
||||
self.emit(
|
||||
f'show text "{{size=60}}{escape_text(scene["heading"])}{{/size}}" '
|
||||
"as title_card at truecenter"
|
||||
)
|
||||
self.emit("with fade")
|
||||
self.emit(f"pause {TITLE_PAUSE}")
|
||||
self.emit("hide title_card")
|
||||
if self.bg:
|
||||
self.emit(f"scene {bg_image_name(self.bg)} at tint_{self.tint}")
|
||||
self.emit("with fade")
|
||||
for line in scene["lines"]:
|
||||
self.feed(line)
|
||||
self.flush()
|
||||
if self.mode == "nvl":
|
||||
self.emit("nvl hide dissolve")
|
||||
self.out.append("")
|
||||
return self.out
|
||||
|
||||
|
||||
def render_script(work: Work, annotated: dict[str, Any], moods: set[str]) -> str:
|
||||
end_text = work.data["work"].get("end_text", DEFAULT_END_TEXT)
|
||||
out = [
|
||||
"## Generated by `vnpipe renpy`. Do not edit: regenerate instead.",
|
||||
"",
|
||||
"label start:",
|
||||
" window auto",
|
||||
"",
|
||||
]
|
||||
known = {c["at"] for c in work.data.get("cues", [])}
|
||||
seen: set[str] = set()
|
||||
music_state: dict[str, str | None] = {"playing": None}
|
||||
for scene in annotated["scenes"]:
|
||||
out.extend(SceneWriter(work, scene, moods, music_state).render())
|
||||
seen |= {line["id"] for line in scene["lines"]}
|
||||
missing = known - seen
|
||||
if missing:
|
||||
raise ValueError(f"cues refer to unknown line ids: {sorted(missing)}")
|
||||
out += [
|
||||
" scene black",
|
||||
" with fade",
|
||||
f' show text "{{size=60}}{escape_text(end_text)}{{/size}}" as title_card at truecenter',
|
||||
" with dissolve",
|
||||
f" pause {END_PAUSE}",
|
||||
" return",
|
||||
"",
|
||||
]
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
# --- static project files -----------------------------------------------------------------
|
||||
|
||||
|
||||
def render_characters(work: Work) -> str:
|
||||
cast = dict(work.cast)
|
||||
cast.setdefault("narrator", {"name": "", "color": "#d8cfc0"})
|
||||
out = ["## Generated by `vnpipe renpy`. Do not edit: regenerate instead.", ""]
|
||||
for cid, info in cast.items():
|
||||
name = info.get("name") or ""
|
||||
color = info.get("color")
|
||||
who = quote(name) if name else "None"
|
||||
props: list[str] = []
|
||||
if name and color:
|
||||
props.append(f"who_color={_plain_quote(color)}")
|
||||
if not name and color:
|
||||
props.append(f"what_color={_plain_quote(color)}")
|
||||
if cid == "narrator":
|
||||
props.append("what_italic=True")
|
||||
adv = ", ".join([who, *props])
|
||||
nvl_props = ["kind=nvl", *props]
|
||||
if not name:
|
||||
nvl_props.append('what_style="nvl_thought"')
|
||||
out.append(f"define {char_var(cid)} = Character({adv})")
|
||||
out.append(f"define {char_var(cid, nvl=True)} = Character({', '.join([who, *nvl_props])})")
|
||||
out.append("")
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
def render_images(entries: list[ImageEntry]) -> str:
|
||||
out = ["## Generated by `vnpipe renpy`. Do not edit: regenerate instead.", ""]
|
||||
for e in entries:
|
||||
out.append(f"image {e.name} = {_plain_quote('images/' + e.rel)}")
|
||||
out.append("")
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
def _about(work: Work) -> str:
|
||||
info = work.data["work"]
|
||||
text_l, trans_l, tail = ABOUT_LABELS.get(info.get("language", "es"), ABOUT_LABELS["en"])
|
||||
parts = [info.get("subtitle", "")]
|
||||
if info.get("author"):
|
||||
parts.append(f"{text_l}: {info['author']}")
|
||||
if info.get("translator"):
|
||||
parts.append(f"{trans_l}: {info['translator']}")
|
||||
parts.append(tail)
|
||||
return "\\n\\n".join(escape_text(p) for p in parts if p)
|
||||
|
||||
|
||||
def _substitute(text: str, values: dict[str, str]) -> str:
|
||||
for key, value in values.items():
|
||||
text = text.replace(f"@@{key}@@", value)
|
||||
if "@@" in text:
|
||||
raise ValueError("unreplaced template token")
|
||||
return text
|
||||
|
||||
|
||||
def write_text(path: Path, text: str) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text, encoding="utf-8", newline="\n")
|
||||
|
||||
|
||||
def _audio_moods(out: Path) -> set[str]:
|
||||
audio = out / "game" / "audio"
|
||||
return {p.stem for p in audio.glob("*.ogg")} if audio.is_dir() else set()
|
||||
|
||||
|
||||
def generate(work: Work, annotated: dict[str, Any], out: Path) -> list[Path]:
|
||||
"""Write the Ren'Py project into ``out``; returns every generated file (sorted)."""
|
||||
info = work.data["work"]
|
||||
manifest_path = work.path("assets/assets.json")
|
||||
manifest = load_manifest(work.root) if manifest_path.is_file() else None
|
||||
entries = collect_images(work, manifest)
|
||||
game = out / "game"
|
||||
for sub in ("images", "gui", "fonts"):
|
||||
shutil.rmtree(game / sub, ignore_errors=True)
|
||||
game.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# GUI template: copy binaries, substitute tokens in .rpy files.
|
||||
menu_bg = MENU_BG_FALLBACK
|
||||
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)
|
||||
if first_bg:
|
||||
menu_bg = bg_image_name(first_bg)
|
||||
values = {
|
||||
"TITLE": escape_text(info["title"]),
|
||||
"VERSION": "0.1",
|
||||
"ABOUT": _about(work),
|
||||
"BUILD_NAME": f"{info['id']}-vn",
|
||||
"SAVE_DIR": f"{info['id']}-vn",
|
||||
"MENU_BG": menu_bg,
|
||||
}
|
||||
written: list[Path] = []
|
||||
for src in sorted((TEMPLATE_DIR / "game").rglob("*")):
|
||||
if not src.is_file():
|
||||
continue
|
||||
dest = game / src.relative_to(TEMPLATE_DIR / "game")
|
||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||
written.append(dest)
|
||||
if src.suffix == ".rpy":
|
||||
write_text(dest, _substitute(src.read_text(encoding="utf-8"), values))
|
||||
else:
|
||||
shutil.copyfile(src, dest)
|
||||
|
||||
for name, text in (
|
||||
("characters.rpy", render_characters(work)),
|
||||
("images.rpy", render_images(entries)),
|
||||
("script.rpy", render_script(work, annotated, _audio_moods(out))),
|
||||
):
|
||||
write_text(game / name, text)
|
||||
written.append(game / name)
|
||||
|
||||
for e in entries:
|
||||
dest = game / "images" / e.rel
|
||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||
written.append(dest)
|
||||
if e.source:
|
||||
shutil.copyfile(e.source, dest)
|
||||
else:
|
||||
placeholder(e.asset).save(dest, "WEBP", quality=90)
|
||||
|
||||
return sorted(written)
|
||||
|
||||
|
||||
# --- CLI ----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def cmd_renpy(args: argparse.Namespace) -> int:
|
||||
work = load_work(args.work)
|
||||
if args.from_parsed:
|
||||
parsed = json.loads(work.path("data/parsed.json").read_text(encoding="utf-8"))
|
||||
validate(parsed, "parsed")
|
||||
annotated = annotations_from_parsed(work, parsed)
|
||||
else:
|
||||
path = work.path("data/annotated.json")
|
||||
if not path.is_file():
|
||||
raise SystemExit(f"renpy: {path} missing; run annotation or pass --from-parsed")
|
||||
annotated = json.loads(path.read_text(encoding="utf-8"))
|
||||
validate(annotated, "annotated")
|
||||
out = args.out or Path("vn") / work.id
|
||||
files = generate(work, annotated, out)
|
||||
print(f"renpy: wrote {len(files)} files under {out}")
|
||||
return 0
|
||||
|
||||
|
||||
def register(subparsers: argparse._SubParsersAction) -> None:
|
||||
parser = subparsers.add_parser("renpy", help="Generate the Ren'Py project")
|
||||
parser.add_argument(
|
||||
"--from-parsed",
|
||||
action="store_true",
|
||||
help="Build trivial annotations from parsed.json instead of reading annotated.json",
|
||||
)
|
||||
parser.add_argument("--out", type=Path, help="Output directory (default: vn/<work id>)")
|
||||
parser.set_defaults(handler=cmd_renpy)
|
||||
@@ -0,0 +1,480 @@
|
||||
################################################################################
|
||||
## Initialization
|
||||
################################################################################
|
||||
|
||||
## The init offset statement causes the initialization statements in this file
|
||||
## to run before init statements in any other file.
|
||||
init offset = -2
|
||||
|
||||
## Calling gui.init resets the styles to sensible default values, and sets the
|
||||
## width and height of the game.
|
||||
init python:
|
||||
gui.init(1920, 1080)
|
||||
|
||||
## Enable checks for invalid or unstable properties in screens or transforms
|
||||
define config.check_conflicting_properties = True
|
||||
|
||||
|
||||
################################################################################
|
||||
## GUI Configuration Variables
|
||||
################################################################################
|
||||
|
||||
|
||||
## Colors ######################################################################
|
||||
##
|
||||
## The colors of text in the interface.
|
||||
|
||||
## An accent color used throughout the interface to label and highlight text.
|
||||
define gui.accent_color = '#c9a25b'
|
||||
|
||||
## The color used for a text button when it is neither selected nor hovered.
|
||||
define gui.idle_color = '#888888'
|
||||
|
||||
## The small color is used for small text, which needs to be brighter/darker to
|
||||
## achieve the same effect.
|
||||
define gui.idle_small_color = '#aaaaaa'
|
||||
|
||||
## The color that is used for buttons and bars that are hovered.
|
||||
define gui.hover_color = '#dec79c'
|
||||
|
||||
## The color used for a text button when it is selected but not focused. A
|
||||
## button is selected if it is the current screen or preference value.
|
||||
define gui.selected_color = '#ffffff'
|
||||
|
||||
## The color used for a text button when it cannot be selected.
|
||||
define gui.insensitive_color = '#8888887f'
|
||||
|
||||
## Colors used for the portions of bars that are not filled in. These are not
|
||||
## used directly, but are used when re-generating bar image files.
|
||||
define gui.muted_color = '#504024'
|
||||
define gui.hover_muted_color = '#786136'
|
||||
|
||||
## The colors used for dialogue and menu choice text.
|
||||
define gui.text_color = '#efe6d2'
|
||||
define gui.interface_text_color = '#efe6d2'
|
||||
|
||||
|
||||
## Fonts and Font Sizes ########################################################
|
||||
|
||||
## The font used for in-game text.
|
||||
define gui.text_font = "fonts/RobotoSlab-Regular.ttf"
|
||||
|
||||
## The font used for character names.
|
||||
define gui.name_text_font = "fonts/RobotoSlab-Regular.ttf"
|
||||
|
||||
## The font used for out-of-game text.
|
||||
define gui.interface_text_font = "fonts/RobotoSlab-Regular.ttf"
|
||||
|
||||
## The size of normal dialogue text.
|
||||
define gui.text_size = 33
|
||||
|
||||
## The size of character names.
|
||||
define gui.name_text_size = 45
|
||||
|
||||
## The size of text in the game's user interface.
|
||||
define gui.interface_text_size = 33
|
||||
|
||||
## The size of labels in the game's user interface.
|
||||
define gui.label_text_size = 36
|
||||
|
||||
## The size of text on the notify screen.
|
||||
define gui.notify_text_size = 24
|
||||
|
||||
## The size of the game's title.
|
||||
define gui.title_text_size = 75
|
||||
|
||||
|
||||
## Main and Game Menus #########################################################
|
||||
|
||||
## The images used for the main and game menus.
|
||||
define gui.main_menu_background = "@@MENU_BG@@"
|
||||
define gui.game_menu_background = "@@MENU_BG@@"
|
||||
|
||||
|
||||
## Dialogue ####################################################################
|
||||
##
|
||||
## These variables control how dialogue is displayed on the screen one line at a
|
||||
## time.
|
||||
|
||||
## The height of the textbox containing dialogue.
|
||||
define gui.textbox_height = 278
|
||||
|
||||
## The placement of the textbox vertically on the screen. 0.0 is the top, 0.5 is
|
||||
## center, and 1.0 is the bottom.
|
||||
define gui.textbox_yalign = 1.0
|
||||
|
||||
|
||||
## The placement of the speaking character's name, relative to the textbox.
|
||||
## These can be a whole number of pixels from the left or top, or 0.5 to center.
|
||||
define gui.name_xpos = 360
|
||||
define gui.name_ypos = 0
|
||||
|
||||
## The horizontal alignment of the character's name. This can be 0.0 for left-
|
||||
## aligned, 0.5 for centered, and 1.0 for right-aligned.
|
||||
define gui.name_xalign = 0.0
|
||||
|
||||
## The width, height, and borders of the box containing the character's name, or
|
||||
## None to automatically size it.
|
||||
define gui.namebox_width = None
|
||||
define gui.namebox_height = None
|
||||
|
||||
## The borders of the box containing the character's name, in left, top, right,
|
||||
## bottom order.
|
||||
define gui.namebox_borders = Borders(5, 5, 5, 5)
|
||||
|
||||
## If True, the background of the namebox will be tiled, if False, the
|
||||
## background of the namebox will be scaled.
|
||||
define gui.namebox_tile = False
|
||||
|
||||
|
||||
## The placement of dialogue relative to the textbox. These can be a whole
|
||||
## number of pixels relative to the left or top side of the textbox, or 0.5 to
|
||||
## center.
|
||||
define gui.dialogue_xpos = 402
|
||||
define gui.dialogue_ypos = 75
|
||||
|
||||
## The maximum width of dialogue text, in pixels.
|
||||
define gui.dialogue_width = 1116
|
||||
|
||||
## The horizontal alignment of the dialogue text. This can be 0.0 for left-
|
||||
## aligned, 0.5 for centered, and 1.0 for right-aligned.
|
||||
define gui.dialogue_text_xalign = 0.0
|
||||
|
||||
|
||||
## Buttons #####################################################################
|
||||
##
|
||||
## These variables, along with the image files in gui/button, control aspects of
|
||||
## how buttons are displayed.
|
||||
|
||||
## The width and height of a button, in pixels. If None, Ren'Py computes a size.
|
||||
define gui.button_width = None
|
||||
define gui.button_height = None
|
||||
|
||||
## The borders on each side of the button, in left, top, right, bottom order.
|
||||
define gui.button_borders = Borders(6, 6, 6, 6)
|
||||
|
||||
## If True, the background image will be tiled. If False, the background image
|
||||
## will be linearly scaled.
|
||||
define gui.button_tile = False
|
||||
|
||||
## The font used by the button.
|
||||
define gui.button_text_font = gui.interface_text_font
|
||||
|
||||
## The size of the text used by the button.
|
||||
define gui.button_text_size = gui.interface_text_size
|
||||
|
||||
## The color of button text in various states.
|
||||
define gui.button_text_idle_color = gui.idle_color
|
||||
define gui.button_text_hover_color = gui.hover_color
|
||||
define gui.button_text_selected_color = gui.selected_color
|
||||
define gui.button_text_insensitive_color = gui.insensitive_color
|
||||
|
||||
## The horizontal alignment of the button text. (0.0 is left, 0.5 is center, 1.0
|
||||
## is right).
|
||||
define gui.button_text_xalign = 0.0
|
||||
|
||||
|
||||
## These variables override settings for different kinds of buttons. Please see
|
||||
## the gui documentation for the kinds of buttons available, and what each is
|
||||
## used for.
|
||||
##
|
||||
## These customizations are used by the default interface:
|
||||
|
||||
define gui.radio_button_borders = Borders(27, 6, 6, 6)
|
||||
|
||||
define gui.check_button_borders = Borders(27, 6, 6, 6)
|
||||
|
||||
define gui.confirm_button_text_xalign = 0.5
|
||||
|
||||
define gui.page_button_borders = Borders(15, 6, 15, 6)
|
||||
|
||||
define gui.quick_button_borders = Borders(15, 6, 15, 0)
|
||||
define gui.quick_button_text_size = 21
|
||||
define gui.quick_button_text_idle_color = gui.idle_small_color
|
||||
define gui.quick_button_text_selected_color = gui.accent_color
|
||||
|
||||
## You can also add your own customizations, by adding properly-named variables.
|
||||
## For example, you can uncomment the following line to set the width of a
|
||||
## navigation button.
|
||||
|
||||
# define gui.navigation_button_width = 250
|
||||
|
||||
|
||||
## Choice Buttons ##############################################################
|
||||
##
|
||||
## Choice buttons are used in the in-game menus.
|
||||
|
||||
define gui.choice_button_width = 1185
|
||||
define gui.choice_button_height = None
|
||||
define gui.choice_button_tile = False
|
||||
define gui.choice_button_borders = Borders(150, 8, 150, 8)
|
||||
define gui.choice_button_text_font = gui.text_font
|
||||
define gui.choice_button_text_size = gui.text_size
|
||||
define gui.choice_button_text_xalign = 0.5
|
||||
define gui.choice_button_text_idle_color = '#888888'
|
||||
define gui.choice_button_text_hover_color = "#ffffff"
|
||||
define gui.choice_button_text_insensitive_color = '#8888887f'
|
||||
|
||||
|
||||
## File Slot Buttons ###########################################################
|
||||
##
|
||||
## A file slot button is a special kind of button. It contains a thumbnail
|
||||
## image, and text describing the contents of the save slot. A save slot uses
|
||||
## image files in gui/button, like the other kinds of buttons.
|
||||
|
||||
## The save slot button.
|
||||
define gui.slot_button_width = 414
|
||||
define gui.slot_button_height = 309
|
||||
define gui.slot_button_borders = Borders(15, 15, 15, 15)
|
||||
define gui.slot_button_text_size = 21
|
||||
define gui.slot_button_text_xalign = 0.5
|
||||
define gui.slot_button_text_idle_color = gui.idle_small_color
|
||||
define gui.slot_button_text_selected_idle_color = gui.selected_color
|
||||
define gui.slot_button_text_selected_hover_color = gui.hover_color
|
||||
|
||||
## The width and height of thumbnails used by the save slots.
|
||||
define config.thumbnail_width = 384
|
||||
define config.thumbnail_height = 216
|
||||
|
||||
## The number of columns and rows in the grid of save slots.
|
||||
define gui.file_slot_cols = 3
|
||||
define gui.file_slot_rows = 2
|
||||
|
||||
|
||||
## Positioning and Spacing #####################################################
|
||||
##
|
||||
## These variables control the positioning and spacing of various user interface
|
||||
## elements.
|
||||
|
||||
## The position of the left side of the navigation buttons, relative to the left
|
||||
## side of the screen.
|
||||
define gui.navigation_xpos = 60
|
||||
|
||||
## The vertical position of the skip indicator.
|
||||
define gui.skip_ypos = 15
|
||||
|
||||
## The vertical position of the notify screen.
|
||||
define gui.notify_ypos = 68
|
||||
|
||||
## The spacing between menu choices.
|
||||
define gui.choice_spacing = 33
|
||||
|
||||
## Buttons in the navigation section of the main and game menus.
|
||||
define gui.navigation_spacing = 6
|
||||
|
||||
## Controls the amount of spacing between preferences.
|
||||
define gui.pref_spacing = 15
|
||||
|
||||
## Controls the amount of spacing between preference buttons.
|
||||
define gui.pref_button_spacing = 0
|
||||
|
||||
## The spacing between file page buttons.
|
||||
define gui.page_spacing = 0
|
||||
|
||||
## The spacing between file slots.
|
||||
define gui.slot_spacing = 15
|
||||
|
||||
## The position of the main menu text.
|
||||
define gui.main_menu_text_xalign = 1.0
|
||||
|
||||
|
||||
## Frames ######################################################################
|
||||
##
|
||||
## These variables control the look of frames that can contain user interface
|
||||
## components when an overlay or window is not present.
|
||||
|
||||
## Generic frames.
|
||||
define gui.frame_borders = Borders(6, 6, 6, 6)
|
||||
|
||||
## The frame that is used as part of the confirm screen.
|
||||
define gui.confirm_frame_borders = Borders(60, 60, 60, 60)
|
||||
|
||||
## The frame that is used as part of the skip screen.
|
||||
define gui.skip_frame_borders = Borders(24, 8, 75, 8)
|
||||
|
||||
## The frame that is used as part of the notify screen.
|
||||
define gui.notify_frame_borders = Borders(24, 8, 60, 8)
|
||||
|
||||
## Should frame backgrounds be tiled?
|
||||
define gui.frame_tile = False
|
||||
|
||||
|
||||
## Bars, Scrollbars, and Sliders ###############################################
|
||||
##
|
||||
## These control the look and size of bars, scrollbars, and sliders.
|
||||
##
|
||||
## The default GUI only uses sliders and vertical scrollbars. All of the other
|
||||
## bars are only used in creator-written screens.
|
||||
|
||||
## The height of horizontal bars, scrollbars, and sliders. The width of vertical
|
||||
## bars, scrollbars, and sliders.
|
||||
define gui.bar_size = 38
|
||||
define gui.scrollbar_size = 18
|
||||
define gui.slider_size = 38
|
||||
|
||||
## True if bar images should be tiled. False if they should be linearly scaled.
|
||||
define gui.bar_tile = False
|
||||
define gui.scrollbar_tile = False
|
||||
define gui.slider_tile = False
|
||||
|
||||
## Horizontal borders.
|
||||
define gui.bar_borders = Borders(6, 6, 6, 6)
|
||||
define gui.scrollbar_borders = Borders(6, 6, 6, 6)
|
||||
define gui.slider_borders = Borders(6, 6, 6, 6)
|
||||
|
||||
## Vertical borders.
|
||||
define gui.vbar_borders = Borders(6, 6, 6, 6)
|
||||
define gui.vscrollbar_borders = Borders(6, 6, 6, 6)
|
||||
define gui.vslider_borders = Borders(6, 6, 6, 6)
|
||||
|
||||
## What to do with unscrollable scrollbars in the game menu. "hide" hides them,
|
||||
## while None shows them.
|
||||
define gui.unscrollable = "hide"
|
||||
|
||||
|
||||
## History #####################################################################
|
||||
##
|
||||
## The history screen displays dialogue that the player has already dismissed.
|
||||
|
||||
## The number of blocks of dialogue history Ren'Py will keep.
|
||||
define config.history_length = 250
|
||||
|
||||
## The height of a history screen entry, or None to make the height variable at
|
||||
## the cost of performance.
|
||||
define gui.history_height = 210
|
||||
|
||||
## Additional space to add between history screen entries.
|
||||
define gui.history_spacing = 0
|
||||
|
||||
## The position, width, and alignment of the label giving the name of the
|
||||
## speaking character.
|
||||
define gui.history_name_xpos = 233
|
||||
define gui.history_name_ypos = 0
|
||||
define gui.history_name_width = 233
|
||||
define gui.history_name_xalign = 1.0
|
||||
|
||||
## The position, width, and alignment of the dialogue text.
|
||||
define gui.history_text_xpos = 255
|
||||
define gui.history_text_ypos = 3
|
||||
define gui.history_text_width = 1110
|
||||
define gui.history_text_xalign = 0.0
|
||||
|
||||
|
||||
## NVL-Mode ####################################################################
|
||||
##
|
||||
## The NVL-mode screen displays the dialogue spoken by NVL-mode characters.
|
||||
|
||||
## The borders of the background of the NVL-mode background window.
|
||||
define gui.nvl_borders = Borders(0, 15, 0, 30)
|
||||
|
||||
## The maximum number of NVL-mode entries Ren'Py will display. When more entries
|
||||
## than this are to be show, the oldest entry will be removed.
|
||||
define gui.nvl_list_length = 12
|
||||
|
||||
## The height of an NVL-mode entry. Set this to None to have the entries
|
||||
## dynamically adjust height.
|
||||
define gui.nvl_height = None
|
||||
|
||||
## The spacing between NVL-mode entries when gui.nvl_height is None, and between
|
||||
## NVL-mode entries and an NVL-mode menu.
|
||||
define gui.nvl_spacing = 15
|
||||
|
||||
## The position, width, and alignment of the label giving the name of the
|
||||
## speaking character.
|
||||
define gui.nvl_name_xpos = 645
|
||||
define gui.nvl_name_ypos = 0
|
||||
define gui.nvl_name_width = 225
|
||||
define gui.nvl_name_xalign = 1.0
|
||||
|
||||
## The position, width, and alignment of the dialogue text.
|
||||
define gui.nvl_text_xpos = 675
|
||||
define gui.nvl_text_ypos = 12
|
||||
define gui.nvl_text_width = 885
|
||||
define gui.nvl_text_xalign = 0.0
|
||||
|
||||
## The position, width, and alignment of nvl_thought text (the text said by the
|
||||
## nvl_narrator character.)
|
||||
define gui.nvl_thought_xpos = 360
|
||||
define gui.nvl_thought_ypos = 0
|
||||
define gui.nvl_thought_width = 1170
|
||||
define gui.nvl_thought_xalign = 0.0
|
||||
|
||||
## The position of nvl menu_buttons.
|
||||
define gui.nvl_button_xpos = 675
|
||||
define gui.nvl_button_xalign = 0.0
|
||||
|
||||
|
||||
## Localization ################################################################
|
||||
|
||||
## This controls where a line break is permitted. The default is suitable
|
||||
## for most languages. A list of available values can be found at https://
|
||||
## www.renpy.org/doc/html/style_properties.html#style-property-language
|
||||
|
||||
define gui.language = "unicode"
|
||||
|
||||
|
||||
################################################################################
|
||||
## Mobile devices
|
||||
################################################################################
|
||||
|
||||
init python:
|
||||
|
||||
## This increases the size of the quick buttons to make them easier to touch
|
||||
## on tablets and phones.
|
||||
@gui.variant
|
||||
def touch():
|
||||
|
||||
gui.quick_button_borders = Borders(60, 21, 60, 0)
|
||||
|
||||
## This changes the size and spacing of various GUI elements to ensure they
|
||||
## are easily visible on phones.
|
||||
@gui.variant
|
||||
def small():
|
||||
|
||||
## Font sizes.
|
||||
gui.text_size = 45
|
||||
gui.name_text_size = 54
|
||||
gui.notify_text_size = 38
|
||||
gui.interface_text_size = 45
|
||||
gui.button_text_size = 45
|
||||
gui.label_text_size = 51
|
||||
|
||||
## Adjust the location of the textbox.
|
||||
gui.textbox_height = 360
|
||||
gui.name_xpos = 120
|
||||
gui.dialogue_xpos = 135
|
||||
gui.dialogue_width = 1650
|
||||
|
||||
## Change the size and spacing of various things.
|
||||
gui.slider_size = 54
|
||||
|
||||
gui.choice_button_width = 1860
|
||||
gui.choice_button_text_size = 45
|
||||
|
||||
gui.navigation_spacing = 30
|
||||
gui.pref_button_spacing = 15
|
||||
|
||||
gui.history_height = 285
|
||||
gui.history_text_width = 1035
|
||||
|
||||
gui.quick_button_text_size = 30
|
||||
|
||||
## File button layout.
|
||||
gui.file_slot_cols = 2
|
||||
gui.file_slot_rows = 2
|
||||
|
||||
## NVL-mode.
|
||||
gui.nvl_height = None
|
||||
|
||||
gui.nvl_name_width = 458
|
||||
gui.nvl_name_xpos = 488
|
||||
|
||||
gui.nvl_text_width = 1373
|
||||
gui.nvl_text_xpos = 518
|
||||
gui.nvl_text_ypos = 8
|
||||
|
||||
gui.nvl_thought_width = 1860
|
||||
gui.nvl_thought_xpos = 30
|
||||
|
||||
gui.nvl_button_width = 1860
|
||||
gui.nvl_button_xpos = 30
|
||||
|
After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 198 B |
|
After Width: | Height: | Size: 198 B |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 503 B |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 722 B |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,208 @@
|
||||
## This file contains options that can be changed to customize your game.
|
||||
##
|
||||
## Lines beginning with two '#' marks are comments, and you shouldn't uncomment
|
||||
## them. Lines beginning with a single '#' mark are commented-out code, and you
|
||||
## may want to uncomment them when appropriate.
|
||||
|
||||
|
||||
## Basics ######################################################################
|
||||
|
||||
## A human-readable name of the game. This is used to set the default window
|
||||
## title, and shows up in the interface and error reports.
|
||||
##
|
||||
## The _() surrounding the string marks it as eligible for translation.
|
||||
|
||||
define config.name = _("@@TITLE@@")
|
||||
|
||||
|
||||
## Determines if the title given above is shown on the main menu screen. Set
|
||||
## this to False to hide the title.
|
||||
|
||||
define gui.show_name = True
|
||||
|
||||
|
||||
## The version of the game.
|
||||
|
||||
define config.version = "@@VERSION@@"
|
||||
|
||||
|
||||
## Text that is placed on the game's about screen. Place the text between the
|
||||
## triple-quotes, and leave a blank line between paragraphs.
|
||||
|
||||
define gui.about = _p("""@@ABOUT@@""")
|
||||
|
||||
|
||||
## A short name for the game used for executables and directories in the built
|
||||
## distribution. This must be ASCII-only, and must not contain spaces, colons,
|
||||
## or semicolons.
|
||||
|
||||
define build.name = "@@BUILD_NAME@@"
|
||||
|
||||
|
||||
## Sounds and music ############################################################
|
||||
|
||||
## These three variables control, among other things, which mixers are shown
|
||||
## to the player by default. Setting one of these to False will hide the
|
||||
## appropriate mixer.
|
||||
|
||||
define config.has_sound = False
|
||||
define config.has_music = False
|
||||
define config.has_voice = True
|
||||
|
||||
|
||||
## To allow the user to play a test sound on the sound or voice channel,
|
||||
## uncomment a line below and use it to set a sample sound to play.
|
||||
|
||||
# define config.sample_sound = "sample-sound.ogg"
|
||||
# define config.sample_voice = "sample-voice.ogg"
|
||||
|
||||
|
||||
## Uncomment the following line to set an audio file that will be played while
|
||||
## the player is at the main menu. This file will continue playing into the
|
||||
## game, until it is stopped or another file is played.
|
||||
|
||||
# define config.main_menu_music = "main-menu-theme.ogg"
|
||||
|
||||
|
||||
## Transitions #################################################################
|
||||
##
|
||||
## These variables set transitions that are used when certain events occur.
|
||||
## Each variable should be set to a transition, or None to indicate that no
|
||||
## transition should be used.
|
||||
|
||||
## Entering or exiting the game menu.
|
||||
|
||||
define config.enter_transition = dissolve
|
||||
define config.exit_transition = dissolve
|
||||
|
||||
|
||||
## Between screens of the game menu.
|
||||
|
||||
define config.intra_transition = dissolve
|
||||
|
||||
|
||||
## A transition that is used after a game has been loaded.
|
||||
|
||||
define config.after_load_transition = None
|
||||
|
||||
|
||||
## Used when entering the main menu after the game has ended.
|
||||
|
||||
define config.end_game_transition = None
|
||||
|
||||
|
||||
## A variable to set the transition used when the game starts does not exist.
|
||||
## Instead, use a with statement after showing the initial scene.
|
||||
|
||||
|
||||
## Window management ###########################################################
|
||||
##
|
||||
## This controls when the dialogue window is displayed. If "show", it is always
|
||||
## displayed. If "hide", it is only displayed when dialogue is present. If
|
||||
## "auto", the window is hidden before scene statements and shown again once
|
||||
## dialogue is displayed.
|
||||
##
|
||||
## After the game has started, this can be changed with the "window show",
|
||||
## "window hide", and "window auto" statements.
|
||||
|
||||
define config.window = "auto"
|
||||
|
||||
|
||||
## Transitions used to show and hide the dialogue window
|
||||
|
||||
define config.window_show_transition = Dissolve(.2)
|
||||
define config.window_hide_transition = Dissolve(.2)
|
||||
|
||||
|
||||
## Preference defaults #########################################################
|
||||
|
||||
## Controls the default text speed. The default, 0, is infinite, while any other
|
||||
## number is the number of characters per second to type out.
|
||||
|
||||
default preferences.text_cps = 0
|
||||
|
||||
|
||||
## The default auto-forward delay. Larger numbers lead to longer waits, with 0
|
||||
## to 30 being the valid range.
|
||||
|
||||
default preferences.afm_time = 15
|
||||
|
||||
|
||||
## Save directory ##############################################################
|
||||
##
|
||||
## Controls the platform-specific place Ren'Py will place the save files for
|
||||
## this game. The save files will be placed in:
|
||||
##
|
||||
## Windows: %APPDATA\RenPy\<config.save_directory>
|
||||
##
|
||||
## Macintosh: $HOME/Library/RenPy/<config.save_directory>
|
||||
##
|
||||
## Linux: $HOME/.renpy/<config.save_directory>
|
||||
##
|
||||
## This generally should not be changed, and if it is, should always be a
|
||||
## literal string, not an expression.
|
||||
|
||||
define config.save_directory = "@@SAVE_DIR@@"
|
||||
|
||||
|
||||
## Icon ########################################################################
|
||||
##
|
||||
## The icon displayed on the taskbar or dock.
|
||||
|
||||
define config.window_icon = "gui/window_icon.png"
|
||||
|
||||
|
||||
## Build configuration #########################################################
|
||||
##
|
||||
## This section controls how Ren'Py turns your project into distribution files.
|
||||
|
||||
init python:
|
||||
|
||||
## The following functions take file patterns. File patterns are case-
|
||||
## insensitive, and matched against the path relative to the base directory,
|
||||
## with and without a leading /. If multiple patterns match, the first is
|
||||
## used.
|
||||
##
|
||||
## In a pattern:
|
||||
##
|
||||
## / is the directory separator.
|
||||
##
|
||||
## * matches all characters, except the directory separator.
|
||||
##
|
||||
## ** matches all characters, including the directory separator.
|
||||
##
|
||||
## For example, "*.txt" matches txt files in the base directory, "game/
|
||||
## **.ogg" matches ogg files in the game directory or any of its
|
||||
## subdirectories, and "**.psd" matches psd files anywhere in the project.
|
||||
|
||||
## Classify files as None to exclude them from the built distributions.
|
||||
|
||||
build.classify('**~', None)
|
||||
build.classify('**.bak', None)
|
||||
build.classify('**/.**', None)
|
||||
build.classify('**/#**', None)
|
||||
build.classify('**/thumbs.db', None)
|
||||
|
||||
## To archive files, classify them as 'archive'.
|
||||
|
||||
# build.classify('game/**.png', 'archive')
|
||||
# build.classify('game/**.jpg', 'archive')
|
||||
|
||||
## Files matching documentation patterns are duplicated in a mac app build,
|
||||
## so they appear in both the app and the zip file.
|
||||
|
||||
build.documentation('*.html')
|
||||
build.documentation('*.txt')
|
||||
|
||||
|
||||
## A Google Play license key is required to perform in-app purchases. It can be
|
||||
## found in the Google Play developer console, under "Monetize" > "Monetization
|
||||
## Setup" > "Licensing".
|
||||
|
||||
# define build.google_play_key = "..."
|
||||
|
||||
|
||||
## The username and project name associated with an itch.io project, separated
|
||||
## by a slash.
|
||||
|
||||
# define build.itch_project = "renpytom/test-project"
|
||||
@@ -0,0 +1,36 @@
|
||||
## Support code for the generated script: transitions, stage positions, colour
|
||||
## treatments and the screen shake. Static; copied verbatim by `vnpipe renpy`.
|
||||
|
||||
define vn_slow = Dissolve(2.0)
|
||||
define vn_flash = Fade(0.1, 0.0, 0.6, color="#ffffff")
|
||||
|
||||
transform vn_left:
|
||||
xalign 0.15 yalign 1.0
|
||||
|
||||
transform vn_center:
|
||||
xalign 0.5 yalign 1.0
|
||||
|
||||
transform vn_right:
|
||||
xalign 0.85 yalign 1.0
|
||||
|
||||
transform tint_none:
|
||||
matrixcolor IdentityMatrix()
|
||||
|
||||
transform tint_dark:
|
||||
matrixcolor TintMatrix("#8a8498") * BrightnessMatrix(-0.2)
|
||||
|
||||
transform tint_red:
|
||||
matrixcolor TintMatrix("#f0968a") * BrightnessMatrix(-0.05)
|
||||
|
||||
transform vn_shake:
|
||||
xoffset 0 yoffset 0
|
||||
linear 0.05 xoffset 18 yoffset -8
|
||||
linear 0.05 xoffset -18 yoffset 8
|
||||
linear 0.05 xoffset 14 yoffset -6
|
||||
linear 0.05 xoffset -14 yoffset 6
|
||||
linear 0.05 xoffset 8 yoffset -3
|
||||
linear 0.05 xoffset 0 yoffset 0
|
||||
|
||||
init python:
|
||||
config.font_replacement_map["fonts/RobotoSlab-Regular.ttf", True, False] = (
|
||||
"fonts/RobotoSlab-Bold.ttf", False, False)
|
||||
@@ -0,0 +1,699 @@
|
||||
{
|
||||
"work": "mini",
|
||||
"parsed_sha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"fallback_chunks": [],
|
||||
"scenes": [
|
||||
{
|
||||
"id": "lyric",
|
||||
"heading": "LÍRICA",
|
||||
"lines": [
|
||||
{
|
||||
"id": "lyric_0001",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Tornáis de nuevo, imágenes flotantes,",
|
||||
"src_line": 100,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": [],
|
||||
"music": "sacred"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0002",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "que un día contemplé,",
|
||||
"src_line": 101,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0003",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "¿Asiros podré feliz?",
|
||||
"src_line": 102,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0004",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Venid, y envueltas en el velo,",
|
||||
"src_line": 103,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0005",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "girad en derredor;",
|
||||
"src_line": 104,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0006",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "el corazón aún late,",
|
||||
"src_line": 105,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0007",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "si aspira vuestro aliento.",
|
||||
"src_line": 106,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0008",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Hoy vuelven de otro tiempo",
|
||||
"src_line": 107,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0009",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "la alegre historia,",
|
||||
"src_line": 108,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0010",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 1,
|
||||
"indent": 0,
|
||||
"text": "Y los queridos seres",
|
||||
"src_line": 120,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lyric_0011",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 1,
|
||||
"indent": 0,
|
||||
"text": "que la dicha nos robó.",
|
||||
"src_line": 121,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "melancholic",
|
||||
"location": "dedication",
|
||||
"time_of_day": "timeless",
|
||||
"on_stage": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "talk",
|
||||
"heading": "CONVERSACIÓN",
|
||||
"lines": [
|
||||
{
|
||||
"id": "talk_0001",
|
||||
"kind": "cast",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "EL DIRECTOR, EL POETA",
|
||||
"src_line": 200,
|
||||
"ann": {
|
||||
"speaker": null,
|
||||
"kind": "narration",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0002",
|
||||
"kind": "verse",
|
||||
"speaker": "director",
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 2,
|
||||
"text": "Decid, buenos amigos,",
|
||||
"src_line": 201,
|
||||
"ann": {
|
||||
"speaker": "director",
|
||||
"kind": "dialogue",
|
||||
"emotion": "joyful",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0003",
|
||||
"kind": "verse",
|
||||
"speaker": "director",
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "de mi afán camaradas,",
|
||||
"src_line": 202,
|
||||
"ann": {
|
||||
"speaker": "director",
|
||||
"kind": "dialogue",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0004",
|
||||
"kind": "verse",
|
||||
"speaker": "director",
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "¿qué pensáis [ahora]?",
|
||||
"src_line": 203,
|
||||
"ann": {
|
||||
"speaker": "director",
|
||||
"kind": "dialogue",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0005",
|
||||
"kind": "verse",
|
||||
"speaker": "director",
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Es mi {anhelo} preferente",
|
||||
"src_line": 204,
|
||||
"ann": {
|
||||
"speaker": "director",
|
||||
"kind": "dialogue",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0006",
|
||||
"kind": "verse",
|
||||
"speaker": "director",
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "al público dar gusto:",
|
||||
"src_line": 205,
|
||||
"ann": {
|
||||
"speaker": "director",
|
||||
"kind": "dialogue",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0007",
|
||||
"kind": "verse",
|
||||
"speaker": "director",
|
||||
"speaker_note": null,
|
||||
"speech": 0,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "lo \"mejor\" que pueda.",
|
||||
"src_line": 206,
|
||||
"ann": {
|
||||
"speaker": "director",
|
||||
"kind": "dialogue",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0008",
|
||||
"kind": "verse",
|
||||
"speaker": "poet",
|
||||
"speaker_note": null,
|
||||
"speech": 1,
|
||||
"stanza": 0,
|
||||
"indent": 26,
|
||||
"text": "¡Vete, profano!",
|
||||
"src_line": 207,
|
||||
"ann": {
|
||||
"speaker": "poet",
|
||||
"kind": "dialogue",
|
||||
"emotion": "angry",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "right"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0009",
|
||||
"kind": "verse",
|
||||
"speaker": "director",
|
||||
"speaker_note": null,
|
||||
"speech": 2,
|
||||
"stanza": 0,
|
||||
"indent": 20,
|
||||
"text": "Calla, que oye.",
|
||||
"src_line": 208,
|
||||
"ann": {
|
||||
"speaker": "director",
|
||||
"kind": "dialogue",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "right"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0010",
|
||||
"kind": "direction",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 2,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Se aleja.",
|
||||
"src_line": 209,
|
||||
"ann": {
|
||||
"speaker": "narrator",
|
||||
"kind": "stage_direction",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "right"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0011",
|
||||
"kind": "verse",
|
||||
"speaker": "poet",
|
||||
"speaker_note": null,
|
||||
"speech": 3,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Mi pecho se oprime",
|
||||
"src_line": 210,
|
||||
"ann": {
|
||||
"speaker": "poet",
|
||||
"kind": "dialogue",
|
||||
"emotion": "melancholic",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0012",
|
||||
"kind": "verse",
|
||||
"speaker": "poet",
|
||||
"speaker_note": null,
|
||||
"speech": 3,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "bajo tanto peso,",
|
||||
"src_line": 211,
|
||||
"ann": {
|
||||
"speaker": "poet",
|
||||
"kind": "dialogue",
|
||||
"emotion": "melancholic",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0013",
|
||||
"kind": "verse",
|
||||
"speaker": "poet",
|
||||
"speaker_note": null,
|
||||
"speech": 3,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "y el ocaso llega.",
|
||||
"src_line": 212,
|
||||
"ann": {
|
||||
"speaker": "poet",
|
||||
"kind": "dialogue",
|
||||
"emotion": "melancholic",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0014",
|
||||
"kind": "verse",
|
||||
"speaker": "lord",
|
||||
"speaker_note": null,
|
||||
"speech": 4,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "¡Mi siervo!",
|
||||
"src_line": 213,
|
||||
"ann": {
|
||||
"speaker": "lord",
|
||||
"kind": "dialogue",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "right"
|
||||
},
|
||||
{
|
||||
"character": "lord",
|
||||
"position": "center"
|
||||
}
|
||||
],
|
||||
"music": "none"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0015",
|
||||
"kind": "verse",
|
||||
"speaker": "lord",
|
||||
"speaker_note": null,
|
||||
"speech": 4,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Tentarlo puedes.",
|
||||
"src_line": 214,
|
||||
"ann": {
|
||||
"speaker": "lord",
|
||||
"kind": "dialogue",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "right"
|
||||
},
|
||||
{
|
||||
"character": "lord",
|
||||
"position": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0016",
|
||||
"kind": "verse",
|
||||
"speaker": "director",
|
||||
"speaker_note": null,
|
||||
"speech": 5,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Basta ya de charla.",
|
||||
"src_line": 215,
|
||||
"ann": {
|
||||
"speaker": "director",
|
||||
"kind": "dialogue",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "right"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0017",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 6,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Callan los pájaros;",
|
||||
"src_line": 216,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0018",
|
||||
"kind": "verse",
|
||||
"speaker": null,
|
||||
"speaker_note": null,
|
||||
"speech": 6,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "la noche cae.",
|
||||
"src_line": 217,
|
||||
"ann": {
|
||||
"speaker": "poet_voice",
|
||||
"kind": "narration",
|
||||
"emotion": "neutral",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "talk_0019",
|
||||
"kind": "verse",
|
||||
"speaker": "poet",
|
||||
"speaker_note": null,
|
||||
"speech": 7,
|
||||
"stanza": 0,
|
||||
"indent": 0,
|
||||
"text": "Despierto.",
|
||||
"src_line": 218,
|
||||
"ann": {
|
||||
"speaker": "poet",
|
||||
"kind": "dialogue",
|
||||
"emotion": "angry",
|
||||
"location": "stage",
|
||||
"time_of_day": "day",
|
||||
"on_stage": [
|
||||
{
|
||||
"character": "director",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"character": "poet",
|
||||
"position": "right"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
# Minimal work used by tests/test_renpy_gen.py (no assets: the generator falls back to placeholders).
|
||||
[work]
|
||||
id = "mini"
|
||||
title = "Mini"
|
||||
subtitle = "Fixture work"
|
||||
author = "A. Author"
|
||||
translator = "T. Translator"
|
||||
language = "es"
|
||||
|
||||
[cast.narrator]
|
||||
name = ""
|
||||
color = "#d8cfc0"
|
||||
|
||||
[cast.poet_voice]
|
||||
name = ""
|
||||
color = "#e8dcc2"
|
||||
sprite = false
|
||||
|
||||
[cast.director]
|
||||
name = "El Director"
|
||||
color = "#c9a25b"
|
||||
sprite = true
|
||||
expressions = { neutral = "neutral", joyful = "pleased", angry = "worried" }
|
||||
|
||||
[cast.poet]
|
||||
name = "El Poeta"
|
||||
color = "#8fa8c8"
|
||||
sprite = true
|
||||
expressions = { neutral = "neutral", melancholic = "neutral", angry = "indignant" }
|
||||
|
||||
[cast.lord]
|
||||
name = "El Señor"
|
||||
color = "#fff4c8"
|
||||
sprite = false
|
||||
|
||||
[staging.lyric]
|
||||
bg = "bg_dedication"
|
||||
mode = "nvl"
|
||||
|
||||
[staging.talk]
|
||||
bg = "bg_theatre"
|
||||
mode = "adv"
|
||||
|
||||
[[cues]]
|
||||
at = "talk_0014"
|
||||
bg = "bg_heaven"
|
||||
transition = "slow"
|
||||
tint = "dark"
|
||||
hide_all = true
|
||||
|
||||
[[cues]]
|
||||
at = "talk_0016"
|
||||
mode = "nvl"
|
||||
|
||||
[[cues]]
|
||||
at = "talk_0019"
|
||||
bg = "bg_theatre"
|
||||
transition = "flash"
|
||||
tint = "none"
|
||||
mode = "adv"
|
||||
shake = true
|
||||
@@ -0,0 +1,255 @@
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from vnpipe import renpy_gen
|
||||
from vnpipe.config import load_work
|
||||
from vnpipe.schema import validate
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
FIXTURES = Path(__file__).parent / "fixtures"
|
||||
SDK = ROOT / "tools/renpy-sdk/renpy.sh"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def work():
|
||||
return load_work(FIXTURES / "mini_work")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def annotated():
|
||||
data = json.loads((FIXTURES / "annotated_mini.json").read_text(encoding="utf-8"))
|
||||
validate(data, "annotated")
|
||||
return data
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def project(work, annotated, tmp_path_factory):
|
||||
out = tmp_path_factory.mktemp("proj")
|
||||
renpy_gen.generate(work, annotated, out)
|
||||
return out
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def script(project) -> str:
|
||||
return (project / "game/script.rpy").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def scene_block(script: str, scene_id: str) -> list[str]:
|
||||
lines = script.split("\n")
|
||||
start = lines.index(f"label scene_{scene_id}:")
|
||||
end = next((i for i in range(start + 1, len(lines)) if lines[i].startswith("label ")), None)
|
||||
if end is None:
|
||||
end = len(lines)
|
||||
return [ln.strip() for ln in lines[start:end]]
|
||||
|
||||
|
||||
def say_lines(block: list[str]) -> list[str]:
|
||||
return [ln for ln in block if ln.startswith("c_")]
|
||||
|
||||
|
||||
def test_escape_text():
|
||||
assert renpy_gen.escape_text("a [b] {c}") == "a [[b] {{c}"
|
||||
assert renpy_gen.escape_text('say "hi"\\') == 'say \\"hi\\"\\\\'
|
||||
assert renpy_gen.escape_text("a\nb") == "a\\nb"
|
||||
|
||||
|
||||
def test_escaping_in_script(script):
|
||||
assert "¿qué pensáis [[ahora]?" in script
|
||||
assert "Es mi {{anhelo} preferente" in script
|
||||
assert 'lo \\"mejor\\" que pueda.' in script
|
||||
|
||||
|
||||
def test_title_card_and_end(script):
|
||||
block = scene_block(script, "talk")
|
||||
assert 'show text "{size=60}CONVERSACIÓN{/size}" as title_card at truecenter' in block
|
||||
assert "with fade" in block
|
||||
assert "scene bg theatre at tint_none" in block
|
||||
assert script.rstrip().endswith("return")
|
||||
assert "Continuará…" in script
|
||||
|
||||
|
||||
def test_nvl_pages_per_stanza(script):
|
||||
block = scene_block(script, "lyric")
|
||||
says = say_lines(block)
|
||||
# 9-line stanza -> pages of 8 and 1, then the 2-line second stanza
|
||||
assert [s.count("\\n") + 1 for s in says] == [8, 1, 2]
|
||||
assert all(s.startswith("c_poet_voice_nvl ") for s in says)
|
||||
assert block.count("nvl clear") == 3
|
||||
assert block[-2:] == ["nvl hide dissolve", ""]
|
||||
assert not any(ln.startswith("show ") and "vn_" in ln for ln in block)
|
||||
|
||||
|
||||
def test_adv_grouping(script):
|
||||
says = say_lines(scene_block(script, "talk"))
|
||||
# director's 6 verse lines -> 4 + 2
|
||||
assert says[0].count("\\n") == 3
|
||||
assert says[1].count("\\n") == 1
|
||||
assert says[0].startswith("c_director ")
|
||||
# split lines (indent >= 6) get their own boxes
|
||||
assert says[2] == 'c_poet "¡Vete, profano!"'
|
||||
assert says[3] == 'c_director "Calla, que oye."'
|
||||
# stage direction: narrator, own box
|
||||
assert says[4] == 'c_narrator "Se aleja."'
|
||||
# poet's 3 lines in one box
|
||||
assert says[5].count("\\n") == 2
|
||||
|
||||
|
||||
def test_cue_forces_box_break_and_emits_before_line(script):
|
||||
block = scene_block(script, "talk")
|
||||
cue_start = block.index("# talk_0014 .. talk_0015")
|
||||
prefix = block[:cue_start]
|
||||
# cue 1: slow bg change with dark tint and sprites hidden, before the Lord's lines
|
||||
assert "show bg heaven at tint_dark" in prefix
|
||||
assert prefix[prefix.index("show bg heaven at tint_dark") + 1] == "with vn_slow"
|
||||
assert "hide poet" in prefix[-6:]
|
||||
# Poet's box ended before the cue (box break at cue line)
|
||||
assert any("y el ocaso llega." in ln for ln in prefix)
|
||||
|
||||
|
||||
def test_mode_switch_and_flash_shake(script):
|
||||
block = scene_block(script, "talk")
|
||||
i_nvl = block.index("# talk_0016")
|
||||
# nvl cue at 0016: sprites hidden (nothing changes the bg), director spoke in nvl mode
|
||||
assert block[i_nvl + 1].startswith("c_director_nvl ")
|
||||
assert "nvl clear" in block[i_nvl:]
|
||||
# lyric voice lines in nvl are grouped into one page
|
||||
pages = [ln for ln in block if ln.startswith("c_poet_voice_nvl")]
|
||||
assert pages == ['c_poet_voice_nvl "Callan los pájaros;\\nla noche cae."']
|
||||
# cue 3: leave nvl, flash + shake, tint reset
|
||||
i_cue = block.index("# talk_0019")
|
||||
assert block[i_cue - 4 : i_cue] == [
|
||||
"nvl hide dissolve",
|
||||
"show bg theatre at tint_none",
|
||||
"with vn_flash",
|
||||
"show layer master at vn_shake",
|
||||
]
|
||||
|
||||
|
||||
def test_expression_mapping(script):
|
||||
block = scene_block(script, "talk")
|
||||
# first line of the first box is joyful -> director "pleased"
|
||||
assert "show director pleased at vn_left" in block
|
||||
# poet angry -> indignant (split box); director stays pleased/neutral as per his own lines
|
||||
assert "show poet indignant at vn_right" in block
|
||||
# poet melancholic -> neutral
|
||||
assert "show poet neutral at vn_right" in block
|
||||
|
||||
|
||||
def test_stable_positions(script):
|
||||
block = scene_block(script, "talk")
|
||||
shows = [ln for ln in block if ln.startswith("show poet ")]
|
||||
assert shows and all(ln.endswith("at vn_right") for ln in shows)
|
||||
assert not any("vn_center" in ln for ln in block) # annotated centre was never used
|
||||
|
||||
|
||||
def test_sprite_false_never_shown(script):
|
||||
assert "show lord" not in script
|
||||
assert "show poet_voice" not in script
|
||||
assert "c_lord " in script # still speaks, with name and colour
|
||||
|
||||
|
||||
def test_characters_and_images(project):
|
||||
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_nvl = Character("El Director", kind=nvl' in chars
|
||||
assert "define c_narrator = Character(None, what_color=" 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"))
|
||||
assert "None" in nameless_nvl and "nvl_thought" in nameless_nvl
|
||||
images = (project / "game/images.rpy").read_text(encoding="utf-8")
|
||||
assert 'image bg dedication = "images/bg/dedication.webp"' in images
|
||||
assert 'image director pleased = "images/sprites/director_pleased.webp"' in images
|
||||
assert (project / "game/images/sprites/poet_indignant.webp").is_file()
|
||||
assert (project / "game/images/bg/theatre.webp").is_file()
|
||||
assert not (project / "game/images/sprites/lord_neutral.webp").exists()
|
||||
|
||||
|
||||
def test_options_substitution(project):
|
||||
options = (project / "game/options.rpy").read_text(encoding="utf-8")
|
||||
assert 'config.name = _("Mini")' in options
|
||||
assert 'build.name = "mini-vn"' in options
|
||||
assert "@@" not in options
|
||||
gui = (project / "game/gui.rpy").read_text(encoding="utf-8")
|
||||
assert 'gui.main_menu_background = "bg dedication"' in gui
|
||||
assert (project / "game/gui/textbox.png").is_file()
|
||||
assert (project / "game/fonts/RobotoSlab-Regular.ttf").is_file()
|
||||
|
||||
|
||||
def test_music_only_when_audio_exists(work, annotated, tmp_path):
|
||||
out = tmp_path / "p"
|
||||
renpy_gen.generate(work, annotated, out)
|
||||
assert "play music" not in (out / "game/script.rpy").read_text(encoding="utf-8")
|
||||
(out / "game/audio").mkdir()
|
||||
(out / "game/audio/sacred.ogg").write_bytes(b"OggS")
|
||||
renpy_gen.generate(work, annotated, out)
|
||||
text = (out / "game/script.rpy").read_text(encoding="utf-8")
|
||||
assert 'play music "audio/sacred.ogg" fadeout 1.0 fadein 1.0' in text
|
||||
assert "stop music fadeout 1.0" in text # mood "none" on the Lord's first line
|
||||
assert (out / "game/audio/sacred.ogg").is_file() # regeneration keeps user audio
|
||||
|
||||
|
||||
def test_unknown_cue_target_fails(work, annotated):
|
||||
broken = json.loads(json.dumps(annotated))
|
||||
broken["scenes"][1]["lines"] = broken["scenes"][1]["lines"][:5]
|
||||
with pytest.raises(ValueError, match="unknown line ids"):
|
||||
renpy_gen.render_script(work, broken, set())
|
||||
|
||||
|
||||
def test_unknown_speaker_fails(work, annotated):
|
||||
broken = json.loads(json.dumps(annotated))
|
||||
broken["scenes"][1]["lines"][1]["ann"]["speaker"] = "ghost"
|
||||
with pytest.raises(ValueError, match="ghost"):
|
||||
renpy_gen.render_script(work, broken, set())
|
||||
|
||||
|
||||
def tree(root: Path) -> dict[str, bytes]:
|
||||
return {
|
||||
str(p.relative_to(root)): p.read_bytes() for p in sorted(root.rglob("*")) if p.is_file()
|
||||
}
|
||||
|
||||
|
||||
def test_deterministic(work, annotated, tmp_path):
|
||||
a, b = tmp_path / "a", tmp_path / "b"
|
||||
renpy_gen.generate(work, annotated, a)
|
||||
renpy_gen.generate(work, annotated, b)
|
||||
renpy_gen.generate(work, annotated, b) # regenerating over an existing tree
|
||||
assert tree(a) == tree(b)
|
||||
|
||||
|
||||
def test_from_parsed_annotations():
|
||||
work = load_work(ROOT / "works/faust")
|
||||
parsed = json.loads((ROOT / "works/faust/data/parsed.json").read_text(encoding="utf-8"))
|
||||
annotated = renpy_gen.annotations_from_parsed(work, parsed)
|
||||
validate(annotated, "annotated")
|
||||
teatro = next(s for s in annotated["scenes"] if s["id"] == "prologo_teatro")
|
||||
stage = [ln["ann"]["on_stage"] for ln in teatro["lines"] if ln["kind"] == "verse"]
|
||||
assert stage[0] == [{"character": "director", "position": "left"}]
|
||||
assert {e["character"]: e["position"] for e in stage[-1]} == {
|
||||
"director": "left",
|
||||
"poet": "right",
|
||||
"clown": "center",
|
||||
}
|
||||
dedication = annotated["scenes"][0]["lines"][0]["ann"]
|
||||
assert dedication["speaker"] == "poet_voice" and dedication["on_stage"] == []
|
||||
cielo = next(s for s in annotated["scenes"] if s["id"] == "prologo_cielo")
|
||||
assert cielo["lines"][0]["ann"]["on_stage"] == []
|
||||
# the real project generates (cues all resolve) without writing anything
|
||||
renpy_gen.render_script(work, annotated, set())
|
||||
|
||||
|
||||
@pytest.mark.skipif(not SDK.exists(), reason="Ren'Py SDK not installed in tools/renpy-sdk")
|
||||
def test_renpy_lint(work, annotated, tmp_path):
|
||||
out = tmp_path / "mini"
|
||||
renpy_gen.generate(work, annotated, out)
|
||||
env = {**os.environ, "HOME": str(tmp_path / "home")}
|
||||
(tmp_path / "home").mkdir()
|
||||
result = subprocess.run(
|
||||
[str(SDK), str(out), "lint"], capture_output=True, text=True, env=env, timeout=300
|
||||
)
|
||||
report = result.stdout + result.stderr
|
||||
assert result.returncode == 0, report
|
||||
assert "Traceback" not in report and "error" not in report.lower(), report
|
||||