RenPy-Android-Unpack: Newest Ren'Py support
This commit is contained in:
parent
20f86f7c0e
commit
dbf627d15e
2 changed files with 30 additions and 8 deletions
2
RenPy-Android-Unpack/requirements.txt
Normal file
2
RenPy-Android-Unpack/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Pillow==9.5.0
|
||||||
|
colorama==0.4.6
|
|
@ -1,4 +1,5 @@
|
||||||
#!python3
|
#!python3
|
||||||
|
from PIL import Image
|
||||||
import colorama
|
import colorama
|
||||||
import zipfile
|
import zipfile
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -17,20 +18,38 @@ def printer(msg, level):
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
|
def extract_folder(zip_ref, path, dest):
|
||||||
|
for content in zip_ref.namelist():
|
||||||
|
if content.split('/')[0] == path:
|
||||||
|
zip_ref.extract(content, dest)
|
||||||
|
|
||||||
|
|
||||||
|
def find_modern_icon(directory):
|
||||||
|
icons = []
|
||||||
|
for folder, folders, files in os.walk(directory):
|
||||||
|
for file in os.listdir(folder):
|
||||||
|
if os.path.splitext(file)[1] == ".png":
|
||||||
|
image = Image.open(f"{folder}/{file}")
|
||||||
|
if image.size[0] == 432 and image.size[1] == 432:
|
||||||
|
icons.append(f"{folder}/{file}")
|
||||||
|
if len(icons) == 0:
|
||||||
|
raise KeyError
|
||||||
|
return icons
|
||||||
|
|
||||||
|
|
||||||
def extract_assets(file):
|
def extract_assets(file):
|
||||||
try:
|
try:
|
||||||
with zipfile.ZipFile(file, 'r') as zip_ref:
|
with zipfile.ZipFile(file, 'r') as zip_ref:
|
||||||
for content in zip_ref.namelist():
|
extract_folder(zip_ref, 'assets', '')
|
||||||
if content.split('/')[0] == 'assets':
|
|
||||||
zip_ref.extract(content)
|
|
||||||
if os.path.splitext(file)[1] == '.apk':
|
if os.path.splitext(file)[1] == '.apk':
|
||||||
try:
|
try:
|
||||||
zip_ref.extract('res/mipmap-xxxhdpi-v4/icon_background.png', 'assets')
|
# ~Ren'Py 8, 7
|
||||||
zip_ref.extract('res/mipmap-xxxhdpi-v4/icon_foreground.png', 'assets')
|
extract_folder(zip_ref, 'res', 'assets')
|
||||||
os.rename('assets/res/mipmap-xxxhdpi-v4/icon_background.png', 'assets/android-icon_background.png')
|
for icon in find_modern_icon('assets/res'):
|
||||||
os.rename('assets/res/mipmap-xxxhdpi-v4/icon_foreground.png', 'assets/android-icon_foreground.png')
|
os.rename(icon, f"assets/{os.path.split(icon)[1]}")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
try:
|
try:
|
||||||
|
# ~Ren'Py 6
|
||||||
zip_ref.extract('res/drawable/icon.png', 'assets')
|
zip_ref.extract('res/drawable/icon.png', 'assets')
|
||||||
os.rename('assets/res/drawable/icon.png', 'assets/icon.png')
|
os.rename('assets/res/drawable/icon.png', 'assets/icon.png')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -82,7 +101,8 @@ if __name__ == '__main__':
|
||||||
rename_dirs('assets')
|
rename_dirs('assets')
|
||||||
printer('Removing unneeded files... ', "info")
|
printer('Removing unneeded files... ', "info")
|
||||||
if os.path.splitext(filename)[1] == '.apk':
|
if os.path.splitext(filename)[1] == '.apk':
|
||||||
remove_unneeded(['assets/renpy', 'assets/res', 'assets/dexopt'], False)
|
remove_unneeded(['assets/renpy', 'assets/res'], False)
|
||||||
|
remove_unneeded(['assets/dexopt'], True)
|
||||||
printer('Renaming directory... ', "info")
|
printer('Renaming directory... ', "info")
|
||||||
remove_unneeded([os.path.splitext(filename)[0]], True)
|
remove_unneeded([os.path.splitext(filename)[0]], True)
|
||||||
os.rename('assets', os.path.splitext(filename)[0])
|
os.rename('assets', os.path.splitext(filename)[0])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue