Page 1 of 1

Make imagebuttons unclickable under choice menus

Posted: Wed Jun 01, 2022 8:40 pm
by Gigan
Hello everyone ! Sorry for bothering you again but I have 0 idea on how to fix that problem. :/

I have a shop screen with several clickable imagebuttons (only the diary here, and the "back" one) :
Image

When you click on a item, a choice menu appear :
Image

The problem is the action won't be completed if when clicking on the "Yeah" option, the mouse cursor is still on the imagebutton. The first and second screens just repeat themselves until I click somewhere else. Only then, the purchase is deemed completed and the item disappear from the shelves.

Any way to correct that problem ? Like, by making the imagebutton unclickable when a choice menu appear ? :/

My code, for what it's worth :

Code: Select all

screen magasin_hotspot():
    add "bg/bg magasin_vente.png"
    add "candiceshop" at right
    add "candiceshop_eye neutre" at right
    add "candiceshop_mouth parle" at right
    imagebutton: #Bouton retour
        focus_mask True
        xpos 10
        ypos 400
        idle "imagebutton_retour.png"
        action [Hide("magasin_hotspot"), Jump("shop_1_choix")]
    if diary_shop == True: #diary
        imagebutton:
            focus_mask True
            xpos 400
            ypos 40
            idle "diary_icon.png"
            action Jump("diary_conv")

Code: Select all

label shop_buy:
    show screen magasin_hotspot
    show screen money_display
    c "Take your time."

label diary_conv:
    menu:
        c "An old diary. Found it on the floor. Most of the pages are torn, but heh. Selling it anyway... 100 Gold."
        "Yeah":
            if money_points >= 100:
                c "Thank you !"
                play sound "audio/jingle_tresor2.wav"
                d "{color=#ad2c05}{font=fonts/BaksoSapi.otf}{size=+8}You got a diary !{/size}{/font}\nWhat it is all about...{/color}"
                $ diary_shop = False
                $ money_points -= 100
                $ got_diary = True
                $ got_diary_shop = True
                $ first_time_diary = True
                $ first_time_diary_buffalo = True
                jump shop_buy
            else:
                c "You don't have enough money, you doofus !"
                jump shop_buy
        "no":
            c "Alright."
            jump shop_buy

Re: Make imagebuttons unclickable under choice menus

Posted: Thu Jun 02, 2022 12:05 am
by niho
A simple way to enable/disable buttons is by using sensitive. You can either give it a true/false statement or a flag, so that the button is only enabled when its flag is true. For example you could add sensitive buttons_enabled to every button that you want to be disabled at some point, so then you can just add the following to your labels:

Code: Select all

label shop_buy:
    $ buttons_enabled = True
    ...

label diary_conv:
    $ buttons_enabled = False
    ...
    
And you shouldn't be able to click the other buttons.

Re: Make imagebuttons unclickable under choice menus

Posted: Thu Jun 02, 2022 4:32 am
by Ocelot
modes were made for that.

Code: Select all

screen scr():
    $ in_menu = (renpy.get_mode() == 'menu')
    # . . .
    buttton:
        sensitive not in_menu
        

Re: Make imagebuttons unclickable under choice menus

Posted: Thu Jun 02, 2022 5:07 am
by Gigan
Well that was easier than expected. :|
Thank you so much to both of you ! ( >^_^)>