mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- add a system interface for CheckCheatmode and moved some sound code to the backend.
This commit is contained in:
parent
75afc69306
commit
8aaab153fa
25 changed files with 187 additions and 164 deletions
|
@ -44,8 +44,11 @@
|
|||
#include "m_random.h"
|
||||
#include "printf.h"
|
||||
#include "c_cvars.h"
|
||||
#include "gamestate.h"
|
||||
|
||||
CVARD(Bool, snd_enabled, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enables/disables sound effects")
|
||||
CVAR(Bool, i_soundinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, i_pauseinbackground, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
||||
int SoundEnabled()
|
||||
{
|
||||
|
@ -1710,3 +1713,160 @@ void S_SoundReset()
|
|||
S_RestartMusic();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CCMD cachesound <sound name>
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
#include "s_music.h"
|
||||
#include "vm.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "stats.h"
|
||||
#include "i_net.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
|
||||
CCMD(cachesound)
|
||||
{
|
||||
if (argv.argc() < 2)
|
||||
{
|
||||
Printf("Usage: cachesound <sound> ...\n");
|
||||
return;
|
||||
}
|
||||
for (int i = 1; i < argv.argc(); ++i)
|
||||
{
|
||||
FSoundID sfxnum = argv[i];
|
||||
if (sfxnum != FSoundID(0))
|
||||
{
|
||||
soundEngine->CacheSound(sfxnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CCMD(listsoundchannels)
|
||||
{
|
||||
Printf("%s", soundEngine->ListSoundChannels().GetChars());
|
||||
}
|
||||
|
||||
// intentionally moved here to keep the s_music include out of the rest of the file.
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// S_PauseSound
|
||||
//
|
||||
// Stop music and sound effects, during game PAUSE.
|
||||
//==========================================================================
|
||||
|
||||
void S_PauseSound(bool notmusic, bool notsfx)
|
||||
{
|
||||
if (!notmusic)
|
||||
{
|
||||
S_PauseMusic();
|
||||
}
|
||||
if (!notsfx)
|
||||
{
|
||||
soundEngine->SetPaused(true);
|
||||
GSnd->SetSfxPaused(true, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DObject, S_PauseSound)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_BOOL(notmusic);
|
||||
PARAM_BOOL(notsfx);
|
||||
S_PauseSound(notmusic, notsfx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// S_ResumeSound
|
||||
//
|
||||
// Resume music and sound effects, after game PAUSE.
|
||||
//==========================================================================
|
||||
|
||||
void S_ResumeSound(bool notsfx)
|
||||
{
|
||||
S_ResumeMusic();
|
||||
if (!notsfx)
|
||||
{
|
||||
soundEngine->SetPaused(false);
|
||||
GSnd->SetSfxPaused(false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DObject, S_ResumeSound)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_BOOL(notsfx);
|
||||
S_ResumeSound(notsfx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// S_SetSoundPaused
|
||||
//
|
||||
// Called with state non-zero when the app is active, zero when it isn't.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void S_SetSoundPaused(int state)
|
||||
{
|
||||
if (!netgame && (i_pauseinbackground))
|
||||
{
|
||||
pauseext = !state;
|
||||
}
|
||||
|
||||
if ((state || i_soundinbackground) && !pauseext)
|
||||
{
|
||||
if (paused == 0)
|
||||
{
|
||||
S_ResumeSound(true);
|
||||
if (GSnd != nullptr)
|
||||
{
|
||||
GSnd->SetInactive(SoundRenderer::INACTIVE_Active);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paused == 0)
|
||||
{
|
||||
S_PauseSound(false, true);
|
||||
if (GSnd != nullptr)
|
||||
{
|
||||
GSnd->SetInactive(gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL ?
|
||||
SoundRenderer::INACTIVE_Complete :
|
||||
SoundRenderer::INACTIVE_Mute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
CCMD(snd_status)
|
||||
{
|
||||
GSnd->PrintStatus();
|
||||
}
|
||||
|
||||
CCMD(snd_reset)
|
||||
{
|
||||
S_SoundReset();
|
||||
}
|
||||
|
||||
CCMD(snd_listdrivers)
|
||||
{
|
||||
GSnd->PrintDriversList();
|
||||
}
|
||||
|
||||
ADD_STAT(sound)
|
||||
{
|
||||
return GSnd->GatherStats();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -306,6 +306,7 @@ public:
|
|||
void MarkUsed(int num);
|
||||
void CacheMarkedSounds();
|
||||
TArray<FSoundChan*> AllActiveChannels();
|
||||
virtual void SetSoundPaused(int state) {}
|
||||
|
||||
void MarkAllUnused()
|
||||
{
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "engineerrors.h"
|
||||
#include "printf.h"
|
||||
#include "palutil.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
|
||||
struct FLatchedValue
|
||||
|
@ -1462,7 +1463,7 @@ EXTERN_CVAR(Bool, sv_cheats);
|
|||
|
||||
void FBaseCVar::CmdSet (const char *newval)
|
||||
{
|
||||
if ((GetFlags() & CVAR_CHEAT) && CheckCheatmode ())
|
||||
if ((GetFlags() & CVAR_CHEAT) && sysCallbacks.CheckCheatmode && sysCallbacks.CheckCheatmode(true, false))
|
||||
return;
|
||||
|
||||
MarkUnsafe();
|
||||
|
|
|
@ -59,8 +59,6 @@ extern bool ParsingKeyConf, UnsafeExecutionContext;
|
|||
extern FString StoredWarp; // [RH] +warp at the command line
|
||||
|
||||
|
||||
extern bool CheckCheatmode (bool printmsg = true, bool sponly = false);
|
||||
|
||||
FExecList *C_ParseCmdLineParams(FExecList *exec);
|
||||
|
||||
// Add commands to the console as if they were typed in. Can handle wait
|
||||
|
|
|
@ -17,6 +17,8 @@ bool AppActive = true;
|
|||
int chatmodeon;
|
||||
gamestate_t gamestate = GS_STARTUP;
|
||||
bool ToggleFullscreen;
|
||||
int paused;
|
||||
bool pauseext;
|
||||
|
||||
FStartupInfo GameStartupInfo;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ struct SystemCallbacks
|
|||
void (*ToggleFullConsole)();
|
||||
void (*StartCutscene)(bool blockui);
|
||||
void (*SetTransition)(int type);
|
||||
bool (*CheckCheatmode)(bool printmsg, bool sponly);
|
||||
};
|
||||
|
||||
extern SystemCallbacks sysCallbacks;
|
||||
|
@ -50,5 +51,7 @@ extern FString endoomName;
|
|||
extern bool batchrun;
|
||||
extern float menuBlurAmount;
|
||||
extern bool generic_ui;
|
||||
extern int paused;
|
||||
extern bool pauseext;
|
||||
|
||||
void UpdateGenericUI(bool cvar);
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include "s_music.h"
|
||||
#include "texturemanager.h"
|
||||
#include "v_draw.h"
|
||||
#include "d_main.h"
|
||||
|
||||
extern FILE *Logfile;
|
||||
extern bool insave;
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "i_interface.h"
|
||||
|
||||
EXTERN_CVAR(Bool, queryiwad);
|
||||
EXTERN_CVAR(Bool, defaultiwad);
|
||||
EXTERN_CVAR(String, defaultiwad);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -3529,6 +3529,7 @@ static int D_DoomMain_Internal (void)
|
|||
System_ToggleFullConsole,
|
||||
System_StartCutscene,
|
||||
System_SetTransition,
|
||||
CheckCheatmode,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -161,4 +161,6 @@ inline bool V_IsTrueColor()
|
|||
return vid_rendermode == 1 || vid_rendermode == 4;
|
||||
}
|
||||
|
||||
bool CheckCheatmode(bool printmsg = true, bool sponly = false);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -69,6 +69,8 @@
|
|||
#include "gstrings.h"
|
||||
#include "s_music.h"
|
||||
#include "screenjob.h"
|
||||
#include "d_main.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
EXTERN_CVAR (Int, disableautosave)
|
||||
EXTERN_CVAR (Int, autosavecount)
|
||||
|
|
|
@ -108,8 +108,6 @@ EXTERN_CVAR (Float, snd_musicvolume) // maximum volume for music
|
|||
#include "menustate.h"
|
||||
|
||||
extern bool automapactive; // In AutoMap mode?
|
||||
extern int paused; // Game Pause?
|
||||
extern bool pauseext;
|
||||
|
||||
|
||||
extern bool viewactive;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "c_functions.h"
|
||||
#include "gstrings.h"
|
||||
#include "texturemanager.h"
|
||||
#include "d_main.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
#include "hwrenderer/scene/hw_drawinfo.h"
|
||||
#include "doommenu.h"
|
||||
#include "screenjob.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
|
||||
static FRandom pr_dmspawn ("DMSpawn");
|
||||
|
@ -145,8 +146,6 @@ extern bool playedtitlemusic;
|
|||
|
||||
gameaction_t gameaction;
|
||||
|
||||
int paused;
|
||||
bool pauseext;
|
||||
bool sendpause; // send a pause event next tic
|
||||
bool sendsave; // send a save event next tic
|
||||
bool sendturn180; // [RH] send a 180 degree turn next tic
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "filesystem.h"
|
||||
#include "am_map.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
#include "p_setup.h"
|
||||
#include "p_local.h"
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "filesystem.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "texturemanager.h"
|
||||
#include "d_main.h"
|
||||
|
||||
extern void LoadActors ();
|
||||
extern void InitBotStuff();
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "a_morph.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "vm.h"
|
||||
#include "d_main.h"
|
||||
|
||||
uint8_t globalfreeze, globalchangefreeze; // user's freeze state.
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "events.h"
|
||||
#include "actorinlines.h"
|
||||
#include "g_game.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
extern gamestate_t wipegamestate;
|
||||
extern uint8_t globalfreeze, globalchangefreeze;
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "filesystem.h"
|
||||
#include "vm.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "d_main.h"
|
||||
|
||||
IMPLEMENT_CLASS(DBot, false, true)
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "g_levellocals.h"
|
||||
#include "events.h"
|
||||
#include "actorinlines.h"
|
||||
#include "d_main.h"
|
||||
|
||||
static FRandom pr_botrespawn ("BotRespawn");
|
||||
static FRandom pr_killmobj ("ActorDie");
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#include "g_game.h"
|
||||
#include "i_system.h"
|
||||
#include "v_draw.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "doomdef.h"
|
||||
#include "m_swap.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "c_console.h"
|
||||
|
|
|
@ -71,8 +71,6 @@
|
|||
|
||||
|
||||
FBoolCVar noisedebug("noise", false, 0); // [RH] Print sound debugging info?
|
||||
CVAR (Bool, i_soundinbackground, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Bool, i_pauseinbackground, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
|
||||
|
||||
static FString LastLocalSndInfo;
|
||||
|
@ -922,52 +920,6 @@ void S_SerializeSounds(FSerializer &arc)
|
|||
GSnd->UpdateSounds();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// S_SetSoundPaused
|
||||
//
|
||||
// Called with state non-zero when the app is active, zero when it isn't.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void S_SetSoundPaused(int state)
|
||||
{
|
||||
if (!netgame && (i_pauseinbackground)
|
||||
#ifdef _DEBUG
|
||||
&& !demoplayback
|
||||
#endif
|
||||
)
|
||||
{
|
||||
pauseext = !state;
|
||||
}
|
||||
|
||||
if ((state || i_soundinbackground) && !pauseext)
|
||||
{
|
||||
if (paused == 0)
|
||||
{
|
||||
S_ResumeSound(true);
|
||||
if (GSnd != nullptr)
|
||||
{
|
||||
GSnd->SetInactive(SoundRenderer::INACTIVE_Active);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paused == 0)
|
||||
{
|
||||
S_PauseSound(false, true);
|
||||
if (GSnd != nullptr)
|
||||
{
|
||||
GSnd->SetInactive(gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL ?
|
||||
SoundRenderer::INACTIVE_Complete :
|
||||
SoundRenderer::INACTIVE_Mute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CalcSectorSoundOrg
|
||||
|
@ -1475,111 +1427,3 @@ CCMD (loopsound)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CCMD cachesound <sound name>
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
CCMD (cachesound)
|
||||
{
|
||||
if (argv.argc() < 2)
|
||||
{
|
||||
Printf ("Usage: cachesound <sound> ...\n");
|
||||
return;
|
||||
}
|
||||
for (int i = 1; i < argv.argc(); ++i)
|
||||
{
|
||||
FSoundID sfxnum = argv[i];
|
||||
if (sfxnum != FSoundID(0))
|
||||
{
|
||||
soundEngine->CacheSound(sfxnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CCMD(listsoundchannels)
|
||||
{
|
||||
Printf("%s", soundEngine->ListSoundChannels().GetChars());
|
||||
}
|
||||
|
||||
// intentionally moved here to keep the s_music include out of the rest of the file.
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// S_PauseSound
|
||||
//
|
||||
// Stop music and sound effects, during game PAUSE.
|
||||
//==========================================================================
|
||||
#include "s_music.h"
|
||||
|
||||
void S_PauseSound (bool notmusic, bool notsfx)
|
||||
{
|
||||
if (!notmusic)
|
||||
{
|
||||
S_PauseMusic();
|
||||
}
|
||||
if (!notsfx)
|
||||
{
|
||||
soundEngine->SetPaused(true);
|
||||
GSnd->SetSfxPaused (true, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DObject, S_PauseSound)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_BOOL(notmusic);
|
||||
PARAM_BOOL(notsfx);
|
||||
S_PauseSound(notmusic, notsfx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// S_ResumeSound
|
||||
//
|
||||
// Resume music and sound effects, after game PAUSE.
|
||||
//==========================================================================
|
||||
|
||||
void S_ResumeSound (bool notsfx)
|
||||
{
|
||||
S_ResumeMusic();
|
||||
if (!notsfx)
|
||||
{
|
||||
soundEngine->SetPaused(false);
|
||||
GSnd->SetSfxPaused (false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DObject, S_ResumeSound)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_BOOL(notsfx);
|
||||
S_ResumeSound(notsfx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
CCMD (snd_status)
|
||||
{
|
||||
GSnd->PrintStatus ();
|
||||
}
|
||||
|
||||
CCMD (snd_reset)
|
||||
{
|
||||
S_SoundReset();
|
||||
}
|
||||
|
||||
CCMD (snd_listdrivers)
|
||||
{
|
||||
GSnd->PrintDriversList ();
|
||||
}
|
||||
|
||||
ADD_STAT (sound)
|
||||
{
|
||||
return GSnd->GatherStats ();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "po_man.h"
|
||||
#include "gi.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
#include "g_level.h"
|
||||
#include "serializer_doom.h"
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "doomstat.h"
|
||||
#include "g_level.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "d_main.h"
|
||||
|
||||
EXTERN_CVAR (Bool, ticker);
|
||||
EXTERN_CVAR (Bool, noisedebug);
|
||||
|
|
Loading…
Reference in a new issue