|
From: Yoda-JM <yo...@us...> - 2010-04-05 10:36:47
|
Module: performous
Branch: master
Commit: c9695e39b061bfffea6ee9274f027c11f11a9e83
Author: Vincent Le Ligeour <yo...@us...>
Date: Mon Apr 5 12:36:32 2010 +0200
Fixed filtering by instrument not being displayed when no song is found
---
game/screen_songs.cc | 41 ++++++++++++++++++++++++++++-------------
game/screen_songs.hh | 2 +-
2 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/game/screen_songs.cc b/game/screen_songs.cc
index 292feab..bcccf25 100644
--- a/game/screen_songs.cc
+++ b/game/screen_songs.cc
@@ -264,7 +264,7 @@ void ScreenSongs::draw() {
theme->order.draw(oss_order.str());
theme->has_hiscore.draw(oss_has_hiscore.str());
} else theme->hiscores.draw(oss_order.str());
- if (!m_songs.empty()&&!show_hiscores) drawInstruments(m_songs.current(), Dimensions(m_instrumentList->ar()).fixedHeight(0.03).center(-0.04));
+ if (!show_hiscores) drawInstruments(Dimensions(m_instrumentList->ar()).fixedHeight(0.03).center(-0.04));
}
stopMultimedia(info);
if (m_jukebox) {
@@ -277,18 +277,37 @@ void ScreenSongs::draw() {
} else if (!m_audio.isPaused() && m_playTimer.get() > IDLE_TIMEOUT) m_songs.advance(1); // Switch if song hasn't changed for IDLE_TIMEOUT seconds
}
-void ScreenSongs::drawInstruments(Song const& song, Dimensions const& dim, float alpha) const {
+void ScreenSongs::drawInstruments(Dimensions const& dim, float alpha) const {
+
+ bool have_vocals = false;
+ bool have_bass = false;
+ bool have_drums = false;
+ bool have_dance = false;
+ bool is_karaoke = false;
+ unsigned char typeFilter = m_songs.getTypeFilter();
+ int guitarCount = 0;
+
+ if( !m_songs.empty() ) {
+ Song const& song = m_songs.current();
+ have_vocals = song.hasVocals();
+ have_bass = isTrackInside(song.track_map,"bass");
+ have_drums = song.hasDrums();
+ have_dance = song.hasDance();
+ is_karaoke = (song.music.find("vocals") != song.music.end());
+ if (isTrackInside(song.track_map,"guitar")) guitarCount++;
+ if (isTrackInside(song.track_map,"coop guitar")) guitarCount++;
+ if (isTrackInside(song.track_map,"rhythm guitar")) guitarCount++;
+ }
+
UseTexture tex(*m_instrumentList);
double x;
float xincr = 0.2f;
- unsigned char typeFilter = m_songs.getTypeFilter();
{
// vocals
- float a = alpha * (song.hasVocals() ? 1.00 : 0.25);
+ float a = alpha * (have_vocals ? 1.00 : 0.25);
float m = !(typeFilter & 8);
- bool karaoke = (song.music.find("vocals") != song.music.end());
glutil::Begin block(GL_TRIANGLE_STRIP);
- glColor4f(m * 1.0f, 1.0f, m * (karaoke ? 0.25f : 1.0f), a);
+ glColor4f(m * 1.0f, 1.0f, m * (is_karaoke ? 0.25f : 1.0f), a);
x = dim.x1()+0.00*(dim.x2()-dim.x1());
glTexCoord2f(getIconTex(1), 0.0f); glVertex2f(x, dim.y1());
glTexCoord2f(getIconTex(1), 1.0f); glVertex2f(x, dim.y2());
@@ -300,10 +319,6 @@ void ScreenSongs::drawInstruments(Song const& song, Dimensions const& dim, float
// guitars
float a = alpha;
float m = !(typeFilter & 4);
- int guitarCount = 0;
- if (isTrackInside(song.track_map,"guitar")) guitarCount++;
- if (isTrackInside(song.track_map,"coop guitar")) guitarCount++;
- if (isTrackInside(song.track_map,"rhythm guitar")) guitarCount++;
if (guitarCount == 0) { guitarCount = 1; a *= 0.25f; }
for (int i = guitarCount-1; i >= 0; i--) {
glutil::Begin block(GL_TRIANGLE_STRIP);
@@ -318,7 +333,7 @@ void ScreenSongs::drawInstruments(Song const& song, Dimensions const& dim, float
}
{
// bass
- float a = alpha * (isTrackInside(song.track_map,"bass") ? 1.00f : 0.25f);
+ float a = alpha * (have_bass ? 1.00f : 0.25f);
float m = !(typeFilter & 4);
glutil::Begin block(GL_TRIANGLE_STRIP);
glColor4f(m * 1.0f, 1.0f, m * 1.0f, a);
@@ -331,7 +346,7 @@ void ScreenSongs::drawInstruments(Song const& song, Dimensions const& dim, float
}
{
// drums
- float a = alpha * (song.hasDrums() ? 1.00f : 0.25f);
+ float a = alpha * (have_drums ? 1.00f : 0.25f);
float m = !(typeFilter & 2);
glutil::Begin block(GL_TRIANGLE_STRIP);
glColor4f(m * 1.0f, 1.0f, m * 1.0f, a);
@@ -344,7 +359,7 @@ void ScreenSongs::drawInstruments(Song const& song, Dimensions const& dim, float
}
{
// dancing
- float a = alpha * (song.hasDance() ? 1.00f : 0.25f);
+ float a = alpha * (have_dance ? 1.00f : 0.25f);
float m = !(typeFilter & 1);
glutil::Begin block(GL_TRIANGLE_STRIP);
glColor4f(m * 1.0f, 1.0f, m * 1.0f, a);
diff --git a/game/screen_songs.hh b/game/screen_songs.hh
index 0470489..ed00a63 100644
--- a/game/screen_songs.hh
+++ b/game/screen_songs.hh
@@ -36,7 +36,7 @@ public:
void drawJukebox(); ///< draw the songbrowser in jukebox mode (fullscreen, full previews, ...)
protected:
- void drawInstruments(Song const& song, Dimensions const& dim, float alpha = 1.0f) const;
+ void drawInstruments(Dimensions const& dim, float alpha = 1.0f) const;
void drawMultimedia();
void updateMultimedia(Song& song, ScreenSharedInfo& info);
void stopMultimedia(ScreenSharedInfo& info);
|