1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 12:53:11 +08:00

Isolate RulesetSkinProvidingContainer from falling back to parent skin sources

For simplicity of lookup order, and which sources are used for the lookup.
This commit is contained in:
Salman Ahmed 2021-06-22 02:52:37 +03:00
parent ebe0d43790
commit d53a43cf3c

View File

@ -7,18 +7,26 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.UI;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
/// <summary> /// <summary>
/// A type of <see cref="SkinProvidingContainer"/> that provides access to the beatmap skin and user skin, /// A type of <see cref="SkinProvidingContainer"/> specialized for <see cref="DrawableRuleset"/> and other gameplay-related components.
/// with each legacy skin source transformed with the ruleset's legacy skin transformer. /// Providing access to the <see cref="SkinManager"/> skin sources and the beatmap skin each surrounded with the ruleset legacy skin transformer.
/// While also limiting lookups from falling back to any parent <see cref="ISkinSource"/>s out of this container.
/// </summary> /// </summary>
public class RulesetSkinProvidingContainer : SkinProvidingContainer public class RulesetSkinProvidingContainer : SkinProvidingContainer
{ {
protected readonly Ruleset Ruleset; protected readonly Ruleset Ruleset;
protected readonly IBeatmap Beatmap; protected readonly IBeatmap Beatmap;
/// <remarks>
/// This container already re-exposes all <see cref="SkinManager"/> skin sources in a ruleset-usable form.
/// Therefore disallow falling back to any parent <see cref="ISkinSource"/> any further.
/// </remarks>
protected override bool AllowFallingBackToParent => false;
protected override Container<Drawable> Content { get; } protected override Container<Drawable> Content { get; }
public RulesetSkinProvidingContainer(Ruleset ruleset, IBeatmap beatmap, [CanBeNull] ISkin beatmapSkin) public RulesetSkinProvidingContainer(Ruleset ruleset, IBeatmap beatmap, [CanBeNull] ISkin beatmapSkin)
@ -42,12 +50,7 @@ namespace osu.Game.Skinning
private void load() private void load()
{ {
UpdateSkins(); UpdateSkins();
} skinManager.SourceChanged += UpdateSkins;
protected override void OnSourceChanged()
{
UpdateSkins();
base.OnSourceChanged();
} }
protected virtual void UpdateSkins() protected virtual void UpdateSkins()
@ -83,5 +86,13 @@ namespace osu.Game.Skinning
return legacySkin; return legacySkin;
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (skinManager != null)
skinManager.SourceChanged -= UpdateSkins;
}
} }
} }