MyGUI
3.2.1
|
00001 /* 00002 * This source file is part of MyGUI. For the latest info, see http://mygui.info/ 00003 * Distributed under the MIT License 00004 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 00005 */ 00006 00007 #ifndef __MYGUI_LANGUAGE_MANAGER_H__ 00008 #define __MYGUI_LANGUAGE_MANAGER_H__ 00009 00010 #include "MyGUI_Prerequest.h" 00011 #include "MyGUI_Singleton.h" 00012 #include "MyGUI_XmlDocument.h" 00013 #include "MyGUI_Delegate.h" 00014 #include "MyGUI_Types.h" 00015 #include "MyGUI_BackwardCompatibility.h" 00016 00017 namespace MyGUI 00018 { 00019 00020 class MYGUI_EXPORT LanguageManager : 00021 public Singleton<LanguageManager>, 00022 public MemberObsolete<LanguageManager> 00023 { 00024 public: 00025 LanguageManager(); 00026 00027 void initialise(); 00028 void shutdown(); 00029 00031 void setCurrentLanguage(const std::string& _name); 00033 const std::string& getCurrentLanguage() const; 00034 00037 UString replaceTags(const UString& _line); 00038 00040 UString getTag(const UString& _tag); 00041 00043 void addUserTag(const UString& _tag, const UString& _replace); 00044 00046 void clearUserTags(); 00047 00049 bool loadUserTags(const std::string& _file); 00050 00055 delegates::CMultiDelegate1<const std::string&> eventChangeLanguage; 00056 00063 delegates::CDelegate2<const UString&, UString&> eventRequestTag; 00064 00065 private: 00066 void _load(xml::ElementPtr _node, const std::string& _file, Version _version); 00067 00068 bool loadLanguage(const std::string& _file, bool _user = false); 00069 void _loadLanguage(IDataStream* _stream, bool _user); 00070 void _loadLanguageXML(IDataStream* _stream, bool _user); 00071 00072 UString replaceTagsPass(const UString& _line, bool& _replaceResult); 00073 00074 private: 00075 typedef std::map<UString, UString> MapLanguageString; 00076 00077 MapLanguageString mMapLanguage; 00078 MapLanguageString mUserMapLanguage; 00079 00080 std::string mCurrentLanguageName; 00081 00082 typedef std::map<std::string, VectorString> MapListString; 00083 MapListString mMapFile; 00084 00085 bool mIsInitialise; 00086 std::string mXmlLanguageTagName; 00087 }; 00088 00089 } // namespace MyGUI 00090 00091 #endif // __MYGUI_LANGUAGE_MANAGER_H__