mirror of
https://git.cavemanon.xyz/Cavemanon/SnootGame.git
synced 2025-03-22 10:00:27 +01:00
cg gallery wip vol4: pagination
This commit is contained in:
parent
f4a7c84f81
commit
9f0ade7fe4
1 changed files with 34 additions and 10 deletions
|
@ -14,6 +14,9 @@ init python:
|
||||||
# { item: string; cg: Displayable; }[]
|
# { item: string; cg: Displayable; }[]
|
||||||
galleryItems = []
|
galleryItems = []
|
||||||
|
|
||||||
|
# Which page of the gallery is shown
|
||||||
|
galleryPage = 1
|
||||||
|
|
||||||
# Make a scaled cg button
|
# Make a scaled cg button
|
||||||
# (cg: string, unlocked?: boolean): Displayable
|
# (cg: string, unlocked?: boolean): Displayable
|
||||||
def cg(fname, unlocked = False):
|
def cg(fname, unlocked = False):
|
||||||
|
@ -72,6 +75,16 @@ init python:
|
||||||
end = start + GALLERY_CGS_PER_PAGE
|
end = start + GALLERY_CGS_PER_PAGE
|
||||||
return galleryItems[start:end]
|
return galleryItems[start:end]
|
||||||
|
|
||||||
|
# Increments page
|
||||||
|
# (): None
|
||||||
|
def nextPage():
|
||||||
|
galleryPage += 1
|
||||||
|
|
||||||
|
# Decrements page
|
||||||
|
# (): None
|
||||||
|
def prevPage():
|
||||||
|
galleryPage -= 1
|
||||||
|
|
||||||
# Call to loading the gallery
|
# Call to loading the gallery
|
||||||
loadGallery()
|
loadGallery()
|
||||||
|
|
||||||
|
@ -84,16 +97,27 @@ screen cg_gallery():
|
||||||
use game_menu(_("Gallery"), scroll="viewport"):
|
use game_menu(_("Gallery"), scroll="viewport"):
|
||||||
|
|
||||||
fixed:
|
fixed:
|
||||||
$ pageItems = getGalleryPage(3)
|
$ pageItems = getGalleryPage(galleryPage)
|
||||||
$ galleryRows = len(pageItems) / GALLERY_COLS
|
$ galleryRows = len(pageItems) / GALLERY_COLS
|
||||||
grid GALLERY_COLS galleryRows:
|
$ maxPage = len(galleryItems) / GALLERY_CGS_PER_PAGE
|
||||||
|
vbox:
|
||||||
|
hbox:
|
||||||
|
grid GALLERY_COLS galleryRows:
|
||||||
|
|
||||||
spacing gui.slot_spacing
|
spacing gui.slot_spacing
|
||||||
|
|
||||||
# Iterate through galleryItems and add cgs buttons
|
# Iterate through galleryItems and add cgs buttons
|
||||||
for item in pageItems:
|
for item in pageItems:
|
||||||
if item["item"] == None:
|
if item["item"] == None:
|
||||||
# TODO: empty space
|
# TODO: empty space
|
||||||
add g.make_button(pageItems[0]["item"], pageItems[0]["cg"], xalign = 0.5, yalign = 0.5)
|
add g.make_button(pageItems[0]["item"], pageItems[0]["cg"], xalign = 0.5, yalign = 0.5)
|
||||||
else:
|
else:
|
||||||
add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5)
|
add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5)
|
||||||
|
|
||||||
|
hbox:
|
||||||
|
if galleryPage < maxPage:
|
||||||
|
textbutton ">" action SetVariable("galleryPage", galleryPage + 1)
|
||||||
|
|
||||||
|
hbox:
|
||||||
|
if galleryPage > 1:
|
||||||
|
textbutton "<" action SetVariable("galleryPage", galleryPage - 1)
|
||||||
|
|
Loading…
Reference in a new issue