From 102d23d47fa7402a5c0ca15a012ba03f467777d7 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Mon, 27 Jun 2022 22:31:51 +0100 Subject: [PATCH] Bug fixes * Fixed generic update image creator * Fixed new side image type regression * Fixed MyMod game version inside manifest * Fixed MyMod missing from release * Fixed android mods detection * Removed android searchpaths (superseded) * Moved engine related changes into its own file --- game/mods/MyMod/manifest.json | 2 +- game/scripts/characters/genie/wardrobe.rpy | 2 +- game/scripts/gui/say.rpy | 2 + game/scripts/mods.rpy | 7 --- game/scripts/options.rpy | 3 +- game/scripts/utility/devtools.rpy | 45 ---------------- game/scripts/utility/engine.rpy | 62 ++++++++++++++++++++++ game/scripts/utility/updater.rpy | 4 +- 8 files changed, 70 insertions(+), 57 deletions(-) create mode 100644 game/scripts/utility/engine.rpy diff --git a/game/mods/MyMod/manifest.json b/game/mods/MyMod/manifest.json index 680b19c5..1a5dea2b 100644 --- a/game/mods/MyMod/manifest.json +++ b/game/mods/MyMod/manifest.json @@ -3,5 +3,5 @@ "Author": "LoafyLemon", "Version": "1.0.0", "Description": "Adds ponytail hairstyle for Hermione", - "GameVer": "1.40" + "GameVer": "1.43" } diff --git a/game/scripts/characters/genie/wardrobe.rpy b/game/scripts/characters/genie/wardrobe.rpy index 5e5a38d0..b4c99b2d 100644 --- a/game/scripts/characters/genie/wardrobe.rpy +++ b/game/scripts/characters/genie/wardrobe.rpy @@ -8,7 +8,7 @@ init python: return 0 layeredimage genie: - anchor (0, 1.0) + anchor (0.0, 1.0) group hair: attribute nude "characters/genie/hair.webp" diff --git a/game/scripts/gui/say.rpy b/game/scripts/gui/say.rpy index eb249774..8799a39e 100644 --- a/game/scripts/gui/say.rpy +++ b/game/scripts/gui/say.rpy @@ -31,6 +31,8 @@ screen say(who, what, side_image=None, icon=None): if side_image: add side_image yalign 1.0 yanchor 1.0 zoom 0.5 + else: + add SideImage() window id "window": style gui.theme("say_window") diff --git a/game/scripts/mods.rpy b/game/scripts/mods.rpy index 989dae6b..3dcc6da0 100644 --- a/game/scripts/mods.rpy +++ b/game/scripts/mods.rpy @@ -13,13 +13,6 @@ init python: global mods_list all_files = renpy.list_files() - - if renpy.android: - # Include files outside the application archive and strip the directory path. - # Normally it wouldn't be necessary but `renpy.list_files` does not list files outside archives on android. - for dir in config.searchpath: - all_files.extend([os.path.join(path.replace(dir, ""), name) for path, _, files in os.walk(dir) for name in files]) - mods = filter(lambda x: x.endswith(".json"), all_files) for i, manifest in enumerate(mods): diff --git a/game/scripts/options.rpy b/game/scripts/options.rpy index fde017d2..77bb30b6 100644 --- a/game/scripts/options.rpy +++ b/game/scripts/options.rpy @@ -25,7 +25,6 @@ init python: # https://www.renpy.org/doc/html/config.html # Pre-Release related flags and variables -define config.searchpath = [os.environ["ANDROID_PUBLIC"]] if renpy.android else [config.gamedir, config.commondir] define config.autoreload = False define config.developer = "auto" define config.console = True @@ -152,6 +151,7 @@ init python: build.classify("icon.ico", "windows") build.classify("game/presplash_*.png", "renpy") build.classify("game/outfits/**", "all") + build.classify("game/mods/MyMod/**", "all") build.classify("**.py", None) build.classify("**.txt", None) @@ -169,4 +169,5 @@ init python: build.classify("cache/**", None) build.classify("game/saves/**", None) + build.classify("game/mods/**", None) diff --git a/game/scripts/utility/devtools.rpy b/game/scripts/utility/devtools.rpy index e06c4044..972dcee1 100644 --- a/game/scripts/utility/devtools.rpy +++ b/game/scripts/utility/devtools.rpy @@ -1,48 +1,3 @@ -init python: - - if renpy.android: - class Android11TextureLeakFix(NoRollback): - def __init__(self, limit=100): - self.statements = 0 - self.limit = limit - - def __call__(self, name): - if renpy.is_init_phase(): - return - - self.statements += 1 - - if self.statements > self.limit: - self.statements = 0 - - # Big thanks to Andykl (https://github.com/Andykl) - # for finding the issue and inventing this workaround. - # https://github.com/renpy/renpy/issues/3643 - - cache = renpy.display.im.cache - cache_size = cache.get_total_size() - cache_limit = cache.cache_limit * 0.95 - - if cache_size >= cache_limit: - if config.developer: - print("Cache limit reached, purging cache... ({}/{})\n{}".format(cache_size, cache_limit, renpy.get_filename_line())) - - cache.clear() - - if renpy.game.interface is not None: - if config.developer: - print("Statements limit reached, cleaning textures... ({})\n{}".format(self.limit, renpy.get_filename_line())) - - renpy.game.interface.full_redraw = True - renpy.game.interface.restart_interaction = True - - if renpy.display.draw is not None: - renpy.display.draw.kill_textures() - - renpy.display.render.free_memory() - - config.statement_callbacks.append(Android11TextureLeakFix()) - init python early: if renpy.version_tuple < (7,5,0,22061501): raise RuntimeWarning("Your Ren'Py launcher is outdated, the current minimal requirement is 7.5.0.22061501+\nPlease perform an update and try launching the game again.") diff --git a/game/scripts/utility/engine.rpy b/game/scripts/utility/engine.rpy new file mode 100644 index 00000000..5e898fc3 --- /dev/null +++ b/game/scripts/utility/engine.rpy @@ -0,0 +1,62 @@ +init -10 python: + + if renpy.android: + # Attempts at fixing the texture leak plaguing + # android devices, mainly running on Android11 & Android 12. + class Android11TextureLeakFix(NoRollback): + def __init__(self, limit=100): + self.statements = 0 + self.limit = limit + + def __call__(self, name): + if renpy.is_init_phase(): + return + + self.statements += 1 + + if self.statements > self.limit: + self.statements = 0 + + # Big thanks to Andykl (https://github.com/Andykl) + # for finding the issue and inventing this workaround. + # https://github.com/renpy/renpy/issues/3643 + + cache = renpy.display.im.cache + cache_size = cache.get_total_size() + cache_limit = cache.cache_limit * 0.95 + + if cache_size >= cache_limit: + if config.developer: + print("Cache limit reached, purging cache... ({}/{})\n{}".format(cache_size, cache_limit, renpy.get_filename_line())) + + cache.clear() + + if renpy.game.interface is not None: + if config.developer: + print("Statements limit reached, cleaning textures... ({})\n{}".format(self.limit, renpy.get_filename_line())) + + renpy.game.interface.full_redraw = True + renpy.game.interface.restart_interaction = True + + if renpy.display.draw is not None: + renpy.display.draw.kill_textures() + + renpy.display.render.free_memory() + + config.statement_callbacks.append(Android11TextureLeakFix()) + + if renpy.windows: + # On windows, Renpy does not support backslashes in some of its functions, + # but because the code needs to be platform-independent, + # we require to monkey patch those functions in order + # to remain compatible with all platforms without losing functionality. + + _renpy_loadable = renpy.loadable + + @renpy.pure + def _loadable(filename): + filename = filename.replace("\\", "/") + + return _renpy_loadable(filename) + + renpy.loadable = _loadable diff --git a/game/scripts/utility/updater.rpy b/game/scripts/utility/updater.rpy index c3160549..796466aa 100644 --- a/game/scripts/utility/updater.rpy +++ b/game/scripts/utility/updater.rpy @@ -82,7 +82,7 @@ init python: def version_logo(): url = UPDATE_URL filename = "logo_{}.webp".format(UPDATE_VER) - path = os.path.join(config.basedir, "update/{}".format(filename)) + path = os.path.join(config.basedir, "update", filename) # Read file if exists if os.path.isfile(path): @@ -103,7 +103,7 @@ init python: return im.Data(data, path) except: - path = os.path.join(config.basedir, "update/generic.webp") + path = os.path.join(config.basedir, "update", "generic.webp") with open(path, "rb") as f: data = f.read()