1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Add debug keybind CTRL+(SHIFT)+F8 to cycle lang

This adds a debug keybind to cycle the current language forwards,
CTRL+F8. It also adds a debug keybind to cycle it backwards,
CTRL+SHIFT+F8.

This is only active if the translator menu is active (and so if the
regular F8 keybind is also active).

This is useful for quickly catching errors in translations and/or
inconsistencies between translations. In fact, I've already caught
several translation mistakes using this keybind which made me mildly
panic that I screwed something up in my own code, only to realize that
no, actually, it was the translation that was at fault.

For now, this is only meant to be used in-game, as text boxes get
retranslated instantly, whereas things like menu options don't. But menu
options will be retranslated on-the-fly in a later commit.
This commit is contained in:
Misa 2024-01-21 14:39:18 -08:00 committed by Misa Elizabeth Kai
parent 84daa8fbc2
commit 9b56a53d98
2 changed files with 42 additions and 5 deletions

View file

@ -269,7 +269,8 @@ static void updatebuttonmappings(int bind)
} }
} }
static void recomputetextboxes(void) /* Also used in KeyPoll.cpp. */
void recomputetextboxes(void)
{ {
/* Retranslate and reposition all text boxes. /* Retranslate and reposition all text boxes.
* WARNING: Needs to update in linear order, starting from 0. */ * WARNING: Needs to update in linear order, starting from 0. */
@ -1131,6 +1132,8 @@ static void menuactionpress(void)
if (loc::languagelist.size() != 0 && (unsigned)game.currentmenuoption < loc::languagelist.size()) if (loc::languagelist.size() != 0 && (unsigned)game.currentmenuoption < loc::languagelist.size())
{ {
/* Update code also used in KeyPoll.cpp. */
loc::languagelist_curlang = game.currentmenuoption;
loc::lang = loc::languagelist[game.currentmenuoption].code; loc::lang = loc::languagelist[game.currentmenuoption].code;
loc::loadtext(false); loc::loadtext(false);
loc::lang_set = true; loc::lang_set = true;

View file

@ -16,6 +16,7 @@
#include "Music.h" #include "Music.h"
#include "Screen.h" #include "Screen.h"
#include "UTF8.h" #include "UTF8.h"
#include "UtilityClass.h"
#include "Vlogging.h" #include "Vlogging.h"
bool SaveScreenshot(void); bool SaveScreenshot(void);
@ -138,6 +139,9 @@ static int changemousestate(
return timeout; return timeout;
} }
/* Also used in Input.cpp. */
void recomputetextboxes(void);
void KeyPoll::Poll(void) void KeyPoll::Poll(void)
{ {
static int raw_mousex = 0; static int raw_mousex = 0;
@ -177,12 +181,42 @@ void KeyPoll::Poll(void)
} }
if (loc::show_translator_menu && evt.key.keysym.sym == SDLK_F8 && !evt.key.repeat) if (loc::show_translator_menu && evt.key.keysym.sym == SDLK_F8 && !evt.key.repeat)
{
if (keymap[SDLK_LCTRL])
{
/* Debug keybind to cycle language.
* Not really meant to be used inside menus. */
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();
recomputetextboxes();
}
}
else
{ {
/* Reload language files */ /* Reload language files */
loc::loadtext(false); loc::loadtext(false);
graphics.grphx.init_translations(); graphics.grphx.init_translations();
music.playef(Sound_COIN); music.playef(Sound_COIN);
} }
}
if (evt.key.keysym.sym == SDLK_F6 && !evt.key.repeat) if (evt.key.keysym.sym == SDLK_F6 && !evt.key.repeat)
{ {