Hey, bumping this in case anyone sees it who might be able to help me, it's been 3 months and I'm still at a loss. Maybe it's just my lack of programming skills, I dunno, but this is one of those things I have no idea how to figure out on my own.
EDIT:
Okay, I asked on the renpy discord and someone by the name of "Fen (Feniks)" came up with an alternative solution for me, which happens to be a lot simpler and works with existing systems rather than replacing them. All it really does is make use of the "window_background" parameter for character definitions...plus a bunch of extra things to make it work properly. No shade to m_from_space, I'm still very grateful for their help, it just didn't QUITE work perfectly, and as far as I can tell this solution does.
As per usual, I barely understand how any of this code works, but I want to include it here for posterity (and so this thread doesn't become one of those google results with an almost-but-not-quite solved problem).
So first of all, this stuff makes it so dialogue boxes fade out and in properly during menu/scene transitions, rather than flashing to the narrator's background:
Code: Select all
#make it so when an empty dialogue line is said (such as when a menu or scene change happens) it fades out using the previous character's background rather than the narrator
init python:
def my_empty_window():
try:
who = _last_say_who
who = renpy.eval_who(who)
except:
who = None
if who is None:
who = narrator
if isinstance(who, NVLCharacter):
nvl_show_core()
elif isinstance(who, ADVCharacter):
who.empty_window()
elif isinstance(store._narrator, ADVCharacter):
store._narrator.empty_window()
#and then this stuff makes it so it fades back in using the appropriate dialogue background
#this part was just copied from 00library.rpy and the two "store._narrator"s in the elif were changed to "who"
try:
scry = renpy.scry()
# When running in a say statement or menu-with-caption, scry for
# the next say statement, and get the window from that.
if scry.say or scry.menu_with_caption:
who = None
for i in range(10):
if scry.say:
who = scry.who
break
scry = scry.next()
else:
who = _last_say_who
who = renpy.eval_who(who)
except Exception:
who = None
if who is None:
who = narrator
if isinstance(who, NVLCharacter):
nvl_show_core()
elif not isinstance(who, NVLCharacter):
who.empty_window()
else:
store._narrator.empty_window()
config.empty_window = my_empty_window
Then here's the transform for the scrolling dialogue box background, set up as a function which uses some time shenanigans to make it not reset itself on every interaction. This is still using the same image dimensions I described above, so change the numbers around if needed.
Code: Select all
#dialogue box pan animation
init python:
import time # so it works on real time not the shown timebase
def tile_function(trans, st, at):
trans.align = (0.0, 1.0)
# 3.0 is how long it takes to move the image to a new tile spot
t = time.time() % 3.0 / 3.0
trans.xoffset = int(t*-150)
trans.yoffset = int(t*80)
# immediate refresh
return 0
transform move_tile():
function tile_function
And here's some example characters, complete with some non-relevant code that I'm including in case I ever have to refer back here for something. The namebox_background in the generic character is something that I apparently need for generic character nameboxes to work properly? I guess? That's a separate topic but I'm including it anyway. I don't remember when I added that but the namebox breaks if I get rid of it.
Code: Select all
define narrator = Character(None, window_background=AlphaMask(Fixed(At("images/gui/Narrator_bg.png", move_tile)), "images/gui/dialoguemask.png"))
define generic = Character("generic", namebox_background = Frame("Generic_nbox", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign),
window_background=AlphaMask(Fixed(At("images/gui/Narrator_bg.png", move_tile)), "images/gui/dialoguemask.png"))
define m = Character("orange lass", window_background=AlphaMask(Fixed(At("images/gui/orange lass_bg.png", move_tile)), "images/gui/dialoguemask.png"), image='m')
define e = Character("blue fella", window_background=AlphaMask(Fixed(At("images/gui/blue fella_bg.png", move_tile)), "images/gui/dialoguemask.png"), image='b')
define bl = Character("Background Lady", kind=generic)
define bd = Character("Background Dude", kind=generic)
You can leave screens.rpy how it was by default rather than making any alterations to it, and simply shove all that code into your main script file or whatever.
There's probably a way to more efficiently define those characters rather than repeating those long window_background segments for each one but I tried and couldn't figure out how, so if anyone sees this and knows a way feel free to share.