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!)

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

Postby Graf Zahl » Fri Feb 17, 2017 12:45 pm

Nash wrote: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?


The main difference is how they work. The list menus are for widgets that have special design, like the main menu's patches and it allows positioning of each widget. Such a menu cannot scroll due to the explicit positioning

The option menus are pure text and the menu controls the entire layout. You only can use one font per menu and if the menu gets to large it automativally scrolls.

Obviously both need quite different widgets.
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 » Fri Feb 17, 2017 1:18 pm

Code: Select allExpand view
Class ListMenuScroller : ListMenu
{
   double sineWave;
   Array<Double> px;
   bool saved;
   
   override void Ticker()
   {   
      if (px.Size() <= 0)
         px.Reserve(mDesc.mItems.Size());
      
      sineWave = (sineWave + (360.0 / 35.0)) % 360.0;
      
      for(int i=0; i < mDesc.mItems.Size(); i++)
      {
         if (!saved)
         {
            px[i] = mDesc.mItems[i].GetX();
         }
         mDesc.mItems[i].SetX(px[i] + sin(sineWave) * 5);
      }
      saved = true;
      Super.Ticker();
   }
}


And here's a menu that shifts itself left and right with a sine wave. The only problem is, they're ints... so it looks jagged when slowing down or speeding up.

But the main point here is how to offset the ENTIRE menu.

Take note, there is no SetY, only OffsetPositionY.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

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

Postby Accensus » Sat Feb 18, 2017 8:55 am

Will ZMENUDEF allow for making proper weapon/upgrade/whatever buy menus, effectively replacing the ACS HudMessage hacks? If no, will we ever see a menu handling system that does this without hacks?
Accensus
 
Joined: 11 Feb 2016

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

Postby Graf Zahl » Sat Feb 18, 2017 9:12 am

The menu system is fully programmable, so it's up to you to implement what you need. A generic advice cannot be given, because each mod is different.
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 Accensus » Sat Feb 18, 2017 9:16 am

I see. Thanks for the quick reply, Graf. Definitely good to hear that I can now do a menu without having to cause a HudMessage mess. Gonna wait on the documentation before I start, though.
Accensus
 
Joined: 11 Feb 2016

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

Postby Accensus » Sat Feb 18, 2017 10:01 am

Another question. Can I check for an item's quantity in real-time while in the menu? For example, the menu shows I have 1000 gold and then I buy something for 300. Is it possible for the value to update to reflect the remaning 700 gold or will I have to reopen the menu?
Accensus
 
Joined: 11 Feb 2016

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

Postby Major Cooke » Sat Feb 18, 2017 10:02 am

Yes. See Nash's example a page or two back.

Unfortunately, documenting the menu system is going to be a lot harder than other ZScript things, mainly because of all the possibilities -- not to mention I'm still trying to get the hang of it.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: How To: ZSCRIPT MENUS?

Postby Accensus » Sat Feb 18, 2017 10:09 am

Take your time, Cooke. Thanks for pointing me to the DL. Will definitely take the example apart and learn how to do a proper menu. Big thanks go to you too, Graf, for making this possible.
Accensus
 
Joined: 11 Feb 2016

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

Postby Graf Zahl » Sat Feb 18, 2017 10:24 am

Major Cooke wrote:Yes. See Nash's example a page or two back.

Unfortunately, documenting the menu system is going to be a lot harder than other ZScript things, mainly because of all the possibilities -- not to mention I'm still trying to get the hang of it.



Careful. Once safeguards are in place this won't be directly doable anymore. The inventory change action needs to be routed through the network protocol and that part hasn't been done yet.
If game state gets altered directly from the menu it won't be recorded in demos or transmitted in multiplayer games.

Right now you are seriously at risk to create stuff that won't work in an official release. Right now I cannot say how this will work precisely so please don't ask.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: How To: ZSCRIPT MENUS?

Postby Major Cooke » Sat Feb 18, 2017 1:10 pm

Okay, that settles it. I'm not doing a damn drop of documentation until it's guaranteed that it's all said and done. Thank you for the warning.

I'll hold off with D4D's menu changes except for implementing static text that just displays credits vs cost using the same cvar system. I was relying on this method:

Code: Select allExpand view
NumberField "Cost", Cost_U1Pistol, 0, 500000000,    0.00000000000000000000000001
NumberField "Cash", D4DCash, -10, 500000000,       0.00000000000000000000000001


...with a stupidly high decimal count adjuster to prevent price changing (as it would take like a year of holding one key direction). I knew it wouldn't hold forever, but it was the only way to display cost and credit the player had. At least I can start there.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: How To: ZSCRIPT MENUS?

Postby Graf Zahl » Sat Feb 18, 2017 1:37 pm

You can change CVARs all you like. The problem is direct manipulation of game state.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: How To: ZSCRIPT MENUS?

Postby Major Cooke » Sat Feb 18, 2017 2:12 pm

Yeah. I was actually trying to prevent the numberfields from being adjustable with that huge decimal number, but that trick no longer appears to work.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: How To: ZSCRIPT MENUS?

Postby Graf Zahl » Sat Feb 18, 2017 3:57 pm

I think the easier way is to subclass them and kill the input that change the values there.
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 » Sat Feb 18, 2017 5:32 pm

Yeah, was thinking the same thing too but with fancier text.
Also, an idea just hit me about what you said earlier...
Graf Zahl wrote:Right now I cannot say how this will work precisely.


You could go a similar route as DIALOGUE, since that will basically require allowing checking of actors somehow. Unless that's not multiplayer friendly?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: How To: ZSCRIPT MENUS?

Postby Major Cooke » Sat Feb 18, 2017 10:48 pm

Is there any way to, when calling Menu.SetMenu, transfer all strings and/or graphics used in a previous menu for the sake of 'making them go out'? They would just be purely decorative such as fading between menus.
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 1 guest