diff --git a/src/config.c b/src/config.c index 9b5d4a2b0f..fc8887a0d2 100644 --- a/src/config.c +++ b/src/config.c @@ -201,7 +201,24 @@ void config_set_defaults() config_property_definition *property = §ion->property_definitions[j]; value_union *destValue = (value_union*)((size_t)section->base_address + (size_t)property->offset); - memcpy(destValue, &property->default_value, _configValueTypeSize[property->type]); + + if (strcmp(property->property_name, "language") == 0){ + destValue->value_uint16 = platform_get_locale_language(); + if (destValue->value_uint16 == LANGUAGE_UNDEFINED) + memcpy(destValue, &property->default_value, _configValueTypeSize[property->type]); + } + else if (strcmp(property->property_name, "currency_format") == 0){ + destValue->value_uint8 = platform_get_locale_currency(); + } + else if (strcmp(property->property_name, "measurement_format") == 0){ + destValue->value_uint8 = platform_get_locale_measurement_format(); + } + else if (strcmp(property->property_name, "temperature_format") == 0){ + destValue->value_uint8 = platform_get_locale_temperature_format(); + } + else { + memcpy(destValue, &property->default_value, _configValueTypeSize[property->type]); + } } } } diff --git a/src/config.h b/src/config.h index c42215fea9..258c5917ff 100644 --- a/src/config.h +++ b/src/config.h @@ -151,6 +151,8 @@ void config_set_defaults(); bool config_open_default(); bool config_save_default(); +uint16 getLanguage(); + void config_reset_shortcut_keys(); bool config_find_or_browse_install_directory(); diff --git a/src/platform/platform.h b/src/platform/platform.h index 3ffb128872..98bd6b0041 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -105,6 +105,10 @@ void platform_get_user_directory(char *outPath, const char *subDirectory); void platform_show_messagebox(char *message); int platform_open_common_file_dialog(int type, char *title, char *filename, char *filterPattern, char *filterName); char *platform_open_directory_browser(char *title); +uint8 platform_get_locale_currency(); +uint16 platform_get_locale_language(); +uint8 platform_get_locale_measurement_format(); +uint8 platform_get_locale_temperature_format(); // Windows specific definitions #ifdef _WIN32 diff --git a/src/platform/windows.c b/src/platform/windows.c index 35a8493c81..7517d30fa7 100644 --- a/src/platform/windows.c +++ b/src/platform/windows.c @@ -26,6 +26,9 @@ #include "../addresses.h" #include "../cmdline.h" #include "../openrct2.h" +#include "../localisation/language.h" +#include "../localisation/currency.h" +#include "../config.h" #include "platform.h" // The name of the mutex used to prevent multiple instances of the game from running @@ -591,4 +594,120 @@ PCHAR *CommandLineToArgvA(PCHAR CmdLine, int *_argc) return argv; } -#endif \ No newline at end of file +uint16 platform_get_locale_language(){ + CHAR langCode[4]; + + if (GetLocaleInfo(LOCALE_USER_DEFAULT, + LOCALE_SABBREVLANGNAME, + (LPSTR)&langCode, + sizeof(langCode)) == 0){ + return LANGUAGE_UNDEFINED; + } + + if (strcmp(langCode, "ENG") == 0){ + return LANGUAGE_ENGLISH_UK; + } + else if (strcmp(langCode, "ENU") == 0){ + return LANGUAGE_ENGLISH_US; + } + else if (strcmp(langCode, "DEU") == 0){ + return LANGUAGE_GERMAN; + } + else if (strcmp(langCode, "NLD") == 0){ + return LANGUAGE_DUTCH; + } + else if (strcmp(langCode, "FRA") == 0){ + return LANGUAGE_FRENCH; + } + else if (strcmp(langCode, "HUN") == 0){ + return LANGUAGE_HUNGARIAN; + } + else if (strcmp(langCode, "PLK") == 0){ + return LANGUAGE_POLISH; + } + else if (strcmp(langCode, "ESP") == 0){ + return LANGUAGE_SPANISH; + } + else if (strcmp(langCode, "SVE") == 0){ + return LANGUAGE_SWEDISH; + } + return LANGUAGE_UNDEFINED; +} + +uint8 platform_get_locale_currency(){ + CHAR currCode[4]; + + if (GetLocaleInfo(LOCALE_USER_DEFAULT, + LOCALE_SINTLSYMBOL, + (LPSTR)&currCode, + sizeof(currCode)) == 0){ + return CURRENCY_POUNDS; + } + if (strcmp(currCode, "GBP") == 0){ + return CURRENCY_POUNDS; + } + else if (strcmp(currCode, "USD") == 0){ + return CURRENCY_DOLLARS; + } + else if (strcmp(currCode, "EUR") == 0){ + return CURRENCY_EUROS; + } + else if (strcmp(currCode, "SEK") == 0){ + return CURRENCY_KRONA; + } + else if (strcmp(currCode, "DEM") == 0){ + return CURRENCY_DEUTSCHMARK; + } + else if (strcmp(currCode, "ITL") == 0){ + return CURRENCY_LIRA; + } + else if (strcmp(currCode, "JPY") == 0){ + return CURRENCY_YEN; + } + else if (strcmp(currCode, "ESP") == 0){ + return CURRENCY_PESETA; + } + else if (strcmp(currCode, "FRF") == 0){ + return CURRENCY_FRANC; + } + else if (strcmp(currCode, "NLG") == 0){ + return CURRENCY_GUILDERS; + } + return CURRENCY_POUNDS; +} + +uint8 platform_get_locale_measurement_format(){ + UINT measurement_system; + if (GetLocaleInfo(LOCALE_USER_DEFAULT, + LOCALE_IMEASURE | LOCALE_RETURN_NUMBER, + (LPSTR)&measurement_system, + sizeof(measurement_system)) == 0){ + return MEASUREMENT_FORMAT_IMPERIAL; + } + switch (measurement_system){ + case 0: + return MEASUREMENT_FORMAT_METRIC; + case 1: + default: + return MEASUREMENT_FORMAT_IMPERIAL; + } +} + +uint8 platform_get_locale_temperature_format(){ + // There does not seem to be a function to obtain this, just check the countries + UINT country; + if (GetLocaleInfo(LOCALE_USER_DEFAULT, + LOCALE_IMEASURE | LOCALE_RETURN_NUMBER, + (LPSTR)&country, + sizeof(country)) == 0){ + return TEMPERATURE_FORMAT_C; + } + switch (country){ + case CTRY_UNITED_STATES: + case CTRY_BELIZE: + return TEMPERATURE_FORMAT_F; + default: + return TEMPERATURE_FORMAT_C; + } +} +#endif diff --git a/src/title.c b/src/title.c index d7fbbd9f44..e3d568ed5c 100644 --- a/src/title.c +++ b/src/title.c @@ -266,6 +266,7 @@ static void DrawOpenRCT2(int x, int y) void game_handle_input(); void title_update() { + screenshot_check(); title_handle_keyboard_input();