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 23 class XMLNode; 24 25 #include <assert.h> 26 #include <irrString.h> 27 #include <string> 28 #include <map> 29 #include <vector> 30 31 typedef std::vector<irr::core::stringw> TipSet; 32 33 /** This class manages the list of all tips. It reads the 34 * data/tips.xml file, which contains the contents for 35 * each tip. 36 */ 37 class TipsManager 38 { 39 private: 40 /** Pointer to the single instance. */ 41 static TipsManager *m_tips_manager; 42 43 std::map<std::string, TipSet> m_all_tip_sets; 44 45 TipsManager (); 46 47 void addTipSet(const XMLNode *input); 48 49 public: 50 /** Static function to create the instance of the tips manager. */ create()51 static void create() 52 { 53 assert(!m_tips_manager); 54 m_tips_manager = new TipsManager(); 55 } // create 56 // ------------------------------------------------------------------------ 57 /** Static function to get the tips manager. */ get()58 static TipsManager* get() 59 { 60 assert(m_tips_manager); 61 return m_tips_manager; 62 } // get 63 // ------------------------------------------------------------------------ destroy()64 static void destroy() 65 { 66 delete m_tips_manager; 67 m_tips_manager = NULL; 68 } // destroy 69 // ======================================================================== 70 /** Get a tip by ID. */ 71 const irr::core::stringw& getTip(const std::string& id) const; 72 // ------------------------------------------------------------------------ 73 }; // class TipsManager 74 75 #endif 76 #endif 77