Customizing Menu Choices

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
TomDowd
Newbie
Posts: 3
Joined: Sun Oct 15, 2017 1:21 pm
Contact:

Customizing Menu Choices

#1 Post by TomDowd » Thu Oct 11, 2018 5:09 pm

With apologies, if the answer to this is right under my nose - I've been looking (and will continue to look) - but is it possible to customize the position of menu choice buttons, such as dialogue response choices, so that they can be anywhere on the screen? Right now they vertically stack in the center of the screen and I'd like to change that around. Is it possible?

Thanks in advance!

TD

User avatar
xavimat
Eileen-Class Veteran
Posts: 1336
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: Customizing Menu Choices

#2 Post by xavimat » Thu Oct 11, 2018 6:53 pm

The file screens.rpy has the screen choice, you can customize it as you need. You'll find some style choice... definitions below the screen.
Also gui.rpy has many definitions of styles applied to that screen and its elements, like spacing, positioning, width, etc. Look for the words "gui.choice_". There is an entire section for choice buttons.
You can adapt all of that as you wish.
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
unknown [Sci-Fi - mystery - computer]
Honest Critique (Avatar made with Chibi Maker by ~gen8)

TomDowd
Newbie
Posts: 3
Joined: Sun Oct 15, 2017 1:21 pm
Contact:

Re: Customizing Menu Choices

#3 Post by TomDowd » Fri Oct 12, 2018 11:27 am

Thank you - that was very helpful!

From looking at it and what properties are accessible it doesn't appear that there's any functionality for using the Menu system for anything other than a stacked set of choices - Is that accurate? I could not, for example, run them horizontally or control the individual location of choices (without ditching the Menu system and using custom buttons directly)?

Thanks again!

TD

rames44
Regular
Posts: 54
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Customizing Menu Choices

#4 Post by rames44 » Fri Oct 12, 2018 12:01 pm

If you wanted to change your whole game to, say, horizontal instead of vertical, you could edit screens.rpy (the “choice” screen) to use an hbox instead of a vbox.

When you use the “menu” command, what Ren’py does is show the “choice” screen and pass in your choices. How they are displayed is then entirely up to the “choice” screen definition, which you can edit to your hearts content. I’ve seen games that have a global variable to select different formats within the choice screen at different points in the game, for example. So, sky’s the limit, depending on how good you are with screen language.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1336
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: Customizing Menu Choices

#5 Post by xavimat » Fri Oct 12, 2018 5:28 pm

You can use a global variable, as rames44 suggest that affect the choice screen and its appearance.

Or you can create different choice screens:
- copy the original one to another named, for example, "choice2" and change the appearance in the copy.
- then use renpy.display_menu to invoke your menus (it's tricky to construct the options, but works). https://www.renpy.org/doc/html/statemen ... splay_menu
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
unknown [Sci-Fi - mystery - computer]
Honest Critique (Avatar made with Chibi Maker by ~gen8)

TomDowd
Newbie
Posts: 3
Joined: Sun Oct 15, 2017 1:21 pm
Contact:

Re: Customizing Menu Choices

#6 Post by TomDowd » Mon Oct 15, 2018 4:32 pm

Thanks! This all has helped tremendously, but I think I'm going to need a little bit more hand-holding...

Can you place a style block within an if statement? The answer seems to be no, since whenever I do that the code loads the second style block regardless of the value of the variable being tested. I have this:

Code: Select all

if NumChoices == 1:
        style choice_vbox: 
            ypos 100
    else: 
        style choice_vbox: 
            ypos 1000
Note that this is just to test the functionality. If I swap the 100 and 1000 value it's clear that the lower block is being read regardless of the value of NumChoices. NumChoices is set up (as default) elsewhere, not within a label.

What obvious thing am I missing? I'm guessing is that its how the use of style (if that's even appropriate) is handled. How then does one select different formats within the choice screen?

Thanks!

rames44
Regular
Posts: 54
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Customizing Menu Choices

#7 Post by rames44 » Tue Oct 16, 2018 12:29 pm

No, you can use “if” to conditionally define styles, since they’re set up before your game runs.

What you should do is to create two different styles, then inside your screen you can have an “if” statement that either puts something in with one style, or else something (possibly the same thing) with the other style.

Or, you can use a style that omits the item that differs, and use the “if” technique to apply the common style plus the item that varies.

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

Re: Customizing Menu Choices

#8 Post by Alex » Tue Oct 16, 2018 1:29 pm

TomDowd wrote:
Thu Oct 11, 2018 5:09 pm
.. is it possible to customize the position of menu choice buttons, such as dialogue response choices, so that they can be anywhere on the screen?...
Check this thread - viewtopic.php?f=8&t=52172#p497436

Post Reply

Who is online

Users browsing this forum: PyTom