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 newgrf_text_type.h Header of Action 04 "universal holder" structure */
10 #ifndef NEWGRF_TEXT_TYPE_H
11 #define NEWGRF_TEXT_TYPE_H
13 /** This character (thorn) indicates a unicode string to NFO. */
14 static const char32_t NFO_UTF8_IDENTIFIER
= 0x00DE;
16 /** A GRF text with associated language ID. */
18 uint8_t langid
; ///< The language associated with this GRFText.
19 std::string text
; ///< The actual (translated) text.
22 /** A GRF text with a list of translations. */
23 using GRFTextList
= std::vector
<GRFText
>;
24 /** Reference counted wrapper around a GRFText pointer. */
25 using GRFTextWrapper
= std::shared_ptr
<GRFTextList
>;
27 /** Mapping of language data between a NewGRF and OpenTTD. */
29 /** Mapping between NewGRF and OpenTTD IDs. */
31 uint8_t newgrf_id
; ///< NewGRF's internal ID for a case/gender.
32 uint8_t openttd_id
; ///< OpenTTD's internal ID for a case/gender.
35 /* We need a vector and can't use SmallMap due to the fact that for "setting" a
36 * gender of a string or requesting a case for a substring we want to map from
37 * the NewGRF's internal ID to OpenTTD's ID whereas for the choice lists we map
38 * the genders/cases/plural OpenTTD IDs to the NewGRF's internal IDs. In this
39 * case a NewGRF developer/translator might want a different translation for
40 * both cases. Thus we are basically implementing a multi-map. */
41 std::vector
<Mapping
> gender_map
; ///< Mapping of NewGRF and OpenTTD IDs for genders.
42 std::vector
<Mapping
> case_map
; ///< Mapping of NewGRF and OpenTTD IDs for cases.
43 int plural_form
; ///< The plural form used for this language.
45 int GetMapping(int newgrf_id
, bool gender
) const;
46 int GetReverseMapping(int openttd_id
, bool gender
) const;
47 static const LanguageMap
*GetLanguageMap(uint32_t grfid
, uint8_t language_id
);
50 #endif /* NEWGRF_TEXT_TYPE_H */