Ok, this one is tough but I'd like to give it a shot.
I have a screen called 'trait_details' that is displayed when hovering over a 'Trait' button, and hidden when unhovering, similar to a tooltip screen.
Depending on how many 'traits' there are, the content is sometimes too long for the screen.
So what I want to create is a screen that slowly scrolls down on its own when it's too long, similar to some games. (Think about the star wars intro text effect, without the perspective). I used a viewport and a ui.adjustment(), and I managed to do just that:
Code: Select all
## TRAITS LIST ##
textbutton "Traits":
action NullAction()
hovered Show("trait_details", girl=girl)
unhovered Hide("trait_details")
[...]
screen trait_details(girl):
tag trait_details
default yadj = ui.adjustment()
default t = 0
if len(girl.traits) > 12:
timer 0.01 repeat True action (SetScreenVariable("t", t + 0.01), Function(yadj.change, max(0, 100*(t-0.1))))
frame:
background c_ui_darker
xalign 0.5
yalign 0.8
xsize int(config.screen_width / 2.8)
ymaximum int(config.screen_height*0.8)
viewport:
yadjustment yadj
has vbox spacing 3
text girl.name + "'s traits"
for trait in girl.traits:
hbox:
text trait.name
text trait.get_description()
[...]
The problem is that when one moves the mouse away from the Trait button, the screen stays shown until the scrolling animation is complete, ignoring this part of the code:
This doesn't happen when the length of the trait list is shorter (and the timer is off): the screen hides immediately upon unhovering.unhovered Hide("trait_details")
Do you guys know how to enforce the 'Hide' command on a screen that has a timer when unhovering? Is there a different approach that works to get the same behavior? Thank you for reading!