Last active
February 27, 2024 20:57
-
-
Save midgethetree/b210ddadfb07e85873022fde0202f646 to your computer and use it in GitHub Desktop.
Scrollbutton code for the Ren'Py visual novel engine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Example of the code in use ################################################## | |
screen game_menu(title, scroll=None, yinitial=0.0): | |
style_prefix "game_menu" | |
if main_menu: | |
add gui.main_menu_background | |
else: | |
add gui.game_menu_background | |
frame: | |
style "game_menu_outer_frame" | |
hbox: | |
## Reserve space for the navigation section. | |
frame: | |
style "game_menu_navigation_frame" | |
frame: | |
style "game_menu_content_frame" | |
has side 'c b' # use side to create space for the scrollbuttons | |
if scroll == "viewport": | |
viewport: | |
yinitial yinitial | |
scrollbars "vertical" | |
mousewheel True | |
draggable True | |
pagekeys True | |
id 'game_menu' # scrollbuttons can only scroll viewports if they're given an id | |
side_yfill True | |
vbox: | |
transclude | |
elif scroll == "vpgrid": | |
vpgrid: | |
cols 1 | |
yinitial yinitial | |
scrollbars "vertical" | |
mousewheel True | |
draggable True | |
pagekeys True | |
id 'game_menu' #midge | |
side_yfill True | |
transclude | |
else: | |
transclude | |
if scroll: # here is where the scrollbuttons themselves will go, if the screen is scrollable | |
hbox xalign 0.5 spacing 50: | |
scrollbutton _('Up') action Scroll('game_menu', 'vertical decrease', 'page') | |
scrollbutton _('Down') action Scroll('game_menu', 'vertical increase', 'page') | |
else: | |
null | |
use navigation | |
textbutton _("Return"): | |
style "return_button" | |
action Return() | |
label title | |
if main_menu: | |
key "game_menu" action ShowMenu("main_menu") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment