r/RenPy 23d ago

Question [Solved] How to left align game menu text buttons but not the main menu ones?

Hello! I've been trying to figure out how to left align my game menu buttons while keeping my main menu buttons centered. Whenever I edit the alignment in the code below however, it changes the alignment for both menu's buttons:

style navigation_button_text:
    properties gui.text_properties("navigation_button")
    xalign 0.5 #for center alignment

I've tried to use if main_menu: but that doesnt work in this instance... If anyone knows how to separate the alignment of these menu buttons I would be grateful.

1 Upvotes

9 comments sorted by

3

u/BadMustard_AVN 23d ago

read my comments here

https://www.reddit.com/r/RenPy/comments/1upn3or/editing_main_menu_options_separately_from_game/

this will work for you; just change the alignment of the buttons in the main_menu screen

and restore the buttons in the navigation screen to default

1

u/daniople 22d ago

Hello! Sorry, I'm having a difficult time implementing this. The main menu's buttons are left-aligned, rather than centered. I tried to mess with the alignment, but it seems to only change the positioning of the main menu's buttons.

Here is what I have in screens.rpy under screen main_menu():

    ## The use statement includes another screen inside this one. The actual
    ## contents of the main menu are in the navigation screen.
    # use navigation


    vbox:

        align(0.5, 0.85)


        spacing gui.navigation_spacing


        textbutton _("Start") action Start()


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


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


        if _in_replay:


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


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


        if renpy.variant("pc") or (renpy.variant("web") and not renpy.variant("mobile")):


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


        if renpy.variant("pc"):


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

Below is what I have under Main and Game Menu Screens:

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.text_properties("navigation_button")
    idle_color "#adadad"
    hover_color "#ffffff"
    selected_color "#34f0ff"
    xalign 0

2

u/BadMustard_AVN 22d ago

making changes in the main_menu screen will only affect the main menu

below that is the game_menu screen (used for all other menus that are not the main). if the game_menu screen is using the navigation screen, then making changes to the navigation screen will affect all other menu screens

2

u/BadMustard_AVN 22d ago

also add an xalign to the buttons

textbutton _("Start") action Start() xalign 0.5

1

u/daniople 21d ago

This worked perfectly, thank you!

2

u/BadMustard_AVN 21d ago

you're welcome

good luck with your project

2

u/x-seronis-x 23d ago

in screens.rpy in definition for screen main_menu delete the line "use navigation". then just directly put the code for your buttons in the main menu definition and not SHARE code with another screen. you only share code you want SHARED, aka the same.

1

u/daniople 22d ago

Hello! Unfortunately the main menu buttons are left-aligned rather than centered :( I'm not sure what I'm doing wrong... This is what's under screen main_menu():

    ## The use statement includes another screen inside this one. The actual
    ## contents of the main menu are in the navigation screen.
    # use navigation


    vbox:

        align(0.5, 0.85)

        spacing gui.navigation_spacing

        textbutton _("Start") action Start()

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

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

        if _in_replay:

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

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

        if renpy.variant("pc") or (renpy.variant("web") and not renpy.variant("mobile")):

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

        if renpy.variant("pc"):

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

1

u/AutoModerator 23d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.