[SOLVED] Can't dismiss custom screen attached to main menu

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
User avatar
Kaji
Regular
Posts: 87
Joined: Thu Nov 17, 2022 10:17 pm
Github: Kaji01
Discord: Kaji#7767
Contact:

[SOLVED] Can't dismiss custom screen attached to main menu

#1 Post by Kaji »

So I'm developing a collection of stories, and wanted a screen where the player could see the index displayed, similar to the save slot view, but with our stories listed in there, and with a scrolling view instead of several pages.

I managed to mostly figure out how to reverse-engineer it based on the save slots screen in screens.rpy, however what I'm finding is that it's not allowing me to dismiss the screen if I don't want to make a selection—once you select this screen, you will make a choice or else you'll have to force-quit the app. Clicking on the main menu choices does nothing; neither does the Return button.

I've consulted the original screen's code to see if there is something I'm missing, but I can't see what the issue might be, unless perhaps there's just something inherent to the scrollable area that's getting in the way.

The following is the complete code for the screen, along with some seed data to display on it.

Code: Select all

init python:
    import math

    # Define our story list here
    stories = [
        {
            "title": "Jugemu",
            "prefix": "jugemu",
            "summary": "What to name the kid?"
        },
        {
            "title": "Binbougami",
            "prefix": "binbougami",
            "summary": "Who is lazier?"
        },
        {
            "title": "Tairabayashi",
            "prefix": "tairabayashi",
            "summary": "Can anyone read this?"
        },
        {
            "title": "Amidaike",
            "prefix": "amidaike",
            "summary": "A joke goes too far"
        },
    ]

screen story_list():

    default page_name_value = FilePageNameInputValue(_("Story List"))

    use game_menu(_("Story List")):

        viewport:
            scrollbars "vertical"
            mousewheel True
            arrowkeys True

            vbox:

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

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

                    xalign 0.5
                    yalign 0.5

                    spacing gui.slot_spacing

                    for i in range(story_grid_cells):

                        if (i < len(stories)):

                            button:
                                action Start(stories[i]["prefix"] + "_start") ## Start telling story from Label in string

                                has vbox

                                add im.Scale("bg temple outside.png", config.thumbnail_width, config.thumbnail_height) xalign 0.5

                                text stories[i]["title"]:
                                    style "slot_time_text"

                                text stories[i]["summary"]:
                                    style "slot_name_text"
                        else: ## Create an empty button

                            button:
                                has vbox

                                add im.Scale("bg home.jpg", config.thumbnail_width, config.thumbnail_height) xalign 0.5

                                text "":
                                    style "slot_time_text"

                                text "":
                                    style "slot_name_text"
And this is the code where I inject it into the main menu:

Code: Select all

screen navigation():

    vbox:
        style_prefix "navigation"

        xpos gui.navigation_xpos
        yalign 0.5

        spacing gui.navigation_spacing

        if main_menu:

            textbutton _("Start") action Start()

        else:

            textbutton _("History") action ShowMenu("history")

            textbutton _("Save") action ShowMenu("save")

            textbutton _("Load") action ShowMenu("load")

            textbutton _("Story List") action ShowMenu("story_list") # Added item here

            textbutton _("Glossary") action ShowMenu("glossary")

            textbutton _("Preferences") action ShowMenu("preferences")
            
            ...
Last edited by Kaji on Tue Nov 22, 2022 8:49 am, edited 1 time in total.

User avatar
Kaji
Regular
Posts: 87
Joined: Thu Nov 17, 2022 10:17 pm
Github: Kaji01
Discord: Kaji#7767
Contact:

Re: Can't dismiss custom screen attached to main menu

#2 Post by Kaji »

Pinky! from the Discord picked up on the mistake here. Need to add

Code: Select all

tag menu
to the top of the screen function in order to connect the menu properly.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]