Cache thumbnail parallel

This commit is contained in:
Nutbuster 2022-10-21 12:43:01 +11:00
parent 7a0462506a
commit e74d634799
1 changed files with 73 additions and 0 deletions

73
game/bugout.rpy Normal file
View File

@ -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