2014-08-15 00:46:36 +02:00
|
|
|
/*****************************************************************************
|
2020-05-07 20:35:30 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
2014-08-15 00:46:36 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2014-08-15 00:46:36 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2014-08-15 00:46:36 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _LANGUAGE_H_
|
|
|
|
#define _LANGUAGE_H_
|
|
|
|
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../common.h"
|
2018-01-05 22:01:16 +01:00
|
|
|
#include "../drawing/Font.h"
|
2014-08-15 00:46:36 +02:00
|
|
|
|
2018-06-22 23:01:56 +02:00
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
LANGUAGE_UNDEFINED,
|
2017-10-09 10:53:09 +02:00
|
|
|
LANGUAGE_ARABIC,
|
|
|
|
LANGUAGE_CATALAN,
|
|
|
|
LANGUAGE_CHINESE_SIMPLIFIED,
|
|
|
|
LANGUAGE_CHINESE_TRADITIONAL,
|
|
|
|
LANGUAGE_CZECH,
|
2018-07-19 21:15:54 +02:00
|
|
|
LANGUAGE_DANISH,
|
2017-10-09 10:53:09 +02:00
|
|
|
LANGUAGE_GERMAN,
|
2017-06-06 23:24:18 +02:00
|
|
|
LANGUAGE_ENGLISH_UK,
|
|
|
|
LANGUAGE_ENGLISH_US,
|
2020-10-05 13:21:27 +02:00
|
|
|
LANGUAGE_ESPERANTO,
|
2017-10-09 10:53:09 +02:00
|
|
|
LANGUAGE_SPANISH,
|
2017-06-06 23:24:18 +02:00
|
|
|
LANGUAGE_FRENCH,
|
2017-10-09 10:53:09 +02:00
|
|
|
LANGUAGE_ITALIAN,
|
|
|
|
LANGUAGE_JAPANESE,
|
|
|
|
LANGUAGE_KOREAN,
|
2017-06-06 23:24:18 +02:00
|
|
|
LANGUAGE_HUNGARIAN,
|
2017-10-09 10:53:09 +02:00
|
|
|
LANGUAGE_DUTCH,
|
|
|
|
LANGUAGE_NORWEGIAN,
|
2017-06-06 23:24:18 +02:00
|
|
|
LANGUAGE_POLISH,
|
|
|
|
LANGUAGE_PORTUGUESE_BR,
|
|
|
|
LANGUAGE_RUSSIAN,
|
2017-10-09 10:53:09 +02:00
|
|
|
LANGUAGE_FINNISH,
|
|
|
|
LANGUAGE_SWEDISH,
|
2018-08-13 00:16:11 +02:00
|
|
|
LANGUAGE_TURKISH,
|
2017-06-06 23:24:18 +02:00
|
|
|
LANGUAGE_COUNT
|
2014-08-15 00:46:36 +02:00
|
|
|
};
|
|
|
|
|
2020-12-23 05:43:27 +01:00
|
|
|
enum class RCT2LanguageId
|
2017-12-11 19:29:25 +01:00
|
|
|
{
|
2020-12-23 05:43:27 +01:00
|
|
|
EnglishUK,
|
|
|
|
EnglishUS,
|
|
|
|
French,
|
|
|
|
German,
|
|
|
|
Spanish,
|
|
|
|
Italian,
|
|
|
|
Dutch,
|
|
|
|
Swedish,
|
|
|
|
Japanese,
|
|
|
|
Korean,
|
|
|
|
ChineseSimplified,
|
|
|
|
ChineseTraditional,
|
|
|
|
Undefined,
|
|
|
|
Portuguese,
|
|
|
|
Blank = 254,
|
|
|
|
End = 255
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2017-12-11 19:29:25 +01:00
|
|
|
|
2015-07-26 18:50:01 +02:00
|
|
|
#define FONT_OPENRCT2_SPRITE NULL
|
|
|
|
|
2017-10-26 23:23:24 +02:00
|
|
|
#include "../interface/FontFamilies.h"
|
|
|
|
|
2018-06-22 23:01:56 +02:00
|
|
|
struct language_descriptor
|
|
|
|
{
|
|
|
|
const char* locale;
|
|
|
|
const utf8* english_name;
|
|
|
|
const utf8* native_name;
|
2018-02-01 19:01:47 +01:00
|
|
|
#if !defined(NO_TTF)
|
2018-06-22 23:01:56 +02:00
|
|
|
TTFontFamily const* font_family;
|
2017-01-03 22:57:15 +01:00
|
|
|
#else
|
2018-06-22 23:01:56 +02:00
|
|
|
void* font_family;
|
2017-10-26 23:23:24 +02:00
|
|
|
#endif
|
2018-07-26 13:48:45 +02:00
|
|
|
bool isRtl;
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2015-07-26 18:50:01 +02:00
|
|
|
|
|
|
|
extern const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT];
|
|
|
|
|
2020-10-13 02:14:39 +02:00
|
|
|
constexpr const char* BlackUpArrowString = u8"{BLACK}▲";
|
|
|
|
constexpr const char* BlackDownArrowString = u8"{BLACK}▼";
|
|
|
|
constexpr const char* BlackLeftArrowString = u8"{BLACK}◀";
|
|
|
|
constexpr const char* BlackRightArrowString = u8"{BLACK}▶";
|
|
|
|
constexpr const char* CheckBoxMarkString = u8"✓";
|
2015-07-27 02:09:24 +02:00
|
|
|
|
2018-06-22 23:01:56 +02:00
|
|
|
uint8_t language_get_id_from_locale(const char* locale);
|
|
|
|
const char* language_get_string(rct_string_id id);
|
2018-06-20 17:28:51 +02:00
|
|
|
bool language_open(int32_t id);
|
2014-08-15 00:46:36 +02:00
|
|
|
|
2018-06-22 23:01:56 +02:00
|
|
|
uint32_t utf8_get_next(const utf8* char_ptr, const utf8** nextchar_ptr);
|
|
|
|
int32_t utf8_insert_codepoint(utf8* dst, uint32_t codepoint);
|
|
|
|
bool utf8_is_codepoint_start(const utf8* text);
|
2019-10-20 19:03:09 +02:00
|
|
|
int32_t utf8_get_codepoint_length(char32_t codepoint);
|
2018-06-22 23:01:56 +02:00
|
|
|
int32_t utf8_length(const utf8* text);
|
2015-07-26 01:55:17 +02:00
|
|
|
|
2021-01-06 17:22:22 +01:00
|
|
|
std::string rct2_to_utf8(std::string_view src, RCT2LanguageId languageId);
|
|
|
|
std::string utf8_to_rct2(std::string_view src);
|
2018-06-22 23:01:56 +02:00
|
|
|
bool language_get_localised_scenario_strings(const utf8* scenarioFilename, rct_string_id* outStringIds);
|
2016-06-25 17:34:35 +02:00
|
|
|
void language_free_object_string(rct_string_id stringId);
|
2018-06-22 23:01:56 +02:00
|
|
|
rct_string_id language_allocate_object_string(const std::string& target);
|
2017-12-05 13:55:33 +01:00
|
|
|
|
2020-04-19 15:51:01 +02:00
|
|
|
constexpr utf8* utf8_write_codepoint(utf8* dst, uint32_t codepoint)
|
|
|
|
{
|
|
|
|
if (codepoint <= 0x7F)
|
|
|
|
{
|
2020-04-22 17:09:29 +02:00
|
|
|
dst[0] = static_cast<utf8>(codepoint);
|
2020-04-19 15:51:01 +02:00
|
|
|
return dst + 1;
|
|
|
|
}
|
|
|
|
else if (codepoint <= 0x7FF)
|
|
|
|
{
|
|
|
|
dst[0] = 0xC0 | ((codepoint >> 6) & 0x1F);
|
|
|
|
dst[1] = 0x80 | (codepoint & 0x3F);
|
|
|
|
return dst + 2;
|
|
|
|
}
|
|
|
|
else if (codepoint <= 0xFFFF)
|
|
|
|
{
|
|
|
|
dst[0] = 0xE0 | ((codepoint >> 12) & 0x0F);
|
|
|
|
dst[1] = 0x80 | ((codepoint >> 6) & 0x3F);
|
|
|
|
dst[2] = 0x80 | (codepoint & 0x3F);
|
|
|
|
return dst + 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dst[0] = 0xF0 | ((codepoint >> 18) & 0x07);
|
|
|
|
dst[1] = 0x80 | ((codepoint >> 12) & 0x3F);
|
|
|
|
dst[2] = 0x80 | ((codepoint >> 6) & 0x3F);
|
|
|
|
dst[3] = 0x80 | (codepoint & 0x3F);
|
|
|
|
return dst + 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-21 02:08:55 +02:00
|
|
|
#endif
|