1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 10:17:32 +08:00

Extract common implementation into private method

This commit is contained in:
Dean Herbert 2021-04-03 18:58:25 +09:00
parent 7e73af1c5a
commit cc9db90d11

View File

@ -129,13 +129,7 @@ namespace osu.Game.Overlays.KeyBinding
var button = buttons[i++];
button.UpdateKeyCombination(d);
using (var usage = realmFactory.GetForWrite())
{
var binding = usage.Realm.Find<RealmKeyBinding>(((IHasGuidPrimaryKey)button.KeyBinding).ID.ToString());
binding.KeyCombinationString = button.KeyBinding.KeyCombinationString;
usage.Commit();
}
updateStoreFromButton(button);
}
}
@ -294,13 +288,7 @@ namespace osu.Game.Overlays.KeyBinding
{
if (bindTarget != null)
{
using (var write = realmFactory.GetForWrite())
{
var binding = write.Realm.Find<RealmKeyBinding>(((IHasGuidPrimaryKey)bindTarget.KeyBinding).ID.ToString());
binding.KeyCombinationString = bindTarget.KeyBinding.KeyCombinationString;
write.Commit();
}
updateStoreFromButton(bindTarget);
bindTarget.IsBinding = false;
Schedule(() =>
@ -345,6 +333,17 @@ namespace osu.Game.Overlays.KeyBinding
if (bindTarget != null) bindTarget.IsBinding = true;
}
private void updateStoreFromButton(KeyButton button)
{
using (var usage = realmFactory.GetForWrite())
{
var binding = usage.Realm.Find<RealmKeyBinding>(((IHasGuidPrimaryKey)button.KeyBinding).ID.ToString());
binding.KeyCombinationString = button.KeyBinding.KeyCombinationString;
usage.Commit();
}
}
private class CancelButton : TriangleButton
{
public CancelButton()