I have grid with one row and eight columns (technically six, but with an extra two on the left and right respectively to create null space to keep all the items centered), and within this grid are imagebuttons. each opens a screen to display some options, but if that screen is closed, the viewport scrolls itself by a small amount? this does not happen with an hbox in place of the grid, however the grid is necessary for a certain effect unrelated to this (done via atl) to function correctly. is there something i'm doing wrong? below is my code for review.
default current_chapter = 1
default ch1_selected = False
default ch2_selected = False
default ch3_selected = False
default ch4_selected = False
default ch5_selected = False
default ch6_selected = False
screen chapter_select():
tag menu
on "show":
action [SetVariable("ch1_selected", False),
SetVariable("ch2_selected", False),
SetVariable("ch3_selected", False),
SetVariable("ch4_selected", False),
SetVariable("ch5_selected", False),
SetVariable("ch6_selected", False)]
add "gui/bgs/genericbg.png"
use game_menu(_("CHAPTER SELECT")):
side 'c':
pos (-325, -100) xysize (1920, 1080)
controller_viewport:
mousewheel True draggable renpy.variant("touch")
id "viewport_chapter_select" hscroll_style "center"
scroll_delay (0.5, 0.0)
trap_focus ("up", "down", "left", "right")
scroll_warper "easein"
grid 8 1:
spacing 400
add "gui/chapter_select/card_empty.png" xalign 0.5 yalign 0.45
imagebutton:
xalign 0.5
yalign 0.45
if current_chapter == 1:
default_focus True
auto "gui/chapter_select/card_ch1_%s.png"
action [SetVariable("ch1_selected", True), Show("chapter_confirm")]
at (cardfliphide if ch1_selected else cardflipshow)
hovered SetVariable("current_chapter", 1)
hover_sound "sfx/menu_hover.ogg"
activate_sound "sfx/menu_select.ogg"
imagebutton:
xalign 0.5
yalign 0.45
if persistent.ch2_unlocked == True:
if current_chapter == 2:
default_focus True
auto "gui/chapter_select/card_ch2_%s.png"
action [SetVariable("ch2_selected", True), Show("chapter_confirm")]
else:
idle "gui/chapter_select/locked.png"
action NullAction()
at (cardfliphide if ch2_selected else cardflipshow)
hovered SetVariable("current_chapter", 2)
hover_sound "sfx/menu_hover.ogg"
activate_sound "sfx/menu_select.ogg"
imagebutton:
xalign 0.5
yalign 0.45
if persistent.ch3_unlocked == True:
if current_chapter == 3:
default_focus True
auto "gui/chapter_select/card_ch3_%s.png"
action [SetVariable("ch3_selected", True), Show("chapter_confirm")]
else:
idle "gui/chapter_select/locked.png"
action NullAction()
at (cardfliphide if ch3_selected else cardflipshow)
hovered SetVariable("current_chapter", 3)
hover_sound "sfx/menu_hover.ogg"
activate_sound "sfx/menu_select.ogg"
imagebutton:
xalign 0.5
yalign 0.45
if persistent.ch4_unlocked == True:
if current_chapter == 4:
default_focus True
auto "gui/chapter_select/card_ch4_%s.png"
action [SetVariable("ch4_selected", True), Show("chapter_confirm")]
else:
idle "gui/chapter_select/locked.png"
action NullAction()
at (cardfliphide if ch4_selected else cardflipshow)
hovered SetVariable("current_chapter", 4)
hover_sound "sfx/menu_hover.ogg"
activate_sound "sfx/menu_select.ogg"
imagebutton:
xalign 0.5
yalign 0.45
if persistent.ch5_unlocked == True:
if current_chapter == 5:
default_focus True
auto "gui/chapter_select/card_ch5_%s.png"
action [SetVariable("ch5_selected", True), Show("chapter_confirm")]
else:
idle "gui/chapter_select/locked.png"
action NullAction()
at (cardfliphide if ch5_selected else cardflipshow)
hovered SetVariable("current_chapter", 5)
hover_sound "sfx/menu_hover.ogg"
activate_sound "sfx/menu_select.ogg"
imagebutton:
xalign 0.5
yalign 0.45
if persistent.ch6_unlocked == True:
if current_chapter == 6:
default_focus True
auto "gui/chapter_select/card_ch6_%s.png"
action [SetVariable("ch6_selected", True), Show("chapter_confirm")]
else:
idle "gui/chapter_select/locked.png"
action NullAction()
at (cardfliphide if ch6_selected else cardflipshow)
hovered SetVariable("current_chapter", 6)
hover_sound "sfx/menu_hover.ogg"
activate_sound "sfx/menu_select.ogg"
add "gui/chapter_select/card_empty.png" xalign 0.5 yalign 0.45
screen chapter_confirm():
modal True
frame:
background None
add "gui/chapter_select/card_back.png" xalign 0.501 yalign 0.498
align (0.5, 0.5)
at cardflipcombined
vbox:
xalign 0.5
yalign 0.5
spacing 10
if current_chapter == 1:
text "Would you like to play\nChapter One?" textalign 0.5 style "btn_generic" color "#fff"
if current_chapter == 2:
text "Would you like to play\nChapter Two?" textalign 0.5 style "btn_generic" color "#fff"
if current_chapter == 3:
text "Would you like to play\nChapter Three?" textalign 0.5 style "btn_generic" color "#fff"
if current_chapter == 4:
text "Would you like to play\nChapter Four?" textalign 0.5 style "btn_generic" color "#fff"
if current_chapter == 5:
text "Would you like to play\nChapter Five?" textalign 0.5 style "btn_generic" color "#fff"
if current_chapter == 6:
text "Would you like to play\nChapter Six?" textalign 0.5 style "btn_generic" color "#fff"
textbutton _("Yes"):
at btn_grow
default_focus True
xalign 0.5
text_style "btn_generic"
if current_chapter == 1:
action Start("ch1_start")
if current_chapter == 2:
action Start("ch2_start")
if current_chapter == 3:
action Start("ch3_start")
if current_chapter == 4:
action Start("ch4_start")
if current_chapter == 5:
action Start("ch5_start")
if current_chapter == 6:
action Start("ch6_start")
textbutton _("No"):
at btn_grow
xalign 0.5
text_style "btn_generic"
action [SetVariable("ch1_selected", False), SetVariable("ch2_selected", False), SetVariable("ch3_selected", False), SetVariable("ch4_selected", False), SetVariable("ch5_selected", False), SetVariable("ch6_selected", False), Hide("chapter_confirm")]
key "rollback" action [SetVariable("ch1_selected", False), SetVariable("ch2_selected", False), SetVariable("ch3_selected", False), SetVariable("ch4_selected", False), SetVariable("ch5_selected", False), SetVariable("ch6_selected", False), Hide("chapter_confirm")]