highscore is marked as online when using online mode

main
Martin Felis 2011-03-27 22:16:19 +02:00
parent 729518af7f
commit 1c6cb70590
3 changed files with 22 additions and 1 deletions

View File

@ -45,6 +45,7 @@ int Model::OnInit (int argc, char* argv[]) {
// Reset the newest highscore entry index which may be used for highlighting // Reset the newest highscore entry index which may be used for highlighting
// the newest entry. // the newest entry.
mNewestHighscoreEntryIndex = std::numeric_limits<unsigned int>::max(); mNewestHighscoreEntryIndex = std::numeric_limits<unsigned int>::max();
mHighscoreIsOnline = false;
// initialize event handlers and register them // initialize event handlers and register them
Engine::RegisterListener (this, EventGameOver); Engine::RegisterListener (this, EventGameOver);
@ -188,12 +189,15 @@ void Model::LoadHighscoreList () {
AddLocalHighscoreEntry ("Jabba the Hutt", 1000); AddLocalHighscoreEntry ("Jabba the Hutt", 1000);
} }
mHighscoreIsOnline = false;
if (Model::UseServerHighscore.GetBoolValue()) { if (Model::UseServerHighscore.GetBoolValue()) {
Engine::LogDebug ("Retrieving Highscore from server"); Engine::LogDebug ("Retrieving Highscore from server");
std::stringstream global_highscore_stream; std::stringstream global_highscore_stream;
if (PullGlobalHighscore(global_highscore_stream)) { if (PullGlobalHighscore(global_highscore_stream)) {
ParseHighscoreStream(global_highscore_stream); ParseHighscoreStream(global_highscore_stream);
mHighscoreIsOnline = true;
return; return;
} }

View File

@ -73,6 +73,7 @@ class Model : public Engine::ModelBase {
unsigned int AddLocalHighscoreEntry(const std::string &name, const unsigned int points); unsigned int AddLocalHighscoreEntry(const std::string &name, const unsigned int points);
void LoadLocalHighscoreList (); void LoadLocalHighscoreList ();
void SaveLocalHighscoreList (); void SaveLocalHighscoreList ();
bool GetHighscoreIsOnline() { return mHighscoreIsOnline; };
std::list<HighscoreEntry> mHighscoreList; std::list<HighscoreEntry> mHighscoreList;
unsigned int mNewestHighscoreEntryIndex; unsigned int mNewestHighscoreEntryIndex;
@ -111,6 +112,8 @@ class Model : public Engine::ModelBase {
static Engine::Variable UseServerHighscore; static Engine::Variable UseServerHighscore;
static Engine::Variable UseServerHighscoreAsked; static Engine::Variable UseServerHighscoreAsked;
bool mHighscoreIsOnline;
virtual bool OnReceiveEvent (const Engine::EventBasePtr &event); virtual bool OnReceiveEvent (const Engine::EventBasePtr &event);
friend class View; friend class View;

View File

@ -852,8 +852,22 @@ void View::DrawHighscoreEntry (float x, float y, float entry_width, const std::s
void View::DrawUiHighscore() { void View::DrawUiHighscore() {
DrawPageTitle ("Highscores"); DrawPageTitle ("Highscores");
SelectFont ("console.ttf size=23");
if (GetModel()->GetHighscoreIsOnline()) {
SelectFont("console.ttf size=23 color=#006600");
std::string title= "-online-";
float width, height;
DrawGLStringMeasure(title.c_str(), &width, &height);
float xpos = (screen_right - width) * 0.5 - 40;
float ypos = 130;
Engine::GUI::Label (4, title.c_str(), xpos - 2, ypos + 2);
SelectFont("console.ttf size=23 color=#00cf00");
Engine::GUI::Label (4, title.c_str(), xpos, ypos);
}
SelectFont ("console.ttf size=23");
unsigned int entry_length = 32; unsigned int entry_length = 32;
float char_width, height; float char_width, height;
DrawGLStringMeasure ("M", &char_width, &height); DrawGLStringMeasure ("M", &char_width, &height);