|
From: Tapio V. <aa...@us...> - 2010-10-17 16:36:33
|
Module: performous
Branch: master
Commit: 909f06a59c14cb7b2f0e8dbc3b059cab0a8e25c2
Author: Tapio Vierros <tap...@gm...>
Date: Sun Oct 17 19:35:38 2010 +0300
Vocal track changer to pause menu.
---
game/configuration.cc | 2 +-
game/screen_sing.cc | 19 ++++++++++++++++++-
game/screen_sing.hh | 2 ++
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/game/configuration.cc b/game/configuration.cc
index e68516b..fdc1bcd 100644
--- a/game/configuration.cc
+++ b/game/configuration.cc
@@ -66,7 +66,7 @@ void ConfigItem::verifyType(std::string const& type) const {
for (Config::const_iterator it = config.begin(); it != config.end(); ++it) {
if (&it->second == this) { name = it->first; break; }
}
- if (m_type.empty()) throw std::logic_error("Config item " + name + " used in C++ but missing from config schema");
+ if (m_type.empty()) throw std::logic_error("Config item " + name + ", requested_type=" + type + " used in C++ but missing from config schema");
throw std::logic_error("Config item type mismatch: item=" + name + ", type=" + m_type + ", requested=" + type);
}
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 8f9d27a..c0c2c00 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -2,7 +2,6 @@
#include "songparser.hh"
#include "util.hh"
-#include "configuration.hh"
#include "screen_players.hh"
#include "fs.hh"
#include "database.hh"
@@ -118,6 +117,22 @@ void ScreenSing::enter() {
m_menu.clear();
m_menu.add(MenuOption(_("Resume"), _("Back to performing!")));
m_menu.add(MenuOption(_("Restart"), _("Start the song\nfrom the beginning"), "Sing"));
+ { // Vocal tracks
+ ConfigItem::OptionList opts;
+ std::vector<std::string> voctracks = m_song->getVocalTrackNames();
+ int cur = 0;
+ // Add vocal tracks to option list
+ for (std::vector<std::string>::const_iterator it = voctracks.begin(); it != voctracks.end(); ++it) {
+ if (m_selectedTrack == *it) cur = opts.size(); // Find the index of current track
+ opts.push_back(*it);
+ }
+ m_vocalTrackOpts = ConfigItem(opts); // Create a ConfigItem from the option list
+ if (opts.size() > 1) { // Vocal track changer only if there is options
+ m_vocalTrackOpts.select(cur); // Set the selection to current track
+ m_menu.add(MenuOption("", _("Change vocal track\n(restart required)"), &m_vocalTrackOpts));
+ m_menu.back().setDynamicName(m_selectedTrack); // Set the title to be dynamic
+ }
+ }
m_menu.add(MenuOption(_("Quit"), _("Exit to song browser"), "Songs"));
m_menu.close();
// Startup delay for instruments is longer than for singing only
@@ -287,6 +302,8 @@ void ScreenSing::manageEvent(SDL_Event event) {
if (nav == input::START) {
m_menu.action();
if (!m_menu.isOpen() && m_audio.isPaused()) m_audio.togglePause();
+ // Handle updates
+ if (m_selectedTrack != m_vocalTrackOpts.so()) m_selectedTrack = m_vocalTrackOpts.so();
return;
}
else if (nav == input::DOWN) { m_menu.move(1); return; }
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index 6ea1fa0..447802d 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -15,6 +15,7 @@
#include "progressbar.hh"
#include "webcam.hh"
#include "screen_players.hh"
+#include "configuration.hh"
class Players;
class Audio;
@@ -95,5 +96,6 @@ class ScreenSing: public Screen {
bool m_only_singers_alive;
bool m_practmode;
std::string m_selectedTrack;
+ ConfigItem m_vocalTrackOpts;
};
|