Preventing user clicking on screen during dialogue

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:

Preventing user clicking on screen during dialogue

#1 Post by goldo » Mon Jan 23, 2017 8:48 am

Hi, I am trying to do something a little tricky.

I have a screen full of buttons, which I want to still show in the background during a particular dialogue.
But I do not want the player to be able to click on the screen buttons while the dialogue is playing.

To achieve this, I have covered the button screen with another screen which has some opacity and activates at the start of the dialogue (to indicate to the player that the background screen is unavailable), and I have made that screen modal.

However, because of the modal screen, it is now impossible to advance through the game. The dialogue just stays stuck at the first sentence.

I tried putting the 'say' window on a high zorder, but it doesn't help. I'm guessing the 'click-to-advance' behavior is happening on a low layer.

What would be the best way to approach this particular problem? Thanks a lot!

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Preventing user clicking on screen during dialogue

#2 Post by Ocelot » Mon Jan 23, 2017 11:01 am

Modal screens would stop interactions with everything until you hide them. Including advancing and other screens. You could make your modal screen one pixel in size and it would still block everything

Quick fix is make screen non-modal and a single invisible button, covering whole screen, with do-nothing action.
< < insert Rick Cook quote here > >

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Preventing user clicking on screen during dialogue

#3 Post by Imperf3kt » Mon Jan 23, 2017 2:10 pm

I'd personally use imagebuttons and place their images on screen and not make them buttons until you need them to be buttons.
No need to rely on blocking the buttons then.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

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

Re: Preventing user clicking on screen during dialogue

#4 Post by goldo » Mon Jan 23, 2017 11:25 pm

Ocelot wrote:Modal screens would stop interactions with everything until you hide them. Including advancing and other screens. You could make your modal screen one pixel in size and it would still block everything

Quick fix is make screen non-modal and a single invisible button, covering whole screen, with do-nothing action.
Thanks! I'll try that, and report.

Edit:
So I tried with an invisible button. It almost works as intended, however, advancing the story only happens when clicking outside the invisible screen. That could be confusing for players. Is there any way I could cause the invisible button to advance to the next line of conversation instead of doing nothing?

Here's an illustration of what I'm trying to achieve:
Image

PS: I am not using image buttons at all for that game, it's a design decision that would be too complex to unwind. I could also set a blocking variable and use it with an 'if' clause on each button's action, but that would add a lot of clutter to the code, because there are lots of buttons...

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

Re: Preventing user clicking on screen during dialogue

#5 Post by goldo » Wed Jan 25, 2017 12:07 am

goldo wrote: So I tried with an invisible button. It almost works as intended, however, advancing the story only happens when clicking outside the invisible screen. That could be confusing for players. Is there any way I could cause the invisible button to advance to the next line of conversation instead of doing nothing?
I found the solution, and it was actually super easy! All I had to do was mapping the invisible button to the action 'Return()', and voila, the game advances when clicking. Thank you guys for your help.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]