34 TEXT_TAB_INDUSTRY = 9,
35 TEXT_TAB_STATION = 12,
36 TEXT_TAB_SPECIAL = 14,
37 TEXT_TAB_OLD_CUSTOM = 15,
38 TEXT_TAB_VEHICLE = 16,
40 TEXT_TAB_OLD_NEWGRF = 26,
75using StringParameterData = std::variant<std::monostate, uint64_t, std::string>;
78struct StringParameter {
82 StringParameter() =
default;
83 inline StringParameter(StringParameterData &&
data) :
data(std::move(
data)),
type(0) {}
88 inline StringParameter(std::string_view
data) :
data(std::string{
data}),
type(0) {}
89 inline StringParameter(std::string &&
data) :
data(std::move(
data)),
type(0) {}
92 inline StringParameter(
const ConvertibleThroughBase
auto &
data) :
data(static_cast<uint64_t>(
data.base())),
type(0) {}
100 EncodedString() =
default;
102 auto operator<=>(
const EncodedString &)
const =
default;
107 inline void clear() { this->
string.clear(); }
108 inline bool empty()
const {
return this->
string.empty(); }
114 explicit EncodedString(std::string &&
string) :
string(std::move(
string)) {}
118 template <
typename Tcont,
typename Titer>
121 friend class ScriptText;
Container for an encoded string, created by GetEncodedString.
friend EncodedString GetEncodedStringWithArgs(StringID str, std::span< const StringParameter > params)
Encode a string with its parameters into an encoded string.
std::string string
The encoded string.
std::string GetDecodedString() const
Decode the encoded string.
EncodedString ReplaceParam(size_t param, StringParameter &&value) const
Replace a parameter of this EncodedString.
Endian-aware buffer adapter that always reads values in little endian order.
Endian-aware buffer adapter that always writes values in little endian order.
Concept for unifying the convert through 'base()' behaviour of several 'strong' types.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
StrongType::Typedef< uint32_t, struct StringIndexInTabTag, StrongType::Compare, StrongType::Integer > StringIndexInTab
The index/offset of a string within a StringTab.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames).
static constexpr StringID SPECSTR_COMPANY_NAME_START
Special strings for company names on the form "TownName transport".
static constexpr StringID SPECSTR_SILLY_NAME
Special string for silly company names.
static const uint TAB_SIZE_NEWGRF
Number of strings for NewGRFs.
static const uint TAB_SIZE_GAMESCRIPT
Number of strings for GameScripts.
static const uint MAX_LANG
Maximum number of languages supported by the game, and the NewGRF specs.
static const uint TAB_SIZE_BITS
Number of bits for the StringIndex within a StringTab.
static constexpr uint32_t BUILTIN_TOWNNAME_GENERATOR_COUNT
The number of builtin generators for town names.
static constexpr StringID SPECSTR_ANDCO_NAME
Special string for Surname & Co company names.
static constexpr StringID SPECSTR_PRESIDENT_NAME
Special string for the president's name.
static constexpr StringID SPECSTR_TOWNNAME_START
Special strings for town names.
static const uint TAB_SIZE
Number of strings per StringTab.
StringTab
StringTabs to group StringIDs.
@ TEXT_TAB_NEWGRF_START
Start of NewGRF supplied strings.
@ TEXT_TAB_GAMESCRIPT_START
Start of GameScript supplied strings.
@ TEXT_TAB_END
End of language files.
TextDirection
Directions a text can go to.
@ TD_LTR
Text is written left-to-right by default.
@ TD_RTL
Text is written right-to-left by default.
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
Type (helpers) for making a strong typedef that is a distinct type.
The data required to format and validate a single parameter of a string.
StringParameterData data
The data of the parameter.
char32_t type
The StringControlCode to interpret this data with when it's the first parameter, otherwise '\0'.
Templated helper to make a type-safe 'typedef' representing a single POD value.