mirror of
https://git.cavemanon.xyz/Cavemanon/SnootGame.git
synced 2025-03-13 20:19:25 +01:00
CG Menu Redo
This commit is contained in:
parent
5723216d95
commit
d6686c318a
1 changed files with 24 additions and 31 deletions
|
@ -78,6 +78,8 @@ init python:
|
|||
"ext": ext
|
||||
})
|
||||
|
||||
|
||||
|
||||
# Reads /images/cgs dir for all image files
|
||||
# Populates g:Gallery and galleryItems
|
||||
# Appends extra spaces at the end
|
||||
|
@ -103,15 +105,18 @@ init python:
|
|||
addGalleryItem(str, ACCEPTED_EXTENSIONS[0], image[0], image[1], unlocked)
|
||||
lazy_counter += 1
|
||||
|
||||
# Add empty items to fill grid after last cg button
|
||||
extraSpaces = GALLERY_COLS - (lazy_counter % GALLERY_COLS)
|
||||
for i in range(0, extraSpaces):
|
||||
|
||||
return
|
||||
# this is bugged, sees galleryItems as a local variable? weird python variable scope bug
|
||||
extraSpaces = GALLERY_CGS_PER_PAGE - (lazy_counter % GALLERY_CGS_PER_PAGE)
|
||||
for i in range(1, extraSpaces):
|
||||
galleryItems.append({
|
||||
"item": None,
|
||||
"cg": None,
|
||||
"ext": None
|
||||
})
|
||||
|
||||
|
||||
# Returns what params to call im.FactorScale with for cg button size
|
||||
# Basically the delta diff dimensions
|
||||
# (w: int; h: int) -> { x: float; y: float }
|
||||
|
@ -134,38 +139,26 @@ init python:
|
|||
|
||||
|
||||
|
||||
|
||||
## CG Gallery screen ########################################################
|
||||
## A screen that shows the image gallery
|
||||
screen cg_gallery():
|
||||
python:
|
||||
items = len(galleryItems)
|
||||
galleryRows = (items / GALLERY_COLS) + 1
|
||||
extraSpaces = GALLERY_COLS - (items % GALLERY_COLS)
|
||||
print items
|
||||
print galleryRows
|
||||
print extraSpaces
|
||||
tag menu
|
||||
use game_menu(_("Gallery"), scroll="viewport"):
|
||||
|
||||
fixed:
|
||||
$ pageItems = getGalleryPage(galleryPage)
|
||||
$ galleryRows = len(pageItems) / GALLERY_COLS
|
||||
$ maxPage = len(galleryItems) / GALLERY_CGS_PER_PAGE
|
||||
vbox:
|
||||
hbox:
|
||||
grid GALLERY_COLS galleryRows:
|
||||
grid GALLERY_COLS galleryRows:
|
||||
spacing 20
|
||||
for item in galleryItems:
|
||||
#very slow but once cached, it's 'OK', not ideal
|
||||
add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5)
|
||||
# Add empty items to fill grid after last cg button
|
||||
for i in range(0, extraSpaces):
|
||||
null height 20
|
||||
|
||||
spacing gui.slot_spacing
|
||||
|
||||
# Iterate through galleryItems and add cgs buttons
|
||||
for item in pageItems:
|
||||
if item["item"] == None:
|
||||
hbox
|
||||
else:
|
||||
add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5)
|
||||
|
||||
grid 3 1:
|
||||
if galleryPage > 1:
|
||||
textbutton "<" action SetVariable("galleryPage", galleryPage - 1)
|
||||
else:
|
||||
hbox
|
||||
|
||||
label str(galleryPage)
|
||||
|
||||
if galleryPage < maxPage:
|
||||
textbutton ">" action SetVariable("galleryPage", galleryPage + 1)
|
||||
else:
|
||||
hbox
|
||||
|
|
Loading…
Reference in a new issue