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
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

@Graf Zahl:

Is this a bug or "you're doing it wrong"? Calling Super.Drawer() on my custom OptionMenu class just produces blank menus. If I remove the Super.Drawer call, I don't get blank menus.

EDIT: Attachment removed, see this post for an updated and functional example
Last edited by Nash on Thu Feb 16, 2017 9:14 pm, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

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

Post by Graf Zahl »

Nash wrote: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.
That seems to be a common problem with modders which ultimately will kill the engine because nothing can get refactored again.
User avatar
Major Cooke
Posts: 8175
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 »

Kinsie wrote:How times change.
I'm still working on updating documentation but with college back in full swing, things have slowed down.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

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

Post by Graf Zahl »

Nash wrote:@Graf Zahl:

Is this a bug or "you're doing it wrong"? Calling Super.Drawer() on my custom OptionMenu class just produces blank menus. If I remove the Super.Drawer call, I don't get blank menus.

The menu is blank. What do you expect?
User avatar
Major Cooke
Posts: 8175
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, why is Selectable for things like submenus backwards? I.e. if selectable returns true, it cannot be selected.

Shouldn't that be renamed to NotSelectable, or have the logic be reversed?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

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

Post by Graf Zahl »

What did you do?
User avatar
Major Cooke
Posts: 8175
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 »

Turns out I was only looking at the very base version instead, didn't notice the version where it does mGrayCheck. Nevermind.
User avatar
Major Cooke
Posts: 8175
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 »

What's this third parameter supposed to do for submenu? It takes an int but I'm not seeing what for...
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

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

Post by Graf Zahl »

It's a parameter that gets passed to the Init function of the submenu (e.g. to notify the skill menu of the chosen episode.)
User avatar
Major Cooke
Posts: 8175
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. Is there a way to effectively replace all of one type of menu, say... OptionMenu without needing to go through, copy/paste GZDoom's menudef into our own and mass replace them?
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

Here's an example CustomMenu. What I did:

- Every OptionMenu's header is changed to SmallFont, via way of DefaultOptionMenu (every OptionMenu is affected without me having to copy/paste a lot of stuff in MENUDEF)
- Controls changed to use SmallFont instead of ConFont

Shows the basics of doing stuff.

NOTE: Specifying a Class inside DefaultOptionMenu and DefaultListMenu only will work after this commit ... if you try my example WAD and you don't see SmallFont being used as the title header in every Option menu, just wait for a newer devbuild to come out

EDIT: Even BETTAR example here! -> viewtopic.php?p=978168#p978168
Last edited by Nash on Fri Feb 17, 2017 10:59 am, edited 1 time in total.
User avatar
Major Cooke
Posts: 8175
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 »

I figured out how to get the player. It was actually not very difficult.

Code: Select all

Actor plr;
bool printOnce;
override void Ticker()
{
	Super.Ticker();
	if (!printOnce)
	{
		if (playeringame[consoleplayer])
			plr = players[consoleplayer].mo;
		
			
		if (plr)		plr.A_LogInt(1);
		else			console.Printf("Ruh roh!");
			
		printOnce = true;
	}
}
If I'm right about this, I might be able to replace the alias keyconf hackery used to prop up D4D's purchase menu after all. :D
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

Graf - what are the key differences between ListMenu and OptionMenu and more importantly, which should I pick for a particular situation, if I want to make a completely new menu?

You can put widgets and functionality in both, and you can also draw images and text on both... for example, the player menu is one complicated ListMenu with all kinds of stuff in it, but nothing's stopping from making the player menu an OptionMenu if one wanted to. So I'm not really understanding why are there 2 distinct kinds of menus...
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

An even more updated menu example!!!!!!!

I added a completely fresh and custom menu, an imaginary "Items Menu".

In this demo, I show you how to create a pretty cool widget that is unselectable, prints the player's current health and bullets, and show you how to hook it all up so that your players can call this menu in-game.

This will be the basis for your custom shop system, inventory screen or player stats screen... anything you can think of!

Thanks to MajorCooke for confirming that you can retrieve player data in the menu!

EDIT: File deleted. It does not work anymore in the latest revisions as some underlying systems have changed. See Major Cooke's new example instead: viewtopic.php?p=982760#p982760
Last edited by Nash on Wed Mar 08, 2017 8:32 pm, edited 1 time in total.
User avatar
Major Cooke
Posts: 8175
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 »

No problem. ;)

Note to self: Do not attempt to inherit from ListMenuItemTextItem or ListMenuItemPatchItem. It's impossible to get a working Init function going and, without its definition, will fail to initialize at all. Instead, inherit from ListMenuItemSelectable and use the aforementioned classes innards.
Locked

Return to “Scripting”