SuperTuxKart
Loading...
Searching...
No Matches
grand_prix_manager.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2008-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_GRAND_PRIX_MANAGER_HPP
20#define HEADER_GRAND_PRIX_MANAGER_HPP
21
22#include "race/grand_prix_data.hpp"
23
24#include <vector>
25#include <string>
26#include "utils/ptr_vector.hpp"
27
28class GrandPrixData;
29
34{
35private:
36 static const char* SUFFIX;
37
39
41 void loadFiles();
43 void loadDir(const std::string& dir, enum GrandPrixData::GPGroupType group);
45 void load(const std::string &filename, enum GrandPrixData::GPGroupType group);
46
48 std::string generateId();
49
50public:
53 void reload();
54 bool existsName(const irr::core::stringw& name) const;
55 void checkConsistency();
56
57 // Methods for the gp editor
58 GrandPrixData* editGrandPrix(const std::string& s);
59 GrandPrixData* createNewGP(const irr::core::stringw& newName);
60 GrandPrixData* copy(const std::string& id,
61 const irr::core::stringw& newName);
62 void remove(const std::string& id);
63 // ------------------------------------------------------------------------
66 const GrandPrixData* getGrandPrix(const std::string& s) const;
67 // ------------------------------------------------------------------------
70 const GrandPrixData* getGrandPrix(const int i) const { return m_gp_data.get(i); }
71 // ------------------------------------------------------------------------
73 unsigned int getNumberOfGrandPrix() const { return (int)m_gp_data.size(); }
74}; // GrandPrixManager
75
76extern GrandPrixManager *grand_prix_manager;
77
78#endif
Simple class that hold the data relevant to a 'grand_prix', aka.
Definition: grand_prix_data.hpp:36
GPGroupType
Used to classify GPs into groups.
Definition: grand_prix_data.hpp:46
Definition: grand_prix_manager.hpp:34
const GrandPrixData * getGrandPrix(const int i) const
Returns a pointer to the data for the specified GP.
Definition: grand_prix_manager.hpp:70
void load(const std::string &filename, enum GrandPrixData::GPGroupType group)
Load a grand prix and add it to m_gp_data.
Definition: grand_prix_manager.cpp:84
const GrandPrixData * getGrandPrix(const std::string &s) const
Returns a pointer to the data for the specified GP.
Definition: grand_prix_manager.cpp:149
void loadFiles()
Load all the grands prix from the 3 directories known.
Definition: grand_prix_manager.cpp:46
unsigned int getNumberOfGrandPrix() const
Returns the number of GPs.
Definition: grand_prix_manager.hpp:73
std::string generateId()
Generates a new unique indentifier for a user defined grand prix.
Definition: grand_prix_manager.cpp:113
void loadDir(const std::string &dir, enum GrandPrixData::GPGroupType group)
Load all the grands prix in one directory.
Definition: grand_prix_manager.cpp:67
Definition: ptr_vector.hpp:44