mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Replace Add/Reset methods with single Set
method
This commit is contained in:
@ -6,7 +6,6 @@ using System.Linq;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.OpenGL.Textures;
|
using osu.Framework.Graphics.OpenGL.Textures;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
@ -67,8 +66,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
|
|
||||||
protected override void OnSourceChanged()
|
protected override void OnSourceChanged()
|
||||||
{
|
{
|
||||||
ResetSources();
|
SetSources(sources);
|
||||||
sources.ForEach(AddSource);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +60,6 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
protected override void OnSourceChanged()
|
protected override void OnSourceChanged()
|
||||||
{
|
{
|
||||||
ResetSources();
|
|
||||||
|
|
||||||
// Populate a local list first so we can adjust the returned order as we go.
|
// Populate a local list first so we can adjust the returned order as we go.
|
||||||
var sources = new List<ISkin>();
|
var sources = new List<ISkin>();
|
||||||
|
|
||||||
@ -91,8 +89,7 @@ namespace osu.Game.Skinning
|
|||||||
else
|
else
|
||||||
sources.Add(rulesetResourcesSkin);
|
sources.Add(rulesetResourcesSkin);
|
||||||
|
|
||||||
foreach (var skin in sources)
|
SetSources(sources);
|
||||||
AddSource(skin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ISkin GetLegacyRulesetTransformedSkin(ISkin legacySkin)
|
protected ISkin GetLegacyRulesetTransformedSkin(ISkin legacySkin)
|
||||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Skinning
|
|||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
if (skin != null)
|
if (skin != null)
|
||||||
AddSource(skin);
|
SetSources(new[] { skin });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -169,21 +169,10 @@ namespace osu.Game.Skinning
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a new skin to this provider. Will be added to the end of the lookup order precedence.
|
/// Replace the sources used for lookups in this container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="skin">The skin to add.</param>
|
/// <param name="sources">The new sources.</param>
|
||||||
protected void AddSource(ISkin skin)
|
protected void SetSources(IEnumerable<ISkin> sources)
|
||||||
{
|
|
||||||
skinSources = skinSources.Append((skin, new DisableableSkinSource(skin, this))).ToArray();
|
|
||||||
|
|
||||||
if (skin is ISkinSource source)
|
|
||||||
source.SourceChanged += TriggerSourceChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clears all skin sources.
|
|
||||||
/// </summary>
|
|
||||||
protected void ResetSources()
|
|
||||||
{
|
{
|
||||||
foreach (var skin in skinSources)
|
foreach (var skin in skinSources)
|
||||||
{
|
{
|
||||||
@ -191,11 +180,17 @@ namespace osu.Game.Skinning
|
|||||||
source.SourceChanged -= TriggerSourceChanged;
|
source.SourceChanged -= TriggerSourceChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
skinSources = Array.Empty<(ISkin skin, DisableableSkinSource wrapped)>();
|
skinSources = sources.Select(skin => (skin, new DisableableSkinSource(skin, this))).ToArray();
|
||||||
|
|
||||||
|
foreach (var skin in skinSources)
|
||||||
|
{
|
||||||
|
if (skin.skin is ISkinSource source)
|
||||||
|
source.SourceChanged += TriggerSourceChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when any source has changed (either <see cref="ParentSource"/> or a source registered via <see cref="AddSource"/>).
|
/// Invoked when any source has changed (either <see cref="ParentSource"/> or sources replaced via <see cref="SetSources"/>).
|
||||||
/// This is also invoked once initially during <see cref="CreateChildDependencies"/> to ensure sources are ready for children consumption.
|
/// This is also invoked once initially during <see cref="CreateChildDependencies"/> to ensure sources are ready for children consumption.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void OnSourceChanged() { }
|
protected virtual void OnSourceChanged() { }
|
||||||
|
Reference in New Issue
Block a user