- hooked up the menu code so that it can receive events.

Nothing pretty yet but a start is made.
This commit is contained in:
Christoph Oelckers 2019-11-21 22:31:46 +01:00
parent 2740913c60
commit 5f9b57519a
11 changed files with 76 additions and 38 deletions

View file

@ -27,6 +27,7 @@
#include "v_draw.h" #include "v_draw.h"
#include "imgui.h" #include "imgui.h"
#include "stats.h" #include "stats.h"
#include "menu.h"
#ifdef USE_OPENGL #ifdef USE_OPENGL
# include "glsurface.h" # include "glsurface.h"
@ -10067,6 +10068,7 @@ void videoNextPage(void)
// Draw the console plus debug output on top of everything else. // Draw the console plus debug output on top of everything else.
DrawFullscreenBlends(); DrawFullscreenBlends();
M_Drawer();
FStat::PrintStat(); FStat::PrintStat();
C_DrawConsole(); C_DrawConsole();
GLInterface.Draw2D(&twod); GLInterface.Draw2D(&twod);

View file

@ -25,6 +25,7 @@
#include "c_console.h" #include "c_console.h"
#include "d_gui.h" #include "d_gui.h"
#include "inputstate.h" #include "inputstate.h"
#include "menu.h"
int eventhead; int eventhead;
int eventtail; int eventtail;
@ -150,10 +151,8 @@ void D_ProcessEvents (void)
(void)0;//UpdateJoystickMenu(I_UpdateDeviceList()); (void)0;//UpdateJoystickMenu(I_UpdateDeviceList());
if (C_Responder (ev)) if (C_Responder (ev))
continue; // console ate the event continue; // console ate the event
#if 0
if (M_Responder (ev)) if (M_Responder (ev))
continue; // menu ate the event continue; // menu ate the event
#endif
G_Responder (ev); G_Responder (ev);
} }
} }

View file

@ -23,6 +23,7 @@
#include "i_specialpaths.h" #include "i_specialpaths.h"
#include "z_music.h" #include "z_music.h"
#include "statistics.h" #include "statistics.h"
#include "menu.h"
#ifndef NETCODE_DISABLE #ifndef NETCODE_DISABLE
#include "enet.h" #include "enet.h"
#endif #endif
@ -381,6 +382,7 @@ int CONFIG_Init()
buttonMap.SetGameAliases(); buttonMap.SetGameAliases();
Mus_Init(); Mus_Init();
InitStatistics(); InitStatistics();
M_Init();

View file

@ -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) : FListMenuItemSelectable(x, y, height, child, param)
{ {
mText = text; mText = text;
/*
mFont = font; mFont = font;
mColor = color; mColor = color;
mColorSelected = color2; mColorSelected = color2;
*/
mFont = NewSmallFont;
mColor = CR_RED;
mColorSelected = CR_GOLD;
mHotkey = hotkey; mHotkey = hotkey;
} }
FListMenuItemText::~FListMenuItemText() FListMenuItemText::~FListMenuItemText()
{ {
if (mText != NULL)
{
delete [] mText;
}
} }
void FListMenuItemText::Drawer(bool selected) void FListMenuItemText::Drawer(bool selected)
{ {
const char *text = mText; const char *text = mText;
if (text != NULL) if (mText.Len())
{ {
if (*text == '$') text = GStrings(text+1); if (*text == '$') text = GStrings(text+1);
DrawText(&twod, mFont, selected ? mColorSelected : mColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE); 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() int FListMenuItemText::GetWidth()
{ {
const char *text = mText; const char *text = mText;
if (text != NULL) if (mText.Len())
{ {
if (*text == '$') text = GStrings(text+1); if (*text == '$') text = GStrings(text+1);
return mFont->StringWidth(text); return mFont->StringWidth(text);

View file

@ -296,6 +296,7 @@ void M_StartControlPanel (bool makeSound)
} }
C_HideConsole (); // [RH] Make sure console goes bye bye. C_HideConsole (); // [RH] Make sure console goes bye bye.
GUICapture |= 1;
menuactive = MENU_On; menuactive = MENU_On;
// Pause sound effects before we play the menu switch sound. // Pause sound effects before we play the menu switch sound.
// That way, it won't be paused. // That way, it won't be paused.
@ -416,9 +417,9 @@ void M_SetMenu(FName menu, int param)
} }
else 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); newmenu->Init(DMenu::CurrentMenu, ld);
M_ActivateMenu(newmenu); M_ActivateMenu(newmenu);
} }
@ -426,9 +427,9 @@ void M_SetMenu(FName menu, int param)
else if ((*desc)->mType == MDESC_OptionsMenu) else if ((*desc)->mType == MDESC_OptionsMenu)
{ {
FOptionMenuDescriptor *ld = static_cast<FOptionMenuDescriptor*>(*desc); FOptionMenuDescriptor *ld = static_cast<FOptionMenuDescriptor*>(*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); newmenu->Init(DMenu::CurrentMenu, ld);
M_ActivateMenu(newmenu); M_ActivateMenu(newmenu);
} }
@ -649,6 +650,7 @@ bool M_Responder (event_t *ev)
void M_Ticker (void) void M_Ticker (void)
{ {
DMenu::MenuTime++; DMenu::MenuTime++;
if (DMenu::MenuTime & 3) return;
if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off) if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off)
{ {
DMenu::CurrentMenu->Ticker(); DMenu::CurrentMenu->Ticker();
@ -685,7 +687,7 @@ void M_Ticker (void)
void M_Drawer (void) void M_Drawer (void)
{ {
PalEntry fade = 0;// x70000000; PalEntry fade = 0x70000000;
#if 0 #if 0
player_t *player = &players[consoleplayer]; player_t *player = &players[consoleplayer];
AActor *camera = player->camera; AActor *camera = player->camera;
@ -701,9 +703,9 @@ void M_Drawer (void)
#endif #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(); DMenu::CurrentMenu->Drawer();
} }
} }
@ -723,6 +725,7 @@ void M_ClearMenus ()
DMenu::CurrentMenu = NULL; DMenu::CurrentMenu = NULL;
} }
menuactive = MENU_Off; menuactive = MENU_Off;
GUICapture &= ~1;
} }
//============================================================================= //=============================================================================
@ -733,6 +736,7 @@ void M_ClearMenus ()
void M_Init (void) void M_Init (void)
{ {
timerSetCallback(M_Ticker);
M_ParseMenuDefs(); M_ParseMenuDefs();
M_CreateMenus(); M_CreateMenus();
} }

View file

@ -96,7 +96,7 @@ struct FMenuDescriptor
FName mMenuName; FName mMenuName;
FString mNetgameMessage; FString mNetgameMessage;
int mType; int mType;
const PClass *mClass; FName mClass;
virtual ~FMenuDescriptor() {} virtual ~FMenuDescriptor() {}
}; };
@ -399,12 +399,12 @@ public:
class FListMenuItemText : public FListMenuItemSelectable class FListMenuItemText : public FListMenuItemSelectable
{ {
const char *mText; FString mText;
FFont *mFont; FFont *mFont;
EColorRange mColor; EColorRange mColor;
EColorRange mColorSelected; EColorRange mColorSelected;
public: 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(); ~FListMenuItemText();
void Drawer(bool selected); void Drawer(bool selected);
int GetWidth(); int GetWidth();
@ -430,8 +430,8 @@ class DListMenu : public DMenu
DECLARE_CLASS(DListMenu, DMenu) DECLARE_CLASS(DListMenu, DMenu)
protected: protected:
FListMenuDescriptor *mDesc; FListMenuDescriptor *mDesc = nullptr;
FListMenuItem *mFocusControl; FListMenuItem *mFocusControl = nullptr;
public: public:
DListMenu(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL); DListMenu(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL);
@ -467,7 +467,7 @@ class FOptionMenuItem : public FListMenuItem
{ {
protected: protected:
FString mLabel; FString mLabel;
bool mCentered; bool mCentered = false;
void drawLabel(int indent, int y, EColorRange color, bool grayed = false); void drawLabel(int indent, int y, EColorRange color, bool grayed = false);
public: public:

View file

@ -241,12 +241,7 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
else if (sc.Compare("Class")) else if (sc.Compare("Class"))
{ {
sc.MustGetString(); sc.MustGetString();
const PClass *cls = PClass::FindClass(sc.String); desc->mClass = sc.String;
if (cls == NULL || !cls->IsDescendantOf(RUNTIME_CLASS(DListMenu)))
{
sc.ScriptError("Unknown menu class '%s'", sc.String);
}
desc->mClass = cls;
} }
else if (sc.Compare("Selector")) else if (sc.Compare("Selector"))
{ {
@ -428,8 +423,8 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
static bool CheckCompatible(FMenuDescriptor *newd, FMenuDescriptor *oldd) static bool CheckCompatible(FMenuDescriptor *newd, FMenuDescriptor *oldd)
{ {
if (oldd->mClass == NULL) return true; /*if (oldd->mClass == NULL)*/ return true;
return oldd->mClass == newd->mClass; //return oldd->mClass == newd->mClass;
} }
static bool ReplaceMenu(FScanner &sc, FMenuDescriptor *desc) static bool ReplaceMenu(FScanner &sc, FMenuDescriptor *desc)
@ -629,12 +624,7 @@ static void ParseOptionMenuBody(FScanner &sc, FOptionMenuDescriptor *desc)
else if (sc.Compare("Class")) else if (sc.Compare("Class"))
{ {
sc.MustGetString(); sc.MustGetString();
const PClass *cls = PClass::FindClass(sc.String); desc->mClass = sc.String;
if (cls == NULL || !cls->IsDescendantOf(RUNTIME_CLASS(DOptionMenu)))
{
sc.ScriptError("Unknown menu class '%s'", sc.String);
}
desc->mClass = cls;
} }
else if (sc.Compare("Title")) else if (sc.Compare("Title"))
{ {

View file

@ -203,7 +203,7 @@ void DMessageBoxMenu::Drawer ()
if (messageSelection >= 0) if (messageSelection >= 0)
{ {
if ((DMenu::MenuTime%8) < 6) if (((DMenu::MenuTime>>2)%8) < 6)
{ {
DrawText(&twod, ConFont, OptionSettings.mFontColorSelection, DrawText(&twod, ConFont, OptionSettings.mFontColorSelection,
(150 - 160) * CleanXfac + screen->GetWidth() / 2, (150 - 160) * CleanXfac + screen->GetWidth() / 2,

View file

@ -444,7 +444,7 @@ void DOptionMenu::Drawer ()
int cur_indent = mDesc->mItems[i]->Draw(mDesc, y, indent, isSelected); int cur_indent = mDesc->mItems[i]->Draw(mDesc, y, indent, isSelected);
if (cur_indent >= 0 && isSelected && mDesc->mItems[i]->Selectable()) 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"); M_DrawConText(OptionSettings.mFontColorSelection, cur_indent + 3 * CleanXfac_1, y+fontheight-9*CleanYfac_1, "\xd");
} }

View file

@ -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"
}

View file