[ZScript] ZForms 1.0

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

[ZScript] ZForms 1.0

Post by Gutawer »

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
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: [ZScript] ZForms 1.0

Post by Nash »

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
Jimmy
 
 
Posts: 4725
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him

Re: [ZScript] ZForms 1.0

Post by Jimmy »

Hell yeah!
User avatar
Redneckerz
Spotlight Team
Posts: 1090
Joined: Mon Nov 25, 2019 8:54 am
Graphics Processor: Intel (Modern GZDoom)

Re: [ZScript] ZForms 1.0

Post by Redneckerz »

Incredible piece of work that brings yet another mod-friendly layer of versatility to the GZDoom family.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: [ZScript] ZForms 1.0

Post by Major Cooke »

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
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: [ZScript] ZForms 1.0

Post by Gutawer »

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
Deon
Posts: 233
Joined: Thu Oct 08, 2020 10:44 am

Re: [ZScript] ZForms 1.0

Post by Deon »

Thank you for the amazing framework.

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

Code: Select all

	void setText(string text)
	{
		self.text = text;
		self.wrap = true;
		self.autoSize = true;
	}
can be improved into

Code: Select all

	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 all

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
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: [ZScript] ZForms 1.0

Post by Gutawer »

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
Deon
Posts: 233
Joined: Thu Oct 08, 2020 10:44 am

Re: [ZScript] ZForms 1.0

Post by Deon »

I am a bit slow.
Can you explain why using this inside of SetText function for 1.0 could be a problem?

Code: Select all

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
TheRailgunner
Posts: 1556
Joined: Mon Jul 08, 2013 10:08 pm

Re: [ZScript] ZForms 1.0

Post by TheRailgunner »

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
Caligari87
Admin
Posts: 6191
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him

Re: [ZScript] ZForms 1.0

Post by Caligari87 »

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-)
Jarewill
 
 
Posts: 1821
Joined: Sun Jul 21, 2019 8:54 am

Re: [ZScript] ZForms 1.0

Post by Jarewill »

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.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: [ZScript] ZForms 1.0

Post by ramon.dexter »

Hi, the latest gzdoom 4.10.0 returns an error in frame.zsc, line 32, return type mismatch.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: [ZScript] ZForms 1.0

Post by Major Cooke »

I'm unable to check at the moment but if this is because of dynamic array return type changes with the functions, I'm actually reporting this as a bug since it breaks mods.
User avatar
Xeotroid
Posts: 443
Joined: Sat Jun 23, 2012 7:44 am
Graphics Processor: nVidia with Vulkan support
Location: Czech Rep.

Re: [ZScript] ZForms 1.0

Post by Xeotroid »

Use the version of ZForms found in the repository, that one works fine on both stable and dev builds of GZDoom.

(edited for clarity)

Return to “Script Library”