2020-10-06 20:35:25 +00:00
|
|
|
|
2020-10-06 23:00:43 +00:00
|
|
|
class ExhumedMenuDelegate : RazeMenuDelegate
|
2020-10-06 20:35:25 +00:00
|
|
|
{
|
2020-10-07 22:21:07 +00:00
|
|
|
double zoomsize; // this is the only persistent place where it can be conveniently stored.
|
|
|
|
|
2020-10-06 20:35:25 +00:00
|
|
|
override int DrawCaption(String title, Font fnt, int y, bool drawit)
|
|
|
|
{
|
|
|
|
let font = generic_ui? NewConsoleFont : BigFont; // this ignores the passed font intentionally.
|
2020-10-07 22:21:07 +00:00
|
|
|
let cr = generic_ui ? Font.CR_FIRE : Font.CR_UNTRANSLATED; // this ignores the passed font intentionally.
|
2020-10-06 20:35:25 +00:00
|
|
|
let texid = TexMan.CheckForTexture("MENUBLANK");
|
|
|
|
let texsize = TexMan.GetScaledSize(texid);
|
|
|
|
let fonth = font.GetGlyphHeight("A");
|
|
|
|
if (drawit)
|
|
|
|
{
|
|
|
|
int width = font.StringWidth(title);
|
|
|
|
if (texid.isValid())
|
|
|
|
{
|
|
|
|
double scalex = 1.; // Expand the box if the text is longer
|
|
|
|
if (texsize.X - 18 < width) scalex = width / (texsize.X - 18);
|
|
|
|
screen.DrawTexture(texid, false, 160, 20, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffset, true, DTA_ScaleX, scalex);
|
|
|
|
}
|
2020-10-07 22:21:07 +00:00
|
|
|
screen.DrawText(font, cr, 160 - width / 2, 20 - fonth / 2, title, DTA_FullscreenScale, FSMode_Fit320x200Top);
|
2020-10-06 20:35:25 +00:00
|
|
|
}
|
|
|
|
double fx, fy, fw, fh;
|
|
|
|
[fx, fy, fw, fh] = Screen.GetFullscreenRect(320, 200, FSMode_ScaleToFit43Top);
|
|
|
|
int h = texid.isValid()? texsize.Y : fonth;
|
|
|
|
return int((y+h) * fh / 200); // This must be the covered height of the header in true pixels.
|
|
|
|
}
|
2020-10-07 22:50:23 +00:00
|
|
|
|
|
|
|
override bool DrawSelector(ListMenuDescriptor desc)
|
|
|
|
{
|
|
|
|
double y = desc.mItems[desc.mSelectedItem].GetY();
|
|
|
|
let tex = TexMan.CheckForTexture("MENUCURSORTILE");
|
|
|
|
screen.DrawTexture(tex, false, 37, y - 12, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TopLeft, true);
|
|
|
|
screen.DrawTexture(tex, false, 232, y - 12, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TopLeft, true, DTA_FlipX, true);
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-06 20:35:25 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 22:21:07 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class ListMenuItemExhumedPlasma : ListMenuItem
|
|
|
|
{
|
|
|
|
void Init(ListMenuDescriptor desc)
|
|
|
|
{
|
|
|
|
Super.Init(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
native override void Draw(bool selected, ListMenuDescriptor desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
class ListMenuItemExhumedLogo : ListMenuItem
|
|
|
|
{
|
|
|
|
void Init(ListMenuDescriptor desc)
|
|
|
|
{
|
|
|
|
Super.Init(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
native override void Draw(bool selected, ListMenuDescriptor desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Menu related game interface functions
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class ListMenuItemExhumedTextItem : ListMenuItemTextItem
|
|
|
|
{
|
|
|
|
void Init(ListMenuDescriptor desc, String text, String hotkey, Name child, int param = 0)
|
|
|
|
{
|
|
|
|
Super.Init(desc, text, hotkey, child, param);
|
|
|
|
if (child == 'none') mEnabled = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitDirect(double x, double y, int height, String hotkey, String text, Font font, int color, int color2, Name child, int param = 0)
|
|
|
|
{
|
|
|
|
Super.InitDirect(x, y, height, hotkey, text, font, color, color2, child, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
override void Draw(bool selected, ListMenuDescriptor desc)
|
|
|
|
{
|
|
|
|
let font = generic_ui ? NewConsoleFont : BigFont; // this ignores the passed font intentionally.
|
|
|
|
let cr = generic_ui ? Font.CR_FIRE : Font.CR_UNTRANSLATED; // this ignores the passed font intentionally.
|
|
|
|
let tex = TexMan.CheckForTexture("MENUBLANK");
|
|
|
|
let texsize = TexMan.GetScaledSize(tex);
|
|
|
|
let fonth = font.GetGlyphHeight("A");
|
|
|
|
int width = font.StringWidth(mText);
|
2020-10-07 22:50:23 +00:00
|
|
|
let delegate = ExhumedMenuDelegate(menuDelegate);
|
|
|
|
let zoom = delegate ? delegate.zoomsize : 1.;
|
|
|
|
|
2020-10-07 22:21:07 +00:00
|
|
|
|
|
|
|
let v = TexMan.GetScaledSize(tex);
|
|
|
|
double y = mYpos + v.y / 2;
|
|
|
|
|
|
|
|
int shade;
|
2021-04-23 08:07:02 +00:00
|
|
|
if (selected) shade = Raze.CalcSinTableValue(MSTime() * 16 * 120 / 1000) >> 9;
|
2020-10-07 22:21:07 +00:00
|
|
|
else if (Selectable()) shade = 0;
|
|
|
|
else shade = 25;
|
2021-04-23 08:07:02 +00:00
|
|
|
let color = Raze.shadeToLight(shade);
|
2020-10-07 22:21:07 +00:00
|
|
|
|
|
|
|
double scalex = 1.; // Squash the text if it is too wide. Due to design limitations we cannot expand the box here. :(
|
2020-10-07 22:50:23 +00:00
|
|
|
if (texsize.X - 18 < width)
|
2020-10-07 22:21:07 +00:00
|
|
|
{
|
2020-10-07 22:50:23 +00:00
|
|
|
scalex = (texsize.X - 18) / width;
|
|
|
|
width = (texsize.X - 18);
|
2020-10-07 22:21:07 +00:00
|
|
|
}
|
2020-10-07 22:50:23 +00:00
|
|
|
|
|
|
|
screen.DrawTexture(tex, false, 160, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffset, true, DTA_ScaleX, scalex, DTA_Color, color, DTA_ScaleX, zoom, DTA_ScaleY, zoom);
|
|
|
|
screen.DrawText(font, cr, 160 - zoom * width / 2, y - zoom * fonth / 2, mText, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Color, color, DTA_ScaleX, zoom * scalex, DTA_ScaleY, zoom);
|
2020-10-07 22:21:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class ExhumedMainMenu : ListMenu
|
|
|
|
{
|
|
|
|
override void Ticker()
|
|
|
|
{
|
|
|
|
Super.Ticker();
|
|
|
|
let delegate = ExhumedMenuDelegate(menuDelegate);
|
|
|
|
if (!delegate) return;
|
2020-10-07 22:50:23 +00:00
|
|
|
// handle the menu zoom-in. The zoom is stored in the delegate so that it can be accessed by code which does not receive a reference to the menu.
|
2020-10-07 22:21:07 +00:00
|
|
|
if (delegate.zoomsize < 1.)
|
|
|
|
{
|
|
|
|
delegate.zoomsize += 0.0625;
|
|
|
|
if (delegate.zoomsize >= 1.)
|
|
|
|
delegate.zoomsize = 1.;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|