How can I put the choice title on top of the choices box?

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
Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

How can I put the choice title on top of the choices box?

#1 Post by Ryue »

I'm using the following choice screen code to display my choices. My problem is now that when I put a title for the menu in....it is not displayed on top.
Instead it is put onto the bottom.

How can I now put it on top of the menu?

Choice call:

Code: Select all

    menu:
        "What should I talk about?"
        
        "Tell me about the layout and the districts":
            pass
        
        "Tell me about the crime problem":
            pass
            
        "Tell me about GEN-Tech":
            pass
            
        "Enough of this. Let's start with the very beginning":
            pass
Screen code:

Code: Select all

screen choice(items):
    style_prefix "choice"
    
    default choiceToolTip = Tooltip("")
    default hasAtLeastOneToolTip = False
    
    frame:
        background Frame("Graphics/GUI/choices/choice_box.png")

        vbox:
            null height 5
            
            for i in items:
                #textbutton i.caption action i.action
                $captionEnd = i.caption.find("##")
                
                if (captionEnd<>-1):
                    $caption = i.caption[:captionEnd]
                    $toolTip = i.caption[captionEnd + 2:]
                    $hasAtLeastOneToolTip = True
                else:
                    $caption = i.caption
                    $toolTip = ""
                
                hbox:
                    xsize 1300
                    
                    frame:
                        background None
                        xysize 64, 64
                        xalign 0
                        xpos 10
                        #yalign 0.5
                        imagebutton:
                            idle "graphics/gui/choices/choice_idle.png" 
                            hover "graphics/gui/choices/choice_hover.png" 
                            selected_idle "graphics/gui/choices/choice_hover.png" 
                            selected_hover "graphics/gui/choices/choice_hover.png"
                            hovered [choiceToolTip.Action(toolTip)]
                            action i.action
                    frame:
                        background None
                        yalign 0.5
                        ysize 80
                        xsize 1200
                        text caption yalign 0.5
            if (hasAtLeastOneToolTip):
                text choiceToolTip.value + "\n" xalign 0.5 color "#EE0000"  size 18 italic True
            else:
                null height 20
These styles are not default

Code: Select all

style choice_vbox is vbox
style choice_vbox:
    spacing gui.choice_spacing

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: How can I put the choice title on top of the choices box

#2 Post by Ocelot »

First: set config.narrator_menu to False. This will make say statement inside menu to be sent as button with None action.

So in your choice screen you will need to catch button with action equal to None. Usually (always?) it would be the first one and use its caption as header.
Or just do nothing: buttons with None action would be displayed as inaktive buttons, so you can just style inactive state of choice button as you wish.
< < insert Rick Cook quote here > >

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: How can I put the choice title on top of the choices box

#3 Post by Ryue »

tnx that worked.

Is there any default "header" like style? else I wall make it per hand.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: How can I put the choice title on top of the choices box

#4 Post by Ocelot »

No, there isn't any. By default, title button is just a disabled button, nothing fancy.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Google [Bot]