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!)
Locked
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: How To: ZSCRIPT MENUS?

Post by ZZYZX »

Child menu should take things from parent one on construction.
I remember you are supposed to have link to the parent...
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How To: ZSCRIPT MENUS?

Post by Major Cooke »

Piss waffles... precisely what I was hoping to avoid. Ah well.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: How To: ZSCRIPT MENUS?

Post by ZZYZX »

You are consistently trying to avoid the best ways to do things.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How To: ZSCRIPT MENUS?

Post by Major Cooke »

Not really. OnMenuCreated was made for 2.5, not 2.4. Init functions for items don't work like regular menu init.

Also not having to splatter copy/paste code everywhere is certainly much nicer...
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: How To: ZSCRIPT MENUS?

Post by ZZYZX »

If you can have that in base class for your submenus it's probably not copy+paste? idk. I haven't seen any menu code ever.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: How To: ZSCRIPT MENUS?

Post by Graf Zahl »

If you have to to weird stuff, create your own widget that does not rely on stock code to create the submenu. In that case you'd have full access to it and can transfer whatever you wish. If you need to transfer content you won't be able to do it without some special coding.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How To: ZSCRIPT MENUS?

Post by Major Cooke »

Graf Zahl wrote:If you have to to weird stuff, create your own widget that does not rely on stock code to create the submenu. In that case you'd have full access to it and can transfer whatever you wish. If you need to transfer content you won't be able to do it without some special coding.
I'm not even ready to tackle that yet. That'd take doing all the screen resizing and resolution calculations and... I'm only knee-deep in the menu code at the moment.

At first I thought OnMenuCreated was called internally, then I realized it was just a ZScript exclusive. So I got that taken care of and now it works.

Now the next big thing I have to do is figure out how to make nice tiers like this work in just one menu instead of three. Should be interesting:

Image
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: How To: ZSCRIPT MENUS?

Post by Ed the Bat »

ZScript menus are quite over my head, at this point. But the possibilities have me quite interested. I don't suppose it would be feasible to try to make a grid-like selection menu, perhaps for a player select?
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How To: ZSCRIPT MENUS?

Post by Major Cooke »

Yes, that is possible. And yes, ZScript menus are truly insane in terms of flexibility and making things work. Why you could even have it, say, prompt a password for a door if you want. Or use it as a journal for discovering different things. That is, when Graf changes Menu.SetMenu to clearscope. :mrgreen:
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: How To: ZSCRIPT MENUS?

Post by Ed the Bat »

I've wanted a player select menu like that for years. But I worry it will be a long time before I can understand it well enough to create that on my own.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How To: ZSCRIPT MENUS?

Post by Major Cooke »

This is where knowing some Java/C++ pays off. This whole concept was based around the UnrealScript idea, though Graf most likely will have taken many of his own liberties.

Anyway... The easiest method I can advise people is, either use VS2015 where all the .cpp files and text is easily searchable, or you can extract all the ZScript menu code from gzdoom.pk3. It's under zscript/menu. I do it with VS2015 since the search capability allows finding things really easily.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: How To: ZSCRIPT MENUS?

Post by ZZYZX »

Is there a way to require mouse for a specific menu?

edit: nevermind x2, my guessed way didn't do it.
Also, I'd like to not only require it, but also hide the default cursor to draw my own.

edit: nevermind x3, apparently I can use the InputEvent for when the mouse is off.
Ok, now, is there a way to DISABLE mouse for my menu so that I can always receive InputEvent instead of UiEvent?

Also how do I prevent closing the menu by escape? (I mean I already can spawn the same menu in OnDestroy, but that'd be a dirty hack and I'm looking for a valid way, and also one that wouldn't crash my executable...)
I want a main menu that opens automatically on startup (can do that already I think) and can't be closed (???)

Oh, alsoalsoalso can we get a GenericMenu in MENUDEF? Right now I need to inherit ListMenu or OptionMenu even if I intend replacing 100% of the functionality from scratch and it's not a menu at all.

My current implementation of a god mode menu looks like this: http://www.mediafire.com/file/8qo5iejb3 ... m3Menu.pk3
I'm thinking of implementing a windowing system in ZScript that has everything disconnected from specific rendering/input backends and in theory can do things like rendering via DrawPowerup and receiving input via event handlers, as well as rendering via menus and receiving input via menus. And of course have it's state disconnected from menus so the menu can be killed as many times as you want, the state will stay.
It should also work with either InputEvent or UiEvent for mouse... because apparently in menus anything can happen.
Wrappers rule :rock:
(also, HOERS-related)
Last edited by ZZYZX on Thu Mar 23, 2017 6:37 pm, edited 1 time in total.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How To: ZSCRIPT MENUS?

Post by Major Cooke »

Yet another exploit that needs shooting apparently. And yes, HOERS related. :P
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: How To: ZSCRIPT MENUS?

Post by ZZYZX »

Hey that's not an exploit — that's legit usage of ZScript features that exist at the moment, with no unwanted side effects (well except that you can't start a game, but that's temporary).
If Graf allowed RenderOverlay, it'd be an overlay on a TITLEMAP, with MainMenu calling Destroy on Init if not in GS_LEVEL. But as there are no overlays...

Besides, Doom 3 menu should not close by escape, unless it's in the game. But I didn't implement that part yet — in fact nothing is implemented at all for now :)
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: How To: ZSCRIPT MENUS?

Post by Nash »

Alt + F4 and "delete WAD to Recycle Bin" always works unconditionally, so this fearmongering of unclosable menus is just exaggeration. ZZYZX already gave realistic use cases.

I can make a WAD even more annoying that calls new(someThinker) in a never-ending while() loop...
Locked

Return to “Scripting”