Part of #21421: refactor CURRENCY_SYMBOL_MAX_SIZE

This commit is contained in:
Claudio Tiecher 2024-03-31 21:18:56 +02:00
parent 1f7070b948
commit f698fbfc54
3 changed files with 10 additions and 10 deletions

View File

@ -109,7 +109,7 @@ static Widget window_custom_currency_widgets[] = {
case WIDX_SYMBOL_TEXT:
WindowTextInputRawOpen(
this, WIDX_SYMBOL_TEXT, STR_CUSTOM_CURRENCY_SYMBOL_INPUT_TITLE, STR_CUSTOM_CURRENCY_SYMBOL_INPUT_DESC,
{}, CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, CURRENCY_SYMBOL_MAX_SIZE);
{}, CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, kCurrencySymbolMaxSize);
break;
}
}
@ -164,7 +164,7 @@ static Widget window_custom_currency_widgets[] = {
case WIDX_SYMBOL_TEXT:
SafeStrCpy(
CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, std::string(text).c_str(),
CURRENCY_SYMBOL_MAX_SIZE);
kCurrencySymbolMaxSize);
gConfigGeneral.CustomCurrencySymbol = CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode;

View File

@ -22,16 +22,16 @@ CurrencyDescriptor CurrencyDescriptors[EnumValue(CurrencyType::Count)] = {
{ "JPY", 1000, CurrencyAffix::Prefix, u8"¥", CurrencyAffix::Suffix, "YEN", STR_YEN }, // Japanese Yen
{ "ESP", 10, CurrencyAffix::Suffix, u8"Pts", CurrencyAffix::Suffix, "Pts", STR_PESETA }, // Spanish Peseta
{ "ITL", 1000, CurrencyAffix::Prefix, u8"L", CurrencyAffix::Prefix, "L", STR_LIRA }, // Italian Lira
{ "NLG", 10, CurrencyAffix::Prefix, u8"ƒ ", CurrencyAffix::Prefix, "fl.", STR_GUILDERS }, // Dutch Guilder
{ "SEK", 100, CurrencyAffix::Suffix, u8" kr", CurrencyAffix::Suffix, " kr", STR_KRONA }, // Swedish Krona
{ "NLG", 10, CurrencyAffix::Prefix, u8"ƒ ", CurrencyAffix::Prefix, "fl.", STR_GUILDERS }, // Dutch Guilder
{ "SEK", 100, CurrencyAffix::Suffix, u8" kr", CurrencyAffix::Suffix, " kr", STR_KRONA }, // Swedish Krona
{ "EUR", 10, CurrencyAffix::Prefix, u8"", CurrencyAffix::Suffix, "EUR", STR_EUROS }, // Euro
{ "KRW", 10000, CurrencyAffix::Prefix, u8"", CurrencyAffix::Prefix, "W", STR_WON }, // South Korean Won
{ "RUB", 1000, CurrencyAffix::Suffix, u8"", CurrencyAffix::Prefix, "R ", STR_ROUBLE }, // Russian Rouble
{ "CZK", 100, CurrencyAffix::Suffix, u8" ", CurrencyAffix::Suffix, " Kc", STR_CZECH_KORUNA }, // Czech koruna
{ "CZK", 100, CurrencyAffix::Suffix, u8" ", CurrencyAffix::Suffix, " Kc", STR_CZECH_KORUNA }, // Czech koruna
{ "HKD", 100, CurrencyAffix::Prefix, u8"$", CurrencyAffix::Prefix, "HKD", STR_HONG_KONG_DOLLAR}, // Hong Kong Dollar
{ "TWD", 1000, CurrencyAffix::Prefix, u8"NT$", CurrencyAffix::Prefix, "NT$", STR_NEW_TAIWAN_DOLLAR}, // New Taiwan Dollar
{ "CNY", 100, CurrencyAffix::Prefix, u8"CN¥", CurrencyAffix::Prefix, "CNY", STR_CHINESE_YUAN }, // Chinese Yuan
{ "HUF", 1000, CurrencyAffix::Suffix, u8" Ft", CurrencyAffix::Suffix, " Ft", STR_HUNGARIAN_FORINT}, // Hungarian Forint
{ "HUF", 1000, CurrencyAffix::Suffix, u8" Ft", CurrencyAffix::Suffix, " Ft", STR_HUNGARIAN_FORINT}, // Hungarian Forint
{ "CTM", 10, CurrencyAffix::Prefix, u8"Ctm", CurrencyAffix::Prefix, "Ctm", STR_CUSTOM_CURRENCY }, // Customizable currency
};
// clang-format on
@ -44,6 +44,6 @@ void CurrencyLoadCustomCurrencyConfig()
{
SafeStrCpy(
CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, gConfigGeneral.CustomCurrencySymbol.c_str(),
CURRENCY_SYMBOL_MAX_SIZE);
kCurrencySymbolMaxSize);
}
}

View File

@ -45,7 +45,7 @@ enum class CurrencyAffix
Suffix
};
#define CURRENCY_SYMBOL_MAX_SIZE 8
constexpr size_t kCurrencySymbolMaxSize = 8;
#define CURRENCY_RATE_MAX_NUM_DIGITS 9
// Currency format specification - inspired by OpenTTD
@ -55,9 +55,9 @@ struct CurrencyDescriptor
// Rate is relative to 0.10 GBP
int32_t rate;
CurrencyAffix affix_unicode;
utf8 symbol_unicode[CURRENCY_SYMBOL_MAX_SIZE];
utf8 symbol_unicode[kCurrencySymbolMaxSize];
CurrencyAffix affix_ascii;
char symbol_ascii[CURRENCY_SYMBOL_MAX_SIZE];
char symbol_ascii[kCurrencySymbolMaxSize];
StringId stringId;
};