Loopable Screens between different folders

This commit is contained in:
nutbuster 2021-07-18 07:55:49 +10:00
parent 24324ec3ed
commit c4f95dd7c6
2 changed files with 47 additions and 29 deletions

View file

@ -1137,7 +1137,7 @@ screen extrasnavigation():
[ "Help", ShowMenu("help") ], [ "Help", ShowMenu("help") ],
[ "About", ShowMenu("about") ], [ "About", ShowMenu("about") ],
[ "Updates", ShowMenu("updates") ], [ "Updates", ShowMenu("updates") ],
[ "Gallery", ShowMenu("cg_gallery") ], [ "Gallery", ShowMenu("cg_gallery_0") ],
[ "Return", ShowMenu("main_menu") ] [ "Return", ShowMenu("main_menu") ]
] ) ] )

View file

@ -10,10 +10,9 @@ init python:
NOT_UNLOCKED_COVER = im.FactorScale("gui/gallery/unlocked_cg_button_cover.png", DEFAULT_WIDTH_SCALE_RATIO, DEFAULT_HEIGHT_SCALE_RATIO) NOT_UNLOCKED_COVER = im.FactorScale("gui/gallery/unlocked_cg_button_cover.png", DEFAULT_WIDTH_SCALE_RATIO, DEFAULT_HEIGHT_SCALE_RATIO)
ACCEPTED_EXTENSIONS = ["jpg", "png"] ACCEPTED_EXTENSIONS = ["jpg", "png"]
CG_PATHS = [ CG_PATHS = [
{ 'path': "images/cgs/", 'name': "CG", 'eval': None #CG doesn't really make sense
}, #CG doesn't really make sense { 'path': "images/cgs/", 'name': "CG", 'eval': None },
{ 'path': "images/animations/", 'name': "Animations", 'eval': None #{ 'path': "images/animations/", 'name': "Animations", 'eval': None },
},
{ 'path': "images/NotForKids!/", 'name': "Lewd", { 'path': "images/NotForKids!/", 'name': "Lewd",
'eval': 'presistent.lewd == True' 'eval': 'presistent.lewd == True'
} }
@ -25,8 +24,9 @@ init python:
item is name, fn is fullpath item is name, fn is fullpath
ext is the file extension ext is the file extension
{ item: string; fn: string, cg: Displayable; ext: string }[] { item: string; fn: string, cg: Displayable; ext: string }[]
(reference in this init python, actually used in screens)
""" """
galleryItems = [] gallery_items = []
# key dict pair, cg <-> cgs' galleryitems [] # key dict pair, cg <-> cgs' galleryitems []
gallery_dic = {} # gallery_dic = {} #
@ -80,11 +80,22 @@ init python:
# Call to loading the gallery # Call to loading the gallery
loadGallery() loadGallery()
"""
'Recursive' / Loopable / Roundtrip Screens
_0 <-> _1
"""
screen cg_gallery_0(__yoffset = 0, origin = 'CG'):
tag menu
use cg_gallery('1', __yoffset, origin)
screen cg_gallery_1( __yoffset = 0, origin = 'CG'):
tag menu
use cg_gallery('0', __yoffset, origin)
""" """
CG Gallery screen - A screen that shows the image gallery CG Gallery screen - A screen that shows the image gallery
Basically Gallery Object has terrible defaults, so I just wrote my own stuff Basically Gallery Object has terrible defaults, so I just wrote my own stuff
""" """
screen cg_gallery(__yoffset = 0): screen cg_gallery(flag, __yoffset = 0, origin = 'CG'):
style_prefix "game_menu" style_prefix "game_menu"
if main_menu: if main_menu:
@ -93,17 +104,19 @@ screen cg_gallery(__yoffset = 0):
add gui.main_menu_background add gui.main_menu_background
add gui.game_menu_background add gui.game_menu_background
python:
galleryItems = gallery_dic["CG"]
items = len(galleryItems)
galleryRows = (items / GALLERY_COLS) + 1
extraSpaces = GALLERY_COLS - (items % GALLERY_COLS)
item_counter = 0
tag menu tag menu
frame:
style "game_menu_outer_frame"
python:
empty_spaces = gallery_rows = item_counter = 0
gallery_items = gallery_dic[origin]
items = len(gallery_items)
gallery_rows = (items / GALLERY_COLS) + 1
empty_spaces = GALLERY_COLS - (items % GALLERY_COLS)
frame:
style "game_menu_outer_frame"
viewport: viewport:
yinitial __yoffset yinitial __yoffset
scrollbars "vertical" scrollbars "vertical"
@ -112,8 +125,8 @@ screen cg_gallery(__yoffset = 0):
pagekeys True pagekeys True
xpos 440 xpos 440
grid GALLERY_COLS galleryRows: grid GALLERY_COLS gallery_rows:
for item in galleryItems: for item in gallery_items:
# Should properly fix with actual margin difference but good # Should properly fix with actual margin difference but good
# enough or the actual position # enough or the actual position
python: python:
@ -121,9 +134,9 @@ screen cg_gallery(__yoffset = 0):
yoffset = item_counter / 3 * PREFERRED_HEIGHT * 1.15 yoffset = item_counter / 3 * PREFERRED_HEIGHT * 1.15
yoffset = int( yoffset + (PREFERRED_HEIGHT * 1.15)) yoffset = int( yoffset + (PREFERRED_HEIGHT * 1.15))
use flag_button(item, yoffset) use flag_button(item, yoffset, origin)
for i in range(0, extraSpaces): for i in range(0, empty_spaces):
null height 20 null height 20
vbox: vbox:
@ -133,10 +146,15 @@ screen cg_gallery(__yoffset = 0):
spacing gui.navigation_spacing spacing gui.navigation_spacing
textbutton _("CG")
textbutton _("NotForKids!") for cp in CG_PATHS:
textbutton _("Animations") #gallery_dic[cp['name']] = [] #
textbutton _("Return") action Return() if cp['name'] is origin:
textbutton _(cp['name'])
else:
textbutton _(cp['name']) action ShowMenu('cg_gallery_'+flag, 0, cp['name'])
#textbutton _(cp['name']) action set_reflow(origin, cp['name'], gallery_rows, empty_spaces)
textbutton _("Return") action ShowMenu('main_menu')
if _in_replay: if _in_replay:
textbutton _("End Replay") action EndReplay(confirm=True) textbutton _("End Replay") action EndReplay(confirm=True)
@ -150,12 +168,12 @@ screen cg_gallery(__yoffset = 0):
""" """
if/else flow control & extra parameters for Buttons if/else flow control & extra parameters for Buttons
""" """
screen flag_button(item, yoffset): screen flag_button(item, yoffset, origin):
python: python:
flag = renpy.seen_image(item['item']) flag = renpy.seen_image(item['item'])
if flag: if flag:
button: button:
action ShowMenu('view_image', item['fn'], ShowMenu('cg_gallery', yoffset)) action ShowMenu('view_image', item['fn'], ShowMenu('cg_gallery_0', yoffset, origin))
xcenter 0.5 ycenter 0.5 xcenter 0.5 ycenter 0.5
vbox: vbox:
text item["item"] xalign 0.5 text item["item"] xalign 0.5
@ -170,12 +188,12 @@ screen flag_button(item, yoffset):
""" """
view_image, Loads the image in fullscreen with viewport control. view_image, Loads the image in fullscreen with viewport control.
""" """
screen view_image(fn, origin): screen view_image(fn, _origin):
tag menu tag menu
key "game_menu" action origin key "game_menu" action _origin
viewport: viewport:
#Ren'Py is isn't smart enough to not edgescroll while pressed, so we'll have to disable this for mobile #Ren'Py is isn't smart enough to not edgescroll while pressed, so we'll have to disable this for mobile
edgescroll (300, 800) edgescroll (300, 1800)
draggable True draggable True
arrowkeys True arrowkeys True
pagekeys True pagekeys True