Keep raw and compiled strings together in LanguageStrings
[openttd/fttd.git] / src / game / game_text.hpp
blob8b1ea9201dad0a1161199ad08f0db7ceb95801d2
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file game_text.hpp Base functions regarding game texts. */
12 #ifndef GAME_TEXT_HPP
13 #define GAME_TEXT_HPP
15 #include <vector>
16 #include "../core/pointer.h"
17 #include "../core/smallvec_type.hpp"
19 /** The tab we place our strings in. */
20 static const uint GAME_TEXT_TAB = 18;
22 const char *GetGameStringPtr(uint id);
23 void RegisterGameTranslation(class Squirrel *engine);
24 void ReconsiderGameScriptLanguage();
26 /** Container for the raw (unencoded) language strings of a language. */
27 struct LanguageStrings {
28 const char *language; ///< Name of the language (base filename).
29 StringList raw; ///< The raw strings of the language.
30 StringList compiled; ///< The compiled strings of the language.
32 LanguageStrings(const char *language, const char *end = NULL);
33 ~LanguageStrings();
36 /** Container for all the game strings. */
37 struct GameStrings {
38 uint version; ///< The version of the language strings.
39 LanguageStrings *cur_language; ///< The current (compiled) language.
41 /** Helper class to store a vector of LanguageStrings. */
42 struct LanguageVector : std::vector <ttd_unique_ptr <LanguageStrings> > {
43 /** Append a newly constructed LanguageStrings to the vector. */
44 void append (LanguageStrings *ls)
46 this->push_back (ttd_unique_ptr <LanguageStrings> (ls));
50 LanguageVector strings; ///< The strings per language, first is master.
52 StringList string_names; ///< The names of the compiled strings.
54 void Compile();
56 static GameStrings *current;
59 #endif /* GAME_TEXT_HPP */