Converter - screens.py parses the screen language: containers (fixed, frame, vbox, hbox, grid, vpgrid, viewport, button, has), widgets (text, textbutton, imagebutton, add, bar ...), if/for/use/transclude, default, python, key, timer, on, inline ATL, conditional properties, and decompiled forms (unparenthesised operators, glued property values, comma separated actions) - style statements, call/show/hide screen operators and Python-level renpy.show_screen are translated; only screens the game shows are audited, unused stock screens no longer block an import; undefined screens do - ATL values may be computed at run time and transforms take parameters (at blink(0.2, 0.3)); blur property Player - screens.ts builds the DOM from the IR and rebuilds it on state changes; buttons with idle/hover/selected/insensitive states, tooltips, sounds, modal screens, timers and keys that survive re-rendering, saved with the save file - Actions: Jump, Call, Return, SetVariable, Toggle*, SetScreenVariable, Show, Hide, ToggleScreen, Function, Play, Notify, If, Language, ShowMenu, OpenURL ... - Crop/LiveCrop/Solid/Frame/Transform/DynamicDisplayable values, crop property, globals(), renpy.variant/change_language/seen_image, transition stubs Tests: screen parser and runtime (linkedom DOM), screens fixture compiled from tests/fixtures/screens.rpy. Docs: docs/SCREENS.md. Twisted-Thoughts now passes the strict compatibility check. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
24 lines
930 B
Python
24 lines
930 B
Python
"""Compile the screens/styles of a .rpy file to JSON: python -m tests.make_screens SOURCE.rpy OUT.json"""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from app.converter.compatibility import audit_ir, require_supported_scripts
|
|
from app.converter.pipeline import _used_screens
|
|
from app.converter.rpy_parser import RpyParser, ScriptData
|
|
|
|
|
|
def main(source: Path, out: Path) -> None:
|
|
data = ScriptData()
|
|
RpyParser(data, source.name).parse(source.read_text(encoding="utf-8"))
|
|
audit_ir(data)
|
|
require_supported_scripts(data)
|
|
shipped = {name: data.screens[name] for name in sorted(_used_screens(data))}
|
|
out.write_text(json.dumps({"screens": shipped, "styles": data.styles, "atl": data.atl,
|
|
"transforms": data.transforms}, ensure_ascii=False, separators=(",", ":")),
|
|
encoding="utf-8")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(Path(sys.argv[1]), Path(sys.argv[2]))
|