1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-25 15:54:31 +01:00
Files
OpenRCT2/src/openrct2/localisation/Localisation.h
2018-06-15 09:36:17 +02:00

104 lines
4.0 KiB
C

#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 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, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#ifndef LOCALISATION_H
#define LOCALISATION_H
#include <cstring>
#include "Currency.h"
#include "Date.h"
#include "FormatCodes.h"
#include "Language.h"
#include "StringIds.h"
#include "../management/Marketing.h"
bool utf8_is_format_code(sint32 codepoint);
bool utf8_is_colour_code(sint32 codepoint);
bool utf8_should_use_sprite_for_codepoint(sint32 codepoint);
sint32 utf8_get_format_code_arg_length(sint32 codepoint);
void utf8_remove_formatting(utf8* string, bool allowColours);
void format_string(char *dest, size_t size, rct_string_id format, void *args);
void format_string_raw(char *dest, size_t size, char *src, void *args);
void format_string_to_upper(char *dest, size_t size, rct_string_id format, void *args);
void generate_string_file();
utf8 *get_string_end(const utf8 *text);
size_t get_string_size(const utf8 *text);
sint32 get_string_length(const utf8 *text);
// The maximum number of characters allowed for string/money conversions (anything above will risk integer overflow issues)
#define MONEY_STRING_MAXLENGTH 14
money32 string_to_money(const char* string_to_monetise);
void money_to_string(money32 amount, char * buffer_to_put_value_to, size_t buffer_len, bool forceDecimals);
void user_string_clear_all();
rct_string_id user_string_allocate(sint32 base, const utf8 *text);
void user_string_free(rct_string_id id);
bool is_user_string_id(rct_string_id stringId);
#define MAX_USER_STRINGS 1024
#define USER_STRING_MAX_LENGTH 32
#define USER_STRING_START 0x8000
#define USER_STRING_END 0x8FFF
#define REAL_NAME_START 0xA000
#define REAL_NAME_END 0xDFFF
// Constants used by user_string_allocate
enum {
USER_STRING_HIGH_ID_NUMBER = 1 << 2,
USER_STRING_DUPLICATION_PERMITTED = 1 << 7
};
// Real name data
extern const char real_name_initials[16];
extern const char *real_names[1024];
extern utf8 gUserStrings[MAX_USER_STRINGS][USER_STRING_MAX_LENGTH];
extern char gCommonStringFormatBuffer[256];
extern uint8 gCommonFormatArgs[80];
extern uint8 gMapTooltipFormatArgs[40];
extern bool gDebugStringFormatting;
extern const rct_string_id SpeedNames[5];
extern const rct_string_id ObjectiveNames[12];
extern const rct_string_id ResearchFundingLevelNames[4];
extern const rct_string_id MarketingCampaignNames[ADVERTISING_CAMPAIGN_COUNT][3];
extern const rct_string_id RideInspectionIntervalNames[];
extern const rct_string_id PeepThoughts[174];
extern const rct_string_id DateDayNames[31];
extern const rct_string_id DateGameMonthNames[MONTH_COUNT];
extern const rct_string_id DateGameShortMonthNames[MONTH_COUNT];
[[maybe_unused]] static inline void set_format_arg_body(uint8 *args, size_t offset, uintptr_t value, size_t size)
{
memcpy(args + offset, &value, size);
}
#define set_format_arg(offset, type, value) \
do { static_assert(sizeof(type) <= sizeof(uintptr_t), "Type too large"); \
set_format_arg_body(gCommonFormatArgs, offset, (uintptr_t)value, sizeof(type)); } while (false)
#define set_format_arg_on(args, offset, type, value) \
set_format_arg_body(args, offset, (uintptr_t)value, sizeof(type))
#define set_map_tooltip_format_arg(offset, type, value) \
do { static_assert(sizeof(type) <= sizeof(uintptr_t), "Type too large"); \
set_format_arg_body(gMapTooltipFormatArgs, offset, (uintptr_t)value, sizeof(type)); } while (false)
#endif