In-game buttons and disabling of certain features...(SOLVED)

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
brofisto
Regular
Posts: 51
Joined: Thu Nov 04, 2010 4:24 pm
Organization: The Neotable
Contact:

In-game buttons and disabling of certain features...(SOLVED)

#1 Post by brofisto » Wed Nov 17, 2010 1:59 pm

Is there a way to have a button cover an area of the screen in-game?
Image
I want the red button to cause the game to quit, but I don't know how to make it happen.


Is there a way to completely disable right-clicking?
Seems straightforward enough, but I can't seem to figure it out.


Is there a way to disable rollback?
Once again, I can't figure it out.


Is there a way to disable the "Are you sure you want to quit?" message?
It bugs me in every game I make.
Last edited by brofisto on Thu Nov 18, 2010 10:10 am, edited 2 times in total.
ImageImageImage

User avatar
Formedras
Regular
Posts: 40
Joined: Sat Oct 04, 2008 3:11 am
Projects: Ninja TK
Contact:

Re: In-game buttons and disabling of certain features...

#2 Post by Formedras » Wed Nov 17, 2010 9:29 pm

To quit, call renpy.quit() as a python function, or jump to the label _quit. These methods also bypass the confirm-quit prompt.
If you want to instead send the player back to the main menu, call renpy.full_restart() as a python function. Again, this disables the associated prompt.

To disable rollback, $ config.rollback_enabled = False.

The effect of right-clicking (and also ESC) is disabled by $_game_menu_screen = None. (This is how it appears in the documentation; it may be inaccurate in that it might need a space after the $.)

To remove the game menu's confirm-quit prompt, modify the Quit button (this, I'm not sure of how, but I know it's in the docs) to jump to _quit instead of calling _quit_prompt.
(This is not suggested, even if it annoys you as a maker. Having a user accidentally quit before they have a chance to save is even more of an annoyance to them.)

All of this is in the documentation and FAQ (Except maybe the _quit label). Please, in the future, read the docs and make cursory explorations before asking easy questions. That's what it's there for.
http://www.google.com/profiles/tizalka
Current Project:
Ninja TK

broken_angel
Veteran
Posts: 322
Joined: Sun Oct 03, 2010 11:49 pm
Completed: Memoirs of an Angel (2010)
Projects: Memoirs of an Angel (Remake); W.I.S.H
Location: United States
Contact:

Re: In-game buttons and disabling of certain features...

#3 Post by broken_angel » Wed Nov 17, 2010 10:29 pm

Creating an on-screen button can be found in the Cookbook (Button Game Menu).
Just replace "textbutton" with "imagebutton". You can format it like...

Code: Select all

show_whatever_button = False
    
    def whatever_button():

        if show_whatever_button:

            ui.hbox(xpos = 100, xalign=0, ypos = 100, yalign=0)
            ui.imagebutton("idle.png", "hover.png", clicked=renpy.curried_call_in_new_context("label_to_jump_to"))
            ui.close()
    
    config.overlay_functions.append(whatever_button)
The above assumes that you'll want the button to appear at certain times and disappear at others, so you can toggle it using
$ show_whatever_button = True/False

Or you can actually add a button a little easier with the new screen language.

Code: Select all

screen whatever:
    hbox xalign 0 yalign 0:
        imagebutton auto "button_%s.png" action Jump('label_to_jump_to') pos (100,100)

## Here's an example of how to toggle the button to show or disappear.
label start:

    show screen whatever
    "Now you see it..."

    hide screen whatever
    "...And now you don't."
In the above example, you would need to make six images:
button_idle, button_hover, button_insensitive, button_selected_idle, button_selected_hover, button_selected_insensitive

Both methods do the same thing - show a button on the screen. However, if you plan for the button to go to a pre-defined Ren'py label (such as jump to the main menu, a game menu, or the confirm quit screen), then you'll want to use the first method so that the button disappears when you go to that screen.

User avatar
brofisto
Regular
Posts: 51
Joined: Thu Nov 04, 2010 4:24 pm
Organization: The Neotable
Contact:

Re: In-game buttons and disabling of certain features...

#4 Post by brofisto » Thu Nov 18, 2010 10:09 am

Thanks for your help, everything working fine now.
Sorry, I should have read the documentation more carefully, but I appreciate all your help.
ImageImageImage

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Ocelot, Sergei Falcon