mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Upgrade platform_get_locale_currency()
This commit is contained in:
@@ -151,7 +151,7 @@ namespace Config
|
||||
model->autosave_amount = reader->GetInt32("autosave_amount", DEFAULT_NUM_AUTOSAVES_TO_KEEP);
|
||||
model->confirmation_prompt = reader->GetBoolean("confirmation_prompt", false);
|
||||
model->currency_format = reader->GetEnum<CurrencyType>(
|
||||
"currency_format", platform_get_locale_currency(), Enum_Currency);
|
||||
"currency_format", Platform::GetLocaleCurrency(), Enum_Currency);
|
||||
model->custom_currency_rate = reader->GetInt32("custom_currency_rate", 10);
|
||||
model->custom_currency_affix = reader->GetEnum<CurrencyAffix>(
|
||||
"custom_currency_affix", CurrencyAffix::Suffix, Enum_CurrencySymbolAffix);
|
||||
|
||||
@@ -26,11 +26,6 @@ bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size)
|
||||
}
|
||||
# endif
|
||||
|
||||
CurrencyType platform_get_locale_currency()
|
||||
{
|
||||
return platform_get_currency_value(NULL);
|
||||
}
|
||||
|
||||
MeasurementFormat platform_get_locale_measurement_format()
|
||||
{
|
||||
return MeasurementFormat::Metric;
|
||||
|
||||
@@ -34,20 +34,6 @@
|
||||
# include <locale.h>
|
||||
# include <pwd.h>
|
||||
|
||||
CurrencyType platform_get_locale_currency()
|
||||
{
|
||||
char* langstring = setlocale(LC_MONETARY, "");
|
||||
|
||||
if (langstring == nullptr)
|
||||
{
|
||||
return platform_get_currency_value(NULL);
|
||||
}
|
||||
|
||||
struct lconv* lc = localeconv();
|
||||
|
||||
return platform_get_currency_value(lc->int_curr_symbol);
|
||||
}
|
||||
|
||||
MeasurementFormat platform_get_locale_measurement_format()
|
||||
{
|
||||
// LC_MEASUREMENT is GNU specific.
|
||||
|
||||
@@ -60,6 +60,11 @@ namespace Platform
|
||||
{
|
||||
return LANGUAGE_ENGLISH_UK;
|
||||
}
|
||||
|
||||
CurrencyType GetLocaleCurrency()
|
||||
{
|
||||
return Platform::GetCurrencyValue(NULL);
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
||||
@@ -236,6 +236,20 @@ namespace Platform
|
||||
}
|
||||
return LANGUAGE_ENGLISH_UK;
|
||||
}
|
||||
|
||||
CurrencyType GetLocaleCurrency()
|
||||
{
|
||||
char* langstring = setlocale(LC_MONETARY, "");
|
||||
|
||||
if (langstring == nullptr)
|
||||
{
|
||||
return Platform::GetCurrencyValue(NULL);
|
||||
}
|
||||
|
||||
struct lconv* lc = localeconv();
|
||||
|
||||
return Platform::GetCurrencyValue(lc->int_curr_symbol);
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
||||
@@ -696,6 +696,17 @@ namespace Platform
|
||||
}
|
||||
return LANGUAGE_UNDEFINED;
|
||||
}
|
||||
|
||||
CurrencyType GetLocaleCurrency()
|
||||
{
|
||||
CHAR currCode[4];
|
||||
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SINTLSYMBOL, reinterpret_cast<LPSTR>(&currCode), sizeof(currCode)) == 0)
|
||||
{
|
||||
return Platform::GetCurrencyValue(nullptr);
|
||||
}
|
||||
|
||||
return Platform::GetCurrencyValue(currCode);
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
||||
@@ -207,6 +207,15 @@ namespace Platform
|
||||
return LANGUAGE_ENGLISH_UK;
|
||||
}
|
||||
}
|
||||
|
||||
CurrencyType GetLocaleCurrency()
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
NSString* currencyCode = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencyCode];
|
||||
return Platform::GetCurrencyValue(currencyCode.UTF8String);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,6 +43,8 @@ namespace Platform
|
||||
std::string ResolveCasing(const std::string& path, bool fileExists);
|
||||
|
||||
uint16_t GetLocaleLanguage();
|
||||
CurrencyType GetLocaleCurrency();
|
||||
CurrencyType GetCurrencyValue(const char* currCode);
|
||||
rct2_time GetTimeLocal();
|
||||
rct2_date GetDateLocal();
|
||||
|
||||
|
||||
@@ -70,6 +70,24 @@ static LARGE_INTEGER _entryTimestamp;
|
||||
|
||||
namespace Platform
|
||||
{
|
||||
CurrencyType GetCurrencyValue(const char* currCode)
|
||||
{
|
||||
if (currCode == nullptr || strlen(currCode) < 3)
|
||||
{
|
||||
return CurrencyType::Pounds;
|
||||
}
|
||||
|
||||
for (int32_t currency = 0; currency < EnumValue(CurrencyType::Count); ++currency)
|
||||
{
|
||||
if (strncmp(currCode, CurrencyDescriptors[currency].isoCode, 3) == 0)
|
||||
{
|
||||
return static_cast<CurrencyType>(currency);
|
||||
}
|
||||
}
|
||||
|
||||
return CurrencyType::Pounds;
|
||||
}
|
||||
|
||||
rct2_date GetDateLocal()
|
||||
{
|
||||
auto time = std::time(nullptr);
|
||||
@@ -242,24 +260,6 @@ void platform_sleep(uint32_t ms)
|
||||
#endif
|
||||
}
|
||||
|
||||
CurrencyType platform_get_currency_value(const char* currCode)
|
||||
{
|
||||
if (currCode == nullptr || strlen(currCode) < 3)
|
||||
{
|
||||
return CurrencyType::Pounds;
|
||||
}
|
||||
|
||||
for (int32_t currency = 0; currency < EnumValue(CurrencyType::Count); ++currency)
|
||||
{
|
||||
if (strncmp(currCode, CurrencyDescriptors[currency].isoCode, 3) == 0)
|
||||
{
|
||||
return static_cast<CurrencyType>(currency);
|
||||
}
|
||||
}
|
||||
|
||||
return CurrencyType::Pounds;
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
float platform_get_default_scale()
|
||||
{
|
||||
|
||||
@@ -205,17 +205,6 @@ time_t platform_file_get_modified_time(const utf8* path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
CurrencyType platform_get_locale_currency()
|
||||
{
|
||||
CHAR currCode[4];
|
||||
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SINTLSYMBOL, reinterpret_cast<LPSTR>(&currCode), sizeof(currCode)) == 0)
|
||||
{
|
||||
return platform_get_currency_value(nullptr);
|
||||
}
|
||||
|
||||
return platform_get_currency_value(currCode);
|
||||
}
|
||||
|
||||
MeasurementFormat platform_get_locale_measurement_format()
|
||||
{
|
||||
UINT measurement_system;
|
||||
|
||||
@@ -45,15 +45,6 @@ bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size)
|
||||
}
|
||||
# endif // NO_TTF
|
||||
|
||||
CurrencyType platform_get_locale_currency()
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
NSString* currencyCode = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencyCode];
|
||||
return platform_get_currency_value(currencyCode.UTF8String);
|
||||
}
|
||||
}
|
||||
|
||||
MeasurementFormat platform_get_locale_measurement_format()
|
||||
{
|
||||
@autoreleasepool
|
||||
|
||||
@@ -105,8 +105,6 @@ void platform_sleep(uint32_t ms);
|
||||
void platform_get_user_directory(utf8* outPath, const utf8* subDirectory, size_t outSize);
|
||||
bool platform_open_common_file_dialog(utf8* outFilename, file_dialog_desc* desc, size_t outSize);
|
||||
utf8* platform_open_directory_browser(const utf8* title);
|
||||
CurrencyType platform_get_locale_currency();
|
||||
CurrencyType platform_get_currency_value(const char* currencyCode);
|
||||
MeasurementFormat platform_get_locale_measurement_format();
|
||||
TemperatureUnit platform_get_locale_temperature_format();
|
||||
uint8_t platform_get_locale_date_format();
|
||||
|
||||
Reference in New Issue
Block a user