OpenTTD Source: src/newgrf_text.h Source File

OpenTTD Source 15.0-RC2

newgrf_text.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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef NEWGRF_TEXT_H
11#define NEWGRF_TEXT_H
12
13#include "newgrf_text_type.h"
14#include "strings_type.h"
15#include "table/control_codes.h"
16
17 StringID AddGRFString(uint32_t grfid, GRFStringID stringid, uint8_t langid, bool new_scheme, bool allow_newlines, std::string_view text_to_add, StringID def_string);
18 StringID GetGRFStringID(uint32_t grfid, GRFStringID stringid);
19std::optional<std::string_view> GetGRFStringFromGRFText(const GRFTextList &text_list);
20std::optional<std::string_view> GetGRFStringFromGRFText(const GRFTextWrapper &text);
21std::string_view GetGRFStringPtr(StringIndexInTab stringid);
22void CleanUpStrings();
23void SetCurrentGrfLangID(uint8_t language_id);
24std::string TranslateTTDPatchCodes(uint32_t grfid, uint8_t language_id, bool allow_newlines, std::string_view str, StringControlCode byte80 = SCC_NEWGRF_PRINT_WORD_STRING_ID);
25void AddGRFTextToList(GRFTextList &list, uint8_t langid, uint32_t grfid, bool allow_newlines, std::string_view text_to_add);
26void AddGRFTextToList(GRFTextWrapper &list, uint8_t langid, uint32_t grfid, bool allow_newlines, std::string_view text_to_add);
27void AddGRFTextToList(GRFTextWrapper &list, std::string_view text_to_add);
28
29bool CheckGrfLangID(uint8_t lang_id, uint8_t grf_version);
30
31std::vector<StringParameter> GetGRFStringTextStackParameters(const struct GRFFile *grffile, StringID stringid, std::span<const int32_t> textstack);
32std::string GetGRFStringWithTextStack(const struct GRFFile *grffile, GRFStringID grfstringid, std::span<const int32_t> textstack);
33
34#endif /* NEWGRF_TEXT_H */
control_codes.h
Control codes that are embedded in the translation strings.
StringControlCode
StringControlCode
List of string control codes used for string formatting, displaying, and by strgen to generate the la...
Definition control_codes.h:17
SCC_NEWGRF_PRINT_WORD_STRING_ID
@ SCC_NEWGRF_PRINT_WORD_STRING_ID
81: Read 2 bytes from the stack as String ID
Definition control_codes.h:141
GetGRFStringTextStackParameters
std::vector< StringParameter > GetGRFStringTextStackParameters(const GRFFile *grffile, StringID stringid, std::span< const int32_t > textstack)
Process the text ref stack for a GRF String and return its parameters.
Definition newgrf_text.cpp:977
AddGRFTextToList
void AddGRFTextToList(GRFTextList &list, uint8_t langid, uint32_t grfid, bool allow_newlines, std::string_view text_to_add)
Add a string to a GRFText list.
Definition newgrf_text.cpp:501
CleanUpStrings
void CleanUpStrings()
House cleaning.
Definition newgrf_text.cpp:675
GetGRFStringPtr
std::string_view GetGRFStringPtr(StringIndexInTab stringid)
Get a C-string from a stringid set by a newgrf.
Definition newgrf_text.cpp:632
TranslateTTDPatchCodes
std::string TranslateTTDPatchCodes(uint32_t grfid, uint8_t language_id, bool allow_newlines, std::string_view str, StringControlCode byte80=SCC_NEWGRF_PRINT_WORD_STRING_ID)
Translate TTDPatch string codes into something OpenTTD can handle (better).
Definition newgrf_text.cpp:237
GetGRFStringWithTextStack
std::string GetGRFStringWithTextStack(const struct GRFFile *grffile, GRFStringID grfstringid, std::span< const int32_t > textstack)
Format a GRF string using the text ref stack for parameters.
Definition newgrf_text.cpp:999
SetCurrentGrfLangID
void SetCurrentGrfLangID(uint8_t language_id)
Equivalence Setter function between game and newgrf langID.
Definition newgrf_text.cpp:652
AddGRFString
StringID AddGRFString(uint32_t grfid, GRFStringID stringid, uint8_t langid, bool new_scheme, bool allow_newlines, std::string_view text_to_add, StringID def_string)
Add the new read string into our structure.
Definition newgrf_text.cpp:536
GetGRFStringID
StringID GetGRFStringID(uint32_t grfid, GRFStringID stringid)
Returns the index for this stringid associated with its grfID.
Definition newgrf_text.cpp:580
GetGRFStringFromGRFText
std::optional< std::string_view > GetGRFStringFromGRFText(const GRFTextList &text_list)
Get a C-string from a GRFText-list.
Definition newgrf_text.cpp:599
newgrf_text_type.h
Header of Action 04 "universal holder" structure.
GRFTextWrapper
std::shared_ptr< GRFTextList > GRFTextWrapper
Reference counted wrapper around a GRFText pointer.
Definition newgrf_text_type.h:32
GRFTextList
std::vector< GRFText > GRFTextList
A GRF text with a list of translations.
Definition newgrf_text_type.h:30
strings_type.h
Types related to strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
GRFFile
Dynamic data of a loaded NewGRF.
Definition newgrf.h:114
StrongType::Typedef< uint32_t, struct GRFStringIDTag, StrongType::Compare, StrongType::Integer >