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.

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

Postby Nash » Thu Feb 16, 2017 8:33 am

@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
Nash
Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

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

Postby Graf Zahl » Thu Feb 16, 2017 11:35 am

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Major Cooke » Thu Feb 16, 2017 11:38 am

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
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

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

Postby Graf Zahl » Thu Feb 16, 2017 12:07 pm

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Major Cooke » Thu Feb 16, 2017 1:02 pm

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
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

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

Postby Graf Zahl » Thu Feb 16, 2017 1:16 pm

What did you do?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Major Cooke » Thu Feb 16, 2017 1:22 pm

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
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

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

Postby Major Cooke » Thu Feb 16, 2017 1:44 pm

What's this third parameter supposed to do for submenu? It takes an int but I'm not seeing what for...
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

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

Postby Graf Zahl » Thu Feb 16, 2017 2:27 pm

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Major Cooke » Thu Feb 16, 2017 5:46 pm

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
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

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

Postby Nash » Thu Feb 16, 2017 9:13 pm

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
Nash
Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

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

Postby Major Cooke » Fri Feb 17, 2017 9:06 am

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

Code: Select allExpand view
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
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

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

Postby Nash » Fri Feb 17, 2017 10:21 am

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
Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

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

Postby Nash » Fri Feb 17, 2017 10:59 am

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
Nash
Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

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

Postby Major Cooke » Fri Feb 17, 2017 11:51 am

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.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests