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

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
justsomenerd02
Newbie
Posts: 3
Joined: Wed Feb 13, 2019 6:57 am
Contact:

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

#1 Post 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
Last edited by justsomenerd02 on Fri Sep 17, 2021 11:43 am, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2376
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

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

#2 Post 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
< < insert Rick Cook quote here > >

justsomenerd02
Newbie
Posts: 3
Joined: Wed Feb 13, 2019 6:57 am
Contact:

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

#3 Post 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

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2376
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

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

#4 Post 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.
< < insert Rick Cook quote here > >

justsomenerd02
Newbie
Posts: 3
Joined: Wed Feb 13, 2019 6:57 am
Contact:

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

#5 Post 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 :)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], myself600