1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 12:45:09 +08:00

Update other transformers with similar refactored logic

This commit is contained in:
Dean Herbert 2021-05-30 19:15:59 +09:00
parent 50d71faf56
commit 17574833fb
3 changed files with 139 additions and 143 deletions

View File

@ -120,14 +120,12 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
case ManiaSkinComponents.StageForeground: case ManiaSkinComponents.StageForeground:
return new LegacyStageForeground(); return new LegacyStageForeground();
default:
return Source.GetDrawableComponent(component);
} }
default: break;
return Source.GetDrawableComponent(component);
} }
return Source.GetDrawableComponent(component);
} }
private Drawable getResult(HitResult result) private Drawable getResult(HitResult result)

View File

@ -34,91 +34,90 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
public override Drawable GetDrawableComponent(ISkinComponent component) public override Drawable GetDrawableComponent(ISkinComponent component)
{ {
if (!(component is OsuSkinComponent osuComponent)) if (component is OsuSkinComponent osuComponent)
return Source.GetDrawableComponent(component);
switch (osuComponent.Component)
{ {
case OsuSkinComponents.FollowPoint: switch (osuComponent.Component)
return this.GetAnimation(component.LookupName, true, false, true, startAtCurrentTime: false); {
case OsuSkinComponents.FollowPoint:
return this.GetAnimation(component.LookupName, true, false, true, startAtCurrentTime: false);
case OsuSkinComponents.SliderFollowCircle: case OsuSkinComponents.SliderFollowCircle:
var followCircle = this.GetAnimation("sliderfollowcircle", true, true, true); var followCircle = this.GetAnimation("sliderfollowcircle", true, true, true);
if (followCircle != null) if (followCircle != null)
// follow circles are 2x the hitcircle resolution in legacy skins (since they are scaled down from >1x // follow circles are 2x the hitcircle resolution in legacy skins (since they are scaled down from >1x
followCircle.Scale *= 0.5f; followCircle.Scale *= 0.5f;
return followCircle; return followCircle;
case OsuSkinComponents.SliderBall: case OsuSkinComponents.SliderBall:
var sliderBallContent = this.GetAnimation("sliderb", true, true, animationSeparator: ""); var sliderBallContent = this.GetAnimation("sliderb", true, true, animationSeparator: "");
// todo: slider ball has a custom frame delay based on velocity // todo: slider ball has a custom frame delay based on velocity
// Math.Max((150 / Velocity) * GameBase.SIXTY_FRAME_TIME, GameBase.SIXTY_FRAME_TIME); // Math.Max((150 / Velocity) * GameBase.SIXTY_FRAME_TIME, GameBase.SIXTY_FRAME_TIME);
if (sliderBallContent != null) if (sliderBallContent != null)
return new LegacySliderBall(sliderBallContent); return new LegacySliderBall(sliderBallContent);
return null;
case OsuSkinComponents.SliderBody:
if (hasHitCircle.Value)
return new LegacySliderBody();
return null;
case OsuSkinComponents.SliderTailHitCircle:
if (hasHitCircle.Value)
return new LegacyMainCirclePiece("sliderendcircle", false);
return null;
case OsuSkinComponents.SliderHeadHitCircle:
if (hasHitCircle.Value)
return new LegacyMainCirclePiece("sliderstartcircle");
return null;
case OsuSkinComponents.HitCircle:
if (hasHitCircle.Value)
return new LegacyMainCirclePiece();
return null;
case OsuSkinComponents.Cursor:
if (Source.GetTexture("cursor") != null)
return new LegacyCursor();
return null;
case OsuSkinComponents.CursorTrail:
if (Source.GetTexture("cursortrail") != null)
return new LegacyCursorTrail();
return null;
case OsuSkinComponents.HitCircleText:
if (!this.HasFont(LegacyFont.HitCircle))
return null; return null;
return new LegacySpriteText(LegacyFont.HitCircle) case OsuSkinComponents.SliderBody:
{ if (hasHitCircle.Value)
// stable applies a blanket 0.8x scale to hitcircle fonts return new LegacySliderBody();
Scale = new Vector2(0.8f),
};
case OsuSkinComponents.SpinnerBody: return null;
bool hasBackground = Source.GetTexture("spinner-background") != null;
if (Source.GetTexture("spinner-top") != null && !hasBackground) case OsuSkinComponents.SliderTailHitCircle:
return new LegacyNewStyleSpinner(); if (hasHitCircle.Value)
else if (hasBackground) return new LegacyMainCirclePiece("sliderendcircle", false);
return new LegacyOldStyleSpinner();
return null; return null;
default: case OsuSkinComponents.SliderHeadHitCircle:
return Source.GetDrawableComponent(component); if (hasHitCircle.Value)
return new LegacyMainCirclePiece("sliderstartcircle");
return null;
case OsuSkinComponents.HitCircle:
if (hasHitCircle.Value)
return new LegacyMainCirclePiece();
return null;
case OsuSkinComponents.Cursor:
if (Source.GetTexture("cursor") != null)
return new LegacyCursor();
return null;
case OsuSkinComponents.CursorTrail:
if (Source.GetTexture("cursortrail") != null)
return new LegacyCursorTrail();
return null;
case OsuSkinComponents.HitCircleText:
if (!this.HasFont(LegacyFont.HitCircle))
return null;
return new LegacySpriteText(LegacyFont.HitCircle)
{
// stable applies a blanket 0.8x scale to hitcircle fonts
Scale = new Vector2(0.8f),
};
case OsuSkinComponents.SpinnerBody:
bool hasBackground = Source.GetTexture("spinner-background") != null;
if (Source.GetTexture("spinner-top") != null && !hasBackground)
return new LegacyNewStyleSpinner();
else if (hasBackground)
return new LegacyOldStyleSpinner();
return null;
}
} }
return Source.GetDrawableComponent(component);
} }
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)

View File

@ -38,102 +38,101 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
return Drawable.Empty().With(d => d.Expire()); return Drawable.Empty().With(d => d.Expire());
} }
if (!(component is TaikoSkinComponent taikoComponent)) if (component is TaikoSkinComponent taikoComponent)
return Source.GetDrawableComponent(component);
switch (taikoComponent.Component)
{ {
case TaikoSkinComponents.DrumRollBody: switch (taikoComponent.Component)
if (GetTexture("taiko-roll-middle") != null) {
return new LegacyDrumRoll(); case TaikoSkinComponents.DrumRollBody:
if (GetTexture("taiko-roll-middle") != null)
return new LegacyDrumRoll();
return null; return null;
case TaikoSkinComponents.InputDrum: case TaikoSkinComponents.InputDrum:
if (GetTexture("taiko-bar-left") != null) if (GetTexture("taiko-bar-left") != null)
return new LegacyInputDrum(); return new LegacyInputDrum();
return null; return null;
case TaikoSkinComponents.CentreHit: case TaikoSkinComponents.CentreHit:
case TaikoSkinComponents.RimHit: case TaikoSkinComponents.RimHit:
if (GetTexture("taikohitcircle") != null) if (GetTexture("taikohitcircle") != null)
return new LegacyHit(taikoComponent.Component); return new LegacyHit(taikoComponent.Component);
return null; return null;
case TaikoSkinComponents.DrumRollTick: case TaikoSkinComponents.DrumRollTick:
return this.GetAnimation("sliderscorepoint", false, false); return this.GetAnimation("sliderscorepoint", false, false);
case TaikoSkinComponents.HitTarget: case TaikoSkinComponents.HitTarget:
if (GetTexture("taikobigcircle") != null) if (GetTexture("taikobigcircle") != null)
return new TaikoLegacyHitTarget(); return new TaikoLegacyHitTarget();
return null; return null;
case TaikoSkinComponents.PlayfieldBackgroundRight: case TaikoSkinComponents.PlayfieldBackgroundRight:
if (GetTexture("taiko-bar-right") != null) if (GetTexture("taiko-bar-right") != null)
return new TaikoLegacyPlayfieldBackgroundRight(); return new TaikoLegacyPlayfieldBackgroundRight();
return null; return null;
case TaikoSkinComponents.PlayfieldBackgroundLeft: case TaikoSkinComponents.PlayfieldBackgroundLeft:
// This is displayed inside LegacyInputDrum. It is required to be there for layout purposes (can be seen on legacy skins). // This is displayed inside LegacyInputDrum. It is required to be there for layout purposes (can be seen on legacy skins).
if (GetTexture("taiko-bar-right") != null) if (GetTexture("taiko-bar-right") != null)
return Drawable.Empty(); return Drawable.Empty();
return null; return null;
case TaikoSkinComponents.BarLine: case TaikoSkinComponents.BarLine:
if (GetTexture("taiko-barline") != null) if (GetTexture("taiko-barline") != null)
return new LegacyBarLine(); return new LegacyBarLine();
return null; return null;
case TaikoSkinComponents.TaikoExplosionMiss: case TaikoSkinComponents.TaikoExplosionMiss:
var missSprite = this.GetAnimation(getHitName(taikoComponent.Component), true, false); var missSprite = this.GetAnimation(getHitName(taikoComponent.Component), true, false);
if (missSprite != null) if (missSprite != null)
return new LegacyHitExplosion(missSprite); return new LegacyHitExplosion(missSprite);
return null; return null;
case TaikoSkinComponents.TaikoExplosionOk: case TaikoSkinComponents.TaikoExplosionOk:
case TaikoSkinComponents.TaikoExplosionGreat: case TaikoSkinComponents.TaikoExplosionGreat:
var hitName = getHitName(taikoComponent.Component); var hitName = getHitName(taikoComponent.Component);
var hitSprite = this.GetAnimation(hitName, true, false); var hitSprite = this.GetAnimation(hitName, true, false);
if (hitSprite != null) if (hitSprite != null)
{ {
var strongHitSprite = this.GetAnimation($"{hitName}k", true, false); var strongHitSprite = this.GetAnimation($"{hitName}k", true, false);
return new LegacyHitExplosion(hitSprite, strongHitSprite); return new LegacyHitExplosion(hitSprite, strongHitSprite);
} }
return null; return null;
case TaikoSkinComponents.TaikoExplosionKiai: case TaikoSkinComponents.TaikoExplosionKiai:
// suppress the default kiai explosion if the skin brings its own sprites. // suppress the default kiai explosion if the skin brings its own sprites.
// the drawable needs to expire as soon as possible to avoid accumulating empty drawables on the playfield. // the drawable needs to expire as soon as possible to avoid accumulating empty drawables on the playfield.
if (hasExplosion.Value) if (hasExplosion.Value)
return Drawable.Empty().With(d => d.Expire()); return Drawable.Empty().With(d => d.Expire());
return null; return null;
case TaikoSkinComponents.Scroller: case TaikoSkinComponents.Scroller:
if (GetTexture("taiko-slider") != null) if (GetTexture("taiko-slider") != null)
return new LegacyTaikoScroller(); return new LegacyTaikoScroller();
return null; return null;
case TaikoSkinComponents.Mascot: case TaikoSkinComponents.Mascot:
return new DrawableTaikoMascot(); return new DrawableTaikoMascot();
}
default:
return Source.GetDrawableComponent(component);
} }
return Source.GetDrawableComponent(component);
} }
private string getHitName(TaikoSkinComponents component) private string getHitName(TaikoSkinComponents component)