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/>.
8 /** @file game_text.hpp Base functions regarding game texts. */
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.
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. */
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.
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 */