|
From: Tapio V. <aa...@us...> - 2009-12-01 14:50:57
|
Module: performous
Branch: dance
Commit: efef3d4a99a3cf4234a27489cc7eaa65958c6ccb
Author: Tapio Vierros <tap...@gm...>
Date: Tue Dec 1 11:58:04 2009 +0200
Dancers are drawn in ScoreWindow and included in HiScore.
---
game/dancegraph.cc | 3 +++
game/dancegraph.hh | 2 ++
game/database.hh | 1 +
game/screen_sing.cc | 34 ++++++++++++++++++++++++++++------
game/screen_sing.hh | 5 ++---
5 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 84587cc..51009ea 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -7,6 +7,7 @@
#include <stdexcept>
namespace {
+ const std::string diffv[] = { "Beginner", "Easy", "Medium", "Hard", "Challenge" };
const float past = -0.2f;
const float future = 1.8f;
const float offsetY = 1.8f; // TODO: more clever way to do this?
@@ -67,6 +68,8 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
}
+std::string DanceGraph::getDifficultyString() const { return diffv[m_level]; }
+
void DanceGraph::difficultyDelta(int delta) {
int newLevel = m_level + delta;
std::cout << "difficultyDelta called with " << delta << " (newLevel = " << newLevel << ")" << std::endl;
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 4805934..4b96a29 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -40,6 +40,8 @@ class DanceGraph {
unsigned stream() const { return m_stream; }
double correctness() const { return m_correctness.get(); }
int getScore() const { return m_score * m_scoreFactor; }
+ std::string getGameMode() const { return m_gamingMode; }
+ std::string getDifficultyString() const;
private:
enum DanceStep {
STEP_LEFT = 0,
diff --git a/game/database.hh b/game/database.hh
index 4463692..c61ae47 100644
--- a/game/database.hh
+++ b/game/database.hh
@@ -11,6 +11,7 @@
struct ScoreItem {
int score;
+ enum Type { SINGER, INSTRUMENT, DANCER } type;
std::string track; // includes difficulty
std::string track_simple; // no difficulty
glutil::Color color;
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index d3a4c98..2e490e8 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -204,7 +204,7 @@ void ScreenSing::manageEvent(SDL_Event event) {
if (m_score_window.get()) { activateNextScreen(); return; } // Score window visible -> Enter quits
else if (status == Song::FINISHED && m_song->track_map.empty()) {
m_engine->kill(); // kill the engine thread (to avoid consuming memory)
- m_score_window.reset(new ScoreWindow(m_instruments, m_database)); // Song finished, but no score window -> show it
+ m_score_window.reset(new ScoreWindow(m_instruments, m_database, m_dancers)); // Song finished, but no score window -> show it
}
}
else if (key == SDLK_SPACE && m_score_window.get()) { activateNextScreen(); return; } // Score window visible -> Space quits
@@ -332,7 +332,7 @@ void ScreenSing::draw() {
// Time to create the score window
m_quitTimer.setValue(QUIT_TIMEOUT);
m_engine->kill(); // kill the engine thread (to avoid consuming memory)
- m_score_window.reset(new ScoreWindow(m_instruments, m_database));
+ m_score_window.reset(new ScoreWindow(m_instruments, m_database, m_dancers));
}
}
@@ -342,7 +342,7 @@ void ScreenSing::draw() {
}
}
-ScoreWindow::ScoreWindow(Instruments& instruments, Database& database):
+ScoreWindow::ScoreWindow(Instruments& instruments, Database& database, Dancers& dancers):
m_database(database),
m_pos(0.8, 2.0),
m_bg(getThemePath("score_window.svg")),
@@ -352,8 +352,9 @@ ScoreWindow::ScoreWindow(Instruments& instruments, Database& database):
{
m_pos.setTarget(0.0);
m_database.scores.clear();
+ // Singers
for (std::list<Player>::iterator p = m_database.cur.begin(); p != m_database.cur.end();) {
- ScoreItem item;
+ ScoreItem item; item.type = ScoreItem::SINGER;
item.score = p->getScore();
item.track = "Vocals";
item.track_simple = "vocals";
@@ -363,8 +364,9 @@ ScoreWindow::ScoreWindow(Instruments& instruments, Database& database):
m_database.scores.push_back(item);
++p;
}
+ // Instruments
for (Instruments::iterator it = instruments.begin(); it != instruments.end();) {
- ScoreItem item;
+ ScoreItem item; item.type = ScoreItem::INSTRUMENT;
item.score = it->getScore();
item.track_simple = it->getTrack();
item.track = it->getTrack() + " - " + it->getDifficultyString();
@@ -378,6 +380,20 @@ ScoreWindow::ScoreWindow(Instruments& instruments, Database& database):
m_database.scores.push_back(item);
++it;
}
+ // Dancers
+ for (Dancers::iterator it = dancers.begin(); it != dancers.end();) {
+ ScoreItem item; item.type = ScoreItem::DANCER;
+ item.score = it->getScore();
+ item.track_simple = it->getGameMode();
+ item.track = it->getGameMode() + " - " + it->getDifficultyString();
+ item.track[0] = toupper(item.track[0]);
+ if (item.score < 100) { it = dancers.erase(it); continue; }
+
+ item.color = glutil::Color(1.0f, 0.4f, 0.1f);
+
+ m_database.scores.push_back(item);
+ ++it;
+ }
if (m_database.scores.empty())
m_rank = "No player!";
@@ -385,12 +401,18 @@ ScoreWindow::ScoreWindow(Instruments& instruments, Database& database):
m_database.scores.sort();
m_database.scores.reverse(); // top should be first
int topScore = m_database.scores.front().score;
- if (m_database.scores.front().track_simple == "vocals") {
+ if (m_database.scores.front().type == ScoreItem::SINGER) {
if (topScore > 8000) m_rank = "Hit singer";
else if (topScore > 6000) m_rank = "Lead singer";
else if (topScore > 4000) m_rank = "Rising star";
else if (topScore > 2000) m_rank = "Amateur";
else m_rank = "Tone deaf";
+ } else if (m_database.scores.front().type == ScoreItem::DANCER) {
+ if (topScore > 8000) m_rank = "Maniac";
+ else if (topScore > 6000) m_rank = "Hoofer";
+ else if (topScore > 4000) m_rank = "Rising star";
+ else if (topScore > 2000) m_rank = "Amateur";
+ else m_rank = "Loser";
} else {
if (topScore > 8000) m_rank = "Virtuoso";
else if (topScore > 6000) m_rank = "Rocker";
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index a5c2c8b..e819074 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -25,12 +25,13 @@ class Database;
class Video;
typedef boost::ptr_vector<GuitarGraph> Instruments;
+typedef boost::ptr_vector<DanceGraph> Dancers;
/// shows score at end of song
class ScoreWindow {
public:
/// constructor
- ScoreWindow(Instruments& instruments, Database& database);
+ ScoreWindow(Instruments& instruments, Database& database, Dancers& dancers);
/// draws ScoreWindow
void draw();
bool empty() { return m_database.scores.empty(); }
@@ -84,8 +85,6 @@ class ScreenSing: public Screen {
boost::scoped_ptr<Surface> m_help;
boost::scoped_ptr<Engine> m_engine;
boost::scoped_ptr<LayoutSinger> m_layout_singer;
- typedef boost::ptr_vector<GuitarGraph> Instruments;
- typedef boost::ptr_vector<DanceGraph> Dancers;
Instruments m_instruments;
Dancers m_dancers;
double m_latencyAV; // Latency between audio and video output (do not confuse with latencyAR)
|