|
From: Tapio V. <aa...@us...> - 2009-11-08 08:30:16
|
Module: performous
Branch: dance
Commit: b90a83f550bd0fd6811a0953d7e90e222bbbe7a3
Author: Tapio Vierros <tap...@gm...>
Date: Wed Oct 28 23:25:47 2009 +0200
Singer text feedback is now only display for good grades. It also zooms and fades away.
---
game/layout_singer.cc | 19 ++++++++++---------
game/layout_singer.hh | 1 +
game/player.cc | 7 +++++--
game/player.hh | 5 ++++-
4 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/game/layout_singer.cc b/game/layout_singer.cc
index 97fcc50..99c8bb9 100644
--- a/game/layout_singer.cc
+++ b/game/layout_singer.cc
@@ -54,21 +54,22 @@ void LayoutSinger::drawScore(Position position) {
}
m_score_text[i%4]->draw();
// Give some feedback on how well the last lyrics row went
- if (p->m_prevLineScore >= 0) {
+ float fact = p->m_feedbackFader.get();
+ if (p->m_prevLineScore > 0.5 && fact > 0) {
std::string prevLineRank;
- if (p->m_prevLineScore > 0.9) { prevLineRank = "Perfect"; glColor4f(0.5, 1.0, 0.0, act); }
- else if (p->m_prevLineScore > 0.8) { prevLineRank = "Excellent"; glColor4f(0.2, 0.8, 0.2, act); }
- else if (p->m_prevLineScore > 0.6) { prevLineRank = "Good"; glColor4f(0.6, 1.0, 0.2, act); }
- else if (p->m_prevLineScore > 0.5) { prevLineRank = "Ok"; glColor4f(0.6, 1.0, 0.2, act); }
- else if (p->m_prevLineScore > 0.3) { prevLineRank = "Poor"; glColor4f(0.6, 0.8, 0.2, act); }
- else { prevLineRank = "Horrible"; glColor4f(0.5, 0.5, 0.3, act); }
+ float fzoom = fact / 2.0 + 0.5;
+ if (p->m_prevLineScore > 0.95) { prevLineRank = "Perfect"; glColor4f(0.5, 1.0, 0.0, fact); }
+ else if (p->m_prevLineScore > 0.9) { prevLineRank = "Super"; glColor4f(0.4, 0.9, 0.0, fact); }
+ else if (p->m_prevLineScore > 0.8) { prevLineRank = "Excellent"; glColor4f(0.2, 0.8, 0.2, fact); }
+ else if (p->m_prevLineScore > 0.6) { prevLineRank = "Good"; glColor4f(0.6, 1.0, 0.2, fact); }
+ else if (p->m_prevLineScore > 0.5) { prevLineRank = "Ok"; glColor4f(0.6, 1.0, 0.2, fact); }
m_line_rank_text[i%4]->render(prevLineRank);
switch(position) {
case LayoutSinger::BOTTOM:
- m_line_rank_text[i%4]->dimensions().middle(-0.350 + 0.01 + 0.25 * i).fixedHeight(0.055).screenTop(0.11);
+ m_line_rank_text[i%4]->dimensions().middle(-0.350 + 0.01 + 0.25 * i).fixedHeight(0.055*fzoom).screenTop(0.11);
break;
case LayoutSinger::MIDDLE:
- m_line_rank_text[i%4]->dimensions().right(0.45).fixedHeight(0.04).screenTop(0.060 + 0.050 * i);
+ m_line_rank_text[i%4]->dimensions().right(0.45).fixedHeight(0.04*fzoom).screenTop(0.060 + 0.050 * i);
break;
}
m_line_rank_text[i%4]->draw();
diff --git a/game/layout_singer.hh b/game/layout_singer.hh
index 85823a1..d03a341 100644
--- a/game/layout_singer.hh
+++ b/game/layout_singer.hh
@@ -64,4 +64,5 @@ class LayoutSinger {
boost::scoped_ptr<SvgTxtThemeSimple> m_line_rank_text[4];
Players& m_players;
boost::shared_ptr<ThemeSing> m_theme;
+ AnimValue m_feedbackFader;
};
diff --git a/game/player.cc b/game/player.cc
index fa3a751..5a71639 100644
--- a/game/player.cc
+++ b/game/player.cc
@@ -31,9 +31,12 @@ void Player::update() {
m_maxLineScore += m_song.m_scoreFactor * maxScoreIt->maxScore();
maxScoreIt++;
}
- if (m_maxLineScore > 0)
+ if (m_maxLineScore > 0) {
m_prevLineScore /= m_maxLineScore;
- else m_prevLineScore = -1;
+ m_feedbackFader.setValue(1.0);
+ } else {
+ m_prevLineScore = -1;
+ }
m_lineScore = 0;
}
} else {
diff --git a/game/player.hh b/game/player.hh
index 340326b..5b75fd1 100644
--- a/game/player.hh
+++ b/game/player.hh
@@ -3,6 +3,7 @@
#include "color.hh"
#include "pitch.hh"
#include "util.hh"
+#include "animvalue.hh"
#include <vector>
@@ -28,6 +29,8 @@ struct Player {
double m_maxLineScore;
/// score for the previous line (normalized [0,1])
double m_prevLineScore;
+ /// fader for text feedback display
+ AnimValue m_feedbackFader;
/// activity timer
unsigned m_activitytimer;
/// score iterator
@@ -36,7 +39,7 @@ struct Player {
Player(Song& song, Analyzer& analyzer, size_t frames):
m_song(song), m_analyzer(analyzer), m_pitch(frames, std::make_pair(getNaN(),
-getInf())), m_pos(), m_score(), m_lineScore(), m_maxLineScore(), m_prevLineScore(-1),
- m_activitytimer(), m_scoreIt(m_song.notes.begin()) {}
+ m_feedbackFader(0.0, 0.5), m_activitytimer(), m_scoreIt(m_song.notes.begin()) {}
/// prepares analyzer
void prepare() { m_analyzer.process(); }
/// updates player stats
|