1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +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

@@ -3899,6 +3899,7 @@ STR_5557 :Stay connected after desynchronisation (Multiplayer)
STR_5558 :A restart is required for this setting to take effect STR_5558 :A restart is required for this setting to take effect
STR_5559 :10 min. inspections STR_5559 :10 min. inspections
STR_5560 :{SMALLFONT}{BLACK}Sets the inspection time to 'Every 10 minutes' on all rides STR_5560 :{SMALLFONT}{BLACK}Sets the inspection time to 'Every 10 minutes' on all rides
STR_5561 :Failed to load language file
##################### #####################

View File

@@ -2146,6 +2146,7 @@ enum {
STR_STAY_CONNECTED_AFTER_DESYNC = 5557, STR_STAY_CONNECTED_AFTER_DESYNC = 5557,
STR_RESTART_REQUIRED = 5558, 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 // 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_init();
audio_get_devices(); audio_get_devices();
} }
language_open(gConfigGeneral.language); if (!language_open(gConfigGeneral.language))
{
log_fatal("Failed to open language, exiting.");
return false;
}
http_init(); http_init();
themes_set_default(); themes_set_default();

View File

@@ -1010,11 +1010,27 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown
} }
break; break;
case WIDX_LANGUAGE_DROPDOWN: case WIDX_LANGUAGE_DROPDOWN:
if (dropdownIndex != gCurrentLanguage - 1) { {
language_open(dropdownIndex + 1); int fallbackLanguage = gCurrentLanguage;
gConfigGeneral.language = dropdownIndex + 1; if (dropdownIndex != gCurrentLanguage - 1) {
config_save_default(); if (!language_open(dropdownIndex + 1))
gfx_invalidate_screen(); {
// 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; break;
case WIDX_DATE_FORMAT_DROPDOWN: case WIDX_DATE_FORMAT_DROPDOWN: