How To: ZSCRIPT MENUS?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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: ZSCRIPT MENUS?

Postby Major Cooke » Sun May 28, 2017 4:17 pm

No worries.

That's just it though. Prevention from important things being overridden I suppose. That part I don't know fully.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: How To: ZSCRIPT MENUS?

Postby AFADoomer » Sun May 28, 2017 4:18 pm

I edited after you posted... Maybe Graf can weigh in, then? I may do a feature request...
User avatar
AFADoomer
 
Joined: 15 Jul 2003

Re: How To: ZSCRIPT MENUS?

Postby Major Cooke » Sun May 28, 2017 4:20 pm

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!".
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: How To: ZSCRIPT MENUS?

Postby Nash » Mon May 29, 2017 12:21 am

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.
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: How To: ZSCRIPT MENUS?

Postby AFADoomer » Mon May 29, 2017 10:28 am

Yeah, this was all good. I was mis-reading and mis-remembering code.
User avatar
AFADoomer
 
Joined: 15 Jul 2003

Re: How To: ZSCRIPT MENUS?

Postby Graf Zahl » Wed May 31, 2017 5:18 am

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

Re: How To: ZSCRIPT MENUS?

Postby Nash » Tue Jun 13, 2017 8:01 pm

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.
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: How To: ZSCRIPT MENUS?

Postby XxMiltenXx » Thu Jun 15, 2017 12:30 pm

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 allExpand view
screen.DrawTexture (mTexture, true, x, mYpos, DTA_Clean, true);

Texts
Code: Select allExpand view
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?
XxMiltenXx
 
Joined: 08 Jan 2014

Re: How To: ZSCRIPT MENUS?

Postby Nash » Thu Jun 15, 2017 3:18 pm

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.
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: How To: ZSCRIPT MENUS?

Postby XxMiltenXx » Thu Jun 15, 2017 4:36 pm

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 allExpand view
   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?
XxMiltenXx
 
Joined: 08 Jan 2014

Re: How To: ZSCRIPT MENUS?

Postby AFADoomer » Thu Jun 15, 2017 5:46 pm

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 allExpand view
      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.
User avatar
AFADoomer
 
Joined: 15 Jul 2003

Re: How To: ZSCRIPT MENUS?

Postby XxMiltenXx » Thu Jun 15, 2017 6:27 pm

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 allExpand view
      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 :)
XxMiltenXx
 
Joined: 08 Jan 2014

Re: How To: ZSCRIPT MENUS?

Postby Nero » Mon Sep 04, 2017 6:31 pm

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!
User avatar
Nero
Royal Boredom....Why can't I do this in Windows?
 
Joined: 06 Sep 2006
Location: Middle of Nowheresville Il.

Re: How To: ZSCRIPT MENUS?

Postby GiveOneMoreChance » Thu Sep 07, 2017 7:53 am

Hello, can anybody explain how to make scroll bars and possible convert int to string?
GiveOneMoreChance
 
Joined: 10 Aug 2017

Re: How To: ZSCRIPT MENUS?

Postby ZzZombo » Thu Sep 07, 2017 11:59 pm

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?
ZzZombo
 
Joined: 16 Jul 2012

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest