Keeping text shown during 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.
Message
Author
User avatar
Graph
Veteran
Posts: 230
Joined: Sat Jul 03, 2010 7:22 pm
Completed: Touhou Mecha Chap. 1
Projects: Touhou Mecha, Eastern Starlight Romance
Organization: Dai-Sukima Dan
Contact:

Keeping text shown during transitions

#1 Post by Graph » Wed Sep 05, 2012 6:57 pm

I was wondering if there's an easy way to keep the dialogue box and the text inside shown during a transition like a simple dissolve?

Before you say "window show", I was looking for a way that doesn't make the text, name tab and window buttons disappear during the transition.

The best I've managed so far was a transform like this:

Code: Select all

    transform dlg_dissolve:
        on show:
            alpha 0.0
            linear 0.2 alpha 1.0
        on hide:
            linear 0.2 alpha 0.0
        on replace:      # when new image appears
            alpha 0.0
            linear 0.2 alpha 1.0
        on replaced:     # when old image disappears
            linear 0.2 alpha 0.0
Then I call it like this:

Code: Select all

show aya normal 
show aya thinking at dlg_dissolve
It's almost there; the only issue is that the sprite disappears for a split-second before showing the new expression. Is there a way to make the sprite transition look more like a "with Dissolve(0.2)"? While keeping the textbox and text of course.
Last edited by Graph on Thu Sep 06, 2012 1:43 am, edited 1 time in total.

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Keeping text shown during transitions

#2 Post by apricotorange » Thu Sep 06, 2012 12:21 am

Add the following code to your game:

Code: Select all

init python:
    config.empty_window = renpy.curry(extend)("", interact=False)
    _last_say_what = ""

User avatar
Graph
Veteran
Posts: 230
Joined: Sat Jul 03, 2010 7:22 pm
Completed: Touhou Mecha Chap. 1
Projects: Touhou Mecha, Eastern Starlight Romance
Organization: Dai-Sukima Dan
Contact:

Re: Keeping text shown during transitions

#3 Post by Graph » Thu Sep 06, 2012 1:42 am

It seems to be on the right track. I assume it's meant to be used with "window show"?

I have a bit of trouble figuring out when to used "window show" though. When I use it before any text shows up like so,

Code: Select all

show aya salute at left with dissolve
    window show
    ay "Squad Captain Shameimaru, reporting in!"
    k "At ease. What's the status of the Tengu squads?"
    show aya normal with quick_dissolve
I see the text from before the textbox went away for half a second before the new text starts to display. If I put it anywhere else, the textbox disappears for a moment and comes back again.

Any way to make the textbox not disappear on "window show", or clear the text box of text before it appears again? I might be wrong about this but I hear "nvl clear" may be used in a similar fashion in nvl mode (but mine's adv).

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Keeping text shown during transitions

#4 Post by apricotorange » Thu Sep 06, 2012 3:52 am

Here's a short sample game; the textbox never disappears for me, and the text isn't hidden for a transition:

Code: Select all

define cha = Character("asdf")
define bcha = Character("bsdf")

image aya a= Solid("#F00", maximum=(200, 400))
image aya b = Solid("#FF0", maximum=(200, 400))
image back = "#FAF"

init python:
    config.empty_window = renpy.curry(extend)("", interact=False)
    _last_say_what = ""

label start:
    window show
    scene back
    show aya b at left with dissolve
    cha "asdf"
    bcha "zxcv"
    show aya a with dissolve
    "qwerty"
Is that not the effect you were looking for?

User avatar
Graph
Veteran
Posts: 230
Joined: Sat Jul 03, 2010 7:22 pm
Completed: Touhou Mecha Chap. 1
Projects: Touhou Mecha, Eastern Starlight Romance
Organization: Dai-Sukima Dan
Contact:

Re: Keeping text shown during transitions

#5 Post by Graph » Thu Sep 06, 2012 12:52 pm

apricotorange wrote:Is that not the effect you were looking for?
It's not, you used it at the very start. I don't want to always show the window; I just want to keep it on during fast transitions in the middle of a block of dialogue. I want it to be hidden for CGs and other visuals.

I guess you'd use "window hide". But then the next time you use "window show" you see the text from when you last used "window hide" for a bit before the new text shows up. If you add some dialogue before and after the "window show" you might see what I mean?

I may have figured out this earlier concern of mine though;
Graph wrote:Before you say "window show", I was looking for a way that doesn't make the text, name tab and window buttons disappear during the transition.
The breaking GUI may just be a symptom of how we've programmed it; it's a customized text box. If we use one large image for it rather than have name tab and buttons separate, it might work even when there's no text inside.

Still wondering about the timing for window show though. Thanks for your continued assistance.

Nova Alamak
Regular
Posts: 71
Joined: Sun Jun 08, 2014 1:45 pm
Contact:

Re: Keeping text shown during transitions

#6 Post by Nova Alamak » Fri Jul 04, 2014 5:29 pm

Bump! Can someone answer this person? I'm having the same problem. Adding the line of code to my init area doesn't keep the text box from disappearing when something like this happens:

Code: Select all

init:

    define yj = Character('Yolk')
    image yolk normal = "YolkBase.png"

label start:

    yj  "Neither do I.{w=0.5} The Mayor has a{w=0.5} {i}questionable{/i} sense of humor,{w=0.2} so pray she does not come to her senses if you choose to stay."
    show yolk normal with dissolve
    extend " And what say you?{w=0.5} Will you accept the terms?{w=0.5}" 
After the first line of dialogue, the window vanishes until the transition is done. The code offered didn't change that.

I put the "window show" in and it solved the problem for the textbox itself, but the text and such still vanishes momentarily and it looks really awkward.

User avatar
akakyouryuu
Regular
Posts: 122
Joined: Fri Nov 30, 2012 10:29 am
Contact:

Re: Keeping text shown during transitions

#7 Post by akakyouryuu » Sat Jul 05, 2014 12:44 am

Use renpy.transition in place of the with statement.

Code: Select all

init:

    define yj = Character('Yolk')
    image yolk normal = "YolkBase.png"

label start:

    yj  "Neither do I.{w=0.5} The Mayor has a{w=0.5} {i}questionable{/i} sense of humor,{w=0.2} so pray she does not come to her senses if you choose to stay."
    #show yolk normal with dissolve
    show yolk normal
    $ renpy.transition(dissolve, layer="master")
    extend " And what say you?{w=0.5} Will you accept the terms?{w=0.5}" 

How about "window auto"?
If _preferences.show_empty_window is True, "window auto" shows the window during transitions, but automatically hides the window before the scene statement and shows the window before the say statements

Nova Alamak
Regular
Posts: 71
Joined: Sun Jun 08, 2014 1:45 pm
Contact:

Re: Keeping text shown during transitions

#8 Post by Nova Alamak » Sat Jul 05, 2014 1:42 pm

Thank you! I finally found a way around this persistent issue.

The first solution you offered worked, but it would be kind of cumbersome to manually do that every time you wanted to use a transition mid-dialogue.

The second one had the same effect, and I assume "window auto" stays in place until you change it back somewhere in the script, so it's pretty perfect. It DOES require the preferences code you offered in order to work as well. I think that should be in there by default since it's only in specific scenarios that you'd actually want the textbox to disappear during a really simple transition like say, a facial expression change.

Anyway, great solution, thank you for your help!

EDIT: Juuuuust kidding! I realized the only reason those worked was because I removed the transition. Is it really necessary to have the window and text hide by default during a transition? It looks like the text box stays if I keep the transition in and preface thing with a "window auto", but the text itself still vanishes for a second. Is there a text equivalent for window auto?

User avatar
akakyouryuu
Regular
Posts: 122
Joined: Fri Nov 30, 2012 10:29 am
Contact:

Re: Keeping text shown during transitions

#9 Post by akakyouryuu » Sat Jul 05, 2014 7:53 pm

Add below code.

Code: Select all

init -1700 python:

    def next_who(count=10):
        scry = renpy.exports.scry()
        scry = scry.next()

        while count and scry:

            count -= 1
            if scry.who:
                return scry.who
            scry = scry.next()
        return None

    def for_extend(statement):
            if next_who(1) == extend:
                renpy.transition(extend_transition, layer="master")   

    config.statement_callbacks.append(for_extend)

Edit renpy/ast.py around 605

Code: Select all

    def scry(self):
        rv = Node.scry(self)

        if self.who is not None:
            if self.who_fast:
                who = getattr(renpy.store, self.who)
            else:
                who = renpy.python.py_eval(self.who)
        else:
            who = None
        ##########↓ Added
        rv.who = who
        ##########↑ Added

        if self.interact:
            renpy.exports.scry_say(who, rv)
        else:
            rv.interacts = False

        return rv
try this

Code: Select all

init:

    define yj = Character('Yolk')
    image yolk normal = "YolkBase.png"
    $ extend_transition=dissolve

label start:

    yj  "Neither do I.{w=0.5} The Mayor has a{w=0.5} {i}questionable{/i} sense of humor,{w=0.2} so pray she does not come to her senses if you choose to stay."
    show yolk normal
    # don't use with
    extend " And what say you?{w=0.5} Will you accept the terms?{w=0.5}" 
This may use extend_transition and show window and text during transition just before a extend character.

User avatar
A Hazard
Regular
Posts: 25
Joined: Sun Jun 29, 2014 4:02 pm
Completed: Gilded - The Lily & the Cage
Projects: Fragment - A Broken Fairy Tale
Tumblr: fragmentfairytale
Deviantart: fragmentfairytale
Contact:

Re: Keeping text shown during transitions

#10 Post by A Hazard » Sun Jul 06, 2014 2:06 pm

I'm having the exact same problem. While "window auto" will keep the textbox in place, I want the actual text to remain through transitions and pauses.

The first code "config.empty_window" actually did keep the textbox & text in place for me, but the text repeated itself 10+ times for some reason.
sample.png
The second code "$ renpy.transition(dissolve, layer="master")" obviously makes everything on the master layer dissolve, including objects I didn't want. It also made my custom "bottom" layer disappear during the transition (I'm assuming because my "bottom" layer is shown beneath the "master" one).
sample2.png
I couldn't get the third code "$ extend_transition=dissolve" to work (Renpy wouldn't boot up after I edited ast.py), but it seems like it would only work for when "extend" is used and not in other cases of transitions.

Is there anything else that can be tried? Right now I'm using a hack where a screenshot of the textbox + last text is shown during the transition, but that would get incredibly cumbersome for every transition in the game.

User avatar
akakyouryuu
Regular
Posts: 122
Joined: Fri Nov 30, 2012 10:29 am
Contact:

Re: Keeping text shown during transitions

#11 Post by akakyouryuu » Sun Jul 06, 2014 7:07 pm

Edit renpy/display/core.py in about 1707 and 2079 line

Code: Select all


    def show_window(self):

        if not renpy.store._window:
            return

        if not renpy.game.preferences.show_empty_window:
            return

        ############↓Edit
        if renpy.store.show_text_during_trans:
            return
        ############↑Edit

        if renpy.game.context().scene_lists.shown_window:
            return

        if renpy.config.empty_window:
            renpy.config.empty_window()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

            while repeat:
                repeat, rv = self.interact_core(preloads=preloads, **kwargs)

            return rv

        finally:

            context.interacting = False

            # Clean out transient stuff at the end of an interaction.
            if clear:
                scene_lists = renpy.game.context().scene_lists
                ####################↓Edited
                if renpy.store.show_text_during_trans:
                    if (("screens", "say") in scene_lists.additional_transient:
                        scene_lists.additional_transient.remove(("screens", "say"))

                    if (("screens", "nvl") in scene_lists.additional_transient:
                        scene_lists.additional_transient.remove(("screens", "nvl"))
                ####################↑Edited
                scene_lists.replace_transient()

            self.ongoing_transition = { }
            self.transition_time = { }
            self.transition_from = { }


Added below code

Code: Select all

init python:
    show_text_during_trans = False
Try this

Code: Select all

init:

    define yj = Character('Yolk')
    image yolk normal = "YolkBase.png"

label start:

    $ show_text_during_trans=True
    yj  "Neither do I.{w=0.5} The Mayor has a{w=0.5} {i}questionable{/i} sense of humor,{w=0.2} so pray she does not come to her senses if you choose to stay."
    show yolk normal
    with dissolve
    extend " And what say you?{w=0.5} Will you accept the terms?{w=0.5}" 
    $ show_text_during_trans=False
If show_text_during_trans is True, this shows window and text during transitions.

User avatar
A Hazard
Regular
Posts: 25
Joined: Sun Jun 29, 2014 4:02 pm
Completed: Gilded - The Lily & the Cage
Projects: Fragment - A Broken Fairy Tale
Tumblr: fragmentfairytale
Deviantart: fragmentfairytale
Contact:

Re: Keeping text shown during transitions

#12 Post by A Hazard » Sun Jul 06, 2014 8:26 pm

Unfortunately I couldn't get Renpy to boot up again with the edits to core.py. It will start up with the line ~1707 edit but not with the edit to ~2079. I noticed that the edited code in 2079 has 8 left hand brackets vs 6 right hand brackets, but fiddling with the brackets didn't help either.

User avatar
ArachneJericho
Regular
Posts: 196
Joined: Sun Jun 22, 2014 2:04 am
Projects: Kaguya Hime
Tumblr: mousedeerproductions
Location: Seattle, WA, USA
Contact:

Re: Keeping text shown during transitions

#13 Post by ArachneJericho » Sun Jul 06, 2014 8:31 pm

The problem is the code here:

Code: Select all

                    if (("screens", "say") in scene_lists.additional_transient:
There is an extra parenthesis ( here and in the next if. Remove it.

User avatar
akakyouryuu
Regular
Posts: 122
Joined: Fri Nov 30, 2012 10:29 am
Contact:

Re: Keeping text shown during transitions

#14 Post by akakyouryuu » Sun Jul 06, 2014 9:01 pm

Fixed

Code: Select all

                ####################↓Edited
                if renpy.store.show_text_during_trans:
                    if ("screens", "say") in scene_lists.additional_transient:
                        scene_lists.additional_transient.remove(("screens", "say"))

                    if ("screens", "nvl") in scene_lists.additional_transient:
                        scene_lists.additional_transient.remove(("screens", "nvl"))
                ####################↑Edited

User avatar
A Hazard
Regular
Posts: 25
Joined: Sun Jun 29, 2014 4:02 pm
Completed: Gilded - The Lily & the Cage
Projects: Fragment - A Broken Fairy Tale
Tumblr: fragmentfairytale
Deviantart: fragmentfairytale
Contact:

Re: Keeping text shown during transitions

#15 Post by A Hazard » Sun Jul 06, 2014 9:32 pm

Woo, that's it, Renpy booted up again. (Apparently I was trying to remove/add the wrong brackets before). But now it's giving me the error...

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 137, in script call
    call _gl_test
  File "renpy/common/00gltest.rpy", line 358, in script
    $ __gl_test()
  File "renpy/common/00gltest.rpy", line 358, in <module>
    $ __gl_test()
  File "renpy/common/00gltest.rpy", line 284, in _m1_00gltest__gl_test
    _gl_performance_test()
  File "renpy/common/00gltest.rpy", line 301, in _gl_performance_test
    ui.interact(suppress_underlay=True, suppress_overlay=True)
AttributeError: 'StoreModule' object has no attribute 'show_text_during_trans'
And the...

Code: Select all

init -9999 python:

    show_text_during_trans = False
code is currently in options.rpy

Post Reply

Who is online

Users browsing this forum: Google [Bot], kylemercury