From ef2c4fd0d8ec68e8754aa12cf5cf381a5f839ed9 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 10 Jun 2021 15:05:08 +0300 Subject: [PATCH] Make `RulesetSkinProvidingContainer` able to be overriden for testing purposes --- osu.Game/Screens/Play/Player.cs | 4 +++- .../Skinning/RulesetSkinProvidingContainer.cs | 20 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index bec5181efe..fbcc7ea96f 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -234,7 +234,7 @@ namespace osu.Game.Screens.Play 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. // 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 RulesetSkinProvidingContainer CreateRulesetSkinProvider(Ruleset ruleset, IBeatmap beatmap, ISkin beatmapSkin) => new RulesetSkinProvidingContainer(ruleset, beatmap, beatmapSkin); + private Drawable createUnderlayComponents() => DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both }; diff --git a/osu.Game/Skinning/RulesetSkinProvidingContainer.cs b/osu.Game/Skinning/RulesetSkinProvidingContainer.cs index 18399cbdb4..8087043230 100644 --- a/osu.Game/Skinning/RulesetSkinProvidingContainer.cs +++ b/osu.Game/Skinning/RulesetSkinProvidingContainer.cs @@ -16,15 +16,15 @@ namespace osu.Game.Skinning /// public class RulesetSkinProvidingContainer : SkinProvidingContainer { - private readonly Ruleset ruleset; - private readonly IBeatmap beatmap; + protected readonly Ruleset Ruleset; + protected readonly IBeatmap Beatmap; protected override Container Content { get; } public RulesetSkinProvidingContainer(Ruleset ruleset, IBeatmap beatmap, [CanBeNull] ISkin beatmapSkin) { - this.ruleset = ruleset; - this.beatmap = beatmap; + Ruleset = ruleset; + Beatmap = beatmap; InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin == null ? null : ruleset.CreateLegacySkinProvider(beatmapSkin, beatmap)) { @@ -41,25 +41,25 @@ namespace osu.Game.Skinning [BackgroundDependencyLoader] private void load() { - updateSkins(); + UpdateSkins(); } protected override void OnSourceChanged() { - updateSkins(); + UpdateSkins(); base.OnSourceChanged(); } - private void updateSkins() + protected virtual void UpdateSkins() { SkinSources.Clear(); - SkinSources.Add(ruleset.CreateLegacySkinProvider(skinManager.CurrentSkin.Value, beatmap)); + 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.DefaultLegacySkin, Beatmap)); - SkinSources.Add(ruleset.CreateLegacySkinProvider(skinManager.DefaultSkin, beatmap)); + SkinSources.Add(Ruleset.CreateLegacySkinProvider(skinManager.DefaultSkin, Beatmap)); } } }