fixed editor zooming if gui is not active
[twcon.git] / src / game / localization.h
blob49edd86026997dd11091fc004ef5836623f8fc12
1 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2 /* If you are missing that file, acquire a complete release at teeworlds.com. */
3 #ifndef GAME_LOCALIZATION_H
4 #define GAME_LOCALIZATION_H
5 #include <base/tl/string.h>
6 #include <base/tl/sorted_array.h>
8 class CLocalizationDatabase
10 class CString
12 public:
13 unsigned m_Hash;
15 // TODO: do this as an const char * and put everything on a incremental heap
16 string m_Replacement;
18 bool operator <(const CString &Other) const { return m_Hash < Other.m_Hash; }
19 bool operator <=(const CString &Other) const { return m_Hash <= Other.m_Hash; }
20 bool operator ==(const CString &Other) const { return m_Hash == Other.m_Hash; }
23 sorted_array<CString> m_Strings;
24 int m_VersionCounter;
25 int m_CurrentVersion;
27 public:
28 CLocalizationDatabase();
30 bool Load(const char *pFilename, class IStorage *pStorage, class IConsole *pConsole);
32 int Version() { return m_CurrentVersion; }
34 void AddString(const char *pOrgStr, const char *pNewStr);
35 const char *FindString(unsigned Hash);
38 extern CLocalizationDatabase g_Localization;
40 class CLocConstString
42 const char *m_pDefaultStr;
43 const char *m_pCurrentStr;
44 unsigned m_Hash;
45 int m_Version;
46 public:
47 CLocConstString(const char *pStr);
48 void Reload();
50 inline operator const char *()
52 if(m_Version != g_Localization.Version())
53 Reload();
54 return m_pCurrentStr;
59 extern const char *Localize(const char *pStr);
60 #endif