- handle menu customization via callbacks.

This commit is contained in:
Christoph Oelckers 2022-10-02 17:49:39 +02:00
parent a084667bed
commit 73142ef2cf
8 changed files with 15 additions and 14 deletions

View file

@ -24,4 +24,5 @@ FStartupInfo GameStartupInfo;
CVAR(Bool, queryiwad, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
CVAR(String, defaultiwad, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
CVAR(Bool, vid_fps, false, 0)

View file

@ -2,6 +2,7 @@
#include "zstring.h"
#include "intrect.h"
#include "name.h"
struct event_t;
class FRenderState;
@ -37,6 +38,8 @@ struct SystemCallbacks
void (*SetTransition)(int type);
bool (*CheckCheatmode)(bool printmsg, bool sponly);
void (*HudScaleChanged)();
bool (*SetSpecialMenu)(FName& menu, int param);
void (*OnMenuOpen)(bool makesound);
};
extern SystemCallbacks sysCallbacks;

View file

@ -55,8 +55,6 @@
#include "i_time.h"
#include "printf.h"
void M_StartControlPanel(bool makeSound, bool scaleoverride = false);
int DMenu::InMenu;
static ScaleOverrider *CurrentScaleOverrider;
//
@ -434,8 +432,10 @@ bool DMenu::TranslateKeyboardEvents()
//
//=============================================================================
void M_DoStartControlPanel (bool scaleoverride)
void M_StartControlPanel (bool makesound, bool scaleoverride)
{
if (sysCallbacks.OnMenuOpen) sysCallbacks.OnMenuOpen(makesound);
// intro might call this repeatedly
if (CurrentMenu != nullptr)
return;
@ -504,11 +504,9 @@ DEFINE_ACTION_FUNCTION(DMenu, ActivateMenu)
//
//=============================================================================
bool M_SetSpecialMenu(FName& menu, int param); // game specific checks
void M_SetMenu(FName menu, int param)
{
if (!M_SetSpecialMenu(menu, param)) return;
if (sysCallbacks.SetSpecialMenu && !sysCallbacks.SetSpecialMenu(menu, param)) return;
DMenuDescriptor **desc = MenuDescriptors.CheckKey(menu);
if (desc != nullptr)

View file

@ -303,7 +303,7 @@ void M_ActivateMenu(DMenu *menu);
void M_ClearMenus ();
void M_PreviousMenu ();
void M_ParseMenuDefs();
void M_DoStartControlPanel(bool scaleoverride);
void M_StartControlPanel(bool makeSound, bool scaleoverride = false);
void M_SetMenu(FName menu, int param = -1);
void M_StartMessage(const char *message, int messagemode, FName action = NAME_None);
DMenu *StartPickerMenu(DMenu *parent, const char *name, FColorCVar *cvar);

View file

@ -40,7 +40,6 @@
#include "vm.h"
#include "menustate.h"
void M_StartControlPanel(bool makeSound, bool scaleoverride = false);
FName MessageBoxClass = NAME_MessageBoxMenu;
CVAR(Bool, m_quickexit, false, CVAR_ARCHIVE)

View file

@ -158,6 +158,7 @@ void R_Shutdown();
void I_ShutdownInput();
void SetConsoleNotifyBuffer();
void I_UpdateDiscordPresence(bool SendPresence, const char* curstatus, const char* appid, const char* steamappid);
bool M_SetSpecialMenu(FName& menu, int param); // game specific checks
const FIWADInfo *D_FindIWAD(TArray<FString> &wadfiles, const char *iwad, const char *basewad);
@ -197,6 +198,7 @@ EXTERN_CVAR (Bool, sv_unlimited_pickup)
EXTERN_CVAR (Bool, r_drawplayersprites)
EXTERN_CVAR (Bool, show_messages)
EXTERN_CVAR(Bool, ticker)
EXTERN_CVAR(Bool, vid_fps)
extern bool setmodeneeded;
extern bool demorecording;
@ -299,7 +301,6 @@ CVAR(Bool, autoloadbrightmaps, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOB
CVAR(Bool, autoloadlights, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
CVAR(Bool, autoloadwidescreen, true, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
CVAR(Bool, r_debug_disable_vis_filter, false, 0)
CVAR(Bool, vid_fps, false, 0)
CVAR(Int, vid_showpalette, 0, 0)
CUSTOM_CVAR (Bool, i_discordrpc, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -3540,6 +3541,8 @@ static int D_DoomMain_Internal (void)
System_SetTransition,
CheckCheatmode,
System_HudScaleChanged,
M_SetSpecialMenu,
OnMenuOpen,
};

View file

@ -234,7 +234,7 @@ bool M_SetSpecialMenu(FName& menu, int param)
//
//=============================================================================
void M_StartControlPanel(bool makeSound, bool scaleoverride)
void OnMenuOpen(bool makeSound)
{
if (hud_toggled)
D_ToggleHud();
@ -249,7 +249,6 @@ void M_StartControlPanel(bool makeSound, bool scaleoverride)
{
S_Sound(CHAN_VOICE, CHANF_UI, "menu/activate", snd_menuvolume, ATTN_NONE);
}
M_DoStartControlPanel(scaleoverride);
}

View file

@ -2,9 +2,6 @@
#include "menu.h"
#include "savegamemanager.h"
void M_StartControlPanel (bool makeSound, bool scaleoverride = false);
struct FNewGameStartup
{
const char *PlayerClass;
@ -17,6 +14,7 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs);
void M_StartupSkillMenu(FNewGameStartup *gs);
void M_CreateGameMenus();
void SetDefaultMenuColors();
void OnMenuOpen(bool makeSound);
class FSavegameManager : public FSavegameManagerBase
{