Ren'Py Can't put "main menu" buttons in a frame. Can this be fixed?

Avalonica

Newbie
Oct 11, 2017
40
20
Hello, often can the "basics" be the largest hurdles to overcome (really telling in my case).

Here is the code I want to inject into the "vanilla" menu:
PHP:
#================
# Placeholder
            frame:
                background Frame("gui/frame.png")
#===============

I would love to have a nice "frame" around this menu. The blue lines making a box represent a nice beautiful BIG frame.
frame.jpg

But I get this when trying to be smart... I had it all figured out. This is such a sad day... All pandas in China are crying now.
lol.jpg

Life is so cruel towards me sometimes... here is the code I poke in, but maybe I do it all wrong. The important thing is that frames works perfect in all other sections, it's just the main menu that makes issues. Same thing happened when I tried in a fresh Ren'py build. So it's definatly something with my code that's wrong...

PHP:
################################################################################
## Main and Game Menu Screens
################################################################################

## Navigation screen ###########################################################
##
## This screen is included in the main and game menus, and provides navigation
## to other menus, and to start the game.

screen navigation():


    vbox:
        style_prefix "navigation"

        xpos gui.navigation_xpos
        yalign 0.5

        spacing gui.navigation_spacing

        if main_menu:

#==============================================
# Here is where I placed my sweet code. What is it missing?!
            frame:
                background Frame("gui/frame.png")
#==============================================


            textbutton _("Start") action Start()

        else:

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

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

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

        textbutton _("Preferences") 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") 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)
Look here... works perfect on this box:
works here.jpg

Please, if anyone can clean up the code and maybe write some comments in the code so I can lean from it (in order to get better) please please do so. :cry:
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,963
16,199
Code:
#==============================================
# Here is where I placed my sweet code. What is it missing?!
            frame:
                background Frame("gui/frame.png")
#==============================================
What is missing is the style for this frame.
Look at the original screen, there's a line with this style_prefix "navigation"[/code], it tell you what will be used by Ren'py to style the screen ; each used style being made of [i]style_prefix[/i] + [i]_[/i] + [i]name of the screen statement[/i].

Therefore, here you need a style name [i]navigation_frame[/i] that will define the size of the frame and its position. Something like :
[code]
style navigation_frame is default:
xpos 50
yalign 0.6
xsize 300
ysize 600
[/code]

Use unren ([URL='https://f95zone.to/threads/3083/']windows[/URL] or [URL='https://f95zone.to/threads/16887']Linux/MacOS X[/URL]) to enable the developer mode, then when looking at Summertime Saga (if I recognized the screenshot correctly), put the mouse over the frame (but not over the button) and press [icode]SHIFT
+ i. It will open the displayable inspector and, by clicking on the name of the style you'll know (almost) all you need to know about the style of this frame.
 
  • Like
Reactions: Avalonica

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,808
24,388
in your code you show a frame with no content.
in your case the entire vbox of the navigation screen has to be the child of the frame.
you probably want something like this
Python:
screen navigation():

    frame:
        style_prefix "navigation"

        background Frame("gui/frame.png", Borders(5,5,5,5))
        padding (5,5,5,5)
        xpos gui.navigation_xpos
        yalign 0.5

        vbox:

            spacing gui.navigation_spacing

            if main_menu:

                textbutton _("Start") action Start()

            .
            .
            .
or define the style navigation_frame as described by anne O'nymous.
 
Last edited:
  • Like
Reactions: Avalonica

Avalonica

Newbie
Oct 11, 2017
40
20
Wonderful, just wonderful. Now everything works perfect! Thanks to both of you I also learned a bit more about xpos

Image4.png

Here is the code that fixed it all...

Code:
    frame:
        background Frame("gui/frame.png", Borders(50,50,50,50))
        xpos 20
        yalign 0.5
        xsize 300
        ysize 600
 
Last edited: