mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 14:53:21 +08:00
Addressed change requests
This commit is contained in:
parent
191604340f
commit
dd53a70071
@ -403,8 +403,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
var taikoMod = getMod() as TaikoModDifficultyAdjust;
|
||||
return
|
||||
taikoMod?.ExtendedLimits.Value == true &&
|
||||
taikoMod?.DrainRate.Value == setting_change &&
|
||||
taikoMod?.OverallDifficulty.Value == setting_change;
|
||||
taikoMod.DrainRate.Value == setting_change &&
|
||||
taikoMod.OverallDifficulty.Value == setting_change;
|
||||
});
|
||||
|
||||
AddAssert("non-shared settings at default", () =>
|
||||
|
@ -58,7 +58,6 @@ using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Utils;
|
||||
using File = System.IO.File;
|
||||
using RuntimeInfo = osu.Framework.RuntimeInfo;
|
||||
|
||||
namespace osu.Game
|
||||
@ -393,11 +392,8 @@ namespace osu.Game
|
||||
|
||||
Ruleset.BindValueChanged(onRulesetChanged);
|
||||
Beatmap.BindValueChanged(onBeatmapChanged);
|
||||
SelectedMods.BindValueChanged(change => Logger.Log($"{modSetting(change.OldValue)} => {modSetting(change.NewValue)}"));
|
||||
}
|
||||
|
||||
private object modSetting(IReadOnlyList<Mod> mods) => mods.OfType<ModDoubleTime>().FirstOrDefault()?.GetSettingsSourceProperties().First().Item2.GetValue(mods.OfType<ModDoubleTime>().First())!;
|
||||
|
||||
private void addFilesWarning()
|
||||
{
|
||||
var realmStore = new RealmFileStore(realm, Storage);
|
||||
@ -629,7 +625,7 @@ namespace osu.Game
|
||||
return;
|
||||
}
|
||||
|
||||
//for some reason emptying SelectedMods resets all SettingSources Bindables to default value
|
||||
//DeepCloning collection, because emptying SelectedMods resets all SettingSources Bindables to their default value
|
||||
var previouslySelectedMods = SelectedMods.Value.Select(mod => mod.DeepClone()).ToArray();
|
||||
|
||||
if (!SelectedMods.Disabled)
|
||||
@ -643,7 +639,7 @@ namespace osu.Game
|
||||
{
|
||||
Mod newMod = instance.CreateModFromAcronym(oldMod.Acronym);
|
||||
|
||||
newMod?.CopyFromSimilar(oldMod);
|
||||
newMod?.CopySharedSettings(oldMod);
|
||||
|
||||
return newMod;
|
||||
}).Where(m => m != null).ToArray();
|
||||
|
@ -141,10 +141,28 @@ namespace osu.Game.Rulesets.Mods
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies all shared mod setting values from <paramref name="source"/> into this instance.
|
||||
/// Copies mod setting values from <paramref name="source"/> into this instance, overwriting all existing settings.
|
||||
/// </summary>
|
||||
/// <param name="source">The mod to copy properties from.</param>
|
||||
public void CopyFromSimilar(Mod source)
|
||||
public void CopyFrom(Mod source)
|
||||
{
|
||||
if (source.GetType() != GetType())
|
||||
throw new ArgumentException($"Expected mod of type {GetType()}, got {source.GetType()}.", nameof(source));
|
||||
|
||||
foreach (var (_, property) in this.GetSettingsSourceProperties())
|
||||
{
|
||||
var targetBindable = (IBindable)property.GetValue(this)!;
|
||||
var sourceBindable = (IBindable)property.GetValue(source)!;
|
||||
|
||||
CopyAdjustedSetting(targetBindable, sourceBindable);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies all mod setting values sharing same <see cref="MemberInfo.Name"/> from <paramref name="source"/> into this instance.
|
||||
/// </summary>
|
||||
/// <param name="source">The mod to copy properties from.</param>
|
||||
internal void CopySharedSettings(Mod source)
|
||||
{
|
||||
Dictionary<string, object> oldSettings = new Dictionary<string, object>();
|
||||
|
||||
@ -164,24 +182,6 @@ namespace osu.Game.Rulesets.Mods
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies mod setting values from <paramref name="source"/> into this instance, overwriting all existing settings.
|
||||
/// </summary>
|
||||
/// <param name="source">The mod to copy properties from.</param>
|
||||
public void CopyFrom(Mod source)
|
||||
{
|
||||
if (source.GetType() != GetType())
|
||||
throw new ArgumentException($"Expected mod of type {GetType()}, got {source.GetType()}.", nameof(source));
|
||||
|
||||
foreach (var (_, property) in this.GetSettingsSourceProperties())
|
||||
{
|
||||
var targetBindable = (IBindable)property.GetValue(this)!;
|
||||
var sourceBindable = (IBindable)property.GetValue(source)!;
|
||||
|
||||
CopyAdjustedSetting(targetBindable, sourceBindable);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When creating copies or clones of a Mod, this method will be called
|
||||
/// to copy explicitly adjusted user settings from <paramref name="target"/>.
|
||||
|
Loading…
Reference in New Issue
Block a user