1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:07:23 +08:00

Merge pull request #21184 from peppy/skinnable-things-cleanup

Skinnable class naming pass
This commit is contained in:
Dan Balasescu 2022-11-10 12:52:08 +09:00 committed by GitHub
commit 606d42c679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
98 changed files with 295 additions and 289 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
private void load()
{
ScalingContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Fruit),
new CatchSkinComponentLookup(CatchSkinComponents.Fruit),
_ => 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(ISkinComponentLookup lookup)
{
switch (component)
switch (lookup)
{
case CatchSkinComponent catchComponent:
case CatchSkinComponentLookup catchComponent:
// TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries.
switch (catchComponent.Component)
{
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Argon
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(ISkinComponentLookup lookup)
{
if (component is SkinnableTargetComponent targetComponent)
if (lookup is GlobalSkinComponentLookup targetComponent)
{
switch (targetComponent.Target)
switch (targetComponent.Lookup)
{
case SkinnableTarget.MainHUDComponents:
var components = base.GetDrawableComponent(component) as SkinnableTargetComponentsContainer;
case GlobalSkinComponentLookup.LookupType.MainHUDComponents:
var components = base.GetDrawableComponent(lookup) as SkinnableTargetComponentsContainer;
if (providesComboCounter && components != null)
{
@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
}
}
if (component is CatchSkinComponent catchSkinComponent)
if (lookup is CatchSkinComponentLookup catchSkinComponent)
{
switch (catchSkinComponent.Component)
{
@ -95,11 +95,11 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
return null;
default:
throw new UnsupportedSkinComponentException(component);
throw new UnsupportedSkinComponentException(lookup);
}
}
return base.GetDrawableComponent(component);
return base.GetDrawableComponent(lookup);
}
private bool hasOldStyleCatcherSprite() =>
@ -127,7 +127,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{
case CatchSkinConfiguration.FlipCatcherPlate:
// 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 CatchSkinComponentLookup(CatchSkinComponents.Catcher)) != null)
return (IBindable<TValue>)new Bindable<bool>();
break;

View File

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

View File

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

View File

@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Catch.UI
public readonly Bindable<CatcherAnimationState> AnimationState = new Bindable<CatcherAnimationState>();
public SkinnableCatcher()
: base(new CatchSkinComponent(CatchSkinComponents.Catcher), _ => new DefaultCatcher())
: base(new CatchSkinComponentLookup(CatchSkinComponents.Catcher), _ => new DefaultCatcher())
{
Anchor = Anchor.TopCentre;
// 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,
Width = 0.5f,
Child = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
Child = new SkinnableDrawable(new ManiaSkinComponentLookup(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
{
RelativeSizeAxes = Axes.Both
}
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Child = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
Child = new SkinnableDrawable(new ManiaSkinComponentLookup(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
{
RelativeSizeAxes = Axes.Both
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,14 +22,14 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
this.beatmap = (ManiaBeatmap)beatmap;
}
public override Drawable? GetDrawableComponent(ISkinComponent component)
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
switch (component)
switch (lookup)
{
case GameplaySkinComponent<HitResult> resultComponent:
case GameplaySkinComponentLookup<HitResult> resultComponent:
return new ArgonJudgementPiece(resultComponent.Component);
case ManiaSkinComponent maniaComponent:
case ManiaSkinComponentLookup maniaComponent:
// TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries.
switch (maniaComponent.Component)
{
@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
break;
}
return base.GetDrawableComponent(component);
return base.GetDrawableComponent(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(ISkinComponentLookup lookup)
{
switch (component)
switch (lookup)
{
case GameplaySkinComponent<HitResult> resultComponent:
case GameplaySkinComponentLookup<HitResult> resultComponent:
return getResult(resultComponent.Component);
case ManiaSkinComponent maniaComponent:
case ManiaSkinComponentLookup maniaComponent:
if (!isLegacySkin.Value || !hasKeyTexture.Value)
return null;
@ -120,11 +120,11 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
return new LegacyStageForeground();
default:
throw new UnsupportedSkinComponentException(component);
throw new UnsupportedSkinComponentException(lookup);
}
}
return base.GetDrawableComponent(component);
return base.GetDrawableComponent(lookup);
}
private Drawable getResult(HitResult result)

View File

@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Mania.UI
skin.SourceChanged += onSourceChanged;
onSourceChanged();
Drawable background = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
Drawable background = new SkinnableDrawable(new ManiaSkinComponentLookup(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
{
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
background.CreateProxy(),
HitObjectArea,
keyArea = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.KeyArea), _ => new DefaultKeyArea())
keyArea = new SkinnableDrawable(new ManiaSkinComponentLookup(ManiaSkinComponents.KeyArea), _ => new DefaultKeyArea())
{
RelativeSizeAxes = Axes.Both,
},

View File

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

View File

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

View File

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

View File

@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.Tests
RelativeSizeAxes = Axes.Both;
}
public Drawable GetDrawableComponent(ISkinComponent component) => null;
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => null;
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
{
public Drawable GetDrawableComponent(ISkinComponent component) => null;
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => null;
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null;
public ISample GetSample(ISampleInfo sampleInfo) => null;

View File

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

View File

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

View File

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

View File

@ -83,7 +83,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
Body = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderBody), _ => new DefaultSliderBody(), confineMode: ConfineMode.NoScaling),
Body = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.SliderBody), _ => new DefaultSliderBody(), confineMode: ConfineMode.NoScaling),
tailContainer = new Container<DrawableSliderTail> { RelativeSizeAxes = Axes.Both },
tickContainer = new Container<DrawableSliderTick> { 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[]
{
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderFollowCircle), _ => new DefaultFollowCircle())
new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.SliderFollowCircle), _ => new DefaultFollowCircle())
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
RelativeSizeAxes = Axes.Both,
Masking = true
},
ball = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderBall), _ => new DefaultSliderBall())
ball = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.SliderBall), _ => new DefaultSliderBall())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

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

View File

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

View File

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

View File

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

View File

@ -5,9 +5,9 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Osu
{
public class OsuSkinComponent : GameplaySkinComponent<OsuSkinComponents>
public class OsuSkinComponentLookup : GameplaySkinComponentLookup<OsuSkinComponents>
{
public OsuSkinComponent(OsuSkinComponents component)
public OsuSkinComponentLookup(OsuSkinComponents 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(ISkinComponentLookup lookup)
{
switch (component)
switch (lookup)
{
case GameplaySkinComponent<HitResult> resultComponent:
case GameplaySkinComponentLookup<HitResult> resultComponent:
return new ArgonJudgementPiece(resultComponent.Component);
case OsuSkinComponent osuComponent:
case OsuSkinComponentLookup osuComponent:
// TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries.
switch (osuComponent.Component)
{
@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
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);
}
protected override Drawable CreateDefault(ISkinComponent component)
protected override Drawable CreateDefault(ISkinComponentLookup 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.
// 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),
},
},
number = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
number = new SkinnableSpriteText(new OsuSkinComponentLookup(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
{
Font = OsuFont.Numeric.With(size: 40),
UseFullGlyphHeight = false,

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon
Child = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon
{
RelativeSizeAxes = Axes.Both,
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);
}
protected override Drawable CreateDefault(ISkinComponent component)
protected override Drawable CreateDefault(ISkinComponentLookup 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,
// 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)
{
OverlayLayer.Add(hitCircleText = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
OverlayLayer.Add(hitCircleText = new SkinnableSpriteText(new OsuSkinComponentLookup(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
{
Font = OsuFont.Numeric.With(size: 40),
UseFullGlyphHeight = false,

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
AutoSizeAxes = Axes.Both;
string lookupName = new OsuSkinComponent(OsuSkinComponents.ReverseArrow).LookupName;
string lookupName = new OsuSkinComponentLookup(OsuSkinComponents.ReverseArrow).LookupName;
var skin = skinSource.FindProvider(s => s.GetTexture(lookupName) != null);
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);
}
public override Drawable? GetDrawableComponent(ISkinComponent component)
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
if (component is OsuSkinComponent osuComponent)
if (lookup is OsuSkinComponentLookup osuComponent)
{
switch (osuComponent.Component)
{
case OsuSkinComponents.FollowPoint:
return this.GetAnimation(component.LookupName, true, true, true, startAtCurrentTime: false);
return this.GetAnimation("followpoint", true, true, true, startAtCurrentTime: false);
case OsuSkinComponents.SliderScorePoint:
return this.GetAnimation(component.LookupName, false, false);
return this.GetAnimation("sliderscorepoint", false, false);
case OsuSkinComponents.SliderFollowCircle:
var followCircleContent = this.GetAnimation("sliderfollowcircle", true, true, true);
@ -136,11 +136,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
return new LegacyApproachCircle();
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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -90,8 +90,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
}
protected override SkinnableDrawable CreateMainPiece() => HitObject.Type == HitType.Centre
? new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.CentreHit), _ => new CentreHitCirclePiece(), confineMode: ConfineMode.ScaleToFit)
: new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.RimHit), _ => new RimHitCirclePiece(), confineMode: ConfineMode.ScaleToFit);
? new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.CentreHit), _ => new CentreHitCirclePiece(), confineMode: ConfineMode.ScaleToFit)
: new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.RimHit), _ => new RimHitCirclePiece(), confineMode: ConfineMode.ScaleToFit);
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);
}
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Swell),
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Swell),
_ => new SwellCirclePiece
{
// 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;
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollTick),
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.DrumRollTick),
_ => new TickPiece());
}
}

View File

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

View File

@ -5,9 +5,9 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko
{
public class TaikoSkinComponent : GameplaySkinComponent<TaikoSkinComponents>
public class TaikoSkinComponentLookup : GameplaySkinComponentLookup<TaikoSkinComponents>
{
public TaikoSkinComponent(TaikoSkinComponents component)
public TaikoSkinComponentLookup(TaikoSkinComponents 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));
FrameStableComponents.Add(scroller = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Scroller), _ => Empty())
FrameStableComponents.Add(scroller = new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Scroller), _ => Empty())
{
RelativeSizeAxes = Axes.X,
Depth = float.MaxValue

View File

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

View File

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

View File

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

View File

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

View File

@ -126,7 +126,7 @@ namespace osu.Game.Tests.Gameplay
Color4.Green
};
public Drawable GetDrawableComponent(ISkinComponent component) => throw new NotImplementedException();
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => 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;
}
public Drawable GetDrawableComponent(ISkinComponent component) => throw new NotSupportedException();
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => throw new NotSupportedException();
public ISample GetSample(ISampleInfo sampleInfo) => 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();
}
public Drawable GetDrawableComponent(ISkinComponent component) => skin.GetDrawableComponent(component);
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => skin.GetTexture(componentName);

View File

@ -80,7 +80,7 @@ namespace osu.Game.Tests.Skins
var skin = new TestSkin(new SkinInfo(), null, storage);
Assert.That(skin.DrawableComponentInfo, Has.Count.EqualTo(2));
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents], Has.Length.EqualTo(9));
Assert.That(skin.DrawableComponentInfo[GlobalSkinComponentLookup.LookupType.MainHUDComponents], Has.Length.EqualTo(9));
}
}
@ -93,10 +93,10 @@ namespace osu.Game.Tests.Skins
var skin = new TestSkin(new SkinInfo(), null, storage);
Assert.That(skin.DrawableComponentInfo, Has.Count.EqualTo(2));
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents], Has.Length.EqualTo(6));
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.SongSelect], Has.Length.EqualTo(1));
Assert.That(skin.DrawableComponentInfo[GlobalSkinComponentLookup.LookupType.MainHUDComponents], Has.Length.EqualTo(6));
Assert.That(skin.DrawableComponentInfo[GlobalSkinComponentLookup.LookupType.SongSelect], Has.Length.EqualTo(1));
var skinnableInfo = skin.DrawableComponentInfo[SkinnableTarget.SongSelect].First();
var skinnableInfo = skin.DrawableComponentInfo[GlobalSkinComponentLookup.LookupType.SongSelect].First();
Assert.That(skinnableInfo.Type, Is.EqualTo(typeof(SkinnableSprite)));
Assert.That(skinnableInfo.Settings.First().Key, Is.EqualTo("sprite_name"));
@ -107,10 +107,10 @@ namespace osu.Game.Tests.Skins
using (var storage = new ZipArchiveReader(stream))
{
var skin = new TestSkin(new SkinInfo(), null, storage);
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents], Has.Length.EqualTo(8));
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(UnstableRateCounter)));
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(ColourHitErrorMeter)));
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(LegacySongProgress)));
Assert.That(skin.DrawableComponentInfo[GlobalSkinComponentLookup.LookupType.MainHUDComponents], Has.Length.EqualTo(8));
Assert.That(skin.DrawableComponentInfo[GlobalSkinComponentLookup.LookupType.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(UnstableRateCounter)));
Assert.That(skin.DrawableComponentInfo[GlobalSkinComponentLookup.LookupType.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(ColourHitErrorMeter)));
Assert.That(skin.DrawableComponentInfo[GlobalSkinComponentLookup.LookupType.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(LegacySongProgress)));
}
}

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Skins
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 TestSkinComponentLookup())?.Name == expected);
}
[TestCase(false)]
@ -59,7 +59,7 @@ namespace osu.Game.Tests.Skins
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 TestSkinComponentLookup()) != null) == expected());
}
public class UserSkinSource : LegacySkin
@ -69,7 +69,7 @@ namespace osu.Game.Tests.Skins
{
}
public override Drawable GetDrawableComponent(ISkinComponent component)
public override Drawable GetDrawableComponent(ISkinComponentLookup lookup)
{
return new Container { Name = "user" };
}
@ -82,7 +82,7 @@ namespace osu.Game.Tests.Skins
{
}
public override Drawable GetDrawableComponent(ISkinComponent component)
public override Drawable GetDrawableComponent(ISkinComponentLookup lookup)
{
return new Container { Name = "beatmap" };
}
@ -98,7 +98,7 @@ namespace osu.Game.Tests.Skins
this.skin = skin;
}
public Drawable GetDrawableComponent(ISkinComponent component) => skin.GetDrawableComponent(component);
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup);
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);
}
private class TestSkinComponent : ISkinComponent
private class TestSkinComponentLookup : ISkinComponentLookup
{
public string LookupName => string.Empty;
}

View File

@ -221,7 +221,7 @@ namespace osu.Game.Tests.Skins
this.skin = skin;
}
public Drawable GetDrawableComponent(ISkinComponent component) => skin.GetDrawableComponent(component);
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup);
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;
}
public Drawable GetDrawableComponent(ISkinComponent component) => throw new System.NotImplementedException();
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => throw new System.NotImplementedException();
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
{

View File

@ -40,7 +40,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
CreateSkinTest(TrianglesSkin.CreateInfo(), () => new LegacyBeatmapSkin(new BeatmapInfo(), null));
AddUntilStep("wait for hud load", () => Player.ChildrenOfType<SkinnableTargetContainer>().All(c => c.ComponentsLoaded));
AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(SkinnableTarget.MainHUDComponents, skinManager.CurrentSkin.Value));
AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(GlobalSkinComponentLookup.LookupType.MainHUDComponents, skinManager.CurrentSkin.Value));
}
protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func<ISkin> getBeatmapSkin)
@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual.Gameplay
});
}
protected bool AssertComponentsFromExpectedSource(SkinnableTarget target, ISkin expectedSource)
protected bool AssertComponentsFromExpectedSource(GlobalSkinComponentLookup.LookupType target, ISkin expectedSource)
{
var actualComponentsContainer = Player.ChildrenOfType<SkinnableTargetContainer>().First(s => s.Target == target)
.ChildrenOfType<SkinnableTargetComponentsContainer>().SingleOrDefault();
@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual.Gameplay
var actualInfo = actualComponentsContainer.CreateSkinnableInfo();
var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource.GetDrawableComponent(new SkinnableTargetComponent(target));
var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource.GetDrawableComponent(new GlobalSkinComponentLookup(target));
if (expectedComponentsContainer == null)
return false;

View File

@ -164,7 +164,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
private bool allow = true;
protected override bool AllowDrawableLookup(ISkinComponent component) => allow;
protected override bool AllowDrawableLookup(ISkinComponentLookup lookup) => allow;
public void Disable()
{
@ -182,8 +182,8 @@ namespace osu.Game.Tests.Visual.Gameplay
{
public new Drawable Drawable => base.Drawable;
public ExposedSkinnableDrawable(string name, Func<ISkinComponent, Drawable> defaultImplementation, ConfineMode confineMode = ConfineMode.ScaleToFit)
: base(new TestSkinComponent(name), defaultImplementation, confineMode)
public ExposedSkinnableDrawable(string name, Func<ISkinComponentLookup, Drawable> defaultImplementation, ConfineMode confineMode = ConfineMode.ScaleToFit)
: base(new TestSkinComponentLookup(name), defaultImplementation, confineMode)
{
}
}
@ -251,8 +251,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public new Drawable Drawable => base.Drawable;
public int SkinChangedCount { get; private set; }
public SkinConsumer(string name, Func<ISkinComponent, Drawable> defaultImplementation)
: base(new TestSkinComponent(name), defaultImplementation)
public SkinConsumer(string name, Func<ISkinComponentLookup, Drawable> defaultImplementation)
: base(new TestSkinComponentLookup(name), defaultImplementation)
{
}
@ -288,8 +288,8 @@ namespace osu.Game.Tests.Visual.Gameplay
this.size = size;
}
public Drawable GetDrawableComponent(ISkinComponent componentName) =>
componentName.LookupName == "available"
public Drawable GetDrawableComponent(ISkinComponentLookup componentLookupName) =>
(componentLookupName as TestSkinComponentLookup)?.LookupName == "available"
? new DrawWidthBox
{
Colour = Color4.Yellow,
@ -306,7 +306,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private class SecondarySource : ISkin
{
public Drawable GetDrawableComponent(ISkinComponent componentName) => new SecondarySourceBox();
public Drawable GetDrawableComponent(ISkinComponentLookup componentLookupName) => new SecondarySourceBox();
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))]
private class SkinSourceContainer : Container, ISkinSource
{
public Drawable GetDrawableComponent(ISkinComponent componentName) => new BaseSourceBox();
public Drawable GetDrawableComponent(ISkinComponentLookup componentLookupName) => new BaseSourceBox();
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 TestSkinComponentLookup : ISkinComponentLookup
{
public TestSkinComponent(string name)
public TestSkinComponentLookup(string name)
{
LookupName = name;
}

View File

@ -142,7 +142,7 @@ namespace osu.Game.Tests.Visual.Gameplay
IBindable<bool> ISamplePlaybackDisabler.SamplePlaybackDisabled => SamplePlaybackDisabled;
public Drawable GetDrawableComponent(ISkinComponent component) => source?.GetDrawableComponent(component);
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => source?.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source?.GetTexture(componentName, wrapModeS, wrapModeT);
public ISample GetSample(ISampleInfo sampleInfo) => source?.GetSample(sampleInfo);
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)
RemoveInternal(JudgementBody, true);
AddInternal(JudgementBody = new SkinnableDrawable(new GameplaySkinComponent<HitResult>(type), _ =>
AddInternal(JudgementBody = new SkinnableDrawable(new GameplaySkinComponentLookup<HitResult>(type), _ =>
CreateDefaultJudgement(type), confineMode: ConfineMode.NoScaling)
{
Anchor = Anchor.Centre,

View File

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

View File

@ -391,7 +391,7 @@ namespace osu.Game.Screens.Play
private OsuConfigManager config { get; set; }
public MainComponentsContainer()
: base(SkinnableTarget.MainHUDComponents)
: base(GlobalSkinComponentLookup.LookupType.MainHUDComponents)
{
RelativeSizeAxes = Axes.Both;
}

View File

@ -250,7 +250,7 @@ namespace osu.Game.Screens.Select
}
}
},
new SkinnableTargetContainer(SkinnableTarget.SongSelect)
new SkinnableTargetContainer(GlobalSkinComponentLookup.LookupType.SongSelect)
{
RelativeSizeAxes = Axes.Both,
},

View File

@ -7,7 +7,6 @@ using JetBrains.Annotations;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Beatmaps.Formats;
@ -81,17 +80,27 @@ namespace osu.Game.Skinning
return null;
}
public override Drawable? GetDrawableComponent(ISkinComponent component)
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
if (base.GetDrawableComponent(component) is Drawable c)
if (base.GetDrawableComponent(lookup) is Drawable c)
return c;
switch (component)
switch (lookup)
{
case SkinnableTargetComponent target:
switch (target.Target)
case SkinnableSprite.SpriteComponentLookup spriteLookup:
switch (spriteLookup.LookupName)
{
case SkinnableTarget.SongSelect:
// Temporary until default skin has a valid hit lighting.
case @"lighting":
return Drawable.Empty();
}
break;
case GlobalSkinComponentLookup globalLookup:
switch (globalLookup.Lookup)
{
case GlobalSkinComponentLookup.LookupType.SongSelect:
var songSelectComponents = new SkinnableTargetComponentsContainer(_ =>
{
// do stuff when we need to.
@ -99,7 +108,7 @@ namespace osu.Game.Skinning
return songSelectComponents;
case SkinnableTarget.MainHUDComponents:
case GlobalSkinComponentLookup.LookupType.MainHUDComponents:
var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
{
var score = container.OfType<DefaultScoreCounter>().FirstOrDefault();
@ -178,16 +187,6 @@ namespace osu.Game.Skinning
return null;
}
switch (component.LookupName)
{
// Temporary until default skin has a valid hit lighting.
case @"lighting":
return Drawable.Empty();
}
if (GetTexture(component.LookupName) is Texture t)
return new Sprite { Texture = t };
return null;
}

View File

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

View File

@ -314,7 +314,7 @@ namespace osu.Game.Skinning.Editor
private ISkinnableTarget getFirstTarget() => availableTargets.FirstOrDefault();
private ISkinnableTarget getTarget(SkinnableTarget target)
private ISkinnableTarget getTarget(GlobalSkinComponentLookup.LookupType target)
{
return availableTargets.FirstOrDefault(c => c.Target == target);
}

View File

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

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
{
public class GlobalSkinComponentLookup : ISkinComponentLookup
{
public readonly LookupType Lookup;
public GlobalSkinComponentLookup(LookupType lookup)
{
Lookup = lookup;
}
public enum LookupType
{
MainHUDComponents,
SongSelect
}
}
}

View File

@ -17,9 +17,9 @@ namespace osu.Game.Skinning
/// <summary>
/// Retrieve a <see cref="Drawable"/> component implementation.
/// </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>
Drawable? GetDrawableComponent(ISkinComponent component);
Drawable? GetDrawableComponent(ISkinComponentLookup lookup);
/// <summary>
/// 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,20 @@
// 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="GameplaySkinComponentLookup{T}"/> to do a simple lookup based on
/// a provided enum.
/// </remarks>
public interface ISkinComponentLookup
{
}
}

View File

@ -5,12 +5,17 @@ using System;
using osu.Framework.Bindables;
using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Graphics;
using osu.Game.Configuration;
namespace osu.Game.Skinning
{
/// <summary>
/// Denotes a drawable which, as a drawable, can be adjusted via skinning specifications.
/// </summary>
/// <remarks>
/// Attaching this interface to any <see cref="IDrawable"/> will make it serialisable to skin settings.
/// Adding <see cref="SettingSourceAttribute"/> annotated bindables will also serialise these settings alongside each instance.
/// </remarks>
public interface ISkinnableDrawable : IDrawable
{
/// <summary>

View File

@ -18,7 +18,7 @@ namespace osu.Game.Skinning
/// <summary>
/// The definition of this target.
/// </summary>
SkinnableTarget Target { get; }
GlobalSkinComponentLookup.LookupType Target { get; }
/// <summary>
/// A bindable list of components which are being tracked by this skinnable target.

View File

@ -43,13 +43,13 @@ namespace osu.Game.Skinning
return new RealmBackedResourceStore<BeatmapSetInfo>(beatmapInfo.BeatmapSet.ToLive(resources.RealmAccess), resources.Files, resources.RealmAccess);
}
public override Drawable? GetDrawableComponent(ISkinComponent component)
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
if (component is SkinnableTargetComponent targetComponent)
if (lookup is GlobalSkinComponentLookup targetComponent)
{
switch (targetComponent.Target)
switch (targetComponent.Lookup)
{
case SkinnableTarget.MainHUDComponents:
case GlobalSkinComponentLookup.LookupType.MainHUDComponents:
// this should exist in LegacySkin instead, but there isn't a fallback skin for LegacySkins yet.
// therefore keep the check here until fallback default legacy skin is supported.
if (!this.HasFont(LegacyFont.Score))
@ -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)

View File

@ -322,17 +322,17 @@ namespace osu.Game.Skinning
return null;
}
public override Drawable? GetDrawableComponent(ISkinComponent component)
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
if (base.GetDrawableComponent(component) is Drawable c)
if (base.GetDrawableComponent(lookup) is Drawable c)
return c;
switch (component)
switch (lookup)
{
case SkinnableTargetComponent target:
switch (target.Target)
case GlobalSkinComponentLookup target:
switch (target.Lookup)
{
case SkinnableTarget.MainHUDComponents:
case GlobalSkinComponentLookup.LookupType.MainHUDComponents:
var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
{
var score = container.OfType<LegacyScoreCounter>().FirstOrDefault();
@ -379,7 +379,7 @@ namespace osu.Game.Skinning
return null;
case GameplaySkinComponent<HitResult> resultComponent:
case GameplaySkinComponentLookup<HitResult> resultComponent:
// kind of wasteful that we throw this away, but should do for now.
if (getJudgementAnimation(resultComponent.Component) != null)
@ -397,7 +397,7 @@ namespace osu.Game.Skinning
return null;
case SkinnableSprite.SpriteComponent sprite:
case SkinnableSprite.SpriteComponentLookup sprite:
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"));
}
public Drawable? GetDrawableComponent(ISkinComponent component) => null;
public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => null;
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => textures.Get(componentName, wrapModeS, wrapModeT);

View File

@ -37,9 +37,9 @@ namespace osu.Game.Skinning
public SkinConfiguration Configuration { get; set; }
public IDictionary<SkinnableTarget, SkinnableInfo[]> DrawableComponentInfo => drawableComponentInfo;
public IDictionary<GlobalSkinComponentLookup.LookupType, SkinnableInfo[]> DrawableComponentInfo => drawableComponentInfo;
private readonly Dictionary<SkinnableTarget, SkinnableInfo[]> drawableComponentInfo = new Dictionary<SkinnableTarget, SkinnableInfo[]>();
private readonly Dictionary<GlobalSkinComponentLookup.LookupType, SkinnableInfo[]> drawableComponentInfo = new Dictionary<GlobalSkinComponentLookup.LookupType, SkinnableInfo[]>();
public abstract ISample? GetSample(ISampleInfo sampleInfo);
@ -97,7 +97,7 @@ namespace osu.Game.Skinning
Configuration = new SkinConfiguration();
// skininfo files may be null for default skin.
foreach (SkinnableTarget skinnableTarget in Enum.GetValues(typeof(SkinnableTarget)))
foreach (GlobalSkinComponentLookup.LookupType skinnableTarget in Enum.GetValues(typeof(GlobalSkinComponentLookup.LookupType)))
{
string filename = $"{skinnableTarget}.json";
@ -154,12 +154,12 @@ namespace osu.Game.Skinning
DrawableComponentInfo[targetContainer.Target] = targetContainer.CreateSkinnableInfo().ToArray();
}
public virtual Drawable? GetDrawableComponent(ISkinComponent component)
public virtual Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
switch (component)
switch (lookup)
{
case SkinnableTargetComponent target:
if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo))
case GlobalSkinComponentLookup target:
if (!DrawableComponentInfo.TryGetValue(target.Lookup, out var skinnableInfo))
return null;
var components = new List<Drawable>();

View File

@ -201,7 +201,7 @@ namespace osu.Game.Skinning
public event Action SourceChanged;
public Drawable GetDrawableComponent(ISkinComponent component) => lookupWithFallback(s => s.GetDrawableComponent(component));
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => lookupWithFallback(s => s.GetDrawableComponent(lookup));
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>
protected virtual bool AllowFallingBackToParent => true;
protected virtual bool AllowDrawableLookup(ISkinComponent component) => true;
protected virtual bool AllowDrawableLookup(ISkinComponentLookup lookup) => true;
protected virtual bool AllowTextureLookup(string componentName) => true;
@ -107,19 +107,19 @@ namespace osu.Game.Skinning
}
}
public Drawable? GetDrawableComponent(ISkinComponent component)
public Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
foreach (var (_, lookupWrapper) in skinSources)
{
Drawable? sourceDrawable;
if ((sourceDrawable = lookupWrapper.GetDrawableComponent(component)) != null)
if ((sourceDrawable = lookupWrapper.GetDrawableComponent(lookup)) != null)
return sourceDrawable;
}
if (!AllowFallingBackToParent)
return null;
return ParentSource?.GetDrawableComponent(component);
return ParentSource?.GetDrawableComponent(lookup);
}
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
@ -238,10 +238,10 @@ namespace osu.Game.Skinning
this.provider = provider;
}
public Drawable? GetDrawableComponent(ISkinComponent component)
public Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
if (provider.AllowDrawableLookup(component))
return skin.GetDrawableComponent(component);
if (provider.AllowDrawableLookup(lookup))
return skin.GetDrawableComponent(lookup);
return null;
}

View File

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

View File

@ -31,25 +31,25 @@ namespace osu.Game.Skinning
set => base.AutoSizeAxes = value;
}
protected readonly ISkinComponent Component;
protected readonly ISkinComponentLookup ComponentLookup;
private readonly ConfineMode confineMode;
/// <summary>
/// Create a new skinnable drawable.
/// </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="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)
: this(component, confineMode)
public SkinnableDrawable(ISkinComponentLookup lookup, Func<ISkinComponentLookup, Drawable>? defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
: this(lookup, confineMode)
{
createDefault = defaultImplementation;
}
protected SkinnableDrawable(ISkinComponent component, ConfineMode confineMode = ConfineMode.NoScaling)
protected SkinnableDrawable(ISkinComponentLookup lookup, ConfineMode confineMode = ConfineMode.NoScaling)
{
Component = component;
ComponentLookup = lookup;
this.confineMode = confineMode;
RelativeSizeAxes = Axes.Both;
@ -60,13 +60,13 @@ namespace osu.Game.Skinning
/// </summary>
public void ResetAnimation() => (Drawable as IFramedAnimation)?.GotoFrame(0);
private readonly Func<ISkinComponent, Drawable>? createDefault;
private readonly Func<ISkinComponentLookup, Drawable>? createDefault;
private readonly Cached scaling = new Cached();
private bool isDefault;
protected virtual Drawable CreateDefault(ISkinComponent component) => createDefault?.Invoke(component) ?? Empty();
protected virtual Drawable CreateDefault(ISkinComponentLookup lookup) => createDefault?.Invoke(lookup) ?? Empty();
/// <summary>
/// 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)
{
var retrieved = skin.GetDrawableComponent(Component);
var retrieved = skin.GetDrawableComponent(ComponentLookup);
if (retrieved == null)
{
Drawable = CreateDefault(Component);
Drawable = CreateDefault(ComponentLookup);
isDefault = true;
}
else

View File

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

View File

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

View File

@ -1,11 +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 enum SkinnableTarget
{
MainHUDComponents,
SongSelect
}
}

View File

@ -1,17 +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 class SkinnableTargetComponent : ISkinComponent
{
public readonly SkinnableTarget Target;
public string LookupName => Target.ToString();
public SkinnableTargetComponent(SkinnableTarget target)
{
Target = target;
}
}
}

View File

@ -13,7 +13,7 @@ namespace osu.Game.Skinning
{
private SkinnableTargetComponentsContainer? content;
public SkinnableTarget Target { get; }
public GlobalSkinComponentLookup.LookupType Target { get; }
public IBindableList<ISkinnableDrawable> Components => components;
@ -25,7 +25,7 @@ namespace osu.Game.Skinning
private CancellationTokenSource? cancellationSource;
public SkinnableTargetContainer(SkinnableTarget target)
public SkinnableTargetContainer(GlobalSkinComponentLookup.LookupType target)
{
Target = target;
}
@ -39,7 +39,7 @@ namespace osu.Game.Skinning
components.Clear();
ComponentsLoaded = false;
content = CurrentSkin.GetDrawableComponent(new SkinnableTargetComponent(Target)) as SkinnableTargetComponentsContainer;
content = CurrentSkin.GetDrawableComponent(new GlobalSkinComponentLookup(Target)) as SkinnableTargetComponentsContainer;
cancellationSource?.Cancel();
cancellationSource = null;

View File

@ -7,7 +7,6 @@ using JetBrains.Annotations;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Beatmaps.Formats;
@ -59,17 +58,27 @@ namespace osu.Game.Skinning
return null;
}
public override Drawable? GetDrawableComponent(ISkinComponent component)
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
if (base.GetDrawableComponent(component) is Drawable c)
if (base.GetDrawableComponent(lookup) is Drawable c)
return c;
switch (component)
switch (lookup)
{
case SkinnableTargetComponent target:
switch (target.Target)
case SkinnableSprite.SpriteComponentLookup spriteLookup:
switch (spriteLookup.LookupName)
{
case SkinnableTarget.SongSelect:
// Temporary until default skin has a valid hit lighting.
case @"lighting":
return Drawable.Empty();
}
break;
case GlobalSkinComponentLookup target:
switch (target.Lookup)
{
case GlobalSkinComponentLookup.LookupType.SongSelect:
var songSelectComponents = new SkinnableTargetComponentsContainer(_ =>
{
// do stuff when we need to.
@ -77,7 +86,7 @@ namespace osu.Game.Skinning
return songSelectComponents;
case SkinnableTarget.MainHUDComponents:
case GlobalSkinComponentLookup.LookupType.MainHUDComponents:
var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
{
var score = container.OfType<DefaultScoreCounter>().FirstOrDefault();
@ -156,16 +165,6 @@ namespace osu.Game.Skinning
return null;
}
switch (component.LookupName)
{
// Temporary until default skin has a valid hit lighting.
case @"lighting":
return Drawable.Empty();
}
if (GetTexture(component.LookupName) is Texture t)
return new Sprite { Texture = t };
return null;
}

View File

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