SuperTuxKart
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Highscores Class Reference

Represents one highscore entry, i.e. More...

#include <highscores.hpp>

Public Types

enum  SortOrder {
  SO_DEFAULT , SO_TRACK = SO_DEFAULT , SO_KART_NUM , SO_DIFF ,
  SO_LAPS , SO_REV
}
 Order of sort for Highscores.
 
enum  { HIGHSCORE_LEN = 5 }
 
typedef std::string HighscoreType
 

Public Member Functions

bool operator< (const Highscores &hi) const
 
 Highscores (const Highscores::HighscoreType &highscore_type, int num_karts, const RaceManager::Difficulty &difficulty, const std::string &trackName, const int number_of_laps, const bool reverse)
 Creates a new entry.
 
 Highscores (int num_karts, const RaceManager::Difficulty &difficulty, const std::string &trackName, const int target, const GrandPrixData::GPReverseType reverse_type, RaceManager::MinorRaceModeType minor_mode)
 Constructor for grandprix highscores.
 
 Highscores (const XMLNode &node)
 Creates an entry from a file.
 
void readEntry (const XMLNode &node)
 
void writeEntry (UTFWriter &writer)
 Writes the highscores in this entry to the writer.
 
int matches (const HighscoreType &highscore_type, int num_karts, const RaceManager::Difficulty &difficulty, const std::string &track, const int number_of_laps, const bool reverse)
 
int matches (int num_karts, const RaceManager::Difficulty &difficulty, const std::string &track, const int target, const GrandPrixData::GPReverseType reverse_type, RaceManager::MinorRaceModeType minor_mode)
 matches method for grandprix highscores
 
int addData (const std::string &kart_name, const irr::core::stringw &name, const float time)
 Inserts the data into the highscore list.
 
int addGPData (const std::string &kart_name, const irr::core::stringw &name, std::string gp_name, const float time)
 
int getNumberEntries () const
 
void getEntry (int number, std::string &kart_name, irr::core::stringw &name, float *const time) const
 

Static Public Member Functions

static bool compare (const std::unique_ptr< Highscores > &a, const std::unique_ptr< Highscores > &b)
 
static void setSortOrder (SortOrder so)
 

Public Attributes

std::string m_track
 
HighscoreType m_highscore_type
 
int m_number_of_karts
 
int m_difficulty
 
int m_number_of_laps
 
bool m_reverse
 
int m_gp_reverse_type
 
int m_gp_minor_mode
 

Private Member Functions

int findHighscorePosition (const std::string &kart_name, const core::stringw &name, const float time)
 

Private Attributes

std::array< std::string, HIGHSCORE_LEN > m_kart_name
 
std::array< stringw, HIGHSCORE_LEN > m_name
 
std::array< float, HIGHSCORE_LEN > m_time
 

Static Private Attributes

static SortOrder m_sort_order = Highscores::SO_DEFAULT
 

Detailed Description

Represents one highscore entry, i.e.

the (atm up to five) highscores for a particular setting (track, #karts, difficulty etc).

Member Function Documentation

◆ addData()

int Highscores::addData ( const std::string &  kart_name,
const irr::core::stringw &  name,
const float  time 
)

Inserts the data into the highscore list.

If the new entry is fast enough to be in the highscore list, the new position (1-HIGHSCORE_LEN) is returned, otherwise a 0.

◆ writeEntry()

void Highscores::writeEntry ( UTFWriter writer)

Writes the highscores in this entry to the writer.

It will only write anything if there is actually a highscore recored (i.e. time >=0). Empty entries are created e.g. when changing the number of laps in the GUI, resulting in empty entries here.

Parameters
writerThe file stream to write the data to.

The documentation for this class was generated from the following files: