From 8484b3619858d505cc9d463cab17cacc3ad795e5 Mon Sep 17 00:00:00 2001 From: Dav999 Date: Tue, 29 Aug 2023 23:03:08 +0200 Subject: [PATCH] Fix "no language files found" title screen bug If you've never set a language before ( is not 1), then the language screen will show up before the title screen. Selecting the language will then make the title screen show up. If no language files are present, the old logic for handling this was to simply show the language screen at startup anyway, and let it display the error message that language files are missing, as a warning that the game is not packaged correctly. However, this logic has two flaws: - If the user has ever had language files and set a language before (in a VVVVVV on that computer), the warning element is gone because the language screen is not shown in that case - the game is simply in English - If the user has never set a language before, and then goes to the language screen later via the menu, they will be sent to the title screen, even if they were in-game. The main menu will also be broken. The new way is to not show the language screen at startup if language files are missing, and to change the logic so that you will only be sent to the title screen if you actually haven't seen the title screen yet. I will also add a proper warning that fonts or language files are missing by adding a message in the bottom left corner (in place of the MMMMMM installed message). --- desktop_version/src/Input.cpp | 7 +++---- desktop_version/src/Localization.cpp | 2 ++ desktop_version/src/Localization.h | 2 ++ desktop_version/src/main.cpp | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 2df8963b..3614e458 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1098,8 +1098,6 @@ static void menuactionpress(void) { music.playef(Sound_VIRIDIAN); - bool show_title = !loc::lang_set; - if (loc::languagelist.size() != 0 && (unsigned)game.currentmenuoption < loc::languagelist.size()) { loc::lang = loc::languagelist[game.currentmenuoption].code; @@ -1107,12 +1105,13 @@ static void menuactionpress(void) loc::lang_set = true; } - if (show_title) + if (loc::pre_title_lang_menu) { /* Make the title screen appear, we haven't seen it yet */ game.menustart = false; game.createmenu(Menu::mainmenu); game.currentmenuoption = 0; + loc::pre_title_lang_menu = false; } else { @@ -2226,7 +2225,7 @@ void titleinput(void) && game.menucountdown <= 0 && (key.isDown(27) || key.isDown(game.controllerButton_esc))) { - if (game.currentmenuname == Menu::language && !loc::lang_set) + if (game.currentmenuname == Menu::language && loc::pre_title_lang_menu) { /* Don't exit from the initial language screen, * you can't do this on the loading/title screen either. */ diff --git a/desktop_version/src/Localization.cpp b/desktop_version/src/Localization.cpp index 88ee0867..c8105430 100644 --- a/desktop_version/src/Localization.cpp +++ b/desktop_version/src/Localization.cpp @@ -12,6 +12,8 @@ namespace loc { bool lang_set = false; +bool pre_title_lang_menu = false; + std::string lang = "en"; std::string lang_custom = ""; std::string new_level_font = ""; diff --git a/desktop_version/src/Localization.h b/desktop_version/src/Localization.h index 71e615ce..c63b3771 100644 --- a/desktop_version/src/Localization.h +++ b/desktop_version/src/Localization.h @@ -45,6 +45,8 @@ struct TextboxFormat }; extern bool lang_set; +extern bool pre_title_lang_menu; + extern std::string lang; extern std::string lang_custom; extern std::string new_level_font; diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index da782e22..300f675f 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -661,8 +661,9 @@ int main(int argc, char *argv[]) game.gamestate = TITLEMODE; if (game.slowdown == 0) game.slowdown = 30; - if (!loc::lang_set) + if (!loc::lang_set && !loc::languagelist.empty()) { + loc::pre_title_lang_menu = true; game.gamestate = TITLEMODE; game.menustart = true; game.createmenu(Menu::language);