SuperTuxKart
highscores.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2006-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_HIGHSCORES_HPP
20 #define HEADER_HIGHSCORES_HPP
21 #include <string>
22 #include <vector>
23 #include <map>
24 
25 #include "race/race_manager.hpp"
26 
27 #include <irrString.h>
28 
29 class XMLNode;
30 class UTFWriter;
31 
38 {
39 public:
40  typedef std::string HighscoreType;
41 
42 private:
43  enum {HIGHSCORE_LEN = 5}; // It's a top 5 list
44  std::string m_track;
45  HighscoreType m_highscore_type;
46  int m_number_of_karts;
47  int m_difficulty;
48  int m_number_of_laps;
49  bool m_reverse;
50  std::string m_kart_name[HIGHSCORE_LEN];
51  irr::core::stringw m_name[HIGHSCORE_LEN];
52  float m_time[HIGHSCORE_LEN];
53 public:
56  Highscores (const Highscores::HighscoreType &highscore_type,
57  int num_karts, const RaceManager::Difficulty &difficulty,
58  const std::string &trackName, const int number_of_laps,
59  const bool reverse);
62  Highscores (const XMLNode &node);
63 
64  void readEntry (const XMLNode &node);
65  void writeEntry(UTFWriter &writer);
66  int matches (const HighscoreType &highscore_type, int num_karts,
67  const RaceManager::Difficulty &difficulty,
68  const std::string &track, const int number_of_laps,
69  const bool reverse);
70  int addData (const std::string& kart_name,
71  const irr::core::stringw& name, const float time);
72  int getNumberEntries() const;
73  void getEntry (int number, std::string &kart_name,
74  irr::core::stringw &name, float *const time) const;
75 }; // Highscores
76 
77 #endif
Difficulty
Game difficulty.
Definition: race_manager.hpp:224
utility class used to write wide (UTF-16 or UTF-32, depending of size of wchar_t) XML files
Definition: utf_writer.hpp:34
void writeEntry(UTFWriter &writer)
Writes the highscores in this entry to the writer.
Definition: highscores.cpp:115
int addData(const std::string &kart_name, const irr::core::stringw &name, const float time)
Inserts the data into the highscore list.
Definition: highscores.cpp:164
Represents one highscore entry, i.e.
Definition: highscores.hpp:37
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.
Definition: highscores.cpp:30
utility class used to parse XML files
Definition: xml_node.hpp:47