1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 11:12:55 +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++]; var button = buttons[i++];
button.UpdateKeyCombination(d); button.UpdateKeyCombination(d);
using (var usage = realmFactory.GetForWrite()) updateStoreFromButton(button);
{
var binding = usage.Realm.Find<RealmKeyBinding>(((IHasGuidPrimaryKey)button.KeyBinding).ID.ToString());
binding.KeyCombinationString = button.KeyBinding.KeyCombinationString;
usage.Commit();
}
} }
} }
@ -294,13 +288,7 @@ namespace osu.Game.Overlays.KeyBinding
{ {
if (bindTarget != null) if (bindTarget != null)
{ {
using (var write = realmFactory.GetForWrite()) updateStoreFromButton(bindTarget);
{
var binding = write.Realm.Find<RealmKeyBinding>(((IHasGuidPrimaryKey)bindTarget.KeyBinding).ID.ToString());
binding.KeyCombinationString = bindTarget.KeyBinding.KeyCombinationString;
write.Commit();
}
bindTarget.IsBinding = false; bindTarget.IsBinding = false;
Schedule(() => Schedule(() =>
@ -345,6 +333,17 @@ namespace osu.Game.Overlays.KeyBinding
if (bindTarget != null) bindTarget.IsBinding = true; 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 private class CancelButton : TriangleButton
{ {
public CancelButton() public CancelButton()