cg gallery wip vol1: gallery data init, gallery screen

This commit is contained in:
lazysnake 2021-06-12 21:50:48 +02:00
parent 4d9e2155e3
commit 8cd9643818
3 changed files with 55 additions and 0 deletions

View File

@ -316,6 +316,7 @@ screen navigation():
textbutton _("Save") action ShowMenu("save")
textbutton _("Load") action ShowMenu("load")
textbutton _("Options") action ShowMenu("preferences")
textbutton _("Gallery") action ShowMenu("cg_gallery")
textbutton _("Help And About") action ShowMenu("helpandabout")
@ -382,6 +383,8 @@ screen main_menu():
imagebutton auto "gui/button/menubuttons/startbutton_%s.png" action Start()
imagebutton auto "gui/button/menubuttons/loadbutton_%s.png" action ShowMenu("load")
imagebutton auto "gui/button/menubuttons/optionsbutton_%s.png" action ShowMenu("preferences")
#TODO: gallery btn needs asset
imagebutton auto "gui/button/menubuttons/helpbutton_%s.png" action ShowMenu("cg_gallery")
imagebutton auto "gui/button/menubuttons/helpbutton_%s.png" action ShowMenu("helpandabout")
imagebutton auto "gui/button/menubuttons/quitbutton_%s.png" action Quit(confirm=not main_menu)

0
game/src/__init__.py Normal file
View File

52
game/src/cg_gallery.rpy Normal file
View File

@ -0,0 +1,52 @@
init python:
g = Gallery()
gallery_cols = 3
gallery_items = []
not_unlocked_cover = "a04" #TODO (needs asset)
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)
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)
})
# 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)
# SAFE GUARD
if len(gallery_items) % gallery_cols != 0:
raise Exception("Invalid gallery!")
## 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:
add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5)