Page 9 of 10

Re: How To: ZSCRIPT MENUS?

Posted: Sun May 28, 2017 3:17 pm
by Major Cooke
No worries.

That's just it though. Prevention from important things being overridden I suppose. That part I don't know fully.

Re: How To: ZSCRIPT MENUS?

Posted: Sun May 28, 2017 3:18 pm
by AFADoomer
I edited after you posted... Maybe Graf can weigh in, then? I may do a feature request...

Re: How To: ZSCRIPT MENUS?

Posted: Sun May 28, 2017 3:20 pm
by Major Cooke
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!".

Re: How To: ZSCRIPT MENUS?

Posted: Sun May 28, 2017 11:21 pm
by Nash
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?
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.

Re: How To: ZSCRIPT MENUS?

Posted: Mon May 29, 2017 9:28 am
by AFADoomer
Yeah, this was all good. I was mis-reading and mis-remembering code.

Re: How To: ZSCRIPT MENUS?

Posted: Wed May 31, 2017 4:18 am
by Graf Zahl
AFADoomer wrote:I edited after you posted... Maybe Graf can weigh in, then? I may do a feature request...
Please do. I do not feel like reading trough 2 pages of discussion to get to the bottom of it.

Re: How To: ZSCRIPT MENUS?

Posted: Tue Jun 13, 2017 7:01 pm
by Nash
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.

Re: How To: ZSCRIPT MENUS?

Posted: Thu Jun 15, 2017 11:30 am
by XxMiltenXx
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

Code: Select all

screen.DrawTexture (mTexture, true, x, mYpos, DTA_Clean, true);
Texts

Code: Select all

screen.DrawText(mFont, mColor, x, mYpos, text, DTA_Clean, true);
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?

Re: How To: ZSCRIPT MENUS?

Posted: Thu Jun 15, 2017 2:18 pm
by Nash
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.

Re: How To: ZSCRIPT MENUS?

Posted: Thu Jun 15, 2017 3:36 pm
by XxMiltenXx
Hmm ... tried that, failed miserably :D. 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:

Code: Select all

	TextItem "Set it up!","o", "OptionsMenu"
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?

Re: How To: ZSCRIPT MENUS?

Posted: Thu Jun 15, 2017 4:46 pm
by AFADoomer
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:

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);
			}
		}
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 -
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.
I will try... Apologies if this is either too basic or not enough.

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.

Re: How To: ZSCRIPT MENUS?

Posted: Thu Jun 15, 2017 5:27 pm
by XxMiltenXx
AFADoomer 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:

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);
			}
		}
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).
Thanks, this is the information I needed :)

Re: How To: ZSCRIPT MENUS?

Posted: Mon Sep 04, 2017 5:31 pm
by Sarah
Spoiler: Original Post
Update - 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!

Re: How To: ZSCRIPT MENUS?

Posted: Thu Sep 07, 2017 6:53 am
by GiveOneMoreChance
Hello, can anybody explain how to make scroll bars and possible convert int to string?

Re: How To: ZSCRIPT MENUS?

Posted: Thu Sep 07, 2017 10:59 pm
by ZzZombo
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?