Pivot menu

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
User avatar
liude
Newbie
Posts: 16
Joined: Fri Dec 18, 2009 9:42 am
Contact:

Pivot menu

#1 Post by liude » Mon Apr 19, 2010 5:50 pm

So, I'm trying to build a pivot menu that links to all the other menus. It shows up on to of the screen and presents the user with the menu links when called, but for some reason after you select quit or return from a menu it bounces you back to the title screen. Here is the script:

Code: Select all

init:
     python:
         def _menu_pivot(text, target):
             clicked = ui.jumps(target)
        

label _menu_pivot:
    
    # Show the menu background.
    scene 

     # Show the pivot menu in the middle of the screen.
    $ ui.vbox(xalign=0.5, yalign=0.5)

     # Show each link, using the menu function. The three arguments are:
     # - The text of a link.
     # - The label that we jump to if the menu is picked.
    $ _menu_pivot ("Save", "save")
    $ _menu_pivot ("Load", "load")
    $ _menu_pivot ("Close Menu", "end_menu_pivot")
    $ ui.close()
    $ ui.interact()

label end_menu_pivot:
    return
    
label save:
    $ renpy.game_menu("save_screen")
    return

label load:
    $ renpy.game_menu("load_screen")
    return

As for how to get to the menu i changed the keybinding for the game menu to it, so instead of a right click bringing up the sav screen it brings this menu up. If anyone could help me get this working i'd be very thankfull.

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Pivot menu

#2 Post by Aleema » Mon Apr 19, 2010 11:54 pm

liude wrote:So, I'm trying to build a pivot menu that links to all the other menus. It shows up on to of the screen and presents the user with the menu links when called, but for some reason after you select quit or return from a menu it bounces you back to the title screen.
You should be able to cut out the save/load/end labels and make the targets you send to menu_pivot "save_screen", "load_screen", and "_return", respectively. Sending the player to extra labels may be what's causing your problem?
liude wrote:As for how to get to the menu i changed the keybinding for the game menu to it, so instead of a right click bringing up the sav screen it brings this menu up. If anyone could help me get this working i'd be very thankfull.
You can also easily change the default menu for both ESC and right-clicking by setting this value to your custom screen:

Code: Select all

_game_menu_screen = "custom_screen"
P.S. I love your avatar. =P

User avatar
Alex
Lemma-Class Veteran
Posts: 2473
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Pivot menu

#3 Post by Alex » Tue Apr 20, 2010 1:59 pm

I think, the problem is in using <ui.jumps>. You make your game jumps to label "save", and when you click "return" button it tries to return, but there is no place to return... (hm...). Try <renpy.curried_call_in_new_context> - it will call menu in new context and then - will return back to your game context. (Someone correct me if I mistaken). This explains much much better http://www.renpy.org/wiki/renpy/doc/coo ... _Game_Menu

User avatar
liude
Newbie
Posts: 16
Joined: Fri Dec 18, 2009 9:42 am
Contact:

Re: Pivot menu

#4 Post by liude » Tue Apr 20, 2010 3:10 pm

Thanks for the replies, as i got the first one i tried to remove the labels and as it didn't work I remade the code from scratch. It works fine now, thanks for the idea. Here is the working code:

Code: Select all

init python:
    _game_menu_screen = "_menu_pivot"

label _menu_pivot:
    # Show the menu background.
    scene
        
    $ ui.window()
    #Darkens the scene in the background
    $ ui.fixed()
    $ ui.close()
    
    #Creates button area and adds text to the top
    $ ui.vbox(xalign=0.5, yalign=0.40)
    $ ui.text("Menu", xalign=0.5, yalign=0.33, size=35)
    
    #Defines what the menu will do when a button is clicked. This is defined in 3 steps:
    #Text that will be written in the button
    #What will happen when the button is clicked
    #Minimum width of the button
    $ ui.textbutton("Return to Game", clicked=ui.jumps("_return"), xminimum=400)
    $ ui.textbutton("Save", clicked=_intra_jumps("save_screen", "intra_transition"), xminimum=400)
    $ ui.textbutton("Load", clicked=_intra_jumps("load_screen", "intra_transition"), xminimum=400)
    $ ui.textbutton("Quit Game", clicked=ui.jumps("_quit_prompt"), xminimum=400)

    $ ui.close()
    $ choice = ui.interact(suppress_overlay=True)
You can use/modify this script to fit your needs, but some credit is always nice :wink:
As for placement, it should go at the bottom of the options.rpy file.
Also, if anyone wants to put it in the cookbook, go ahead :D

Post Reply

Who is online

Users browsing this forum: No registered users