Page 1 of 1

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

Posted: Wed Nov 17, 2010 1:59 pm
by brofisto
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.

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

Posted: Wed Nov 17, 2010 9:29 pm
by Formedras
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.

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

Posted: Wed Nov 17, 2010 10:29 pm
by broken_angel
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.

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

Posted: Thu Nov 18, 2010 10:09 am
by brofisto
Thanks for your help, everything working fine now.
Sorry, I should have read the documentation more carefully, but I appreciate all your help.