mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Rename realm persisted properties to avoid casting necessity
This commit is contained in:
@ -7,7 +7,7 @@ using Realms;
|
||||
|
||||
namespace osu.Game.Input.Bindings
|
||||
{
|
||||
[MapTo("KeyBinding")]
|
||||
[MapTo(nameof(KeyBinding))]
|
||||
public class RealmKeyBinding : RealmObject, IHasGuidPrimaryKey, IKeyBinding
|
||||
{
|
||||
[PrimaryKey]
|
||||
@ -17,20 +17,22 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
public int? Variant { get; set; }
|
||||
|
||||
KeyCombination IKeyBinding.KeyCombination
|
||||
public KeyCombination KeyCombination
|
||||
{
|
||||
get => KeyCombination;
|
||||
set => KeyCombination = value.ToString();
|
||||
get => KeyCombinationString;
|
||||
set => KeyCombinationString = value.ToString();
|
||||
}
|
||||
|
||||
object IKeyBinding.Action
|
||||
public object Action
|
||||
{
|
||||
get => Action;
|
||||
set => Action = (int)value;
|
||||
get => ActionInt;
|
||||
set => ActionInt = (int)value;
|
||||
}
|
||||
|
||||
public int Action { get; set; }
|
||||
[MapTo(nameof(Action))]
|
||||
public int ActionInt { get; set; }
|
||||
|
||||
public string KeyCombination { get; set; }
|
||||
[MapTo(nameof(KeyCombination))]
|
||||
public string KeyCombinationString { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,9 @@ namespace osu.Game.Input
|
||||
/// <returns>A set of display strings for all the user's key configuration for the action.</returns>
|
||||
public IEnumerable<string> GetReadableKeyCombinationsFor(GlobalAction globalAction)
|
||||
{
|
||||
foreach (var action in RealmFactory.Context.All<RealmKeyBinding>().Where(b => (GlobalAction)b.Action == globalAction))
|
||||
foreach (var action in RealmFactory.Context.All<RealmKeyBinding>().Where(b => (GlobalAction)b.ActionInt == globalAction))
|
||||
{
|
||||
string str = ((IKeyBinding)action).KeyCombination.ReadableString();
|
||||
string str = action.KeyCombination.ReadableString();
|
||||
|
||||
// even if found, the readable string may be empty for an unbound action.
|
||||
if (str.Length > 0)
|
||||
@ -66,7 +66,7 @@ namespace osu.Game.Input
|
||||
// compare counts in database vs defaults
|
||||
foreach (var group in defaults.GroupBy(k => k.Action))
|
||||
{
|
||||
int count = usage.Context.All<RealmKeyBinding>().Count(k => k.RulesetID == rulesetId && k.Variant == variant && k.Action == (int)group.Key);
|
||||
int count = usage.Context.All<RealmKeyBinding>().Count(k => k.RulesetID == rulesetId && k.Variant == variant && k.ActionInt == (int)group.Key);
|
||||
int aimCount = group.Count();
|
||||
|
||||
if (aimCount <= count)
|
||||
@ -78,8 +78,8 @@ namespace osu.Game.Input
|
||||
usage.Context.Add(new RealmKeyBinding
|
||||
{
|
||||
ID = Guid.NewGuid().ToString(),
|
||||
KeyCombination = insertable.KeyCombination.ToString(),
|
||||
Action = (int)insertable.Action,
|
||||
KeyCombinationString = insertable.KeyCombination.ToString(),
|
||||
ActionInt = (int)insertable.Action,
|
||||
RulesetID = rulesetId,
|
||||
Variant = variant
|
||||
});
|
||||
|
Reference in New Issue
Block a user