diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index 7d4ed9166..36c406492 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -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() {} diff --git a/source/common/menu/listmenu.cpp b/source/common/menu/listmenu.cpp index 311d0e15d..df1cfa725 100644 --- a/source/common/menu/listmenu.cpp +++ b/source/common/menu/listmenu.cpp @@ -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); } } diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index b3cf00b6b..5214e2900 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -121,6 +121,12 @@ struct FMenuDescriptor class FListMenuItem; class FOptionMenuItem; +enum ListMenuFlags +{ + LMF_Centered = 1, + LMF_DontSpace = 2 +}; + struct FListMenuDescriptor : public FMenuDescriptor { TDeletingArray 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; } }; diff --git a/source/common/menu/menudef.cpp b/source/common/menu/menudef.cpp index 97b0dba14..33b188b07 100644 --- a/source/common/menu/menudef.cpp +++ b/source/common/menu/menudef.cpp @@ -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); diff --git a/source/duke3d/src/d_menu.cpp b/source/duke3d/src/d_menu.cpp index f5e0d332b..fb94c809b 100644 --- a/source/duke3d/src/d_menu.cpp +++ b/source/duke3d/src/d_menu.cpp @@ -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; diff --git a/source/duke3d/src/duke3d.h b/source/duke3d/src/duke3d.h index 36ebf07dd..4d6405e7f 100644 --- a/source/duke3d/src/duke3d.h +++ b/source/duke3d/src/duke3d.h @@ -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; diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index d9d2b1c4b..970eed8c7 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -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); diff --git a/wadsrc/static/demolition/menudef.txt b/wadsrc/static/demolition/menudef.txt index 4d566fa67..529bd04a9 100644 --- a/wadsrc/static/demolition/menudef.txt +++ b/wadsrc/static/demolition/menudef.txt @@ -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