Fix key binding settings saving for current session after hitting Esc to cancel

This commit is contained in:
Sezz 2025-03-26 23:26:00 +11:00
parent c2c6b5f072
commit 22195b3267
3 changed files with 18 additions and 10 deletions

View file

@ -9,12 +9,13 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
* Added live console input to perform Lua commands in realtime.
### Bug fixes
* Fixed pathfinding for friendly NPCs, such as monkeys.
* Fixed pathfinding for friendly NPCs such as monkeys.
* Fixed particles remaining in the level after reloading from the savegame.
* Fixed particles being canceled by fog bulbs.
* Fixed crash in case hair object is the last object in a level.
* Fixed crash with incorrectly applied animated textures on static meshes.
* Fixed console window not hiding in non-debug mode on Windows 11.
* Fixed key binding settings saving for the current play session after hitting Esc to cancel.
### Lua API changes
* Added missing constructor for `Collision.Probe` without room number.

View file

@ -690,7 +690,7 @@ namespace TEN::Gui
CurrentSettings.IgnoreInput = true;
}
if (CurrentSettings.NewKeyWaitTimer > 0.0f)
if (CurrentSettings.NewKeyWaitTimer > 0)
{
ClearAllActions();
@ -699,15 +699,15 @@ namespace TEN::Gui
bool legacy30FpsDoneDraw = false;
bool decreaseCounter = false;
while (CurrentSettings.NewKeyWaitTimer > 0.0f)
while (CurrentSettings.NewKeyWaitTimer > 0)
{
g_Synchronizer.Sync();
while (g_Synchronizer.Synced())
{
CurrentSettings.NewKeyWaitTimer -= 1.0f;
if (CurrentSettings.NewKeyWaitTimer <= 0.0f)
CurrentSettings.NewKeyWaitTimer = 0.0f;
CurrentSettings.NewKeyWaitTimer--;
if (CurrentSettings.NewKeyWaitTimer <= 0)
CurrentSettings.NewKeyWaitTimer = 0;
if (!fromPauseMenu)
{
@ -760,7 +760,7 @@ namespace TEN::Gui
g_Bindings.SetKeyBinding(InputDeviceID::Custom, InputActionID(baseIndex + SelectedOption), selectedKeyID);
DefaultConflict();
CurrentSettings.NewKeyWaitTimer = 0.0f;
CurrentSettings.NewKeyWaitTimer = 0;
CurrentSettings.IgnoreInput = true;
return;
}
@ -850,6 +850,7 @@ namespace TEN::Gui
if (SelectedOption == (OptionCount - 2))
{
SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always);
ApplyDefaultBindings();
return;
}
@ -858,9 +859,11 @@ namespace TEN::Gui
if (SelectedOption == (OptionCount - 1))
{
SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always);
CurrentSettings.Configuration.Bindings = g_Bindings.GetBindingProfile(InputDeviceID::Custom);
g_Configuration.Bindings = g_Bindings.GetBindingProfile(InputDeviceID::Custom);
SaveConfiguration();
MenuToDisplay = fromPauseMenu ? Menu::Pause : Menu::Options;
SelectedOption = 2;
return;
@ -870,7 +873,9 @@ namespace TEN::Gui
if (SelectedOption == OptionCount)
{
SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always);
g_Bindings.SetBindingProfile(InputDeviceID::Custom, CurrentSettings.Configuration.Bindings);
MenuToDisplay = fromPauseMenu ? Menu::Pause : Menu::Options;
SelectedOption = 2;
return;
@ -881,6 +886,8 @@ namespace TEN::Gui
{
SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always);
g_Bindings.SetBindingProfile(InputDeviceID::Custom, CurrentSettings.Configuration.Bindings);
MenuToDisplay = Menu::Options;
SelectedOption = 2;
}

View file

@ -111,9 +111,9 @@ namespace TEN::Gui
GameConfiguration Configuration = {};
int SelectedScreenResolution = 0;
bool IgnoreInput = false; // Ignore input until all actions are inactive.
float NewKeyWaitTimer = 0.0f;
int SelectedScreenResolution = 0;
bool IgnoreInput = false; // Ignore input until all actions are inactive.
int NewKeyWaitTimer = 0;
};
class GuiController