grayed out in-game menu

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
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

grayed out in-game menu

#1 Post by DaFool »

Hi,

I want to know whats the most efficient method to make a menu that contains the following buttons:

A B C D

Where sometimes, some buttons are not available for action. For example, D is a 'special move' but is not yet available because a variable has not been set.

This is not an action game by the way, it's instead a form of talk/see/do/explore variation (yes I will name A...D to some other names)

The options I have for implementing this are the following:

1.) Variations of the standard in-game menu... depending on the context, some choices just won't appear. CONS: I want to see future available choices grayed out but still displayed.

2.) a variation of monele's early MagBou 2 talk/see engine. CONS: I don't find the code intuitive at all. I prefer something which I can easily sketch into a State Machine diagram.

3.) A dynamic in-game overlay. I've managed to define multiple types of overlays depending on context, but I would like a set single layout with "empty slots" if you will. Should this be simple, set some part of the choice variables to False initially?

If the answer is somewhere found with a deeper search, I apologize in advance since I am rushing my game for completion before the Christmas break and am getting lazy in other aspects.

Much appreciated in advance.

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

Re: grayed out in-game menu

#2 Post by monele »

I would have gone with regular menus (using "if") if not for that grayed out requirement :/.
Thus, and strangely obvious, I'd go with my method XD...
In the Adventure engine, I use loops and other stuff that make it complicated, but if you strip it down the the displaying of buttons, I think it's pretty simple :

Code: Select all

ui.frame() # or any other container, styled if needed, to contain the buttons
ui.textbutton("Choice A", clicked=ui.jumps("somelabel"))
ui.textbutton("Choice B", clicked=ui.jumps("labelB"))
if someconditional:
    ui.textbutton("Choice C - Special Attack", clicked=ui.jumps("labelC"))
else:
    ui.textbutton("Choice C - Special Attack", clicked=None))
ui.interact()
This should display three buttons, the first two being always the same, while the third one is clickable only if "someconditional" is true.
And if you hate the if/else and would rather have a single line for that third button, it should be possible to replace "ui.jumps('labelC')" and "None" with a single ternary function that returns one or the other depending on a conditional. I can give details on this if needed.

Guest

Re: grayed out in-game menu

#3 Post by Guest »

Yes, in short, a button will be shown but not be active (and greyed out, but that's a style setting - style prefix "insensitive_") if the value given as the clickable is None.

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: grayed out in-game menu

#4 Post by DaFool »

I temporarily use multiple menu variations, but am coming back to this. A simple copy paste doesn't work, if I remember correctly.

What do I do to call the textbutton menu in-game? Append $ in front of every ui statement?

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

Re: grayed out in-game menu

#5 Post by monele »

Yes. Or put the whole thing in a "python" block.

HotLimit
Regular
Posts: 48
Joined: Thu Jun 18, 2009 4:04 pm
Contact:

Re: grayed out in-game menu

#6 Post by HotLimit »

I'm looking to do the same thing (have a menu with several options, with certain options un-clickable depending on different conditions), but do I have to create my own custom menu every time I want to do this?

I know how to hide certain options:

Code: Select all

menu:

    "Walk Away":
        ...

    "Go Crazy" if sanity == 0:
        ...
and change the text displayed in options:

Code: Select all

define sanity = "???"

menu:

    "Walk Away":
        ...

    "%(sanity)s":
        ...
But is there any way to display certain options but not allow people to click them? What I usually do is create a loop, but that requires extra code:

Code: Select all

label begin:

    e "Hey, how are you doing?"

    jump choice_one

label choice_one:

menu:

    "Good!":

        e "Oh, that's great!"

    "Not Great...":

        if happy > 0:

            jump choice_one

        elif:

            e "Oh, that's too bad..."

User avatar
Clayton Barnett
Regular
Posts: 80
Joined: Wed Sep 12, 2012 12:20 pm
Projects: OKaverse VNs
Organization: 3-AR Studios LLC
Location: Ohio
Contact:

Re: grayed out in-game menu

#7 Post by Clayton Barnett »

Apologies about resurrecting an old thread, but as my menu statement already has a conditional in it, I cannot quite wrap my head around what to do next. What I have now (that works fine) is this:

Code: Select all

menu:

     "Aoi" if aoipoints > 1:
          $ girl = "Aoi"
                 
     "Atti" if attipoints > 1:
          $ girl =  "Atti"
        
     "Rimu" if rimupoints > 1:
         $ girl = "Rimu"
        
     "Aris" if arispoints > 1:
          $ girl = "Aris"  
Now, if [name]points are not > 1, nothing is displayed.
I'd much rather have all four names displayed, but only those where the points condition be met as 'clickable.'

The point behind this is that I don't want someone unfamilar with this game (or VNs in general) to think that there are only 1-2 possible ends.
"Oh, I can't click on the 'Atti' button! I should replay this once I'm finished with Rimu's route."

Thanks again, and sorry about all the newbie-ness.

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: grayed out in-game menu

#8 Post by SundownKid »

You can try making it a screen instead. Make each menu choice a textbutton in a vbox, and substitute the action-less textbutton for the working one if the variable changes.

Code: Select all

screen girlselector:
   vbox xalign 0.5 yalign 0.5:
     if aoipoints > 1:
          textbutton "Aoi" action Jump("Aoi")
     else:
          textbutton "Aoi" action None
                 
et cetera.

Then use:

Code: Select all

call screen girlselector

User avatar
Clayton Barnett
Regular
Posts: 80
Joined: Wed Sep 12, 2012 12:20 pm
Projects: OKaverse VNs
Organization: 3-AR Studios LLC
Location: Ohio
Contact:

Re: grayed out in-game menu

#9 Post by Clayton Barnett »

Thank you for the suggestion... now please help an old man grasp his error. Based upon what you told me and what I want, I came up with this statement in init python:

Code: Select all

screen girlselector:
    vbox xalign 0.5 yalign 0.5:
        if aoipoints > 1:
            textbutton "Aoi" action girl = "Aoi"
        else:
            textbutton "Aoi" action None
From my 1st Grade grasp of Python, in the init python bloc, I don't use $ for variables. As in {$ girl = "Aoi"}. Nonetheless, this does not work.

Now, I could do what you wrote ("jump Aoi") but that would require me writing my Scene 19 FOUR times, one for each character (or calling it), but I cannot believe that RenPy is so unflexible based upon recent experience... so the problem must be me and my ignorance.

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: grayed out in-game menu

#10 Post by SundownKid »

What you should do is something like this:

Code: Select all

action[SetVariable(girl, "Aoi"), Jump("girls")]
So it sets the variable when you jump to that portion. I'm not sure about the quotes, but I think this way should work.

Levrex
Veteran
Posts: 280
Joined: Mon Jun 18, 2012 12:16 pm
Contact:

Re: grayed out in-game menu

#11 Post by Levrex »

SundownKid wrote:I'm not sure about the quotes, but I think this way should work.
"girl" should be quoted, and that's all.
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.

User avatar
Clayton Barnett
Regular
Posts: 80
Joined: Wed Sep 12, 2012 12:20 pm
Projects: OKaverse VNs
Organization: 3-AR Studios LLC
Location: Ohio
Contact:

Re: grayed out in-game menu

#12 Post by Clayton Barnett »

OK, works fine now (with one caveat). I've got

Code: Select all

screen girlselector:
    vbox xalign 0.5 yalign 0.5:
        if aoipoints > 1:
            textbutton "Aoi" action[SetVariable("girl", "Aoi"), Jump("scene18b")]
        else:                
            textbutton "Aoi" action None
        if arispoints > 1:
            textbutton "Aris" action[SetVariable("girl", "Aris"), Jump("scene18b")]
        else:
            textbutton "Aris" action None            
        if attipoints > 1:
            textbutton "Atti" action[SetVariable("girl", "Atti"), Jump("scene18b")]
        else:
            textbutton "Atti" action None            
        if rimupoints > 1:
            textbutton "Rimu" action[SetVariable("girl", "Rimu"), Jump("scene18b")]
        else:
            textbutton "Rimu" action None           
            textbutton "What am I thinking?" action Jump("scenebadend")
The 'jump' command is a bit kludgey, but it works.

My last nag is that while the five boxes are in the middle of the screen, they're all justified to some left margin, rather than truely centered. I'd thought that 'xalign 0.5 yalign 0.5' forced centering, but it seems not.

PS Sorry about being so thick. Woke up this AM with a 101F fever. Still need to get this done, though.

Levrex
Veteran
Posts: 280
Joined: Mon Jun 18, 2012 12:16 pm
Contact:

Re: grayed out in-game menu

#13 Post by Levrex »

Clayton Barnett wrote: My last nag is that while the five boxes are in the middle of the screen, they're all justified to some left margin, rather than truely centered. I'd thought that 'xalign 0.5 yalign 0.5' forced centering, but it seems not.
Yeah, that's true.
I suggest adding line that says

Code: Select all

xfill True
to your choice screen after

Code: Select all

    window:
        style "menu_window"
        xalign 0.5
        yalign 0.5
, or - if that does not work - changing the style of the said screen to something like mm_root or mm_imagemap (or copy the style and edit the new one, if you don't like the new look).
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.

Post Reply

Who is online

Users browsing this forum: Ocelot