- 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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue