[Solved] Arbitrary ATL on textbox show/hide transitions

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
KuroOneHalf
Regular
Posts: 129
Joined: Fri Apr 25, 2014 6:18 pm
Completed: Cuttlebone
Projects: Somewhere In The Shade
Deviantart: KuroOneHalf
itch: kuroonehalf
Contact:

[Solved] Arbitrary ATL on textbox show/hide transitions

#1 Post by KuroOneHalf »

For a long while now I've been trying to find out how to apply ATL to the textbox transitions in order to be able to do cooler textbox show and hide animations like what you find in Persona 4, Danganronpa, Rondo Duo, and some other RPGs with visual novel conversation elements. Past searching and asking around had led me to believe it was not possible, but recently my interest was refueled when I saw the tech in the demo for A Kiss For The Petals - The New Generation.
In it, the textbox in/out transitions do a dissolve + pan animation, by making use of the ComposeTransition and MoveTransition functions to make new transitions and assigning them to config.window_show_transition and config.window_hide_transition.

I've been thoroughly playing with that code since, but unfortunately I have not found anything that works as a solution. A few of the problems I've encountered:
- MoveTransition only seems to support very basic coordinate-change transitions with the pos, anchor, and align functions. Rotate, zoom, and others do nothing. So this works, but for a very limited and static range of transition possibilities.
- Feeding ATL transitions into config.window_show_transition and config.window_hide_transition gets the transitions to play, but is applying them to the whole screen, and not just the textbox. MoveTransition is able to get around this by having a parameter "layers", where you can specify that layers=["screens"], or any other set of them, and the transition is only applied to those. If there was a way to specify what layers ATLs or transitions are applied to then this would be solved, but I don't know of a Renpy function that does that.
- I also tried to use the "on show:" and "on hide:" actions of the Say screen to show the textbox background image with a given ATL, but because those actions are triggered at every line of text the animation is constantly replaying, and not just on the expected in/out transitions.

And as of right now I have no other ideas on how to achieve this. Do you guys know how this could be done?

edit: I wonder if this can be faked by playing a video of the transition and then swapping it with the static textbox image. I'm gonna try to see if it's possible either way but I imagine it's unnecessarily expensive for animations that can be done with ATL.
Last edited by KuroOneHalf on Thu May 26, 2022 5:53 pm, edited 4 times in total.

User avatar
zankizuna
Veteran
Posts: 416
Joined: Fri May 04, 2012 2:20 am
Completed: Monochrome Valentine
Projects: Softwar
Deviantart: raseru09
itch: ZanKizuna
Location: Manilaaaaaaaa
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#2 Post by zankizuna »

modify screen say, i think?
add transforms
I haven't tried, maybe check out screens.rpy :P

User avatar
KuroOneHalf
Regular
Posts: 129
Joined: Fri Apr 25, 2014 6:18 pm
Completed: Cuttlebone
Projects: Somewhere In The Shade
Deviantart: KuroOneHalf
itch: kuroonehalf
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#3 Post by KuroOneHalf »

Bumping this thread to see if we can hopefully figure out a solution this time!

To reiterate the problem: I want arbitrary animations to play on multiple textbox images during the window show and hide events. An extremely basic example of this is the Persona 4 textbox. There's the orange rectangle image and the grey rectangle image, and both animate independently rotating in and out during window show and hide events (and also when switching speakers, but I personally could do without that.)

How could I achieve this? Simple on show/replace/replaced events make the show animation trigger during every line of dialog. How can you make it trigger only when the window show/hide transitions happen, like you see in the video?

Please help me figure this out.🙏

User avatar
plastiekk
Regular
Posts: 112
Joined: Wed Sep 29, 2021 4:08 am
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#4 Post by plastiekk »

KuroOneHalf wrote: Sun May 22, 2022 5:02 pm Bumping this thread to see if we can hopefully figure out a solution this time!
I am not sure if i understand completly what you mean but why not try to add an image to the say screen?

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:

        id "window"
        add "your_animated_image" at your_tranformation    		# <-  simply add an image+transform here
        ...
        
Why on earth did I put the bread in the fridge?

User avatar
m_from_space
Miko-Class Veteran
Posts: 957
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#5 Post by m_from_space »

KuroOneHalf wrote: Sun May 22, 2022 5:02 pmHow could I achieve this? Simple on show/replace/replaced events make the show animation trigger during every line of dialog. How can you make it trigger only when the window show/hide transitions happen, like you see in the video?
I totally understand your frustration here, because I tried to solve it for you and it took me quite some time figuring it out, since the say screen hides and shows multiple times even when it is hidden and so the statements inside the screen never really work for transforms.

But I found a solution that works! :D

You definitely have to place your background inside its own screen and not inside the say screen and check if the say screen is visible. I think I will use this for my own game too, I like that idea. So thanks for bumping it up.

Code: Select all

screen say_background:
    showif renpy.get_screen("say"):
        frame at say_transform:
            xsize 300 ysize 100
            xalign 0.5 yalign 0.5
            background Solid("#ff0a")

transform say_transform:
    on show:
        alpha 0.0 rotate 30
        linear 0.5 alpha 1.0 rotate 0
    on hide:
        alpha 1.0 rotate 0
        linear 0.5 alpha 0.0 rotate 30

label start:
    show screen say_background

    "Let's hide the window and pause for 3 secs."

    window auto hide

    pause 3.0

    "Done."
edit: I used "showif" inside the say_background screen first, but I found out that "if" works better.

edit: No it doesn't, strange. Use showif! :D

User avatar
KuroOneHalf
Regular
Posts: 129
Joined: Fri Apr 25, 2014 6:18 pm
Completed: Cuttlebone
Projects: Somewhere In The Shade
Deviantart: KuroOneHalf
itch: kuroonehalf
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#6 Post by KuroOneHalf »

m_from_space wrote: Wed May 25, 2022 3:42 pm
Oh, that's great! That solves the biggest problem. Thank you!

I've found some other kinks to iron out. One of them is the say screen won't wait for the textbox animation to play before it shows up. However, you can delay the appearance of the text by doing:

Code: Select all

transform say_show_hide_delay(new_widget=None, old_widget=None):
    delay 2.0
    old_widget
    new_widget

define config.window_show_transition = say_show_hide_delay
define config.window_hide_transition = say_show_hide_delay
I haven't figured out how to delay the appearance of other elements though, like the quick menu. Does anyone have an idea how you might be able to do that?

User avatar
m_from_space
Miko-Class Veteran
Posts: 957
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#7 Post by m_from_space »

Uhm, I just realized that all this is way easier by just making our own "window hide" command. Don't know why I didn't think of it earlier. Sure, you have to call it manually, but that shouldn't be a problem, right? It's just a replacement for the old "window hide" (and "window show"), so it's not like more code is really needed. What do you think?

Code: Select all

screen say_background():
    frame at say_transform:
        xsize 300 ysize 100
        xalign 0.5 yalign 0.5
        background Solid("#ff0a")

transform say_transform:
    on show:
        alpha 0.0 rotate 30
        linear 0.5 alpha 1.0 rotate 0
    on hide:
        alpha 1.0 rotate 0
        linear 0.5 alpha 0.0 rotate 30

label my_window_hide:
    hide screen say_background
    pause 1.0
    window auto hide
    return

label my_window_show:
    show screen say_background
    pause 1.0
    window auto show
    return

label start:
    show screen say_background

    "Let's hide the window and pause for 3 secs."

    call my_window_hide

    pause 3.0

    call my_window_show

    "Done."

    "Okay, another sentence."

User avatar
KuroOneHalf
Regular
Posts: 129
Joined: Fri Apr 25, 2014 6:18 pm
Completed: Cuttlebone
Projects: Somewhere In The Shade
Deviantart: KuroOneHalf
itch: kuroonehalf
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#8 Post by KuroOneHalf »

Well, having to replace default scripting syntax seems a bit less than ideal. And it doesn't automatically trigger in situations where window auto triggers events, such as when changing scenes. The initial solution seems overall simpler and more robust.

At the moment there's just two problems I'm aware of left to solve:
- We need a way to delay the appearance of the quickmenu and side images and other elements, so they only appear after the textbox animation has finished.
- The animations still play during skip mode, when you expect them to be skipped.

Update:
Second problem fixed, easily enough.

Code: Select all

screen say_textbox:
    showif renpy.get_screen("say"):
        add  "UI/ingame/textbox.png":
            if not renpy.is_skipping():
                at textbox_animation

User avatar
m_from_space
Miko-Class Veteran
Posts: 957
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#9 Post by m_from_space »

KuroOneHalf wrote: Thu May 26, 2022 10:13 amWell, having to replace default scripting syntax seems a bit less than ideal. And it doesn't automatically trigger in situations where window auto triggers events, such as when changing scenes.
I wouldn't have a problem with writing one line of code when a scene changes, to trigger that effect. But that's me.

Also the problems with the quickmenu and side images and whatever you want to name are not present with just using a label, where you put that animation call inside and whatever happens next.

User avatar
KuroOneHalf
Regular
Posts: 129
Joined: Fri Apr 25, 2014 6:18 pm
Completed: Cuttlebone
Projects: Somewhere In The Shade
Deviantart: KuroOneHalf
itch: kuroonehalf
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#10 Post by KuroOneHalf »

One line per scene change can be a lot of lines if your script is of any meaningful length. :p
And again it's just extra unwanted syntax and more room for error if you have separate writers and programmers. The best solution is to have it happen automatically, which it does with the initial solution.

I was researching callbacks and thought I was a smarty pants when I worked this out.

Code: Select all

python:
        def textbox_callback(mode, old_modes):
            old = old_modes[0]

            if mode == "say":
                renpy.show_screen("say_textbox")
            elif old == "say":
                renpy.hide_screen("textbox")

        config.mode_callbacks.append(textbox_callback)
The idea here is to eliminate having to manually show the textbox screen, and just have it be automatically called when the say mode is activated. Or maybe it could wield some other bonuses. Unfortunately, the say mode is technically only activated AFTER config.window_show_transition, so it causes a timing issue, and it also misfires during sprite show transitions. RIP.

User avatar
KuroOneHalf
Regular
Posts: 129
Joined: Fri Apr 25, 2014 6:18 pm
Completed: Cuttlebone
Projects: Somewhere In The Shade
Deviantart: KuroOneHalf
itch: kuroonehalf
Contact:

Re: Arbitrary ATL on textbox show/hide transitions

#11 Post by KuroOneHalf »

Okay, and the final problem is solved. It feels a little clumsy but I think it may be the most simple solution. I just applied ATL that makes the quickmenu and co. invisible until the textbox animation is done, e.g.

Code: Select all

transform quickmenu_transform:
    on show:
        alpha 0.0
        pause textbox_animation_duration
        linear 0.2 alpha 1.0
Barring any new kinks I find, I think this is fully working as intended! Thanks for the help. :>

Post Reply

Who is online

Users browsing this forum: No registered users