2020-10-06 20:01:20 +00:00
|
|
|
|
2020-10-06 23:00:43 +00:00
|
|
|
class SWMenuDelegate : RazeMenuDelegate
|
2020-10-06 20:01:20 +00:00
|
|
|
{
|
|
|
|
override int DrawCaption(String title, Font fnt, int y, bool drawit)
|
|
|
|
{
|
2021-05-31 09:51:02 +00:00
|
|
|
let font = Raze.PickBigFont();
|
2020-10-06 20:01:20 +00:00
|
|
|
let texid = TexMan.CheckForTexture("MENUBAR");
|
|
|
|
let texsize = TexMan.GetScaledSize(texid);
|
|
|
|
let fonth = font.GetGlyphHeight("A");
|
2020-10-07 21:22:29 +00:00
|
|
|
let fontscale = 1.;
|
2020-10-06 20:01:20 +00:00
|
|
|
if (drawit)
|
|
|
|
{
|
|
|
|
int width = font.StringWidth(title) * fontscale;
|
2020-10-07 21:22:29 +00:00
|
|
|
double scalex = 1.;
|
2020-10-06 20:01:20 +00:00
|
|
|
if (texid.isValid())
|
|
|
|
{
|
2020-10-07 21:22:29 +00:00
|
|
|
if (texsize.X - 60 < width)
|
|
|
|
{
|
|
|
|
// First start squashing the font down to 0.7x the original width.
|
2020-10-13 20:53:27 +00:00
|
|
|
fontscale = (texsize.X - 66) / width;
|
2020-10-07 21:22:29 +00:00
|
|
|
if (fontscale < 0.7)
|
|
|
|
{
|
|
|
|
// If that is not enough, extend the box.
|
|
|
|
fontscale = 0.7;
|
|
|
|
width *= 0.7;
|
2020-10-13 20:53:27 +00:00
|
|
|
scalex = width / (texsize.X - 66);
|
2020-10-07 21:22:29 +00:00
|
|
|
}
|
|
|
|
else width *= fontscale;
|
|
|
|
}
|
|
|
|
screen.DrawTexture(texid, false, 160, 15, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffsetRel, true, DTA_ScaleX, scalex);
|
2020-10-06 20:01:20 +00:00
|
|
|
}
|
2020-10-07 21:22:29 +00:00
|
|
|
screen.DrawText(font, Font.CR_UNTRANSLATED, 160 - width / 2, 17 - fonth / 2, title, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_ScaleX, fontscale);
|
2020-10-06 20:01:20 +00:00
|
|
|
}
|
|
|
|
double fx, fy, fw, fh;
|
|
|
|
[fx, fy, fw, fh] = Screen.GetFullscreenRect(320, 200, FSMode_ScaleToFit43Top);
|
2021-02-02 22:49:04 +00:00
|
|
|
int h = texid.isValid() && texsize.Y < 40? texsize.Y : fonth;
|
2020-10-06 20:01:20 +00:00
|
|
|
return int((y+h) * fh / 200); // This must be the covered height of the header in true pixels.
|
|
|
|
}
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-10-07 21:22:29 +00:00
|
|
|
override bool DrawSelector(ListMenuDescriptor desc)
|
|
|
|
{
|
|
|
|
let item = desc.mItems[desc.mSelectedItem];
|
|
|
|
let x = item.GetX();
|
|
|
|
let y = item.GetY();
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-10-07 21:22:29 +00:00
|
|
|
|
|
|
|
let tex = TexMan.CheckForTexture("YINYANG");
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-10-07 21:22:29 +00:00
|
|
|
x -= TexMan.GetSize(tex) / 4 + 2;
|
|
|
|
y += 4;
|
|
|
|
|
|
|
|
Screen.DrawTexture(tex, true, x, y, DTA_FullscreenScale, FSMode_Fit320x200,
|
|
|
|
DTA_CenterOffset, true, DTA_Color, 0xfff0f0f0, DTA_ScaleX, 0.5, DTA_ScaleY, 0.5);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-26 09:58:40 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
class SWMainMenu : ListMenu
|
|
|
|
{
|
|
|
|
override void Drawer()
|
|
|
|
{
|
|
|
|
let p = StringTable.Localize("REQUIRED_CHARACTERS", false);
|
|
|
|
int newls = (p == "REQUIRED_CHARACTERS")? 17 : 21;
|
|
|
|
if (newls != mDesc.mLineSpacing) ChangeLineSpacing(newls);
|
|
|
|
super.Drawer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-07 21:22:29 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// logo
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
class ListMenuItemSWLogo : ListMenuItem
|
|
|
|
{
|
|
|
|
void Init(ListMenuDescriptor desc)
|
|
|
|
{
|
|
|
|
Super.Init(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
override void Draw(bool selected, ListMenuDescriptor desc)
|
|
|
|
{
|
|
|
|
screen.DrawTexture(TexMan.CheckForTexture("shadow_warrior"), false, 160, 15, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true, DTA_Color, 0xfff0f0f0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// text item
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
class ListMenuItemSWTextItem : 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;
|
|
|
|
}
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-11-08 09:12:12 +00:00
|
|
|
override bool Selectable()
|
|
|
|
{
|
|
|
|
return super.Selectable() && mFont == BigFont;
|
|
|
|
}
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-10-07 21:22:29 +00:00
|
|
|
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);
|
|
|
|
}
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-10-07 21:22:29 +00:00
|
|
|
override void Draw(bool selected, ListMenuDescriptor desc)
|
|
|
|
{
|
2021-05-31 09:51:02 +00:00
|
|
|
let gamefont = generic_ui ? NewSmallFont : mFont == SmallFont? Raze.PickSmallFont() : mFont == BigFont? Raze.PickBigFont() : mFont;
|
2021-05-29 09:47:05 +00:00
|
|
|
int cr = mColor != Font.CR_UNDEFINED? mColor : generic_ui? Font.CR_RED : Font.CR_UNTRANSLATED;
|
2020-11-08 09:12:12 +00:00
|
|
|
double scalex = generic_ui && mFont == SmallFont? 0.5 : 1.;
|
2020-10-07 21:22:29 +00:00
|
|
|
|
|
|
|
// The font here is very bulky and may cause problems with localized content. Account for that by squashing the text if needed.
|
|
|
|
int length = gamefont.StringWidth(mText);
|
|
|
|
if (mXpos + length > 320)
|
|
|
|
{
|
|
|
|
scalex = (315. - mXpos) / length;
|
|
|
|
}
|
|
|
|
|
2020-11-08 09:12:12 +00:00
|
|
|
Screen.DrawText(gamefont, cr, mXpos, mYpos, mText, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Color, !super.Selectable()? 0xff505050 : 0xffffffff, DTA_ScaleX, scalex);
|
2020-10-07 21:22:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|