diff --git a/src/lang.h b/src/lang.h index 9f813d8b..3bbaccc3 100644 --- a/src/lang.h +++ b/src/lang.h @@ -291,13 +291,14 @@ enum StringID { #define STR_SCALE "25", "50", "75", "100" -const char *helpText = +static char helpText[1024]; +const char *helpTextFormat = "Start - add second player or restore Lara@" "H - Show or hide this help@" "ALT and ENTER - Fullscreen@" "5 - Save Game@" "9 - Load Game@" - "C - Look@" + "%s - Look@" "R - Slow motion@" "T - Fast motion@" "Roll - Up & Down@" @@ -310,6 +311,20 @@ const char *helpText = "DOZY on - Look & Duck & Action & Jump@" "DOZY off - Walk@" "Free Camera - hold L & R stick"; +inline const char* getKeyName(InputKey key) { + static const char* keyNames[] = { + STR_KEYS + }; + if ((int)key >= 0 && (int)key < COUNT(keyNames)) + return keyNames[(int)key]; + return "UNKNOWN"; +} + +inline void updateHelpText() { + InputKey lookKey = (InputKey)Core::settings.controls[0].keys[cLook].key; + const char* keyName = getKeyName(lookKey); + sprintf(helpText, helpTextFormat, keyName); +} #include "lang/en.h" #include "lang/fr.h" diff --git a/src/ui.h b/src/ui.h index 03cf736b..a7b73849 100644 --- a/src/ui.h +++ b/src/ui.h @@ -541,6 +541,7 @@ namespace UI { void init(IGame *game) { ensureLanguage(Core::settings.audio.language); + updateHelpText(); UI::game = game; showHelp = false; helpTipTime = 5.0f; @@ -635,6 +636,7 @@ namespace UI { if (Input::down[ikH]) { Input::down[ikH] = false; showHelp = !showHelp; + updateHelpText(); helpTipTime = 0.0f; } if (helpTipTime > 0.0f) @@ -726,7 +728,7 @@ namespace UI { #if defined(_OS_WEB) || defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_MAC) || defined(_OS_RPI) if (showHelp) { - textOut(vec2(32, 32), STR_HELP_TEXT, aLeft, width - 32, 255, UI::SHADE_GRAY); + textOut(vec2(32, 32), helpText, aLeft, width - 32, 255, UI::SHADE_GRAY); } else { if (helpTipTime > 0.0f) { textOut(vec2(0, height - 16), STR_HELP_PRESS, aCenter, width, 255, UI::SHADE_ORANGE);