[SOLVED] How to create a scrollable save/load menu (2 cols X 3 rows)

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
alexei
Regular
Posts: 137
Joined: Mon Sep 09, 2019 10:31 am
Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
Organization: Funigami
itch: funigami
Discord: alexei#5190
Contact:

[SOLVED] How to create a scrollable save/load menu (2 cols X 3 rows)

#1 Post by alexei »

I'm trying to create a scrollable save/load menu. Any idea how to achieve this?
Image
Here's the default renpy code.

Code: Select all

screen file_slots(title):

    default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))

    use game_menu(title):

        fixed:

            ## This ensures the input will get the enter event before any of the
            ## buttons do.
            order_reverse True

            ## The page name, which can be edited by clicking on a button.
            button:
                style "page_label"

                key_events True
                xalign 0.5
                action page_name_value.Toggle()

                input:
                    style "page_label_text"
                    value page_name_value

            ## The grid of file slots.
            grid gui.file_slot_cols gui.file_slot_rows:
                style_prefix "slot"

                xalign 0.5
                yalign 0.5

                spacing gui.slot_spacing

                for i in range(gui.file_slot_cols * gui.file_slot_rows):

                    $ slot = i + 1

                    button:
                        action FileAction(slot)

                        has vbox

                        add FileScreenshot(slot) xalign 0.5

                        text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
                            style "slot_time_text"

                        text FileSaveName(slot):
                            style "slot_name_text"

                        key "save_delete" action FileDelete(slot)

            ## Buttons to access other pages.
            hbox:
                style_prefix "page"

                xalign 0.5
                yalign 1.0

                spacing gui.page_spacing

                textbutton _("<") action FilePagePrevious()

                if config.has_autosave:
                    textbutton _("{#auto_page}A") action FilePage("auto")

                if config.has_quicksave:
                    textbutton _("{#quick_page}Q") action FilePage("quick")

                ## range(1, 10) gives the numbers from 1 to 9.
                for page in range(1, 10):
                    textbutton "[page]" action FilePage(page)

                textbutton _(">") action FilePageNext()

when I change the col/rows, no scrollbar is shown, hiding the last row. Any idea how to fix this? I tried a bunch of things but nothing worked.
Last edited by alexei on Thu Sep 22, 2022 3:49 am, edited 1 time in total.

User avatar
Syrale
Regular
Posts: 101
Joined: Sun Oct 25, 2015 10:28 am
Completed: Robot Daycare, Deep Sea Valentine, Locke(d)
Projects: Artificial Selection, Artificial Fashionista, rei_carnation
Github: kigyo
itch: kigyo
Discord: kigyodev
Contact:

Re: How to create a scrollable save/load menu (2 cols X 3 rows)

#2 Post by Syrale »

Try using a "vpgrid" instead of simply a "grid"
https://www.renpy.org/doc/html/screens.html?#vpgrid
ImageArtificial Selection (ongoing) |ImageDeep Sea Valentine | ImageRobot Daycare (NaNo19)
| ImageArtificial Fashionista (NaNo24)

My Developer Tools: Ren'Py Minimap/Location System | Ren'Py Word Counter+

alexei
Regular
Posts: 137
Joined: Mon Sep 09, 2019 10:31 am
Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
Organization: Funigami
itch: funigami
Discord: alexei#5190
Contact:

Re: How to create a scrollable save/load menu (2 cols X 3 rows)

#3 Post by alexei »

So here's how I did it. I added a viewport with a child size. You need to have both and specify their width and height.

Code: Select all

            fixed:

                ## This ensures the input will get the enter event before any of the
                ## buttons do.
                order_reverse True

                viewport:
                    child_size (1850, 1200)

                    scrollbars "vertical"

                    mousewheel True
                    draggable True

                    ## The grid of file slots.
                    grid gui.file_slot_cols gui.file_slot_rows:

                        style_prefix "slot"

                        xalign 0.90
                        yalign 0.28

                        spacing gui.slot_spacing

                        for i in range(gui.file_slot_cols * gui.file_slot_rows):

                            $ slot = i + 1

                            button:
                                action FileAction(slot)

                                has vbox

                                text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
                                    style "slot_time_text"

                                text FileSaveName(slot):
                                    style "slot_name_text"

                                add FileScreenshot(slot) xalign 0.5 ypos -20

                                key "save_delete" action FileDelete(slot)

                    ## Buttons to access other pages.
                    hbox:
                        style_prefix "page"

                        xalign 0.785
                        yalign 1.0

                        spacing gui.page_spacing

                        if config.has_autosave:
                            textbutton _("{#auto_page}A") action FilePage("auto")

                        if config.has_quicksave:
                            textbutton _("{#quick_page}Q") action FilePage("quick")

                        ## range(1, 9) gives the numbers from 1 to 8.
                        for page in range(1, 9):
                            textbutton "|[page]|" action FilePage(page)

Post Reply

Who is online

Users browsing this forum: No registered users