SuperTuxKart
Loading...
Searching...
No Matches
highscore_manager.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_HIGHSCORE_MANAGER_HPP
20#define HEADER_HIGHSCORE_MANAGER_HPP
21
22#include <string>
23#include <vector>
24#include <map>
25#include <memory>
26
27#include "race/highscores.hpp"
28
36{
37public:
38private:
39 static const unsigned int CURRENT_HSCORE_FILE_VERSION;
40 std::vector<std::unique_ptr<Highscores> > m_all_scores;
41
42 std::string m_filename;
43 bool m_can_write;
44
45 void setFilename();
46
47public:
50 // ------------------------------------------------------------------------
51 void loadHighscores();
52 // ------------------------------------------------------------------------
53 void saveHighscores();
54 // ------------------------------------------------------------------------
55 Highscores *getHighscores(const Highscores::HighscoreType &highscore_type,
56 int num_karts,
57 const RaceManager::Difficulty difficulty,
58 const std::string &trackName,
59 const int number_of_laps,
60 const bool reverse);
61 // ------------------------------------------------------------------------
63 Highscores *getGPHighscores(int num_karts,
64 const RaceManager::Difficulty difficulty,
65 const std::string &trackName,
66 const int target,
69 // ------------------------------------------------------------------------
70 void deleteHighscores(int i) { m_all_scores.erase
71 (m_all_scores.begin() + i); }
72 // ------------------------------------------------------------------------
73 void clearHighscores() { m_all_scores.clear(); }
74 // ------------------------------------------------------------------------
75 bool highscoresEmpty() { return m_all_scores.empty(); }
76 // ------------------------------------------------------------------------
77 Highscores* getHighscoresAt(int i) { return m_all_scores.at(i).get(); }
78 // ------------------------------------------------------------------------
79 int highscoresSize() { return m_all_scores.size(); }
80 // ------------------------------------------------------------------------
81 void sortHighscores(bool reverse)
82 {
83 (reverse ? std::stable_sort(m_all_scores.rbegin(),
84 m_all_scores.rend(), Highscores::compare) :
85 std::stable_sort(m_all_scores.begin(),
86 m_all_scores.end(), Highscores::compare));
87 }
88}; // HighscoreManager
89
90extern HighscoreManager* highscore_manager;
91#endif
GPReverseType
Used to define the reverse setting when creating a random GP: No reverse, all reverse (if available o...
Definition: grand_prix_data.hpp:89
This class reads and writes the 'highscores.xml' file, and also takes care of dealing with new record...
Definition: highscore_manager.hpp:36
void setFilename()
Determines the path to store the highscore file in.
Definition: highscore_manager.cpp:55
Highscores * getGPHighscores(int num_karts, const RaceManager::Difficulty difficulty, const std::string &trackName, const int target, GrandPrixData::GPReverseType reverse_type, RaceManager::MinorRaceModeType minor_mode)
getHighscores method for grandprix highscores
Definition: highscore_manager.cpp:209
Represents one highscore entry, i.e.
Definition: highscores.hpp:41
MinorRaceModeType
Minor variants to the major types of race.
Definition: race_manager.hpp:110
Difficulty
Game difficulty.
Definition: race_manager.hpp:230