From ad6e31aa128c488cf56fc44a3533c2cb99037a26 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 21 Jan 2024 23:43:03 -0800 Subject: [PATCH] Disable switching languages during cutscene tests Not gonna lie, I am a bit disappointed at having to do this, because it actually worked pretty well despite a few bugs depending on which language you entered with. But that's only because I'm working with the official translation files, which are in sync with each other. With translation files that are completely arbitrary, it would be apparent that switching languages during the cutscene test doesn't really make sense. Like, at all. That's because the list of cutscenes is populated entirely from language-specific XML and the cutscenes in them are also from language-specific XML. So keeping the same position in the menu doesn't really make sense, and keeping the same position in a cutscene definitely doesn't make sense. --- desktop_version/src/Game.cpp | 2 +- desktop_version/src/Input.cpp | 6 +++ desktop_version/src/KeyPoll.cpp | 95 +++++++++++++++++++++------------ 3 files changed, 68 insertions(+), 35 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index b46e7b7f..151cef1f 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6809,7 +6809,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) option(loc::gettext("audio")); option(loc::gettext("game pad")); option(loc::gettext("accessibility")); - option(loc::gettext("language")); + option(loc::gettext("language"), !translator_cutscene_test); option(loc::gettext("return")); menuyoff = 0; maxspacing = 15; diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index eeeab1cb..d1c03f35 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1062,6 +1062,12 @@ static void menuactionpress(void) break; case 5: //language options + if (game.translator_cutscene_test) + { + music.playef(Sound_CRY); + break; + } + music.playef(Sound_VIRIDIAN); loc::loadlanguagelist(); loc::pre_title_lang_menu = false; diff --git a/desktop_version/src/KeyPoll.cpp b/desktop_version/src/KeyPoll.cpp index 92be5ba0..d9454a94 100644 --- a/desktop_version/src/KeyPoll.cpp +++ b/desktop_version/src/KeyPoll.cpp @@ -142,6 +142,66 @@ static int changemousestate( /* Also used in Input.cpp. */ void recomputetextboxes(void); +bool cycle_language(bool should_recompute_textboxes) +{ + extern KeyPoll key; + + if (game.gamestate == TITLEMODE + && game.currentmenuname == Menu::translator_options_cutscenetest) + { + /* Unfortunately, despite how it may appear to be working, the options + * are actually language-specific, and the order could be totally + * different between languages too. So we can't cycle in this menu. */ + music.playef(Sound_CRY); + return should_recompute_textboxes; + } + if (game.translator_cutscene_test) + { + /* Refuse cycling here for similar reasons, even if it seems like it's + * working. The text boxes are based off of the language XML and + * could be completely different between languages. */ + music.playef(Sound_CRY); + return should_recompute_textboxes; + } + + int i = loc::languagelist_curlang; + if (key.keymap[SDLK_LSHIFT]) + { + /* Backwards */ + i--; + } + else + { + /* Forwards */ + i++; + } + if (!loc::languagelist.empty()) + { + i = POS_MOD(i, (int) loc::languagelist.size()); + + loc::languagelist_curlang = i; + loc::lang = loc::languagelist[i].code; + loc::loadtext(false); + graphics.grphx.init_translations(); + + should_recompute_textboxes = true; + } + + if (game.gamestate == TITLEMODE) + { + int temp = game.menucountdown; + game.createmenu(game.currentmenuname, true); + game.menucountdown = temp; + + if (game.currentmenuname == Menu::language) + { + game.currentmenuoption = i; + } + } + + return should_recompute_textboxes; +} + void KeyPoll::Poll(void) { static int raw_mousex = 0; @@ -188,40 +248,7 @@ void KeyPoll::Poll(void) if (keymap[SDLK_LCTRL]) { /* Debug keybind to cycle language. */ - int i = loc::languagelist_curlang; - if (keymap[SDLK_LSHIFT]) - { - /* Backwards */ - i--; - } - else - { - /* Forwards */ - i++; - } - if (!loc::languagelist.empty()) - { - i = POS_MOD(i, (int) loc::languagelist.size()); - - loc::languagelist_curlang = i; - loc::lang = loc::languagelist[i].code; - loc::loadtext(false); - graphics.grphx.init_translations(); - - should_recompute_textboxes = true; - } - - if (game.gamestate == TITLEMODE) - { - int temp = game.menucountdown; - game.createmenu(game.currentmenuname, true); - game.menucountdown = temp; - - if (game.currentmenuname == Menu::language) - { - game.currentmenuoption = i; - } - } + should_recompute_textboxes = cycle_language(should_recompute_textboxes); } else {