|
From: Yoda-JM <yo...@us...> - 2009-09-05 11:19:42
|
Module: performous
Branch: master
Commit: d6ee3d6e96fa04bce9b78f9717232556a1e96b1d
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Sep 5 13:19:04 2009 +0200
Fixed instrument loading
---
game/guitargraph.cc | 11 ++++++-----
game/guitargraph.hh | 2 +-
game/screen_sing.cc | 14 +++++++++-----
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 9f50c34..f45ee92 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -36,14 +36,14 @@ namespace {
}
-GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, unsigned track):
+GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
m_audio(audio),
- m_input(drums ? input::DRUMS : input::GUITAR),
+ m_input(track=="drums" ? input::DRUMS : input::GUITAR),
m_song(song),
m_button("button.svg"),
m_button_l("button_l.svg"),
m_tap("tap.svg"),
- m_drums(drums),
+ m_drums(track=="drums"),
m_cx(0.0, 0.2),
m_width(0.5, 0.4),
m_stream(),
@@ -71,9 +71,10 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, unsigned tr
unsigned int i = 0;
for (TrackMap::const_iterator it = m_song.track_map.begin(); it != m_song.track_map.end(); ++it,++i) {
std::string index = it->first;
- if (drums != (index == "drums")) continue;
m_track_map.insert(make_pair(index, &it->second));
- if( i == track ) m_track_index = index;
+ if( index == track ) m_track_index = index;
+
+ // load required textures (even the unused)
if (index == "drums") m_necks.insert(index, new Texture("drumneck.svg"));
else if (index == "bass") m_necks.insert(index, new Texture("bassneck.svg"));
else m_necks.insert(index, new Texture("guitarneck.svg"));
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index b965104..889b1ca 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -43,7 +43,7 @@ static inline bool operator==(Chord const& a, Chord const& b) {
class GuitarGraph {
public:
/// constructor
- GuitarGraph(Audio& audio, Song const& song, bool drums, unsigned num);
+ GuitarGraph(Audio& audio, Song const& song, std::string track);
/** draws GuitarGraph
* @param time at which time to draw
*/
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 0ca3028..eed1cd9 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -34,13 +34,17 @@ void ScreenSing::enter() {
m_layout_singer.reset(new LayoutSinger(*m_song, m_players, theme));
// I know some purists would hang me for this loop
if( !m_song->track_map.empty() ) {
- bool drums = false;
- for (int num = 0; true; ++num) {
+ // 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";
+ while (1) {
try {
Instruments::iterator it = m_instruments.end();
- if (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, drums, num));
- } catch (std::runtime_error&) { if (drums) break; drums = true; }
+ 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_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
|