2021-06-10 01:41:16 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2021-06-10 18:41:41 +08:00
|
|
|
using JetBrains.Annotations;
|
2021-06-10 01:41:16 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A type of <see cref="SkinProvidingContainer"/> that provides access to the beatmap skin and user skin,
|
|
|
|
/// each transformed with the ruleset's own skin transformer individually.
|
|
|
|
/// </summary>
|
|
|
|
public class RulesetSkinProvidingContainer : SkinProvidingContainer
|
|
|
|
{
|
|
|
|
private readonly Ruleset ruleset;
|
|
|
|
private readonly IBeatmap beatmap;
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content { get; }
|
|
|
|
|
2021-06-10 18:41:41 +08:00
|
|
|
public RulesetSkinProvidingContainer(Ruleset ruleset, IBeatmap beatmap, [CanBeNull] ISkin beatmapSkin)
|
2021-06-10 01:41:16 +08:00
|
|
|
{
|
|
|
|
this.ruleset = ruleset;
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
|
2021-06-10 18:41:41 +08:00
|
|
|
InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin == null ? null : ruleset.CreateLegacySkinProvider(beatmapSkin, beatmap))
|
2021-06-10 01:41:16 +08:00
|
|
|
{
|
|
|
|
Child = Content = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private SkinManager skinManager { get; set; }
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
updateSkins();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnSourceChanged()
|
|
|
|
{
|
|
|
|
updateSkins();
|
|
|
|
base.OnSourceChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateSkins()
|
|
|
|
{
|
2021-06-10 16:55:22 +08:00
|
|
|
SkinSources.Clear();
|
2021-06-10 18:04:34 +08:00
|
|
|
|
|
|
|
SkinSources.Add(ruleset.CreateLegacySkinProvider(skinManager.CurrentSkin.Value, beatmap));
|
|
|
|
|
|
|
|
if (skinManager.CurrentSkin.Value is LegacySkin)
|
|
|
|
SkinSources.Add(ruleset.CreateLegacySkinProvider(skinManager.DefaultLegacySkin, beatmap));
|
|
|
|
|
|
|
|
SkinSources.Add(ruleset.CreateLegacySkinProvider(skinManager.DefaultSkin, beatmap));
|
2021-06-10 01:41:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|