1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Early out and report error if langauge files are missing

This is a common problem if you don't set up your paths properly on
Linux, so be nice and try to provide helpful message why we failed to
load instead of crashing on user a moment later.
This commit is contained in:
Michał Janiszewski
2015-11-04 18:11:10 +01:00
parent e2ce5ee49e
commit 2d62c356c3
4 changed files with 28 additions and 6 deletions

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: