For the most part, this code works as expected - even when there are multiple windows onscreen at once.
However, if two windows include text that begins with the same word, only the last one is displayed. I have a theory about what might be causing this (perhaps Ren'Py interprets that word as a tag to one of the elements, and will only show one element at a time for a given tag?) but haven't been able to find a relevant section in the documentation. I've tried unsuccessfully to add a "tag=" argument to some of the displayables and see if I can find one that's the source of the problem - and maybe pass unique tag values to - but haven't had any luck so far.
Here is some code that demonstrates the problem.
Code: Select all
transform bubble_move(txt, ypos, background="000",delay=0,style_name="bubble_window",yoffset=-200,xadjust=0.5):
#Makes sure bubbles are spaced out and don't overlap
time delay
Window(Text(txt, size=20), style_name)
ypos ypos
#xalign 0.5
xalign xadjust
alpha 0.1
parallel:
linear 0.5 alpha 1.0
parallel:
#Speed and direction are handled by yoffset
linear 2 yoffset -200
parallel:
pause 1.5
linear 0.5 alpha 0.1
Null()
init python:
import time
class Bubble():
#time.time() returns seconds past the epoch
def __init__(self):
self.start_time = 0
self.delay_duration = .5
#Generally not used; it's there if I want to log what's in the bubbles
self.debug_text = "Debugging text"
self.xadjust = 0.1
def set_timestamp(self,delay=0):
self.start_time = time.time() + delay
def get_timestamp(self):
return self.start_time
def calculate_delay(self):
now = time.time()
time_elapsed = now - self.get_timestamp()
if time_elapsed > self.delay_duration:
#renpy.log("The if: %s" % self.debug_text)
self.set_timestamp()
return 0
else:
delay = self.delay_duration - time_elapsed
#renpy.log("The else: %.2f" % delay)
self.set_timestamp(delay)
return delay
def show_bubble(self,txt,ypos,background="#000",delay=0,style_name="bubble_window",xadjust=0.5):
#self.debug_text = txt
bubble_delay = self.calculate_delay()
renpy.show(txt, what=bubble_move(txt, ypos, delay=bubble_delay,style_name=style_name))
#Used this to horizontally space bubbles during testing
#self.xadjust += 0.1
#if self.xadjust >= 1:
# self.xadjust = 0.1
return True
#I have several of these wrappers for the show_bubble function; they vary in style and the additional text added
def stat_bad_decrease(self, varname):
self.show_bubble("{} has decreased".format(varname),300,style_name="bubble_window_good")
start:
define bubbler = Bubble()
"We're about to see some bubbles that demonstrate the problem."
python:
#This one doesn't show up
bubbler.stat_bad_decrease("Same First")
#This one doesn't show up, either
bubbler.stat_bad_decrease("Same Again")
#This one shows up
bubbler.stat_bad_decrease("Same Third")
#"Aggressive Micromanagement" and "Aggressive Nanomanagement" don't show up - but "Aggressive Picomanagement" does
for bubble_label in ["Superfluous Paperwork", "Time-Wasting All-Hands Meetings", "Aggressive Micromanagement", "Tedious Weekly Reports",
"Unnecessarily Verbose Procedures", "Aggressive Nanomanagement", "Inaccurate Training Materials", "Acronym Bloat",
"Embarrassing Slogans","Aggressive Picomanagement"]:
bubbler.stat_bad_decrease(bubble_label)
"Here are the bubbles."