SnootGame/game/src/cg_gallery.rpy

69 lines
2.0 KiB
Plaintext

init python:
g = Gallery()
gallery_cols = 3
gallery_items = []
not_unlocked_cover = im.FactorScale("gui/gallery/unlocked_cg_button_cover.png", 0.225, 0.225)
def cg(fname, unlocked = False):
#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)
g.image(image_name)
if unlocked:
g.unlock(image_name)
else:
g.condition("persistent." + image_name)
gallery_items.append({
"item": image_name,
"cg": cg(image_name, unlocked)
})
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
})
## CG Gallery screen ########################################################
## A screen that shows the image gallery
screen cg_gallery():
tag menu
use game_menu(_("Gallery"), scroll="viewport"):
fixed:
$ gallery_rows = len(gallery_items) / gallery_cols
grid gallery_cols gallery_rows:
spacing gui.slot_spacing
for item in gallery_items:
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)