SuperTuxKart
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 
28 #include "irrlicht.h"
29 class GrandPrixData;
30 
35 {
36 private:
37  static const char* SUFFIX;
38 
39  PtrVector<GrandPrixData> m_gp_data;
40 
42  void loadFiles();
44  void loadDir(const std::string& dir, enum GrandPrixData::GPGroupType group);
46  void load(const std::string &filename, enum GrandPrixData::GPGroupType group);
47 
49  std::string generateId();
50 
51 public:
54  void reload();
55  bool existsName(const irr::core::stringw& name) const;
56  void checkConsistency();
57 
58  // Methods for the gp editor
59  GrandPrixData* editGrandPrix(const std::string& s);
60  GrandPrixData* createNewGP(const irr::core::stringw& newName);
61  GrandPrixData* copy(const std::string& id,
62  const irr::core::stringw& newName);
63  void remove(const std::string& id);
64  // ------------------------------------------------------------------------
67  const GrandPrixData* getGrandPrix(const std::string& s) const;
68  // ------------------------------------------------------------------------
71  const GrandPrixData* getGrandPrix(const int i) const { return m_gp_data.get(i); }
72  // ------------------------------------------------------------------------
74  unsigned int getNumberOfGrandPrix() const { return (int)m_gp_data.size(); }
75 }; // GrandPrixManager
76 
77 extern GrandPrixManager *grand_prix_manager;
78 
79 #endif
void loadDir(const std::string &dir, enum GrandPrixData::GPGroupType group)
Load all the grands prix in one directory.
Definition: grand_prix_manager.cpp:67
void loadFiles()
Load all the grands prix from the 3 directories known.
Definition: grand_prix_manager.cpp:46
const GrandPrixData * getGrandPrix(const std::string &s) const
Returns a pointer to the data for the specified GP.
Definition: grand_prix_manager.cpp:149
unsigned int getNumberOfGrandPrix() const
Returns the number of GPs.
Definition: grand_prix_manager.hpp:74
std::string generateId()
Generates a new unique indentifier for a user defined grand prix.
Definition: grand_prix_manager.cpp:113
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
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:71
GPGroupType
Used to classify GPs into groups.
Definition: grand_prix_data.hpp:45
Simple class that hold the data relevant to a &#39;grand_prix&#39;, aka.
Definition: grand_prix_data.hpp:35