SuperTuxKart
achievements_manager.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2013-2015 Glenn De Jonghe
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_ACHIEVEMENTS_MANAGER_HPP
20 #define HEADER_ACHIEVEMENTS_MANAGER_HPP
21 
22 #include "achievements/achievements_status.hpp"
23 #include "achievements/web_achievements_status.hpp"
24 
25 #include "utils/types.hpp"
26 #include "utils/ptr_vector.hpp"
27 
28 class AchievementInfo;
29 class AchievementsStatus;
30 
31 #include <string>
32 #include <map>
33 
34 
41 {
42 private:
45 
46  std::map<uint32_t, AchievementInfo *> m_achievements_info;
47  WebAchievementsStatus *m_web;
48 
51  AchievementsStatus * createNewSlot(unsigned int id, bool online);
52 
53 public:
55  static void create()
56  {
57  assert(!m_achievements_manager);
59  } // create
60  // ------------------------------------------------------------------------
63  {
64  assert(m_achievements_manager);
66  } // get
67  // ------------------------------------------------------------------------
68  static void destroy()
69  {
72  } // destroy
73  // ========================================================================
74 
75  AchievementInfo* getAchievementInfo(uint32_t id) const;
76  AchievementsStatus* createAchievementsStatus(const XMLNode *node=NULL, bool updateWeb = false);
77  // ------------------------------------------------------------------------
78  const std::map<uint32_t, AchievementInfo *> & getAllInfo()
79  {
80  return m_achievements_info;
81  } // getAllInfo
82 
83  WebAchievementsStatus* getWebAchievementStatus() { return m_web; }
84 }; // class AchievementsManager
85 
86 #endif
87 
88 /*EOF*/
This class stores an achievement definition from the xml file, including title, description,...
Definition: achievement_info.hpp:41
This class manages the list of all achievements.
Definition: achievements_manager.hpp:41
AchievementsStatus * createAchievementsStatus(const XMLNode *node=NULL, bool updateWeb=false)
Create a new AchievementStatus object that stores all achievement status information for a single pla...
Definition: achievements_manager.cpp:79
static AchievementsManager * m_achievements_manager
Pointer to the single instance.
Definition: achievements_manager.hpp:44
AchievementsManager()
Constructor, which reads data/achievements.xml and stores the information in AchievementInfo objects.
Definition: achievements_manager.cpp:41
static AchievementsManager * get()
Static function to get the achievement manager.
Definition: achievements_manager.hpp:62
static void create()
Static function to create the instance of the achievement manager.
Definition: achievements_manager.hpp:55
This class keeps tracks of all achievements of one player.
Definition: achievements_status.hpp:43
This class updates achievements on an online site.
Definition: web_achievements_status.hpp:34
utility class used to parse XML files
Definition: xml_node.hpp:48
Declares the general types that are used by the network.