Highscores are now displayed in the track screen
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3951 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
0db37d90fb
commit
870c470eab
@ -143,7 +143,7 @@ void FollowTheLeaderRace::restartRace()
|
||||
*/
|
||||
std::string FollowTheLeaderRace::getIdent() const
|
||||
{
|
||||
return "FOLLOW_LEADER";
|
||||
return FTL_IDENT;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
RaceGUI::KartIconDisplayInfo* FollowTheLeaderRace::getKartsDisplayInfo()
|
||||
|
@ -25,6 +25,7 @@ class FollowTheLeaderRace : public LinearWorld
|
||||
{
|
||||
std::vector<float> m_leader_intervals; // time till elimination in follow leader
|
||||
public:
|
||||
|
||||
FollowTheLeaderRace();
|
||||
virtual ~FollowTheLeaderRace();
|
||||
|
||||
|
@ -123,7 +123,8 @@ bool StandardRace::haveBonusBoxes()
|
||||
std::string StandardRace::getIdent() const
|
||||
{
|
||||
if(race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
|
||||
return "STD_TIMETRIAL";
|
||||
return IDENT_TTRIAL;
|
||||
else
|
||||
return "STANDARD";
|
||||
return IDENT_STD;
|
||||
|
||||
} // getIdent
|
||||
|
@ -129,7 +129,7 @@ void ThreeStrikesBattle::kartHit(const int kart_id)
|
||||
*/
|
||||
std::string ThreeStrikesBattle::getIdent() const
|
||||
{
|
||||
return "BATTLE_3_STRIKES";
|
||||
return STRIKES_IDENT;
|
||||
} // getIdent
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -39,6 +39,7 @@ class ThreeStrikesBattle : public World
|
||||
std::vector<BattleInfo> m_kart_info;
|
||||
|
||||
public:
|
||||
|
||||
ThreeStrikesBattle();
|
||||
virtual ~ThreeStrikesBattle();
|
||||
|
||||
|
@ -87,6 +87,25 @@ public:
|
||||
|
||||
MINOR_MODE_3_STRIKES = BATTLE_ARENA(0)
|
||||
};
|
||||
|
||||
// Stupid C++ doesn't accept string constants
|
||||
#define IDENT_STD "STANDARD"
|
||||
#define IDENT_TTRIAL "STD_TIMETRIAL"
|
||||
#define FTL_IDENT "FOLLOW_LEADER"
|
||||
#define STRIKES_IDENT "BATTLE_3_STRIKES"
|
||||
|
||||
static const char* getIdentOf(const MinorRaceModeType mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case MINOR_MODE_QUICK_RACE: return IDENT_STD;
|
||||
case MINOR_MODE_TIME_TRIAL: return IDENT_TTRIAL;
|
||||
case MINOR_MODE_FOLLOW_LEADER: return FTL_IDENT;
|
||||
case MINOR_MODE_3_STRIKES: return STRIKES_IDENT;
|
||||
default: assert(false); return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#undef LINEAR_RACE
|
||||
#undef BATTLE_ARENA
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "race/highscores.hpp"
|
||||
#include "race/highscore_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/dialogs/track_info_dialog.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
@ -74,9 +76,45 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac
|
||||
m_irrlicht_window);
|
||||
a->setTabStop(false);
|
||||
|
||||
// ======== High Scores
|
||||
std::string game_mode_ident = RaceManager::getIdentOf( race_manager->getMinorMode() );
|
||||
const HighscoreEntry::HighscoreType type = "HST_" + game_mode_ident;
|
||||
|
||||
HighscoreEntry* highscores = highscore_manager->getHighscoreEntry(type,
|
||||
race_manager->getNumKarts(),
|
||||
race_manager->getDifficulty(),
|
||||
trackIdent,
|
||||
race_manager->getNumLaps());
|
||||
|
||||
// TODO: update highscores display when number of laps changes
|
||||
const int amount = highscores->getNumberEntries();
|
||||
stringw highscores_string = "= Highscores =\n";
|
||||
std::cout << "====== Highscores =====\n";
|
||||
std::cout << "Checking for highscores of type " << type.c_str() << " with nkarts=" << race_manager->getNumKarts()
|
||||
<< ", difficulty=" << race_manager->getDifficulty() << ", track=" << trackIdent.c_str()
|
||||
<< ", nlaps=" << race_manager->getNumLaps() << std::endl;
|
||||
std::cout << "Got " << amount << " entries\n";
|
||||
|
||||
std::string kart_name;
|
||||
std::string name;
|
||||
float time;
|
||||
|
||||
char buffer[512];
|
||||
for (int n=0; n<amount; n++)
|
||||
{
|
||||
highscores->getEntry(n, kart_name, name, &time);
|
||||
|
||||
sprintf(buffer, "%s (%s) : %.2f\n", kart_name.c_str(), name.c_str(), time);
|
||||
|
||||
std::cout << buffer << std::endl;
|
||||
highscores_string += buffer;
|
||||
}
|
||||
std::cout << "======================\n";
|
||||
|
||||
|
||||
|
||||
core::rect< s32 > area_left(0, y1, m_area.getWidth()/2, y2);
|
||||
IGUIStaticText* b = GUIEngine::getGUIEnv()->addStaticText( stringw(_("High Scores & Track Info")).c_str(),
|
||||
IGUIStaticText* b = GUIEngine::getGUIEnv()->addStaticText( highscores_string.c_str(),
|
||||
area_left, false , true , // border, word warp
|
||||
m_irrlicht_window);
|
||||
b->setTabStop(false);
|
||||
|
Loading…
Reference in New Issue
Block a user