|
From: Tapio V. <aa...@us...> - 2010-01-19 19:58:36
|
Module: performous
Branch: master
Commit: 5d80cfb434b57aadd7ed5a230e5912c00d587842
Author: Tapio Vierros <tap...@gm...>
Date: Tue Jan 19 21:57:37 2010 +0200
Moved in-game volume control to main.cc and added flash messages.
---
game/joystick.cc | 5 +++--
game/main.cc | 15 ++++++++++++++-
game/screen_configuration.cc | 2 --
game/screen_intro.cc | 2 --
game/screen_practice.cc | 2 --
game/screen_sing.cc | 3 ---
game/screen_songs.cc | 2 --
7 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index c514abf..efb9976 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -94,8 +94,9 @@ input::NavButton input::getNav(SDL_Event const &e) {
else if (k == SDLK_PAGEUP) return input::MOREUP;
else if (k == SDLK_PAGEDOWN) return input::MOREDOWN;
else if (k == SDLK_PAUSE || (k == SDLK_p && mod & KMOD_CTRL)) return input::PAUSE;
- else if (k == SDLK_UP && mod & KMOD_CTRL) return input::VOLUME_UP;
- else if (k == SDLK_DOWN && mod & KMOD_CTRL) return input::VOLUME_DOWN;
+ // Volume control is currently handled in main.cc
+ //else if (k == SDLK_UP && mod & KMOD_CTRL) return input::VOLUME_UP;
+ //else if (k == SDLK_DOWN && mod & KMOD_CTRL) return input::VOLUME_DOWN;
} else if (e.type == SDL_JOYBUTTONDOWN) {
// Joystick buttons
unsigned int joy_id = e.jbutton.which;
diff --git a/game/main.cc b/game/main.cc
index 5968199..3a7cfea 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -64,12 +64,25 @@ static void checkEvents_SDL(ScreenManager& sm, Window& window) {
}
if (keypressed == SDLK_PRINT || keypressed == SDLK_F12) {
g_take_screenshot = true;
- continue;
+ continue; // Already handled here...
}
if (keypressed == SDLK_F4 && modifier & KMOD_ALT) {
sm.finished();
continue; // Already handled here...
}
+ // Volume control
+ if ((keypressed == SDLK_UP || keypressed == SDLK_DOWN) && modifier & KMOD_CTRL) {
+ std::string curS = sm.getCurrentScreen()->getName();
+ // Pick proper setting
+ std::string which_vol = (curS == "Sing" || curS == "Practice")
+ ? "audio/music_volume" : "audio/preview_volume";
+ // Adjust value
+ if (keypressed == SDLK_UP) ++config[which_vol];
+ else --config[which_vol];
+ // Show message
+ sm.flashMessage(config[which_vol].getShortDesc() + ": " + config[which_vol].getValue());
+ continue; // Already handled here...
+ }
break;
}
// Forward to screen even if the input system takes it (ignoring pushEvent return value)
diff --git a/game/screen_configuration.cc b/game/screen_configuration.cc
index 3f1f653..b9d50bf 100644
--- a/game/screen_configuration.cc
+++ b/game/screen_configuration.cc
@@ -32,8 +32,6 @@ void ScreenConfiguration::manageEvent(SDL_Event event) {
else if (nav == input::DOWN && selected + 1 < configuration.size()) ++selected;
else if (nav == input::LEFT) --*ci;
else if (nav == input::RIGHT) ++*ci;
- else if (nav == input::VOLUME_DOWN) --config["audio/preview_volume"];
- else if (nav == input::VOLUME_UP) ++config["audio/preview_volume"];
} else if (event.type == SDL_KEYDOWN) {
int key = event.key.keysym.sym;
SDLMod modifier = event.key.keysym.mod;
diff --git a/game/screen_intro.cc b/game/screen_intro.cc
index 670172f..2b488a5 100755
--- a/game/screen_intro.cc
+++ b/game/screen_intro.cc
@@ -41,8 +41,6 @@ void ScreenIntro::manageEvent(SDL_Event event) {
if (nav == input::CANCEL) selected = m_menuOptions.size() - 1; // Move cursor to quit
else if (nav == input::DOWN || nav == input::RIGHT || nav == input::MOREDOWN) ++selected;
else if (nav == input::UP || nav == input::LEFT || nav == input::MOREUP) --selected;
- else if (nav == input::VOLUME_DOWN) --config["audio/preview_volume"];
- else if (nav == input::VOLUME_UP) ++config["audio/preview_volume"];
else if (nav == input::START) {
std::string screen = m_menuOptions[selected].screen;
if (screen.empty()) sm->finished(); else sm->activateScreen(screen);
diff --git a/game/screen_practice.cc b/game/screen_practice.cc
index 63e7b01..4d0720a 100644
--- a/game/screen_practice.cc
+++ b/game/screen_practice.cc
@@ -38,8 +38,6 @@ void ScreenPractice::manageEvent(SDL_Event event) {
input::NavButton nav(input::getNav(event));
if (nav == input::CANCEL || nav == input::START || nav == input::SELECT) sm->activateScreen("Intro");
else if (nav == input::PAUSE) m_audio.togglePause();
- else if (nav == input::VOLUME_DOWN) --config["audio/music_volume"];
- else if (nav == input::VOLUME_UP) ++config["audio/music_volume"];
// FIXME: This should not use stuff from input::detail namespace!
else if (event.type == SDL_JOYBUTTONDOWN // Play drum sounds here
&& input::detail::devices[event.jbutton.which].type_match(input::DRUMS)) {
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 1e7f280..ef0d8ec 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -216,9 +216,6 @@ void ScreenSing::manageEvent(SDL_Event event) {
}
}
}
- // Volume control
- if (nav == input::VOLUME_UP) dispInFlash(++config["audio/music_volume"]);
- if (nav == input::VOLUME_DOWN) dispInFlash(--config["audio/music_volume"]);
}
// Ctrl combinations that can be used while performing (not when score dialog is displayed)
if (event.type == SDL_KEYDOWN && (event.key.keysym.mod & KMOD_CTRL) && !m_score_window.get()) {
diff --git a/game/screen_songs.cc b/game/screen_songs.cc
index 838586e..3f5c619 100644
--- a/game/screen_songs.cc
+++ b/game/screen_songs.cc
@@ -83,8 +83,6 @@ void ScreenSongs::manageEvent(SDL_Event event) {
else if (nav == input::DOWN) m_songs.sortChange(1);
else if (nav == input::MOREUP) m_songs.advance(-10);
else if (nav == input::MOREDOWN) m_songs.advance(10);
- else if (nav == input::VOLUME_DOWN) --config["audio/preview_volume"];
- else if (nav == input::VOLUME_UP) ++config["audio/preview_volume"];
else manageSharedKey(nav);
// Handle less common, keyboard only keys
} else if (event.type == SDL_KEYDOWN) {
|