From c14bf312389e456b97a49584ae0b119e32d05123 Mon Sep 17 00:00:00 2001 From: nutbuster Date: Thu, 27 Oct 2022 17:25:15 +1100 Subject: [PATCH] Undo threading --- game/script.rpy | 15 +---- game/src/cg_gallery.rpy | 116 +++++++++++++++++++++++++++++--------- game/src/splashscreen.rpy | 15 +---- 3 files changed, 94 insertions(+), 52 deletions(-) diff --git a/game/script.rpy b/game/script.rpy index 3d19880..74b5a0f 100644 --- a/game/script.rpy +++ b/game/script.rpy @@ -48,6 +48,8 @@ init python: if persistent.autoup == None: persistent.autoup = False + pass + transform randPosition: alpha 0.0 xalign random.uniform(0.2,0.8) @@ -1144,19 +1146,6 @@ image hotel = "images/backgrounds/hotellobby.jpg" image airport = "images/backgrounds/airport.jpg" image fromairplane = "images/backgrounds/fromairplane.jpg" -#WAOH ITS THE TITLE SCREEN!!!! -label splashscreen: - $ persistent.splashtype = random.randint(0,2000 - 1) - $ renpy.movie_cutscene("images/intros/CaveManonProductions.webm") - - if persistent.autoup: - python: - UpdateCheck() - if persistent.updateresult != "No new version is available": - updater.update(persistent.updateWebServer, force=True) - - stop sound - return #Custom Vars for positions transform scenter: diff --git a/game/src/cg_gallery.rpy b/game/src/cg_gallery.rpy index 0667344..7eb7bcb 100644 --- a/game/src/cg_gallery.rpy +++ b/game/src/cg_gallery.rpy @@ -1,5 +1,8 @@ + init python: + import threading + # CONST PARAMS ALLOW_ZOOM = False GALLERY_COLS = 3 @@ -36,16 +39,34 @@ init python: # Make a scaled cg button # (cg: string; ext: string; w: float - def cg(fname, ext, w): - scale = PREFERRED_WIDTH * 100.0 / w / 100.0 + def cg_(fname, ext, w): + scale = PREFERRED_WIDTH / w #scale = box_ratio(wh) - return im.FactorScale(fname, scale, scale, False) + #image = im.FactorScale(fname, scale, scale, True) + image = im.FactorScale(fname, scale, scale, True) + #return Image(fname, zoom=scale) + return image # Reads /images/cgs dir for all image files # Populates galleryItems # () -> None + def add_(str, _str, ext, cpname): + image = renpy.image_size(Image(_str)) + + item = { + "item": str, + "fn": _str, + "cg": cg_(_str, ext, image[0]), + "ext": ext, + "wh": image + } + gallery_dic[cpname].append(item) + + pass + def loadGallery(): + list_img = renpy.list_images() #if ext is "webm": @@ -57,19 +78,18 @@ init python: _str = path+str+"."+ext if renpy.loadable(_str): #brute force - image = renpy.image_size(Image(_str)) + add_(str, _str, ext, cp['name']) + + - gallery_dic[cp['name']] += [{ - "item": str, - "fn": _str, - "cg": cg(_str, ext, image[0]), - "ext": ext, - "wh": image - }] return # Call to loading the gallery loadGallery() + renpy.start_predict_screen("cg_gallery") + + #sort + # hard code the webm because renpy is really dumb and doesn't add Movies properly until much later fang_webm = 'images/animations/fang tail.webm' @@ -97,6 +117,40 @@ init python: zoom_arr.sort() """ + + class CaveGallery: #incase it confilcts with renpy's gallery + FPS = 1/60 + class GalleryButton(renpy.Displayable): + def __init__(self, x, y, *childs, **kwargs): + super(CaveGallery.GalleryButton, self).__init__(**kwargs) + pass + + def render(self, width, height, st, at): + render = renpy.Render(self.width, self.height) + for x in self.childs: + t = Transform(child=x) + child_render = renpy.render(t, self.width, self.height, st, at) + render.place(x, 0, 0, None, None, st, at) + return render + def event(self, ev, ex, ey, st): #getting clicked on + global CaveGallery + if (renpy.map_event(ev, 'mouseup_1')): #1026 + pass + def visit(self): + return self.childs + + @staticmethod + def render_cavegallery(st, at): + global CaveGallery + + return CaveGallery.FPS + pass + + + pass + + + """ 'Recursive' / Loopable / Roundtrip Screens _0 <-> _1 @@ -111,7 +165,7 @@ screen cg_gallery_1( __yoffset = 0, origin = 'CG'): use cg_gallery('0', __yoffset, origin) #screen view_image(fn, _origin, zoom=1): -screen view_image_a(fn, _origin, zoom = zoom_arr.index(1.0)): +screen view_image_a(fn, _origin = 0, zoom = zoom_arr.index(1.0)): tag menu use view_image(fn, _origin, zoom, 'b') screen view_image_b(fn, _origin, zoom = zoom_arr.index(1.0)): @@ -176,7 +230,7 @@ screen cg_gallery(flag, __yoffset = 0, origin = 'CG'): xcenter 0.525 ycenter 0.525 - viewport: + vpgrid id "vpg": yinitial __yoffset scrollbars "vertical" mousewheel True @@ -184,21 +238,26 @@ screen cg_gallery(flag, __yoffset = 0, origin = 'CG'): pagekeys True xfill True - grid GALLERY_COLS gallery_rows: - xcenter 0.5 - ycenter 0.5 - for item in gallery_items: - # Should properly fix with actual margin difference but good - # enough or the actual position - python: - item_counter += 1 - yoffset = item_counter / 3 * PREFERRED_HEIGHT * 1.15 - yoffset = int( yoffset + (PREFERRED_HEIGHT * 1.15)) + xcenter 0.5 + #ycenter 0.5 - use flag_button(item, yoffset, origin) + spacing 20 - for i in range(0, empty_spaces): - null height 20 + #rows gallery_rows + cols GALLERY_COLS + + for item in gallery_items: + # Should properly fix with actual margin difference but good + # enough or the actual position + python: + item_counter += 1 + #yoffset = int( yoffset + (PREFERRED_HEIGHT * 1.15)) + yoffset = int(item_counter / 3 * PREFERRED_HEIGHT + ((item_counter / 3))) + + use flag_button(item, yoffset, origin) + + for i in range(0, empty_spaces): + null height 20 """ @@ -213,7 +272,8 @@ screen flag_button(item, yoffset, origin): if item['ext'] == "webm": action Replay('fang_movie')#ShowMenu('view_movie', item, ShowMenu('cg_gallery_0', yoffset, origin)) else: - action ShowMenu('view_image_a', item, ShowMenu('cg_gallery_0', yoffset, origin)) + #action ShowMenu('view_image_a', item, ShowMenu('cg_gallery_0', yoffset, origin)) + action Show('view_image', None, item, ShowMenu('cg_gallery_0', yoffset, origin), _zorder=1) xcenter 0.5 ycenter 0.5 padding (1,0,1,2) vbox: @@ -227,6 +287,7 @@ screen flag_button(item, yoffset, origin): add NOT_UNLOCKED_COVER + screen view_movie(item, _origin): tag menu key "game_menu" action _origin @@ -242,6 +303,7 @@ view_image, Loads the image in fullscreen with viewport control. """ screen view_image(item, _origin, zoom = zoom_arr.index(1.0), flag='a'): python: + _origin = Show('cg_gallery') zoom_a = zoom+1 zoom_a_f = ShowMenu('view_image_'+flag, item, _origin, zoom_a) zoom_b = zoom-1 diff --git a/game/src/splashscreen.rpy b/game/src/splashscreen.rpy index 03da848..402aedf 100644 --- a/game/src/splashscreen.rpy +++ b/game/src/splashscreen.rpy @@ -4,7 +4,6 @@ label splashscreen: $ renpy.movie_cutscene("images/intros/CaveManonProductions.webm") python: - import threading import pygame CACHE_PATH = config.basedir.replace("\\","/") + "/game/cache/" @@ -25,7 +24,6 @@ label splashscreen: #save_thumb(NOT_UNLOCKED_COVER,"default","jpg") - g_thread_arr = [] path_testing = [] for x in (gallery_dic.items()): key = x[0] @@ -51,14 +49,11 @@ label splashscreen: 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'])) - g_thread_arr.append(t) - t.start() + save_thumb(y['cg'], y['fn'], y['ext']) pass - if persistent.autoup: + if persistent.autoup == 10000: python: UpdateCheck() if persistent.updateresult != "No new version is available": @@ -66,12 +61,8 @@ label splashscreen: stop sound - if (persistent.languaged_up is None): + if (persistent.languaged_up == 10000): call screen translator_popup - else: - python: - for th in g_thread_arr: - th.join() return