1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +08:00

Mark key and value non-nullable (at realm end) and simplify Value logic

This commit is contained in:
Dean Herbert 2021-09-15 17:12:00 +09:00
parent a150fb2996
commit a1d325cb22
3 changed files with 7 additions and 12 deletions

View File

@ -21,17 +21,12 @@ namespace osu.Game.Configuration
[Indexed] [Indexed]
public int Variant { get; set; } public int Variant { get; set; }
[Required]
public string Key { get; set; } = string.Empty; public string Key { get; set; } = string.Empty;
[MapTo(nameof(Value))] [Required]
public string ValueString { get; set; } = string.Empty; public string Value { get; set; } = string.Empty;
public object Value public override string ToString() => $"{Key} => {Value}";
{
get => ValueString;
set => ValueString = value.ToString();
}
public override string ToString() => $"{Key}=>{Value}";
} }
} }

View File

@ -462,8 +462,8 @@ namespace osu.Game
usage.Realm.Add(new RealmRulesetSetting usage.Realm.Add(new RealmRulesetSetting
{ {
ValueString = dkb.StringValue,
Key = dkb.Key, Key = dkb.Key,
Value = dkb.StringValue,
RulesetID = dkb.RulesetID.Value, RulesetID = dkb.RulesetID.Value,
Variant = dkb.Variant ?? 0, Variant = dkb.Variant ?? 0,
}); });

View File

@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Configuration
setting = new RealmRulesetSetting setting = new RealmRulesetSetting
{ {
Key = lookup.ToString(), Key = lookup.ToString(),
Value = bindable.Value, Value = bindable.Value.ToString(),
RulesetID = rulesetId, RulesetID = rulesetId,
Variant = variant, Variant = variant,
}; };
@ -80,7 +80,7 @@ namespace osu.Game.Rulesets.Configuration
bindable.ValueChanged += b => bindable.ValueChanged += b =>
{ {
realmFactory?.Context.Write(() => setting.Value = b.NewValue); realmFactory?.Context.Write(() => setting.Value = b.NewValue.ToString());
}; };
} }
} }