mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Reorder methods to make more sense
This commit is contained in:
@ -64,38 +64,19 @@ namespace osu.Game.Skinning
|
|||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
/// Add a new skin to this provider. Will be added to the end of the lookup order precedence.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="skin">The skin to add.</param>
|
|
||||||
protected void AddSource(ISkin skin)
|
|
||||||
{
|
{
|
||||||
skinSources.Add((skin, new DisableableSkinSource(skin, this)));
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
if (skin is ISkinSource source)
|
ParentSource = dependencies.Get<ISkinSource>();
|
||||||
source.SourceChanged += TriggerSourceChanged;
|
if (ParentSource != null)
|
||||||
}
|
ParentSource.SourceChanged += TriggerSourceChanged;
|
||||||
|
|
||||||
/// <summary>
|
dependencies.CacheAs<ISkinSource>(this);
|
||||||
/// Remove a skin from this provider.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="skin">The skin to remove.</param>
|
|
||||||
protected void RemoveSource(ISkin skin)
|
|
||||||
{
|
|
||||||
if (skinSources.RemoveAll(s => s.skin == skin) == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (skin is ISkinSource source)
|
TriggerSourceChanged();
|
||||||
source.SourceChanged -= TriggerSourceChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
return dependencies;
|
||||||
/// Clears all skin sources.
|
|
||||||
/// </summary>
|
|
||||||
protected void ResetSources()
|
|
||||||
{
|
|
||||||
foreach (var skin in AllSources.ToArray())
|
|
||||||
RemoveSource(skin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
|
public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
|
||||||
@ -187,27 +168,46 @@ namespace osu.Game.Skinning
|
|||||||
return ParentSource?.GetConfig<TLookup, TValue>(lookup);
|
return ParentSource?.GetConfig<TLookup, TValue>(lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add a new skin to this provider. Will be added to the end of the lookup order precedence.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="skin">The skin to add.</param>
|
||||||
|
protected void AddSource(ISkin skin)
|
||||||
|
{
|
||||||
|
skinSources.Add((skin, new DisableableSkinSource(skin, this)));
|
||||||
|
|
||||||
|
if (skin is ISkinSource source)
|
||||||
|
source.SourceChanged += TriggerSourceChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a skin from this provider.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="skin">The skin to remove.</param>
|
||||||
|
protected void RemoveSource(ISkin skin)
|
||||||
|
{
|
||||||
|
if (skinSources.RemoveAll(s => s.skin == skin) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (skin is ISkinSource source)
|
||||||
|
source.SourceChanged -= TriggerSourceChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears all skin sources.
|
||||||
|
/// </summary>
|
||||||
|
protected void ResetSources()
|
||||||
|
{
|
||||||
|
foreach (var skin in AllSources.ToArray())
|
||||||
|
RemoveSource(skin);
|
||||||
|
}
|
||||||
|
|
||||||
/// <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 a source registered via <see cref="AddSource"/>).
|
||||||
/// 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() { }
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
|
|
||||||
ParentSource = dependencies.Get<ISkinSource>();
|
|
||||||
if (ParentSource != null)
|
|
||||||
ParentSource.SourceChanged += TriggerSourceChanged;
|
|
||||||
|
|
||||||
dependencies.CacheAs<ISkinSource>(this);
|
|
||||||
|
|
||||||
TriggerSourceChanged();
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void TriggerSourceChanged()
|
protected void TriggerSourceChanged()
|
||||||
{
|
{
|
||||||
// Expose to implementations, giving them a chance to react before notifying external consumers.
|
// Expose to implementations, giving them a chance to react before notifying external consumers.
|
||||||
|
Reference in New Issue
Block a user