How To: ZSCRIPT MENUS?
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!)
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!)
-
- Posts: 8196
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: How To: ZSCRIPT MENUS?
No worries.
That's just it though. Prevention from important things being overridden I suppose. That part I don't know fully.
That's just it though. Prevention from important things being overridden I suppose. That part I don't know fully.
-
- Posts: 1337
- Joined: Tue Jul 15, 2003 4:18 pm
Re: How To: ZSCRIPT MENUS?
I edited after you posted... Maybe Graf can weigh in, then? I may do a feature request...
-
- Posts: 8196
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: How To: ZSCRIPT MENUS?
No point. Graf will probably close it because either he cannot, or will not. For example, a will-not is the player menu: he kept all those functions internal to prevent abuse. A cannot: like the color picker menu, if it has a class, are just too complex so you cannot replace those either because it'll fuck things up. Your better off just replacing it on your own side and tell players "DONT use the internal menu!".
-
-
- Posts: 17465
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: How To: ZSCRIPT MENUS?
I have had to specifically request which class of menus to be overridable inside MenuDef in the past (for example, the generic MessageBox was hardcoded until I requested it and it got approved)... so I think the best bet is, if you want a particular class to be moddable, you'll have to request it.AFADoomer wrote:Ah.
Damnit, you're right. Sorry.
So what is the difference between me adding a new Class there and replacing the old class for PlayerMenu with a class that inherits from PlayerMenu? Besides "the engine won't let you"? Shouldn't the inherited class have all of the same underlying code as the parent class? Is this actually something that should not be done, or a holdover from the old system where everything was in compiled code?
-
- Posts: 1337
- Joined: Tue Jul 15, 2003 4:18 pm
Re: How To: ZSCRIPT MENUS?
Yeah, this was all good. I was mis-reading and mis-remembering code.
-
- Lead GZDoom+Raze Developer
- Posts: 49183
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: How To: ZSCRIPT MENUS?
Please do. I do not feel like reading trough 2 pages of discussion to get to the bottom of it.AFADoomer wrote:I edited after you posted... Maybe Graf can weigh in, then? I may do a feature request...
-
-
- Posts: 17465
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: How To: ZSCRIPT MENUS?
Can someone explain to me menu descriptors like I'm a 5 year old?
Despite being able to work with menus and produce somewhat usable widgets, I can't honestly say I truly understand the descriptor concept.
Despite being able to work with menus and produce somewhat usable widgets, I can't honestly say I truly understand the descriptor concept.
-
- Posts: 219
- Joined: Wed Jan 08, 2014 8:40 am
- Graphics Processor: nVidia with Vulkan support
- Location: Germany
Re: How To: ZSCRIPT MENUS?
Hey, I need some help.
I want to alter the look of a menu, but only a certain entry (or value).
From what I understand, the common way that menu items are drawn is like this:
Textures
Texts
So, the whole menu uses the DTA_Clean tag. I simply want to change this tag to the DTA_320x200 tag, so that all menus use it. Is this easily possible, and if yes, how?
I want to alter the look of a menu, but only a certain entry (or value).
From what I understand, the common way that menu items are drawn is like this:
Textures
Code: Select all
screen.DrawTexture (mTexture, true, x, mYpos, DTA_Clean, true);
Code: Select all
screen.DrawText(mFont, mColor, x, mYpos, text, DTA_Clean, true);
-
-
- Posts: 17465
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: How To: ZSCRIPT MENUS?
No, there's no easy way to do it. You'll have to rewrite almost every menu just to change its drawing API to suit your needs. Or copy/paste all of the stock menus. And run the risk of having outdated menu code if there are engine menu fixes upstream.
-
- Posts: 219
- Joined: Wed Jan 08, 2014 8:40 am
- Graphics Processor: nVidia with Vulkan support
- Location: Germany
Re: How To: ZSCRIPT MENUS?
Hmm ... tried that, failed miserably . Jk, but it kinda seems complicated for such a simple change...
Another question about the menus though: Where are the names for the menu items stored?
e.g. MENUDEF entry:
In this case the OptionsMenu will be visually shown ingame as "Set it up!". Is that string accessible via a menu class in ZScript so I can use it? And if so, how?
Another question about the menus though: Where are the names for the menu items stored?
e.g. MENUDEF entry:
Code: Select all
TextItem "Set it up!","o", "OptionsMenu"
-
- Posts: 1337
- Joined: Tue Jul 15, 2003 4:18 pm
Re: How To: ZSCRIPT MENUS?
Each menu item is referenced in the menu descriptor's mItems array. You have to access the correct entry of that array, cast the item as the right type of control (ListMenuItemTextItem), and retrieve the mText value.
So something like this running in your list menu class's Init code should print the list menu text item values to the console every time the menu is opened:
If you want to select a specific item, you can experiment with the GetItem function - GetItem('OptionsMenu') should return the list item you use in your example (See the player menu for an example of this in action).
@Nash -
Essentially, the menu descriptors are used to store specific information used by the overall menu - selector graphic and offsets, base drawing position, etc. Most importantly, it includes an array of all of the menu items that are part of the menu, as defined in either MENUDEF or internally generated code. So, this is how the engine keeps track of what items are supposed to be on a particular menu, and the particulars of how that menu is drawn.
So something like this running in your list menu class's Init code should print the list menu text item values to the console every time the menu is opened:
Code: Select all
for (int i = 0; i < mDesc.mItems.Size(); i++)
{
if (mDesc.mItems[i] is "ListMenuItemTextItem")
{
console.printf("%s", ListMenuItemTextItem(mDesc.mItems[i]).mText);
}
}
@Nash -
I will try... Apologies if this is either too basic or not enough.Nash wrote:Can someone explain to me menu descriptors like I'm a 5 year old?
Despite being able to work with menus and produce somewhat usable widgets, I can't honestly say I truly understand the descriptor concept.
Essentially, the menu descriptors are used to store specific information used by the overall menu - selector graphic and offsets, base drawing position, etc. Most importantly, it includes an array of all of the menu items that are part of the menu, as defined in either MENUDEF or internally generated code. So, this is how the engine keeps track of what items are supposed to be on a particular menu, and the particulars of how that menu is drawn.
-
- Posts: 219
- Joined: Wed Jan 08, 2014 8:40 am
- Graphics Processor: nVidia with Vulkan support
- Location: Germany
Re: How To: ZSCRIPT MENUS?
Thanks, this is the information I neededAFADoomer wrote:Each menu item is referenced in the menu descriptor's mItems array. You have to access the correct entry of that array, cast the item as the right type of control (ListMenuItemTextItem), and retrieve the mText value.
So something like this running in your list menu class's Init code should print the list menu text item values to the console every time the menu is opened:If you want to select a specific item, you can experiment with the GetItem function - GetItem('OptionsMenu') should return the list item you use in your example (See the player menu for an example of this in action).Code: Select all
for (int i = 0; i < mDesc.mItems.Size(); i++) { if (mDesc.mItems[i] is "ListMenuItemTextItem") { console.printf("%s", ListMenuItemTextItem(mDesc.mItems[i]).mText); } }
-
- Posts: 551
- Joined: Wed Sep 06, 2006 12:36 pm
- Preferred Pronouns: She/Her
- Operating System Version (Optional): Debian 11 (bullseye), Windows 10
- Location: Middle of Nowheresville Il.
Re: How To: ZSCRIPT MENUS?
Spoiler: Original PostUpdate - Solved. I assumed this was going to require ZScript but a quick look at the MENUDEF documentation on the wiki showed that my needs are simpler. Z-Windows now has it's own options menu within Options!
-
- Posts: 19
- Joined: Thu Aug 10, 2017 8:09 pm
Re: How To: ZSCRIPT MENUS?
Hello, can anybody explain how to make scroll bars and possible convert int to string?
-
- Posts: 317
- Joined: Mon Jul 16, 2012 2:02 am
Re: How To: ZSCRIPT MENUS?
Do I understand it right you can use this outside of main menu enhancements? Like to do "Do you really want to buy <item> for <price>?" during gameplay. If yes, how?