mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:03:13 +08:00
Rename ISkinComponent
to ISkinLookup
This commit is contained in:
parent
ab458320c4
commit
c908969d9b
@ -5,9 +5,9 @@ using osu.Game.Skinning;
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
@ -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<ISkinLookup, Drawable> defaultImplementation)
|
||||
: base(new CatchSkinLookup(skinComponent), defaultImplementation)
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
private void load()
|
||||
{
|
||||
ScalingContainer.Child = new SkinnableDrawable(
|
||||
new CatchSkinComponent(CatchSkinComponents.Banana),
|
||||
new CatchSkinLookup(CatchSkinComponents.Banana),
|
||||
_ => new BananaPiece());
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
private void load()
|
||||
{
|
||||
ScalingContainer.Child = new SkinnableDrawable(
|
||||
new CatchSkinComponent(CatchSkinComponents.Droplet),
|
||||
new CatchSkinLookup(CatchSkinComponents.Droplet),
|
||||
_ => new DropletPiece());
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
private void load()
|
||||
{
|
||||
ScalingContainer.Child = new SkinnableDrawable(
|
||||
new CatchSkinComponent(CatchSkinComponents.Fruit),
|
||||
new CatchSkinLookup(CatchSkinComponents.Fruit),
|
||||
_ => new FruitPiece());
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
switch (catchComponent.Component)
|
||||
{
|
||||
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Argon
|
||||
break;
|
||||
}
|
||||
|
||||
return base.GetDrawableComponent(component);
|
||||
return base.GetDrawableComponent(lookup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
case SkinnableTarget.MainHUDComponents:
|
||||
var components = base.GetDrawableComponent(component) as SkinnableTargetComponentsContainer;
|
||||
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 CatchSkinLookup 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 CatchSkinLookup(CatchSkinComponents.Catcher)) != null)
|
||||
return (IBindable<TValue>)new Bindable<bool>();
|
||||
|
||||
break;
|
||||
|
@ -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 CatchSkinLookup(CatchSkinComponents.CatchComboCounter), _ => Empty())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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 CatchSkinLookup(CatchSkinComponents.HitExplosion), _ => new DefaultHitExplosion())
|
||||
{
|
||||
CentreComponent = false,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
|
@ -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 CatchSkinLookup(CatchSkinComponents.Catcher), _ => new DefaultCatcher())
|
||||
{
|
||||
Anchor = Anchor.TopCentre;
|
||||
// Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling.
|
||||
|
@ -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 ManiaSkinLookup(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 ManiaSkinLookup(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
|
@ -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 ManiaSkinLookup(ManiaSkinComponents.StageBackground),
|
||||
_ => new DefaultStageBackground())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
|
@ -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 ManiaSkinLookup(ManiaSkinComponents.StageForeground), _ => null)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -5,13 +5,13 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania
|
||||
{
|
||||
public class ManiaSkinComponent : GameplaySkinComponent<ManiaSkinComponents>
|
||||
public class ManiaSkinLookup : GameplaySkinLookup<ManiaSkinComponents>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ManiaSkinComponent"/>.
|
||||
/// Creates a new <see cref="ManiaSkinLookup"/>.
|
||||
/// </summary>
|
||||
/// <param name="component">The component.</param>
|
||||
public ManiaSkinComponent(ManiaSkinComponents component)
|
||||
public ManiaSkinLookup(ManiaSkinComponents component)
|
||||
: base(component)
|
||||
{
|
||||
}
|
@ -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 ManiaSkinLookup(ManiaSkinComponents.HoldNoteBody), _ => new DefaultBodyPiece
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
})
|
||||
|
@ -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 ManiaSkinLookup(Component), _ => new DefaultNotePiece())
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y
|
||||
|
@ -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(ISkinLookup lookup)
|
||||
{
|
||||
switch (component)
|
||||
switch (lookup)
|
||||
{
|
||||
case GameplaySkinComponent<HitResult> resultComponent:
|
||||
case GameplaySkinLookup<HitResult> resultComponent:
|
||||
return new ArgonJudgementPiece(resultComponent.Component);
|
||||
|
||||
case ManiaSkinComponent maniaComponent:
|
||||
case ManiaSkinLookup 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)
|
||||
|
@ -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);
|
||||
|
||||
case ManiaSkinComponent maniaComponent:
|
||||
case ManiaSkinLookup 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)
|
||||
|
@ -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 ManiaSkinLookup(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 ManiaSkinLookup(ManiaSkinComponents.KeyArea), _ => new DefaultKeyArea())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
|
@ -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 ManiaSkinLookup(ManiaSkinComponents.HitTarget), _ => new DefaultHitTarget())
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Depth = 1
|
||||
|
@ -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 ManiaSkinLookup(ManiaSkinComponents.HitExplosion), _ => new DefaultHitExplosion())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
};
|
||||
|
@ -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 ManiaSkinLookup(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 ManiaSkinLookup(ManiaSkinComponents.StageForeground), _ => null)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
|
@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent component) => null;
|
||||
public Drawable GetDrawableComponent(ISkinLookup lookup) => null;
|
||||
|
||||
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
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 ISample GetSample(ISampleInfo sampleInfo) => null;
|
||||
|
||||
|
@ -149,11 +149,11 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
||||
public Drawable GetDrawableComponent(ISkinLookup lookup)
|
||||
{
|
||||
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 new OsuSpriteText
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.FollowPoint), _ => new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
|
@ -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 OsuSkinLookup(CirclePieceComponent), _ => new MainCirclePiece())
|
||||
{
|
||||
Anchor = 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,
|
||||
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(ISkinLookup lookup, Func<ISkinLookup, Drawable> defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||
: base(lookup, defaultImplementation, confineMode)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -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 OsuSkinLookup(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 },
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderFollowCircle), _ => new DefaultFollowCircle())
|
||||
new SkinnableDrawable(new OsuSkinLookup(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 OsuSkinLookup(OsuSkinComponents.SliderBall), _ => new DefaultSliderBall())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.SliderTailHitCircle), _ => Empty())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.SliderTailHitCircle), _ => Empty())
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.SliderScorePoint), _ => new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinner()),
|
||||
RotationTracker = new SpinnerRotationTracker(this)
|
||||
}
|
||||
},
|
||||
|
@ -5,9 +5,9 @@ using osu.Game.Skinning;
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
@ -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);
|
||||
|
||||
case OsuSkinComponent osuComponent:
|
||||
case OsuSkinLookup 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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(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.
|
||||
// See LegacyApproachCircle for documentation as to why this is required.
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Numeric.With(size: 40),
|
||||
UseFullGlyphHeight = false,
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Blending = BlendingParameters.Additive,
|
||||
|
@ -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(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,
|
||||
// when hitcircles have 5px padding on each size. this should be removed if we update the sprite.
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Numeric.With(size: 40),
|
||||
UseFullGlyphHeight = false,
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
{
|
||||
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);
|
||||
InternalChild = skin?.GetAnimation(lookupName, true, true) ?? Empty();
|
||||
|
@ -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(ISkinLookup lookup)
|
||||
{
|
||||
if (component is OsuSkinComponent osuComponent)
|
||||
if (lookup is OsuSkinLookup osuComponent)
|
||||
{
|
||||
switch (osuComponent.Component)
|
||||
{
|
||||
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:
|
||||
return this.GetAnimation(component.LookupName, false, false);
|
||||
return this.GetAnimation(lookup.LookupName, 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)
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
|
@ -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 OsuSkinLookup(OsuSkinComponents.CursorTrail), _ => new DefaultCursorTrail(), confineMode: ConfineMode.NoScaling),
|
||||
new SkinnableDrawable(new OsuSkinLookup(OsuSkinComponents.CursorParticles), confineMode: ConfineMode.NoScaling),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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 OsuSkinLookup(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(ISkinLookup lookup, Func<ISkinLookup, Drawable>? defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||
: base(lookup, defaultImplementation, confineMode)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -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 TaikoSkinLookup(TaikoSkinComponents.Scroller), _ => Empty())
|
||||
{
|
||||
Clock = new FramedClock(clock),
|
||||
Height = 0.4f,
|
||||
|
@ -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 TaikoSkinLookup(TaikoSkinComponents.BarLine), _ => new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
EdgeSmoothness = new Vector2(0.5f, 0),
|
||||
|
@ -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 TaikoSkinLookup(TaikoSkinComponents.DrumRollBody),
|
||||
_ => new ElongatedCirclePiece());
|
||||
|
||||
public override bool OnPressed(KeyBindingPressEvent<TaikoAction> e) => false;
|
||||
|
@ -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 TaikoSkinLookup(TaikoSkinComponents.DrumRollTick),
|
||||
_ => new TickPiece
|
||||
{
|
||||
Filled = HitObject.FirstTick
|
||||
|
@ -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 TaikoSkinLookup(TaikoSkinComponents.CentreHit), _ => new CentreHitCirclePiece(), confineMode: ConfineMode.ScaleToFit)
|
||||
: new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.RimHit), _ => new RimHitCirclePiece(), confineMode: ConfineMode.ScaleToFit);
|
||||
|
||||
public override IEnumerable<HitSampleInfo> GetSamples()
|
||||
{
|
||||
|
@ -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 TaikoSkinLookup(TaikoSkinComponents.Swell),
|
||||
_ => new SwellCirclePiece
|
||||
{
|
||||
// to allow for rotation transform
|
||||
|
@ -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 TaikoSkinLookup(TaikoSkinComponents.DrumRollTick),
|
||||
_ => new TickPiece());
|
||||
}
|
||||
}
|
||||
|
@ -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(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 (hasExplosion.Value)
|
||||
return Drawable.Empty().With(d => d.Expire());
|
||||
}
|
||||
|
||||
if (component is TaikoSkinComponent taikoComponent)
|
||||
if (lookup is TaikoSkinLookup 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)
|
||||
|
@ -5,9 +5,9 @@ using osu.Game.Skinning;
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
@ -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 TaikoSkinLookup(TaikoSkinComponents.Scroller), _ => Empty())
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Depth = float.MaxValue
|
||||
|
@ -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 TaikoSkinLookup(getComponentName(result)), _ => new DefaultHitExplosion(result));
|
||||
skinnable.OnSkinChanged += runAnimation;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.InputDrum), _ => new DefaultInputDrum())
|
||||
new SkinnableDrawable(new TaikoSkinLookup(TaikoSkinComponents.InputDrum), _ => new DefaultInputDrum())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
|
@ -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 TaikoSkinLookup(TaikoSkinComponents.TaikoExplosionKiai), _ => new DefaultKiaiHitExplosion(hitType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundRight), _ => new PlayfieldBackgroundRight()),
|
||||
new SkinnableDrawable(new TaikoSkinLookup(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 TaikoSkinLookup(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
||||
inputDrum.CreateProxy(),
|
||||
}
|
||||
},
|
||||
mascot = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Mascot), _ => Empty())
|
||||
mascot = new SkinnableDrawable(new TaikoSkinLookup(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 TaikoSkinLookup(TaikoSkinComponents.HitTarget), _ => new TaikoHitTarget())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
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();
|
||||
|
||||
|
@ -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(ISkinLookup lookup) => throw new NotSupportedException();
|
||||
public ISample GetSample(ISampleInfo sampleInfo) => throw new NotSupportedException();
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotSupportedException();
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Tests.Rulesets
|
||||
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);
|
||||
|
||||
|
@ -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 TestSkinLookup())?.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 TestSkinLookup()) != 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(ISkinLookup 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(ISkinLookup 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(ISkinLookup 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 TestSkinLookup : ISkinLookup
|
||||
{
|
||||
public string LookupName => string.Empty;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ namespace osu.Game.Tests.Skins
|
||||
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);
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Tests.Skins
|
||||
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)
|
||||
{
|
||||
|
@ -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 SkinnableTargetLookup(target));
|
||||
if (expectedComponentsContainer == null)
|
||||
return false;
|
||||
|
||||
|
@ -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(ISkinLookup 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<ISkinLookup, Drawable> defaultImplementation, ConfineMode confineMode = ConfineMode.ScaleToFit)
|
||||
: base(new TestSkinLookup(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<ISkinLookup, Drawable> defaultImplementation)
|
||||
: base(new TestSkinLookup(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(ISkinLookup lookupName) =>
|
||||
lookupName.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(ISkinLookup lookupName) => 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(ISkinLookup lookupName) => 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 TestSkinLookup : ISkinLookup
|
||||
{
|
||||
public TestSkinComponent(string name)
|
||||
public TestSkinLookup(string name)
|
||||
{
|
||||
LookupName = name;
|
||||
}
|
||||
|
@ -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(ISkinLookup 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);
|
||||
|
@ -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 GameplaySkinLookup<HitResult>(type), _ =>
|
||||
CreateDefaultJudgement(type), confineMode: ConfineMode.NoScaling)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
#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 ISample GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo);
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Skin.GetConfig<TLookup, TValue>(lookup);
|
||||
|
@ -81,14 +81,14 @@ namespace osu.Game.Skinning
|
||||
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;
|
||||
|
||||
switch (component)
|
||||
switch (lookup)
|
||||
{
|
||||
case SkinnableTargetComponent target:
|
||||
case SkinnableTargetLookup target:
|
||||
switch (target.Target)
|
||||
{
|
||||
case SkinnableTarget.SongSelect:
|
||||
@ -178,14 +178,14 @@ namespace osu.Game.Skinning
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (component.LookupName)
|
||||
switch (lookup.LookupName)
|
||||
{
|
||||
// Temporary until default skin has a valid hit lighting.
|
||||
case @"lighting":
|
||||
return Drawable.Empty();
|
||||
}
|
||||
|
||||
if (GetTexture(component.LookupName) is Texture t)
|
||||
if (GetTexture(lookup.LookupName) is Texture t)
|
||||
return new Sprite { Texture = t };
|
||||
|
||||
return null;
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Skinning
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowDrawableLookup(ISkinComponent component)
|
||||
protected override bool AllowDrawableLookup(ISkinLookup lookup)
|
||||
{
|
||||
if (beatmapSkins == null)
|
||||
throw new InvalidOperationException($"{nameof(BeatmapSkinProvidingContainer)} needs to be loaded before being consumed.");
|
||||
|
@ -5,12 +5,12 @@ using System.Linq;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class GameplaySkinComponent<T> : ISkinComponent
|
||||
public class GameplaySkinLookup<T> : ISkinLookup
|
||||
where T : notnull
|
||||
{
|
||||
public readonly T Component;
|
||||
|
||||
public GameplaySkinComponent(T component)
|
||||
public GameplaySkinLookup(T component)
|
||||
{
|
||||
Component = component;
|
||||
}
|
@ -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(ISkinLookup lookup);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a <see cref="Texture"/>.
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
21
osu.Game/Skinning/ISkinLookup.cs
Normal file
21
osu.Game/Skinning/ISkinLookup.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -43,9 +43,9 @@ 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(ISkinLookup lookup)
|
||||
{
|
||||
if (component is SkinnableTargetComponent targetComponent)
|
||||
if (lookup is SkinnableTargetLookup targetComponent)
|
||||
{
|
||||
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)
|
||||
|
@ -322,14 +322,14 @@ namespace osu.Game.Skinning
|
||||
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;
|
||||
|
||||
switch (component)
|
||||
switch (lookup)
|
||||
{
|
||||
case SkinnableTargetComponent target:
|
||||
case SkinnableTargetLookup target:
|
||||
switch (target.Target)
|
||||
{
|
||||
case SkinnableTarget.MainHUDComponents:
|
||||
@ -379,7 +379,7 @@ namespace osu.Game.Skinning
|
||||
|
||||
return null;
|
||||
|
||||
case GameplaySkinComponent<HitResult> resultComponent:
|
||||
case GameplaySkinLookup<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.SpriteLookup sprite:
|
||||
return this.GetAnimation(sprite.LookupName, false, false);
|
||||
}
|
||||
|
||||
|
@ -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(ISkinLookup lookup) => null;
|
||||
|
||||
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => textures.Get(componentName, wrapModeS, wrapModeT);
|
||||
|
||||
|
@ -154,11 +154,11 @@ namespace osu.Game.Skinning
|
||||
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))
|
||||
return null;
|
||||
|
||||
|
@ -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(ISkinLookup lookup) => lookupWithFallback(s => s.GetDrawableComponent(lookup));
|
||||
|
||||
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => lookupWithFallback(s => s.GetTexture(componentName, wrapModeS, wrapModeT));
|
||||
|
||||
|
@ -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(ISkinLookup 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(ISkinLookup 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(ISkinLookup lookup)
|
||||
{
|
||||
if (provider.AllowDrawableLookup(component))
|
||||
return skin.GetDrawableComponent(component);
|
||||
if (provider.AllowDrawableLookup(lookup))
|
||||
return skin.GetDrawableComponent(lookup);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -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(ISkinLookup lookup) => Skin.GetDrawableComponent(lookup);
|
||||
|
||||
public virtual Texture? GetTexture(string componentName) => GetTexture(componentName, default, default);
|
||||
|
||||
|
@ -31,25 +31,25 @@ namespace osu.Game.Skinning
|
||||
set => base.AutoSizeAxes = value;
|
||||
}
|
||||
|
||||
protected readonly ISkinComponent Component;
|
||||
protected readonly ISkinLookup Lookup;
|
||||
|
||||
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(ISkinLookup lookup, Func<ISkinLookup, Drawable>? defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||
: this(lookup, confineMode)
|
||||
{
|
||||
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;
|
||||
|
||||
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<ISkinLookup, 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(ISkinLookup 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(Lookup);
|
||||
|
||||
if (retrieved == null)
|
||||
{
|
||||
Drawable = CreateDefault(Component);
|
||||
Drawable = CreateDefault(Lookup);
|
||||
isDefault = true;
|
||||
}
|
||||
else
|
||||
|
@ -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 SpriteLookup(textureName), confineMode)
|
||||
{
|
||||
SpriteName.Value = textureName;
|
||||
}
|
||||
|
||||
public SkinnableSprite()
|
||||
: base(new SpriteComponent(string.Empty), ConfineMode.NoScaling)
|
||||
: base(new SpriteLookup(string.Empty), ConfineMode.NoScaling)
|
||||
{
|
||||
RelativeSizeAxes = Axes.None;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
SpriteName.BindValueChanged(name =>
|
||||
{
|
||||
((SpriteComponent)Component).LookupName = name.NewValue ?? string.Empty;
|
||||
((SpriteLookup)Lookup).LookupName = name.NewValue ?? string.Empty;
|
||||
if (IsLoaded)
|
||||
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)
|
||||
return new SpriteNotFound(component.LookupName);
|
||||
return new SpriteNotFound(lookup.LookupName);
|
||||
|
||||
return new Sprite { Texture = texture };
|
||||
}
|
||||
|
||||
public bool UsesFixedAnchor { get; set; }
|
||||
|
||||
internal class SpriteComponent : ISkinComponent
|
||||
internal class SpriteLookup : ISkinLookup
|
||||
{
|
||||
public string LookupName { get; set; }
|
||||
|
||||
public SpriteComponent(string textureName)
|
||||
public SpriteLookup(string textureName)
|
||||
{
|
||||
LookupName = textureName;
|
||||
}
|
||||
|
@ -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(ISkinLookup lookup, Func<ISkinLookup, SpriteText> defaultImplementation, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||
: base(lookup, defaultImplementation, confineMode)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Skinning
|
||||
components.Clear();
|
||||
ComponentsLoaded = false;
|
||||
|
||||
content = CurrentSkin.GetDrawableComponent(new SkinnableTargetComponent(Target)) as SkinnableTargetComponentsContainer;
|
||||
content = CurrentSkin.GetDrawableComponent(new SkinnableTargetLookup(Target)) as SkinnableTargetComponentsContainer;
|
||||
|
||||
cancellationSource?.Cancel();
|
||||
cancellationSource = null;
|
||||
|
@ -3,13 +3,13 @@
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class SkinnableTargetComponent : ISkinComponent
|
||||
public class SkinnableTargetLookup : ISkinLookup
|
||||
{
|
||||
public readonly SkinnableTarget Target;
|
||||
|
||||
public string LookupName => Target.ToString();
|
||||
|
||||
public SkinnableTargetComponent(SkinnableTarget target)
|
||||
public SkinnableTargetLookup(SkinnableTarget target)
|
||||
{
|
||||
Target = target;
|
||||
}
|
@ -59,14 +59,14 @@ namespace osu.Game.Skinning
|
||||
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;
|
||||
|
||||
switch (component)
|
||||
switch (lookup)
|
||||
{
|
||||
case SkinnableTargetComponent target:
|
||||
case SkinnableTargetLookup target:
|
||||
switch (target.Target)
|
||||
{
|
||||
case SkinnableTarget.SongSelect:
|
||||
@ -156,14 +156,14 @@ namespace osu.Game.Skinning
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (component.LookupName)
|
||||
switch (lookup.LookupName)
|
||||
{
|
||||
// Temporary until default skin has a valid hit lighting.
|
||||
case @"lighting":
|
||||
return Drawable.Empty();
|
||||
}
|
||||
|
||||
if (GetTexture(component.LookupName) is Texture t)
|
||||
if (GetTexture(lookup.LookupName) is Texture t)
|
||||
return new Sprite { Texture = t };
|
||||
|
||||
return null;
|
||||
|
@ -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(ISkinLookup lookup)
|
||||
: base($@"Unsupported component type: {lookup.GetType()} (lookup: ""{lookup.LookupName}"").")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user