mirror of https://github.com/OpenRCT2/OpenRCT2.git
Auto-detect locale on first run
This commit is contained in:
parent
1639f614f1
commit
f1a1639c8c
|
@ -133,7 +133,7 @@ namespace Config
|
||||||
model->autosave_frequency = reader->GetSint32("autosave", AUTOSAVE_EVERY_5MINUTES);
|
model->autosave_frequency = reader->GetSint32("autosave", AUTOSAVE_EVERY_5MINUTES);
|
||||||
model->confirmation_prompt = reader->GetBoolean("confirmation_prompt", false);
|
model->confirmation_prompt = reader->GetBoolean("confirmation_prompt", false);
|
||||||
model->construction_marker_colour = reader->GetBoolean("construction_marker_colour", false);
|
model->construction_marker_colour = reader->GetBoolean("construction_marker_colour", false);
|
||||||
model->currency_format = reader->GetEnum<sint32>("currency_format", CURRENCY_POUNDS, Enum_Currency);
|
model->currency_format = reader->GetEnum<sint32>("currency_format", platform_get_locale_currency(), Enum_Currency);
|
||||||
model->custom_currency_rate = reader->GetSint32("custom_currency_rate", 10);
|
model->custom_currency_rate = reader->GetSint32("custom_currency_rate", 10);
|
||||||
model->custom_currency_affix = reader->GetEnum<sint32>("custom_currency_affix", CURRENCY_SUFFIX, Enum_CurrencySymbolAffix);
|
model->custom_currency_affix = reader->GetEnum<sint32>("custom_currency_affix", CURRENCY_SUFFIX, Enum_CurrencySymbolAffix);
|
||||||
model->custom_currency_symbol = reader->GetCString("custom_currency_symbol", "Ctm");
|
model->custom_currency_symbol = reader->GetCString("custom_currency_symbol", "Ctm");
|
||||||
|
@ -144,13 +144,13 @@ namespace Config
|
||||||
model->rct1_path = reader->GetCString("rct1_path", nullptr);
|
model->rct1_path = reader->GetCString("rct1_path", nullptr);
|
||||||
model->rct2_path = reader->GetCString("game_path", nullptr);
|
model->rct2_path = reader->GetCString("game_path", nullptr);
|
||||||
model->landscape_smoothing = reader->GetBoolean("landscape_smoothing", true);
|
model->landscape_smoothing = reader->GetBoolean("landscape_smoothing", true);
|
||||||
model->language = reader->GetEnum<sint32>("language", LANGUAGE_ENGLISH_UK, Enum_LanguageEnum);
|
model->language = reader->GetEnum<sint32>("language", platform_get_locale_language(), Enum_LanguageEnum);
|
||||||
model->measurement_format = reader->GetEnum<sint32>("measurement_format", MEASUREMENT_FORMAT_METRIC, Enum_MeasurementFormat);
|
model->measurement_format = reader->GetEnum<sint32>("measurement_format", platform_get_locale_measurement_format(), Enum_MeasurementFormat);
|
||||||
model->play_intro = reader->GetBoolean("play_intro", false);
|
model->play_intro = reader->GetBoolean("play_intro", false);
|
||||||
model->save_plugin_data = reader->GetBoolean("save_plugin_data", true);
|
model->save_plugin_data = reader->GetBoolean("save_plugin_data", true);
|
||||||
model->debugging_tools = reader->GetBoolean("debugging_tools", false);
|
model->debugging_tools = reader->GetBoolean("debugging_tools", false);
|
||||||
model->show_height_as_units = reader->GetBoolean("show_height_as_units", false);
|
model->show_height_as_units = reader->GetBoolean("show_height_as_units", false);
|
||||||
model->temperature_format = reader->GetEnum<sint32>("temperature_format", TEMPERATURE_FORMAT_C, Enum_Temperature);
|
model->temperature_format = reader->GetEnum<sint32>("temperature_format", platform_get_locale_temperature_format(), Enum_Temperature);
|
||||||
model->window_height = reader->GetSint32("window_height", -1);
|
model->window_height = reader->GetSint32("window_height", -1);
|
||||||
model->window_snap_proximity = reader->GetSint32("window_snap_proximity", 5);
|
model->window_snap_proximity = reader->GetSint32("window_snap_proximity", 5);
|
||||||
model->window_width = reader->GetSint32("window_width", -1);
|
model->window_width = reader->GetSint32("window_width", -1);
|
||||||
|
@ -161,7 +161,7 @@ namespace Config
|
||||||
model->test_unfinished_tracks = reader->GetBoolean("test_unfinished_tracks", false);
|
model->test_unfinished_tracks = reader->GetBoolean("test_unfinished_tracks", false);
|
||||||
|
|
||||||
model->no_test_crashes = reader->GetBoolean("no_test_crashes", false);
|
model->no_test_crashes = reader->GetBoolean("no_test_crashes", false);
|
||||||
model->date_format = reader->GetEnum<sint32>("date_format", DATE_FORMAT_DAY_MONTH_YEAR, Enum_DateFormat);
|
model->date_format = reader->GetEnum<sint32>("date_format", platform_get_locale_date_format(), Enum_DateFormat);
|
||||||
model->auto_staff_placement = reader->GetBoolean("auto_staff", true);
|
model->auto_staff_placement = reader->GetBoolean("auto_staff", true);
|
||||||
model->handymen_mow_default = reader->GetBoolean("handymen_mow_default", false);
|
model->handymen_mow_default = reader->GetBoolean("handymen_mow_default", false);
|
||||||
model->default_inspection_interval = reader->GetSint32("default_inspection_interval", 2);
|
model->default_inspection_interval = reader->GetSint32("default_inspection_interval", 2);
|
||||||
|
|
|
@ -201,6 +201,8 @@ uint8 platform_get_currency_value(const char *currencyCode);
|
||||||
uint16 platform_get_locale_language();
|
uint16 platform_get_locale_language();
|
||||||
uint8 platform_get_locale_measurement_format();
|
uint8 platform_get_locale_measurement_format();
|
||||||
uint8 platform_get_locale_temperature_format();
|
uint8 platform_get_locale_temperature_format();
|
||||||
|
uint8 platform_get_locale_date_format();
|
||||||
|
|
||||||
#ifndef NO_TTF
|
#ifndef NO_TTF
|
||||||
bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size);
|
bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size);
|
||||||
#endif // NO_TTF
|
#endif // NO_TTF
|
||||||
|
|
|
@ -30,8 +30,10 @@
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
|
#include "../localisation/date.h"
|
||||||
#include "../localisation/language.h"
|
#include "../localisation/language.h"
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
#include "../util/util.h"
|
#include "../util/util.h"
|
||||||
|
@ -949,6 +951,50 @@ uint8 platform_get_locale_temperature_format()
|
||||||
return TEMPERATURE_FORMAT_C;
|
return TEMPERATURE_FORMAT_C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8 platform_get_locale_date_format()
|
||||||
|
{
|
||||||
|
// Retrieve short date format, eg "MM/dd/yyyy"
|
||||||
|
wchar_t dateFormat[20];
|
||||||
|
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SSHORTDATE, dateFormat, sizeof(dateFormat)) == 0)
|
||||||
|
{
|
||||||
|
return DATE_FORMAT_DAY_MONTH_YEAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The only valid characters for format types are: dgyM
|
||||||
|
// We try to find 3 strings of format types, ignore any characters in between.
|
||||||
|
// We also ignore 'g', as it represents 'era' and we don't have that concept
|
||||||
|
// in our date formats.
|
||||||
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd317787(v=vs.85).aspx
|
||||||
|
//
|
||||||
|
wchar_t first[sizeof(dateFormat)];
|
||||||
|
wchar_t second[sizeof(dateFormat)];
|
||||||
|
if (swscanf(dateFormat, L"%l[dyM]%*l[^dyM]%l[dyM]%*l[^dyM]%*l[dyM]", first, second) != 2) {
|
||||||
|
return DATE_FORMAT_DAY_MONTH_YEAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcsncmp(L"d", first, 1) == 0)
|
||||||
|
{
|
||||||
|
return DATE_FORMAT_DAY_MONTH_YEAR;
|
||||||
|
}
|
||||||
|
else if (wcsncmp(L"M", first, 1) == 0)
|
||||||
|
{
|
||||||
|
return DATE_FORMAT_MONTH_DAY_YEAR;
|
||||||
|
}
|
||||||
|
else if (wcsncmp(L"y", first, 1) == 0)
|
||||||
|
{
|
||||||
|
if (wcsncmp(L"d", second, 1) == 0) {
|
||||||
|
return DATE_FORMAT_YEAR_DAY_MONTH;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Closest possible option
|
||||||
|
return DATE_FORMAT_YEAR_MONTH_DAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default fallback
|
||||||
|
return DATE_FORMAT_DAY_MONTH_YEAR;
|
||||||
|
}
|
||||||
|
|
||||||
bool platform_check_steam_overlay_attached()
|
bool platform_check_steam_overlay_attached()
|
||||||
{
|
{
|
||||||
return GetModuleHandle("GameOverlayRenderer.dll") != NULL;
|
return GetModuleHandle("GameOverlayRenderer.dll") != NULL;
|
||||||
|
|
Loading…
Reference in New Issue