OpenTTD Source 20250205-master-gfd85ab1e2c
strings_type.h
Go to the documentation of this file.
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 */
7
10#ifndef STRINGS_TYPE_H
11#define STRINGS_TYPE_H
12
14
18typedef uint32_t StringID;
19static const StringID INVALID_STRING_ID = 0xFFFF;
20static const int MAX_CHAR_LENGTH = 4;
21static const uint MAX_LANG = 0x7F;
22
24enum TextDirection : uint8_t {
27};
28
30enum StringTab : uint8_t {
31 /* Tabs 0..1 for regular strings */
32 TEXT_TAB_TOWN = 4,
33 TEXT_TAB_INDUSTRY = 9,
34 TEXT_TAB_STATION = 12,
35 TEXT_TAB_SPECIAL = 14,
36 TEXT_TAB_OLD_CUSTOM = 15,
37 TEXT_TAB_VEHICLE = 16,
38 /* Tab 17 for regular strings */
39 TEXT_TAB_OLD_NEWGRF = 26,
43};
44
47
49static const uint TAB_SIZE_BITS = 11;
51static const uint TAB_SIZE = 1 << TAB_SIZE_BITS;
52
54static const uint TAB_SIZE_GAMESCRIPT = TAB_SIZE * 32;
55
57static const uint TAB_SIZE_NEWGRF = TAB_SIZE * 256;
58
60static constexpr uint32_t BUILTIN_TOWNNAME_GENERATOR_COUNT = 21;
61
63static constexpr StringID SPECSTR_TOWNNAME_START = 0x20C0;
64static constexpr StringID SPECSTR_TOWNNAME_END = SPECSTR_TOWNNAME_START + BUILTIN_TOWNNAME_GENERATOR_COUNT;
65
67static constexpr StringID SPECSTR_COMPANY_NAME_START = 0x70EA;
68static constexpr StringID SPECSTR_COMPANY_NAME_END = SPECSTR_COMPANY_NAME_START + BUILTIN_TOWNNAME_GENERATOR_COUNT;
69
70static constexpr StringID SPECSTR_SILLY_NAME = 0x70E5;
71static constexpr StringID SPECSTR_ANDCO_NAME = 0x70E6;
72static constexpr StringID SPECSTR_PRESIDENT_NAME = 0x70E7;
73
74using StringParameterData = std::variant<uint64_t, std::string>;
75
76#endif /* STRINGS_TYPE_H */
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
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.
Templated helper to make a type-safe 'typedef' representing a single POD value.