mirror of https://github.com/ppy/osu
Merge remote-tracking branch 'upstream/master' into import-test-fixes
This commit is contained in:
commit
7ba22f0028
|
@ -6,6 +6,7 @@
|
|||
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 @@ protected DatabasedKeyBindingInputManager(RulesetInfo ruleset = null, int? varia
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace osu.Game.Input
|
|||
{
|
||||
public class KeyBindingStore : DatabaseBackedStore
|
||||
{
|
||||
public event Action KeyBindingChanged;
|
||||
|
||||
public KeyBindingStore(Func<OsuDbContext> getContext, RulesetStore rulesets, Storage storage = null)
|
||||
: base(getContext, storage)
|
||||
{
|
||||
|
@ -79,6 +81,8 @@ public void Update(KeyBinding keyBinding)
|
|||
var context = GetContext();
|
||||
context.Update(keyBinding);
|
||||
context.SaveChanges();
|
||||
|
||||
KeyBindingChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue