mirror of
https://github.com/ppy/osu
synced 2025-01-04 21:30:08 +00: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:
parent
ebe0d43790
commit
d53a43cf3c
@ -7,18 +7,26 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// A type of <see cref="SkinProvidingContainer"/> that provides access to the beatmap skin and user skin,
|
||||
/// with each legacy skin source transformed with the ruleset's legacy skin transformer.
|
||||
/// A type of <see cref="SkinProvidingContainer"/> specialized for <see cref="DrawableRuleset"/> and other gameplay-related components.
|
||||
/// 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>
|
||||
public class RulesetSkinProvidingContainer : SkinProvidingContainer
|
||||
{
|
||||
protected readonly Ruleset Ruleset;
|
||||
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; }
|
||||
|
||||
public RulesetSkinProvidingContainer(Ruleset ruleset, IBeatmap beatmap, [CanBeNull] ISkin beatmapSkin)
|
||||
@ -42,12 +50,7 @@ namespace osu.Game.Skinning
|
||||
private void load()
|
||||
{
|
||||
UpdateSkins();
|
||||
}
|
||||
|
||||
protected override void OnSourceChanged()
|
||||
{
|
||||
UpdateSkins();
|
||||
base.OnSourceChanged();
|
||||
skinManager.SourceChanged += UpdateSkins;
|
||||
}
|
||||
|
||||
protected virtual void UpdateSkins()
|
||||
@ -83,5 +86,13 @@ namespace osu.Game.Skinning
|
||||
|
||||
return legacySkin;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (skinManager != null)
|
||||
skinManager.SourceChanged -= UpdateSkins;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user