Hiding only part of a screen with the middle mouse button

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
goldo
Regular
Posts: 63
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Hiding only part of a screen with the middle mouse button

#1 Post by goldo » Fri Jul 24, 2020 5:13 am

Hi guys,

I want to emulate the behavior of 'hide_windows', but keep parts of a screen showing together with the background image.

So my screen is set up to override the middle button keymap, like so:

Code: Select all

screen night(event_pic = None, event_bg = None, changes = "", has_log = True): # event_pic can be an object or a string

    tag show_screen

    default show_ui = True

    key "mouseup_2" action ToggleScreenVariable("show_ui")
    
The 'show_ui' var is then used within the screen code to determine what needs to be hidden or not.

However, my problem is that when a 'say' window is showing as well, the say window stays on when I click the middle button. This is not what I want.

So I tried:

Code: Select all

screen night(event_pic = None, event_bg = None, changes = "", has_log = True): # event_pic can be an object or a string

    tag show_screen

    default show_ui = True

    key "mouseup_2" action (ToggleScreenVariable("show_ui"), ToggleScreen("say"))
Which works fine on the first click, but crashes when clicking the middle mouse button again:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/BKendday.rpy", line 686, in script call
    call show_night_event(ev)
  File "game/BKevents.rpy", line 1003, in script
    $ renpy.say(ev.char, text_descript)
  File "game/BKevents.rpy", line 1003, in <module>
    $ renpy.say(ev.char, text_descript)
Exception: Required parameter who has no value.

Apparently, while the 'say' window was hidden, the game forgot what it was supposed to say.


I then took various shots in the dark, all of which failed:

Code: Select all

 renpy.curried_call_in_new_context("_hide_windows")

HideInterface()

Function(ui.interact, suppress_overlay=False, suppress_window=True)

renpy.curried_invoke_in_new_context(ui.interact, suppress_overlay=False, suppress_window=True)
The best I could do is this:

Code: Select all

screen night(event_pic = None, event_bg = None, changes = "", has_log = True): # event_pic can be an object or a string

    tag show_screen

    default show_ui = True

    if show_ui:
        key "mouseup_2" action (ToggleScreenVariable("show_ui"), Hide("say")) #, ToggleScreen("say")), renpy.curried_call_in_new_context("_hide_windows"), HideInterface(), renpy.curried_invoke_in_new_context(ui.interact, suppress_overlay=False, suppress_window=True) all don't work
    else:
        key "mouseup_2" action (ToggleScreenVariable("show_ui"), Function(renpy.get_reshow_say))
But instead of working as I expected (showing the say window again with the correct dialog), it just jumps to the next line of dialogue when clicking the middle mouse button for the second time.


So I'm stuck. Does anyone know how I could achieve what I'm going for: hiding parts of a screen plus the say window and then showing both again at the click of a mouse button? Thank you!

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: Hiding only part of a screen with the middle mouse button

#2 Post by Remix » Fri Jul 24, 2020 7:38 pm

tbh I've not fully read through all...

Perhaps just conditional the screen say.... if show_ui, show content, else ignore it or maybe just shift it offscreen
Frameworks & Scriptlets:

goldo
Regular
Posts: 63
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Hiding only part of a screen with the middle mouse button

#3 Post by goldo » Fri Jul 24, 2020 7:45 pm

Thank you for your reply. show_ui is a local screen variable, but I suppose I could introduce a global variable to do that instead.

If there's a solution that doesn't involve changing the 'say' screen (I've been trying to keep original renpy screens untouched), I would like that, but otherwise I could go that route.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]