31 lines
1.9 KiB
Python
31 lines
1.9 KiB
Python
"""Third-party Ren'Py libraries that the player implements natively.
|
|
|
|
Some community snippets are Python classes written against Ren'Py's render API (``renpy.Displayable``,
|
|
``renpy.Render``, pygame events). The browser player cannot run that API, so it ships its own class of the
|
|
same name and the converter drops the game's copy. Everything the converter needs to know about them lives
|
|
here; add an entry together with the TypeScript implementation (``nativeClasses`` in ``python.ts`` or the
|
|
displayable in ``screens.ts``), never in the shared converter code.
|
|
"""
|
|
|
|
#: class name -> what the native version offers
|
|
NATIVE_CLASSES: dict[str, dict] = {
|
|
"Gallery": {"methods": ("button", "image", "display", "make_button", "Action", "unlock", "unlock_image", "condition")},
|
|
# parallax picture that drifts against the mouse (screens: ``add TrackCursor("bg.png", 20)``)
|
|
"TrackCursor": {"methods": ()},
|
|
# Feniksdev's colour picker; the native class keeps the chosen colour and slot, the game draws its own UI
|
|
# Ren'Py's own MusicRoom, which games subclass; the player ships the playlist logic (musicroom.ts)
|
|
"MusicRoom": {"methods": ("add", "is_unlocked", "get_playlist", "Play", "Stop", "TogglePause", "Next",
|
|
"Previous", "RandomPlay", "SetLoop", "ToggleLoop", "SetSingleTrack",
|
|
"ToggleSingleTrack", "SetShuffle", "ToggleShuffle", "UnlockAll", "LockAll")},
|
|
"ColorPicker": {"methods": ("set_color", "save_color", "set_saved_color", "get_color", "swap_to_saved_color")},
|
|
}
|
|
|
|
#: modules those classes import for their event handlers; harmless once the class is replaced
|
|
NATIVE_IMPORTS = {"pygame"}
|
|
|
|
# These image factories are lowered to image IR by displayable_expr, rather than
|
|
# instantiated in Python. Their render-API classes must not execute at startup.
|
|
COMPILED_IMAGE_CLASSES = {"TransitionConditionSwitch"}
|
|
|
|
NATIVE_METHODS = {m for spec in NATIVE_CLASSES.values() for m in spec["methods"]}
|