[ZScript] Tips for menus

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
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)

[ZScript] Tips for menus

Post by m8f »





What does this do?
This thing displays randomly selected string from a hardcoded list in the main menu.
May come in handy if someone desires to add tips/notes/etc in their mod.

Features:
- compatibility between IWADs and mods
- automatic line breaking (text takes 3/4 of screen width max)
- code can be tuned so text is displayed in other menus
- CVar to toggle on/off (tp_show_notes)

I wonder if it's possible to bypass tt_MenuInjector hack. It's used to run ZScript code before the level is started.
Event handlers, even StaticEventHandler, are registered on level start.

How to use:
- change tp_ prefix to your own;
- include .zs file in your zscript lump;
- add Injector OptionMenu at the end of menudef;
- add a cvar to cvarinfo.

Download
Source code
Last edited by m8f on Wed Aug 10, 2022 9:52 am, edited 6 times in total.
User avatar
Beed28
Posts: 598
Joined: Sun Feb 24, 2013 4:07 pm
Location: United Kingdom

Re: [ZScript] Tips for menus

Post by Beed28 »

This sounds super neat! Is it okay if I use some of this in a mod of mine?
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)

Re: [ZScript] Tips for menus

Post by m8f »

Yes, of course you can. Make sure you change tp_ prefix to your own everywhere, so it won't conflict if someone loads two Tips systems.

I just added a check so if two Tips systems are loaded at the same, only the first is displaying. Please use code from tips-0.2.pk3.
SanyaWaffles
Posts: 810
Joined: Thu Apr 25, 2013 12:21 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11 for the Motorola Powerstack II
Graphics Processor: nVidia with Vulkan support
Location: The Corn Fields

Re: [ZScript] Tips for menus

Post by SanyaWaffles »

This is really neat... however I'm having trouble using it in my own project and I can't figure out why.

EDIT: It appears this doesn't work when included in an IPK3 for some reason.
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)

Re: [ZScript] Tips for menus

Post by m8f »

Is there an error or it just doesn't show the text?

Make sure you integrate all components:
- include .zs file in your zscript lump
- add Injector OptionMenu in menudef
- add a cvar to menudef

It also may not work if you have custom MainMenu. Does your setup have something special in this regard?
SanyaWaffles
Posts: 810
Joined: Thu Apr 25, 2013 12:21 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11 for the Motorola Powerstack II
Graphics Processor: nVidia with Vulkan support
Location: The Corn Fields

Re: [ZScript] Tips for menus

Post by SanyaWaffles »

Even though we solved it I wanna explain what was going on.

It wasn't showing the labels at all. I did edit it to look up text strings as opposed to hardcoded strings. That wasn't what was causing it.

From our discussion this morning/afternoon on Discord it seems it has to do with the order in which my MENUDEF was defined. I had to put it at the very end for it to take effect - after everything else had been stated.

Now it works with a few modifications to make it more appropriate for my project such as changing the font and color and adding a black background to the text to make it easier to read.

This is something I've been wanting for some time, but editing menus is a pain. Thanks for this!
User avatar
Sarah
Posts: 551
Joined: Wed Sep 06, 2006 12:36 pm
Preferred Pronouns: She/Her
Operating System Version (Optional): Debian 11 (bullseye), Windows 10
Location: Middle of Nowheresville Il.

Re: [ZScript] Tips for menus

Post by Sarah »

Spoiler:
Tooltips is no longer available on the ZDoom Forum. Thank you.
Last edited by Sarah on Thu Apr 27, 2023 6:13 pm, edited 4 times in total.
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)

Re: [ZScript] Tips for menus

Post by m8f »

I don't want in any way discourage anybody from tweaking Tips, but there is an issue with both Tips with Options and Tooltips. On some resolutions, Options Menu doesn't fit on a screen, and one need to scroll down to see the bottom of it. In this case, Tips are displayed only if the menu is scrolled to the bottom.

If one wants tooltips, I know two existing solutions:
1. Nash tooltips, included in Nash's Gore Mod
2. These tooltips.
User avatar
Sarah
Posts: 551
Joined: Wed Sep 06, 2006 12:36 pm
Preferred Pronouns: She/Her
Operating System Version (Optional): Debian 11 (bullseye), Windows 10
Location: Middle of Nowheresville Il.

Re: [ZScript] Tips for menus

Post by Sarah »

The problem isn't with the positioning code, it's doing the same thing Nash's Gore mod is, it's that Screen.GetWidth() and Screen.GetHeight() start acting weird on resolutions smaller than 640x400; they just return 640 and 400 respectively - checked this with a quick little console log and resolution jump rope.

I don't know why, and I currently don't have a solution other than saying keep your resolution at least 640x400 if you want to use any of these mods.
But I also recommend Nash's Option Menu implementation, it's very straightforward and honestly the superior system. So much so I'm rewriting my menus to follow the example.
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)

Re: [ZScript] Tips for menus

Post by m8f »

Wait, there is one more solution: Mouse hovering tooltip menu by Ivory Duke.
CaptainNurbles
Posts: 276
Joined: Sat Jan 27, 2018 9:12 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: The Deepest Reaches of Space

Re: [ZScript] Tips for menus

Post by CaptainNurbles »

So is there any way that this can be integrated into a mod in .PK3 format? As I understand it from reading other comments in this thread, it doesn't like to work in PK3s, but works fine if the mod is in .WAD format.
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)

Re: [ZScript] Tips for menus

Post by m8f »

Nope, this works fine in PK3. Make sure you:
Make sure you integrate all components:
- include .zs file in your zscript lump;
- add Injector OptionMenu at the end of menudef;
- add a cvar to cvarinfo.

If you have already tried, are there any issues?
CaptainNurbles
Posts: 276
Joined: Sat Jan 27, 2018 9:12 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: The Deepest Reaches of Space

Re: [ZScript] Tips for menus

Post by CaptainNurbles »

So the ZScript lump already does include the ZS file, and I have made sure that all of the tp_ prefixes to something else, and that this has been reflected in the ZScript lump.

With the menudef, is it just "Injector Optionmenu" like that at the end, nothing else to be done?

How would I go about adding the cvar to cvar info?

If it ain't clear yet, I don't actually know what I'm doing lol. I just know a bit about DECORATE, ACS and ZScript are totally out of my skillset.
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)

Re: [ZScript] Tips for menus

Post by m8f »

zscript lump - good. Don't forget to add ..._tips.zs file itself.
menudef - yes.
cvarinfo if you don't have cvarinfo lump in your mod, just copy one from the archive.

No problem - let me know if it still doesn't work.
CaptainNurbles
Posts: 276
Joined: Sat Jan 27, 2018 9:12 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: The Deepest Reaches of Space

Re: [ZScript] Tips for menus

Post by CaptainNurbles »

Yep, all's been done, still ain't appearing on the menu. Not quite sure why. All the files in the OG mod were copied over directly into my mod. The only differences is that I changed the tp_ prefix to sp_, and the menu messages were rewritten and expanded to show stuff relevant to my mod.

Return to “Script Library”