Allow custom MessageBox menu selector

GZDoom used to have hardcoded MessageBox menu selector, 0x0d character
of console font, while the other menu is displayed is SmallFont.
It looked too ugly if SmallFont and ConFont heights are different,
and also there was no method of modifying the selector.

Now, the selector is 0x0d from SmallFont, if SmallFont contains this glyph
(its height is greater than zero), otherwise it falls back to previous
behavior (using ConFont as a source of this glyph).

To define custom MessageBox menu selector, just define 0x0d glyph for
SmallFont, and it will be displayed in the menu.

The gap between selector and menu options text is 3 pixels (as before), and
if you wish to enlarge this gap, just add some transparent columns at the
right side of 0x0d glyph.
This commit is contained in:
makise-homura 2022-12-28 04:06:44 +03:00 committed by Rachael Alexanderson
parent 6164d883c9
commit 357d846b7a
2 changed files with 4 additions and 4 deletions

View file

@ -78,7 +78,7 @@ class CustomMessageBoxMenuBase : Menu abstract
}
else
{
arrowFont = ConFont;
arrowFont = ((textFont && textFont.GetGlyphHeight(0xd) > 0) ? textFont : ConFont);
destWidth = CleanWidth;
destHeight = CleanHeight;
selector = "\xd";
@ -133,7 +133,7 @@ class CustomMessageBoxMenuBase : Menu abstract
if ((MenuTime() % 8) < 6)
{
screen.DrawText(arrowFont, OptionMenuSettings.mFontColorSelection,
(destWidth/2 - 11) + OptionXOffset(messageSelection), y + fontheight * messageSelection, selector, DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true);
(destWidth/2 - 3 - arrowFont.StringWidth(selector)) + OptionXOffset(messageSelection), y + fontheight * messageSelection, selector, DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true);
}
}
}

View file

@ -79,7 +79,7 @@ class MessageBoxMenu : Menu
}
else
{
arrowFont = ConFont;
arrowFont = ((textFont && textFont.GetGlyphHeight(0xd) > 0) ? textFont : ConFont);
destWidth = CleanWidth;
destHeight = CleanHeight;
selector = "\xd";
@ -134,7 +134,7 @@ class MessageBoxMenu : Menu
if ((MenuTime() % 8) < 6)
{
screen.DrawText(arrowFont, OptionMenuSettings.mFontColorSelection,
destWidth/2 - 11, y + fontheight * messageSelection, selector, DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true);
destWidth/2 - 3 - arrowFont.StringWidth(selector), y + fontheight * messageSelection, selector, DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true);
}
}
}