From 3500888971ce59a044eec2dfbb37e04494388b2e Mon Sep 17 00:00:00 2001 From: AllyTally Date: Wed, 11 Aug 2021 22:08:32 -0300 Subject: [PATCH] Add audiopause(on/off) command If you have unfocus pause off, and unfocus audio pause off, then this command will go into effect. When it's set to on, the audio will pause when you unfocus the game. When it's set to off, the audio will not. This is different from the setting, and gets saved to the save file. --- desktop_version/src/Game.cpp | 7 +++++++ desktop_version/src/Game.h | 1 + desktop_version/src/KeyPoll.cpp | 4 ++-- desktop_version/src/Script.cpp | 13 +++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index d678f122..572fb019 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -391,6 +391,7 @@ void Game::init(void) disablepause = false; disableaudiopause = false; + disabletemporaryaudiopause = true; inputdelay = false; } @@ -5193,6 +5194,10 @@ void Game::customloadquick(std::string savfile) { map.customshowmm = help.Int(pText); } + else if (SDL_strcmp(pKey, "disabletemporaryaudiopause") == 0) + { + disabletemporaryaudiopause = help.Int(pText); + } } @@ -5674,6 +5679,8 @@ bool Game::customsavequick(std::string savfile) xml::update_tag(msgs, "showminimap", (int) map.customshowmm); + xml::update_tag(msgs, "disabletemporaryaudiopause", (int) disabletemporaryaudiopause); + std::string summary = savearea + ", " + timestring(); xml::update_tag(msgs, "summary", summary.c_str()); diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 1138343d..07a0bd8b 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -475,6 +475,7 @@ public: bool disablepause; bool disableaudiopause; + bool disabletemporaryaudiopause; bool inputdelay; }; diff --git a/desktop_version/src/KeyPoll.cpp b/desktop_version/src/KeyPoll.cpp index 8db01e09..b7d1ceef 100644 --- a/desktop_version/src/KeyPoll.cpp +++ b/desktop_version/src/KeyPoll.cpp @@ -327,7 +327,7 @@ void KeyPoll::Poll(void) if (!game.disablepause) { isActive = true; - if (!game.disableaudiopause) + if (!game.disableaudiopause || !game.disabletemporaryaudiopause) { music.resume(); music.resumeef(); @@ -350,7 +350,7 @@ void KeyPoll::Poll(void) if (!game.disablepause) { isActive = false; - if (!game.disableaudiopause) + if (!game.disableaudiopause || !game.disabletemporaryaudiopause) { music.pause(); music.pauseef(); diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 85419341..9fd4947f 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -326,6 +326,17 @@ void scriptclass::run(void) { graphics.showcutscenebars = false; } + if (words[0] == "audiopause") + { + if (words[1] == "on") + { + game.disabletemporaryaudiopause = false; + } + else if (words[1] == "off") + { + game.disabletemporaryaudiopause = true; + } + } if (words[0] == "untilbars") { if (graphics.showcutscenebars) @@ -3465,6 +3476,8 @@ void scriptclass::hardreset(void) game.activeactivity = -1; game.act_fade = 5; + game.disabletemporaryaudiopause = true; + //dwgraphicsclass graphics.backgrounddrawn = false; graphics.textbox.clear();