[Solved] Delay choice screen action until after hide transform (borken in 6.99.14 - nightly fix though)

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
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

[Solved] Delay choice screen action until after hide transform (borken in 6.99.14 - nightly fix though)

#1 Post by Remix »

Ok, so although the below works in 6.99.13 (which I figured had issues with the on hide) it does not work in 6.99.14
Once again, directly a choice is made, the screen and all the buttons disappears without giving time for any transforms to run.

Has anyone got a choice screen 'on hide' transform running in the new version?
Addendum:
The nightly builds (since the 'on hide' fix that Tom implemented) allow the below code to work fine.
If I get time I will try running the transforms without each part of the code and try to find a neater solution.


As the title suggests, is there a way to delay the actions in the choice screen (or indeed any screen that automatically Hide()'s) so that on hide transforms have enough time to run?
Ren'py 6.99.13 with individual Transforms applied as ATL on each choice button in turn using 'on start' to show (as 'on show' doesn't work) and presumably 'on hide' to hide.

Currently, the click immediately hides the screen and shows the say window again.
I can get around that using a function call and set_transform_event("hide") on all the button transforms as long as I remove the actual i.action parts (which do not wait until the transforms are finished)
Unfortunately the action needs to return the chosen value to work with rollback (and indeed to continue the game)

Already tried:
Function effecting var = renpy.display.behavior.PauseBehavior( delay=1.5, result=renpy.run(i.action) ) => return var.event(None, 0,0,0)
Function( invoke_in_new_context, renpy.pause, 1.5 ) ... then the i.action bits
config.transition_screens = True ... no effect
Plenty of other possibilities too

Note: already tried old suggestions from forum which do not work in 6.99.13

Any ideas?
Last edited by Remix on Wed Jan 17, 2018 8:38 am, edited 4 times in total.
Frameworks & Scriptlets:

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Delay choice screen action until after hide transform

#2 Post by philat »

Hmm. I can't think of a simple way to do precisely what you asked, but (in the default choice screen) transforms on the vbox (and not the buttons) work normally with on show / on hide instructions in ATL. I'm not sure why. They don't wait to show the say screen, though, they just run on top of the say screen (which is automatically shown).

You can also use a transition on the screen itself if that is close enough to what you want. (i.e., on "hide" action With(dissolve) or something).

Is this enough to get you where you want, or no? Obviously neither option above allows per button transforms, so if that's specifically what you need, I got nothing.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Delay choice screen action until after hide transform

#3 Post by Remix »

Yup, button specific... they all sit in a fixed and appear from a set node position to move to their designated positions (which are in a slight arc, just to be different)
Might have a try with PauseBehavior or Timer a bit more tomorrow, perhaps calling the i.action in a new context...

Still a bit concerned that per button transforms do not even allow 'on show'... hmmm

Sleep time now though ZzZzZzzz

Sub-note: Thanks for trying anyway ;)
Frameworks & Scriptlets:

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Delay choice screen action until after hide transform

#4 Post by philat »

Yeah, the thing that was weird for me is that the transforms doesn't work on a per button basis anyway, which was why I got thinking about it. Seems kind of like a bug. Sorry I can't be more help.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Delay choice screen action until after hide transform

#5 Post by Remix »

Will try a few options today and post a snippet if anything works...

If a hbox 'on hide' can stop the screen from disappearing I can possibly use one just for that and force the button transform events through a function. I do not really mind if the say window reappears while they are 'closing'.
Frameworks & Scriptlets:

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Delay choice screen action until after hide transform

#6 Post by Remix »

Seem to have it running... on show still needs on start though...

Rough code snippet:
(might not actually work as it was fly-typed by editing larger code sample)
(the important bits should give an idea though)

Code: Select all

screen pretty_choice( items ):
    # yup, mine has a bit more in here, including styles, frame creation from params, deterministic positions etc etc
    fixed:
        for idx,i in enumerate( items ):
            textbutton "[i.caption]":
                text_slow_cps 8.0 # hehe
                xmaximum 620
                anchor (0.5, 0.5)
                size_group "choice_buttons"

                background Frame( "some_img.png", left=Borders(27, 31, 29, 25),
                        yminimum=57, xminimum=57, yfill=True)

                at move_alpha_zoom( [(1.01, idx*100), 0.0, 0.0], [(0.4, idx*100), 1.0, 1.0], 1.5)

                action [ i.action ]

init python:
    
    ######### the transform mode toggler #########

    def set_button_transform_event(mode="show", screen_name="choice"):

        def get_transforms_for_buttons( child ):
            trans = []
            if hasattr( child, 'children' ):
                for c in child.children:
                    if hasattr(c, '__class__') \
                    and 'Transform' in c.__class__.__name__ \
                    and hasattr(c, 'child') \
                    and hasattr(c.child, '__class__') \
                    and 'Button' in c.child.__class__.__name__:
                        trans.append( c )
                    trans += get_transforms_for_buttons( c )
            return trans

        screen = renpy.get_screen( screen_name )
        if not screen:
            raise AttributeError, "Unknown screen name " \
                                  "'{0}'".format( screen_name )

        button_transforms = get_transforms_for_buttons( screen )

        for transform in button_transforms:
            transform.set_transform_event( mode )

    # tried this, didn't work - likely button do not exist when ran
    #
    # def show_choice_buttons(trans, st, at):
    #     # ignore params, just run the actions
    #     set_button_transform_event( "show", "choice" )
    #     return None

    def hide_choice_buttons(trans, st, at):
        # ignore params, just run the actions
        set_button_transform_event( "hide", "choice" )
        return None

transform move_alpha_zoom( start, end, duration ):
    on show, start: # show doesn't actually work here
        pos start[0]
        alpha start[1]
        zoom start[2]

        linear duration pos end[0] alpha end[1] zoom end[2]

    on hide:
        linear duration pos start[0] alpha start[1] zoom start[2]

# default preferences.wheel_menu_speed = 10

transform choice_transform( delay=2.0 ):
    alpha 1.0
    on hide:
        # hide vbox = hide buttons
        function hide_choice_buttons
        linear delay alpha 1.0
        
screen choice(items):
    style_prefix "choice"

    vbox at choice_transform( 1.5 ):
        # for i in items:
        #     textbutton i.caption action i.action
        use pretty_choice( items )
Frameworks & Scriptlets:

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: [6.99.14 Unsolved] Delay choice screen action until after hide transform

#7 Post by Remix »

Ok, so although the above works in 6.99.13 (which I figured had issues with the on hide) it does not work in 6.99.14

Once again, directly a choice is made, the screen and all the buttons disappears without giving time for any transforms to run.

Has anyone got a choice screen 'on hide' transform running in the new version?
Frameworks & Scriptlets:

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: [6.99.14 Unsolved] Delay choice screen action until after hide transform

#8 Post by PyTom »

There's a bug in on hide, I'll be releasing a 6.99.14.1 in the next day or so to fix it.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: [6.99.14 Unsolved] Delay choice screen action until after hide transform

#9 Post by Remix »

Wonderful news, thanks Tom.
I'd been wracking my brain to think of a possible workaround and was getting nowhere. Will check to see what works and what doesn't when the next release/nightly comes out.
Thanks for the reply and for all your hard work.
Frameworks & Scriptlets:

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: [6.99.14 Unsolved] Delay choice screen action until after hide transform

#10 Post by PyTom »

It should be fixed in the current nightly, fwiw.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: [Solved] Delay choice screen action until after hide transform (borken in 6.99.14 - nightly fix though)

#11 Post by Remix »

With the:

Code: Select all

        for transform in button_transforms:
            transform.set_transform_event( mode )
        ## and the rest...
snippet, everything seems to be working as it did in 6.99.13.
Hopefully find some time to test a bit further and see if 'on hide' events on container children can be ran without resorting to the method above when just hiding a screen.

Thanks again for the fix PyTom :)
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot]