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 13:34:12 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2021-03-13 15:34:50 -0500
commit9107e9e6c337fbd9790eeb7e89e473d5da129f36 (patch)
tree4dc08eaebcbff0e284713965b743c6189ba9aaad /src/menu_system.cpp
parent8a7d87a312b3dc42877577e99533c96d48714368 (diff)
downloadtanetane-9107e9e6c337fbd9790eeb7e89e473d5da129f36.tar.gz
tanetane-9107e9e6c337fbd9790eeb7e89e473d5da129f36.tar.bz2
tanetane-9107e9e6c337fbd9790eeb7e89e473d5da129f36.zip
Music volume is controllable from settings menu
#7
Diffstat (limited to 'src/menu_system.cpp')
-rw-r--r--src/menu_system.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/menu_system.cpp b/src/menu_system.cpp index e1aca8d..c099afe 100644 --- a/src/menu_system.cpp +++ b/src/menu_system.cpp
@@ -55,8 +55,15 @@ void MenuSystem::openPauseMenu() {
55 .ActivationFunction([this] (Game&) { 55 .ActivationFunction([this] (Game&) {
56 openSubmenu(Menu({ 56 openSubmenu(Menu({
57 MenuBuilder().Slider("Music Volume: ") 57 MenuBuilder().Slider("Music Volume: ")
58 .InitialValue(10) 58 .InitialValue(game_.getMixer().isMusicMuted() ? 0 : game_.getMixer().getMusicVolume())
59 .MaxValue(10), 59 .MaxValue(10)
60 .SelectionChangedFunction([this] (MenuItem& menuItem) {
61 if (game_.getMixer().isMusicMuted()) {
62 menuItem.value = game_.getMixer().getMusicVolume();
63 }
64
65 game_.getMixer().setMusicVolume(menuItem.value);
66 }),
60 MenuBuilder().Slider("Sound Volume: ") 67 MenuBuilder().Slider("Sound Volume: ")
61 .InitialValue(10) 68 .InitialValue(10)
62 .MaxValue(10), 69 .MaxValue(10),
@@ -135,6 +142,10 @@ void MenuSystem::pressedLeft() {
135 if (menuItem.type == MenuType::Slider && menuItem.value > 0) { 142 if (menuItem.type == MenuType::Slider && menuItem.value > 0) {
136 menuItem.value--; 143 menuItem.value--;
137 144
145 if (menuItem.selectionChanged) {
146 menuItem.selectionChanged(menuItem);
147 }
148
138 game_.getMixer().playSound("../res/sfx/horizontal_menu.wav"); 149 game_.getMixer().playSound("../res/sfx/horizontal_menu.wav");
139 } 150 }
140} 151}
@@ -146,6 +157,10 @@ void MenuSystem::pressedRight() {
146 if (menuItem.type == MenuType::Slider && menuItem.value < menuItem.maxValue) { 157 if (menuItem.type == MenuType::Slider && menuItem.value < menuItem.maxValue) {
147 menuItem.value++; 158 menuItem.value++;
148 159
160 if (menuItem.selectionChanged) {
161 menuItem.selectionChanged(menuItem);
162 }
163
149 game_.getMixer().playSound("../res/sfx/horizontal_menu.wav"); 164 game_.getMixer().playSound("../res/sfx/horizontal_menu.wav");
150 } 165 }
151} 166}