diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 028b5bd3b..5c28f87bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -955,14 +955,9 @@ set (PCH_SOURCES maploader/compatibility.cpp maploader/postprocessor.cpp menu/doommenu.cpp - menu/joystickmenu.cpp menu/loadsavemenu.cpp - menu/menu.cpp menu/menudef.cpp - menu/messagebox.cpp - menu/optionmenu.cpp menu/playermenu.cpp - menu/resolutionmenu.cpp gamedata/textures/animations.cpp gamedata/textures/anim_switches.cpp gamedata/textures/buildloader.cpp @@ -1120,6 +1115,12 @@ set (PCH_SOURCES common/objects/dobject.cpp common/objects/dobjgc.cpp common/objects/dobjtype.cpp + common/menu/joystickmenu.cpp + common/menu/menu.cpp + common/menu/messagebox.cpp + common/menu/optionmenu.cpp + common/menu/resolutionmenu.cpp + common/rendering/v_framebuffer.cpp common/rendering/v_video.cpp common/rendering/r_thread.cpp diff --git a/src/menu/joystickmenu.cpp b/src/common/menu/joystickmenu.cpp similarity index 99% rename from src/menu/joystickmenu.cpp rename to src/common/menu/joystickmenu.cpp index 388c012df..4baea836f 100644 --- a/src/menu/joystickmenu.cpp +++ b/src/common/menu/joystickmenu.cpp @@ -32,7 +32,7 @@ ** */ -#include "menu/menu.h" +#include "menu.h" #include "m_joy.h" #include "vm.h" diff --git a/src/menu/menu.cpp b/src/common/menu/menu.cpp similarity index 99% rename from src/menu/menu.cpp rename to src/common/menu/menu.cpp index 0ab3efa36..9f2cdf168 100644 --- a/src/menu/menu.cpp +++ b/src/common/menu/menu.cpp @@ -51,6 +51,9 @@ #include "vm.h" #include "gamestate.h" #include "i_interface.h" +#include "menustate.h" +#include "i_time.h" +#include "printf.h" void M_StartControlPanel(bool makeSound, bool scaleoverride = false); @@ -101,7 +104,7 @@ extern PClass *DefaultListMenuClass; extern PClass *DefaultOptionMenuClass; -#define KEY_REPEAT_DELAY (TICRATE*5/12) +#define KEY_REPEAT_DELAY (GameTicRate*5/12) #define KEY_REPEAT_RATE (3) bool OkForLocalization(FTextureID texnum, const char* substitute); @@ -394,11 +397,6 @@ void M_SetMenu(FName menu, int param) DMenuDescriptor **desc = MenuDescriptors.CheckKey(menu); if (desc != nullptr) { - if ((*desc)->mNetgameMessage.IsNotEmpty() && netgame && !demoplayback) - { - M_StartMessage((*desc)->mNetgameMessage, 1); - return; - } if ((*desc)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor))) { @@ -711,8 +709,6 @@ void M_Ticker (void) void M_Drawer (void) { - player_t *player = &players[consoleplayer]; - AActor *camera = player->camera; PalEntry fade = 0; if (CurrentMenu != nullptr && menuactive != MENU_Off) diff --git a/src/menu/menu.h b/src/common/menu/menu.h similarity index 82% rename from src/menu/menu.h rename to src/common/menu/menu.h index a2b6a91f7..3e8ecf1e8 100644 --- a/src/menu/menu.h +++ b/src/common/menu/menu.h @@ -5,7 +5,6 @@ #include "dobject.h" -#include "d_player.h" #include "c_cvars.h" #include "v_font.h" #include "textures.h" @@ -18,7 +17,6 @@ struct event_t; class FTexture; class FFont; enum EColorRange : int; -class FPlayerClass; class FKeyBindings; struct FBrokenLines; @@ -45,64 +43,6 @@ enum EMenuKey }; -struct FNewGameStartup -{ - const char *PlayerClass; - int Episode; - int Skill; -}; - -extern FNewGameStartup NewGameStartupInfo; - -struct FSaveGameNode -{ - FString SaveTitle; - FString Filename; - bool bOldVersion = false; - bool bMissingWads = false; - bool bNoDelete = false; -}; - -struct FSavegameManager -{ -private: - TArray SaveGames; - FSaveGameNode NewSaveNode; - int LastSaved = -1; - int LastAccessed = -1; - FGameTexture *SavePic = nullptr; - -public: - int WindowSize = 0; - FString SaveCommentString; - FSaveGameNode *quickSaveSlot = nullptr; - ~FSavegameManager(); - -private: - int InsertSaveNode(FSaveGameNode *node); -public: - void NotifyNewSave(const FString &file, const FString &title, bool okForQuicksave, bool forceQuicksave); - void ClearSaveGames(); - - void ReadSaveStrings(); - void UnloadSaveData(); - - int RemoveSaveSlot(int index); - void LoadSavegame(int Selected); - void DoSave(int Selected, const char *savegamestring); - unsigned ExtractSaveData(int index); - void ClearSaveStuff(); - bool DrawSavePic(int x, int y, int w, int h); - void DrawSaveComment(FFont *font, int cr, int x, int y, int scalefactor); - void SetFileInfo(int Selected); - unsigned SavegameCount(); - FSaveGameNode *GetSavegame(int i); - void InsertNewSaveNode(); - bool RemoveNewSaveNode(); - -}; - -extern FSavegameManager savegameManager; class DMenu; extern DMenu *CurrentMenu; extern int MenuTime; @@ -343,8 +283,6 @@ void M_ActivateMenu(DMenu *menu); void M_ClearMenus (); void M_PreviousMenu (); void M_ParseMenuDefs(); -void M_StartupEpisodeMenu(FNewGameStartup *gs); -void M_StartupSkillMenu(FNewGameStartup *gs); void M_DoStartControlPanel(bool scaleoverride); void M_SetMenu(FName menu, int param = -1); void M_StartMessage(const char *message, int messagemode, FName action = NAME_None); diff --git a/src/menu/messagebox.cpp b/src/common/menu/messagebox.cpp similarity index 99% rename from src/menu/messagebox.cpp rename to src/common/menu/messagebox.cpp index a38e8dbdc..8b43d8d76 100644 --- a/src/menu/messagebox.cpp +++ b/src/common/menu/messagebox.cpp @@ -38,6 +38,7 @@ #include "i_video.h" #include "c_dispatch.h" #include "vm.h" +#include "menustate.h" void M_StartControlPanel(bool makeSound, bool scaleoverride = false); FName MessageBoxClass = NAME_MessageBoxMenu; diff --git a/src/menu/optionmenu.cpp b/src/common/menu/optionmenu.cpp similarity index 99% rename from src/menu/optionmenu.cpp rename to src/common/menu/optionmenu.cpp index 0635ee580..99069d176 100644 --- a/src/menu/optionmenu.cpp +++ b/src/common/menu/optionmenu.cpp @@ -33,7 +33,7 @@ */ #include "v_video.h" -#include "menu/menu.h" +#include "menu.h" #include "vm.h" diff --git a/src/menu/resolutionmenu.cpp b/src/common/menu/resolutionmenu.cpp similarity index 98% rename from src/menu/resolutionmenu.cpp rename to src/common/menu/resolutionmenu.cpp index 2f5d8d983..216e6b85f 100644 --- a/src/menu/resolutionmenu.cpp +++ b/src/common/menu/resolutionmenu.cpp @@ -37,7 +37,8 @@ #include "c_dispatch.h" #include "c_cvars.h" #include "v_video.h" -#include "menu/menu.h" +#include "menu.h" +#include "printf.h" CVAR(Int, menu_resolution_custom_width, 640, 0) CVAR(Int, menu_resolution_custom_height, 480, 0) diff --git a/src/common/platform/win32/i_mouse.cpp b/src/common/platform/win32/i_mouse.cpp index 329da45d7..ddcdc7816 100644 --- a/src/common/platform/win32/i_mouse.cpp +++ b/src/common/platform/win32/i_mouse.cpp @@ -42,7 +42,9 @@ #include "d_eventbase.h" #include "d_gui.h" #include "hardware.h" -#include "menu/menu.h" +#include "menu.h" +#include "menustate.h" +#include "keydef.h" #include "i_interface.h" // MACROS ------------------------------------------------------------------ diff --git a/src/gamedata/keysections.cpp b/src/gamedata/keysections.cpp index 464941d2e..61e7c1e62 100644 --- a/src/gamedata/keysections.cpp +++ b/src/gamedata/keysections.cpp @@ -34,12 +34,15 @@ */ -#include "menu/menu.h" +#include "menu.h" #include "gi.h" #include "c_bind.h" #include "c_dispatch.h" #include "gameconfigfile.h" #include "filesystem.h" +#include "gi.h" +#include "d_player.h" +#include "c_dispatch.h" TArray KeySections; extern TArray KeyConfWeapons; diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index 86c0ff512..d987bb89e 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -62,6 +62,7 @@ #include "doommenu.h" #include "r_utility.h" #include "gameconfigfile.h" +#include "d_player.h" EXTERN_CVAR(Int, cl_gfxlocalization) EXTERN_CVAR(Bool, m_quickexit) @@ -191,6 +192,17 @@ bool M_SetSpecialMenu(FName menu, int param) break; } + DMenuDescriptor** desc = MenuDescriptors.CheckKey(menu); + if (desc != nullptr) + { + if ((*desc)->mNetgameMessage.IsNotEmpty() && netgame && !demoplayback) + { + M_StartMessage((*desc)->mNetgameMessage, 1); + return false; + } + } + + // End of special checks return true; } diff --git a/src/menu/doommenu.h b/src/menu/doommenu.h index 3d6d45254..1b566480d 100644 --- a/src/menu/doommenu.h +++ b/src/menu/doommenu.h @@ -2,3 +2,66 @@ #include "menu.h" void M_StartControlPanel (bool makeSound, bool scaleoverride = false); + + +struct FNewGameStartup +{ + const char *PlayerClass; + int Episode; + int Skill; +}; + +extern FNewGameStartup NewGameStartupInfo; +void M_StartupEpisodeMenu(FNewGameStartup *gs); +void M_StartupSkillMenu(FNewGameStartup *gs); + +// The savegame manager contains too much code that is game specific. Parts are shareable but need more work first. +struct FSaveGameNode +{ + FString SaveTitle; + FString Filename; + bool bOldVersion = false; + bool bMissingWads = false; + bool bNoDelete = false; +}; + +struct FSavegameManager +{ +private: + TArray SaveGames; + FSaveGameNode NewSaveNode; + int LastSaved = -1; + int LastAccessed = -1; + FGameTexture *SavePic = nullptr; + +public: + int WindowSize = 0; + FString SaveCommentString; + FSaveGameNode *quickSaveSlot = nullptr; + ~FSavegameManager(); + +private: + int InsertSaveNode(FSaveGameNode *node); +public: + void NotifyNewSave(const FString &file, const FString &title, bool okForQuicksave, bool forceQuicksave); + void ClearSaveGames(); + + void ReadSaveStrings(); + void UnloadSaveData(); + + int RemoveSaveSlot(int index); + void LoadSavegame(int Selected); + void DoSave(int Selected, const char *savegamestring); + unsigned ExtractSaveData(int index); + void ClearSaveStuff(); + bool DrawSavePic(int x, int y, int w, int h); + void DrawSaveComment(FFont *font, int cr, int x, int y, int scalefactor); + void SetFileInfo(int Selected); + unsigned SavegameCount(); + FSaveGameNode *GetSavegame(int i); + void InsertNewSaveNode(); + bool RemoveNewSaveNode(); + +}; + +extern FSavegameManager savegameManager; diff --git a/src/menu/playermenu.cpp b/src/menu/playermenu.cpp index 84ed9fc1a..6c930147c 100644 --- a/src/menu/playermenu.cpp +++ b/src/menu/playermenu.cpp @@ -1,6 +1,6 @@ /* ** playermenu.cpp -** The player setup menu +** The player setup menu's setters. These are native for security purposes. ** **--------------------------------------------------------------------------- ** Copyright 2001-2010 Randy Heit @@ -33,12 +33,13 @@ ** */ -#include "menu/menu.h" +#include "menu.h" #include "gi.h" #include "c_dispatch.h" #include "teaminfo.h" #include "r_state.h" #include "vm.h" +#include "d_player.h" EXTERN_CVAR(Int, team) EXTERN_CVAR(Float, autoaim)