- menu code update.

This commit is contained in:
Christoph Oelckers 2020-10-05 18:39:16 +02:00
parent 53980787b6
commit be55e26689
4 changed files with 48 additions and 64 deletions

View File

@ -369,6 +369,7 @@ struct CVar native
native void SetString(String s);
native int GetRealType();
native int ResetToDefault();
native int GetGlyphHeight(String charcode);
}
struct GIFont version("2.4")

View File

@ -191,9 +191,25 @@ class ListMenu : Menu
{
int sel = -1;
// convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture
x = ((x - (screen.GetWidth() / 2)) / CleanXfac) + 160;
y = ((y - (screen.GetHeight() / 2)) / CleanYfac) + 100;
int w = mDesc.DisplayWidth();
double sx, sy;
if (w == ListMenuDescriptor.CleanScale)
{
// convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture
x = ((x - (screen.GetWidth() / 2)) / CleanXfac) + 160;
y = ((y - (screen.GetHeight() / 2)) / CleanYfac) + 100;
}
else
{
// for fullscreen scale, transform coordinates so that for the given rect the coordinates are within (0, 0, w, h)
int h = mDesc.DisplayHeight();
double fx, fy, fw, fh;
[fx, fy, fw, fh] = Screen.GetFullscreenRect(w, h, FSMode_ScaleToFit43);
x = int((x - fx) * w / fw);
y = int((y - fy) * h / fh);
}
if (mFocusControl != NULL)
{

View File

@ -239,15 +239,7 @@ class OptionMenu : Menu
if (y <= 0)
{
let font = generic_ui || !mDesc.mFont? NewSmallFont : mDesc.mFont;
if (font && mDesc.mTitle.Length() > 0)
{
y = -y + font.GetHeight();
}
else
{
y = -y;
}
y = DrawCaption(mDesc.mTitle, y, false);
}
y *= CleanYfac_1;
int rowheight = OptionMenuSettings.mLinespacing * CleanYfac_1;
@ -430,25 +422,39 @@ class OptionMenu : Menu
return screen.GetWidth() / 2 + indent * CleanXfac_1;
}
//=============================================================================
//
// draws and/or measures the caption.
//
//=============================================================================
virtual int DrawCaption(String title, int y, bool drawit)
{
let font = generic_ui || !mDesc.mFont ? NewSmallFont : mDesc.mFont;
if (font && mDesc.mTitle.Length() > 0)
{
return menuCustomizer.DrawCaption(title, font, y, drawit);
}
else
{
return y;
}
}
//=============================================================================
//
//
//
//=============================================================================
override void Drawer ()
{
int y = mDesc.mPosition;
if (y <= 0)
{
let font = generic_ui || !mDesc.mFont? NewSmallFont : mDesc.mFont;
if (font && mDesc.mTitle.Length() > 0)
{
let tt = Stringtable.Localize(mDesc.mTitle);
screen.DrawText (font, OptionMenuSettings.mTitleColor,
(screen.GetWidth() - font.StringWidth(tt) * CleanXfac_1) / 2, 10*CleanYfac_1,
tt, DTA_CleanNoMove_1, true);
y = -y + font.GetHeight();
}
else
{
y = -y;
}
y = DrawCaption(mDesc.mTitle, -y, true);
}
mDesc.mDrawTop = y;
int fontheight = OptionMenuSettings.mLinespacing * CleanYfac_1;

View File

@ -1234,42 +1234,3 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
}
//=============================================================================
//
// Placeholder classes for overhauled video mode menu. Do not use!
// Their sole purpose is to support mods with full copy of embedded MENUDEF
//
//=============================================================================
class OptionMenuItemScreenResolution : OptionMenuItem
{
String mResTexts[3];
int mSelection;
int mHighlight;
int mMaxValid;
enum EValues
{
SRL_INDEX = 0x30000,
SRL_SELECTION = 0x30003,
SRL_HIGHLIGHT = 0x30004,
};
OptionMenuItemScreenResolution Init(String command)
{
return self;
}
override bool Selectable()
{
return false;
}
}
class VideoModeMenu : OptionMenu
{
static bool SetSelectedSize()
{
return false;
}
}