summary refs log tree commit diff stats
path: root/src/menu_system.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2021-03-13 11:34:59 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2021-03-13 15:34:50 -0500
commit10c92d7f54759d9356ac948f6d019a82e40e3f4d (patch)
treed31fed66978bc8a97cacbced7e40e146a6200cc4 /src/menu_system.cpp
parent37bbad70090071a473a04583e373491557906699 (diff)
downloadtanetane-10c92d7f54759d9356ac948f6d019a82e40e3f4d.tar.gz
tanetane-10c92d7f54759d9356ac948f6d019a82e40e3f4d.tar.bz2
tanetane-10c92d7f54759d9356ac948f6d019a82e40e3f4d.zip
Added pause menu open and close sound
#7
Diffstat (limited to 'src/menu_system.cpp')
-rw-r--r--src/menu_system.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/menu_system.cpp b/src/menu_system.cpp index 468fa6e..6b03fca 100644 --- a/src/menu_system.cpp +++ b/src/menu_system.cpp
@@ -44,7 +44,8 @@ void MenuSystem::openPauseMenu() {
44 MenuBuilder().Command("Resume Game") 44 MenuBuilder().Command("Resume Game")
45 .ActivationFunction([] (Game& game) { 45 .ActivationFunction([] (Game& game) {
46 game.getSystem<MenuSystem>().closePauseMenu(); 46 game.getSystem<MenuSystem>().closePauseMenu();
47 }), 47 })
48 .SkipSoundEffect(),
48 MenuBuilder().Command("Quit") 49 MenuBuilder().Command("Quit")
49 .ActivationFunction([] (Game& game) { 50 .ActivationFunction([] (Game& game) {
50 game.quit(); 51 game.quit();
@@ -54,7 +55,7 @@ void MenuSystem::openPauseMenu() {
54 if (game_.getMap().hasExitArea()) { 55 if (game_.getMap().hasExitArea()) {
55 builders.push_back(MenuBuilder().Command("Exit Area") 56 builders.push_back(MenuBuilder().Command("Exit Area")
56 .ActivationFunction([] (Game& game) { 57 .ActivationFunction([] (Game& game) {
57 game.getSystem<MenuSystem>().closePauseMenu(); 58 game.getSystem<MenuSystem>().closePauseMenu(false);
58 game.getSystem<ScriptSystem>().runScript(game.getMap().getName(), "exit_area"); 59 game.getSystem<ScriptSystem>().runScript(game.getMap().getName(), "exit_area");
59 })); 60 }));
60 } 61 }
@@ -62,11 +63,17 @@ void MenuSystem::openPauseMenu() {
62 menu_ = CreateMenu(builders); 63 menu_ = CreateMenu(builders);
63 64
64 cursor_ = 0; 65 cursor_ = 0;
66
67 game_.getMixer().playSound("../res/sfx/menu_open.wav");
65} 68}
66 69
67void MenuSystem::closePauseMenu() { 70void MenuSystem::closePauseMenu(bool playSfx) {
68 pauseAnimation_.start(125, 0.0); 71 pauseAnimation_.start(125, 0.0);
69 openState_ = OpenState::Animating; 72 openState_ = OpenState::Animating;
73
74 if (playSfx) {
75 game_.getMixer().playSound("../res/sfx/menu_close.wav");
76 }
70} 77}
71 78
72void MenuSystem::pressedUp() { 79void MenuSystem::pressedUp() {
@@ -96,9 +103,13 @@ void MenuSystem::pressedDown() {
96} 103}
97 104
98void MenuSystem::activateOption() { 105void MenuSystem::activateOption() {
99 game_.getMixer().playSound("../res/sfx/menu_activate.wav"); 106 if (menu_[cursor_].type == MenuType::Command) {
107 if (menu_[cursor_].playSfx) {
108 game_.getMixer().playSound("../res/sfx/menu_activate.wav");
109 }
100 110
101 if (menu_[cursor_].type == MenuType::Command && menu_[cursor_].activationFunction) { 111 if (menu_[cursor_].activationFunction) {
102 menu_[cursor_].activationFunction(game_); 112 menu_[cursor_].activationFunction(game_);
113 }
103 } 114 }
104} 115}