How can I add a text prompt as a header to an in-game menu?

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
limpciabatta
Newbie
Posts: 13
Joined: Sun Feb 19, 2023 10:22 pm
Contact:

How can I add a text prompt as a header to an in-game menu?

#1 Post by limpciabatta »

I'm working on customizing my in-game menus, specifically how choice buttons are presented, and I'm curious if there's a way to incorporate a "choice prompt" as a header?

Here's what I currently have:

Code: Select all

menu: 
	"{color=#b3d56d}{u}Would you like to do anything else today?{/u}{/color}" #this is the "prompt" that appears in the dialogue box at the bottom of the screen
	"I want to go to the store": #this is the choice button that appears on the main screen
		play sound "choice.mp3" #this is the sound effect that plays when the user clicks the button
       		jump section_store #this is the action for jumping to another section
	"I want to go to the movies":
		play sound "choice.mp3"
        	jump section_movies
	"I want to hang out with one of my friends":
		play sound "choice.mp3"
        	jump section_friends
What I would like to have is to show the "prompt" text ("Would you like to do anything else today?") above the choice buttons that appear on the main screen, instead of below the buttons in the dialogue box at the bottom of the screen. I also have multiple in-game menus in my project, so ideally I'd love to have some kind of way that I can "plug in" different prompts associated with each menu, although I also don't mind going with a more manual solution.

Is something like this possible, and if so, how can I configure it?

Enormous thanks in advance!

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: How can I add a text prompt as a header to an in-game menu?

#2 Post by m_from_space »

limpciabatta wrote: Tue Feb 06, 2024 10:42 am What I would like to have is to show the "prompt" text ("Would you like to do anything else today?") above the choice buttons that appear on the main screen, instead of below the buttons in the dialogue box at the bottom of the screen.
By default, Renpy will show the "narrated text" of a menu as if being spoken by the narrator inside the dialogue window. Cou can change this behavior by setting...

Code: Select all

define config.narrator_menu = False
Here is the explanation: https://www.renpy.org/doc/html/config.h ... rator_menu

But you either have to use one or the other option for your game. Now of course you always can just re-design the whole choice screen, that you will find inside <screens.rpy>... But still, you either let the narrator speak your menu caption or show it somewhere else.

limpciabatta
Newbie
Posts: 13
Joined: Sun Feb 19, 2023 10:22 pm
Contact:

Re: How can I add a text prompt as a header to an in-game menu?

#3 Post by limpciabatta »

Thanks! It looks like putting define config.narrator_menu = False in the game script gave me the behavior that I was looking for. Although now I'm seeing the prompt/menu caption in the same style of text box that's being used for the menu, making it look like another menu option even though it's not. If I wanted to change the background for only the caption text, how would I go about doing that?

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: How can I add a text prompt as a header to an in-game menu?

#4 Post by m_from_space »

limpciabatta wrote: Tue Feb 06, 2024 11:32 am If I wanted to change the background for only the caption text, how would I go about doing that?
The caption is the item i, when the value of i.action is None. It's described here: https://www.renpy.org/doc/html/screen_s ... tml#choice

I'm not sure what your choice screens looks like, but here is a variant that shows the caption text inside a frame with some background color and all menu options as textbuttons.

Code: Select all

screen choice(items):
    vbox:
        for i in items:
            if i.action is None:
                frame:
                    background Solid("#555")
                    text i.caption
            else:
                textbutton i.caption action i.action

limpciabatta
Newbie
Posts: 13
Joined: Sun Feb 19, 2023 10:22 pm
Contact:

Re: How can I add a text prompt as a header to an in-game menu?

#5 Post by limpciabatta »

Thanks! I think that's getting me on the right track, although not quite exactly where I want to be. I've got a couple of basic mockups for what I currently have and what I'd like to do (they're low fidelity, just focusing on how I'd like to layout the buttons and the prompt):

What I currently have: https://drive.google.com/file/d/10C_nQy ... drive_link

What I would like to do: https://drive.google.com/file/d/1mha76r ... drive_link

For what I'd like to do, I figure I'll need to also change "style choice_vbox is vbox" in script.rpy to style choice_vbox is hbox", although is there a way that I can split out and center the prompt caption separately above the menu choices, like what I have in the mockup?

Post Reply

Who is online

Users browsing this forum: No registered users