The code currently only displays as an adv style menu. I created this code with two ideas in mind: one was seeing people ask how to have a menu with grayed out options instead of hidden, the other to have more a little bit more control over the menu without straying too far from the default choice screen. Download both files attached and you can copy them into a new project and launch it. It displays like the default menu. The second menu in the attached example script shows how an option can be grayed out.
Here is how to define a menu using my code and then I will show you the rough Ren'Py equivalent:
Code: Select all
$ choose = Menu("First Menu")
$ choose.option("1", "lbl")
$ choose.option("2", "lbl2")
$ choose.option("3", "lbl3", "a==5")
$ choose.display()
Before I dissect my code, let me give you the Ren'Py equivalent:
Code: Select all
menu:
"First Menu"
"1":
jump lbl
"2":
jump lbl2
"3" if a == 5:
jump lbl3
In the first line of my code, I use the variable 'choose'. You can name your variable whatever you want. In this example, the menu's prompt text is "First Menu" with no speaker. You can create the menu without prompt text by declaring it like this:
And you can also declare it with a character so that it will be displayed with the name of the character. Example:
Code: Select all
$ choose = Menu("Pick an Option!", e)
In that example, e is the character Eileen and the prompt will be spoken by her. Calling choose.option adds options to the menu and will be displayed in the order they are added. When you call the function, you will always call it with the text to display on the button and the label it will jump to both as strings. It can also be called like the third option in the example:
Code: Select all
$ choose.option("3", "lbl3", "a==5")
The optional third argument "a==5" is a string that is evaluated to check whether or not it should display the button as grayed out. You can use any conditional statement as a string for that argument for whatever purposes you need. The line choose.display() is self-explanatory as all it does is display the menu. The screen code in menuclass.rpy is only a template and based directly off of the default choice menu. You can alter the screen language of screen display in menuclass.rpy to suit your purposes just like you can the screen choice in the screens.rpy file. When it comes time to show another menu, you can re-use the variable 'choose' if you have no other purpose for it. You can also declare a new menu with a different variable name if you have a purpose for doing so.
There are drawbacks to using this code as it forces you to have a label to jump to for every option which isn't always necessary in the default Ren'Py menu syntax. It can also unnecessarily complicate things if you don't have a specific purpose for using this code. I figure that a few people might like it because of its ability to handle grayed out options. It's also worth noting that you can use this code and still use regular Ren'Py menus.
EDIT: Updated rpy files to include the addition of storing tooltip information as well as a default way of displaying it. Check
this post for a different method that relies on default menu syntax and works with ADV and NVL mode.