Page 1 of 1

[Solved] Displacement between the game menus after I added a new screen

Posted: Thu Sep 16, 2021 10:29 am
by justsomenerd02
Hello I'm relatively new(ish?) to GUI customization in renpy and I need a bit of help, I might have messed up something.

I wanted to add a chapter select screen to the main menu but after I did, when I try to access the new screen or options. load, about etc from the main menu, the placement of the navigation is off compared to how it used to be. But only from the main menu, when I start a new game or select the chapter and access the navigation from there it looks like how it should. What went wrong here?

Here's how it should look like, as accessed from in-game:

https://imgur.com/8klTjsE

And here is what it looks like from the main menu

https://imgur.com/IPRj0IT

Shortening the chapter select option in the menu made the problem a lot less noticable but it's still there.

The navigation code:

Code: Select all

screen navigation():

    vbox:
        style_prefix "navigation"

        if renpy.get_screen("main_menu"):

            xalign 0.5
            yalign 0.6

        else:

            xpos gui.navigation_xpos
            yalign 0.5


        spacing gui.navigation_spacing

        if main_menu:

            textbutton _("Start") action Start()

            textbutton _("Chapters") action ShowMenu("chapters")

        else:

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

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

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

        textbutton _("Options") action ShowMenu("preferences")

        if _in_replay:

            textbutton _("End Replay") action EndReplay(confirm=True)

        elif not main_menu:

            textbutton _("Main Menu") action MainMenu()

        textbutton _("About") action ShowMenu("about")

        if renpy.variant("pc"):

            ## Help isn't necessary or relevant to mobile devices.
            textbutton _("Help") action ShowMenu("help")

            ## The quit button is banned on iOS and unnecessary on Android.
            textbutton _("Quit") action Quit(confirm=not main_menu)


style navigation_button is gui_button
style navigation_button_text is gui_button_text

style navigation_button:
    size_group "navigation"
    properties gui.button_properties("navigation_button")

style navigation_button_text:
    properties gui.button_text_properties("navigation_button")
    xalign 0.5

Re: Displacement between the game menus after I added a new screen

Posted: Fri Sep 17, 2021 3:03 am
by Ocelot

Code: Select all

    vbox:
        style_prefix "navigation"

        if renpy.get_screen("main_menu"):

            xalign 0.5
            yalign 0.6

        else:

            xpos gui.navigation_xpos
            yalign 0.5
Replace xpos gui.navigation_xpos with xalign 0.5

Re: Displacement between the game menus after I added a new screen

Posted: Fri Sep 17, 2021 3:27 am
by justsomenerd02
So replacing xpos gui.navigation_xpos with xalign unfortunately did not help the issue, if anything it made it worse.

https://imgur.com/N6IeJeE

Re: Displacement between the game menus after I added a new screen

Posted: Fri Sep 17, 2021 6:01 am
by Ocelot
Oh, I misread your problem. You just need to adjust gui.navigation_xpos in either gui.rpy or config.rpy so it would look well.

Re: Displacement between the game menus after I added a new screen

Posted: Fri Sep 17, 2021 11:41 am
by justsomenerd02
Thank you for the suggestion I try
Update: so in the meantime I found a workaround solution that managed to fix the issue: I added an offset parameter for it

Basically the code looks like this now:

Code: Select all

screen navigation():

    vbox:
        style_prefix "navigation"

        if renpy.get_screen("main_menu"):

            xalign 0.5
            yalign 0.6

        else:

            xpos gui.navigation_xpos
            yalign 0.5

        if main_menu:
            xoffset 0

        else:
            xoffset-5


This might not be the most efficient way but it did the job
Thank you for the help thought! I really appreciate it :)