|
From: Tapio V. <aa...@us...> - 2009-11-13 15:48:35
|
Module: performous
Branch: master
Commit: f054d79681581dfbe14138447a4bf8c31dded056
Author: Tapio Vierros <tap...@gm...>
Date: Fri Nov 13 17:47:48 2009 +0200
Preliminary support for displaying instruments in ScoreWindow.
---
game/database.hh | 3 ++-
game/glutil.hh | 2 +-
game/screen_sing.cc | 15 ++++++++-------
game/screen_sing.hh | 2 +-
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/game/database.hh b/game/database.hh
index c1be3de..f23da1d 100644
--- a/game/database.hh
+++ b/game/database.hh
@@ -6,12 +6,13 @@
#include "players.hh"
#include "hiscore.hh"
#include "songitems.hh"
-
+#include "glutil.hh"
#include "fs.hh"
struct ScoreItem {
int score;
std::string track;
+ glutil::Color color;
bool operator < (ScoreItem const& other)
{
return score < other.score;
diff --git a/game/glutil.hh b/game/glutil.hh
index 94cc921..ad7f309 100644
--- a/game/glutil.hh
+++ b/game/glutil.hh
@@ -63,7 +63,7 @@ namespace glutil {
b, ///< blue
a; ///< alpha value
/// create nec Color object with given channels
- Color(float r_, float g_, float b_, float a_ = 1.0): r(r_), g(g_), b(b_), a(a_) {}
+ Color(float r_ = 0.0, float g_ = 0.0, float b_ = 0.0, float a_ = 1.0): r(r_), g(g_), b(b_), a(a_) {}
/// overload float cast
operator float*() { return reinterpret_cast<float*>(this); }
/// overload float const cast
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 8cf0e6c..9dec6fd 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -8,7 +8,7 @@
#include "database.hh"
#include "video.hh"
#include "guitargraph.hh"
-
+#include "glutil.hh"
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
@@ -328,7 +328,8 @@ ScoreWindow::ScoreWindow(Instruments& instruments, Database& database):
ScoreItem item;
item.score = p->getScore();
item.track = "vocals";
-
+ item.color = glutil::Color(p->m_color.r, p->m_color.g, p->m_color.b);
+
if (item.score < 500) { p = m_database.cur.erase(p); continue; }
m_database.scores.push_back(item);
if (item.score > topScore) topScore = item.score;
@@ -350,7 +351,7 @@ ScoreWindow::ScoreWindow(Instruments& instruments, Database& database):
m_database.scores.reverse(); // top should be first
// topScore is also in m_database.scores.front()
- if (m_database.cur.empty()) m_rank = "No singer!";
+ if (m_database.scores.empty()) m_rank = "No player!";
else if (topScore > 8000) m_rank = "Hit singer";
else if (topScore > 6000) m_rank = "Lead singer";
else if (topScore > 4000) m_rank = "Rising star";
@@ -364,12 +365,12 @@ void ScoreWindow::draw() {
glutil::PushMatrix block;
glTranslatef(0.0, m_pos.get(), 0.0);
m_bg.draw();
- const double spacing = 0.1 + 0.1 / m_database.cur.size();
+ const double spacing = 0.1 + 0.1 / m_database.scores.size();
unsigned i = 0;
- for (std::list<Player>::const_iterator p = m_database.cur.begin(); p != m_database.cur.end(); ++p, ++i) {
- int score = p->getScore();
- glColor3f(p->m_color.r, p->m_color.g, p->m_color.b);
+ for (Database::cur_scores_t::const_iterator p = m_database.scores.begin(); p != m_database.scores.end(); ++p, ++i) {
+ int score = p->score;
+ glColor4fv(p->color);
double x = -0.12 + spacing * (0.5 + i - 0.5 * m_database.cur.size());
m_scoreBar.dimensions.middle(x).bottom(0.24);
m_scoreBar.draw(score / 10000.0);
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index 8663473..56b73aa 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -31,7 +31,7 @@ class ScoreWindow {
ScoreWindow(Instruments& instruments, Database& database);
/// draws ScoreWindow
void draw();
- bool empty() { return m_database.cur.empty(); }
+ bool empty() { return m_database.scores.empty(); }
private:
Database& m_database;
AnimValue m_pos;
|