Refrain from attempting to transform null skins

This commit is contained in:
Salman Ahmed 2021-06-10 13:41:41 +03:00
parent 5c9c424a0d
commit 09a2d008d2
3 changed files with 9 additions and 5 deletions

View File

@ -127,7 +127,7 @@ public virtual LegacyMods ConvertToLegacyMods(Mod[] mods)
[CanBeNull]
public ModAutoplay GetAutoplayMod() => GetAllMods().OfType<ModAutoplay>().FirstOrDefault();
public virtual ISkin CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => null;
public virtual ISkin CreateLegacySkinProvider([NotNull] ISkin skin, IBeatmap beatmap) => null;
protected Ruleset()
{

View File

@ -1,6 +1,8 @@
// 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.
using System;
using JetBrains.Annotations;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -20,11 +22,12 @@ public abstract class LegacySkinTransformer : ISkin
/// <summary>
/// The <see cref="ISkin"/> which is being transformed.
/// </summary>
[NotNull]
protected ISkin Skin { get; }
protected LegacySkinTransformer(ISkin skin)
protected LegacySkinTransformer([NotNull] ISkin skin)
{
Skin = skin;
Skin = skin ?? throw new ArgumentNullException(nameof(skin));
}
public abstract Drawable GetDrawableComponent(ISkinComponent component);

View File

@ -1,6 +1,7 @@
// 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.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -20,12 +21,12 @@ public class RulesetSkinProvidingContainer : SkinProvidingContainer
protected override Container<Drawable> Content { get; }
public RulesetSkinProvidingContainer(Ruleset ruleset, IBeatmap beatmap, ISkin beatmapSkin)
public RulesetSkinProvidingContainer(Ruleset ruleset, IBeatmap beatmap, [CanBeNull] ISkin beatmapSkin)
{
this.ruleset = ruleset;
this.beatmap = beatmap;
InternalChild = new BeatmapSkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkin, beatmap))
InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin == null ? null : ruleset.CreateLegacySkinProvider(beatmapSkin, beatmap))
{
Child = Content = new Container
{