SuperTuxKart
Loading...
Searching...
No Matches
tips_manager.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2019 dumaosen
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#ifndef SERVER_ONLY
19
20#ifndef HEADER_TIPS_MANAGER_HPP
21#define HEADER_TIPS_MANAGER_HPP
22
23class XMLNode;
24
25#include <assert.h>
26#include <irrString.h>
27#include <string>
28#include <map>
29#include <vector>
30
31typedef std::vector<irr::core::stringw> TipSet;
32
38{
39private:
42
43 std::map<std::string, TipSet> m_all_tip_sets;
44
45 TipsManager ();
46
47 void addTipSet(const XMLNode *input);
48
49public:
51 static void create()
52 {
53 assert(!m_tips_manager);
55 } // create
56 // ------------------------------------------------------------------------
58 static TipsManager* get()
59 {
60 assert(m_tips_manager);
61 return m_tips_manager;
62 } // get
63 // ------------------------------------------------------------------------
64 static void destroy()
65 {
66 delete m_tips_manager;
67 m_tips_manager = NULL;
68 } // destroy
69 // ========================================================================
71 const irr::core::stringw& getTip(const std::string& id) const;
72 // ------------------------------------------------------------------------
73 bool isEmpty() const { return m_all_tip_sets.empty(); }
74 // ------------------------------------------------------------------------
75}; // class TipsManager
76
77#endif
78#endif
This class manages the list of all tips.
Definition: tips_manager.hpp:38
const irr::core::stringw & getTip(const std::string &id) const
Get a tip by ID.
Definition: tips_manager.cpp:93
static TipsManager * m_tips_manager
Pointer to the single instance.
Definition: tips_manager.hpp:41
static void create()
Static function to create the instance of the tips manager.
Definition: tips_manager.hpp:51
static TipsManager * get()
Static function to get the tips manager.
Definition: tips_manager.hpp:58
TipsManager()
Constructor, which reads data/tips.xml and stores the information in objects.
Definition: tips_manager.cpp:36
utility class used to parse XML files
Definition: xml_node.hpp:48