Is there any way to define button styles in choice menus?

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
User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Is there any way to define button styles in choice menus?

#1 Post by namastaii »

With a menu like:

menu:
"choice 1":
blah
"choice 2":
blah blah

Is there anyway to tell individual choices to be a specific button style? Like "choice 1" has a different button style than "choice 2" does? Is this even possible? And how would you do it? If not...is there any way to customize individual menus as a whole to go to certain button styles? I already have the button styles, I was just trying to do something specific and not sure how to do it.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Is there any way to define button styles in choice menus

#2 Post by PyTom »

No, you basically have to use a screen to do this.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Is there any way to define button styles in choice menus

#3 Post by namastaii »

Okay. I guess I could do an imagemap. Thanks^^

Kinsman
Regular
Posts: 130
Joined: Sun Jul 26, 2009 7:07 pm
Location: Fredericton, NB, Canada
Contact:

Re: Is there any way to define button styles in choice menus

#4 Post by Kinsman »

If you want to use a screen, you can get what you want with a little bit of Python code.

This code takes the regular choice screen and adds a few lines:

Code: Select all

screen choice(items):

    window:
        style "menu_window"
        xalign 0.5
        yalign 0.5

        vbox:
            style "menu"
            spacing 2

            for caption, action, chosen in items:
                
                python:
                    captionelements = caption.split("/")
                    if len(captionelements) > 1:
                        caption = captionelements[1]
                        menubuttonstyle = captionelements[0]
                    else:
                        menubuttonstyle = "menu_choice_button"

                if action:

                    button:
                        action action
                        #style "menu_choice_button"
                        style menubuttonstyle

                        text caption style "menu_choice"

                else:
                    text caption style "menu_caption"
When going through the menu items, it will break apart the text and look a forward slash(/). If it finds one, it takes what's to the left of the slash as a style name.

Code: Select all

init -2:
        
    style menu_choice_button_blue is menu_choice_button:
        background "#00f"
    style menu_choice_button_green is menu_choice_button:
        background "#0f0"

label start:

    e "Menu Test!"
    
    menu:
        "Here's a basic option":
            jump after_menu
        "menu_choice_button_blue/Here's a bluish option":
            jump after_menu
        "menu_choice_button_green/Here's a greenish option":
            jump after_menu

label after_menu:
    
    e "Good choice!"

    return
Flash To Ren'Py Exporter
See the Cookbook thread

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Is there any way to define button styles in choice menus

#5 Post by namastaii »

Thanks I should try that out.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]