mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Merge branch 'master' into mod-using-reference-equality
This commit is contained in:
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Configuration;
|
||||
@ -13,16 +14,21 @@ using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Online.API
|
||||
{
|
||||
[MessagePackObject]
|
||||
public class APIMod : IMod, IEquatable<APIMod>
|
||||
{
|
||||
[JsonProperty("acronym")]
|
||||
[Key(0)]
|
||||
public string Acronym { get; set; }
|
||||
|
||||
[JsonProperty("settings")]
|
||||
[Key(1)]
|
||||
[MessagePackFormatter(typeof(ModSettingsDictionaryFormatter))]
|
||||
public Dictionary<string, object> Settings { get; set; } = new Dictionary<string, object>();
|
||||
|
||||
[JsonConstructor]
|
||||
private APIMod()
|
||||
[SerializationConstructor]
|
||||
public APIMod()
|
||||
{
|
||||
}
|
||||
|
||||
@ -31,7 +37,12 @@ namespace osu.Game.Online.API
|
||||
Acronym = mod.Acronym;
|
||||
|
||||
foreach (var (_, property) in mod.GetSettingsSourceProperties())
|
||||
Settings.Add(property.Name.Underscore(), property.GetValue(mod));
|
||||
{
|
||||
var bindable = (IBindable)property.GetValue(mod);
|
||||
|
||||
if (!bindable.IsDefault)
|
||||
Settings.Add(property.Name.Underscore(), bindable);
|
||||
}
|
||||
}
|
||||
|
||||
public Mod ToMod(Ruleset ruleset)
|
||||
@ -46,7 +57,7 @@ namespace osu.Game.Online.API
|
||||
if (!Settings.TryGetValue(property.Name.Underscore(), out object settingValue))
|
||||
continue;
|
||||
|
||||
((IBindable)property.GetValue(resultMod)).Parse(settingValue);
|
||||
resultMod.CopyAdjustedSetting((IBindable)property.GetValue(resultMod), settingValue);
|
||||
}
|
||||
|
||||
return resultMod;
|
||||
|
Reference in New Issue
Block a user