diff --git a/source/blood/CMakeLists.txt b/source/blood/CMakeLists.txt index 5750e3d21..564c2a255 100644 --- a/source/blood/CMakeLists.txt +++ b/source/blood/CMakeLists.txt @@ -102,6 +102,7 @@ set( PCH_SOURCES src/view.cpp src/warp.cpp src/weapon.cpp + src/d_menu.cpp ) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 5e9f70636..1b1610d4c 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -71,6 +71,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecontrol.h" #include "m_argv.h" #include "statistics.h" +#include "menu/menu.h" #ifdef _WIN32 # include @@ -713,8 +714,8 @@ void StartLevel(GAMEOPTIONS *gameOptions) gCacheMiss = 0; gFrame = 0; gChokeCounter = 0; - if (!gDemo.at1) - gGameMenuMgr.Deactivate(); + if (!gDemo.at1) + M_ClearMenus(); levelTryPlayMusicOrNothing(gGameOptions.nEpisode, gGameOptions.nLevel); // viewSetMessage(""); viewSetErrorMessage(""); @@ -819,67 +820,21 @@ void LocalKeys(void) buttonMap.ClearButton(gamefunc_See_Chase_View); return; } +#if 0 switch (key) { case sc_kpad_Period: case sc_Delete: if (ctrl && alt) { - gQuitGame = 1; + gQuitGame = 1; // uh, what? return; } break; - case sc_Escape: - inputState.keyFlushScans(); - if (gGameStarted && gPlayer[myconnectindex].pXSprite->health != 0) - { - if (!gGameMenuMgr.m_bActive) - gGameMenuMgr.Push(&menuMainWithSave,-1); - } - else - { - if (!gGameMenuMgr.m_bActive) - gGameMenuMgr.Push(&menuMain,-1); - } - return; - case sc_F1: - inputState.keyFlushScans(); - if (gGameOptions.nGameType == 0) - gGameMenuMgr.Push(&menuOrder,-1); - break; - case sc_F2: - inputState.keyFlushScans(); - if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0) - gGameMenuMgr.Push(&menuSaveGame,-1); - break; - case sc_F3: - inputState.keyFlushScans(); - if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0) - gGameMenuMgr.Push(&menuLoadGame,-1); - break; - case sc_F4: - inputState.keyFlushScans(); - if (!gGameMenuMgr.m_bActive) - gGameMenuMgr.Push(&menuOptionsSound,-1); - return; - case sc_F5: - inputState.keyFlushScans(); - if (!gGameMenuMgr.m_bActive) - gGameMenuMgr.Push(&menuOptions,-1); - return; - case sc_F8: - inputState.keyFlushScans(); - if (!gGameMenuMgr.m_bActive) - gGameMenuMgr.Push(&menuOptionsDisplayMode, -1); - return; - case sc_F10: - inputState.keyFlushScans(); - if (!gGameMenuMgr.m_bActive) - gGameMenuMgr.Push(&menuQuit,-1); - break; - case sc_F11: + case default: break; } +#endif } } @@ -943,7 +898,7 @@ void ProcessFrame(void) viewClearInterpolations(); if (!gDemo.at1) { - if (gPaused || gEndGameMgr.at0 || (gGameOptions.nGameType == 0 && gGameMenuMgr.m_bActive)) + if (gPaused || gEndGameMgr.at0 || (gGameOptions.nGameType == 0 && M_Active())) return; if (gDemo.at0) gDemo.Write(gFifoInput[(gNetFifoTail-1)&255]); @@ -1000,8 +955,9 @@ void ProcessFrame(void) { if (gGameOptions.uGameFlags&8) levelPlayEndScene(gGameOptions.nEpisode); - gGameMenuMgr.Deactivate(); - gGameMenuMgr.Push(&menuCredits,-1); + + M_StartControlPanel(false); + M_SetMenu(NAME_CreditsMenu); } gGameOptions.uGameFlags &= ~3; gRestartGame = 1; @@ -1249,7 +1205,6 @@ int GameInterface::app_main() levelAddUserMap(gUserMapFilename); gStartNewGame = 1; } - SetupMenus(); videoSetViewableArea(0, 0, xdim - 1, ydim - 1); if (!bQuickStart) credLogosDos(); @@ -1285,9 +1240,12 @@ RESTART: else if (gDemo.at1 && !bAddUserMap && !bNoDemo) gDemo.Playback(); if (gDemo.at59ef > 0) - gGameMenuMgr.Deactivate(); - if (!bAddUserMap && !gGameStarted) - gGameMenuMgr.Push(&menuMain, -1); + M_ClearMenus(); + if (!bAddUserMap && !gGameStarted) + { + M_StartControlPanel(false); + M_SetMenu(NAME_MainMenu); + } ready2send = 1; while (!gQuitGame) { @@ -1297,10 +1255,6 @@ RESTART: inputState.SetBindsEnabled(gInputMode == kInputGame); switch (gInputMode) { - case kInputMenu: - if (gGameMenuMgr.m_bActive) - gGameMenuMgr.Process(); - break; case kInputGame: LocalKeys(); break; @@ -1377,10 +1331,6 @@ RESTART: { switch (gInputMode) { - case kInputMenu: - if (gGameMenuMgr.m_bActive) - gGameMenuMgr.Draw(); - break; case kInputMessage: gPlayerMsg.ProcessKeys(); gPlayerMsg.Draw(); @@ -1424,6 +1374,8 @@ RESTART: gRestartGame = 0; gGameStarted = 0; levelSetupOptions(0,0); +#if 0 + // What's this loop for? Needs checking while (gGameMenuMgr.m_bActive) { gGameMenuMgr.Process(); @@ -1435,6 +1387,7 @@ RESTART: videoNextPage(); } } +#endif if (gGameOptions.nGameType != 0) { if (!gDemo.at0 && gDemo.at59ef > 0 && gGameOptions.nGameType == 0 && !bNoDemo) diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 39d4dd700..92bc9186f 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -46,7 +46,6 @@ extern INICHAIN *pINIChain; enum INPUT_MODE { kInputGame = 0, - kInputMenu, kInputMessage, kInputEndGame, }; diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 3678eaa7c..e0b4d9fd5 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -174,7 +174,7 @@ void ctrlGetInput(void) if (gQuitRequest) gInput.keyFlags.quit = 1; - if (gGameStarted && gInputMode != kInputMessage && gInputMode != kInputMenu + if (gGameStarted && gInputMode != kInputMessage && buttonMap.ButtonDown(gamefunc_SendMessage)) { buttonMap.ClearButton(gamefunc_SendMessage); diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp new file mode 100644 index 000000000..62521b56a --- /dev/null +++ b/source/blood/src/d_menu.cpp @@ -0,0 +1,152 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2010-2019 EDuke32 developers and contributors +Copyright (C) 2019 Nuke.YKT + +This file is part of NBlood. + +NBlood is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +//------------------------------------------------------------------------- + +#include "ns.h" // Must come before everything else! + +#include "build.h" +#include "compat.h" +#include "mouse.h" +#include "common_game.h" +#include "blood.h" +#include "config.h" +#include "gamemenu.h" +#include "globals.h" +#include "inifile.h" +#include "levels.h" +#include "menu.h" +#include "qav.h" +#include "resource.h" +#include "view.h" +#include "demo.h" +#include "network.h" +#include "c_bind.h" + +bool ShowOptionMenu(); + +BEGIN_BLD_NS + +CMenuTextMgr gMenuTextMgr; + +CMenuTextMgr::CMenuTextMgr() +{ + at0 = -1; +} + +void CMenuTextMgr::DrawText(const char* pString, int nFont, int x, int y, int nShade, int nPalette, bool shadow) +{ + viewDrawText(nFont, pString, x, y, nShade, nPalette, 0, shadow); +} + +void CMenuTextMgr::GetFontInfo(int nFont, const char* pString, int* pXSize, int* pYSize) +{ + if (nFont < 0 || nFont >= 5) + return; + viewGetFontInfo(nFont, pString, pXSize, pYSize); +} + +const char* zNetGameTypes[] = +{ + "Cooperative", + "Bloodbath", + "Teams", +}; + +void drawLoadingScreen(void) +{ + char buffer[80]; + if (gGameOptions.nGameType == 0) + { + if (gDemo.at1) + sprintf(buffer, "Loading Demo"); + else + sprintf(buffer, "Loading Level"); + } + else + sprintf(buffer, "%s", zNetGameTypes[gGameOptions.nGameType - 1]); + viewLoadingScreen(2049, buffer, levelGetTitle(), NULL); +} + +void UpdateNetworkMenus(void) +{ + // Kept as a reminder to reimplement later. +#if 0 + if (gGameOptions.nGameType > 0) + { + itemMain1.at24 = &menuNetStart; + itemMain1.at28 = 2; + } + else + { + itemMain1.at24 = &menuEpisode; + itemMain1.at28 = -1; + } + if (gGameOptions.nGameType > 0) + { + itemMainSave1.at24 = &menuNetStart; + itemMainSave1.at28 = 2; + } + else + { + itemMainSave1.at24 = &menuEpisode; + itemMainSave1.at28 = -1; + } +#endif +} + +void MenuSetupEpisodeInfo(void) +{ +#if 0 + memset(zEpisodeNames, 0, sizeof(zEpisodeNames)); + memset(zLevelNames, 0, sizeof(zLevelNames)); + for (int i = 0; i < 6; i++) + { + if (i < gEpisodeCount) + { + EPISODEINFO* pEpisode = &gEpisodeInfo[i]; + zEpisodeNames[i] = pEpisode->at0; + for (int j = 0; j < 16; j++) + { + if (j < pEpisode->nLevels) + { + zLevelNames[i][j] = pEpisode->at28[j].at90; + } + } + } + } +#endif +} + +bool GameInterface::mouseInactiveConditional(bool condition) +{ + return condition; +} + + + +FSavegameInfo GameInterface::GetSaveSig() +{ + return { SAVESIG_BLD, MINSAVEVER_BLD, SAVEVER_BLD }; +} + + +END_BLD_NS diff --git a/source/blood/src/demo.cpp b/source/blood/src/demo.cpp index 202ebc661..dc1970161 100644 --- a/source/blood/src/demo.cpp +++ b/source/blood/src/demo.cpp @@ -281,9 +281,6 @@ void CDemo::ProcessKeys(void) { switch (gInputMode) { - case kInputMenu: - gGameMenuMgr.Process(); - break; case kInputMessage: gPlayerMsg.ProcessKeys(); break; diff --git a/source/blood/src/endgame.cpp b/source/blood/src/endgame.cpp index d453362e6..50a589d89 100644 --- a/source/blood/src/endgame.cpp +++ b/source/blood/src/endgame.cpp @@ -40,6 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "view.h" #include "messages.h" #include "statistics.h" +#include "gamemenu.h" BEGIN_BLD_NS diff --git a/source/blood/src/gamemenu.cpp b/source/blood/src/gamemenu.cpp index 7e6fd143e..25b02756c 100644 --- a/source/blood/src/gamemenu.cpp +++ b/source/blood/src/gamemenu.cpp @@ -43,6 +43,8 @@ bool ShowOptionMenu(); BEGIN_BLD_NS +#if 0 + CMenuTextMgr gMenuTextMgr; CGameMenuMgr gGameMenuMgr; @@ -2985,9 +2987,6 @@ bool CGameMenuItemPassword::Event(CGameMenuEvent &event) return CGameMenuItem::Event(event); } -bool GameInterface::mouseInactiveConditional(bool condition) -{ - return MOUSEINACTIVECONDITIONAL(condition); -} +#endif END_BLD_NS diff --git a/source/blood/src/gamemenu.h b/source/blood/src/gamemenu.h index f1cad59af..eeba0d837 100644 --- a/source/blood/src/gamemenu.h +++ b/source/blood/src/gamemenu.h @@ -31,6 +31,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS +class CMenuTextMgr +{ +public: + int at0; + CMenuTextMgr(); + void DrawText(const char *pString, int nFont, int x, int y, int nShade, int nPalette, bool shadow ); + void GetFontInfo(int nFont, const char *pString, int *pXSize, int *pYSize); +}; + +extern CMenuTextMgr gMenuTextMgr; + +void drawLoadingScreen(void); +void UpdateNetworkMenus(void); + + +#if 0 + #define M_MOUSETIMEOUT 210 #define kMaxGameMenuItems 128 @@ -85,15 +102,6 @@ struct CGameMenuEvent { #undef DrawText #endif -class CMenuTextMgr -{ -public: - int at0; - CMenuTextMgr(); - void DrawText(const char *pString, int nFont, int x, int y, int nShade, int nPalette, bool shadow ); - void GetFontInfo(int nFont, const char *pString, int *pXSize, int *pYSize); -}; - class CGameMenu; class CGameMenuItem { @@ -488,7 +496,7 @@ public: bool MouseOutsideBounds(vec2_t const * const pos, const int32_t x, const int32_t y, const int32_t width, const int32_t height); }; -extern CMenuTextMgr gMenuTextMgr; extern CGameMenuMgr gGameMenuMgr; +#endif END_BLD_NS diff --git a/source/blood/src/loadsave.cpp b/source/blood/src/loadsave.cpp index 1e9c231a3..01e7ef102 100644 --- a/source/blood/src/loadsave.cpp +++ b/source/blood/src/loadsave.cpp @@ -463,7 +463,6 @@ void LoadSavedInfo(void) } if ((uint32_t)hFile.Read(&gSaveGameOptions[nCount], sizeof(gSaveGameOptions[0])) != sizeof(gSaveGameOptions[0])) ThrowError("Error reading save file."); - strcpy(strRestoreGameStrings[gSaveGameOptions[nCount].nSaveGameSlot], gSaveGameOptions[nCount].szUserGameName); nCount++; } FinishSavegameRead(); @@ -471,7 +470,6 @@ void LoadSavedInfo(void) void UpdateSavedInfo(int nSlot) { - strcpy(strRestoreGameStrings[gSaveGameOptions[nSlot].nSaveGameSlot], gSaveGameOptions[nSlot].szUserGameName); } static MyLoadSave *myLoadSave; diff --git a/source/blood/src/menu.cpp b/source/blood/src/menu.cpp index 7cf24fd38..e105d86fc 100644 --- a/source/blood/src/menu.cpp +++ b/source/blood/src/menu.cpp @@ -49,6 +49,8 @@ EXTERN_CVAR(Bool, hud_powerupduration) BEGIN_BLD_NS +#if 0 + void SaveGame(CGameMenuItemZEditBitmap *, CGameMenuEvent *); void SaveGameProcess(CGameMenuItemChain *); @@ -105,13 +107,6 @@ char strRestoreGameStrings[][16] = "", }; -const char *zNetGameTypes[] = -{ - "Cooperative", - "Bloodbath", - "Teams", -}; - const char *zMonsterStrings[] = { "None", @@ -1354,30 +1349,6 @@ void SetupMenus(void) SetupNetworkMenu(); } -void UpdateNetworkMenus(void) -{ - if (gGameOptions.nGameType > 0) - { - itemMain1.at24 = &menuNetStart; - itemMain1.at28 = 2; - } - else - { - itemMain1.at24 = &menuEpisode; - itemMain1.at28 = -1; - } - if (gGameOptions.nGameType > 0) - { - itemMainSave1.at24 = &menuNetStart; - itemMainSave1.at28 = 2; - } - else - { - itemMainSave1.at24 = &menuEpisode; - itemMainSave1.at28 = -1; - } -} - void SetDoppler(CGameMenuItemZBool *pItem) { snd_doppler = pItem->at20; @@ -2183,45 +2154,6 @@ void SetParentalLock(CGameMenuItemZBool *pItem) // NUKE-TODO: CONFIG_WriteAdultMode(); } -void MenuSetupEpisodeInfo(void) -{ - memset(zEpisodeNames, 0, sizeof(zEpisodeNames)); - memset(zLevelNames, 0, sizeof(zLevelNames)); - for (int i = 0; i < 6; i++) - { - if (i < gEpisodeCount) - { - EPISODEINFO *pEpisode = &gEpisodeInfo[i]; - zEpisodeNames[i] = pEpisode->at0; - for (int j = 0; j < 16; j++) - { - if (j < pEpisode->nLevels) - { - zLevelNames[i][j] = pEpisode->at28[j].at90; - } - } - } - } -} - -void drawLoadingScreen(void) -{ - char buffer[80]; - if (gGameOptions.nGameType == 0) - { - if (gDemo.at1) - sprintf(buffer, "Loading Demo"); - else - sprintf(buffer, "Loading Level"); - } - else - sprintf(buffer, "%s", zNetGameTypes[gGameOptions.nGameType-1]); - viewLoadingScreen(2049, buffer, levelGetTitle(), NULL); -} - -FSavegameInfo GameInterface::GetSaveSig() -{ - return { SAVESIG_BLD, MINSAVEVER_BLD, SAVEVER_BLD }; -} +#endif END_BLD_NS diff --git a/source/blood/src/menu.h b/source/blood/src/menu.h index 3654f9d7a..cdc90f0af 100644 --- a/source/blood/src/menu.h +++ b/source/blood/src/menu.h @@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS +#if 0 + extern CGameMenu menuMain; extern CGameMenu menuMainWithSave; extern CGameMenu menuNetMain; @@ -54,6 +56,7 @@ extern CGameMenu menuOptionsDisplayMode; extern char strRestoreGameStrings[][16]; void drawLoadingScreen(void); void SetupMenus(void); -void UpdateNetworkMenus(void); + +#endif END_BLD_NS diff --git a/source/blood/src/menus.h b/source/blood/src/menus.h deleted file mode 100644 index 104366533..000000000 --- a/source/blood/src/menus.h +++ /dev/null @@ -1,535 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2016 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - -#ifndef menus_h_ -#define menus_h_ - -#include "compat.h" -#include "cache1d.h" -#include "pragmas.h" -#include "common.h" -#include "blood.h" - -BEGIN_BLD_NS - -#if defined EDUKE32_TOUCH_DEVICES -# define EDUKE32_SIMPLE_MENU -# define EDUKE32_ANDROID_MENU -#endif - -// #define EDUKE32_SIMPLE_MENU - -enum MenuIndex_t { - MENU_NULL = INT32_MIN, // sentinel for "do nothing" - MENU_CLOSE = -2, // sentinel for "close the menu"/"no menu" - MENU_PREVIOUS = -1, // sentinel for "go to previous menu" - MENU_MAIN = 0, - MENU_MAIN_INGAME = 50, - MENU_EPISODE = 100, - MENU_USERMAP = 101, - MENU_NEWGAMECUSTOM = 102, - MENU_NEWGAMECUSTOMSUB = 103, - MENU_SKILL = 110, - MENU_GAMESETUP = 200, - MENU_OPTIONS = 202, - MENU_VIDEOSETUP = 203, - MENU_KEYBOARDSETUP = 204, - MENU_MOUSESETUP = 205, - MENU_JOYSTICKSETUP = 206, - MENU_JOYSTICKBTNS = 207, - MENU_JOYSTICKAXES = 208, - MENU_KEYBOARDKEYS = 209, - MENU_MOUSEBTNS = 210, - MENU_MOUSEADVANCED = 212, - MENU_JOYSTICKAXIS = 213, - MENU_TOUCHSETUP = 214, - MENU_TOUCHSENS = 215, - MENU_TOUCHBUTTONS = 216, - MENU_CONTROLS = 220, - MENU_POLYMOST = 230, - MENU_COLCORR = 231, - MENU_COLCORR_INGAME = 232, - MENU_SCREENSETUP = 233, - MENU_DISPLAYSETUP = 234, - MENU_POLYMER = 240, - MENU_LOAD = 300, - MENU_SAVE = 350, - MENU_STORY = 400, - MENU_F1HELP = 401, - MENU_QUIT = 500, - MENU_QUITTOTITLE = 501, - MENU_QUIT_INGAME = 502, - MENU_NETSETUP = 600, - MENU_NETWAITMASTER = 601, - MENU_NETWAITVOTES = 603, - MENU_SOUND = 700, - MENU_SOUND_INGAME = 701, - MENU_ADVSOUND = 702, - MENU_SAVESETUP = 750, - MENU_SAVECLEANVERIFY = 751, - MENU_RESETSTATSVERIFY = 752, - MENU_CHEATS = 800, - MENU_CHEATENTRY = 801, - MENU_CHEAT_WARP = 802, - MENU_CHEAT_SKILL = 803, - MENU_CREDITS = 990, - MENU_CREDITS2 = 991, - MENU_CREDITS3 = 992, - MENU_CREDITS4 = 993, - MENU_CREDITS5 = 994, - MENU_LOADVERIFY = 1000, - MENU_LOADDELVERIFY = 1100, - MENU_NEWVERIFY = 1500, - MENU_SAVEVERIFY = 2000, - MENU_SAVEDELVERIFY = 2100, - MENU_COLCORRRESETVERIFY = 2200, - MENU_KEYSRESETVERIFY = 2201, - MENU_KEYSCLASSICVERIFY = 2202, - MENU_JOYSTANDARDVERIFY = 2203, - MENU_JOYPROVERIFY = 2204, - MENU_JOYCLEARVERIFY = 2205, - MENU_ADULTPASSWORD = 10001, - MENU_RESETPLAYER = 15000, - MENU_BUYDUKE = 20000, - MENU_NETWORK = 20001, - MENU_PLAYER = 20002, - MENU_MACROS = 20004, - MENU_NETHOST = 20010, - MENU_NETOPTIONS = 20011, - MENU_NETUSERMAP = 20012, - MENU_NETJOIN = 20020, -}; - - - -typedef int32_t MenuID_t; - - -typedef enum MenuAnimationType_t -{ // Note: This enum is for logical categories, not visual types. - MA_None, - MA_Return, - MA_Advance, -} MenuAnimationType_t; - -// a subset of screentext parameters, restricted because menus require accessibility -typedef struct MenuFont_t -{ -// int32_t xspace, yline; - vec2_t emptychar, between; - int32_t zoom; - int32_t cursorLeftPosition, cursorCenterPosition, cursorScale; - int32_t textflags; - int16_t tilenum; - // selected shade glows, deselected shade is used by Blood, disabled shade is used by SW - int8_t shade_deselected, shade_disabled; - uint8_t pal; - uint8_t pal_selected, pal_deselected, pal_disabled; - uint8_t pal_selected_right, pal_deselected_right, pal_disabled_right; - - int32_t get_yline() const { return mulscale16(emptychar.y, zoom); } -} MenuFont_t; - - - -typedef enum MenuEntryType_t -{ - Dummy, - Link, - Option, - Custom2Col, - RangeInt32, - RangeFloat, -#ifdef MENU_ENABLE_RANGEDOUBLE - RangeDouble, -#endif - String, - Spacer, -} MenuEntryType_t; - -typedef struct MenuEntryFormat_t -{ - int32_t marginBottom; - int32_t indent; - int32_t width; // 0: center, >0: width of the label column (left-aligned options), <0: -width of everything (right-aligned) -} MenuEntryFormat_t; - - -typedef struct MenuMenuFormat_t -{ - vec2_t pos; - int32_t bottomcutoff; // >0: the bottom edge of the menu before automatic scrolling kicks in, <0: -total height for vertical justification -} MenuMenuFormat_t; - -typedef struct MenuLink_t -{ - // traits - MenuID_t linkID; - MenuAnimationType_t animation; -} MenuLink_t; -typedef struct MenuOptionSet_t -{ - // traits - char const **optionNames; - int32_t *optionValues; // If NULL, the identity of currentOption is assumed. - - // pop-up list appearance - MenuMenuFormat_t *menuFormat; - MenuEntryFormat_t *entryFormat; - MenuFont_t *font; - - // traits - int32_t numOptions; - - // pop-up list state - int32_t currentEntry; - int32_t scrollPos; - - // appearance - uint8_t features; // bit 1 = disable left/right arrows, bit 2 = disable list - - int32_t getMarginBottom() const { return mulscale16(entryFormat->marginBottom, font->zoom); } - int32_t getIndent() const { return mulscale16(entryFormat->indent, font->zoom); } -} MenuOptionSet_t; -typedef struct MenuOption_t -{ - // appearance - MenuFont_t *font; - - // traits - MenuOptionSet_t *options; // so that common sets such as Yes/No, On/Off can be reused - - // effect - int32_t *data; - - // state - int32_t currentOption; -} MenuOption_t; -typedef struct MenuCustom2Col_t -{ - // effect - uint8_t *column[2]; - char const **key; - - // appearance - MenuFont_t *font; - - // effect - size_t numvalid; - - // appearance - int32_t columnWidth; - - // state - int8_t screenOpen; -} MenuCustom2Col_t; - -enum MenuRangeFlags_t -{ - DisplayTypeInteger = 1, - DisplayTypePercent = 2, - DisplayTypeNormalizedDecimal = 3, - DisplayTypeMask = (1<<0)|(1<<1), - - EnforceIntervals = 1<<7, -}; -typedef struct MenuRangeInt32_t -{ - // effect - int32_t *variable; - - // appearance - MenuFont_t *font; - - // traits - int32_t min; - int32_t max; - int32_t onehundredpercent; // 0 implies max - int32_t steps; - - uint8_t flags; -} MenuRangeInt32_t; -typedef struct MenuRangeFloat_t -{ - // effect - float *variable; - - // appearance - MenuFont_t *font; - - // traits - float min; - float max; - float onehundredpercent; // 0 implies 1.0 - int32_t steps; - - uint8_t flags; -} MenuRangeFloat_t; -#ifdef MENU_ENABLE_RANGEDOUBLE -typedef struct MenuRangeDouble_t -{ - // effect - double *variable; - - // appearance - MenuFont_t *font; - - // traits - double min; - double max; - double onehundredpercent; // 0 implies 1.0 - int32_t steps; - - uint8_t flags; -} MenuRangeDouble_t; -#endif -typedef struct MenuString_t -{ - // state - char* editfield; - - // effect - char* variable; - - // appearance - MenuFont_t *font; - - // effect - int32_t bufsize; - int32_t flags; -} MenuString_t; -typedef struct MenuSpacer_t -{ - int32_t height; -} MenuSpacer_t; - -// For internal use only. -enum MenuEntryFlags_t -{ - MEF_Disabled = 1<<0, - MEF_LookDisabled = 1<<1, - MEF_Hidden = 1<<2, -}; - -typedef struct MenuEntry_t -{ - // traits - const char *name; - - // appearance - MenuFont_t *font; - MenuEntryFormat_t *format; - - void *entry; - MenuEntryType_t type; - - // state - int32_t flags; - int32_t ytop, ybottom; - - int32_t getMarginBottom() const { return mulscale16(format->marginBottom, font->zoom); } - int32_t getIndent() const { return mulscale16(format->indent, font->zoom); } - int32_t getHeight() const - { - return type == Spacer ? mulscale16(((MenuSpacer_t *)entry)->height, font->zoom) : font->get_yline(); - } -} MenuEntry_t; - - -typedef enum MenuType_t -{ - Menu, - Panel, - Verify, - Message, - TextForm, - FileSelect, -} MenuType_t; - -typedef struct MenuMenu_t -{ - const char *title; - - MenuMenuFormat_t *format; - - MenuEntry_t **entrylist; - int32_t numEntries; - - // state - int32_t currentEntry, currentColumn; - int32_t scrollPos; -} MenuMenu_t; -typedef struct MenuPanel_t -{ - const char *title; - - MenuID_t previousID; - MenuAnimationType_t previousAnimation; - MenuID_t nextID; - MenuAnimationType_t nextAnimation; -} MenuPanel_t; -typedef struct MenuVerify_t -{ - vec2_t cursorpos; - - MenuID_t linkID; - MenuAnimationType_t animation; -} MenuVerify_t; -typedef struct MenuMessage_t -{ - vec2_t cursorpos; - - MenuID_t linkID; - MenuAnimationType_t animation; -} MenuMessage_t; -enum MenuTextFormFlags_t -{ - MTF_Password = 1<<0, -}; -typedef struct MenuTextForm_t -{ - // state - char *input; - - // traits - const char *instructions; - int32_t bufsize; - uint8_t flags; -} MenuTextForm_t; -typedef struct MenuFileSelect_t -{ - const char *title; - - // appearance - MenuMenuFormat_t *format[2]; - MenuFont_t *font[2]; - - // traits - const char * startdir; - const char *pattern; - char *destination; - - // state - //CACHE1D_FIND_REC *findhigh[2]; - int32_t scrollPos[2]; - - // appearance - int32_t marginBottom[2]; - - // state - //fnlist_t fnlist; - int32_t currentList; - - int32_t getMarginBottom(size_t index) const { return mulscale16(marginBottom[index], font[index]->zoom); } -} MenuFileSelect_t; - -typedef struct Menu_t -{ - void *object; - MenuID_t menuID; - MenuID_t parentID; - MenuAnimationType_t parentAnimation; - MenuType_t type; -} Menu_t; - -typedef struct MenuAnimation_t -{ - int32_t(*out)(struct MenuAnimation_t *); - int32_t(*in)(struct MenuAnimation_t *); - - Menu_t *previous; - Menu_t *current; - - int32_t start; - int32_t length; -} MenuAnimation_t; - -extern MenuAnimation_t m_animation; - -extern MenuID_t g_currentMenu; -extern Menu_t *m_currentMenu; - -extern int32_t g_quitDeadline; -extern int32_t voting; -int Menu_Change(MenuID_t cm); -void Menu_AnimateChange(int32_t cm, MenuAnimationType_t animtype); -int32_t Menu_IsTextInput(Menu_t *cm); -int G_CheckPlayerColor(int color); -void Menu_Init(void); -void M_DisplayMenus(void); - -extern MenuFont_t MF_Redfont, MF_Bluefont, MF_Minifont; - -#define M_MOUSETIMEOUT 210 -extern int32_t m_mouselastactivity; - -#if defined EDUKE32_TOUCH_DEVICES -# define MOUSEALPHA 0 -# define CURSORALPHA (255/3) -# define MOUSEACTIVECONDITIONAL(condition) (condition) -# define MOUSEWATCHPOINTCONDITIONAL(condition) (condition) -#else -extern int32_t m_mousewake_watchpoint, m_menuchange_watchpoint; -// alpha increments of 3 --> 255 / 3 = 85 --> round up to power of 2 --> 128 --> divide by 2 --> 64 alphatabs required -// use 16 anyway :P -#if 0 -# define MOUSEUSEALPHA (videoGetRenderMode() != REND_CLASSIC || numalphatabs >= 15) -# define MOUSEALPHA (MOUSEUSEALPHA ? clamp(((int32_t) totalclock - m_mouselastactivity - 90)*3, 0, 255) : 0) -# define CURSORALPHA (MOUSEUSEALPHA ? clamp(((int32_t) totalclock - m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3) -# define MOUSEACTIVECONDITION (totalclock - m_mouselastactivity < M_MOUSETIMEOUT) -# define MOUSEACTIVECONDITIONAL(condition) (MOUSEACTIVECONDITION && (condition)) -# define MOUSEINACTIVECONDITIONAL(condition) ((gInputMode != kInputMenu || !MOUSEACTIVECONDITION) && (condition)) -# define MOUSEWATCHPOINTCONDITIONAL(condition) ((condition) || m_mousewake_watchpoint || m_menuchange_watchpoint == 3) -#endif -#endif - -#define MAXMENUGAMEPLAYENTRIES 7 - -enum MenuGameplayEntryFlags -{ - MGE_Locked = 1u<<0u, - MGE_Hidden = 1u<<1u, - MGE_UserContent = 1u<<2u, -}; - -typedef struct MenuGameplayEntry -{ - char name[64]; - uint8_t flags; - - bool isValid() const { return name[0] != '\0'; } -} MenuGameplayEntry; - -typedef struct MenuGameplayStemEntry -{ - MenuGameplayEntry entry; - MenuGameplayEntry subentries[MAXMENUGAMEPLAYENTRIES]; -} MenuGameplayStemEntry; - -extern MenuGameplayStemEntry g_MenuGameplayEntries[MAXMENUGAMEPLAYENTRIES]; - -extern MenuEntry_t ME_NEWGAMECUSTOMENTRIES[MAXMENUGAMEPLAYENTRIES]; -extern MenuEntry_t ME_NEWGAMECUSTOMSUBENTRIES[MAXMENUGAMEPLAYENTRIES][MAXMENUGAMEPLAYENTRIES]; - -END_BLD_NS - -#endif diff --git a/source/blood/src/messages.cpp b/source/blood/src/messages.cpp index f69cb5c96..ef2f8c5a0 100644 --- a/source/blood/src/messages.cpp +++ b/source/blood/src/messages.cpp @@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "globals.h" #include "levels.h" #include "loadsave.h" -#include "menu.h" +#include "gamemenu.h" #include "messages.h" #include "network.h" #include "player.h" diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp index 5998ad2ab..e5f253d0c 100644 --- a/source/blood/src/osdcmd.cpp +++ b/source/blood/src/osdcmd.cpp @@ -83,13 +83,11 @@ static int osdcmd_changelevel(osdcmdptr_t parm) gPacketStartGame.levelId = level; netBroadcastNewGame(); gStartNewGame = 1; - gGameMenuMgr.Deactivate(); return OSDCMD_OK; } levelSetupOptions(volume, level); StartLevel(&gGameOptions); viewResizeView(gViewSize); - gGameMenuMgr.Deactivate(); return OSDCMD_OK; } @@ -118,13 +116,11 @@ static int osdcmd_map(osdcmdptr_t parm) gPacketStartGame.levelId = gGameOptions.nLevel; netBroadcastNewGame(); gStartNewGame = 1; - gGameMenuMgr.Deactivate(); return OSDCMD_OK; } levelSetupOptions(gGameOptions.nEpisode, gGameOptions.nLevel); StartLevel(&gGameOptions); viewResizeView(gViewSize); - gGameMenuMgr.Deactivate(); return OSDCMD_OK; } diff --git a/source/blood/src/screentext.cpp b/source/blood/src/screentext.cpp index 8267aea4d..57a9cbd08 100644 --- a/source/blood/src/screentext.cpp +++ b/source/blood/src/screentext.cpp @@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "blood.h" #include "common_game.h" #include "screentext.h" -#include "menus.h" BEGIN_BLD_NS diff --git a/source/blood/src/screentext.h b/source/blood/src/screentext.h index 6824a3eb8..693b64976 100644 --- a/source/blood/src/screentext.h +++ b/source/blood/src/screentext.h @@ -22,8 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #pragma once -#include "menus.h" - BEGIN_BLD_NS #define USERQUOTE_LEFTOFFSET 5 diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index ef6829df5..ff61a06e5 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -47,7 +47,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "loadsave.h" #include "map2d.h" #include "messages.h" -#include "menu.h" +#include "gamemenu.h" #include "mirrors.h" #include "network.h" #include "player.h" @@ -61,6 +61,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "warp.h" #include "weapon.h" #include "zstring.h" +#include "menu/menu.h" CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable displaying the remaining seconds for power-ups") @@ -1270,7 +1271,7 @@ void viewDrawPowerUps(PLAYER* pPlayer) void viewDrawMapTitle(void) { - if (!hud_showmapname || gGameMenuMgr.m_bActive) + if (!hud_showmapname || M_Active()) return; int const fadeStartTic = int((videoGetRenderMode() == REND_CLASSIC ? 1.25f : 1.f)*kTicsPerSec); @@ -3056,7 +3057,7 @@ void viewDrawScreen(void) if (delta < 0) delta = 0; lastUpdate = totalclock; - if (!gPaused && (!CGameMenuMgr::m_bActive || gGameOptions.nGameType != 0)) + if (!gPaused && (!M_Active() || gGameOptions.nGameType != 0)) { gInterpolate = ((totalclock-gNetFifoClock)+4).toScale16()/4; } diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index eae10b9ad..ae6fe06ea 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -747,7 +747,7 @@ bool M_Responder (event_t *ev) if (ev->type == EV_KeyDown) { // Pop-up menu? - if (ev->data1 == KEY_ESCAPE) + if (ev->data1 == KEY_ESCAPE) // Should we let the games handle Escape for special actions, like backing out of cameras? { M_StartControlPanel(true); M_SetMenu(NAME_IngameMenu, -1); @@ -870,6 +870,12 @@ void Menu_Close(int playerid) { M_ClearMenus(); } + +bool M_Active() +{ + return DMenu::CurrentMenu != nullptr; +} + //============================================================================= // // diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index 8727f2767..6cf842a1c 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -744,6 +744,7 @@ void M_StartMessage(const char *message, int messagemode, int scriptId, FName ac void M_UnhideCustomMenu(int menu, int itemmask); void M_MenuSound(EMenuSounds snd); void M_Autosave(); +bool M_Active(); void I_SetMouseCapture(); diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 32c676db4..a21436a1f 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -984,7 +984,7 @@ void G_DisplayRest(int32_t smoothratio) G_PrintGameQuotes(screenpeek); - if (ud.show_level_text && hud_showmapname && g_levelTextTime > 1 && DMenu::CurrentMenu == nullptr) + if (ud.show_level_text && hud_showmapname && g_levelTextTime > 1 && !M_Active()) { int32_t o = 10|16; diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index e4cbafa46..adc23ea27 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -1015,7 +1015,7 @@ void G_DisplayRest(int32_t smoothratio) G_PrintGameQuotes(screenpeek); - if (ud.show_level_text && hud_showmapname && g_levelTextTime > 1 && DMenu::CurrentMenu == nullptr) + if (ud.show_level_text && hud_showmapname && g_levelTextTime > 1 && !M_Active()) { int32_t o = 10|16;