raze/wadsrc/static/zscript/games/blood/ui/menu.zs

54 lines
1.8 KiB
Text
Raw Normal View History

2020-10-05 19:47:53 +00:00
//-------------------------------------------------------------------------------------------
//
// Caption drawer
//
//-------------------------------------------------------------------------------------------
2020-10-05 19:47:53 +00:00
class MenuCustomizerBlood : MenuCustomize
{
override int DrawCaption(String title, Font fnt, int y, bool drawit)
{
let font = generic_ui? NewConsoleFont : BigFont; // this ignores the passed font intentionally.
let texid = TexMan.CheckForTexture("MENUBAR");
2020-10-05 19:47:53 +00:00
let texsize = TexMan.GetScaledSize(texid);
2020-10-05 22:34:35 +00:00
let fonth = font.GetGlyphHeight("A");
2020-10-05 19:47:53 +00:00
if (drawit)
{
int width = font.StringWidth(title);
if (texid.isValid())
{
double scalex = 1.; // Expand the box if the text is longer
2020-10-05 22:34:35 +00:00
if (texsize.X - 10 < width) scalex = width / (texsize.X - 10);
2020-10-05 19:47:53 +00:00
screen.DrawTexture(texid, false, 160, 20, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffsetRel, true, DTA_ScaleX, scalex);
}
2020-10-05 22:34:35 +00:00
screen.DrawText(font, Font.CR_UNDEFINED, 160 - width / 2, 20 - fonth / 2, title, DTA_FullscreenScale, FSMode_Fit320x200Top);
2020-10-05 19:47:53 +00:00
}
2020-10-05 22:34:35 +00:00
double fx, fy, fw, fh;
[fx, fy, fw, fh] = Screen.GetFullscreenRect(320, 200, FSMode_ScaleToFit43Top);
2020-10-05 19:47:53 +00:00
int h = texid.isValid()? texsize.Y : fonth;
2020-10-05 22:34:35 +00:00
return int((y+h) * fh / 200); // This must be the covered height of the header in true pixels.
2020-10-05 19:47:53 +00:00
}
override bool DrawSelector(ListMenuDescriptor desc)
{
return true; // do not draw any selector.
}
2020-10-05 19:47:53 +00:00
}
//-------------------------------------------------------------------------------------------
//
// The dripping blood - partially native.
//
//-------------------------------------------------------------------------------------------
class ListMenuItemBloodDripDrawer : ListMenuItem
{
void Init(ListMenuDescriptor desc)
{
Super.Init(0, 0);
}
native override void Draw(bool selected, ListMenuDescriptor desc);
}