How To: ZSCRIPT MENUS?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Major Cooke
Posts: 8193
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

How To: ZSCRIPT MENUS?

Post by Major Cooke »

So now that we have shiny new menu options to play with, where do we start?

How will MenuDef interpret 'keywords' for this? I.e. if we have "MyListMenu" which doesn't exactly replace ListMenu, would we use that for MenuDef?
Last edited by Major Cooke on Sat Feb 18, 2017 10:05 am, edited 2 times in total.
User avatar
Nash
 
 
Posts: 17454
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: How to do things with the new menu functions?

Post by Nash »

Graf, can you please provide some barebones basic examples... with no example to follow, no obvious entry points, this feature will go to waste because no one is going to use them...
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: How to do things with the new menu functions?

Post by Accensus »

Give him some time, guys. He just fixed half a page of issues. Patience is what gets things done around here, especially since he's a one-man-army for the most part.
User avatar
Major Cooke
Posts: 8193
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How to do things with the new menu functions?

Post by Major Cooke »

Meh fuck it, I might as well try screwing with it and seeing if I can invent a simple slide-me-over-while-highlighted example...
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: How to do things with the new menu functions?

Post by Accensus »

Don't forget to post results. We're still lacking documentation on the new GetUDMF*** ZScript feature Nash posted about. We're also lacking documentation on how the A_CustomRailgun fire delay works. We need more documentation, guys. I'd happily add it if I knew how the fuck it worked.
User avatar
Major Cooke
Posts: 8193
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How to do things with the new menu functions?

Post by Major Cooke »

Lud wrote:Don't forget to post results. We're still lacking documentation on the new GetUDMF*** ZScript feature Nash posted about. We're also lacking documentation on how the A_CustomRailgun fire delay works. We need more documentation, guys. I'd happily add it if I knew how the fuck it worked.
Now you know how I feel.

It hurts.
User avatar
Xaser
 
 
Posts: 10773
Joined: Sun Jul 20, 2003 12:15 pm

Re: How to do things with the new menu functions?

Post by Xaser »

Lud wrote:We're still lacking documentation on the new GetUDMF*** ZScript feature Nash posted about.
"Still lacking."

The feature was added literally less than a day ago. Jesus H. Roosevelt Christ.

While I can understand the frustration in the OP (though from the linked issue, it looks like that was a bug that's since been fixed), the level of impatience on display here is simply cartoonish. Keep in mind that the new menu features have been completed on a bleeding-edge development branch. Docs aren't going to instantaneously materialize, especially when the person in question is a developer who's still actively developing.

[TBH we need a PSA for this in general; we need to get off the devbuilds-are-releases mindset.]
User avatar
Major Cooke
Posts: 8193
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How to do things with the new menu functions?

Post by Major Cooke »

Xaser wrote:[TBH we need a PSA for this in general; we need to get off the devbuilds-are-releases mindset.]
There already is. Of course I'm bearing this in mind. The problem is, this thing is so vast, when people start asking on how to use it, there will either be documentation immediately or not at all.
User avatar
Xaser
 
 
Posts: 10773
Joined: Sun Jul 20, 2003 12:15 pm

Re: How to do things with the new menu functions?

Post by Xaser »

Major Cooke wrote:The problem is, this thing is so vast, when people start asking on how to use it, there will either be documentation immediately or not at all.
ZScript itself is evidence against this notion. Remember back when nobody knew how to use that, and we were able to figure it out over time? Literally the exact same thing is happening here.

The part I don't understand is this crazy air of desperation that clouds the thread, like if we don't get tips on how to use the new menus NOW, then the entire system will collapse. I really don't understand where this fear is coming from, especially considering we went through the same process with ZScript as a whole and it seems to be working out. Are we afraid Graf is going to vanish or nefariously withhold info*, leaving us modders in the dust for all eternity? Give it some time for things to settle and we'll have this whole thing sorted out.


[*Well, if we keep acting like frightened children, then he may not want to respond, so consider that perhaps. :P ]
User avatar
Major Cooke
Posts: 8193
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How to do things with the new menu functions?

Post by Major Cooke »

Okay, the OP was made thinking that the breakage was on purpose, since D4D's upgrade menu is set up on the thin sticks of keyconf and crappy aliases. I admit that had me scared. That's why I had just a tiny bit of rush and need for knowing some basics to start out with.

Changed it.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49130
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: How to do things with the new menu functions?

Post by Graf Zahl »

Granted, the menu system is a bit different, but in the end it's rather simple, I based it all on two concepts already in use by MENUDEF:

1. Every menu can be linked to a class, you can see that best in the load and save menus. They are defined as ListMenus but they only do that to gain the basic menu functionality you need anyway, the only thing of the list menu they actually use is the caption. Once you have set a new menu class and linked it you are free to go to do what you want, The code may still be C++ but it should show you which functions to override to implement a menu that'S completely independent of the widget system.

2. For adding new widgets you have to follow a simple naming convention (ListMenuItemXYZ or OptionMenuItemXYZ) and then can use it in MENUDEF as a new type 'XYZ params' where the params are directly deduced from the class's Init function's prototype, including optional values. Just have a look at the existing types and look how they get accessed.
User avatar
Major Cooke
Posts: 8193
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How to do things with the new menu functions?

Post by Major Cooke »

Graf, how is Font.FindFontColor supposed to work?
Because this doesn't work:

TEXTCOLO

Code: Select all

Yellow
{
	#272727  #515151    0  64
	#784918  #F3A718   65 207
	#F3A82A  #FCD043  208 256
Console:
	#000000  #7F7F00    0 127
	#FFFF00  #FFFFFF  128 256
Flat:
	#EEEE33
}
MENUDEF

Code: Select all

OptionMenu "OptionsMenu"
{
	Title "$OPTMNU_TITLE"
	SubMenuColor "$OPTMNU_CONTROLS",			"CustomizeControls"
	SubMenuColor "$OPTMNU_MOUSE",			"MouseOptions"
	SubMenuColor "$OPTMNU_JOYSTICK",			"JoystickOptions"
	StaticText " "
	SubMenuColor "$OPTMNU_PLAYER",			"PlayerMenu"
	SubMenuColor "$OPTMNU_GAMEPLAY",			"GameplayOptions"
	SubMenuColor "$OPTMNU_COMPATIBILITY",	"CompatibilityOptions"
	SubMenuColor "$OPTMNU_AUTOMAP",			"AutomapOptions"
	SubMenuColor "$OPTMNU_HUD",				"HUDOptions"
	SubMenuColor "$OPTMNU_MISCELLANEOUS",	"MiscOptions"
	SubMenuColor "$OPTMNU_NETWORK",			"NetworkOptions"
	SubMenuColor "$OPTMNU_SOUND",			"SoundOptions"
	SubMenuColor "$OPTMNU_DISPLAY",			"VideoOptions"
	SubMenuColor "$OPTMNU_VIDEO",			"VideoModeMenu"
	StaticText " "
	SafeCommand "$OPTMNU_DEFAULTS",	"reset2defaults"
	SafeCommand	"$OPTMNU_RESETTOSAVED",	"reset2saved"
	Command "$OPTMNU_CONSOLE",			"menuconsole"
}
ZScript

Code: Select all

Class OptionMenuItemSubMenuColor : OptionMenuItemSubMenu
{
    bool isSelected;
    
    Color selColor;
    
    OptionMenuItemSubmenuColor Init(String label, Name command, int param = 0)
    {
        Super.init(label, command);
        mParam = param;
        return self;
    }
    
    override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
    {
        isSelected = selected;
        int t = Font.FindFontColor("Yellow"); //<---------------------------------------------------------------------------------------------------------------------
        drawLabel(indent, y, selected ? t : OptionMenuSettings.mFontColorMore);
        return indent;
    }
}
It just returns untranslated instead of turning yellow.
User avatar
Kinsie
Posts: 7402
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33

Re: How to do things with the new menu functions?

Post by Kinsie »

Major Cooke wrote:The problem is, this thing is so vast, when people start asking on how to use it, there will either be documentation immediately or not at all.
How times change.
User avatar
Player701
 
 
Posts: 1651
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

Re: How to do things with the new menu functions?

Post by Player701 »

Considering that the question I asked in the ZScript discussion thread has probably been overlooked, and also since this looks like a good place to ask such questions, I will repeat it here:
Player701 wrote:Last time I checked - was long ago, maybe things have changed since then? - MENUDEF could only be used to replace the existing menu setup, not to extend it. Therefore, it was impossible to play with two mods which defined their own menus and wanted them to be accessible from the main menu - one of them would always override the other. Has it indeed changed or is ZScript going to make it possible at last?

(edit) If you don't understand what I mean, compare to how UT2004 handles mutator options. Each mutator can get its own menu section on the mutator configuration tab, or even a separate openable window, complete with any GUI elements the developer would like to have. I was hoping ZDoom would eventually get a kind of a "Mod Menu" extendable via a ZScript API, which would allow a mod to add its subsection(s) there for easy configuration. What's important here is that different subsections wouldn't conflict with each other if there was more than one mod active.
Sorry if this has been answered somewhere already, but I couldn't find any information on this particular aspect of the menu system. I apologize for reposting, just thought it'd help my question to not get lost in the endless stream of messages which is exactly how I would describe the main ZScript thread in its current state. :oops:
User avatar
Nash
 
 
Posts: 17454
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: How to do things with the new menu functions?

Post by Nash »

Why is this MENUDEF crashing the game on startup? This used to work before I pull in the new scripted menus.

EDIT: The "JoystickOptions" block at line 247 is causing the crash. I can remove this block no problem; but I may not the only person who - due to lack of documentation or proper consultation - may have just pasted the entire contents of ZDoom's MENUDEF into their own mod, and then only made cosmetic changes here and there.

Player701's concern about true modularity in the menu system may be worth discussing. I'm sure modders just resorted to pasting the entire contents of the stock MENUDEF because it isn't as modular as, say, DECORATE (not additive).
You do not have the required permissions to view the files attached to this post.

Return to “Scripting”