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

Make RulesetSkinProvidingContainer able to be overriden for testing purposes

This commit is contained in:
Salman Ahmed 2021-06-10 15:05:08 +03:00
parent 09a2d008d2
commit ef2c4fd0d8
2 changed files with 13 additions and 11 deletions

View File

@ -234,7 +234,7 @@ namespace osu.Game.Screens.Play
dependencies.CacheAs(GameplayBeatmap); dependencies.CacheAs(GameplayBeatmap);
var rulesetSkinProvider = new RulesetSkinProvidingContainer(GameplayRuleset, playableBeatmap, Beatmap.Value.Skin); var rulesetSkinProvider = CreateRulesetSkinProvider(GameplayRuleset, playableBeatmap, Beatmap.Value.Skin);
// load the skinning hierarchy first. // load the skinning hierarchy first.
// this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources. // this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
@ -315,6 +315,8 @@ namespace osu.Game.Screens.Play
protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart); protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart);
protected virtual RulesetSkinProvidingContainer CreateRulesetSkinProvider(Ruleset ruleset, IBeatmap beatmap, ISkin beatmapSkin) => new RulesetSkinProvidingContainer(ruleset, beatmap, beatmapSkin);
private Drawable createUnderlayComponents() => private Drawable createUnderlayComponents() =>
DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both }; DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both };

View File

@ -16,15 +16,15 @@ namespace osu.Game.Skinning
/// </summary> /// </summary>
public class RulesetSkinProvidingContainer : SkinProvidingContainer public class RulesetSkinProvidingContainer : SkinProvidingContainer
{ {
private readonly Ruleset ruleset; protected readonly Ruleset Ruleset;
private readonly IBeatmap beatmap; protected readonly IBeatmap Beatmap;
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)
{ {
this.ruleset = ruleset; Ruleset = ruleset;
this.beatmap = beatmap; Beatmap = beatmap;
InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin == null ? null : ruleset.CreateLegacySkinProvider(beatmapSkin, beatmap)) InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin == null ? null : ruleset.CreateLegacySkinProvider(beatmapSkin, beatmap))
{ {
@ -41,25 +41,25 @@ namespace osu.Game.Skinning
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
updateSkins(); UpdateSkins();
} }
protected override void OnSourceChanged() protected override void OnSourceChanged()
{ {
updateSkins(); UpdateSkins();
base.OnSourceChanged(); base.OnSourceChanged();
} }
private void updateSkins() protected virtual void UpdateSkins()
{ {
SkinSources.Clear(); SkinSources.Clear();
SkinSources.Add(ruleset.CreateLegacySkinProvider(skinManager.CurrentSkin.Value, beatmap)); SkinSources.Add(Ruleset.CreateLegacySkinProvider(skinManager.CurrentSkin.Value, Beatmap));
if (skinManager.CurrentSkin.Value is LegacySkin) if (skinManager.CurrentSkin.Value is LegacySkin)
SkinSources.Add(ruleset.CreateLegacySkinProvider(skinManager.DefaultLegacySkin, beatmap)); SkinSources.Add(Ruleset.CreateLegacySkinProvider(skinManager.DefaultLegacySkin, Beatmap));
SkinSources.Add(ruleset.CreateLegacySkinProvider(skinManager.DefaultSkin, beatmap)); SkinSources.Add(Ruleset.CreateLegacySkinProvider(skinManager.DefaultSkin, Beatmap));
} }
} }
} }