mirror of
https://git.cavemanon.xyz/Cavemanon/SnootGame.git
synced 2025-01-22 17:26:20 +01:00
cg gallery wip vol2: load all files
This commit is contained in:
parent
d4781d2d4c
commit
bd6c710380
2 changed files with 30 additions and 14 deletions
BIN
game/gui/gallery/unlocked_cg_button_cover.png
Normal file
BIN
game/gui/gallery/unlocked_cg_button_cover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
|
@ -1,13 +1,16 @@
|
||||||
init python:
|
init python:
|
||||||
g = Gallery()
|
g = Gallery()
|
||||||
|
|
||||||
|
|
||||||
gallery_cols = 3
|
gallery_cols = 3
|
||||||
gallery_items = []
|
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):
|
def cg(fname, unlocked = False):
|
||||||
normalized_fname = fname if unlocked else not_unlocked_cover
|
#if not unlocked:
|
||||||
return im.FactorScale("images/cgs/" + normalized_fname+ ".png", 0.225, 0.225)
|
# return not_unlocked_cover
|
||||||
|
|
||||||
|
return im.FactorScale("images/cgs/" + fname + ".png", 0.225, 0.225)
|
||||||
|
|
||||||
def add_gallery_item(image_name, unlocked = False):
|
def add_gallery_item(image_name, unlocked = False):
|
||||||
g.button(image_name)
|
g.button(image_name)
|
||||||
|
@ -23,18 +26,27 @@ init python:
|
||||||
"cg": cg(image_name, unlocked)
|
"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)
|
from os import listdir, getcwd
|
||||||
add_gallery_item("a12", True)
|
from os.path import isfile, join
|
||||||
add_gallery_item("a13", True)
|
|
||||||
|
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 ########################################################
|
## CG Gallery screen ########################################################
|
||||||
## A screen that shows the image gallery
|
## A screen that shows the image gallery
|
||||||
|
@ -49,4 +61,8 @@ screen cg_gallery():
|
||||||
spacing gui.slot_spacing
|
spacing gui.slot_spacing
|
||||||
|
|
||||||
for item in gallery_items:
|
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)
|
||||||
|
|
Loading…
Reference in a new issue