1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 17:27:24 +08:00

Rename ISkinComponent to ISkinLookup

This commit is contained in:
Dean Herbert 2022-11-09 14:11:41 +09:00
parent ab458320c4
commit c908969d9b
90 changed files with 224 additions and 213 deletions

View File

@ -5,9 +5,9 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Catch namespace osu.Game.Rulesets.Catch
{ {
public class CatchSkinComponent : GameplaySkinComponent<CatchSkinComponents> public class CatchSkinLookup : GameplaySkinLookup<CatchSkinComponents>
{ {
public CatchSkinComponent(CatchSkinComponents component) public CatchSkinLookup(CatchSkinComponents component)
: base(component) : base(component)
{ {
} }

View File

@ -37,8 +37,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
public override bool RemoveWhenNotAlive => true; public override bool RemoveWhenNotAlive => true;
protected CaughtObject(CatchSkinComponents skinComponent, Func<ISkinComponent, Drawable> defaultImplementation) protected CaughtObject(CatchSkinComponents skinComponent, Func<ISkinLookup, Drawable> defaultImplementation)
: base(new CatchSkinComponent(skinComponent), defaultImplementation) : base(new CatchSkinLookup(skinComponent), defaultImplementation)
{ {
Origin = Anchor.Centre; Origin = Anchor.Centre;

View File

@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
private void load() private void load()
{ {
ScalingContainer.Child = new SkinnableDrawable( ScalingContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Banana), new CatchSkinLookup(CatchSkinComponents.Banana),
_ => new BananaPiece()); _ => new BananaPiece());
} }

View File

@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
private void load() private void load()
{ {
ScalingContainer.Child = new SkinnableDrawable( ScalingContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Droplet), new CatchSkinLookup(CatchSkinComponents.Droplet),
_ => new DropletPiece()); _ => new DropletPiece());
} }

View File

@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
private void load() private void load()
{ {
ScalingContainer.Child = new SkinnableDrawable( ScalingContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Fruit), new CatchSkinLookup(CatchSkinComponents.Fruit),
_ => new FruitPiece()); _ => new FruitPiece());
} }

View File

@ -13,11 +13,11 @@ namespace osu.Game.Rulesets.Catch.Skinning.Argon
{ {
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
switch (component) switch (lookup)
{ {
case CatchSkinComponent catchComponent: case CatchSkinLookup catchComponent:
// TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries. // TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries.
switch (catchComponent.Component) switch (catchComponent.Component)
{ {
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Argon
break; break;
} }
return base.GetDrawableComponent(component); return base.GetDrawableComponent(lookup);
} }
} }
} }

View File

@ -25,14 +25,14 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{ {
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
if (component is SkinnableTargetComponent targetComponent) if (lookup is SkinnableTargetLookup targetComponent)
{ {
switch (targetComponent.Target) switch (targetComponent.Target)
{ {
case SkinnableTarget.MainHUDComponents: case SkinnableTarget.MainHUDComponents:
var components = base.GetDrawableComponent(component) as SkinnableTargetComponentsContainer; var components = base.GetDrawableComponent(lookup) as SkinnableTargetComponentsContainer;
if (providesComboCounter && components != null) if (providesComboCounter && components != null)
{ {
@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
} }
} }
if (component is CatchSkinComponent catchSkinComponent) if (lookup is CatchSkinLookup catchSkinComponent)
{ {
switch (catchSkinComponent.Component) switch (catchSkinComponent.Component)
{ {
@ -95,11 +95,11 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
return null; return null;
default: default:
throw new UnsupportedSkinComponentException(component); throw new UnsupportedSkinComponentException(lookup);
} }
} }
return base.GetDrawableComponent(component); return base.GetDrawableComponent(lookup);
} }
private bool hasOldStyleCatcherSprite() => private bool hasOldStyleCatcherSprite() =>
@ -127,7 +127,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{ {
case CatchSkinConfiguration.FlipCatcherPlate: case CatchSkinConfiguration.FlipCatcherPlate:
// Don't flip catcher plate contents if the catcher is provided by this legacy skin. // Don't flip catcher plate contents if the catcher is provided by this legacy skin.
if (GetDrawableComponent(new CatchSkinComponent(CatchSkinComponents.Catcher)) != null) if (GetDrawableComponent(new CatchSkinLookup(CatchSkinComponents.Catcher)) != null)
return (IBindable<TValue>)new Bindable<bool>(); return (IBindable<TValue>)new Bindable<bool>();
break; break;

View File

@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Catch.UI
private readonly IBindable<bool> showCombo = new BindableBool(true); private readonly IBindable<bool> showCombo = new BindableBool(true);
public CatchComboDisplay() public CatchComboDisplay()
: base(new CatchSkinComponent(CatchSkinComponents.CatchComboCounter), _ => Empty()) : base(new CatchSkinLookup(CatchSkinComponents.CatchComboCounter), _ => Empty())
{ {
} }

View File

@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Catch.UI
Anchor = Anchor.BottomCentre; Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre; Origin = Anchor.BottomCentre;
InternalChild = skinnableExplosion = new SkinnableDrawable(new CatchSkinComponent(CatchSkinComponents.HitExplosion), _ => new DefaultHitExplosion()) InternalChild = skinnableExplosion = new SkinnableDrawable(new CatchSkinLookup(CatchSkinComponents.HitExplosion), _ => new DefaultHitExplosion())
{ {
CentreComponent = false, CentreComponent = false,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,

View File

@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Catch.UI
public readonly Bindable<CatcherAnimationState> AnimationState = new Bindable<CatcherAnimationState>(); public readonly Bindable<CatcherAnimationState> AnimationState = new Bindable<CatcherAnimationState>();
public SkinnableCatcher() public SkinnableCatcher()
: base(new CatchSkinComponent(CatchSkinComponents.Catcher), _ => new DefaultCatcher()) : base(new CatchSkinLookup(CatchSkinComponents.Catcher), _ => new DefaultCatcher())
{ {
Anchor = Anchor.TopCentre; Anchor = Anchor.TopCentre;
// Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling. // Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling.

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Width = 0.5f, Width = 0.5f,
Child = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground()) Child = new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
} }
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Width = 0.5f, Width = 0.5f,
Child = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground()) Child = new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
} }

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
SetContents(_ => new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.StageBackground), SetContents(_ => new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.StageBackground),
_ => new DefaultStageBackground()) _ => new DefaultStageBackground())
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
SetContents(_ => new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.StageForeground), _ => null) SetContents(_ => new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.StageForeground), _ => null)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -5,13 +5,13 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Mania namespace osu.Game.Rulesets.Mania
{ {
public class ManiaSkinComponent : GameplaySkinComponent<ManiaSkinComponents> public class ManiaSkinLookup : GameplaySkinLookup<ManiaSkinComponents>
{ {
/// <summary> /// <summary>
/// Creates a new <see cref="ManiaSkinComponent"/>. /// Creates a new <see cref="ManiaSkinLookup"/>.
/// </summary> /// </summary>
/// <param name="component">The component.</param> /// <param name="component">The component.</param>
public ManiaSkinComponent(ManiaSkinComponents component) public ManiaSkinLookup(ManiaSkinComponents component)
: base(component) : base(component)
{ {
} }

View File

@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
headContainer = new Container<DrawableHoldNoteHead> { RelativeSizeAxes = Axes.Both } headContainer = new Container<DrawableHoldNoteHead> { RelativeSizeAxes = Axes.Both }
} }
}, },
bodyPiece = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.HoldNoteBody), _ => new DefaultBodyPiece bodyPiece = new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.HoldNoteBody), _ => new DefaultBodyPiece
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}) })

View File

@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
{ {
rulesetConfig?.BindWith(ManiaRulesetSetting.TimingBasedNoteColouring, configTimingBasedNoteColouring); rulesetConfig?.BindWith(ManiaRulesetSetting.TimingBasedNoteColouring, configTimingBasedNoteColouring);
AddInternal(headPiece = new SkinnableDrawable(new ManiaSkinComponent(Component), _ => new DefaultNotePiece()) AddInternal(headPiece = new SkinnableDrawable(new ManiaSkinLookup(Component), _ => new DefaultNotePiece())
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y AutoSizeAxes = Axes.Y

View File

@ -22,14 +22,14 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
this.beatmap = (ManiaBeatmap)beatmap; this.beatmap = (ManiaBeatmap)beatmap;
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
switch (component) switch (lookup)
{ {
case GameplaySkinComponent<HitResult> resultComponent: case GameplaySkinLookup<HitResult> resultComponent:
return new ArgonJudgementPiece(resultComponent.Component); return new ArgonJudgementPiece(resultComponent.Component);
case ManiaSkinComponent maniaComponent: case ManiaSkinLookup maniaComponent:
// TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries. // TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries.
switch (maniaComponent.Component) switch (maniaComponent.Component)
{ {
@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
break; break;
} }
return base.GetDrawableComponent(component); return base.GetDrawableComponent(lookup);
} }
public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)

View File

@ -74,14 +74,14 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
}); });
} }
public override Drawable GetDrawableComponent(ISkinComponent component) public override Drawable GetDrawableComponent(ISkinLookup lookup)
{ {
switch (component) switch (lookup)
{ {
case GameplaySkinComponent<HitResult> resultComponent: case GameplaySkinLookup<HitResult> resultComponent:
return getResult(resultComponent.Component); return getResult(resultComponent.Component);
case ManiaSkinComponent maniaComponent: case ManiaSkinLookup maniaComponent:
if (!isLegacySkin.Value || !hasKeyTexture.Value) if (!isLegacySkin.Value || !hasKeyTexture.Value)
return null; return null;
@ -120,11 +120,11 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
return new LegacyStageForeground(); return new LegacyStageForeground();
default: default:
throw new UnsupportedSkinComponentException(component); throw new UnsupportedSkinComponentException(lookup);
} }
} }
return base.GetDrawableComponent(component); return base.GetDrawableComponent(lookup);
} }
private Drawable getResult(HitResult result) private Drawable getResult(HitResult result)

View File

@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Mania.UI
skin.SourceChanged += onSourceChanged; skin.SourceChanged += onSourceChanged;
onSourceChanged(); onSourceChanged();
Drawable background = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground()) Drawable background = new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}; };
@ -88,7 +88,7 @@ namespace osu.Game.Rulesets.Mania.UI
// For input purposes, the background is added at the highest depth, but is then proxied back below all other elements // For input purposes, the background is added at the highest depth, but is then proxied back below all other elements
background.CreateProxy(), background.CreateProxy(),
HitObjectArea, HitObjectArea,
keyArea = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.KeyArea), _ => new DefaultKeyArea()) keyArea = new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.KeyArea), _ => new DefaultKeyArea())
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Mania.UI.Components
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Depth = 2, Depth = 2,
}, },
hitTarget = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.HitTarget), _ => new DefaultHitTarget()) hitTarget = new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.HitTarget), _ => new DefaultHitTarget())
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Depth = 1 Depth = 1

View File

@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
InternalChild = skinnableExplosion = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.HitExplosion), _ => new DefaultHitExplosion()) InternalChild = skinnableExplosion = new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.HitExplosion), _ => new DefaultHitExplosion())
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
}; };

View File

@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.UI
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,
Children = new Drawable[] Children = new Drawable[]
{ {
new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.StageBackground), _ => new DefaultStageBackground()) new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.StageBackground), _ => new DefaultStageBackground())
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
}, },
@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Mania.UI
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
} }
}, },
new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.StageForeground), _ => null) new SkinnableDrawable(new ManiaSkinLookup(ManiaSkinComponents.StageForeground), _ => null)
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
}, },

View File

@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.Tests
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
public Drawable GetDrawableComponent(ISkinComponent component) => null; public Drawable GetDrawableComponent(ISkinLookup lookup) => null;
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
{ {

View File

@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Osu.Tests
private class TopLeftCursorSkin : ISkin private class TopLeftCursorSkin : ISkin
{ {
public Drawable GetDrawableComponent(ISkinComponent component) => null; public Drawable GetDrawableComponent(ISkinLookup lookup) => null;
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null; public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null;
public ISample GetSample(ISampleInfo sampleInfo) => null; public ISample GetSample(ISampleInfo sampleInfo) => null;

View File

@ -149,11 +149,11 @@ namespace osu.Game.Rulesets.Osu.Tests
this.identifier = identifier; this.identifier = identifier;
} }
public Drawable GetDrawableComponent(ISkinComponent component) public Drawable GetDrawableComponent(ISkinLookup lookup)
{ {
if (!enabled) return null; if (!enabled) return null;
if (component is OsuSkinComponent osuComponent && osuComponent.Component == OsuSkinComponents.SliderBody) if (lookup is OsuSkinLookup osuComponent && osuComponent.Component == OsuSkinComponents.SliderBody)
return null; return null;
return new OsuSpriteText return new OsuSpriteText

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
{ {
Origin = Anchor.Centre; Origin = Anchor.Centre;
InternalChild = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.FollowPoint), _ => new CircularContainer InternalChild = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.FollowPoint), _ => new CircularContainer
{ {
Masking = true, Masking = true,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,

View File

@ -81,12 +81,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
CirclePiece = new SkinnableDrawable(new OsuSkinComponent(CirclePieceComponent), _ => new MainCirclePiece()) CirclePiece = new SkinnableDrawable(new OsuSkinLookup(CirclePieceComponent), _ => new MainCirclePiece())
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
}, },
ApproachCircle = new ProxyableSkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ApproachCircle), _ => new DefaultApproachCircle()) ApproachCircle = new ProxyableSkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.ApproachCircle), _ => new DefaultApproachCircle())
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -278,8 +278,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
public override bool RemoveWhenNotAlive => false; public override bool RemoveWhenNotAlive => false;
public ProxyableSkinnableDrawable(ISkinComponent component, Func<ISkinComponent, Drawable> defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling) public ProxyableSkinnableDrawable(ISkinLookup lookup, Func<ISkinLookup, Drawable> defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
: base(component, defaultImplementation, confineMode) : base(lookup, defaultImplementation, confineMode)
{ {
} }
} }

View File

@ -83,7 +83,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
Body = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderBody), _ => new DefaultSliderBody(), confineMode: ConfineMode.NoScaling), Body = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.SliderBody), _ => new DefaultSliderBody(), confineMode: ConfineMode.NoScaling),
tailContainer = new Container<DrawableSliderTail> { RelativeSizeAxes = Axes.Both }, tailContainer = new Container<DrawableSliderTail> { RelativeSizeAxes = Axes.Both },
tickContainer = new Container<DrawableSliderTick> { RelativeSizeAxes = Axes.Both }, tickContainer = new Container<DrawableSliderTick> { RelativeSizeAxes = Axes.Both },
repeatContainer = new Container<DrawableSliderRepeat> { RelativeSizeAxes = Axes.Both }, repeatContainer = new Container<DrawableSliderRepeat> { RelativeSizeAxes = Axes.Both },

View File

@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Children = new[] Children = new[]
{ {
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderFollowCircle), _ => new DefaultFollowCircle()) new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.SliderFollowCircle), _ => new DefaultFollowCircle())
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true Masking = true
}, },
ball = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderBall), _ => new DefaultSliderBall()) ball = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.SliderBall), _ => new DefaultSliderBall())
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Children = new Drawable[] Children = new Drawable[]
{ {
// no default for this; only visible in legacy skins. // no default for this; only visible in legacy skins.
CirclePiece = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderTailHitCircle), _ => Empty()) CirclePiece = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.SliderTailHitCircle), _ => Empty())
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -67,7 +67,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Children = new Drawable[] Children = new Drawable[]
{ {
// no default for this; only visible in legacy skins. // no default for this; only visible in legacy skins.
CirclePiece = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderTailHitCircle), _ => Empty()) CirclePiece = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.SliderTailHitCircle), _ => Empty())
} }
}, },
}); });

View File

@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Origin = Anchor.Centre; Origin = Anchor.Centre;
AddInternal(scaleContainer = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderScorePoint), _ => new CircularContainer AddInternal(scaleContainer = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.SliderScorePoint), _ => new CircularContainer
{ {
Masking = true, Masking = true,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Children = new Drawable[] Children = new Drawable[]
{ {
Body = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinner()), Body = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinner()),
RotationTracker = new SpinnerRotationTracker(this) RotationTracker = new SpinnerRotationTracker(this)
} }
}, },

View File

@ -5,9 +5,9 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Osu namespace osu.Game.Rulesets.Osu
{ {
public class OsuSkinComponent : GameplaySkinComponent<OsuSkinComponents> public class OsuSkinLookup : GameplaySkinLookup<OsuSkinComponents>
{ {
public OsuSkinComponent(OsuSkinComponents component) public OsuSkinLookup(OsuSkinComponents component)
: base(component) : base(component)
{ {
} }

View File

@ -14,14 +14,14 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
{ {
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
switch (component) switch (lookup)
{ {
case GameplaySkinComponent<HitResult> resultComponent: case GameplaySkinLookup<HitResult> resultComponent:
return new ArgonJudgementPiece(resultComponent.Component); return new ArgonJudgementPiece(resultComponent.Component);
case OsuSkinComponent osuComponent: case OsuSkinLookup osuComponent:
// TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries. // TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries.
switch (osuComponent.Component) switch (osuComponent.Component)
{ {
@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
break; break;
} }
return base.GetDrawableComponent(component); return base.GetDrawableComponent(lookup);
} }
} }
} }

View File

@ -35,9 +35,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
accentColour.BindValueChanged(colour => Colour = colour.NewValue, true); accentColour.BindValueChanged(colour => Colour = colour.NewValue, true);
} }
protected override Drawable CreateDefault(ISkinComponent component) protected override Drawable CreateDefault(ISkinLookup lookup)
{ {
var drawable = base.CreateDefault(component); var drawable = base.CreateDefault(lookup);
// Although this is a non-legacy component, osu-resources currently stores approach circle as a legacy-like texture. // Although this is a non-legacy component, osu-resources currently stores approach circle as a legacy-like texture.
// See LegacyApproachCircle for documentation as to why this is required. // See LegacyApproachCircle for documentation as to why this is required.

View File

@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
Colour = Color4.White.Opacity(0.5f), Colour = Color4.White.Opacity(0.5f),
}, },
}, },
number = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText number = new SkinnableSpriteText(new OsuSkinLookup(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
{ {
Font = OsuFont.Numeric.With(size: 40), Font = OsuFont.Numeric.With(size: 40),
UseFullGlyphHeight = false, UseFullGlyphHeight = false,

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon Child = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,

View File

@ -35,9 +35,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
accentColour.BindValueChanged(colour => Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true); accentColour.BindValueChanged(colour => Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true);
} }
protected override Drawable CreateDefault(ISkinComponent component) protected override Drawable CreateDefault(ISkinLookup lookup)
{ {
var drawable = base.CreateDefault(component); var drawable = base.CreateDefault(lookup);
// account for the sprite being used for the default approach circle being taken from stable, // account for the sprite being used for the default approach circle being taken from stable,
// when hitcircles have 5px padding on each size. this should be removed if we update the sprite. // when hitcircles have 5px padding on each size. this should be removed if we update the sprite.

View File

@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
if (hasNumber) if (hasNumber)
{ {
OverlayLayer.Add(hitCircleText = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText OverlayLayer.Add(hitCircleText = new SkinnableSpriteText(new OsuSkinLookup(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
{ {
Font = OsuFont.Numeric.With(size: 40), Font = OsuFont.Numeric.With(size: 40),
UseFullGlyphHeight = false, UseFullGlyphHeight = false,

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
string lookupName = new OsuSkinComponent(OsuSkinComponents.ReverseArrow).LookupName; string lookupName = new OsuSkinLookup(OsuSkinComponents.ReverseArrow).LookupName;
var skin = skinSource.FindProvider(s => s.GetTexture(lookupName) != null); var skin = skinSource.FindProvider(s => s.GetTexture(lookupName) != null);
InternalChild = skin?.GetAnimation(lookupName, true, true) ?? Empty(); InternalChild = skin?.GetAnimation(lookupName, true, true) ?? Empty();

View File

@ -28,17 +28,17 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
hasHitCircle = new Lazy<bool>(() => GetTexture("hitcircle") != null); hasHitCircle = new Lazy<bool>(() => GetTexture("hitcircle") != null);
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
if (component is OsuSkinComponent osuComponent) if (lookup is OsuSkinLookup osuComponent)
{ {
switch (osuComponent.Component) switch (osuComponent.Component)
{ {
case OsuSkinComponents.FollowPoint: case OsuSkinComponents.FollowPoint:
return this.GetAnimation(component.LookupName, true, true, true, startAtCurrentTime: false); return this.GetAnimation(lookup.LookupName, true, true, true, startAtCurrentTime: false);
case OsuSkinComponents.SliderScorePoint: case OsuSkinComponents.SliderScorePoint:
return this.GetAnimation(component.LookupName, false, false); return this.GetAnimation(lookup.LookupName, false, false);
case OsuSkinComponents.SliderFollowCircle: case OsuSkinComponents.SliderFollowCircle:
var followCircleContent = this.GetAnimation("sliderfollowcircle", true, true, true); var followCircleContent = this.GetAnimation("sliderfollowcircle", true, true, true);
@ -136,11 +136,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
return new LegacyApproachCircle(); return new LegacyApproachCircle();
default: default:
throw new UnsupportedSkinComponentException(component); throw new UnsupportedSkinComponentException(lookup);
} }
} }
return base.GetDrawableComponent(component); return base.GetDrawableComponent(lookup);
} }
public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)

View File

@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Child = cursorSprite = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling) Child = cursorSprite = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,

View File

@ -47,8 +47,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new[] Children = new[]
{ {
cursorTrail = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.CursorTrail), _ => new DefaultCursorTrail(), confineMode: ConfineMode.NoScaling), cursorTrail = new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.CursorTrail), _ => new DefaultCursorTrail(), confineMode: ConfineMode.NoScaling),
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.CursorParticles), confineMode: ConfineMode.NoScaling), new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.CursorParticles), confineMode: ConfineMode.NoScaling),
} }
}; };
} }

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.UI
{ {
if (e.Action == OsuAction.Smoke) if (e.Action == OsuAction.Smoke)
{ {
AddInternal(currentSegmentSkinnable = new SmokeSkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.CursorSmoke), _ => new DefaultSmokeSegment())); AddInternal(currentSegmentSkinnable = new SmokeSkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.CursorSmoke), _ => new DefaultSmokeSegment()));
// Add initial position immediately. // Add initial position immediately.
addPosition(); addPosition();
@ -68,8 +68,8 @@ namespace osu.Game.Rulesets.Osu.UI
public override double LifetimeStart => Drawable.LifetimeStart; public override double LifetimeStart => Drawable.LifetimeStart;
public override double LifetimeEnd => Drawable.LifetimeEnd; public override double LifetimeEnd => Drawable.LifetimeEnd;
public SmokeSkinnableDrawable(ISkinComponent component, Func<ISkinComponent, Drawable>? defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling) public SmokeSkinnableDrawable(ISkinLookup lookup, Func<ISkinLookup, Drawable>? defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
: base(component, defaultImplementation, confineMode) : base(lookup, defaultImplementation, confineMode)
{ {
} }
} }

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
public TestSceneTaikoScroller() public TestSceneTaikoScroller()
{ {
AddStep("Load scroller", () => SetContents(_ => AddStep("Load scroller", () => SetContents(_ =>
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Scroller), _ => Empty()) new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.Scroller), _ => Empty())
{ {
Clock = new FramedClock(clock), Clock = new FramedClock(clock),
Height = 0.4f, Height = 0.4f,

View File

@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
AddRangeInternal(new Drawable[] AddRangeInternal(new Drawable[]
{ {
line = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.BarLine), _ => new Box line = new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.BarLine), _ => new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
EdgeSmoothness = new Vector2(0.5f, 0), EdgeSmoothness = new Vector2(0.5f, 0),

View File

@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
return base.CreateNestedHitObject(hitObject); return base.CreateNestedHitObject(hitObject);
} }
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollBody), protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.DrumRollBody),
_ => new ElongatedCirclePiece()); _ => new ElongatedCirclePiece());
public override bool OnPressed(KeyBindingPressEvent<TaikoAction> e) => false; public override bool OnPressed(KeyBindingPressEvent<TaikoAction> e) => false;

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
FillMode = FillMode.Fit; FillMode = FillMode.Fit;
} }
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollTick), protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.DrumRollTick),
_ => new TickPiece _ => new TickPiece
{ {
Filled = HitObject.FirstTick Filled = HitObject.FirstTick

View File

@ -90,8 +90,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
} }
protected override SkinnableDrawable CreateMainPiece() => HitObject.Type == HitType.Centre protected override SkinnableDrawable CreateMainPiece() => HitObject.Type == HitType.Centre
? new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.CentreHit), _ => new CentreHitCirclePiece(), confineMode: ConfineMode.ScaleToFit) ? new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.CentreHit), _ => new CentreHitCirclePiece(), confineMode: ConfineMode.ScaleToFit)
: new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.RimHit), _ => new RimHitCirclePiece(), confineMode: ConfineMode.ScaleToFit); : new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.RimHit), _ => new RimHitCirclePiece(), confineMode: ConfineMode.ScaleToFit);
public override IEnumerable<HitSampleInfo> GetSamples() public override IEnumerable<HitSampleInfo> GetSamples()
{ {

View File

@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
targetRing.BorderColour = colours.YellowDark.Opacity(0.25f); targetRing.BorderColour = colours.YellowDark.Opacity(0.25f);
} }
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Swell), protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.Swell),
_ => new SwellCirclePiece _ => new SwellCirclePiece
{ {
// to allow for rotation transform // to allow for rotation transform

View File

@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
public override bool OnPressed(KeyBindingPressEvent<TaikoAction> e) => false; public override bool OnPressed(KeyBindingPressEvent<TaikoAction> e) => false;
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollTick), protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.DrumRollTick),
_ => new TickPiece()); _ => new TickPiece());
} }
} }

View File

@ -27,16 +27,16 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
hasExplosion = new Lazy<bool>(() => GetTexture(getHitName(TaikoSkinComponents.TaikoExplosionGreat)) != null); hasExplosion = new Lazy<bool>(() => GetTexture(getHitName(TaikoSkinComponents.TaikoExplosionGreat)) != null);
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
if (component is GameplaySkinComponent<HitResult>) if (lookup is GameplaySkinLookup<HitResult>)
{ {
// if a taiko skin is providing explosion sprites, hide the judgements completely // if a taiko skin is providing explosion sprites, hide the judgements completely
if (hasExplosion.Value) if (hasExplosion.Value)
return Drawable.Empty().With(d => d.Expire()); return Drawable.Empty().With(d => d.Expire());
} }
if (component is TaikoSkinComponent taikoComponent) if (lookup is TaikoSkinLookup taikoComponent)
{ {
switch (taikoComponent.Component) switch (taikoComponent.Component)
{ {
@ -130,11 +130,11 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
return new DrawableTaikoMascot(); return new DrawableTaikoMascot();
default: default:
throw new UnsupportedSkinComponentException(component); throw new UnsupportedSkinComponentException(lookup);
} }
} }
return base.GetDrawableComponent(component); return base.GetDrawableComponent(lookup);
} }
private string getHitName(TaikoSkinComponents component) private string getHitName(TaikoSkinComponents component)

View File

@ -5,9 +5,9 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko namespace osu.Game.Rulesets.Taiko
{ {
public class TaikoSkinComponent : GameplaySkinComponent<TaikoSkinComponents> public class TaikoSkinLookup : GameplaySkinLookup<TaikoSkinComponents>
{ {
public TaikoSkinComponent(TaikoSkinComponents component) public TaikoSkinLookup(TaikoSkinComponents component)
: base(component) : base(component)
{ {
} }

View File

@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
new BarLineGenerator<BarLine>(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar)); new BarLineGenerator<BarLine>(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar));
FrameStableComponents.Add(scroller = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Scroller), _ => Empty()) FrameStableComponents.Add(scroller = new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.Scroller), _ => Empty())
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Depth = float.MaxValue Depth = float.MaxValue

View File

@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Taiko.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
InternalChild = skinnable = new SkinnableDrawable(new TaikoSkinComponent(getComponentName(result)), _ => new DefaultHitExplosion(result)); InternalChild = skinnable = new SkinnableDrawable(new TaikoSkinLookup(getComponentName(result)), _ => new DefaultHitExplosion(result));
skinnable.OnSkinChanged += runAnimation; skinnable.OnSkinChanged += runAnimation;
} }

View File

@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.InputDrum), _ => new DefaultInputDrum()) new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.InputDrum), _ => new DefaultInputDrum())
{ {
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Taiko.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Child = skinnable = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.TaikoExplosionKiai), _ => new DefaultKiaiHitExplosion(hitType)); Child = skinnable = new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.TaikoExplosionKiai), _ => new DefaultKiaiHitExplosion(hitType));
} }
} }
} }

View File

@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Taiko.UI
InternalChildren = new[] InternalChildren = new[]
{ {
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundRight), _ => new PlayfieldBackgroundRight()), new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.PlayfieldBackgroundRight), _ => new PlayfieldBackgroundRight()),
new Container new Container
{ {
Name = "Left overlay", Name = "Left overlay",
@ -86,11 +86,11 @@ namespace osu.Game.Rulesets.Taiko.UI
BorderColour = colours.Gray0, BorderColour = colours.Gray0,
Children = new[] Children = new[]
{ {
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()), new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
inputDrum.CreateProxy(), inputDrum.CreateProxy(),
} }
}, },
mascot = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Mascot), _ => Empty()) mascot = new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.Mascot), _ => Empty())
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.TopLeft, Anchor = Anchor.TopLeft,
@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
HitTarget = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.HitTarget), _ => new TaikoHitTarget()) HitTarget = new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.HitTarget), _ => new TaikoHitTarget())
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
} }

View File

@ -126,7 +126,7 @@ namespace osu.Game.Tests.Gameplay
Color4.Green Color4.Green
}; };
public Drawable GetDrawableComponent(ISkinComponent component) => throw new NotImplementedException(); public Drawable GetDrawableComponent(ISkinLookup lookup) => throw new NotImplementedException();
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException(); public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();

View File

@ -73,7 +73,7 @@ namespace osu.Game.Tests.NonVisual.Skinning
return lookup_names.Contains(componentName) ? renderer.WhitePixel : null; return lookup_names.Contains(componentName) ? renderer.WhitePixel : null;
} }
public Drawable GetDrawableComponent(ISkinComponent component) => throw new NotSupportedException(); public Drawable GetDrawableComponent(ISkinLookup lookup) => throw new NotSupportedException();
public ISample GetSample(ISampleInfo sampleInfo) => throw new NotSupportedException(); public ISample GetSample(ISampleInfo sampleInfo) => throw new NotSupportedException();
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotSupportedException(); public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotSupportedException();
} }

View File

@ -78,7 +78,7 @@ namespace osu.Game.Tests.Rulesets
OnLoadAsync?.Invoke(); OnLoadAsync?.Invoke();
} }
public Drawable GetDrawableComponent(ISkinComponent component) => skin.GetDrawableComponent(component); public Drawable GetDrawableComponent(ISkinLookup lookup) => skin.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => skin.GetTexture(componentName); public Texture GetTexture(string componentName, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => skin.GetTexture(componentName);

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Skins
string expected = allowBeatmapLookups ? "beatmap" : "user"; string expected = allowBeatmapLookups ? "beatmap" : "user";
AddAssert($"Check lookup is from {expected}", () => requester.GetDrawableComponent(new TestSkinComponent())?.Name == expected); AddAssert($"Check lookup is from {expected}", () => requester.GetDrawableComponent(new TestSkinLookup())?.Name == expected);
} }
[TestCase(false)] [TestCase(false)]
@ -59,7 +59,7 @@ namespace osu.Game.Tests.Skins
ISkin expected() => allowBeatmapLookups ? beatmapSource : userSource; ISkin expected() => allowBeatmapLookups ? beatmapSource : userSource;
AddAssert("Check lookup is from correct source", () => requester.FindProvider(s => s.GetDrawableComponent(new TestSkinComponent()) != null) == expected()); AddAssert("Check lookup is from correct source", () => requester.FindProvider(s => s.GetDrawableComponent(new TestSkinLookup()) != null) == expected());
} }
public class UserSkinSource : LegacySkin public class UserSkinSource : LegacySkin
@ -69,7 +69,7 @@ namespace osu.Game.Tests.Skins
{ {
} }
public override Drawable GetDrawableComponent(ISkinComponent component) public override Drawable GetDrawableComponent(ISkinLookup lookup)
{ {
return new Container { Name = "user" }; return new Container { Name = "user" };
} }
@ -82,7 +82,7 @@ namespace osu.Game.Tests.Skins
{ {
} }
public override Drawable GetDrawableComponent(ISkinComponent component) public override Drawable GetDrawableComponent(ISkinLookup lookup)
{ {
return new Container { Name = "beatmap" }; return new Container { Name = "beatmap" };
} }
@ -98,7 +98,7 @@ namespace osu.Game.Tests.Skins
this.skin = skin; this.skin = skin;
} }
public Drawable GetDrawableComponent(ISkinComponent component) => skin.GetDrawableComponent(component); public Drawable GetDrawableComponent(ISkinLookup lookup) => skin.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, wrapModeS, wrapModeT); public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, wrapModeS, wrapModeT);
@ -109,7 +109,7 @@ namespace osu.Game.Tests.Skins
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => skin.FindProvider(lookupFunction); public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => skin.FindProvider(lookupFunction);
} }
private class TestSkinComponent : ISkinComponent private class TestSkinLookup : ISkinLookup
{ {
public string LookupName => string.Empty; public string LookupName => string.Empty;
} }

View File

@ -221,7 +221,7 @@ namespace osu.Game.Tests.Skins
this.skin = skin; this.skin = skin;
} }
public Drawable GetDrawableComponent(ISkinComponent component) => skin.GetDrawableComponent(component); public Drawable GetDrawableComponent(ISkinLookup lookup) => skin.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, wrapModeS, wrapModeT); public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, wrapModeS, wrapModeT);

View File

@ -87,7 +87,7 @@ namespace osu.Game.Tests.Skins
this.renderer = renderer; this.renderer = renderer;
} }
public Drawable GetDrawableComponent(ISkinComponent component) => throw new System.NotImplementedException(); public Drawable GetDrawableComponent(ISkinLookup lookup) => throw new System.NotImplementedException();
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
{ {

View File

@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual.Gameplay
var actualInfo = actualComponentsContainer.CreateSkinnableInfo(); var actualInfo = actualComponentsContainer.CreateSkinnableInfo();
var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource.GetDrawableComponent(new SkinnableTargetComponent(target)); var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource.GetDrawableComponent(new SkinnableTargetLookup(target));
if (expectedComponentsContainer == null) if (expectedComponentsContainer == null)
return false; return false;

View File

@ -164,7 +164,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
private bool allow = true; private bool allow = true;
protected override bool AllowDrawableLookup(ISkinComponent component) => allow; protected override bool AllowDrawableLookup(ISkinLookup lookup) => allow;
public void Disable() public void Disable()
{ {
@ -182,8 +182,8 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
public new Drawable Drawable => base.Drawable; public new Drawable Drawable => base.Drawable;
public ExposedSkinnableDrawable(string name, Func<ISkinComponent, Drawable> defaultImplementation, ConfineMode confineMode = ConfineMode.ScaleToFit) public ExposedSkinnableDrawable(string name, Func<ISkinLookup, Drawable> defaultImplementation, ConfineMode confineMode = ConfineMode.ScaleToFit)
: base(new TestSkinComponent(name), defaultImplementation, confineMode) : base(new TestSkinLookup(name), defaultImplementation, confineMode)
{ {
} }
} }
@ -251,8 +251,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public new Drawable Drawable => base.Drawable; public new Drawable Drawable => base.Drawable;
public int SkinChangedCount { get; private set; } public int SkinChangedCount { get; private set; }
public SkinConsumer(string name, Func<ISkinComponent, Drawable> defaultImplementation) public SkinConsumer(string name, Func<ISkinLookup, Drawable> defaultImplementation)
: base(new TestSkinComponent(name), defaultImplementation) : base(new TestSkinLookup(name), defaultImplementation)
{ {
} }
@ -288,8 +288,8 @@ namespace osu.Game.Tests.Visual.Gameplay
this.size = size; this.size = size;
} }
public Drawable GetDrawableComponent(ISkinComponent componentName) => public Drawable GetDrawableComponent(ISkinLookup lookupName) =>
componentName.LookupName == "available" lookupName.LookupName == "available"
? new DrawWidthBox ? new DrawWidthBox
{ {
Colour = Color4.Yellow, Colour = Color4.Yellow,
@ -306,7 +306,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private class SecondarySource : ISkin private class SecondarySource : ISkin
{ {
public Drawable GetDrawableComponent(ISkinComponent componentName) => new SecondarySourceBox(); public Drawable GetDrawableComponent(ISkinLookup lookupName) => new SecondarySourceBox();
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException(); public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
@ -318,7 +318,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Cached(typeof(ISkinSource))] [Cached(typeof(ISkinSource))]
private class SkinSourceContainer : Container, ISkinSource private class SkinSourceContainer : Container, ISkinSource
{ {
public Drawable GetDrawableComponent(ISkinComponent componentName) => new BaseSourceBox(); public Drawable GetDrawableComponent(ISkinLookup lookupName) => new BaseSourceBox();
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException(); public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
@ -337,9 +337,9 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
} }
private class TestSkinComponent : ISkinComponent private class TestSkinLookup : ISkinLookup
{ {
public TestSkinComponent(string name) public TestSkinLookup(string name)
{ {
LookupName = name; LookupName = name;
} }

View File

@ -142,7 +142,7 @@ namespace osu.Game.Tests.Visual.Gameplay
IBindable<bool> ISamplePlaybackDisabler.SamplePlaybackDisabled => SamplePlaybackDisabled; IBindable<bool> ISamplePlaybackDisabler.SamplePlaybackDisabled => SamplePlaybackDisabled;
public Drawable GetDrawableComponent(ISkinComponent component) => source?.GetDrawableComponent(component); public Drawable GetDrawableComponent(ISkinLookup lookup) => source?.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source?.GetTexture(componentName, wrapModeS, wrapModeT); public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source?.GetTexture(componentName, wrapModeS, wrapModeT);
public ISample GetSample(ISampleInfo sampleInfo) => source?.GetSample(sampleInfo); public ISample GetSample(ISampleInfo sampleInfo) => source?.GetSample(sampleInfo);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source?.GetConfig<TLookup, TValue>(lookup); public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source?.GetConfig<TLookup, TValue>(lookup);

View File

@ -167,7 +167,7 @@ namespace osu.Game.Rulesets.Judgements
if (JudgementBody != null) if (JudgementBody != null)
RemoveInternal(JudgementBody, true); RemoveInternal(JudgementBody, true);
AddInternal(JudgementBody = new SkinnableDrawable(new GameplaySkinComponent<HitResult>(type), _ => AddInternal(JudgementBody = new SkinnableDrawable(new GameplaySkinLookup<HitResult>(type), _ =>
CreateDefaultJudgement(type), confineMode: ConfineMode.NoScaling) CreateDefaultJudgement(type), confineMode: ConfineMode.NoScaling)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,

View File

@ -53,7 +53,7 @@ namespace osu.Game.Screens.Edit
#region Delegated ISkin implementation #region Delegated ISkin implementation
public Drawable GetDrawableComponent(ISkinComponent component) => Skin.GetDrawableComponent(component); public Drawable GetDrawableComponent(ISkinLookup lookup) => Skin.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT); public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT);
public ISample GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo); public ISample GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Skin.GetConfig<TLookup, TValue>(lookup); public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Skin.GetConfig<TLookup, TValue>(lookup);

View File

@ -81,14 +81,14 @@ namespace osu.Game.Skinning
return null; return null;
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
if (base.GetDrawableComponent(component) is Drawable c) if (base.GetDrawableComponent(lookup) is Drawable c)
return c; return c;
switch (component) switch (lookup)
{ {
case SkinnableTargetComponent target: case SkinnableTargetLookup target:
switch (target.Target) switch (target.Target)
{ {
case SkinnableTarget.SongSelect: case SkinnableTarget.SongSelect:
@ -178,14 +178,14 @@ namespace osu.Game.Skinning
return null; return null;
} }
switch (component.LookupName) switch (lookup.LookupName)
{ {
// Temporary until default skin has a valid hit lighting. // Temporary until default skin has a valid hit lighting.
case @"lighting": case @"lighting":
return Drawable.Empty(); return Drawable.Empty();
} }
if (GetTexture(component.LookupName) is Texture t) if (GetTexture(lookup.LookupName) is Texture t)
return new Sprite { Texture = t }; return new Sprite { Texture = t };
return null; return null;

View File

@ -43,7 +43,7 @@ namespace osu.Game.Skinning
} }
} }
protected override bool AllowDrawableLookup(ISkinComponent component) protected override bool AllowDrawableLookup(ISkinLookup lookup)
{ {
if (beatmapSkins == null) if (beatmapSkins == null)
throw new InvalidOperationException($"{nameof(BeatmapSkinProvidingContainer)} needs to be loaded before being consumed."); throw new InvalidOperationException($"{nameof(BeatmapSkinProvidingContainer)} needs to be loaded before being consumed.");

View File

@ -5,12 +5,12 @@ using System.Linq;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public class GameplaySkinComponent<T> : ISkinComponent public class GameplaySkinLookup<T> : ISkinLookup
where T : notnull where T : notnull
{ {
public readonly T Component; public readonly T Component;
public GameplaySkinComponent(T component) public GameplaySkinLookup(T component)
{ {
Component = component; Component = component;
} }

View File

@ -17,9 +17,9 @@ namespace osu.Game.Skinning
/// <summary> /// <summary>
/// Retrieve a <see cref="Drawable"/> component implementation. /// Retrieve a <see cref="Drawable"/> component implementation.
/// </summary> /// </summary>
/// <param name="component">The requested component.</param> /// <param name="lookup">The requested component.</param>
/// <returns>A drawable representation for the requested component, or null if unavailable.</returns> /// <returns>A drawable representation for the requested component, or null if unavailable.</returns>
Drawable? GetDrawableComponent(ISkinComponent component); Drawable? GetDrawableComponent(ISkinLookup lookup);
/// <summary> /// <summary>
/// Retrieve a <see cref="Texture"/>. /// Retrieve a <see cref="Texture"/>.

View File

@ -1,10 +0,0 @@
// 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.
namespace osu.Game.Skinning
{
public interface ISkinComponent
{
string LookupName { get; }
}
}

View File

@ -0,0 +1,21 @@
// 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.
namespace osu.Game.Skinning
{
/// <summary>
/// A lookup type which can be used with <see cref="ISkin.GetDrawableComponent"/>.
/// </summary>
/// <remarks>
/// Implementations of <see cref="ISkin.GetDrawableComponent"/> should match on types implementing this interface
/// to scope particular lookup variations. Using this, a ruleset or skin implementation could make its own lookup
/// type to scope away from more global contexts.
///
/// More commonly, a ruleset could make use of <see cref="GameplaySkinLookup{T}"/> to do a simple lookup based on
/// a provided enum.
/// </remarks>
public interface ISkinLookup
{
string LookupName { get; }
}
}

View File

@ -43,9 +43,9 @@ namespace osu.Game.Skinning
return new RealmBackedResourceStore<BeatmapSetInfo>(beatmapInfo.BeatmapSet.ToLive(resources.RealmAccess), resources.Files, resources.RealmAccess); return new RealmBackedResourceStore<BeatmapSetInfo>(beatmapInfo.BeatmapSet.ToLive(resources.RealmAccess), resources.Files, resources.RealmAccess);
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
if (component is SkinnableTargetComponent targetComponent) if (lookup is SkinnableTargetLookup targetComponent)
{ {
switch (targetComponent.Target) switch (targetComponent.Target)
{ {
@ -59,7 +59,7 @@ namespace osu.Game.Skinning
} }
} }
return base.GetDrawableComponent(component); return base.GetDrawableComponent(lookup);
} }
public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)

View File

@ -322,14 +322,14 @@ namespace osu.Game.Skinning
return null; return null;
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
if (base.GetDrawableComponent(component) is Drawable c) if (base.GetDrawableComponent(lookup) is Drawable c)
return c; return c;
switch (component) switch (lookup)
{ {
case SkinnableTargetComponent target: case SkinnableTargetLookup target:
switch (target.Target) switch (target.Target)
{ {
case SkinnableTarget.MainHUDComponents: case SkinnableTarget.MainHUDComponents:
@ -379,7 +379,7 @@ namespace osu.Game.Skinning
return null; return null;
case GameplaySkinComponent<HitResult> resultComponent: case GameplaySkinLookup<HitResult> resultComponent:
// kind of wasteful that we throw this away, but should do for now. // kind of wasteful that we throw this away, but should do for now.
if (getJudgementAnimation(resultComponent.Component) != null) if (getJudgementAnimation(resultComponent.Component) != null)
@ -397,7 +397,7 @@ namespace osu.Game.Skinning
return null; return null;
case SkinnableSprite.SpriteComponent sprite: case SkinnableSprite.SpriteLookup sprite:
return this.GetAnimation(sprite.LookupName, false, false); return this.GetAnimation(sprite.LookupName, false, false);
} }

View File

@ -27,7 +27,7 @@ namespace osu.Game.Skinning
samples = audio.GetSampleStore(new NamespacedResourceStore<byte[]>(resources, @"Samples")); samples = audio.GetSampleStore(new NamespacedResourceStore<byte[]>(resources, @"Samples"));
} }
public Drawable? GetDrawableComponent(ISkinComponent component) => null; public Drawable? GetDrawableComponent(ISkinLookup lookup) => null;
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => textures.Get(componentName, wrapModeS, wrapModeT); public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => textures.Get(componentName, wrapModeS, wrapModeT);

View File

@ -154,11 +154,11 @@ namespace osu.Game.Skinning
DrawableComponentInfo[targetContainer.Target] = targetContainer.CreateSkinnableInfo().ToArray(); DrawableComponentInfo[targetContainer.Target] = targetContainer.CreateSkinnableInfo().ToArray();
} }
public virtual Drawable? GetDrawableComponent(ISkinComponent component) public virtual Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
switch (component) switch (lookup)
{ {
case SkinnableTargetComponent target: case SkinnableTargetLookup target:
if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo)) if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo))
return null; return null;

View File

@ -201,7 +201,7 @@ namespace osu.Game.Skinning
public event Action SourceChanged; public event Action SourceChanged;
public Drawable GetDrawableComponent(ISkinComponent component) => lookupWithFallback(s => s.GetDrawableComponent(component)); public Drawable GetDrawableComponent(ISkinLookup lookup) => lookupWithFallback(s => s.GetDrawableComponent(lookup));
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => lookupWithFallback(s => s.GetTexture(componentName, wrapModeS, wrapModeT)); public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => lookupWithFallback(s => s.GetTexture(componentName, wrapModeS, wrapModeT));

View File

@ -28,7 +28,7 @@ namespace osu.Game.Skinning
/// </summary> /// </summary>
protected virtual bool AllowFallingBackToParent => true; protected virtual bool AllowFallingBackToParent => true;
protected virtual bool AllowDrawableLookup(ISkinComponent component) => true; protected virtual bool AllowDrawableLookup(ISkinLookup lookup) => true;
protected virtual bool AllowTextureLookup(string componentName) => true; protected virtual bool AllowTextureLookup(string componentName) => true;
@ -107,19 +107,19 @@ namespace osu.Game.Skinning
} }
} }
public Drawable? GetDrawableComponent(ISkinComponent component) public Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
foreach (var (_, lookupWrapper) in skinSources) foreach (var (_, lookupWrapper) in skinSources)
{ {
Drawable? sourceDrawable; Drawable? sourceDrawable;
if ((sourceDrawable = lookupWrapper.GetDrawableComponent(component)) != null) if ((sourceDrawable = lookupWrapper.GetDrawableComponent(lookup)) != null)
return sourceDrawable; return sourceDrawable;
} }
if (!AllowFallingBackToParent) if (!AllowFallingBackToParent)
return null; return null;
return ParentSource?.GetDrawableComponent(component); return ParentSource?.GetDrawableComponent(lookup);
} }
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
@ -238,10 +238,10 @@ namespace osu.Game.Skinning
this.provider = provider; this.provider = provider;
} }
public Drawable? GetDrawableComponent(ISkinComponent component) public Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
if (provider.AllowDrawableLookup(component)) if (provider.AllowDrawableLookup(lookup))
return skin.GetDrawableComponent(component); return skin.GetDrawableComponent(lookup);
return null; return null;
} }

View File

@ -19,7 +19,7 @@ namespace osu.Game.Skinning
Skin = skin ?? throw new ArgumentNullException(nameof(skin)); Skin = skin ?? throw new ArgumentNullException(nameof(skin));
} }
public virtual Drawable? GetDrawableComponent(ISkinComponent component) => Skin.GetDrawableComponent(component); public virtual Drawable? GetDrawableComponent(ISkinLookup lookup) => Skin.GetDrawableComponent(lookup);
public virtual Texture? GetTexture(string componentName) => GetTexture(componentName, default, default); public virtual Texture? GetTexture(string componentName) => GetTexture(componentName, default, default);

View File

@ -31,25 +31,25 @@ namespace osu.Game.Skinning
set => base.AutoSizeAxes = value; set => base.AutoSizeAxes = value;
} }
protected readonly ISkinComponent Component; protected readonly ISkinLookup Lookup;
private readonly ConfineMode confineMode; private readonly ConfineMode confineMode;
/// <summary> /// <summary>
/// Create a new skinnable drawable. /// Create a new skinnable drawable.
/// </summary> /// </summary>
/// <param name="component">The namespace-complete resource name for this skinnable element.</param> /// <param name="lookup">The namespace-complete resource name for this skinnable element.</param>
/// <param name="defaultImplementation">A function to create the default skin implementation of this element.</param> /// <param name="defaultImplementation">A function to create the default skin implementation of this element.</param>
/// <param name="confineMode">How (if at all) the <see cref="Drawable"/> should be resize to fit within our own bounds.</param> /// <param name="confineMode">How (if at all) the <see cref="Drawable"/> should be resize to fit within our own bounds.</param>
public SkinnableDrawable(ISkinComponent component, Func<ISkinComponent, Drawable>? defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling) public SkinnableDrawable(ISkinLookup lookup, Func<ISkinLookup, Drawable>? defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
: this(component, confineMode) : this(lookup, confineMode)
{ {
createDefault = defaultImplementation; createDefault = defaultImplementation;
} }
protected SkinnableDrawable(ISkinComponent component, ConfineMode confineMode = ConfineMode.NoScaling) protected SkinnableDrawable(ISkinLookup lookup, ConfineMode confineMode = ConfineMode.NoScaling)
{ {
Component = component; Lookup = lookup;
this.confineMode = confineMode; this.confineMode = confineMode;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -60,13 +60,13 @@ namespace osu.Game.Skinning
/// </summary> /// </summary>
public void ResetAnimation() => (Drawable as IFramedAnimation)?.GotoFrame(0); public void ResetAnimation() => (Drawable as IFramedAnimation)?.GotoFrame(0);
private readonly Func<ISkinComponent, Drawable>? createDefault; private readonly Func<ISkinLookup, Drawable>? createDefault;
private readonly Cached scaling = new Cached(); private readonly Cached scaling = new Cached();
private bool isDefault; private bool isDefault;
protected virtual Drawable CreateDefault(ISkinComponent component) => createDefault?.Invoke(component) ?? Empty(); protected virtual Drawable CreateDefault(ISkinLookup lookup) => createDefault?.Invoke(lookup) ?? Empty();
/// <summary> /// <summary>
/// Whether to apply size restrictions (specified via <see cref="confineMode"/>) to the default implementation. /// Whether to apply size restrictions (specified via <see cref="confineMode"/>) to the default implementation.
@ -75,11 +75,11 @@ namespace osu.Game.Skinning
protected override void SkinChanged(ISkinSource skin) protected override void SkinChanged(ISkinSource skin)
{ {
var retrieved = skin.GetDrawableComponent(Component); var retrieved = skin.GetDrawableComponent(Lookup);
if (retrieved == null) if (retrieved == null)
{ {
Drawable = CreateDefault(Component); Drawable = CreateDefault(Lookup);
isDefault = true; isDefault = true;
} }
else else

View File

@ -34,42 +34,42 @@ namespace osu.Game.Skinning
private ISkinSource source { get; set; } = null!; private ISkinSource source { get; set; } = null!;
public SkinnableSprite(string textureName, ConfineMode confineMode = ConfineMode.NoScaling) public SkinnableSprite(string textureName, ConfineMode confineMode = ConfineMode.NoScaling)
: base(new SpriteComponent(textureName), confineMode) : base(new SpriteLookup(textureName), confineMode)
{ {
SpriteName.Value = textureName; SpriteName.Value = textureName;
} }
public SkinnableSprite() public SkinnableSprite()
: base(new SpriteComponent(string.Empty), ConfineMode.NoScaling) : base(new SpriteLookup(string.Empty), ConfineMode.NoScaling)
{ {
RelativeSizeAxes = Axes.None; RelativeSizeAxes = Axes.None;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
SpriteName.BindValueChanged(name => SpriteName.BindValueChanged(name =>
{ {
((SpriteComponent)Component).LookupName = name.NewValue ?? string.Empty; ((SpriteLookup)Lookup).LookupName = name.NewValue ?? string.Empty;
if (IsLoaded) if (IsLoaded)
SkinChanged(CurrentSkin); SkinChanged(CurrentSkin);
}); });
} }
protected override Drawable CreateDefault(ISkinComponent component) protected override Drawable CreateDefault(ISkinLookup lookup)
{ {
var texture = textures.Get(component.LookupName); var texture = textures.Get(lookup.LookupName);
if (texture == null) if (texture == null)
return new SpriteNotFound(component.LookupName); return new SpriteNotFound(lookup.LookupName);
return new Sprite { Texture = texture }; return new Sprite { Texture = texture };
} }
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }
internal class SpriteComponent : ISkinComponent internal class SpriteLookup : ISkinLookup
{ {
public string LookupName { get; set; } public string LookupName { get; set; }
public SpriteComponent(string textureName) public SpriteLookup(string textureName)
{ {
LookupName = textureName; LookupName = textureName;
} }

View File

@ -9,8 +9,8 @@ namespace osu.Game.Skinning
{ {
public class SkinnableSpriteText : SkinnableDrawable, IHasText public class SkinnableSpriteText : SkinnableDrawable, IHasText
{ {
public SkinnableSpriteText(ISkinComponent component, Func<ISkinComponent, SpriteText> defaultImplementation, ConfineMode confineMode = ConfineMode.NoScaling) public SkinnableSpriteText(ISkinLookup lookup, Func<ISkinLookup, SpriteText> defaultImplementation, ConfineMode confineMode = ConfineMode.NoScaling)
: base(component, defaultImplementation, confineMode) : base(lookup, defaultImplementation, confineMode)
{ {
} }

View File

@ -39,7 +39,7 @@ namespace osu.Game.Skinning
components.Clear(); components.Clear();
ComponentsLoaded = false; ComponentsLoaded = false;
content = CurrentSkin.GetDrawableComponent(new SkinnableTargetComponent(Target)) as SkinnableTargetComponentsContainer; content = CurrentSkin.GetDrawableComponent(new SkinnableTargetLookup(Target)) as SkinnableTargetComponentsContainer;
cancellationSource?.Cancel(); cancellationSource?.Cancel();
cancellationSource = null; cancellationSource = null;

View File

@ -3,13 +3,13 @@
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public class SkinnableTargetComponent : ISkinComponent public class SkinnableTargetLookup : ISkinLookup
{ {
public readonly SkinnableTarget Target; public readonly SkinnableTarget Target;
public string LookupName => Target.ToString(); public string LookupName => Target.ToString();
public SkinnableTargetComponent(SkinnableTarget target) public SkinnableTargetLookup(SkinnableTarget target)
{ {
Target = target; Target = target;
} }

View File

@ -59,14 +59,14 @@ namespace osu.Game.Skinning
return null; return null;
} }
public override Drawable? GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinLookup lookup)
{ {
if (base.GetDrawableComponent(component) is Drawable c) if (base.GetDrawableComponent(lookup) is Drawable c)
return c; return c;
switch (component) switch (lookup)
{ {
case SkinnableTargetComponent target: case SkinnableTargetLookup target:
switch (target.Target) switch (target.Target)
{ {
case SkinnableTarget.SongSelect: case SkinnableTarget.SongSelect:
@ -156,14 +156,14 @@ namespace osu.Game.Skinning
return null; return null;
} }
switch (component.LookupName) switch (lookup.LookupName)
{ {
// Temporary until default skin has a valid hit lighting. // Temporary until default skin has a valid hit lighting.
case @"lighting": case @"lighting":
return Drawable.Empty(); return Drawable.Empty();
} }
if (GetTexture(component.LookupName) is Texture t) if (GetTexture(lookup.LookupName) is Texture t)
return new Sprite { Texture = t }; return new Sprite { Texture = t };
return null; return null;

View File

@ -7,8 +7,8 @@ namespace osu.Game.Skinning
{ {
public class UnsupportedSkinComponentException : Exception public class UnsupportedSkinComponentException : Exception
{ {
public UnsupportedSkinComponentException(ISkinComponent component) public UnsupportedSkinComponentException(ISkinLookup lookup)
: base($@"Unsupported component type: {component.GetType()} (lookup: ""{component.LookupName}"").") : base($@"Unsupported component type: {lookup.GetType()} (lookup: ""{lookup.LookupName}"").")
{ {
} }
} }