|
From: Markus R. <god...@us...> - 2009-07-29 15:35:36
|
Module: performous
Branch: master
Commit: 47b8558e3ab57ae277564e032695feea26aa69e7
Author: Markus Raab <un...@ma...>
Date: Sat Jul 25 12:09:57 2009 +0200
only show highscore when reached
better output
+ more debug
---
game/engine.hh | 4 ++++
game/screen_players.cc | 11 ++++-------
game/screen_sing.cc | 17 +++++++++++++++++
3 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/game/engine.hh b/game/engine.hh
index 83b247f..19c91ef 100644
--- a/game/engine.hh
+++ b/game/engine.hh
@@ -46,6 +46,10 @@ class Engine {
template <typename FwdIt> Engine(Audio& audio, Song& song, FwdIt anBegin, FwdIt anEnd, Players &players):
m_audio(audio), m_song(song), m_time(), m_quit(), m_players(players)
{
+ // clear old player information
+ m_players.cur.clear();
+ m_players.scores.clear();
+
size_t frames = m_audio.getLength() / Engine::TIMESTEP;
while (anBegin != anEnd) m_players.cur.push_back(Player(song, *anBegin++, frames));
size_t player = 0;
diff --git a/game/screen_players.cc b/game/screen_players.cc
index 8623b81..4b8a59e 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -78,9 +78,6 @@ else if (key == SDLK_ESCAPE) {
if (m_players.scores.empty() || !m_highscore->reachedNewHighscore(m_players.scores.front()))
{
// no more highscore, we are now finished
- // clear the old players lists
- m_players.scores.clear();
- m_players.cur.clear();
sm->activateScreen("Songs");
} else {
std::cout << "enter the next highscore" << std::endl;
@@ -112,14 +109,14 @@ void ScreenPlayers::draw() {
oss_order << "Check players.txt in current\n";
oss_order << "directory for players";
} else {
- oss_song << "press enter to create player";
+ oss_song << "Press enter to create player!";
oss_order << m_search.text << '\n';
}
} else {
// Format the player information text
- oss_song << "You reached " << m_players.scores.front() << " points\n";
- oss_order << "Name: " << m_players.current().name
- << " Search Text: "
+ oss_song << "You reached " << m_players.scores.front() << " points!\n";
+ oss_order << "Name: " << m_players.current().name << '\n'
+ << "Search Text: "
<< (m_search.text.empty() ? std::string("new player") : m_search.text)
<< '\n';
oss_order << "(" << m_players.currentId() + 1 << "/" << m_players.size() << ")";
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 795b5b6..10f6e5e 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -8,6 +8,7 @@
#include "songs.hh"
#include <iostream>
#include <iomanip>
+#include "highscore.hh" // to check if Players have to be shown
namespace {
static const double QUIT_TIMEOUT = 20.0; // Return to songs screen after 20 seconds in score screen
@@ -70,12 +71,28 @@ void ScreenSing::manageEvent(SDL_Event event) {
else if (key == SDLK_RETURN) {
if (m_score_window.get())
{
+ // TODO: multiple loading...
+ HighScore hi(m_song->path, "High.sco");
+ try {
+ hi.load();
+ } catch (HighScoreException const& hi) {
+ std::cerr << "high.sco:" << hi.line() << " " << hi.what() << std::endl;
+ }
+
+ if (m_players.scores.empty() || !hi.reachedNewHighscore(m_players.scores.front()))
+ {
+ // if no highscore reached..
+ sm->activateScreen("Songs");
+ return;
+ }
+
// Score window visible -> Enter quits to Players Screen
Screen* s = sm->getScreen("Players");
ScreenPlayers* ss = dynamic_cast<ScreenPlayers*> (s);
assert(ss);
ss->setSong(m_song);
sm->activateScreen("Players");
+ return;
}
else if (status == Song::FINISHED) m_score_window.reset(new ScoreWindow(*m_engine, m_players)); // Song finished, but no score window -> show it
}
|