choice button

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
DragonKnight
Regular
Posts: 51
Joined: Sun Nov 12, 2017 10:16 am
Projects: Taboo Hearts
Contact:

choice button

#1 Post by DragonKnight »

How do i make choice button different colors in the same choice
Image1.png
Currently working on Taboo Hearts :D
Currently working on Forbidden :D

irredeemable
Regular
Posts: 78
Joined: Thu Feb 08, 2018 7:57 am
Contact:

Re: choice button

#2 Post by irredeemable »

Use the {color} tag.

Code: Select all

menu:
    "{color=#FF0000}Red,{/color} {color=#00FF00}Greeen{/color}, {color=#0000FF}Blue.{/color}":
        "Oooh, shiny."

irredeemable
Regular
Posts: 78
Joined: Thu Feb 08, 2018 7:57 am
Contact:

Re: choice button

#3 Post by irredeemable »

Oh, if you mean changing the actual button then you'll have to change the choice screen in screens.rpy:

Code: Select all

screen choice(items):
    style_prefix "choice"


    vbox:
        for i in items:
                textbutton i.caption action i.action
You'll have to pass the screen some kind of indication that you want to use a different background, the simplest way is simply to include your own tag in the caption. You'll also need to either create your own background for the button or use an image manipulator to recolor the default renpy background (obviously this is much less efficient, but I'm doing it here just for an example that will work 'out of the box'). For example, here I recolor the default choice button background to red (and the hover_background to a light grey) if the string '(red)' is in the choice caption:

Code: Select all

screen choice(items):
    style_prefix "choice"


    vbox:
        for i in items:
            if '(red)' in i.caption:
                textbutton i.caption.replace("(red)", "") action i.action:
                    idle_background im.MatrixColor("gui/button/choice_idle_background.png", im.matrix.colorize("#ff0000", "#ff0000"))
                    hover_background im.MatrixColor("gui/button/choice_idle_background.png", im.matrix.colorize("#CCCCCC", "#CCCCCC"))
            else:
                textbutton i.caption action i.action
So the menu code would look like:

Code: Select all

menu:
    "This should be red.(red)":
        "Yep, it's red."
    "This should be normal.":
        "Very normal."

User avatar
DragonKnight
Regular
Posts: 51
Joined: Sun Nov 12, 2017 10:16 am
Projects: Taboo Hearts
Contact:

Re: choice button

#4 Post by DragonKnight »

Thank you!!!!!!!
Currently working on Taboo Hearts :D
Currently working on Forbidden :D

Post Reply

Who is online

Users browsing this forum: Google [Bot]