diff --git a/game/gui/gallery/unlocked_cg_button_cover.png b/game/gui/gallery/unlocked_cg_button_cover.png new file mode 100644 index 0000000..9781519 Binary files /dev/null and b/game/gui/gallery/unlocked_cg_button_cover.png differ diff --git a/game/src/cg_gallery.rpy b/game/src/cg_gallery.rpy index aaa6b61..bb33a53 100644 --- a/game/src/cg_gallery.rpy +++ b/game/src/cg_gallery.rpy @@ -1,13 +1,16 @@ init python: g = Gallery() + gallery_cols = 3 gallery_items = [] - not_unlocked_cover = "a04" #TODO (needs asset) + not_unlocked_cover = im.FactorScale("gui/gallery/unlocked_cg_button_cover.png", 0.225, 0.225) def cg(fname, unlocked = False): - normalized_fname = fname if unlocked else not_unlocked_cover - return im.FactorScale("images/cgs/" + normalized_fname+ ".png", 0.225, 0.225) + #if not unlocked: + # return not_unlocked_cover + + return im.FactorScale("images/cgs/" + fname + ".png", 0.225, 0.225) def add_gallery_item(image_name, unlocked = False): g.button(image_name) @@ -23,18 +26,27 @@ init python: "cg": cg(image_name, unlocked) }) - # LIST FILES TO ADD HERE - add_gallery_item("a02") - add_gallery_item("a04", True) - add_gallery_item("a10", True) - add_gallery_item("a11", True) - add_gallery_item("a12", True) - add_gallery_item("a13", True) + from os import listdir, getcwd + from os.path import isfile, join + + cg_path = "images/cgs/" + working_dir_path = getcwd().replace("\\", "/") + cg_dir_path = working_dir_path + "/game/" + cg_path + + for cgFile in listdir(cg_dir_path): + if isfile(join(cg_dir_path, cgFile)): + if (cgFile[-4:] == '.png'): + add_gallery_item(cgFile[0:-4], True) + + extra_spaces = gallery_cols - (len(gallery_items) % gallery_cols) + for i in range(0, extra_spaces): + gallery_items.append({ + "item": None, + "cg": None + }) + - # SAFE GUARD - if len(gallery_items) % gallery_cols != 0: - raise Exception("Invalid gallery!") ## CG Gallery screen ######################################################## ## A screen that shows the image gallery @@ -49,4 +61,8 @@ screen cg_gallery(): spacing gui.slot_spacing for item in gallery_items: - add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5) + if item["item"] == None: + # TODO: empty space + add g.make_button(gallery_items[0]["item"], gallery_items[0]["cg"], xalign = 0.5, yalign = 0.5) + else: + add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5)