Page 1 of 1

[ZScript] Tips for menus

PostPosted: Sun Dec 01, 2019 10:12 am
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.

If you are going to use this script, make sure to change tp_ prefix to your own.

Download: https://www.mediafire.com/file/oaj2ajy7 ... 2.pk3/file

Re: [ZScript] Tips for menus

PostPosted: Sun Dec 01, 2019 3:03 pm
by Beed28
This sounds super neat! Is it okay if I use some of this in a mod of mine?

Re: [ZScript] Tips for menus

PostPosted: Sun Dec 01, 2019 9:38 pm
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.

Re: [ZScript] Tips for menus

PostPosted: Mon Dec 02, 2019 3:45 am
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.

Re: [ZScript] Tips for menus

PostPosted: Mon Dec 02, 2019 4:21 am
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?

Re: [ZScript] Tips for menus

PostPosted: Mon Dec 02, 2019 6:48 pm
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!

Re: [ZScript] Tips for menus

PostPosted: Sun Apr 26, 2020 6:34 pm
by Nero
Hi, sorry to bump this, I want to just post links to Tips with Options and Tooltips. These are modifications I made to m8f's original code.

Tips with Options
Tips with Options
Works exactly the same as the original, just adds in Option Menus.
Open up the Options Menu for a demonstration.

Tooltips
This is in response to this thread, where I was trying to create tooltips for highlighted menu options. A few tweaks to the code later and I had exactly that. This file is a demonstration, also on the Options Menu.

Tips with Options and Tooltips should work fine together, so long as they don't attempt to place text on the same menu, then they'll just overwrite each other.
Also, Option menus are restricted to just one menu. This works fine for me because I need it for just one menu, but a rethink needs had for more menus or better text flexibility.

Tooltips 0.2
Added a list index to the constructor of the Menu Note. This should be used to load string lists on a case by case basis, where each number corresponds to a particular menu. So multiple menus are now supported, not elegantly, but supported. Download link has been updated to version 0.2.

Tooltips 0.3
Tooltips has become its own mod that now has its own thread. This is the last update to this post so that I stop hijacking this thread.
Tooltips 0.3

Old Version:
Tooltips 0.1
Tooltips 0.2

Do as you will with these files, they're mostly m8f's work so I consider it m8f's code and m8f's call. Enjoy! Also let me know if you have any issues downloading either file - I probably borked the share settings for Google Drive.

Re: [ZScript] Tips for menus

PostPosted: Mon Apr 27, 2020 8:56 am
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.

Re: [ZScript] Tips for menus

PostPosted: Mon Apr 27, 2020 8:06 pm
by Nero
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.

Re: [ZScript] Tips for menus

PostPosted: Mon Apr 27, 2020 9:39 pm
by m8f
Wait, there is one more solution: Mouse hovering tooltip menu by Ivory Duke.