Moving choice menu options per screen. [SOLVED]

Knyghtblade

Newbie
Nov 3, 2017
63
14
Sorry if I am posting too many questions, I searched but don't seem to find a specific solution. If I am over posting please let me know and I will stop.

The issue I am experiencing is that most of the choice menus in my game appear in a location that is fine and doesnt block anything, but on one screen it totally blocks the render. Is there a way to relocate menu choices on a per screen basis or is it all or nothing via the gui.rpy script?

Cheers
 
Last edited:

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,584
2,227
Is there a way to relocate menu choices on a per screen basis?

Yes.

By default, when you use menu: it uses the screen choice(): as defined within the screens.rpy file.

But you can override things for specific menu: statements to use a different screen or to pass parameters to the choices screen. (for example, you could pass it a set of coordinates for where you want the menu to appear, but let those default to the current location if you don't specify them).

I'm only going to describe the "use a different screen" solution though, as I think it's simpler when you're just starting out.

So first, I create my "alternative" choices menu. I'm going with the imaginatively named alt_choice.

Python:
screen alt_choice(items):
    style_prefix "alt_choice"

    vbox:
        for i in items:
            if i.action:
                if i.kwargs and i.kwargs.get( "enabled" ) is False:
                    textbutton i.caption action NullAction() sensitive False
                else:
                    textbutton i.caption action i.action
            else:
                textbutton i.caption


style alt_choice_vbox is vbox
style alt_choice_button is button
style alt_choice_button_text is button_text

style alt_choice_vbox:
    xalign 0.1
    ypos 270
    yanchor 0.5

    spacing gui.choice_spacing

style alt_choice_button is default:
    properties gui.button_properties("alt_choice_button")

style alt_choice_button_text is default:
    properties gui.button_text_properties("alt_choice_button")

All I have done is copy the existing screen choice(): and alter the xalign for the vbox to be 0.1 instead of 0.5. This means the menu choices appear nearer the left edge of the screen rather than in the middle. You, of course, could alter it in any way you like.

Edit: Actually, it's not exactly the same as the "normal" choices screen. But you get the idea.

Now... when I want to use this alternative menu, I just need to code things to say "use THIS menu screen, instead of the normal one".

Python:
    menu (screen="alt_choice"):
        "Option 1":
            "You picked option 1."
        "Option 2":
            "You picked option 2."
        "Option 3":
            "You picked option 3."

    return

There's a whole lot of new things you need to learn about in order to customize things. But this is the basics on how to start.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,384
15,294
Python:
    menu (screen="alt_choice"):
It's interesting, but there's another way, that will not need a second screen and that will also offer more flexibility.

The menu statement accept all the parameters you want... as long as they are in the "choice" screen declaration. Therefore, instead of changing the screen, you can just change the coordinate:

Python:
# Add two named arguments, "x" and "y", both optional.
screen choice(items, x=None, y=None ):
    style_prefix "choice"

    vbox:
        # If 'x' have a value, it will be used as position
        if x:
            xpos x
        # Else use the default alignment.
        else:
            xalign 0.5

        # Same for 'y'
        if y:
            ypos y
        else:
            ypos 405
            yanchor 0.5

        # Then the menu as usual
        for i in items:
                textbutton i.caption action i.action

# Need to be changed in order to not have the position in it
style choice_vbox:
#    xalign 0.5
#    ypos 405
#    yanchor 0.5
    spacing gui.choice_spacing
And now you can either have the menu at its default location:
Code:
label whatever:
    menu:
        "choice 1":
            pass
        "choice 2":
            pass
more on the left :
Code:
label whatever:
    menu( x=100 ):
        "choice 1":
            pass
        "choice 2":
            pass
more on the top :
Code:
label whatever:
    menu( y=100 ):
        "choice 1":
            pass
        "choice 2":
            pass
Or at a personalized position :
Code:
label whatever:
    menu( x=123, y=321 ):
        "choice 1":
            pass
        "choice 2":
            pass
You can now cover all the possibilities, even the one you haven't thought about yet, with a single screen.