[ZScript] ZForms 1.0

Post your example zscripts/ACS scripts/etc here.

[ZScript] ZForms 1.0

Postby Gutawer » Fri Nov 06, 2020 7:15 am

ZForms - An easy to use GUI library for ZScript by Gutawer and phantombeta

So honestly this is super way overdue but I'm finally getting around to releasing this after some recent changes reminding me that this exists.

ZForms is a project built out of the difficulty people have expressed with working with the bare-bones nature of the ZScript menu system. It allows easy creation of common UI elements such as buttons, labels, images and frames (which allow for nested menu design).

Version 1.0 Download
Code Repository (Unstable)

Usage of ZForms is pretty simple, in general. The repository has more specific instructions for use (in README.md) but the basic idea is that you use a Python "build script" to generate the code (this is necessary to avoid different projects from clashing with each other if they both use ZForms). Then you just inherit from a class and this gives you access to functions that can create and deal with rendering/handling input for standard UI elements so nothing needs to be done manually.

More detailed usage here (README.md)

Some examples (thanks entirely to phantombeta) are here
API documentation (also thanks to phantombeta) can be found here

Example images:

Se7evidas
Spoiler:

PDA Starter Kit
Spoiler:

Darkadia
Spoiler:


Credits:

Gutawer and phantombeta - Code and API design
Example images used - phantombeta and Nash
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: [ZScript] ZForms 1.0

Postby Nash » Fri Nov 06, 2020 8:14 am

ZForms is good. If you aren't using it to make UIs in your mods, you don't value your free time. :D
User avatar
Nash
AKA Nash Muhandes! Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Re: [ZScript] ZForms 1.0

Postby Jimmy » Fri Nov 06, 2020 8:32 am

Hell yeah!
User avatar
Jimmy
 
 
 
Joined: 10 Apr 2006
Discord: Jimmy#4100
Twitch ID: JimmySquared
Operating System: Windows 10/8.1/8/201x 64-bit

Re: [ZScript] ZForms 1.0

Postby Redneckerz » Fri Nov 06, 2020 1:15 pm

Incredible piece of work that brings yet another mod-friendly layer of versatility to the GZDoom family.
User avatar
Redneckerz
To it's ports i may have seen
Spotlight Team
 
Joined: 25 Nov 2019
Discord: Redneckerz#8399
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: Intel (Modern GZDoom)

Re: [ZScript] ZForms 1.0

Postby Major Cooke » Mon Aug 09, 2021 2:48 am

Out of curiosity, how is the ZFML branch coming along? Looks like you've made quite a lot of progress on many things recently, was curious if that will be continued?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: [ZScript] ZForms 1.0

Postby Gutawer » Mon Aug 09, 2021 5:02 am

Probably not directly. If/when I go back to a textual definition format I'll be rethinking the text design and probably base it on something easier to parse like XML. Reason being, most people won't actually be writing this directly - the main point of making a textual format in the first place is to have it be output from a menu generator so having the text format be easy to read has only caused me issues.

At any rate it's not a priority for me. I'd like to get the 2.0 functionality in and documented before even thinking about continuing that project.
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: [ZScript] ZForms 1.0

Postby Deon » Mon Dec 20, 2021 7:34 pm

Thank you for the amazing framework.

Please implement a quick fix that currently ruins attempts to use "$text" (language strings).

Code: Select allExpand view
   void setText(string text)
   {
      self.text = text;
      self.wrap = true;
      self.autoSize = true;
   }


can be improved into
Code: Select allExpand view
   void setText(string text)
   {
      text = Stringtable.Localize(text);
      self.text = text;
      self.wrap = true;
      self.autoSize = true;
   }


or if you want it to be optional (suggestion of 3saster)
Code: Select allExpand view
void setText(string text, bool localize=true) {
    self.text = localize ? stringtable.localize(text) : text;
   self.wrap = true;
   self.autoSize = true;
}


Without "text = Stringtable.Localize(text);" the text (in case it's a language $string) would get translated AFTER being stored as text, which would destroy linebreaks, wrapping etc.
This simple fix saved my mod :). I hope it's useful.
User avatar
Deon
 
Joined: 08 Oct 2020

Re: [ZScript] ZForms 1.0

Postby Gutawer » Tue Dec 21, 2021 4:38 am

This essentially isn't a bug. There's a couple good internal reasons why not localizing strings inside ZForms itself is a good idea (not least the fact that in ZForms 2.0 internal elements regularly call setText on other labels, which would potentially lead to recursive expansion). You should simply call StringTable.Localize from the outside.
Without "text = Stringtable.Localize(text);" the text (in case it's a language $string) would get translated AFTER being stored as text, which would destroy linebreaks, wrapping etc.

This is a bug for sure but this can't currently be fixed without a feature in GZDoom itself to optionally not localize strings in DrawText. I completely overlooked this and it completely fucks with text input boxes where strings must never be localized, so I guess I should either feature request this or add it myself.

EDIT: Side note - the lack of this GZDoom feature actually screws over its own text boxes. If you set a CVAR in the menu to something like $MUSIC_E1M1 then what you'll notice is that the $ never gets drawn, and when you press Enter and it removes the cursor character _ it'll visually display the text as e1m1 but actually sets it to $MUSIC_E1M1.
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: [ZScript] ZForms 1.0

Postby Deon » Tue Dec 21, 2021 7:34 am

I am a bit slow.
Can you explain why using this inside of SetText function for 1.0 could be a problem?
Code: Select allExpand view
self.text = localize ? stringtable.localize(text) : text;


I am asking because I've done it and it works perfectly, am I missing some possible issue?

I really appreciate the support and the tools, thank you for giving so much! :D
User avatar
Deon
 
Joined: 08 Oct 2020

Re: [ZScript] ZForms 1.0

Postby TheRailgunner » Mon Jan 10, 2022 10:29 am

So, I know this must sound like a stupid question, but...how do I actually USE any of this? From what I can tell, doing literally ANYTHING with this requires a working knowledge of ZScript - am I missing something, or does this require essentially learning a complete programming language to do something as simple as make an inventory screen?

I ask mainly because ZForms is described as "incredibly easy to use", but seems impenetrable to me (much like ZScript itself).
User avatar
TheRailgunner
Words go here.
 
Joined: 08 Jul 2013

Re: [ZScript] ZForms 1.0

Postby Caligari87 » Mon Jan 10, 2022 11:38 am

Yes, you need to know ZScript to use ZForms. It's advertised as "incredibly easy to use" in comparison to doing this stuff in ZScript manually (which is fairly complex even for experienced coders).

TBH I get the impression making an inventory screen has never been "simple" in (G)ZDoom anyway, even using older tech like ACS. This just makes it less painful in a ZScript context.

8-)
User avatar
Caligari87
User Accounts Assistant
 
Joined: 26 Feb 2004
Discord: Caligari87#3089
Github ID: caligari87

Re: [ZScript] ZForms 1.0

Postby Jarewill » Mon Jan 10, 2022 12:02 pm

Having made inventory menus in ZScript both manually and using ZForms, I can confirm that ZForms make it SO MUCH EASIER.

It still requires knowledge of ZScript to properly use though, but ZForms is well documented and has good examples.
Here's also a link to my project that has an inventory menu made in ZForms. I don't know if it will help, but it's always another example.
Jarewill
 
 
 
Joined: 21 Jul 2019


Return to Script Library

Who is online

Users browsing this forum: No registered users and 1 guest