Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Moderator:GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
2 posts
• Page 1 of 1
Sarah
Posts: 551
Joined: Wed Sep 06, 2006 12:36 pm
Preferred Pronouns: She/Her
Operating System Version (Optional): Debian 11 (bullseye), Windows 10
So I modified m8f's Tips for Menus mod to work with Option Menus. Currently it works exactly the same, it picks from a random string and prints it at the bottom right of the screen when the menu is opened.
What I'd like it to do is show a different string depending on what option in the parent menu is highlighted. Is there a way to get an index number of the currently highlighted option, or something along those lines?
class PA_OptionMenuNote : OptionMenuItem
{
const MARGIN = 10;
/// Must contain at least 1 string.
private ui Array<String> _strings;
private ui uint _iString;
PA_OptionMenuNote init()
{
add("Toggling the Auto Pitch control will enable the camera\nto automatically look where the player looks.");
Super.Init("PA Camera Tips:", "none");
return self;
}
override bool, string GetString(int i)
{
return true, "OptionMenuNote";
}
override void OnMenuCreated()
{
_iString = random(0, _strings.size() - 1);
}
// Had to switch to Draw instead of Drawer
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
{
if (!pavar_show_notes)
return Super.Draw(desc, y, indent, selected);
int width = (Screen.GetWidth() / CleanXFac_1) * 3 / 4;
let lines = NewSmallFont.BreakLines(_strings[_iString], width);
int nLines = lines.Count();
double height = NewSmallFont.GetHeight();
double y = Screen.GetHeight() - MARGIN - height * nLines * CleanYFac_1;
for (int i = 0; i < nLines; ++i)
{
double x = Screen.GetWidth() - MARGIN - lines.StringWidth(i) * CleanXFac_1;
Screen.DrawText( NewSmallFont, Font.CR_WHITE, x, y, lines.StringAt(i), DTA_CleanNoMove_1, true);
y += height * CleanYFac_1;
}
return Super.Draw(desc, y, indent, selected);
}
private ui void add(String s)
{
_strings.push(s);
}
}
class OptionMenuItemPA_MenuInjector : OptionMenuItem
{
void Init()
{
injectNote("PAOptions");
}
void injectNote(String menuName)
{
let descriptor = OptionMenuDescriptor(OptionMenuDescriptor.GetDescriptor(menuName));
if (descriptor)
{
bool hasString;
string whatString;
[hasString, whatString] = descriptor.mItems[descriptor.mItems.size() - 1].GetString(0);
if (hasString && whatString == "OptionMenuNote")
return;
else
descriptor.mItems.Push(new("PA_OptionMenuNote").init());
}
else
Console.Printf("MENU TIPS - PA MENU TIP FAILURE TO FIND DESCRIPTOR -");
}
}
Lastly @m8f, I will clean up the current ZScript and incorporate it back into your mod and send it to you if you want - might be able to set up some other options too - let me know what you want me to do.
Update
Very much solved. Thank you AFADoomer for the quick response, that was exactly what I needed.
Also I'd like to make the fruits of my labor available. They, yes they for they are two, come in two flavors, Tips with Options, and Tooltips. What's the difference? Tips with Options is m8f's Tips for Menus mod with the addition of a class for Option Menus. Works exactly the same as m8f's original code, for a demo just open up the Options Menu.
Tooltips is what I was trying to accomplish here. I want text to appear in the lower right hand corner of the screen with information on the current thing I have selected in a menu. Tooltips is about 95% m8f's code, 1% mine, and 4% further head trauma as I banged my head on the keyboard getting it to work. So it's my gift to m8f and the community and you can find more info about both of these mods to the mod over at the mod thread, which I will be making a post at shortly to give info and links.
Please let me know if you have any problems downloading the files from my Google Drive - I probably borked the share settings.
Last edited by Sarah on Mon Apr 27, 2020 12:02 am, edited 2 times in total.