If we want to customize them, for example, to have
Different colour speech bubble per character,
how to do that?
TL;DR:
Add this code to one of your .rpy files:
Code: Select all
init python:
def bub_custom(tag):
""" bubble.properties_callback to use custom properties for particular tags """
possible = [
'_'.join(("bottom_left", tag)),
'_'.join(("bottom_right", tag)),
'_'.join(("top_left", tag)),
'_'.join(("top_right", tag)),
'_'.join(("thought", tag))
]
actual = []
for i in possible:
if i in bubble.properties:
# If custom properties were set for this tag, use them
actual.append(i)
if actual:
return actual
# Otherwise use the default properties
return ["bottom_left", "bottom_right", "top_left", "top_right", "thought"]
define bubble.properties_callback = bub_custom
init 1 python:
# Loop through "tints" dictionary and for every tag there set custom properties
for tag, tint in tints.items():
mtrx = TintMatrix(tint)
ckey = '_'.join(("bottom_left", tag))
bubble.properties[ckey] = bubble.properties["bottom_left"].copy()
bubble.properties[ckey]["window_background"] = Transform(
bubble.frame, xzoom=1, yzoom=1, matrixcolor=mtrx)
ckey = '_'.join(("bottom_right", tag))
bubble.properties[ckey] = bubble.properties["bottom_right"].copy()
bubble.properties[ckey]["window_background"] = Transform(
bubble.frame, xzoom=-1, yzoom=1, matrixcolor=mtrx)
ckey = '_'.join(("top_left", tag))
bubble.properties[ckey] = bubble.properties["top_left"].copy()
bubble.properties[ckey]["window_background"] = Transform(
bubble.frame, xzoom=1, yzoom=-1, matrixcolor=mtrx)
ckey = '_'.join(("top_right", tag))
bubble.properties[ckey] = bubble.properties["top_right"].copy()
bubble.properties[ckey]["window_background"] = Transform(
bubble.frame, xzoom=-1, yzoom=-1, matrixcolor=mtrx)
ckey = '_'.join(("thought", tag))
bubble.properties[ckey] = {
"window_background": Transform(bubble.thoughtframe, matrixcolor=mtrx)
}
PS. The second version (with different syntax) see in the next post.
For every character you want to color the speech bubble, add its
"image tag": "color code"
to dictionary "tints", like this:
Code: Select all
define e = Character(None, image="eileen", kind=bubble)
define l = Character(None, image="lucy", kind=bubble)
define a = Character(None, image="amanda", kind=bubble)
define tints = {
"eileen": "#FCC",
"lucy": "#CFC",
"amanda": "#CCF",
}
for "eileen" will be pink ("#FCC"),
for "lucy" green(ish) ("#CFC"),
for "amanda" blue ("#CCF").
That's it.
Explanation:
In screens.rpy, there is a dict "bubble.properties".
https://renpy.org/doc/html/bubble.html
The code presented here (see "init 1 python" part) loops through "tints" dict and adds custom properties to "bubble.properties".
For every key in "tints" it adds "bottom_left_[key]", "bottom_right_[key]" and so on.
Those custom properties show the same default bubble.frame as usual, but transformed with "matrixcolor", with the tint that you have set in "tints".
https://renpy.org/doc/html/matrixcolor.html
And when a character speaks, bubble.properties_callback function makes the bubble use those custom properties.
https://renpy.org/doc/html/bubble.html# ... s_callback
Of course with a little modification of the code you can set other properties in a similar manner (e.g. quite different backgrounds for bubbles etc.).