[ZScript] Tips for menus

Post your example zscripts/ACS scripts/etc here.

[ZScript] Tips for menus

Postby m8f » Sun Dec 01, 2019 10:12 am





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
Last edited by m8f on Sun Dec 01, 2019 10:09 pm, edited 3 times in total.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff

Re: [ZScript] Tips for menus

Postby Beed28 » Sun Dec 01, 2019 3:03 pm

This sounds super neat! Is it okay if I use some of this in a mod of mine?
User avatar
Beed28
Making entire worlds bounce up and down.
 
Joined: 24 Feb 2013
Location: United Kingdom

Re: [ZScript] Tips for menus

Postby m8f » Sun Dec 01, 2019 9:38 pm

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.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff

Re: [ZScript] Tips for menus

Postby SanyaWaffles » Mon Dec 02, 2019 3:45 am

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
SanyaWaffles
Navy Did Nothing Wrong
 
Joined: 25 Apr 2013
Location: Eastern Ohio
Discord: SanyaWaffles#5095
Twitch ID: sanyawaffles
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] Tips for menus

Postby m8f » Mon Dec 02, 2019 4:21 am

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?
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff

Re: [ZScript] Tips for menus

Postby SanyaWaffles » Mon Dec 02, 2019 6:48 pm

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
SanyaWaffles
Navy Did Nothing Wrong
 
Joined: 25 Apr 2013
Location: Eastern Ohio
Discord: SanyaWaffles#5095
Twitch ID: sanyawaffles
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] Tips for menus

Postby Nero » Sun Apr 26, 2020 6:34 pm

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.
Last edited by Nero on Wed May 06, 2020 6:40 pm, edited 3 times in total.
User avatar
Nero
Royal Boredom....Why can't I do this in Windows?
 
Joined: 06 Sep 2006
Location: Middle of Nowheresville Il.

Re: [ZScript] Tips for menus

Postby m8f » Mon Apr 27, 2020 8:56 am

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
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff

Re: [ZScript] Tips for menus

Postby Nero » Mon Apr 27, 2020 8:06 pm

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
Nero
Royal Boredom....Why can't I do this in Windows?
 
Joined: 06 Sep 2006
Location: Middle of Nowheresville Il.

Re: [ZScript] Tips for menus

Postby m8f » Mon Apr 27, 2020 9:39 pm

Wait, there is one more solution: Mouse hovering tooltip menu by Ivory Duke.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff


Return to Script Library

Who is online

Users browsing this forum: No registered users and 0 guests