mirror of
https://github.com/ppy/osu.git
synced 2025-03-01 23:32:57 +08:00
Switch records to classes for sanity
I don't have anything against records except for the capitalisation when including the paramter names in a constructor. ie. `new Record(This: 1);`
This commit is contained in:
parent
d7a06059f2
commit
8e609b6f1d
@ -44,8 +44,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
|
|
||||||
public delegate void KeyBindingUpdated(KeyBindingRow sender, KeyBindingUpdatedEventArgs args);
|
public delegate void KeyBindingUpdated(KeyBindingRow sender, KeyBindingUpdatedEventArgs args);
|
||||||
|
|
||||||
public record KeyBindingUpdatedEventArgs(bool BindingConflictResolved, bool CanAdvanceToNextBinding);
|
|
||||||
|
|
||||||
public Func<List<RealmKeyBinding>> GetAllSectionBindings { get; set; } = null!;
|
public Func<List<RealmKeyBinding>> GetAllSectionBindings { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -470,15 +468,15 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
|
|
||||||
private void tryPersistKeyBinding(RealmKeyBinding keyBinding, bool advanceToNextBinding)
|
private void tryPersistKeyBinding(RealmKeyBinding keyBinding, bool advanceToNextBinding)
|
||||||
{
|
{
|
||||||
var bindings = GetAllSectionBindings();
|
List<RealmKeyBinding> bindings = GetAllSectionBindings();
|
||||||
var existingBinding = keyBinding.KeyCombination.Equals(new KeyCombination(InputKey.None))
|
RealmKeyBinding? existingBinding = keyBinding.KeyCombination.Equals(new KeyCombination(InputKey.None))
|
||||||
? null
|
? null
|
||||||
: bindings.FirstOrDefault(other => other.ID != keyBinding.ID && other.KeyCombination.Equals(keyBinding.KeyCombination));
|
: bindings.FirstOrDefault(other => other.ID != keyBinding.ID && other.KeyCombination.Equals(keyBinding.KeyCombination));
|
||||||
|
|
||||||
if (existingBinding == null)
|
if (existingBinding == null)
|
||||||
{
|
{
|
||||||
realm.WriteAsync(r => r.Find<RealmKeyBinding>(keyBinding.ID)!.KeyCombinationString = keyBinding.KeyCombination.ToString());
|
realm.WriteAsync(r => r.Find<RealmKeyBinding>(keyBinding.ID)!.KeyCombinationString = keyBinding.KeyCombination.ToString());
|
||||||
BindingUpdated?.Invoke(this, new KeyBindingUpdatedEventArgs(BindingConflictResolved: false, advanceToNextBinding));
|
BindingUpdated?.Invoke(this, new KeyBindingUpdatedEventArgs(bindingConflictResolved: false, advanceToNextBinding));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +528,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
public Popover GetPopover() => new KeyBindingConflictPopover
|
public Popover GetPopover() => new KeyBindingConflictPopover
|
||||||
{
|
{
|
||||||
ConflictInfo = { BindTarget = keyBindingConflictInfo },
|
ConflictInfo = { BindTarget = keyBindingConflictInfo },
|
||||||
BindingConflictResolved = () => BindingUpdated?.Invoke(this, new KeyBindingUpdatedEventArgs(BindingConflictResolved: true, CanAdvanceToNextBinding: false))
|
BindingConflictResolved = () => BindingUpdated?.Invoke(this, new KeyBindingUpdatedEventArgs(bindingConflictResolved: true, canAdvanceToNextBinding: false))
|
||||||
};
|
};
|
||||||
|
|
||||||
private void showBindingConflictPopover(KeyBindingConflictInfo conflictInfo)
|
private void showBindingConflictPopover(KeyBindingConflictInfo conflictInfo)
|
||||||
@ -542,9 +540,48 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains information about the key binding conflict to be resolved.
|
/// Contains information about the key binding conflict to be resolved.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public record KeyBindingConflictInfo(ConflictingKeyBinding Existing, ConflictingKeyBinding New);
|
public class KeyBindingConflictInfo
|
||||||
|
{
|
||||||
|
public ConflictingKeyBinding Existing { get; }
|
||||||
|
public ConflictingKeyBinding New { get; }
|
||||||
|
|
||||||
public record ConflictingKeyBinding(Guid ID, object Action, KeyCombination CombinationWhenChosen, KeyCombination CombinationWhenNotChosen);
|
/// <summary>
|
||||||
|
/// Contains information about the key binding conflict to be resolved.
|
||||||
|
/// </summary>
|
||||||
|
public KeyBindingConflictInfo(ConflictingKeyBinding existingBinding, ConflictingKeyBinding newBinding)
|
||||||
|
{
|
||||||
|
Existing = existingBinding;
|
||||||
|
New = newBinding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ConflictingKeyBinding
|
||||||
|
{
|
||||||
|
public Guid ID { get; }
|
||||||
|
public object Action { get; }
|
||||||
|
public KeyCombination CombinationWhenChosen { get; }
|
||||||
|
public KeyCombination CombinationWhenNotChosen { get; }
|
||||||
|
|
||||||
|
public ConflictingKeyBinding(Guid id, object action, KeyCombination combinationWhenChosen, KeyCombination combinationWhenNotChosen)
|
||||||
|
{
|
||||||
|
ID = id;
|
||||||
|
Action = action;
|
||||||
|
CombinationWhenChosen = combinationWhenChosen;
|
||||||
|
CombinationWhenNotChosen = combinationWhenNotChosen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KeyBindingUpdatedEventArgs
|
||||||
|
{
|
||||||
|
public bool BindingConflictResolved { get; }
|
||||||
|
public bool CanAdvanceToNextBinding { get; }
|
||||||
|
|
||||||
|
public KeyBindingUpdatedEventArgs(bool bindingConflictResolved, bool canAdvanceToNextBinding)
|
||||||
|
{
|
||||||
|
BindingConflictResolved = bindingConflictResolved;
|
||||||
|
CanAdvanceToNextBinding = canAdvanceToNextBinding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user