Make options in menu unelectable/grayed out?

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
Beckers
Regular
Posts: 30
Joined: Thu May 16, 2013 4:21 am
Contact:

Make options in menu unelectable/grayed out?

#1 Post by Beckers »

I was wondering if there's a way to make menu options unclickable, but still appear/be visible? Help is appreciated, thanks in advance :)

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Make options in menu unelectable/grayed out?

#2 Post by Alex »


jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: Make options in menu unelectable/grayed out?

#3 Post by jw2pfd »

I have seen this question pop up a few times and have had a similar interest in having more control over a menu so I started working on some code. I posted a basic version in the Cookbook section that may or may not be helpful -> http://lemmasoft.renai.us/forums/viewto ... 51&t=25460

bg_nocturnal
Regular
Posts: 25
Joined: Thu Feb 13, 2014 9:45 am
Contact:

Re: Make options in menu unelectable/grayed out?

#4 Post by bg_nocturnal »

I already did something similar in another topic. I believe the same approach can help make this work, too:

Code: Select all

screen choice:

    window: 
        style "menu_window"        
        xalign 0.5
        yalign 0.5
        
        vbox:
            style "menu"
            spacing 2
            
            for caption, action, chosen in items:
                
                if action:  
                    
                    if " (disabled)" in caption:
                        $ caption = caption.replace(" (disabled)", "")
                        button:
                            action None
                            style "menu_choice_button"
                            
                            text caption style "menu_choice"
                    else:
                        button:
                            action action
                            style "menu_choice_button"

                            text caption style "menu_choice"
                    
                else:
                    text caption style "menu_caption"
Open your project's screens.rpy file and replace the part which starts with "screen choice" and ends right before "init -2 python" with the code above.

Then, when you want to show an unclickable option, just add " (disabled)" in its text like this:

Code: Select all

    menu:
        "Choice 1": # This is a normal choice
            # Stuff resulting from Choice 1
        "Choice 2 (disabled)": # This will be unclickable and appear as "Choice 2"
            pass # The contents of this block won't actually be used

Taddy
Newbie
Posts: 9
Joined: Sat Jul 27, 2019 7:34 am
Contact:

Re: Make options in menu unelectable/grayed out?

#5 Post by Taddy »

Hello guys.

I am sorry about the stupid question. Is this method is still work? Whatever I do, it doesn't work for me. I've tried many variations of this method, but the choice is still selecteble.
Maybe I make something wrong. Off course I can use

define config.menu_include_disabled = True

But I don't need it for all choises with variables.

I just change code in screen choice:

Code: Select all

screen choice:

    window:
        style "menu_window"
        xalign 0.5
        yalign 0.5

        vbox:
            style "menu"
            spacing 2

            for caption, action, chosen in items:

                if action:

                    if " (disabled)" in caption:
                        $ caption = caption.replace(" (disabled)", "")
                        button:
                            action None
                            style "menu_choice_button"

                            text caption style "menu_choice"
                    else:
                        button:
                            action action
                            style "menu_choice_button"

                            text caption style "menu_choice"

                else:
                    text caption style "menu_caption"
and add " (disabled)" in choises

Code: Select all

hm "It's evening, what would I do?"
    menu:
        "Watch TV - not available in the current version  (disabled)":
            pass
        "Go to bed early":
            hm "I'm so tired, I'd better go to bed."
            stop music fadeout 1.0
            scene i34 with dissolve
            pause
            return
 
But nothing heppen, choise still selecteble.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Make options in menu unelectable/grayed out?

#6 Post by Remix »

The current way of doing things is to use conditionals on the choices and set config.menu_include_disabled to True

Code: Select all

define config.menu_include_disabled = True

default allow_choice = False

label start:
    "It's evening, what would I do?"
    menu:
        "Watch TV - not available in the current version" if allow_choice:
            pass
        "Go to bed early":
            "I'm so tired, I'd better go to bed."
    return
 
Frameworks & Scriptlets:

Taddy
Newbie
Posts: 9
Joined: Sat Jul 27, 2019 7:34 am
Contact:

Re: Make options in menu unelectable/grayed out?

#7 Post by Taddy »

Remix wrote: Thu Mar 19, 2020 9:07 pm The current way of doing things is to use conditionals on the choices and set config.menu_include_disabled to True
Thanks to the66, I found the problem, why not work for me. I used his code.

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            $ disabled = i.kwargs.get("disabled", False)
            textbutton i.caption action i.action sensitive not disabled

menu:
    "Option 1":
        "bla"
    "Option 2" (disabled=True):
        "bla"

SavedByZero
Newbie
Posts: 12
Joined: Tue Jun 16, 2020 11:56 am
Contact:

Re: Make options in menu unelectable/grayed out?

#8 Post by SavedByZero »

Remix wrote: Thu Mar 19, 2020 9:07 pm The current way of doing things is to use conditionals on the choices and set config.menu_include_disabled to True

Code: Select all

define config.menu_include_disabled = True

default allow_choice = False

label start:
    "It's evening, what would I do?"
    menu:
        "Watch TV - not available in the current version" if allow_choice:
            pass
        "Go to bed early":
            "I'm so tired, I'd better go to bed."
    return
 
Can you please show an example of where and how to change the value of allow_choice for one option, then reset it for the others? I tried to do it after the first quote choice (where you currently have "if allow choice") but it's not working.

Also, how would we swap in a "disabled button" graphic for disabled choices?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], decocloud