How can I make a "Show CG"/"Hide UI" 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
User avatar
Mizuiru
Newbie
Posts: 11
Joined: Fri Aug 07, 2009 5:44 pm
Contact:

How can I make a "Show CG"/"Hide UI" button?

#1 Post by Mizuiru » Sat May 29, 2010 9:22 pm

Something I'm used to from playing games based on other visual novel engines is the ability for the user to temporarily hide all of the game's user interface and just show the artwork in the background.

Usually this is either handled by right-clicking anywhere in the game window, or by clicking a button somewhere on the screen. Everything disappears except the painting/pretty girl/whatever in the background, until the user clicks the mouse or hits a key.

I think what I mean in Ren'Py terms is that I'd like to let the user do a 'window hide' any time they want. Is there a way to do that?

(I'd especially love to get the right mouse button doing that, but I'm not sure if it's possible.)

Thanks for any help!

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#2 Post by Aleema » Sat May 29, 2010 9:35 pm

The middle mouse button does this (also, the key "H"). Did you know that, or do you still want to reassign the keymap?

User avatar
Mizuiru
Newbie
Posts: 11
Joined: Fri Aug 07, 2009 5:44 pm
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#3 Post by Mizuiru » Sat May 29, 2010 9:39 pm

Ah, thank you! I was searching for the way to do it, but couldn't seem to find a thread/FAQ entry where it was mentioned. (Edit: Figures it was under the Help button.) I'm using one of those weird Apple mice without any buttons (let alone a middle one), so it didn't occur to me that it might have been that.

That should work fine, yes! However, from a tinkerer's point of view, I'm still curious how one would go about changing the keymap or creating an interface button for it. If you know how to do so, I'd be grateful for the explanation. :)

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#4 Post by Aleema » Sat May 29, 2010 10:17 pm

An interface button for it would look something like:

Code: Select all

ui.imagebutton("hidebuttonoff.png", "hidebuttonon.png", clicked=renpy.curried_call_in_new_context("_hide_windows"))
To change a keymap, look over all the current definitions. You'll see the hiding the windows is assigned to the following three buttons: 'mouseup_2', 'h', 'joy_hide'
The button value for "right mouse click" is 'mouseup_3'. So you'd probably want something like this:

Code: Select all

init:
    $ config.keymap['hide_windows'].append('mouseup_3')
    $ config.keymap['hide_windows'].remove('mouseup_2')

User avatar
Mizuiru
Newbie
Posts: 11
Joined: Fri Aug 07, 2009 5:44 pm
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#5 Post by Mizuiru » Sun May 30, 2010 12:27 pm

Wow, thank you for the help. It's amazing to me how powerful Ren'Py can be when one knows how to use it.

This also answers about a dozen questions I had about how to set up a custom interface, since it lead me to reading up on the various "ui" functions. So, again, thanks!

Looking over the various projects linked in your sig, now I'm wondering if there's anything Ren'Py can't do. :shock:

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#6 Post by Aleema » Sun May 30, 2010 1:46 pm

Mizuiru wrote:Wow, thank you for the help. It's amazing to me how powerful Ren'Py can be when one knows how to use it.

This also answers about a dozen questions I had about how to set up a custom interface, since it lead me to reading up on the various "ui" functions. So, again, thanks!

Looking over the various projects linked in your sig, now I'm wondering if there's anything Ren'Py can't do. :shock:
Good for you! UI functions are really, really awesome. :D
And yes, if you know a little Python, Ren'Py can go a looong way.

User avatar
boboverlord
Newbie
Posts: 19
Joined: Thu Nov 27, 2008 11:01 am
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#7 Post by boboverlord » Mon May 31, 2010 2:17 pm

I'm finding this answer too! Great help!

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#8 Post by Soraminako » Mon Oct 24, 2011 2:08 am

Aleema wrote:An interface button for it would look something like:

Code: Select all

ui.imagebutton("hidebuttonoff.png", "hidebuttonon.png", clicked=renpy.curried_call_in_new_context("_hide_windows"))
Sorry to resurrect an old thread, but I was trying to do something similar to what this code would do, and was wondering if I might be missing something to make it work... :?

I tried:

Code: Select all

ui.imagebutton("hidebuttonoff.png", "hidebuttonon.png", clicked=renpy.curried_call_in_new_context("_screenshot"))
But it just crashes ren'py after attempting to find an nonexistent "_screenshot" label.

I was trying to make a button that does what the "s" key does, saving a screenshot for the player.

Also, is there a way to change the place to where the screenshots are saved? ^^;

I've been scouring the old posts but couldn't find anything on that.
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#9 Post by DragoonHP » Mon Oct 24, 2011 3:57 am

It should probably work...

Code: Select all

textbutton _("Screenshot") action Screenshot()

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#10 Post by Soraminako » Mon Oct 24, 2011 9:05 am

It crashes ren'py, but this seems to be due to the same bug in reaction to bracket folders that ren'py was having before the upgrade to 6.13.7. It's odd. O_o
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#11 Post by DragoonHP » Mon Oct 24, 2011 9:29 am

It works on my 6.13.7...
Weird...

Try to place it in Quick Menu and see if it works...

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#12 Post by Soraminako » Mon Oct 24, 2011 5:48 pm

That game is a short one for which I disabled quick menu, but in any case, PyTom confirmed the problem comes from ren'py reacting to the brackets in the title of folders and crashing. So once that's fixed the code should work for me too. :)
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
Purukitto
Newbie
Posts: 2
Joined: Mon Aug 16, 2021 1:02 pm
Github: Purukitto
itch: purukitto
Contact:

Re: How can I make a "Show CG"/"Hide UI" button?

#13 Post by Purukitto » Mon Aug 16, 2021 1:13 pm

The simplest way in the latest version would be to do the following

Code: Select all

textbutton _('Hide UI') action HideInterface()

Post Reply

Who is online

Users browsing this forum: No registered users