Upload 2 files
Browse files- app/renpy/rpyc.py +17 -2
- app/renpy/store.py +42 -0
app/renpy/rpyc.py
CHANGED
|
@@ -140,10 +140,25 @@ class _Stand:
|
|
| 140 |
pass
|
| 141 |
|
| 142 |
def __setstate__(self, state) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
if isinstance(state, dict):
|
| 144 |
self.__dict__.update(state)
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
# Pickle sometimes appends to or updates a reconstructed object.
|
| 149 |
def append(self, item) -> None:
|
|
|
|
| 140 |
pass
|
| 141 |
|
| 142 |
def __setstate__(self, state) -> None:
|
| 143 |
+
# Pickle hands back state in one of two shapes, and Ren'Py uses both
|
| 144 |
+
# in the same file. Screen-language classes come back as a plain
|
| 145 |
+
# __dict__, but renpy.ast nodes declare __slots__, and for those
|
| 146 |
+
# pickle's default is the pair (instance_dict, slots_dict) with either
|
| 147 |
+
# half allowed to be None.
|
| 148 |
+
#
|
| 149 |
+
# Merging both halves is what makes a compiled script readable at all:
|
| 150 |
+
# a Say node's text lives in the slots half, so treating the pair as
|
| 151 |
+
# opaque leaves `what` unset and the whole file looks like it contains
|
| 152 |
+
# no dialogue.
|
| 153 |
if isinstance(state, dict):
|
| 154 |
self.__dict__.update(state)
|
| 155 |
+
return
|
| 156 |
+
if isinstance(state, tuple) and len(state) == 2:
|
| 157 |
+
for half in state:
|
| 158 |
+
if isinstance(half, dict):
|
| 159 |
+
self.__dict__.update(half)
|
| 160 |
+
return
|
| 161 |
+
self.__dict__["_state"] = state
|
| 162 |
|
| 163 |
# Pickle sometimes appends to or updates a reconstructed object.
|
| 164 |
def append(self, item) -> None:
|
app/renpy/store.py
CHANGED
|
@@ -236,6 +236,40 @@ Ren'Py recompiles a fresh one from the translated .rpy on next launch.
|
|
| 236 |
"""
|
| 237 |
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
def build_output(project_id: str, meta: dict) -> tuple[Path, list[str]]:
|
| 240 |
"""Package the translated scripts.
|
| 241 |
|
|
@@ -295,5 +329,13 @@ def build_output(project_id: str, meta: dict) -> tuple[Path, list[str]]:
|
|
| 295 |
if stale_rpyc:
|
| 296 |
notice = _STALE_NOTICE_HEADER + "\n".join(stale_rpyc) + _STALE_NOTICE_FOOTER
|
| 297 |
zf.writestr(_STALE_NOTICE_NAME, notice)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
shutil.rmtree(staging, ignore_errors=True)
|
| 299 |
return output, stale_rpyc
|
|
|
|
| 236 |
"""
|
| 237 |
|
| 238 |
|
| 239 |
+
_INSTALL_NOTICE_NAME = "HYMT_INSTALL.txt"
|
| 240 |
+
|
| 241 |
+
_INSTALL_ROOTED = """\
|
| 242 |
+
HOW TO INSTALL
|
| 243 |
+
==============
|
| 244 |
+
|
| 245 |
+
This zip mirrors your game's own folder layout, starting at the folder that
|
| 246 |
+
contains `game/`. Extract it over your game's root directory and answer
|
| 247 |
+
"replace" when asked - every file in here belongs exactly where it lands.
|
| 248 |
+
"""
|
| 249 |
+
|
| 250 |
+
_INSTALL_LOOSE = """\
|
| 251 |
+
HOW TO INSTALL
|
| 252 |
+
==============
|
| 253 |
+
|
| 254 |
+
You uploaded loose script files rather than a `game/` folder, so this zip has
|
| 255 |
+
no `game/` folder either. Everything in here belongs INSIDE your game's
|
| 256 |
+
`game/` folder:
|
| 257 |
+
|
| 258 |
+
<YourGame>/game/hymt_translate.rpy
|
| 259 |
+
<YourGame>/game/tl/<language>/...
|
| 260 |
+
|
| 261 |
+
Copy the contents of this zip into `<YourGame>/game/`, keeping the `tl/`
|
| 262 |
+
folder structure intact. Do not put them next to the .exe - Ren'Py only reads
|
| 263 |
+
scripts from inside `game/`.
|
| 264 |
+
"""
|
| 265 |
+
|
| 266 |
+
_INSTALL_FOOTER = """
|
| 267 |
+
Then start the game and choose the language, or set it in Preferences. Nothing
|
| 268 |
+
here overwrites your original scripts: the translations are additional files
|
| 269 |
+
that Ren'Py reads at runtime.
|
| 270 |
+
"""
|
| 271 |
+
|
| 272 |
+
|
| 273 |
def build_output(project_id: str, meta: dict) -> tuple[Path, list[str]]:
|
| 274 |
"""Package the translated scripts.
|
| 275 |
|
|
|
|
| 329 |
if stale_rpyc:
|
| 330 |
notice = _STALE_NOTICE_HEADER + "\n".join(stale_rpyc) + _STALE_NOTICE_FOOTER
|
| 331 |
zf.writestr(_STALE_NOTICE_NAME, notice)
|
| 332 |
+
# Where the files go depends on the shape of the upload, and getting it
|
| 333 |
+
# wrong means the game simply ignores the translation with no error at
|
| 334 |
+
# all - so it is spelled out rather than left to be inferred.
|
| 335 |
+
rooted = tl.game_root(staging, units) != staging
|
| 336 |
+
zf.writestr(
|
| 337 |
+
_INSTALL_NOTICE_NAME,
|
| 338 |
+
(_INSTALL_ROOTED if rooted else _INSTALL_LOOSE) + _INSTALL_FOOTER,
|
| 339 |
+
)
|
| 340 |
shutil.rmtree(staging, ignore_errors=True)
|
| 341 |
return output, stale_rpyc
|