From e74d634799f390b2570051ff9eb247ece65637dd Mon Sep 17 00:00:00 2001 From: nutbuster Date: Fri, 21 Oct 2022 12:43:01 +1100 Subject: [PATCH] Cache thumbnail parallel --- game/bugout.rpy | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 game/bugout.rpy diff --git a/game/bugout.rpy b/game/bugout.rpy new file mode 100644 index 0000000..3b7f0ec --- /dev/null +++ b/game/bugout.rpy @@ -0,0 +1,73 @@ + +label splashscreen: + $ persistent.splashtype = random.randint(0,2000 - 1) + $ renpy.movie_cutscene("images/intros/CaveManonProductions.webm") + + python: + import threading + import pygame + + CACHE_PATH = config.basedir.replace("\\","/") + "/game/cache/" + + if renpy.android: + CACHE_PATH = os.environ['ANDROID_PUBLIC'] + "/cache/" + + # (src_image: FactorScale; name: string, ext: string) FactorScale refers to an image scaled using im.FactorScale() + def save_thumb(src_image, name, ext): + final = CACHE_PATH+"thmb_"+name+'.'+ext + + data = src_image.load() #Returns a pygame surface + if (os.path.exists(final)): + pass + else: + pygame.image.save(data, final) #Saves the image to file + #print('O', final) + + #save_thumb(NOT_UNLOCKED_COVER,"default","jpg") + + thread_arr = [] + path_testing = [] + for x in (gallery_dic.items()): + key = x[0] + value = x[1] + + #slow, roundabout but it works + if key in path_testing: + pass + else: + for c in CG_PATHS: + print(c, os.path.basename(c['path'])) + if (c['name'] == key): + final_dir = os.path.join(CACHE_PATH, "thmb_"+os.path.normpath(c['path'])) + if (os.path.exists(final_dir)): + pass + else: + os.makedirs(final_dir) + + path_testing.append(key) + + for y in value: + print(y['cg']) + if type(y['cg']) is Movie: + pass + else: + #save_thumb(y['cg'], y['fn'], y['ext']) + t = threading.Thread(target=save_thumb, args=(y['cg'], y['fn'], y['ext'])) + thread_arr.append(t) + t.start() + + pass + for th in thread_arr: + th.join() + #renpy.load_image(y['cg']) + print('HELLO') + + if persistent.autoup: + python: + UpdateCheck() + if persistent.updateresult != "No new version is available": + updater.update(persistent.updateWebServer, force=True) + + stop sound + + return