|
From: Yoda-JM <yo...@us...> - 2009-09-06 11:57:56
|
Module: performous
Branch: master
Commit: 0f4fe7a9e4145440332bd48c527514f5a7b1e437
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Sep 6 13:57:28 2009 +0200
Fixed track assignment
---
game/guitargraph.cc | 1 +
game/screen_sing.cc | 22 ++++++++++++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index f45ee92..c906bed 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -79,6 +79,7 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
else if (index == "bass") m_necks.insert(index, new Texture("bassneck.svg"));
else m_necks.insert(index, new Texture("guitarneck.svg"));
}
+ if( m_track_index.empty() ) throw std::runtime_error("Could not find track \"" + track + "\"");
for (int i = 0; i < 6; ++i) m_hit[i].setRate(5.0);
for (int i = 0; i < 5; ++i) m_holds[i] = 0;
if (m_track_map.empty()) throw std::runtime_error("No track");
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index eed1cd9..affbd58 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -36,15 +36,25 @@ void ScreenSing::enter() {
if( !m_song->track_map.empty() ) {
// Here we load alternatively guitar/bass tracks until no guitar controler is available
// then we load all the drums tracks until no drum controler is available (and place them in second position)
- std::string track = "guitar";
+ bool no_guitar = false;
+ bool no_bass = false;
while (1) {
try {
Instruments::iterator it = m_instruments.end();
- if (track == "drums" && m_instruments.size() > 1) it = m_instruments.begin() + 1; // Drums go after the first guitar
- m_instruments.insert(it, new GuitarGraph(m_audio, *m_song, track));
- } catch (std::runtime_error&) { if (track=="drums") break; track = "drums";}
- if( track == "guitar" ) track = "bass";
- if( track == "bass" ) track = "guitar";
+ m_instruments.insert(it, new GuitarGraph(m_audio, *m_song, "guitar"));
+ } catch (std::runtime_error&) {no_guitar = true;}
+ try {
+ Instruments::iterator it = m_instruments.end();
+ m_instruments.insert(it, new GuitarGraph(m_audio, *m_song, "bass"));
+ } catch (std::runtime_error&) {no_bass = true;}
+ if( no_guitar && no_bass ) break;
+ }
+ while(1) {
+ try {
+ Instruments::iterator it = m_instruments.end();
+ if (m_instruments.size() > 1) it = m_instruments.begin() + 1; // Drums go after the first guitar
+ m_instruments.insert(it, new GuitarGraph(m_audio, *m_song, "drums"));
+ } catch (std::runtime_error&) { break; }
}
}
m_audio.playMusic(m_song->music, false, 0.0, m_instruments.empty() ? -1.0 : -8.0); // Startup delay for instruments is longer than for singing only
|