summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/menu_system.cpp2
-rw-r--r--src/mixer.cpp8
-rw-r--r--src/mixer.h4
3 files changed, 14 insertions, 0 deletions
diff --git a/src/menu_system.cpp b/src/menu_system.cpp index 6b03fca..7631e4d 100644 --- a/src/menu_system.cpp +++ b/src/menu_system.cpp
@@ -10,6 +10,7 @@ void MenuSystem::tick(double dt) {
10 openState_ = OpenState::Closed; 10 openState_ = OpenState::Closed;
11 11
12 game_.unpauseGameplay(); 12 game_.unpauseGameplay();
13 game_.getMixer().unpauseSounds();
13 } else if (pauseAnimation_.getProgress() == 1.0) { 14 } else if (pauseAnimation_.getProgress() == 1.0) {
14 openState_ = OpenState::Open; 15 openState_ = OpenState::Open;
15 } 16 }
@@ -64,6 +65,7 @@ void MenuSystem::openPauseMenu() {
64 65
65 cursor_ = 0; 66 cursor_ = 0;
66 67
68 game_.getMixer().pauseSounds();
67 game_.getMixer().playSound("../res/sfx/menu_open.wav"); 69 game_.getMixer().playSound("../res/sfx/menu_open.wav");
68} 70}
69 71
diff --git a/src/mixer.cpp b/src/mixer.cpp index 37c2177..4e8f307 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp
@@ -23,6 +23,14 @@ void Mixer::stopChannel(int channel) {
23 Mix_HaltChannel(channel); 23 Mix_HaltChannel(channel);
24} 24}
25 25
26void Mixer::pauseSounds() {
27 Mix_Pause(-1);
28}
29
30void Mixer::unpauseSounds() {
31 Mix_Resume(-1);
32}
33
26void Mixer::playMusic(std::string_view name, int ms) { 34void Mixer::playMusic(std::string_view name, int ms) {
27 Mix_Music* song = getMusicByName(name); 35 Mix_Music* song = getMusicByName(name);
28 int ret; 36 int ret;
diff --git a/src/mixer.h b/src/mixer.h index b049118..854c67d 100644 --- a/src/mixer.h +++ b/src/mixer.h
@@ -72,6 +72,10 @@ public:
72 72
73 void stopChannel(int channel); 73 void stopChannel(int channel);
74 74
75 void pauseSounds();
76
77 void unpauseSounds();
78
75 // name is the name of the file, not containing the extension 79 // name is the name of the file, not containing the extension
76 // ms is the time in milliseconds to fade in 80 // ms is the time in milliseconds to fade in
77 void playMusic(std::string_view name, int ms = 0); 81 void playMusic(std::string_view name, int ms = 0);