[Solved] Only allow hide_windows if say/etc actually displayed

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
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

[Solved] Only allow hide_windows if say/etc actually displayed

#1 Post by Tayruu »

I have found the function to hide the dialogue window (via mouse-wheel or other buttons) has the issue of causing transition/animation issues if the button is pressed during non-dialogue contexts. Either it makes transitions/animations skip ahead, or fail to play until after a certain amount of time, giving the impression of the game locking up.

To get around this I've been trying to make it so a hide_window function can only be triggered if the say, nvl, or choice window is actually on-screen, but I have been having no luck with this.
  • renpy.get_screen("say") is an example given in the documentation, but it always seems to return None, even when say dialogue is on-screen.
  • This thread recommends renpy.has_screen but I'm pretty sure that checks if a screen is defined, not on-screen.
  • renpy.current_screen().screen_name[0] seems to be the most functional method, but sometimes it returns something other than say/etc despite being on-screen, thus they can't be assured to be at [0].
I also tried creating a _showing_window variable and turning it on/off via on "show"/"hide" in the say screen, however that caused dialogue to behave erratically.

Can anyone give any suggestions as to either detect the dialogue screens, or another way to make sure the window toggling function doesn't cause graphical glitches?
Last edited by Tayruu on Tue Oct 23, 2018 6:47 am, edited 1 time in total.

User avatar
Andredron
Miko-Class Veteran
Posts: 718
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Only allow hide_windows if say/etc actually displayed

#2 Post by Andredron »

Tayruu wrote: Tue Sep 04, 2018 4:04 am I have found the function to hide the dialogue window (via mouse-wheel or other buttons) has the issue of causing transition/animation issues if the button is pressed during non-dialogue contexts. Either it makes transitions/animations skip ahead, or fail to play until after a certain amount of time, giving the impression of the game locking up.

To get around this I've been trying to make it so a hide_window function can only be triggered if the say, nvl, or choice window is actually on-screen, but I have been having no luck with this.
  • renpy.get_screen("say") is an example given in the documentation, but it always seems to return None, even when say dialogue is on-screen.
  • This thread recommends renpy.has_screen but I'm pretty sure that checks if a screen is defined, not on-screen.
  • renpy.current_screen().screen_name[0] seems to be the most functional method, but sometimes it returns something other than say/etc despite being on-screen, thus they can't be assured to be at [0].
I also tried creating a _showing_window variable and turning it on/off via on "show"/"hide" in the say screen, however that caused dialogue to behave erratically.

Can anyone give any suggestions as to either detect the dialogue screens, or another way to make sure the window toggling function doesn't cause graphical glitches?
?

Code: Select all

$ _window_during_transitions = True
 


User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: Only allow hide_windows if say/etc actually displayed

#3 Post by Tayruu »

I'm not sure what I'm supposed to do with that? Looking it up it sounds like a different function entirely - that it makes the dialogue window remain on-screen.

User avatar
XxrenxX
Veteran
Posts: 267
Joined: Tue Oct 02, 2012 2:40 am
Projects: Chasing
Deviantart: bara-ettie
Location: Canada
Contact:

Re: Only allow hide_windows if say/etc actually displayed

#4 Post by XxrenxX »

Tayruu wrote: Wed Sep 05, 2018 10:33 pm I'm not sure what I'm supposed to do with that? Looking it up it sounds like a different function entirely - that it makes the dialogue window remain on-screen.
That function works as a True/False statement. I use it a few times during my game for certain scenes. The below code makes it so when I have the set animation happening the window will not show.

Code: Select all

$ _window_during_transitions = False
scene bg Park1 Purple 
show M Black with flash
pause 0.6
hide M Black
scene bg LivingRoom Day with flash
$ _window_during_transitions = True

"The script/dialogue continues normally after"
there is also the window hide function that I have used in some set animations for my game but I haven't used that in the script file so you may need to try and see what would work better for what you need.

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: Only allow hide_windows if say/etc actually displayed

#5 Post by Tayruu »

I used window show and window hide quite regularly, so _window_during_transitions probably doesn't do anything for me.

And it still doesn't help for detecting if the relevant windows are visible.

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: Only allow hide_windows if say/etc actually displayed

#6 Post by Tayruu »

So this probably isn't the most perfect solution, but it seems to achieve 90% of the job.

The variable store._last_say_who appears to store, well, the last "who" of dialogue. By using this in _new_hide_windows (an edit of the window hiding method), I can skip the function if there's no present dialogue.

Code: Select all

label _new_hide_windows:
    if renpy.context()._menu:
        return
    if not store._last_say_who:
        return
    if _windows_hidden:
        return
    python:
        # Enter hiding mode
        _windows_hidden = True
        renpy.transition(Dissolve(0.2))
        # Keys to exit
        ui.saybehavior(dismiss=['dismiss', 'hide_windows'])
        ui.interact(suppress_overlay=True, suppress_window=True)
        # Fade and exit
        renpy.transition(Dissolve(0.2))
        _windows_hidden = False
    return
The 10% imperfection is if a line of text has no speaker specified (just text within quotes), or when a choice menu is on-screen but there's no paired dialogue. Both these things I should hopefully avoid by design.

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: [Solved] Only allow hide_windows if say/etc actually displayed

#7 Post by rames44 »

So, could you not modify the “say” screen so that it used “on show” and “on hide” to set and clear a global Boolean variable of your own? And if you need to distinguish between the “say” window in dialog and in a choice, do the same thing (with a different variable) with the choice screen?

Seems that would be a lot easier...

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: [Solved] Only allow hide_windows if say/etc actually displayed

#8 Post by Tayruu »

In my original post I mention trying that, but it "caused dialogue to behave erratically". I don't remember what happened exactly, but I think it caused visual glitches?

And besides that would only affect the say screen, this works for say and nvl.

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: [Solved] Only allow hide_windows if say/etc actually displayed

#9 Post by rames44 »

Apologies - misread that part of the OP. Seems odd that that would make the dialog behave badly.

Post Reply

Who is online

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