From d6686c318af9a1a57eb4303e0e7cdeb994912dd1 Mon Sep 17 00:00:00 2001 From: nutbuster Date: Sun, 11 Jul 2021 13:02:41 +1000 Subject: [PATCH] CG Menu Redo --- game/src/cg_gallery.rpy | 55 ++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/game/src/cg_gallery.rpy b/game/src/cg_gallery.rpy index 9bdc135..ce9259e 100644 --- a/game/src/cg_gallery.rpy +++ b/game/src/cg_gallery.rpy @@ -78,6 +78,8 @@ init python: "ext": ext }) + + # Reads /images/cgs dir for all image files # Populates g:Gallery and galleryItems # Appends extra spaces at the end @@ -103,15 +105,18 @@ init python: addGalleryItem(str, ACCEPTED_EXTENSIONS[0], image[0], image[1], unlocked) lazy_counter += 1 - # Add empty items to fill grid after last cg button - extraSpaces = GALLERY_COLS - (lazy_counter % GALLERY_COLS) - for i in range(0, extraSpaces): + + return + # this is bugged, sees galleryItems as a local variable? weird python variable scope bug + extraSpaces = GALLERY_CGS_PER_PAGE - (lazy_counter % GALLERY_CGS_PER_PAGE) + for i in range(1, extraSpaces): galleryItems.append({ "item": None, "cg": None, "ext": None }) + # Returns what params to call im.FactorScale with for cg button size # Basically the delta diff dimensions # (w: int; h: int) -> { x: float; y: float } @@ -134,38 +139,26 @@ init python: + ## CG Gallery screen ######################################################## ## A screen that shows the image gallery screen cg_gallery(): + python: + items = len(galleryItems) + galleryRows = (items / GALLERY_COLS) + 1 + extraSpaces = GALLERY_COLS - (items % GALLERY_COLS) + print items + print galleryRows + print extraSpaces tag menu use game_menu(_("Gallery"), scroll="viewport"): - fixed: - $ pageItems = getGalleryPage(galleryPage) - $ galleryRows = len(pageItems) / GALLERY_COLS - $ maxPage = len(galleryItems) / GALLERY_CGS_PER_PAGE - vbox: - hbox: - grid GALLERY_COLS galleryRows: + grid GALLERY_COLS galleryRows: + spacing 20 + for item in galleryItems: + #very slow but once cached, it's 'OK', not ideal + add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5) + # Add empty items to fill grid after last cg button + for i in range(0, extraSpaces): + null height 20 - spacing gui.slot_spacing - - # Iterate through galleryItems and add cgs buttons - for item in pageItems: - if item["item"] == None: - hbox - else: - add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5) - - grid 3 1: - if galleryPage > 1: - textbutton "<" action SetVariable("galleryPage", galleryPage - 1) - else: - hbox - - label str(galleryPage) - - if galleryPage < maxPage: - textbutton ">" action SetVariable("galleryPage", galleryPage + 1) - else: - hbox