diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 0a9f5070e..d67f72f81 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -27,6 +27,7 @@ #include "v_draw.h" #include "imgui.h" #include "stats.h" +#include "menu.h" #ifdef USE_OPENGL # include "glsurface.h" @@ -10067,6 +10068,7 @@ void videoNextPage(void) // Draw the console plus debug output on top of everything else. DrawFullscreenBlends(); + M_Drawer(); FStat::PrintStat(); C_DrawConsole(); GLInterface.Draw2D(&twod); diff --git a/source/common/console/d_event.cpp b/source/common/console/d_event.cpp index 3846e5829..b61ef1948 100644 --- a/source/common/console/d_event.cpp +++ b/source/common/console/d_event.cpp @@ -25,6 +25,7 @@ #include "c_console.h" #include "d_gui.h" #include "inputstate.h" +#include "menu.h" int eventhead; int eventtail; @@ -150,10 +151,8 @@ void D_ProcessEvents (void) (void)0;//UpdateJoystickMenu(I_UpdateDeviceList()); if (C_Responder (ev)) continue; // console ate the event -#if 0 if (M_Responder (ev)) continue; // menu ate the event -#endif G_Responder (ev); } } diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index 2fabae2d1..62aefcd3e 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -23,6 +23,7 @@ #include "i_specialpaths.h" #include "z_music.h" #include "statistics.h" +#include "menu.h" #ifndef NETCODE_DISABLE #include "enet.h" #endif @@ -381,6 +382,7 @@ int CONFIG_Init() buttonMap.SetGameAliases(); Mus_Init(); InitStatistics(); + M_Init(); diff --git a/source/common/menu/listmenu.cpp b/source/common/menu/listmenu.cpp index 7bcec164b..7cb389e8a 100644 --- a/source/common/menu/listmenu.cpp +++ b/source/common/menu/listmenu.cpp @@ -502,28 +502,29 @@ bool FListMenuItemSelectable::MouseEvent(int type, int x, int y) // //============================================================================= -FListMenuItemText::FListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, EColorRange color, EColorRange color2, FName child, int param) +FListMenuItemText::FListMenuItemText(int x, int y, int height, int hotkey, const FString &text, FFont *font, EColorRange color, EColorRange color2, FName child, int param) : FListMenuItemSelectable(x, y, height, child, param) { mText = text; + /* mFont = font; mColor = color; mColorSelected = color2; + */ + mFont = NewSmallFont; + mColor = CR_RED; + mColorSelected = CR_GOLD; mHotkey = hotkey; } FListMenuItemText::~FListMenuItemText() { - if (mText != NULL) - { - delete [] mText; - } } void FListMenuItemText::Drawer(bool selected) { const char *text = mText; - if (text != NULL) + if (mText.Len()) { if (*text == '$') text = GStrings(text+1); DrawText(&twod, mFont, selected ? mColorSelected : mColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE); @@ -533,7 +534,7 @@ void FListMenuItemText::Drawer(bool selected) int FListMenuItemText::GetWidth() { const char *text = mText; - if (text != NULL) + if (mText.Len()) { if (*text == '$') text = GStrings(text+1); return mFont->StringWidth(text); diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 57e9219d8..2256f7ebc 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -296,6 +296,7 @@ void M_StartControlPanel (bool makeSound) } C_HideConsole (); // [RH] Make sure console goes bye bye. + GUICapture |= 1; menuactive = MENU_On; // Pause sound effects before we play the menu switch sound. // That way, it won't be paused. @@ -416,9 +417,9 @@ void M_SetMenu(FName menu, int param) } else { - const PClass *cls = ld->mClass == NULL? RUNTIME_CLASS(DListMenu) : ld->mClass; + //const PClass *cls = ld->mClass == NULL? RUNTIME_CLASS(DListMenu) : ld->mClass; - DListMenu *newmenu = (DListMenu *)cls->CreateNew(); + DListMenu* newmenu = new DListMenu; newmenu->Init(DMenu::CurrentMenu, ld); M_ActivateMenu(newmenu); } @@ -426,9 +427,9 @@ void M_SetMenu(FName menu, int param) else if ((*desc)->mType == MDESC_OptionsMenu) { FOptionMenuDescriptor *ld = static_cast(*desc); - const PClass *cls = ld->mClass == NULL? RUNTIME_CLASS(DOptionMenu) : ld->mClass; + //const PClass *cls = ld->mClass == NULL? RUNTIME_CLASS(DOptionMenu) : ld->mClass; - DOptionMenu *newmenu = (DOptionMenu *)cls->CreateNew(); + DOptionMenu *newmenu = new DOptionMenu; newmenu->Init(DMenu::CurrentMenu, ld); M_ActivateMenu(newmenu); } @@ -649,6 +650,7 @@ bool M_Responder (event_t *ev) void M_Ticker (void) { DMenu::MenuTime++; + if (DMenu::MenuTime & 3) return; if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off) { DMenu::CurrentMenu->Ticker(); @@ -685,7 +687,7 @@ void M_Ticker (void) void M_Drawer (void) { - PalEntry fade = 0;// x70000000; + PalEntry fade = 0x70000000; #if 0 player_t *player = &players[consoleplayer]; AActor *camera = player->camera; @@ -701,9 +703,9 @@ void M_Drawer (void) #endif - if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off && fade) + if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off) { - if (DMenu::CurrentMenu->DimAllowed()) twod.AddColorOnlyQuad(0, 0, screen->GetWidth(), screen->GetHeight(), fade); + if (DMenu::CurrentMenu->DimAllowed() && fade) twod.AddColorOnlyQuad(0, 0, screen->GetWidth(), screen->GetHeight(), fade); DMenu::CurrentMenu->Drawer(); } } @@ -723,6 +725,7 @@ void M_ClearMenus () DMenu::CurrentMenu = NULL; } menuactive = MENU_Off; + GUICapture &= ~1; } //============================================================================= @@ -733,6 +736,7 @@ void M_ClearMenus () void M_Init (void) { + timerSetCallback(M_Ticker); M_ParseMenuDefs(); M_CreateMenus(); } diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index 8d70dac72..874a7768d 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -96,7 +96,7 @@ struct FMenuDescriptor FName mMenuName; FString mNetgameMessage; int mType; - const PClass *mClass; + FName mClass; virtual ~FMenuDescriptor() {} }; @@ -399,12 +399,12 @@ public: class FListMenuItemText : public FListMenuItemSelectable { - const char *mText; + FString mText; FFont *mFont; EColorRange mColor; EColorRange mColorSelected; public: - FListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, EColorRange color, EColorRange color2, FName child, int param = 0); + FListMenuItemText(int x, int y, int height, int hotkey, const FString &text, FFont *font, EColorRange color, EColorRange color2, FName child, int param = 0); ~FListMenuItemText(); void Drawer(bool selected); int GetWidth(); @@ -430,8 +430,8 @@ class DListMenu : public DMenu DECLARE_CLASS(DListMenu, DMenu) protected: - FListMenuDescriptor *mDesc; - FListMenuItem *mFocusControl; + FListMenuDescriptor *mDesc = nullptr; + FListMenuItem *mFocusControl = nullptr; public: DListMenu(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL); @@ -467,7 +467,7 @@ class FOptionMenuItem : public FListMenuItem { protected: FString mLabel; - bool mCentered; + bool mCentered = false; void drawLabel(int indent, int y, EColorRange color, bool grayed = false); public: diff --git a/source/common/menu/menudef.cpp b/source/common/menu/menudef.cpp index 4f1f5939b..40023216c 100644 --- a/source/common/menu/menudef.cpp +++ b/source/common/menu/menudef.cpp @@ -241,12 +241,7 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc) else if (sc.Compare("Class")) { sc.MustGetString(); - const PClass *cls = PClass::FindClass(sc.String); - if (cls == NULL || !cls->IsDescendantOf(RUNTIME_CLASS(DListMenu))) - { - sc.ScriptError("Unknown menu class '%s'", sc.String); - } - desc->mClass = cls; + desc->mClass = sc.String; } else if (sc.Compare("Selector")) { @@ -428,8 +423,8 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc) static bool CheckCompatible(FMenuDescriptor *newd, FMenuDescriptor *oldd) { - if (oldd->mClass == NULL) return true; - return oldd->mClass == newd->mClass; + /*if (oldd->mClass == NULL)*/ return true; + //return oldd->mClass == newd->mClass; } static bool ReplaceMenu(FScanner &sc, FMenuDescriptor *desc) @@ -629,12 +624,7 @@ static void ParseOptionMenuBody(FScanner &sc, FOptionMenuDescriptor *desc) else if (sc.Compare("Class")) { sc.MustGetString(); - const PClass *cls = PClass::FindClass(sc.String); - if (cls == NULL || !cls->IsDescendantOf(RUNTIME_CLASS(DOptionMenu))) - { - sc.ScriptError("Unknown menu class '%s'", sc.String); - } - desc->mClass = cls; + desc->mClass = sc.String; } else if (sc.Compare("Title")) { diff --git a/source/common/menu/messagebox.cpp b/source/common/menu/messagebox.cpp index f568553f5..f0f17576d 100644 --- a/source/common/menu/messagebox.cpp +++ b/source/common/menu/messagebox.cpp @@ -203,7 +203,7 @@ void DMessageBoxMenu::Drawer () if (messageSelection >= 0) { - if ((DMenu::MenuTime%8) < 6) + if (((DMenu::MenuTime>>2)%8) < 6) { DrawText(&twod, ConFont, OptionSettings.mFontColorSelection, (150 - 160) * CleanXfac + screen->GetWidth() / 2, diff --git a/source/common/menu/optionmenu.cpp b/source/common/menu/optionmenu.cpp index bbe1d278f..1eb6b7981 100644 --- a/source/common/menu/optionmenu.cpp +++ b/source/common/menu/optionmenu.cpp @@ -444,7 +444,7 @@ void DOptionMenu::Drawer () int cur_indent = mDesc->mItems[i]->Draw(mDesc, y, indent, isSelected); if (cur_indent >= 0 && isSelected && mDesc->mItems[i]->Selectable()) { - if (((DMenu::MenuTime%8) < 6) || DMenu::CurrentMenu != this) + if ((((DMenu::MenuTime>>2)%8) < 6) || DMenu::CurrentMenu != this) { M_DrawConText(OptionSettings.mFontColorSelection, cur_indent + 3 * CleanXfac_1, y+fontheight-9*CleanYfac_1, "\xd"); } diff --git a/wadsrc/static/demolition/menudef.txt b/wadsrc/static/demolition/menudef.txt new file mode 100644 index 000000000..838c4a6fa --- /dev/null +++ b/wadsrc/static/demolition/menudef.txt @@ -0,0 +1,40 @@ +//------------------------------------------------------------------------------------------- +// +// Text only variant of the main menu for Doom, Strife and Chex Quest to be used with localized content. +// +//------------------------------------------------------------------------------------------- + +LISTMENU "MainMenu" +{ + linespacing 15 + TextItem "$MNU_NEWGAME", "n", "PlayerclassMenu" + TextItem "$MNU_LOADGAME", "l", "LoadGameMenu" + TextItem "$MNU_OPTIONS", "o", "OptionsMenu" + TextItem "$MNU_HELP", "h", "HelpMenu" + TextItem "$MNU_CREDITS", "c", "CreditsMenu" + TextItem "$MNU_QUITGAME", "q", "QuitMenu" +} + +LISTMENU "MainMenu_Blood" +{ + linespacing 15 + TextItem "$MNU_NEWGAME", "n", "PlayerclassMenu" + TextItem "$MNU_MULTIPLAYER", "m", "MultiMenu" + TextItem "$MNU_OPTIONS", "o", "OptionsMenu" + TextItem "$MNU_LOADGAME", "l", "LoadGameMenu" + TextItem "$MNU_HELP", "h", "HelpMenu" + TextItem "$MNU_CREDITS", "c", "CreditsMenu" + TextItem "$MNU_QUITGAME", "q", "QuitMenu" +} + +LISTMENU "MainMenu_SW" +{ + linespacing 15 + TextItem "$MNU_NEWGAME", "n", "PlayerclassMenu" + TextItem "$MNU_LOADGAME", "l", "LoadGameMenu" + TextItem "$MNU_SAVEGAME", "s", "SaveGameMenu" + TextItem "$MNU_OPTIONS", "o", "OptionsMenu" + TextItem "$MNU_COOLSTUFF", "h", "HelpMenu" + TextItem "$MNU_QUITGAME", "q", "QuitMenu" +} + diff --git a/wadsrc/static/language.txt b/wadsrc/static/language.txt new file mode 100644 index 000000000..e69de29bb