forked from Cavemanon/SnootGame
CG Menu Redo
This commit is contained in:
@ -78,6 +78,8 @@ init python:
|
|||||||
"ext": ext
|
"ext": ext
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Reads /images/cgs dir for all image files
|
# Reads /images/cgs dir for all image files
|
||||||
# Populates g:Gallery and galleryItems
|
# Populates g:Gallery and galleryItems
|
||||||
# Appends extra spaces at the end
|
# Appends extra spaces at the end
|
||||||
@ -103,15 +105,18 @@ init python:
|
|||||||
addGalleryItem(str, ACCEPTED_EXTENSIONS[0], image[0], image[1], unlocked)
|
addGalleryItem(str, ACCEPTED_EXTENSIONS[0], image[0], image[1], unlocked)
|
||||||
lazy_counter += 1
|
lazy_counter += 1
|
||||||
|
|
||||||
# Add empty items to fill grid after last cg button
|
|
||||||
extraSpaces = GALLERY_COLS - (lazy_counter % GALLERY_COLS)
|
return
|
||||||
for i in range(0, extraSpaces):
|
# 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({
|
galleryItems.append({
|
||||||
"item": None,
|
"item": None,
|
||||||
"cg": None,
|
"cg": None,
|
||||||
"ext": None
|
"ext": None
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
# Returns what params to call im.FactorScale with for cg button size
|
# Returns what params to call im.FactorScale with for cg button size
|
||||||
# Basically the delta diff dimensions
|
# Basically the delta diff dimensions
|
||||||
# (w: int; h: int) -> { x: float; y: float }
|
# (w: int; h: int) -> { x: float; y: float }
|
||||||
@ -134,38 +139,26 @@ init python:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## CG Gallery screen ########################################################
|
## CG Gallery screen ########################################################
|
||||||
## A screen that shows the image gallery
|
## A screen that shows the image gallery
|
||||||
screen cg_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
|
tag menu
|
||||||
use game_menu(_("Gallery"), scroll="viewport"):
|
use game_menu(_("Gallery"), scroll="viewport"):
|
||||||
|
|
||||||
fixed:
|
fixed:
|
||||||
$ pageItems = getGalleryPage(galleryPage)
|
grid GALLERY_COLS galleryRows:
|
||||||
$ galleryRows = len(pageItems) / GALLERY_COLS
|
spacing 20
|
||||||
$ maxPage = len(galleryItems) / GALLERY_CGS_PER_PAGE
|
for item in galleryItems:
|
||||||
vbox:
|
#very slow but once cached, it's 'OK', not ideal
|
||||||
hbox:
|
add g.make_button(item["item"], item["cg"], xalign = 0.5, yalign = 0.5)
|
||||||
grid GALLERY_COLS galleryRows:
|
# 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
|
|
||||||
|
Reference in New Issue
Block a user