- Ion Fury's main menu now looks correct.

This commit is contained in:
Christoph Oelckers 2019-11-24 22:31:27 +01:00
parent 57b542671c
commit 42b3d12630
8 changed files with 35 additions and 38 deletions

View file

@ -168,14 +168,6 @@ struct GameStats
int timesecnd;
};
enum ETextOrientation
{
TOR_Default,
TOR_Left,
TOR_Center,
TOR_Right
};
struct GameInterface
{
virtual ~GameInterface() {}
@ -187,7 +179,7 @@ struct GameInterface
virtual bool mouseInactiveConditional(bool condition) { return condition; }
virtual FString statFPS() { return "FPS display not available"; }
virtual GameStats getStats() { return {}; }
virtual void DrawNativeMenuText(int fontnum, int state, int xpos, int ypos, float fontscale, const char* text, int orientation = TOR_Default) {}
virtual void DrawNativeMenuText(int fontnum, int state, int xpos, int ypos, float fontscale, const char* text, int flags) {}
virtual void MainMenuOpened() {}
virtual void MenuOpened() {}
virtual void MenuSelectSound() {}

View file

@ -64,7 +64,7 @@ void DListMenu::Init(DMenu *parent, FListMenuDescriptor *desc)
{
mParentMenu = parent;
mDesc = desc;
if (mDesc->mScriptId) scriptID = mDesc->mScriptId;
if (mDesc->mScriptId >= 0) scriptID = mDesc->mScriptId;
#if 0
if (desc->mCenter)
{
@ -473,7 +473,7 @@ bool FListMenuItemSelectable::CheckCoordinate(int x, int y)
bool FListMenuItemSelectable::Selectable()
{
return mEnabled;
return mEnabled && !mHidden;
}
bool FListMenuItemSelectable::Activate()
@ -578,8 +578,8 @@ void FListMenuItemNativeText::Drawer(DListMenu* menu, const vec2_t& origin, bool
if (mText.Len() && !mHidden)
{
if (*text == '$') text = GStrings(text + 1);
int direction = menu->Descriptor()->mCenter == 0 ? TOR_Center : menu->Descriptor()->mCenter < 0 ? TOR_Right : TOR_Left;
gi->DrawNativeMenuText(mFontnum, selected ? NIT_SelectedState : mEnabled? NIT_ActiveState : NIT_InactiveState, (mXpos << 16) + origin.x, (mYpos << 16) + origin.y, 1.f, text, direction);
auto state = selected ? NIT_SelectedState : mEnabled ? NIT_ActiveState : NIT_InactiveState;
gi->DrawNativeMenuText(mFontnum, state, (mXpos << 16) + origin.x, (mYpos << 16) + origin.y, 1.f, text, menu->Descriptor()->mFlags);
}
}

View file

@ -121,6 +121,12 @@ struct FMenuDescriptor
class FListMenuItem;
class FOptionMenuItem;
enum ListMenuFlags
{
LMF_Centered = 1,
LMF_DontSpace = 2
};
struct FListMenuDescriptor : public FMenuDescriptor
{
TDeletingArray<FListMenuItem *> mItems;
@ -142,7 +148,8 @@ struct FListMenuDescriptor : public FMenuDescriptor
EColorRange mFontColor;
EColorRange mFontColor2;
FMenuDescriptor *mRedirect; // used to redirect overlong skill and episode menus to option menu based alternatives
int mCenter;
int mFlags;
int mSpacing;
FListMenuDescriptor()
{
@ -163,11 +170,13 @@ struct FListMenuDescriptor : public FMenuDescriptor
mFont = NULL;
mFontColor = CR_UNTRANSLATED;
mFontColor2 = CR_UNTRANSLATED;
mScriptId = 0;
mScriptId = -1;
mSecondaryId = 0;
mNativeFontNum = NIT_BigFont;
mNativePalNum = NIT_ActiveColor;
mNativeFontScale = 1.f;
mFlags = 0;
mSpacing = 0;
}
};

View file

@ -270,16 +270,16 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
{
sc.MustGetNumber();
desc->mYbotton = sc.Number;
if (sc.CheckString(","))
{
sc.MustGetNumber();
desc->mCenter = sc.Number;
}
}
}
else if (sc.Compare("Centermenu"))
{
desc->mCenter = 0;
desc->mFlags |= LMF_Centered;
}
else if (sc.Compare("Fixedspacing"))
{
sc.MustGetNumber();
desc->mSpacing = sc.Number;
}
else if (sc.Compare("MouseWindow"))
{
@ -518,7 +518,6 @@ static void ParseListMenu(FScanner &sc)
desc->mRedirect = NULL;
desc->mWLeft = 0;
desc->mWRight = 0;
desc->mCenter = 0;
ParseListMenuBody(sc, desc);
bool scratch = ReplaceMenu(sc, desc);

View file

@ -468,7 +468,7 @@ static int Menu_GetFontHeight(int fontnum)
return font.get_yline();
}
void GameInterface::DrawNativeMenuText(int fontnum, int state, int xpos, int ypos, float fontscale, const char* text, int orientation)
void GameInterface::DrawNativeMenuText(int fontnum, int state, int xpos, int ypos, float fontscale, const char* text, int flags)
{
int ydim_upper = 0;
int ydim_lower = ydim - 1;
@ -480,7 +480,7 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, int xpos, int ypo
status |= MT_Selected;
if (state == NIT_InactiveState)
status |= MT_Disabled;
if (orientation == TOR_Center)
if (flags & LMF_Centered)
status |= MT_XCenter;
bool const dodraw = true;
@ -494,9 +494,6 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, int xpos, int ypo
if (dodraw)
textsize = Menu_Text(x, y_internal, &font, text, status, ydim_upper, ydim_lower);
if (orientation == TOR_Right)
status |= MT_XRight;
if (dodraw && (status & MT_Selected) && state != 1)
{
if (status & MT_XCenter)
@ -564,8 +561,9 @@ protected:
}
totalheight += height;
}
if (mDesc->mSpacing <= 0) calculatedentryspacing = std::max(0, (y_lower - y_upper - totalheight) / (numvalidentries > 1 ? numvalidentries - 1 : 1));
if (calculatedentryspacing <= 0) calculatedentryspacing = mDesc->mSpacing;
calculatedentryspacing = std::max(0, (y_lower - y_upper - totalheight) / (numvalidentries > 1 ? numvalidentries - 1 : 1));
// totalHeight calculating pass
int totalHeight;

View file

@ -156,7 +156,7 @@ struct GameInterface : ::GameInterface
GameStats getStats() override;
// Access to the front end specific menu code. Use is restricted to the main menu, the ingame menu and the skill/episode selection.
// Everything else is either custom screens or will use the generic option menu style.
void DrawNativeMenuText(int fontnum, int state, int xpos, int ypos, float fontscale, const char* text, int orientation = TOR_Default) override;
void DrawNativeMenuText(int fontnum, int state, int xpos, int ypos, float fontscale, const char* text, int orientation) override;
void MenuOpened() override;
void MenuSelectSound() override;
void MenuChooseSound() override;

View file

@ -1760,9 +1760,6 @@ void Menu_Init(void)
// hack; should swap out pointers
MF_Minifont = MF_Bluefont;
MMF_Top_Main.pos.x = 40<<16;
MMF_Top_Main.pos.y = 130<<16;
MMF_Top_Main.bottomcutoff = 190<<16;
M_OPTIONS.format = &MMF_Top_Main;
MEF_MainMenu.width = MEF_OptionsMenu.width = -(160<<16);

View file

@ -6,16 +6,17 @@
LISTMENU "MainMenu"
{
ScriptId 1
ScriptId 0
ifgame(Duke, Nam, WW2GI, Fury)
{
ifgame(fury)
{
position 40, 130, 60, -160
position 40, 130, 60
fixedspacing 2
}
else
{
position 160, 55, 115, 0
position 160, 55, 115
centermenu
}
linespacing 15
@ -39,7 +40,7 @@ LISTMENU "MainMenu"
{
linespacing 15
NativeTextItem "$MNU_NEWGAME", "n", "PlayerclassMenu"
//NativeTextItem "$MNU_MULTIPLAYER", "m", "MultiMenu" // In EDuke this replaces "New Game" when in networking mode. Kept here as a reminder (I'm not going to support EDuke's C/S implementation)
//NativeTextItem "$MNU_NEWGAME", "m", "MultiMenu" // In EDuke this replaces "New Game" when in networking mode. Kept here as a reminder (I'm not going to support EDuke's C/S implementation)
NativeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
NativeTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
NativeTextItem "$MNU_HELP", "h", "HelpMenu"
@ -76,11 +77,12 @@ LISTMENU "IngameMenu"
{
ifgame(fury)
{
position 40, 130, 60, -160
position 40, 130, 60
fixedspacing 2
}
else
{
position 160, 55, 115, 0
position 160, 55, 115
centermenu
}
linespacing 15