-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathdepack.rpy
53 lines (45 loc) · 1.66 KB
/
depack.rpy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# RenPy archive unpacker 1.3
# Decompiles PRA archives from RenPy runtime.
# Compatible with games using versions of RenPy 6.x, 7.x and 8.x
# =============
# HOW TO USE IT
# =============
# 1. Put this file to your /game/ dir.
# 2. Run the game.
# 3. See /unpacked/ dir.
init -9000 python:
import os
import shutil
_LB_GAME_DIR = os.path.join(config.basedir, "game")
_LB_OUTPUT_DIR = os.path.join(config.basedir, "unpacked", "game")
if hasattr(renpy,"list_files"):
_LB_list_files = renpy.list_files
else:
# for RenPy before 6.11.0
_LB_list_files = lambda: [fn for dir, fn in renpy.loader.listdirfiles() if dir != renpy.config.commondir]
# for removing invisible "archived" folder
renpy.loader.walkdir = (lambda f: lambda dir: f(dir) if os.path.exists(dir) else [])(renpy.loader.walkdir)
if hasattr(renpy,"file"):
_LB_file = renpy.file
elif hasattr(renpy,"notl_file"):
_LB_file = renpy.notl_file
else:
# for RenPy before 6.3.0
_LB_file = renpy.loader.load
try:
import __builtin__
_LB_open = __builtin__.open
except:
_LB_open = renpy.compat.open
for fname in _LB_list_files():
old_path = os.path.join(_LB_GAME_DIR, fname)
new_path = os.path.join(_LB_OUTPUT_DIR, fname)
if not os.path.exists(old_path) and not os.path.exists(new_path):
dirname = os.path.dirname(new_path)
if not os.path.exists(dirname):
os.makedirs(dirname)
new = _LB_open(new_path, "wb")
orig = _LB_file(fname)
shutil.copyfileobj(orig, new)
orig.close()
new.close()