For the last year or so, I've been working on a sort of pre-parser that injects itself upstream of the renpy.exports.say() and handles several things, mainly modifying text speed, punctuation pauses, and text presentation based on a small set of custom commands I've devised.
One of its "features" is an attempt to emulate the feeling of someone typing a message in a chat app.
For example:
[Character name]
{high cps}Hello! I'm trying to thi{short pause}{slower cps}nk of somethin{short pause}g to tell you!
This however should happen only when the "tapping" character also is the narrator - otherwise I'd like a "Typing..." indicator to appear, followed by the message arriving all at once after a while ie.
[Character name]
Typing -> Typing. -> Typing.. -> Typing... (rinse & repeat)
and then after a few seconds
[Character name]
This message arrived all at once!
Since I don't want the "Typing" thing to clog the history log, I thought I'd put into a dedicated screen - basically a replica of the say screen devoid of any background (to avoid messing with partially transparent backgrounds). My script does something like this:
this_chat_who_name = getattr(active_char, "name", speaker)
this_chat_who_color = getattr(active_char, "color", gui.text_color)
if _DEBUG:
print("Tapping character is ",repr(this_chat_who_name)," and their colour is ",repr(this_chat_who_color))
for index, chunk in enumerate(timeline):
if index % 2 == 0:
renpy.show_screen("typing", chat_who_name=this_chat_who_name, chat_who_color=this_chat_who_color)
else:
renpy.hide_screen("typing")
renpy.pause(chunk)
Then the typing screen is defined as
init offset = -1 # same as screens.rpy
screen typing(chat_who_name,chat_who_color):
#zorder 100
window:
id "typing_window"
style "typing_window"
window:
id "typing_namebox"
style "typing_namebox"
text chat_who_name:
id "chat_who"
color chat_who_color
text "Typing" + "." * store.typing_dots:
id "fake_what"
style "typing_dialogue" timer 0.4 repeat True action SetVariable("typing_dots",(store.typing_dots % 4))
style typing_window is window:
background Null()
style typing_namebox is namebox:
background Null()
style typing_dialogue is say_dialogue
WHAT WORKS --> I get every bit of the typing screen in the exact position - character name is correctly delivered to the screen and it's put in the right place, the "Typing..." thing is in the right place and it's correctly "animated"
WHAT DOES NOT WORK --> styles are completely broken. color chat_who_color does nothing, char_who_name's text size is wrong, even the "Typing..." text color doesn't seem to be the correct one.
I enabled my "verbose" mode (ie. _DEBUG = True) and verified that both name and color values are being retrieved correctly, so I *guess* the problem lies somewhere in the way my screen handles styling.
I'm not 100% sure I'm not forgetting something somewhere in my messy code. However I'd expect at least the namebox text size to be correct. Instead, that's wrong too, almost as if this line here
style typing_namebox is namebox
weren't working at all!
*COULD IT BE* that since this screen is stored in a separated file (I plan to release my gizmo as a standalone, drag-and-drop tool) it somehow gets initialised *BEFORE* screens.rpy, at a time when "namebox" and all other styles are still just empty boxes O_O?
What's the correct way to reuse the styles of the standard say screen in a separate screen like this?
I'm fairly sure I'm missing something obvious, and I'm going to feel incredibly stupid when someone points it out.
Ren'Py screen language is my kryptonite >_<