diff --git a/.gitignore b/.gitignore index f2f6f80..7b32a3b 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/docs/running.md b/docs/running.md new file mode 100644 index 0000000..7b42d9c --- /dev/null +++ b/docs/running.md @@ -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 , `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/ +``` + +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/.ogg`, so drop files there and regenerate. + +Images come from `works//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). diff --git a/src/vnpipe/renpy_gen.py b/src/vnpipe/renpy_gen.py new file mode 100644 index 0000000..3d1c40b --- /dev/null +++ b/src/vnpipe/renpy_gen.py @@ -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/)") + parser.set_defaults(handler=cmd_renpy) diff --git a/src/vnpipe/renpy_templates/game/fonts/RobotoSlab-Bold.ttf b/src/vnpipe/renpy_templates/game/fonts/RobotoSlab-Bold.ttf new file mode 100644 index 0000000..df5d1df Binary files /dev/null and b/src/vnpipe/renpy_templates/game/fonts/RobotoSlab-Bold.ttf differ diff --git a/src/vnpipe/renpy_templates/game/fonts/RobotoSlab-Regular.ttf b/src/vnpipe/renpy_templates/game/fonts/RobotoSlab-Regular.ttf new file mode 100644 index 0000000..eb52a79 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/fonts/RobotoSlab-Regular.ttf differ diff --git a/src/vnpipe/renpy_templates/game/gui.rpy b/src/vnpipe/renpy_templates/game/gui.rpy new file mode 100644 index 0000000..95e08eb --- /dev/null +++ b/src/vnpipe/renpy_templates/game/gui.rpy @@ -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 diff --git a/src/vnpipe/renpy_templates/game/gui/bubble.png b/src/vnpipe/renpy_templates/game/gui/bubble.png new file mode 100644 index 0000000..3b23ff3 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/bubble.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/button/choice_hover_background.png b/src/vnpipe/renpy_templates/game/gui/button/choice_hover_background.png new file mode 100644 index 0000000..d2cdd41 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/button/choice_hover_background.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/button/choice_idle_background.png b/src/vnpipe/renpy_templates/game/gui/button/choice_idle_background.png new file mode 100644 index 0000000..1570796 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/button/choice_idle_background.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/button/quick_hover_background.png b/src/vnpipe/renpy_templates/game/gui/button/quick_hover_background.png new file mode 100644 index 0000000..0ecc7c9 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/button/quick_hover_background.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/button/quick_idle_background.png b/src/vnpipe/renpy_templates/game/gui/button/quick_idle_background.png new file mode 100644 index 0000000..0ecc7c9 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/button/quick_idle_background.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/frame.png b/src/vnpipe/renpy_templates/game/gui/frame.png new file mode 100644 index 0000000..4a8851d Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/frame.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/game_menu.png b/src/vnpipe/renpy_templates/game/gui/game_menu.png new file mode 100644 index 0000000..ffbba15 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/game_menu.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/main_menu.png b/src/vnpipe/renpy_templates/game/gui/main_menu.png new file mode 100644 index 0000000..ffbba15 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/main_menu.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/namebox.png b/src/vnpipe/renpy_templates/game/gui/namebox.png new file mode 100644 index 0000000..c24135c Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/namebox.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/notify.png b/src/vnpipe/renpy_templates/game/gui/notify.png new file mode 100644 index 0000000..c27b714 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/notify.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/nvl.png b/src/vnpipe/renpy_templates/game/gui/nvl.png new file mode 100644 index 0000000..5e55ec8 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/nvl.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/overlay/confirm.png b/src/vnpipe/renpy_templates/game/gui/overlay/confirm.png new file mode 100644 index 0000000..b95c47c Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/overlay/confirm.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/overlay/game_menu.png b/src/vnpipe/renpy_templates/game/gui/overlay/game_menu.png new file mode 100644 index 0000000..5c588b7 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/overlay/game_menu.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/overlay/main_menu.png b/src/vnpipe/renpy_templates/game/gui/overlay/main_menu.png new file mode 100644 index 0000000..e56f58e Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/overlay/main_menu.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/phone/button/choice_hover_background.png b/src/vnpipe/renpy_templates/game/gui/phone/button/choice_hover_background.png new file mode 100644 index 0000000..d2cdd41 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/phone/button/choice_hover_background.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/phone/button/choice_idle_background.png b/src/vnpipe/renpy_templates/game/gui/phone/button/choice_idle_background.png new file mode 100644 index 0000000..1570796 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/phone/button/choice_idle_background.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/phone/nvl.png b/src/vnpipe/renpy_templates/game/gui/phone/nvl.png new file mode 100644 index 0000000..51d2c7b Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/phone/nvl.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/phone/overlay/game_menu.png b/src/vnpipe/renpy_templates/game/gui/phone/overlay/game_menu.png new file mode 100644 index 0000000..564cff0 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/phone/overlay/game_menu.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/phone/overlay/main_menu.png b/src/vnpipe/renpy_templates/game/gui/phone/overlay/main_menu.png new file mode 100644 index 0000000..a599090 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/phone/overlay/main_menu.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/phone/textbox.png b/src/vnpipe/renpy_templates/game/gui/phone/textbox.png new file mode 100644 index 0000000..2321b23 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/phone/textbox.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/skip.png b/src/vnpipe/renpy_templates/game/gui/skip.png new file mode 100644 index 0000000..2f529ac Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/skip.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/textbox.png b/src/vnpipe/renpy_templates/game/gui/textbox.png new file mode 100644 index 0000000..9374b64 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/textbox.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/thoughtbubble.png b/src/vnpipe/renpy_templates/game/gui/thoughtbubble.png new file mode 100644 index 0000000..8d5d44b Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/thoughtbubble.png differ diff --git a/src/vnpipe/renpy_templates/game/gui/window_icon.png b/src/vnpipe/renpy_templates/game/gui/window_icon.png new file mode 100644 index 0000000..64b4326 Binary files /dev/null and b/src/vnpipe/renpy_templates/game/gui/window_icon.png differ diff --git a/src/vnpipe/renpy_templates/game/options.rpy b/src/vnpipe/renpy_templates/game/options.rpy new file mode 100644 index 0000000..8d12ee3 --- /dev/null +++ b/src/vnpipe/renpy_templates/game/options.rpy @@ -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\ +## +## Macintosh: $HOME/Library/RenPy/ +## +## Linux: $HOME/.renpy/ +## +## 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" diff --git a/src/vnpipe/renpy_templates/game/screens.rpy b/src/vnpipe/renpy_templates/game/screens.rpy new file mode 100644 index 0000000..d601f80 --- /dev/null +++ b/src/vnpipe/renpy_templates/game/screens.rpy @@ -0,0 +1,1621 @@ +################################################################################ +## Initialization +################################################################################ + +init offset = -1 + + +################################################################################ +## Styles +################################################################################ + +style default: + properties gui.text_properties() + language gui.language + +style input: + properties gui.text_properties("input", accent=True) + adjust_spacing False + +style hyperlink_text: + properties gui.text_properties("hyperlink", accent=True) + hover_underline True + +style gui_text: + properties gui.text_properties("interface") + + +style button: + properties gui.button_properties("button") + +style button_text is gui_text: + properties gui.text_properties("button") + yalign 0.5 + + +style label_text is gui_text: + properties gui.text_properties("label", accent=True) + +style prompt_text is gui_text: + properties gui.text_properties("prompt") + + +style bar: + ysize gui.bar_size + left_bar Frame("gui/bar/left.png", gui.bar_borders, tile=gui.bar_tile) + right_bar Frame("gui/bar/right.png", gui.bar_borders, tile=gui.bar_tile) + +style vbar: + xsize gui.bar_size + top_bar Frame("gui/bar/top.png", gui.vbar_borders, tile=gui.bar_tile) + bottom_bar Frame("gui/bar/bottom.png", gui.vbar_borders, tile=gui.bar_tile) + +style scrollbar: + ysize gui.scrollbar_size + base_bar Frame("gui/scrollbar/horizontal_[prefix_]bar.png", gui.scrollbar_borders, tile=gui.scrollbar_tile) + thumb Frame("gui/scrollbar/horizontal_[prefix_]thumb.png", gui.scrollbar_borders, tile=gui.scrollbar_tile) + +style vscrollbar: + xsize gui.scrollbar_size + base_bar Frame("gui/scrollbar/vertical_[prefix_]bar.png", gui.vscrollbar_borders, tile=gui.scrollbar_tile) + thumb Frame("gui/scrollbar/vertical_[prefix_]thumb.png", gui.vscrollbar_borders, tile=gui.scrollbar_tile) + +style slider: + ysize gui.slider_size + base_bar Frame("gui/slider/horizontal_[prefix_]bar.png", gui.slider_borders, tile=gui.slider_tile) + thumb "gui/slider/horizontal_[prefix_]thumb.png" + +style vslider: + xsize gui.slider_size + base_bar Frame("gui/slider/vertical_[prefix_]bar.png", gui.vslider_borders, tile=gui.slider_tile) + thumb "gui/slider/vertical_[prefix_]thumb.png" + + +style frame: + padding gui.frame_borders.padding + background Frame("gui/frame.png", gui.frame_borders, tile=gui.frame_tile) + + + +################################################################################ +## In-game screens +################################################################################ + + +## Say screen ################################################################## +## +## The say screen is used to display dialogue to the player. It takes two +## parameters, who and what, which are the name of the speaking character and +## the text to be displayed, respectively. (The who parameter can be None if no +## name is given.) +## +## This screen must create a text displayable with id "what", as Ren'Py uses +## this to manage text display. It can also create displayables with id "who" +## and id "window" to apply style properties. +## +## https://www.renpy.org/doc/html/screen_special.html#say + +screen say(who, what): + + window: + id "window" + + if who is not None: + + window: + id "namebox" + style "namebox" + text who id "who" + + text what id "what" + + + ## If there's a side image, display it above the text. Do not display on the + ## phone variant - there's no room. + if not renpy.variant("small"): + add SideImage() xalign 0.0 yalign 1.0 + + +## Make the namebox available for styling through the Character object. +init python: + config.character_id_prefixes.append('namebox') + +style window is default +style say_label is default +style say_dialogue is default +style say_thought is say_dialogue + +style namebox is default +style namebox_label is say_label + + +style window: + xalign 0.5 + xfill True + yalign gui.textbox_yalign + ysize gui.textbox_height + + background Image("gui/textbox.png", xalign=0.5, yalign=1.0) + +style namebox: + xpos gui.name_xpos + xanchor gui.name_xalign + xsize gui.namebox_width + ypos gui.name_ypos + ysize gui.namebox_height + + background Frame("gui/namebox.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign) + padding gui.namebox_borders.padding + +style say_label: + properties gui.text_properties("name", accent=True) + xalign gui.name_xalign + yalign 0.5 + +style say_dialogue: + properties gui.text_properties("dialogue") + + xpos gui.dialogue_xpos + xsize gui.dialogue_width + ypos gui.dialogue_ypos + + adjust_spacing False + +## Input screen ################################################################ +## +## This screen is used to display renpy.input. The prompt parameter is used to +## pass a text prompt in. +## +## This screen must create an input displayable with id "input" to accept the +## various input parameters. +## +## https://www.renpy.org/doc/html/screen_special.html#input + +screen input(prompt): + style_prefix "input" + + window: + + vbox: + xanchor gui.dialogue_text_xalign + xpos gui.dialogue_xpos + xsize gui.dialogue_width + ypos gui.dialogue_ypos + + text prompt style "input_prompt" + input id "input" + +style input_prompt is default + +style input_prompt: + xalign gui.dialogue_text_xalign + properties gui.text_properties("input_prompt") + +style input: + xalign gui.dialogue_text_xalign + xmaximum gui.dialogue_width + + +## Choice screen ############################################################### +## +## This screen is used to display the in-game choices presented by the menu +## statement. The one parameter, items, is a list of objects, each with caption +## and action fields. +## +## https://www.renpy.org/doc/html/screen_special.html#choice + +screen choice(items): + style_prefix "choice" + + vbox: + for i in items: + textbutton i.caption action i.action + + +style choice_vbox is vbox +style choice_button is button +style choice_button_text is button_text + +style choice_vbox: + xalign 0.5 + ypos 405 + yanchor 0.5 + + spacing gui.choice_spacing + +style choice_button is default: + properties gui.button_properties("choice_button") + +style choice_button_text is default: + properties gui.text_properties("choice_button") + + +## Quick Menu screen ########################################################### +## +## The quick menu is displayed in-game to provide easy access to the out-of-game +## menus. + +screen quick_menu(): + + ## Ensure this appears on top of other screens. + zorder 100 + + if quick_menu: + + hbox: + style_prefix "quick" + style "quick_menu" + + textbutton _("Back") action Rollback() + textbutton _("History") action ShowMenu('history') + textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True) + textbutton _("Auto") action Preference("auto-forward", "toggle") + textbutton _("Save") action ShowMenu('save') + textbutton _("Q.Save") action QuickSave() + textbutton _("Q.Load") action QuickLoad() + textbutton _("Prefs") action ShowMenu('preferences') + + +## This code ensures that the quick_menu screen is displayed in-game, whenever +## the player has not explicitly hidden the interface. +init python: + config.overlay_screens.append("quick_menu") + +default quick_menu = True + +style quick_menu is hbox +style quick_button is default +style quick_button_text is button_text + +style quick_menu: + xalign 0.5 + yalign 1.0 + +style quick_button: + properties gui.button_properties("quick_button") + +style quick_button_text: + properties gui.text_properties("quick_button") + + +################################################################################ +## Main and Game Menu Screens +################################################################################ + +## Navigation screen ########################################################### +## +## This screen is included in the main and game menus, and provides navigation +## to other menus, and to start the game. + +screen navigation(): + + vbox: + style_prefix "navigation" + + xpos gui.navigation_xpos + yalign 0.5 + + spacing gui.navigation_spacing + + if main_menu: + + textbutton _("Start") action Start() + + else: + + textbutton _("History") action ShowMenu("history") + + textbutton _("Save") action ShowMenu("save") + + textbutton _("Load") action ShowMenu("load") + + textbutton _("Preferences") action ShowMenu("preferences") + + if _in_replay: + + textbutton _("End Replay") action EndReplay(confirm=True) + + elif not main_menu: + + textbutton _("Main Menu") action MainMenu() + + textbutton _("About") action ShowMenu("about") + + if renpy.variant("pc") or (renpy.variant("web") and not renpy.variant("mobile")): + + ## Help isn't necessary or relevant to mobile devices. + textbutton _("Help") action ShowMenu("help") + + if renpy.variant("pc"): + + ## The quit button is banned on iOS and unnecessary on Android and + ## Web. + textbutton _("Quit") action Quit(confirm=not main_menu) + + +style navigation_button is gui_button +style navigation_button_text is gui_button_text + +style navigation_button: + size_group "navigation" + properties gui.button_properties("navigation_button") + +style navigation_button_text: + properties gui.text_properties("navigation_button") + + +## Main Menu screen ############################################################ +## +## Used to display the main menu when Ren'Py starts. +## +## https://www.renpy.org/doc/html/screen_special.html#main-menu + +screen main_menu(): + + ## This ensures that any other menu screen is replaced. + tag menu + + add gui.main_menu_background + + ## This empty frame darkens the main menu. + frame: + style "main_menu_frame" + + ## The use statement includes another screen inside this one. The actual + ## contents of the main menu are in the navigation screen. + use navigation + + if gui.show_name: + + vbox: + style "main_menu_vbox" + + text "[config.name!t]": + style "main_menu_title" + + text "[config.version]": + style "main_menu_version" + + +style main_menu_frame is empty +style main_menu_vbox is vbox +style main_menu_text is gui_text +style main_menu_title is main_menu_text +style main_menu_version is main_menu_text + +style main_menu_frame: + xsize 420 + yfill True + + background "gui/overlay/main_menu.png" + +style main_menu_vbox: + xalign 1.0 + xoffset -30 + xmaximum 1200 + yalign 1.0 + yoffset -30 + +style main_menu_text: + properties gui.text_properties("main_menu", accent=True) + +style main_menu_title: + properties gui.text_properties("title") + +style main_menu_version: + properties gui.text_properties("version") + + +## Game Menu screen ############################################################ +## +## This lays out the basic common structure of a game menu screen. It's called +## with the screen title, and displays the background, title, and navigation. +## +## The scroll parameter can be None, or one of "viewport" or "vpgrid". +## This screen is intended to be used with one or more children, which are +## transcluded (placed) inside it. + +screen game_menu(title, scroll=None, yinitial=0.0, spacing=0): + + style_prefix "game_menu" + + if main_menu: + add gui.main_menu_background + else: + add gui.game_menu_background + + frame: + style "game_menu_outer_frame" + + hbox: + + ## Reserve space for the navigation section. + frame: + style "game_menu_navigation_frame" + + frame: + style "game_menu_content_frame" + + if scroll == "viewport": + + viewport: + yinitial yinitial + scrollbars "vertical" + mousewheel True + draggable True + pagekeys True + + side_yfill True + + vbox: + spacing spacing + + transclude + + elif scroll == "vpgrid": + + vpgrid: + cols 1 + yinitial yinitial + + scrollbars "vertical" + mousewheel True + draggable True + pagekeys True + + side_yfill True + + spacing spacing + + transclude + + else: + + transclude + + use navigation + + textbutton _("Return"): + style "return_button" + + action Return() + + label title + + if main_menu: + key "game_menu" action ShowMenu("main_menu") + + +style game_menu_outer_frame is empty +style game_menu_navigation_frame is empty +style game_menu_content_frame is empty +style game_menu_viewport is gui_viewport +style game_menu_side is gui_side +style game_menu_scrollbar is gui_vscrollbar + +style game_menu_label is gui_label +style game_menu_label_text is gui_label_text + +style return_button is navigation_button +style return_button_text is navigation_button_text + +style game_menu_outer_frame: + bottom_padding 45 + top_padding 180 + + background "gui/overlay/game_menu.png" + +style game_menu_navigation_frame: + xsize 420 + yfill True + +style game_menu_content_frame: + left_margin 60 + right_margin 30 + top_margin 15 + +style game_menu_viewport: + xsize 1380 + +style game_menu_vscrollbar: + unscrollable gui.unscrollable + +style game_menu_side: + spacing 15 + +style game_menu_label: + xpos 75 + ysize 180 + +style game_menu_label_text: + size 75 + color gui.accent_color + yalign 0.5 + +style return_button: + xpos gui.navigation_xpos + yalign 1.0 + yoffset -45 + + +## About screen ################################################################ +## +## This screen gives credit and copyright information about the game and Ren'Py. +## +## There's nothing special about this screen, and hence it also serves as an +## example of how to make a custom screen. + +screen about(): + + tag menu + + ## This use statement includes the game_menu screen inside this one. The + ## vbox child is then included inside the viewport inside the game_menu + ## screen. + use game_menu(_("About"), scroll="viewport"): + + style_prefix "about" + + vbox: + + label "[config.name!t]" + text _("Version [config.version!t]\n") + + ## gui.about is usually set in options.rpy. + if gui.about: + text "[gui.about!t]\n" + + text _("Made with {a=https://www.renpy.org/}Ren'Py{/a} [renpy.version_only].\n\n[renpy.license!t]") + + +style about_label is gui_label +style about_label_text is gui_label_text +style about_text is gui_text + +style about_label_text: + size gui.label_text_size + + +## Load and Save screens ####################################################### +## +## These screens are responsible for letting the player save the game and load +## it again. Since they share nearly everything in common, both are implemented +## in terms of a third screen, file_slots. +## +## https://www.renpy.org/doc/html/screen_special.html#save https:// +## www.renpy.org/doc/html/screen_special.html#load + +screen save(): + + tag menu + + use file_slots(_("Save")) + + +screen load(): + + tag menu + + use file_slots(_("Load")) + + +screen file_slots(title): + + default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves")) + + use game_menu(title): + + fixed: + + ## This ensures the input will get the enter event before any of the + ## buttons do. + order_reverse True + + ## The page name, which can be edited by clicking on a button. + button: + style "page_label" + + key_events True + xalign 0.5 + action page_name_value.Toggle() + + input: + style "page_label_text" + value page_name_value + + ## The grid of file slots. + grid gui.file_slot_cols gui.file_slot_rows: + style_prefix "slot" + + xalign 0.5 + yalign 0.5 + + spacing gui.slot_spacing + + for i in range(gui.file_slot_cols * gui.file_slot_rows): + + $ slot = i + 1 + + button: + action FileAction(slot) + + has vbox + + add FileScreenshot(slot) xalign 0.5 + + text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")): + style "slot_time_text" + + text FileSaveName(slot): + style "slot_name_text" + + key "save_delete" action FileDelete(slot) + + ## Buttons to access other pages. + vbox: + style_prefix "page" + + xalign 0.5 + yalign 1.0 + + hbox: + xalign 0.5 + + spacing gui.page_spacing + + textbutton _("<") action FilePagePrevious() + key "save_page_prev" action FilePagePrevious() + + if config.has_autosave: + textbutton _("{#auto_page}A") action FilePage("auto") + + if config.has_quicksave: + textbutton _("{#quick_page}Q") action FilePage("quick") + + ## range(1, 10) gives the numbers from 1 to 9. + for page in range(1, 10): + textbutton "[page]" action FilePage(page) + + textbutton _(">") action FilePageNext() + key "save_page_next" action FilePageNext() + + if config.has_sync: + if CurrentScreenName() == "save": + textbutton _("Upload Sync"): + action UploadSync() + xalign 0.5 + else: + textbutton _("Download Sync"): + action DownloadSync() + xalign 0.5 + + +style page_label is gui_label +style page_label_text is gui_label_text +style page_button is gui_button +style page_button_text is gui_button_text + +style slot_button is gui_button +style slot_button_text is gui_button_text +style slot_time_text is slot_button_text +style slot_name_text is slot_button_text + +style page_label: + xpadding 75 + ypadding 5 + xalign 0.5 + +style page_label_text: + textalign 0.5 + layout "subtitle" + hover_color gui.hover_color + +style page_button: + properties gui.button_properties("page_button") + +style page_button_text: + properties gui.text_properties("page_button") + +style slot_button: + properties gui.button_properties("slot_button") + +style slot_button_text: + properties gui.text_properties("slot_button") + + +## Preferences screen ########################################################## +## +## The preferences screen allows the player to configure the game to better suit +## themselves. +## +## https://www.renpy.org/doc/html/screen_special.html#preferences + +screen preferences(): + + tag menu + + use game_menu(_("Preferences"), scroll="viewport"): + + vbox: + + hbox: + box_wrap True + + if renpy.variant("pc") or renpy.variant("web"): + + vbox: + style_prefix "radio" + label _("Display") + textbutton _("Window") action Preference("display", "window") + textbutton _("Fullscreen") action Preference("display", "fullscreen") + + vbox: + style_prefix "check" + label _("Skip") + textbutton _("Unseen Text") action Preference("skip", "toggle") + textbutton _("After Choices") action Preference("after choices", "toggle") + textbutton _("Transitions") action InvertSelected(Preference("transitions", "toggle")) + + ## Additional vboxes of type "radio_pref" or "check_pref" can be + ## added here, to add additional creator-defined preferences. + + null height (4 * gui.pref_spacing) + + hbox: + style_prefix "slider" + box_wrap True + + vbox: + + label _("Text Speed") + + bar value Preference("text speed") + + label _("Auto-Forward Time") + + bar value Preference("auto-forward time") + + vbox: + + if config.has_music: + label _("Music Volume") + + hbox: + bar value Preference("music volume") + + if config.has_sound: + + label _("Sound Volume") + + hbox: + bar value Preference("sound volume") + + if config.sample_sound: + textbutton _("Test") action Play("sound", config.sample_sound) + + + if config.has_voice: + label _("Voice Volume") + + hbox: + bar value Preference("voice volume") + + if config.sample_voice: + textbutton _("Test") action Play("voice", config.sample_voice) + + if config.has_music or config.has_sound or config.has_voice: + null height gui.pref_spacing + + textbutton _("Mute All"): + action Preference("all mute", "toggle") + style "mute_all_button" + + +style pref_label is gui_label +style pref_label_text is gui_label_text +style pref_vbox is vbox + +style radio_label is pref_label +style radio_label_text is pref_label_text +style radio_button is gui_button +style radio_button_text is gui_button_text +style radio_vbox is pref_vbox + +style check_label is pref_label +style check_label_text is pref_label_text +style check_button is gui_button +style check_button_text is gui_button_text +style check_vbox is pref_vbox + +style slider_label is pref_label +style slider_label_text is pref_label_text +style slider_slider is gui_slider +style slider_button is gui_button +style slider_button_text is gui_button_text +style slider_pref_vbox is pref_vbox + +style mute_all_button is check_button +style mute_all_button_text is check_button_text + +style pref_label: + top_margin gui.pref_spacing + bottom_margin 3 + +style pref_label_text: + yalign 1.0 + +style pref_vbox: + xsize 338 + +style radio_vbox: + spacing gui.pref_button_spacing + +style radio_button: + properties gui.button_properties("radio_button") + foreground "gui/button/radio_[prefix_]foreground.png" + +style radio_button_text: + properties gui.text_properties("radio_button") + +style check_vbox: + spacing gui.pref_button_spacing + +style check_button: + properties gui.button_properties("check_button") + foreground "gui/button/check_[prefix_]foreground.png" + +style check_button_text: + properties gui.text_properties("check_button") + +style slider_slider: + xsize 525 + +style slider_button: + properties gui.button_properties("slider_button") + yalign 0.5 + left_margin 15 + +style slider_button_text: + properties gui.text_properties("slider_button") + +style slider_vbox: + xsize 675 + + +## History screen ############################################################## +## +## This is a screen that displays the dialogue history to the player. While +## there isn't anything special about this screen, it does have to access the +## dialogue history stored in _history_list. +## +## https://www.renpy.org/doc/html/history.html + +screen history(): + + tag menu + + ## Avoid predicting this screen, as it can be very large. + predict False + + use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0, spacing=gui.history_spacing): + + style_prefix "history" + + for h in _history_list: + + window: + + ## This lays things out properly if history_height is None. + has fixed: + yfit True + + if h.who: + + label h.who: + style "history_name" + substitute False + + ## Take the color of the who text from the Character, if + ## set. + if "color" in h.who_args: + text_color h.who_args["color"] + + $ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags) + text what: + substitute False + + if not _history_list: + label _("The dialogue history is empty.") + + +## This determines what tags are allowed to be displayed on the history screen. + +define gui.history_allow_tags = { "alt", "noalt", "rt", "rb", "art" } + + +style history_window is empty + +style history_name is gui_label +style history_name_text is gui_label_text +style history_text is gui_text + +style history_label is gui_label +style history_label_text is gui_label_text + +style history_window: + xfill True + ysize gui.history_height + +style history_name: + xpos gui.history_name_xpos + xanchor gui.history_name_xalign + ypos gui.history_name_ypos + xsize gui.history_name_width + +style history_name_text: + min_width gui.history_name_width + textalign gui.history_name_xalign + +style history_text: + xpos gui.history_text_xpos + ypos gui.history_text_ypos + xanchor gui.history_text_xalign + xsize gui.history_text_width + min_width gui.history_text_width + textalign gui.history_text_xalign + layout ("subtitle" if gui.history_text_xalign else "tex") + +style history_label: + xfill True + +style history_label_text: + xalign 0.5 + + +## Help screen ################################################################# +## +## A screen that gives information about key and mouse bindings. It uses other +## screens (keyboard_help, mouse_help, and gamepad_help) to display the actual +## help. + +screen help(): + + tag menu + + default device = "keyboard" + + use game_menu(_("Help"), scroll="viewport"): + + style_prefix "help" + + vbox: + spacing 23 + + hbox: + + textbutton _("Keyboard") action SetScreenVariable("device", "keyboard") + textbutton _("Mouse") action SetScreenVariable("device", "mouse") + + if GamepadExists(): + textbutton _("Gamepad") action SetScreenVariable("device", "gamepad") + + if device == "keyboard": + use keyboard_help + elif device == "mouse": + use mouse_help + elif device == "gamepad": + use gamepad_help + + +screen keyboard_help(): + + hbox: + label _("Enter") + text _("Advances dialogue and activates the interface.") + + hbox: + label _("Space") + text _("Advances dialogue without selecting choices.") + + hbox: + label _("Arrow Keys") + text _("Navigate the interface.") + + hbox: + label _("Escape") + text _("Accesses the game menu.") + + hbox: + label _("Ctrl") + text _("Skips dialogue while held down.") + + hbox: + label _("Tab") + text _("Toggles dialogue skipping.") + + hbox: + label _("Page Up") + text _("Rolls back to earlier dialogue.") + + hbox: + label _("Page Down") + text _("Rolls forward to later dialogue.") + + hbox: + label "H" + text _("Hides the user interface.") + + hbox: + label "S" + text _("Takes a screenshot.") + + hbox: + label "V" + text _("Toggles assistive {a=https://www.renpy.org/l/voicing}self-voicing{/a}.") + + hbox: + label "Shift+A" + text _("Opens the accessibility menu.") + + +screen mouse_help(): + + hbox: + label _("Left Click") + text _("Advances dialogue and activates the interface.") + + hbox: + label _("Middle Click") + text _("Hides the user interface.") + + hbox: + label _("Right Click") + text _("Accesses the game menu.") + + hbox: + label _("Mouse Wheel Up") + text _("Rolls back to earlier dialogue.") + + hbox: + label _("Mouse Wheel Down") + text _("Rolls forward to later dialogue.") + + +screen gamepad_help(): + + hbox: + label _("Right Trigger\nA/Bottom Button") + text _("Advances dialogue and activates the interface.") + + hbox: + label _("Left Trigger\nLeft Shoulder") + text _("Rolls back to earlier dialogue.") + + hbox: + label _("Right Shoulder") + text _("Rolls forward to later dialogue.") + + hbox: + label _("D-Pad, Sticks") + text _("Navigate the interface.") + + hbox: + label _("Start, Guide, B/Right Button") + text _("Accesses the game menu.") + + hbox: + label _("Y/Top Button") + text _("Hides the user interface.") + + textbutton _("Calibrate") action GamepadCalibrate() + + +style help_button is gui_button +style help_button_text is gui_button_text +style help_label is gui_label +style help_label_text is gui_label_text +style help_text is gui_text + +style help_button: + properties gui.button_properties("help_button") + xmargin 12 + +style help_button_text: + properties gui.text_properties("help_button") + +style help_label: + xsize 375 + right_padding 30 + +style help_label_text: + size gui.text_size + xalign 1.0 + textalign 1.0 + + + +################################################################################ +## Additional screens +################################################################################ + + +## Confirm screen ############################################################## +## +## The confirm screen is called when Ren'Py wants to ask the player a yes or no +## question. +## +## https://www.renpy.org/doc/html/screen_special.html#confirm + +screen confirm(message, yes_action, no_action): + + ## Ensure other screens do not get input while this screen is displayed. + modal True + + zorder 200 + + style_prefix "confirm" + + add "gui/overlay/confirm.png" + + frame: + + vbox: + xalign .5 + yalign .5 + spacing 45 + + label _(message): + style "confirm_prompt" + xalign 0.5 + + hbox: + xalign 0.5 + spacing 150 + + textbutton _("Yes") action yes_action + textbutton _("No") action no_action + + ## Right-click and escape answer "no". + key "game_menu" action no_action + + +style confirm_frame is gui_frame +style confirm_prompt is gui_prompt +style confirm_prompt_text is gui_prompt_text +style confirm_button is gui_medium_button +style confirm_button_text is gui_medium_button_text + +style confirm_frame: + background Frame([ "gui/confirm_frame.png", "gui/frame.png"], gui.confirm_frame_borders, tile=gui.frame_tile) + padding gui.confirm_frame_borders.padding + xalign .5 + yalign .5 + +style confirm_prompt_text: + textalign 0.5 + layout "subtitle" + +style confirm_button: + properties gui.button_properties("confirm_button") + +style confirm_button_text: + properties gui.text_properties("confirm_button") + + +## Skip indicator screen ####################################################### +## +## The skip_indicator screen is displayed to indicate that skipping is in +## progress. +## +## https://www.renpy.org/doc/html/screen_special.html#skip-indicator + +screen skip_indicator(): + + zorder 100 + style_prefix "skip" + + frame: + + hbox: + spacing 9 + + text _("Skipping") + + text "▸" at delayed_blink(0.0, 1.0) style "skip_triangle" + text "▸" at delayed_blink(0.2, 1.0) style "skip_triangle" + text "▸" at delayed_blink(0.4, 1.0) style "skip_triangle" + + +## This transform is used to blink the arrows one after another. +transform delayed_blink(delay, cycle): + alpha .5 + + pause delay + + block: + linear .2 alpha 1.0 + pause .2 + linear .2 alpha 0.5 + pause (cycle - .4) + repeat + + +style skip_frame is empty +style skip_text is gui_text +style skip_triangle is skip_text + +style skip_frame: + ypos gui.skip_ypos + background Frame("gui/skip.png", gui.skip_frame_borders, tile=gui.frame_tile) + padding gui.skip_frame_borders.padding + +style skip_text: + size gui.notify_text_size + +style skip_triangle: + ## We have to use a font that has the BLACK RIGHT-POINTING SMALL TRIANGLE + ## glyph in it. + font "DejaVuSans.ttf" + + +## Notify screen ############################################################### +## +## The notify screen is used to show the player a message. (For example, when +## the game is quicksaved or a screenshot has been taken.) +## +## https://www.renpy.org/doc/html/screen_special.html#notify-screen + +screen notify(message): + + zorder 100 + style_prefix "notify" + + frame at notify_appear: + text "[message!tq]" + + timer 3.25 action Hide('notify') + + +transform notify_appear: + on show: + alpha 0 + linear .25 alpha 1.0 + on hide: + linear .5 alpha 0.0 + + +style notify_frame is empty +style notify_text is gui_text + +style notify_frame: + ypos gui.notify_ypos + + background Frame("gui/notify.png", gui.notify_frame_borders, tile=gui.frame_tile) + padding gui.notify_frame_borders.padding + +style notify_text: + properties gui.text_properties("notify") + + +## NVL screen ################################################################## +## +## This screen is used for NVL-mode dialogue and menus. +## +## https://www.renpy.org/doc/html/screen_special.html#nvl + + +screen nvl(dialogue, items=None): + + window: + style "nvl_window" + + has vbox: + spacing gui.nvl_spacing + + ## Displays dialogue in either a vpgrid or the vbox. + if gui.nvl_height: + + vpgrid: + cols 1 + yinitial 1.0 + + use nvl_dialogue(dialogue) + + else: + + use nvl_dialogue(dialogue) + + ## Displays the menu, if given. The menu may be displayed incorrectly if + ## config.narrator_menu is set to True. + for i in items: + + textbutton i.caption: + action i.action + style "nvl_button" + + add SideImage() xalign 0.0 yalign 1.0 + + +screen nvl_dialogue(dialogue): + + for d in dialogue: + + window: + id d.window_id + + fixed: + yfit gui.nvl_height is None + + if d.who is not None: + + text d.who: + id d.who_id + + text d.what: + id d.what_id + + +## This controls the maximum number of NVL-mode entries that can be displayed at +## once. +define config.nvl_list_length = gui.nvl_list_length + +style nvl_window is default +style nvl_entry is default + +style nvl_label is say_label +style nvl_dialogue is say_dialogue + +style nvl_button is button +style nvl_button_text is button_text + +style nvl_window: + xfill True + yfill True + + background "gui/nvl.png" + padding gui.nvl_borders.padding + +style nvl_entry: + xfill True + ysize gui.nvl_height + +style nvl_label: + xpos gui.nvl_name_xpos + xanchor gui.nvl_name_xalign + ypos gui.nvl_name_ypos + yanchor 0.0 + xsize gui.nvl_name_width + min_width gui.nvl_name_width + textalign gui.nvl_name_xalign + +style nvl_dialogue: + xpos gui.nvl_text_xpos + xanchor gui.nvl_text_xalign + ypos gui.nvl_text_ypos + xsize gui.nvl_text_width + min_width gui.nvl_text_width + textalign gui.nvl_text_xalign + layout ("subtitle" if gui.nvl_text_xalign else "tex") + +style nvl_thought is say_dialogue: + xpos gui.nvl_thought_xpos + xanchor gui.nvl_thought_xalign + ypos gui.nvl_thought_ypos + xsize gui.nvl_thought_width + min_width gui.nvl_thought_width + textalign gui.nvl_thought_xalign + layout ("subtitle" if gui.nvl_text_xalign else "tex") + +style nvl_button: + properties gui.button_properties("nvl_button") + xpos gui.nvl_button_xpos + xanchor gui.nvl_button_xalign + +style nvl_button_text: + properties gui.text_properties("nvl_button") + + +## Bubble screen ############################################################### +## +## The bubble screen is used to display dialogue to the player when using speech +## bubbles. The bubble screen takes the same parameters as the say screen, must +## create a displayable with the id of "what", and can create displayables with +## the "namebox", "who", and "window" ids. +## +## https://www.renpy.org/doc/html/bubble.html#bubble-screen + +screen bubble(who, what): + style_prefix "bubble" + + window: + id "window" + + if who is not None: + + window: + id "namebox" + style "bubble_namebox" + + text who: + id "who" + + text what: + id "what" + + default ctc = None + showif ctc: + add ctc + +style bubble_window is empty +style bubble_namebox is empty +style bubble_who is default +style bubble_what is default + +style bubble_window: + xpadding 30 + top_padding 5 + bottom_padding 5 + +style bubble_namebox: + xalign 0.5 + +style bubble_who: + xalign 0.5 + textalign 0.5 + color "#000" + +style bubble_what: + align (0.5, 0.5) + text_align 0.5 + layout "subtitle" + color "#000" + +define bubble.frame = Frame("gui/bubble.png", 55, 55, 55, 95) +define bubble.thoughtframe = Frame("gui/thoughtbubble.png", 55, 55, 55, 55) + +define bubble.properties = { + "bottom_left" : { + "window_background" : Transform(bubble.frame, xzoom=1, yzoom=1), + "window_bottom_padding" : 27, + }, + + "bottom_right" : { + "window_background" : Transform(bubble.frame, xzoom=-1, yzoom=1), + "window_bottom_padding" : 27, + }, + + "top_left" : { + "window_background" : Transform(bubble.frame, xzoom=1, yzoom=-1), + "window_top_padding" : 27, + }, + + "top_right" : { + "window_background" : Transform(bubble.frame, xzoom=-1, yzoom=-1), + "window_top_padding" : 27, + }, + + "thought" : { + "window_background" : bubble.thoughtframe, + } +} + +define bubble.expand_area = { + "bottom_left" : (0, 0, 0, 22), + "bottom_right" : (0, 0, 0, 22), + "top_left" : (0, 22, 0, 0), + "top_right" : (0, 22, 0, 0), + "thought" : (0, 0, 0, 0), +} + + + +################################################################################ +## Mobile Variants +################################################################################ + +style pref_vbox: + variant "medium" + xsize 675 + +## Since a mouse may not be present, we replace the quick menu with a version +## that uses fewer and bigger buttons that are easier to touch. +screen quick_menu(): + variant "touch" + + zorder 100 + + if quick_menu: + + hbox: + style "quick_menu" + style_prefix "quick" + + textbutton _("Back") action Rollback() + textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True) + textbutton _("Auto") action Preference("auto-forward", "toggle") + textbutton _("Menu") action ShowMenu() + + +style window: + variant "small" + background "gui/phone/textbox.png" + +style radio_button: + variant "small" + foreground "gui/phone/button/radio_[prefix_]foreground.png" + +style check_button: + variant "small" + foreground "gui/phone/button/check_[prefix_]foreground.png" + +style nvl_window: + variant "small" + background "gui/phone/nvl.png" + +style main_menu_frame: + variant "small" + background "gui/phone/overlay/main_menu.png" + +style game_menu_outer_frame: + variant "small" + background "gui/phone/overlay/game_menu.png" + +style game_menu_navigation_frame: + variant "small" + xsize 510 + +style game_menu_content_frame: + variant "small" + top_margin 0 + +style game_menu_viewport: + variant "small" + xsize 1305 + +style pref_vbox: + variant "small" + xsize 600 + +style bar: + variant "small" + ysize gui.bar_size + left_bar Frame("gui/phone/bar/left.png", gui.bar_borders, tile=gui.bar_tile) + right_bar Frame("gui/phone/bar/right.png", gui.bar_borders, tile=gui.bar_tile) + +style vbar: + variant "small" + xsize gui.bar_size + top_bar Frame("gui/phone/bar/top.png", gui.vbar_borders, tile=gui.bar_tile) + bottom_bar Frame("gui/phone/bar/bottom.png", gui.vbar_borders, tile=gui.bar_tile) + +style scrollbar: + variant "small" + ysize gui.scrollbar_size + base_bar Frame("gui/phone/scrollbar/horizontal_[prefix_]bar.png", gui.scrollbar_borders, tile=gui.scrollbar_tile) + thumb Frame("gui/phone/scrollbar/horizontal_[prefix_]thumb.png", gui.scrollbar_borders, tile=gui.scrollbar_tile) + +style vscrollbar: + variant "small" + xsize gui.scrollbar_size + base_bar Frame("gui/phone/scrollbar/vertical_[prefix_]bar.png", gui.vscrollbar_borders, tile=gui.scrollbar_tile) + thumb Frame("gui/phone/scrollbar/vertical_[prefix_]thumb.png", gui.vscrollbar_borders, tile=gui.scrollbar_tile) + +style slider: + variant "small" + ysize gui.slider_size + base_bar Frame("gui/phone/slider/horizontal_[prefix_]bar.png", gui.slider_borders, tile=gui.slider_tile) + thumb "gui/phone/slider/horizontal_[prefix_]thumb.png" + +style vslider: + variant "small" + xsize gui.slider_size + base_bar Frame("gui/phone/slider/vertical_[prefix_]bar.png", gui.vslider_borders, tile=gui.slider_tile) + thumb "gui/phone/slider/vertical_[prefix_]thumb.png" + +style slider_vbox: + variant "small" + xsize None + +style slider_slider: + variant "small" + xsize 900 diff --git a/src/vnpipe/renpy_templates/game/support.rpy b/src/vnpipe/renpy_templates/game/support.rpy new file mode 100644 index 0000000..72ca9f7 --- /dev/null +++ b/src/vnpipe/renpy_templates/game/support.rpy @@ -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) diff --git a/tests/fixtures/annotated_mini.json b/tests/fixtures/annotated_mini.json new file mode 100644 index 0000000..06ebda6 --- /dev/null +++ b/tests/fixtures/annotated_mini.json @@ -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" + } + ] + } + } + ] + } + ] +} diff --git a/tests/fixtures/mini_work/work.toml b/tests/fixtures/mini_work/work.toml new file mode 100644 index 0000000..e4190a1 --- /dev/null +++ b/tests/fixtures/mini_work/work.toml @@ -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 diff --git a/tests/test_renpy_gen.py b/tests/test_renpy_gen.py new file mode 100644 index 0000000..84710ed --- /dev/null +++ b/tests/test_renpy_gen.py @@ -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