- moved most of the menu code into the backend.

This commit is contained in:
Christoph Oelckers 2020-10-04 22:12:56 +02:00
parent f6240ef428
commit 4b77064fc4
11 changed files with 192 additions and 177 deletions

View file

@ -952,15 +952,9 @@ set (PCH_SOURCES
maploader/renderinfo.cpp
maploader/compatibility.cpp
maploader/postprocessor.cpp
menu/joystickmenu.cpp
menu/menu.cpp
menu/messagebox.cpp
menu/optionmenu.cpp
menu/resolutionmenu.cpp
menu/doommenu.cpp
menu/loadsavemenu.cpp
menu/playermenu.cpp
menu/menudef.cpp
gamedata/textures/animations.cpp
gamedata/textures/anim_switches.cpp
gamedata/textures/buildloader.cpp
@ -1124,6 +1118,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/menu/menudef.cpp
common/rendering/v_framebuffer.cpp
common/rendering/v_video.cpp

View file

@ -839,134 +839,6 @@ void M_EnableMenu (bool on)
//
//=============================================================================
CCMD (menu_main)
{
M_StartControlPanel(true);
M_SetMenu(NAME_Mainmenu, -1);
}
CCMD (menu_load)
{ // F3
M_StartControlPanel (true);
M_SetMenu(NAME_Loadgamemenu, -1);
}
CCMD (menu_save)
{ // F2
M_StartControlPanel (true);
M_SetMenu(NAME_Savegamemenu, -1);
}
CCMD (menu_help)
{ // F1
M_StartControlPanel (true);
M_SetMenu(NAME_Readthismenu, -1);
}
CCMD (menu_game)
{
M_StartControlPanel (true);
M_SetMenu(NAME_Playerclassmenu, -1); // The playerclass menu is the first in the 'start game' chain
}
CCMD (menu_options)
{
M_StartControlPanel (true);
M_SetMenu(NAME_Optionsmenu, -1);
}
CCMD (menu_player)
{
M_StartControlPanel (true);
M_SetMenu(NAME_Playermenu, -1);
}
CCMD (menu_messages)
{
M_StartControlPanel (true);
M_SetMenu(NAME_MessageOptions, -1);
}
CCMD (menu_automap)
{
M_StartControlPanel (true);
M_SetMenu(NAME_AutomapOptions, -1);
}
CCMD (menu_scoreboard)
{
M_StartControlPanel (true);
M_SetMenu(NAME_ScoreboardOptions, -1);
}
CCMD (menu_mapcolors)
{
M_StartControlPanel (true);
M_SetMenu(NAME_MapColorMenu, -1);
}
CCMD (menu_keys)
{
M_StartControlPanel (true);
M_SetMenu(NAME_CustomizeControls, -1);
}
CCMD (menu_gameplay)
{
M_StartControlPanel (true);
M_SetMenu(NAME_GameplayOptions, -1);
}
CCMD (menu_compatibility)
{
M_StartControlPanel (true);
M_SetMenu(NAME_CompatibilityOptions, -1);
}
CCMD (menu_mouse)
{
M_StartControlPanel (true);
M_SetMenu(NAME_MouseOptions, -1);
}
CCMD (menu_joystick)
{
M_StartControlPanel (true);
M_SetMenu(NAME_JoystickOptions, -1);
}
CCMD (menu_sound)
{
M_StartControlPanel (true);
M_SetMenu(NAME_SoundOptions, -1);
}
CCMD (menu_advsound)
{
M_StartControlPanel (true);
M_SetMenu(NAME_AdvSoundOptions, -1);
}
CCMD (menu_modreplayer)
{
M_StartControlPanel(true);
M_SetMenu(NAME_ModReplayerOptions, -1);
}
CCMD (menu_display)
{
M_StartControlPanel (true);
M_SetMenu(NAME_VideoOptions, -1);
}
CCMD (menu_video)
{
M_StartControlPanel (true);
M_SetMenu(NAME_VideoModeMenu, -1);
}
CCMD (openmenu)
{
if (argv.argc() < 2)

View file

@ -49,11 +49,10 @@
#include <zmusic.h>
#include "texturemanager.h"
#include "printf.h"
#include "i_interface.h"
bool CheckGame(const char* string, bool chexisdoom);
bool CheckSkipGameOptionBlock(FScanner& sc);
void SetDefaultMenuColors();
MenuDescriptorList MenuDescriptors;
static DListMenuDescriptor *DefaultListMenuSettings; // contains common settings for all list menus
@ -175,13 +174,7 @@ FTextureID GetMenuTexture(const char* const name)
static void SkipSubBlock(FScanner &sc)
{
sc.MustGetStringName("{");
int depth = 1;
while (depth > 0)
{
sc.MustGetString();
if (sc.Compare("{")) depth++;
if (sc.Compare("}")) depth--;
}
sc.SkipToEndOfBlock();
}
//=============================================================================
@ -190,18 +183,18 @@ static void SkipSubBlock(FScanner &sc)
//
//=============================================================================
static bool CheckSkipGameBlock(FScanner &sc)
static bool CheckSkipGameBlock(FScanner &sc, bool yes = true)
{
bool filter = false;
sc.MustGetStringName("(");
do
{
sc.MustGetString();
filter |= CheckGame(sc.String, false);
if (sysCallbacks.CheckGame) filter |= sysCallbacks.CheckGame(sc.String);
}
while (sc.CheckString(","));
sc.MustGetStringName(")");
if (!filter)
if (filter != yes)
{
SkipSubBlock(sc);
return !sc.CheckString("else");
@ -288,6 +281,14 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
ParseListMenuBody(sc, desc);
}
}
else if (sc.Compare("ifnotgame"))
{
if (!CheckSkipGameBlock(sc, false))
{
// recursively parse sub-block
ParseListMenuBody(sc, desc);
}
}
else if (sc.Compare("ifoption"))
{
if (!CheckSkipOptionBlock(sc))
@ -779,6 +780,14 @@ static void ParseOptionSettings(FScanner &sc)
ParseOptionSettings(sc);
}
}
else if (sc.Compare("ifnotgame"))
{
if (!CheckSkipGameBlock(sc, false))
{
// recursively parse sub-block
ParseOptionSettings(sc);
}
}
else if (sc.Compare("Linespacing"))
{
sc.MustGetNumber();
@ -820,6 +829,14 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc)
ParseOptionMenuBody(sc, desc);
}
}
else if (sc.Compare("ifnotgame"))
{
if (!CheckSkipGameBlock(sc, false))
{
// recursively parse sub-block
ParseOptionMenuBody(sc, desc);
}
}
else if (sc.Compare("ifoption"))
{
if (!CheckSkipOptionBlock(sc))
@ -838,7 +855,7 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc)
}
desc->mClass = cls;
}
else if (sc.Compare("Title"))
else if (sc.Compare({ "Title", "Caption" }))
{
sc.MustGetString();
desc->mTitle = sc.String;
@ -1036,7 +1053,6 @@ void M_ParseMenuDefs()
{
int lump, lastlump = 0;
SetDefaultMenuColors();
// these are supposed to get GC'd after parsing is complete.
DefaultListMenuSettings = Create<DListMenuDescriptor>();
DefaultOptionMenuSettings = Create<DOptionMenuDescriptor>();
@ -1199,31 +1215,3 @@ void M_CreateMenus()
}
#ifdef _WIN32
EXTERN_CVAR(Bool, vr_enable_quadbuffered)
#endif
void UpdateVRModes(bool considerQuadBuffered)
{
FOptionValues ** pVRModes = OptionValues.CheckKey("VRMode");
if (pVRModes == nullptr) return;
TArray<FOptionValues::Pair> & vals = (*pVRModes)->mValues;
TArray<FOptionValues::Pair> filteredValues;
int cnt = vals.Size();
for (int i = 0; i < cnt; ++i) {
auto const & mode = vals[i];
if (mode.Value == 7) { // Quad-buffered stereo
#ifdef _WIN32
if (!vr_enable_quadbuffered) continue;
#else
continue; // Remove quad-buffered option on Mac and Linux
#endif
if (!considerQuadBuffered) continue; // Probably no compatible screen mode was found
}
filteredValues.Push(mode);
}
vals = filteredValues;
}

View file

@ -3437,6 +3437,7 @@ static int D_DoomMain_Internal (void)
FinishDehPatch();
if (!batchrun) Printf("M_Init: Init menus.\n");
SetDefaultMenuColors();
M_Init();
M_CreateGameMenus();

View file

@ -1262,3 +1262,157 @@ void SetDefaultMenuColors()
OptionSettings.mFontColorHighlight = V_FindFontColor(gameinfo.mFontColorHighlight);
OptionSettings.mFontColorSelection = V_FindFontColor(gameinfo.mFontColorSelection);
}
CCMD (menu_main)
{
M_StartControlPanel(true);
M_SetMenu(NAME_Mainmenu, -1);
}
CCMD (menu_load)
{ // F3
M_StartControlPanel (true);
M_SetMenu(NAME_Loadgamemenu, -1);
}
CCMD (menu_save)
{ // F2
M_StartControlPanel (true);
M_SetMenu(NAME_Savegamemenu, -1);
}
CCMD (menu_help)
{ // F1
M_StartControlPanel (true);
M_SetMenu(NAME_Readthismenu, -1);
}
CCMD (menu_game)
{
M_StartControlPanel (true);
M_SetMenu(NAME_Playerclassmenu, -1); // The playerclass menu is the first in the 'start game' chain
}
CCMD (menu_options)
{
M_StartControlPanel (true);
M_SetMenu(NAME_Optionsmenu, -1);
}
CCMD (menu_player)
{
M_StartControlPanel (true);
M_SetMenu(NAME_Playermenu, -1);
}
CCMD (menu_messages)
{
M_StartControlPanel (true);
M_SetMenu(NAME_MessageOptions, -1);
}
CCMD (menu_automap)
{
M_StartControlPanel (true);
M_SetMenu(NAME_AutomapOptions, -1);
}
CCMD (menu_scoreboard)
{
M_StartControlPanel (true);
M_SetMenu(NAME_ScoreboardOptions, -1);
}
CCMD (menu_mapcolors)
{
M_StartControlPanel (true);
M_SetMenu(NAME_MapColorMenu, -1);
}
CCMD (menu_keys)
{
M_StartControlPanel (true);
M_SetMenu(NAME_CustomizeControls, -1);
}
CCMD (menu_gameplay)
{
M_StartControlPanel (true);
M_SetMenu(NAME_GameplayOptions, -1);
}
CCMD (menu_compatibility)
{
M_StartControlPanel (true);
M_SetMenu(NAME_CompatibilityOptions, -1);
}
CCMD (menu_mouse)
{
M_StartControlPanel (true);
M_SetMenu(NAME_MouseOptions, -1);
}
CCMD (menu_joystick)
{
M_StartControlPanel (true);
M_SetMenu(NAME_JoystickOptions, -1);
}
CCMD (menu_sound)
{
M_StartControlPanel (true);
M_SetMenu(NAME_SoundOptions, -1);
}
CCMD (menu_advsound)
{
M_StartControlPanel (true);
M_SetMenu(NAME_AdvSoundOptions, -1);
}
CCMD (menu_modreplayer)
{
M_StartControlPanel(true);
M_SetMenu(NAME_ModReplayerOptions, -1);
}
CCMD (menu_display)
{
M_StartControlPanel (true);
M_SetMenu(NAME_VideoOptions, -1);
}
CCMD (menu_video)
{
M_StartControlPanel (true);
M_SetMenu(NAME_VideoModeMenu, -1);
}
#ifdef _WIN32
EXTERN_CVAR(Bool, vr_enable_quadbuffered)
#endif
void UpdateVRModes(bool considerQuadBuffered)
{
FOptionValues** pVRModes = OptionValues.CheckKey("VRMode");
if (pVRModes == nullptr) return;
TArray<FOptionValues::Pair>& vals = (*pVRModes)->mValues;
TArray<FOptionValues::Pair> filteredValues;
int cnt = vals.Size();
for (int i = 0; i < cnt; ++i) {
auto const& mode = vals[i];
if (mode.Value == 7) { // Quad-buffered stereo
#ifdef _WIN32
if (!vr_enable_quadbuffered) continue;
#else
continue; // Remove quad-buffered option on Mac and Linux
#endif
if (!considerQuadBuffered) continue; // Probably no compatible screen mode was found
}
filteredValues.Push(mode);
}
vals = filteredValues;
}

View file

@ -15,7 +15,7 @@ extern FNewGameStartup NewGameStartupInfo;
void M_StartupEpisodeMenu(FNewGameStartup *gs);
void M_StartupSkillMenu(FNewGameStartup *gs);
void M_CreateGameMenus();
void SetDefaultMenuColors();
// The savegame manager contains too much code that is game specific. Parts are shareable but need more work first.
struct FSaveGameNode
{