[Solved]NVL mode: hiding window with a transition

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
shary
Newbie
Posts: 5
Joined: Sun Jun 28, 2015 8:12 pm
Contact:

[Solved]NVL mode: hiding window with a transition

#1 Post by shary »

Hi. I need some help to hide the nvl window using a transition. All I managed to do is hiding it instantly or not hiding it at all…

So I have something like this (narrator is in nvl mode):

Code: Select all

    hide window
    show foo bar with None    
    "stuff"
The result I'm expecting is that the window will slowly disappear, then the foo sprite should change instantly without any transition and the window will reappear really quickly to show "stuff".

I tried first to change config.window_hide_transition and config.window_show_transition with some transitions but it doesn't work. In fact when doing this, the window isn't hiding at all since the sprite change is instantaneous.


If I add a pause like this:

Code: Select all

    hide window
    $renpy.pause(2)
    show foo bar with None
    "stuff"
It's still not the behavior I'm expecting. The window will hide instantaneously without any transition, then the game will pause and then the window will reappear at the exact same time than the sprite will change.

This code didn't worked either:

Code: Select all

    hide window with dissolve(2)
    show foo bar with None
    "stuff"
The window is hiding instantaneously and then the game will wait for the same time the transition should have taken before changing the sprite and making the window reappear both at the same time.

I think the cause is that the screen used for the window is "transient" and will hide when a transition start. But I couldn't find how to deactivate this behavior.
Last edited by shary on Thu Jul 02, 2015 11:41 pm, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: NVL mode: hiding window with a transition

#2 Post by PyTom »

you probably want "window show" and "window hide":

Code: Select all

window show dissolve

Code: Select all

window hide dissolve
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

shary
Newbie
Posts: 5
Joined: Sun Jun 28, 2015 8:12 pm
Contact:

Re: NVL mode: hiding window with a transition

#3 Post by shary »

Wow. That's an odd syntax. I tried "window hide" and it didn't work, it was still instantaneous. Then I tried "window hide with dissolve" but got a syntax error. So that is the good syntax…

Anyway. With your solution the window does appear with a dissolve animation, so we're getting somewhere. But there are still two problems left.

First, I wish I could use some kind of global setting (I thought config.window_hide_transition would do the trick) because I'm going to do that like every time. If I have to change the duration of that dissolve I will have a really bad time.

However, I can get over this problem I guess… I just have to make a $showWindow() python function or something. I'm just wondering if there is a cleaner solution.

Secondly, and that's the real problem, the hiding is still instantaneous, only the reappearing is working. It just hide instantaneously, change the sprite instantaneously and then slowly reappear with a dissolve transition. Not exactly the behavior I'm expecting…


And now, that I think of it, the behavior I'm expecting can be simply illustrated actually. This is just like the way higurashi is working, at least the steam version: https://youtu.be/JhW5nhg1ld4?t=9m7s

So if I want to reproduce this scene it should be something like this:

Code: Select all

    "\"I'll leave you in the dust."
    extend " Without looking back.\""
    $windowHide()
    show rena blushing
    $windowShow()
    "\"Why are you so mean?{w=0.4} ...Why?\""
Or something similar that do the trick and it should result just like that video. That's more or less what I'm looking for.

shary
Newbie
Posts: 5
Joined: Sun Jun 28, 2015 8:12 pm
Contact:

Re: NVL mode: hiding window with a transition

#4 Post by shary »

Bump.

Ok, so… For some reasons it seems that "nvl hide" instead on "window hide" do the job. I have no idea why. It's basically the same thing, right? It doesn't make any sense, if anyone has an explanation… Anyway, I can have a satisfying result with a code like that:

Code: Select all

    nvl hide Dissolve(3)
    show foo bar
    nvl show Dissolve(0.3)
(Dissolve(3) is way too long but that's just an example)

So the result is good, at last. (show AND hide) But this is still really really inconvenient and far from a durable solution. First the transition after "nvl hide" is supposed to be optional, by supposed I mean, it's written in the doc: http://renpy.org/doc/html/nvl_mode.html ... ode-window But of course it isn't! (error: expected simple expression).

Also there isn't any way to choose a default transition and the configurations empty_window, window_hide_transition, window_show_transition have no effect at all on nvl hide

But it's ok. I just have to define a nvlHide() python function, right? So that I can choose a default transition, maybe add a little pause or even include it in a custom config.show() function do to everything with just one line of code. So, let's try this:

Code: Select all

    def nvlHide():
        Hide(nvl, transition = Dissolve(3)) # I hope this is the right 'nvl hide' python equivalent.
        renpy.pause(0.2)
        return
And, of course, it doesn't work. The window is hidden instantaneously without taking the transition into account. I also tried to do a nvlShow(), same result.

Did i make a mistake anywhere? Does anybody has another, working solution? I'm looking into so much complicated stuff to do something so fucking simple, it's driving me crazy.


Edit:
Hold on!. I may have found a solution… "Hide" isn't the equivalent of "nvl hide", "nvl_hide()" is! And it DOES have a default value: config.adv_nvl_transition.
So if I change that line into "nvl_hide(Dissolve(3))", it works!

Now I just have to make a custom config.show() before I can tag the thread as solved.
I'd also like some explanation on why the "window hide" wouldn't works… There is no reason it wouldn't work…

shary
Newbie
Posts: 5
Joined: Sun Jun 28, 2015 8:12 pm
Contact:

Re: NVL mode: hiding window with a transition

#5 Post by shary »

Ok, this time it's solved for good. There are still some stuff I don't understand and I don't like when I don't understand things so don't hesitate to reply if you want to, but at least I found a solution.

So to summarize for my fellows lurkers who have a similar problem, here are some complete copy-pasta-ble examples of what works/doesn't work. And my (over complicated) solution:

The first thing I tried that didn't work (but should?):

Code: Select all

# You can place the script of your game in this file.

init -1 python hide:    
    config.empty_window = nvl_show_core

    ## Used when the window is shown.
    config.window_show_transition = Dissolve(0.2)

    ## Used when the window is hidden.
    config.window_hide_transition = Dissolve(0.4)

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"
image eileen = Placeholder()
image white = Placeholder("bg")

# Declare characters used by this game.
#define e = Character('Eileen', color="#c8ffc8")

define narrator = Character(None, kind=nvl)

# The game starts here.
label start:
    scene white    

    show eileen happy

    "You've created a new Ren'Py game."

    window hide ##doesn't work
    show eileen sad with Dissolve(0.3)
    window show ##actually work

    "Once you add a story, pictures, and music, you can release it to the world!"

    return

It could have been that simple if it worked… Anyway. Because of some voodoo magic, using nvl hide give some better results:

Code: Select all

# You can place the script of your game in this file.

init -1 python hide:    
    config.empty_window = nvl_show_core #useless

    ## Used when the window is shown.
    config.window_show_transition = Dissolve(4) #useless

    ## Used when the window is hidden.
    config.window_hide_transition = Dissolve(3) #useless

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"
image eileen = Placeholder()
image white = Placeholder("bg")

# Declare characters used by this game.
#define e = Character('Eileen', color="#c8ffc8")

define narrator = Character(None, kind=nvl)

# The game starts here.
label start:
    scene white    

    show eileen happy

    "You've created a new Ren'Py game."

    nvl hide Dissolve(0.4) #Dissolve(0.4) is NOT optional
    show eileen sad with Dissolve(0.3)
    nvl show Dissolve(0.2)

    "Once you add a story, pictures, and music, you can release it to the world!"

    return
This code works, but the syntax sucks and the documentation is wrong, as I said before.

A more sane solution is to make a python function. I think this solution is good enough for most people, I added a pause and the result is really smooth and nice. I like it:

Code: Select all

# You can place the script of your game in this file.

init -1 python hide:    
    config.empty_window = nvl_show_core #still useless

    ## Used when showing NVL-mode text directly after ADV-mode text.
    config.adv_nvl_transition = Dissolve(0.2)

    ## Used when showing ADV-mode text directly after NVL-mode text.
    config.nvl_adv_transition = Dissolve(0.4)

init 1 python:
    def nvlHide():
        nvl_hide(config.nvl_adv_transition)
        #Hide(nvl, transition=Dissolve(3)) #Dissolve(3))
        renpy.pause(0.1)
        return

    def nvlShow():
        renpy.pause(0.1)
        nvl_show(config.adv_nvl_transition)
        #Show(nvl, transition=downLong) #Dissolve(3))
        return


# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"
image eileen = Placeholder()
image white = Placeholder("bg")

# Declare characters used by this game.
#define e = Character('Eileen', color="#c8ffc8")

define narrator = Character(None, kind=nvl)

# The game starts here.
label start:
    scene white    

    show eileen happy

    "You've created a new Ren'Py game."

    $nvlHide()
    show eileen sad with Dissolve(0.3)
    $nvlShow()

    "Once you add a story, pictures, and music, you can release it to the world!"

    return

And now my insane solution. I wanted to change config.show at first but it's a terrible idea, adding pause to config.show make everything buggy. This solution is still probably buggy but at least all the code is define in one place and can be easily fixed without doing search/replaces in hundred of script files. It really is too complicated for what it does but the separation of code logic and script and the syntax simplification please the developer in me and I think it really worth it. You actually need to make a second file which name start with 0, for example 00statements.rpy (I defined a new statement):

Code: Select all

python early:
    
    def execute_nvlShow( (imspec, atl,  expr_with) ):
        (image_name, expression, tag, at_list, layer, zorder, behind) = imspec
        
        if expr_with == None:
            expre_with = Dissolve(0.3)
        
        nvlHide()
        renpy.ast.show_imspec(imspec, atl=atl)
        renpy.with_statement(expr_with)
        nvlShow()
        return

    def parse_nvlShow(lex):
        (image_name, expression, tag, at_list, layer, zorder, behind) = renpy.parser.parse_image_specifier(lex)

        if lex.keyword("with"):
            expr_with = eval(lex.require(lex.simple_expression))
        else:
            expr_with = None

        atl = None
        if lex.match(':'):
            atl = renpy.atl.parse_atl(l.subblock_lexer())
        else:
            lex.expect_noblock('show statement')
                
        lex.expect_eol()
        lex.advance()
            
        return ((image_name, expression, tag, at_list, layer, zorder, behind), atl, expr_with)

    def predict_nvlShow( (imspec, atl, expr_with) ):
        renpy.atl.predict_imspec(imspec, atl=atl)
    
    renpy.register_statement("nvlShow", parse=parse_nvlShow, execute=execute_nvlShow, predict=predict_nvlShow)
I won't explain the code though… It works because magic.

and the script file:

Code: Select all

# You can place the script of your game in this file.

init -1 python hide:    
    config.empty_window = nvl_show_core #still useless

    ## Used when showing NVL-mode text directly after ADV-mode text.
    config.adv_nvl_transition = Dissolve(0.2)

    ## Used when showing ADV-mode text directly after NVL-mode text.
    config.nvl_adv_transition = Dissolve(0.4)

init 1 python:
    def nvlHide():
        nvl_hide(config.nvl_adv_transition)
        #Hide(nvl, transition=Dissolve(3)) #Dissolve(3))
        renpy.pause(0.1)
        return

    def nvlShow():
        renpy.pause(0.1)
        nvl_show(config.adv_nvl_transition)
        #Show(nvl, transition=downLong) #Dissolve(3))
        return


# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"
image eileen = Placeholder()
image white = Placeholder("bg")

# Declare characters used by this game.
#define e = Character('Eileen', color="#c8ffc8")

define narrator = Character(None, kind=nvl)

# The game starts here.
label start:
    scene white    

    show eileen happy

    "You've created a new Ren'Py game."

    nvlShow eileen sad #yeah, that's it. That's all you have to write.

    "Once you add a story, pictures, and music, you can release it to the world!"

    $nvlHide()
    show eileen happy with Dissolve(0.3)
    show eileen sad with Dissolve(0.3)
    show eileen happy with Dissolve(0.3)
    $nvlShow()

    "You can still use the old method when you need to make multiple show."    

    return

My solution is really complex but it gave me the occasion to read a lot of renpy code on github and I learned a lot, so it wasn't a waste of time. I'm just surprised I had to do that much to get a result so simple. (or maybe I'm just a bit crazy).
I didn't get too many answers but I know quite a lot of people read me so, thanks everyone for your time. And if you know why the first solution doesn't work, don't hesitate to reply even if the thread is tagged Solved.
And thanks to people that post real solution of their problems and not just "lol never mind it works now." https://i.imgur.com/vuk57a6.png

Post Reply

Who is online

Users browsing this forum: No registered users