From 43b1b71da16f75447b36edc3f0c2b7f177ff42ec Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 19 Apr 2020 12:40:59 -0700 Subject: [PATCH] Add being able to mute the music by pressing N This is for people who want to use their own soundtrack while playing the game, but who don't want to mute the sound effects as well. This feature was added to VCE, but it was added in the strangest way. It was made an option in "game options" instead of being a keybind, and I don't know why. --- desktop_version/src/Game.cpp | 2 ++ desktop_version/src/Game.h | 2 ++ desktop_version/src/KeyPoll.h | 1 + desktop_version/src/main.cpp | 20 +++++++++++++++++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 9e73414a..20d7c4af 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -119,6 +119,8 @@ void Game::init(void) infocus = true; paused = false; muted = false; + musicmuted = false; + musicmutebutton = 0; globalsound = 128; m_globalVol = 1.0f; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index e55df22e..6047d19f 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -192,6 +192,8 @@ public: bool infocus; bool muted; int mutebutton; + bool musicmuted; + int musicmutebutton; private: float m_globalVol; diff --git a/desktop_version/src/KeyPoll.h b/desktop_version/src/KeyPoll.h index 56333461..53630450 100644 --- a/desktop_version/src/KeyPoll.h +++ b/desktop_version/src/KeyPoll.h @@ -21,6 +21,7 @@ enum Kybrd KEYBOARD_a = SDLK_a, KEYBOARD_d = SDLK_d, KEYBOARD_m = SDLK_m, + KEYBOARD_n = SDLK_n, KEYBOARD_v = SDLK_v, KEYBOARD_z = SDLK_z, diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index b130ac41..d0898c04 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -519,6 +519,16 @@ int main(int argc, char *argv[]) game.mutebutton--; } + if (key.isDown(KEYBOARD_n) && game.musicmutebutton <= 0 && !inEditor) + { + game.musicmutebutton = 8; + game.musicmuted = !game.musicmuted; + } + if (game.musicmutebutton > 0) + { + game.musicmutebutton--; + } + if (game.muted) { game.globalsound = 0; @@ -529,8 +539,16 @@ int main(int argc, char *argv[]) if (!game.muted && game.globalsound == 0) { game.globalsound = 1; - Mix_VolumeMusic(MIX_MAX_VOLUME) ; Mix_Volume(-1,MIX_MAX_VOLUME); + + if (game.musicmuted) + { + Mix_VolumeMusic(0); + } + else + { + Mix_VolumeMusic(MIX_MAX_VOLUME); + } } if (key.resetWindow)