Update: Translations from eints
[openttd-github.git] / src / game / game_text.hpp
blobe0c45741d8b751c881c175be454e87bdd8a5178b
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file game_text.hpp Base functions regarding game texts. */
10 #ifndef GAME_TEXT_HPP
11 #define GAME_TEXT_HPP
13 struct StringParam {
14 enum ParamType {
15 UNUSED,
16 RAW_STRING,
17 STRING,
18 OTHER
21 ParamType type;
22 uint8_t consumes;
23 const char *cmd;
25 StringParam(ParamType type, uint8_t consumes, const char *cmd) : type(type), consumes(consumes), cmd(cmd) {}
27 using StringParams = std::vector<StringParam>;
28 using StringParamsList = std::vector<StringParams>;
30 const char *GetGameStringPtr(uint id);
31 const StringParams &GetGameStringParams(uint id);
32 const std::string &GetGameStringName(uint id);
33 void RegisterGameTranslation(class Squirrel *engine);
34 void ReconsiderGameScriptLanguage();
36 /** Container for the raw (unencoded) language strings of a language. */
37 struct LanguageStrings {
38 std::string language; ///< Name of the language (base filename). Empty string if invalid.
39 StringList lines; ///< The lines of the file to pass into the parser/encoder.
41 LanguageStrings() {}
42 LanguageStrings(const std::string &lang) : language(lang) {}
43 LanguageStrings(const LanguageStrings &other) : language(other.language), lines(other.lines) {}
44 LanguageStrings(LanguageStrings &&other) : language(std::move(other.language)), lines(std::move(other.lines)) {}
46 bool IsValid() const { return !this->language.empty(); }
49 /** Container for all the game strings. */
50 struct GameStrings {
51 uint version; ///< The version of the language strings.
52 LanguageStrings *cur_language; ///< The current (compiled) language.
54 std::vector<LanguageStrings> raw_strings; ///< The raw strings per language, first must be English/the master language!.
55 std::vector<LanguageStrings> compiled_strings; ///< The compiled strings per language, first must be English/the master language!.
56 StringList string_names; ///< The names of the compiled strings.
57 StringParamsList string_params; ///< The parameters for the strings.
59 void Compile();
61 GameStrings() = default;
63 GameStrings(const GameStrings &) = delete;
64 GameStrings(GameStrings &&) = delete;
65 GameStrings &operator=(const GameStrings &) = delete;
66 GameStrings &operator=(GameStrings &&) = delete;
69 #endif /* GAME_TEXT_HPP */