1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-21 05:53:02 +01:00

Merge pull request #2204 from janisozaur/language-check

Early out and report error if langauge files are missing
This commit is contained in:
Duncan
2015-11-05 22:02:25 +00:00
4 changed files with 28 additions and 6 deletions

View File

@@ -2146,6 +2146,7 @@ enum {
STR_STAY_CONNECTED_AFTER_DESYNC = 5557,
STR_RESTART_REQUIRED = 5558,
STR_LANGUAGE_LOAD_FAILED = 5561,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working

View File

@@ -225,7 +225,11 @@ bool openrct2_initialise()
audio_init();
audio_get_devices();
}
language_open(gConfigGeneral.language);
if (!language_open(gConfigGeneral.language))
{
log_fatal("Failed to open language, exiting.");
return false;
}
http_init();
themes_set_default();

View File

@@ -1010,11 +1010,27 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown
}
break;
case WIDX_LANGUAGE_DROPDOWN:
if (dropdownIndex != gCurrentLanguage - 1) {
language_open(dropdownIndex + 1);
gConfigGeneral.language = dropdownIndex + 1;
config_save_default();
gfx_invalidate_screen();
{
int fallbackLanguage = gCurrentLanguage;
if (dropdownIndex != gCurrentLanguage - 1) {
if (!language_open(dropdownIndex + 1))
{
// Failed to open language file, try to recover by falling
// back to previously used language
if (language_open(fallbackLanguage))
{
// It worked, so we can say it with error message in-game
window_error_open(STR_LANGUAGE_LOAD_FAILED, STR_NONE);
}
// report error to console regardless
log_error("Failed to open language file.");
dropdownIndex = fallbackLanguage - 1;
} else {
gConfigGeneral.language = dropdownIndex + 1;
config_save_default();
gfx_invalidate_screen();
}
}
}
break;
case WIDX_DATE_FORMAT_DROPDOWN: