diff --git a/osu.Game/Input/Bindings/DatabasedKeyBindingInputManager.cs b/osu.Game/Input/Bindings/DatabasedKeyBindingInputManager.cs index 8a3c65a35e..6dedf7385b 100644 --- a/osu.Game/Input/Bindings/DatabasedKeyBindingInputManager.cs +++ b/osu.Game/Input/Bindings/DatabasedKeyBindingInputManager.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Input.Bindings; using osu.Game.Rulesets; +using System.Linq; namespace osu.Game.Input.Bindings { @@ -44,11 +45,15 @@ namespace osu.Game.Input.Bindings private void load(KeyBindingStore keyBindings) { store = keyBindings; + store.KeyBindingChanged += ReloadMappings; } - protected override void ReloadMappings() + protected override void Dispose(bool isDisposing) { - KeyBindings = store.Query(ruleset?.ID, variant); + base.Dispose(isDisposing); + store.KeyBindingChanged -= ReloadMappings; } + + protected override void ReloadMappings() => KeyBindings = store.Query(ruleset?.ID, variant).ToList(); } } diff --git a/osu.Game/Input/KeyBindingStore.cs b/osu.Game/Input/KeyBindingStore.cs index bebbb471ac..b434ce4eb7 100644 --- a/osu.Game/Input/KeyBindingStore.cs +++ b/osu.Game/Input/KeyBindingStore.cs @@ -15,6 +15,8 @@ namespace osu.Game.Input { public class KeyBindingStore : DatabaseBackedStore { + public event Action KeyBindingChanged; + public KeyBindingStore(Func getContext, RulesetStore rulesets, Storage storage = null) : base(getContext, storage) { @@ -79,6 +81,8 @@ namespace osu.Game.Input var context = GetContext(); context.Update(keyBinding); context.SaveChanges(); + + KeyBindingChanged?.Invoke(); } } }