Depending on what you're doing, it might be sufficient to use interpolation in a text tag to specify a color, as follows:
Code: Select all
$ coolcolor = '#F00'
menu:
"{color=[coolcolor]}... to ask her right away.":
jump rightaway
"... to ask her later.":
jump later
You can squeeze a little more flexibility out of this using a style, with something like the following:
Code: Select all
$ coolstyle = 'coolstyle_text'
menu:
"{=[coolstyle]}... to ask her right away.":
jump rightaway
"... to ask her later.":
jump later
And define the style with
Code: Select all
style.coolstyle_text.color="#f00"
If you actually need to customize the button based on some variable, you can modify the choice screen to restyle based on the caption. Here's a choice screen that adds support for a tag like "{buttonstyle=coolstyle}":
Code: Select all
init python:
def split_choice_caption(caption):
m = re.match("\{buttonstyle\=(.*)\}(.*)", caption)
if m:
return (m.group(2), m.group(1))
return (caption, "")
screen choice:
window:
style "menu_window"
xalign 0.5
yalign 0.5
vbox:
style "menu"
spacing 2
for caption, action, chosen in items:
$ caption = renpy.substitutions.substitute(caption)
$ (caption, capstyle) = split_choice_caption(caption)
if action:
button:
action action
style style.menu_choice_button[capstyle]
text caption substitute False style style.menu_choice[capstyle]
else:
text caption style "menu_caption"
Then, specify the style:
Code: Select all
style.menu_choice_button["coolstyle"].background = "#F00"
And then, the menu looks like this:
Code: Select all
$ mystyle = 'coolstyle'
menu:
"{buttonstyle=[mystyle]}... to ask her right away.":
jump rightaway
"... to ask her later.":
jump later