1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:47:28 +08:00

Handle all skin component types explicitly

This commit is contained in:
Salman Ahmed 2022-04-23 01:08:53 +03:00
parent 69e2e30971
commit 61078910a6
8 changed files with 40 additions and 5 deletions

View File

@ -90,6 +90,9 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
return new LegacyHitExplosion();
return null;
default:
throw new UnsupportedSkinComponentException(component);
}
}

View File

@ -116,9 +116,10 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
case ManiaSkinComponents.StageForeground:
return new LegacyStageForeground();
}
break;
default:
throw new UnsupportedSkinComponentException(component);
}
}
return base.GetDrawableComponent(component);

View File

@ -35,6 +35,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
case OsuSkinComponents.FollowPoint:
return this.GetAnimation(component.LookupName, true, true, true, startAtCurrentTime: false);
case OsuSkinComponents.SliderScorePoint:
return this.GetAnimation(component.LookupName, false, false);
case OsuSkinComponents.SliderFollowCircle:
var followCircle = this.GetAnimation("sliderfollowcircle", true, true, true);
if (followCircle != null)
@ -123,6 +126,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
case OsuSkinComponents.ApproachCircle:
return new LegacyApproachCircle();
default:
throw new UnsupportedSkinComponentException(component);
}
}

View File

@ -57,6 +57,10 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
case TaikoSkinComponents.DrumRollTick:
return this.GetAnimation("sliderscorepoint", false, false);
case TaikoSkinComponents.Swell:
// todo: support taiko legacy swell (https://github.com/ppy/osu/issues/13601).
return null;
case TaikoSkinComponents.HitTarget:
if (GetTexture("taikobigcircle") != null)
return new TaikoLegacyHitTarget();
@ -119,6 +123,9 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
case TaikoSkinComponents.Mascot:
return new DrawableTaikoMascot();
default:
throw new UnsupportedSkinComponentException(component);
}
}

View File

@ -155,7 +155,7 @@ namespace osu.Game.Skinning
return skinnableTargetWrapper;
}
break;
return null;
}
switch (component.LookupName)

View File

@ -392,8 +392,11 @@ namespace osu.Game.Skinning
return null;
case SkinnableSprite.SpriteComponent sprite:
return this.GetAnimation(sprite.LookupName, false, false);
default:
throw new ArgumentOutOfRangeException(nameof(component));
throw new UnsupportedSkinComponentException(component);
}
}

View File

@ -65,7 +65,7 @@ namespace osu.Game.Skinning
public bool UsesFixedAnchor { get; set; }
private class SpriteComponent : ISkinComponent
public class SpriteComponent : ISkinComponent
{
public string LookupName { get; set; }

View File

@ -0,0 +1,15 @@
// 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;
namespace osu.Game.Skinning
{
public class UnsupportedSkinComponentException : Exception
{
public UnsupportedSkinComponentException(ISkinComponent component)
: base($@"Unsupported component type: {component.GetType()}(""{component.LookupName}"").")
{
}
}
}