Page 1 of 1

Multiple Styles of Choice Menus[solved]

Posted: Mon Apr 15, 2013 5:10 am
by drvoke
Hello!

FYI: Lowest level of newbie here. Like, looking at Python code still has a tendency to make my eyes cross and I haven't coded anything since QBASIC in 5th grade. I've got something that runs in Ren'Py but doesn't do anything interesting except define a couple characters, display some dialogue, give some choices, do easy work with conditionals, and that's pretty much it.

My question is this: Is there a way to create multiple styles of in-game choice menus, and how would I call them from within the game? For instance, if a character is asking you for a response, it might be fine to have the default choice menu that pops up in the center of the screen, but for hubs where you are just moving between areas or choosing people to talk to, you might want it off to the side or whatever.

I only know how to call up the default choice menu, and I can do modest changes to its style from options.rpy, but I can't even determine from the documentation if it's possible to do what I'm thinking, let alone how to implement it. I've taken a look at something that does something similar to what I want in the Ren'Py tutorial game (in demo_ui.rpy, the "day planner" screen and its choice box that lets you pick what to do at what time of day), but I'm having a hard time seeing how to adapt that to my purposes since it seems overly complicated for my purpose and its choices are hard coded where I need something arbitrary so I can re-use it in different locations with different choices.

Any guidance would be appreciated!

Re: Multiple Styles of Choice Menus

Posted: Mon Apr 15, 2013 5:59 am
by Ryue
From what you describe it sounds to me that you want what is called "screen" in renpy and different screens at that.

Am I correct that "moving between areas" would be made by clicking on a map (not sure from your description). That could be made with imagebuttons or imagemaps.


For the lists of people to talk to,... . There are a few possible ways to do it (so its possible). Can you detail a bit more HOW you would like to have it?
Thus is there a plain list at some part of the screen (fixed position of the list itself with dynamic elements in it), or do the list elements have different locations depending on where you are currently at, ....?
Thus something like this? http://i40.tinypic.com/2wbrw1v.jpg
(just with faces instead of locations....btw that is what I meant with imagemap)

Re: Multiple Styles of Choice Menus

Posted: Mon Apr 15, 2013 5:20 pm
by drvoke
Wolf wrote:From what you describe it sounds to me that you want what is called "screen" in renpy and different screens at that.

Am I correct that "moving between areas" would be made by clicking on a map (not sure from your description). That could be made with imagebuttons or imagemaps.


For the lists of people to talk to,... . There are a few possible ways to do it (so its possible). Can you detail a bit more HOW you would like to have it?
Thus is there a plain list at some part of the screen (fixed position of the list itself with dynamic elements in it), or do the list elements have different locations depending on where you are currently at, ....?
Thus something like this? http://i40.tinypic.com/2wbrw1v.jpg
(just with faces instead of locations....btw that is what I meant with imagemap)
Thanks for your reply,

It is the plain list I am talking about, not an imagemap. I know how to change its default position and style in options.rpy, but I want to know how to change its position/style only in certain circumstances.

So, it's fine to have the default style here:

Code: Select all

menu:
    character "A lovely day today, isn't it?"
    "Yes, it is...":
        jump agree_day
    "If you say so...":
        jump disagree_day
But in the following circumstance, for no reason other than style's sake, I may want the menu off to the side, or to change the size or look of the options:

Code: Select all

menu:
    "You're in the lobby of the Alan, Bailey & Schuster Law Firm.  There is an elevator here which will take you to the offices on the upper floors.\n
    Samantha is smiling at you from the reception desk."
    "Elevator":
        "You press the elevator call button and step inside when the doors open..."
        jump abs_elevator
    "Samantha":
        "You walk up to the reception desk and greet Samantha..."
        jump samantha_reception
    "Exit":
        "You walk back out into the city..."
        jump main_street
Thanks for your help!

Re: Multiple Styles of Choice Menus

Posted: Mon Apr 15, 2013 8:43 pm
by apricotorange
The way that choice menus are displayed is determined by "screen choice" (in screens.rpy). If you want the way it displays to vary, you can just use "if" statements inside the screen.

(Strictly speaking, that isn't the only way to do it, but it's the most straightforward.)

Re: Multiple Styles of Choice Menus

Posted: Mon Apr 15, 2013 11:13 pm
by drvoke
apricotorange wrote:The way that choice menus are displayed is determined by "screen choice" (in screens.rpy). If you want the way it displays to vary, you can just use "if" statements inside the screen.

(Strictly speaking, that isn't the only way to do it, but it's the most straightforward.)
Oh, that is clever...! Thank you so much for the help! Are there any guides on how to accomplish this? Where would I put the conditionals? The statements controlling some of the behavior I want to modify are in a init python: block, while others are in the screen choice: block.

Re: Multiple Styles of Choice Menus

Posted: Tue Apr 16, 2013 4:07 pm
by apricotorange
You put the if statement in the "screen choice".

I assume the parts in the "init python" block are styles? In that case, you just need to introduce some new styles: e.g. 'style "alt_menu_window"' instead of 'style "menu_window"' on one branch of the if statement. Or, since you're editing the screen anyway, you can just write the styles straight into the screen (e.g. buttons on screens support a "background" property which overrides any background style).

Re: Multiple Styles of Choice Menus

Posted: Thu Apr 18, 2013 2:06 am
by drvoke
Just wanted to follow up and say that this was all very helpful. I am now able to get the functionality I needed, and everything works as needed. Its probably not the prettiest way, but I couldn't have done it without the assistance here. It's led to me figuring out how to implement other behaviors as well.

Thanks for the help!

Also, when I get home where my files are I will post the code I used to achieve the result for anyone who may be searching for the same issue and comes upon this post.

Never mind, I see there are no collapse tags, and I don't know what the rules about posting long blocks of code out in the open are, so I'll leave it for now.

For anyone interested in a shorter version, this is basically what I've done. Code criticism welcome:

Code: Select all

##########Wherever you initialize your variables
init:
    $ hubmenu = False


##########Making the choice menu conditional in screens.rpy
screen choice:
    if hubmenu: ################# If the variable is set to True, use this style,
        window:                 #
            style "menu_window" #       
            xalign 0.0          # Positioned and aligned in this way,
            yanchor 1.0         #
            ypos 0.68           #
                                #
            vbox:               #
                style "menu"    #
                spacing 2       #
                                #############################
                for caption, action, chosen in items:       #
                                                            #
                    if action:                              #
                                                            #
                        button:                             #
                            action action                   #
                            style "hmenu_choice_button"     # Using this alternate button style.
                            text caption style "menu_choice"
                        
                    else:
                        text caption style "menu_caption"
    else: ## For everything else, use the default style included in screens.rpy
        window:
            . . .
            . . .
            
init -2 python:  ## at the bottom of the same section, where the styles are designated, I create
                 ## the style and necessary properties referenced by the alternate menu screen.

    style.hmenu_choice_button.xminimum = int(config.screen_width * 0.25)
    style.hmenu_choice_button.xmaximum = int(config.screen_width * 0.25)


##########Using it in a scene:
label outside_woodhill:
    $ hubmenu = True  ## I want the alternate menu style here, so set the variable to True
    menu:
        "Item 1":
            jump another_hub
        "Item 2":
            $ hubmenu = False  ## Turning the alternate menu style off in advance of moving to a scene that doesn't need the alternate menu style
            jump not_another_hub
Thanks again!