Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 59 additions & 54 deletions osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Screens.Play.HUD;
using osu.Game.Skinning;
using osuTK.Graphics;

Expand All @@ -25,76 +26,80 @@ public CatchLegacySkinTransformer(ISkin skin)

public override Drawable GetDrawableComponent(ISkinComponent component)
{
if (component is SkinnableTargetComponent targetComponent)
switch (component)
{
switch (targetComponent.Target)
{
case SkinnableTarget.MainHUDComponents:
var components = base.GetDrawableComponent(component) as SkinnableTargetComponentsContainer;

if (providesComboCounter && components != null)
{
// catch may provide its own combo counter; hide the default.
// todo: this should be done in an elegant way per ruleset, defining which HUD skin components should be displayed.
foreach (var legacyComboCounter in components.OfType<LegacyComboCounter>())
legacyComboCounter.HiddenByRulesetImplementation = false;
}

return components;
}
}
case SkinnableTargetComponent targetComponent:
switch (targetComponent.Target)
{
case SkinnableTarget.MainHUDComponents:
var components = base.GetDrawableComponent(component) as SkinnableTargetComponentsContainer;

if (providesComboCounter && components != null)
{
// catch may provide its own combo counter; hide the default.
// todo: this should be done in an elegant way per ruleset, defining which HUD skin components should be displayed.
foreach (var legacyComboCounter in components.OfType<LegacyComboCounter>())
legacyComboCounter.HiddenByRulesetImplementation = false;
}

return components;
}

if (component is CatchSkinComponent catchSkinComponent)
{
switch (catchSkinComponent.Component)
{
case CatchSkinComponents.Fruit:
if (GetTexture("fruit-pear") != null)
return new LegacyFruitPiece();
break;

return null;
case CatchSkinComponent catchSkinComponent:
switch (catchSkinComponent.Component)
{
case CatchSkinComponents.Fruit:
if (GetTexture("fruit-pear") != null)
return new LegacyFruitPiece();

case CatchSkinComponents.Banana:
if (GetTexture("fruit-bananas") != null)
return new LegacyBananaPiece();
return null;

return null;
case CatchSkinComponents.Banana:
if (GetTexture("fruit-bananas") != null)
return new LegacyBananaPiece();

case CatchSkinComponents.Droplet:
if (GetTexture("fruit-drop") != null)
return new LegacyDropletPiece();
return null;

return null;
case CatchSkinComponents.Droplet:
if (GetTexture("fruit-drop") != null)
return new LegacyDropletPiece();

case CatchSkinComponents.Catcher:
decimal version = GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value ?? 1;
return null;

if (version < 2.3m)
{
if (hasOldStyleCatcherSprite())
return new LegacyCatcherOld();
}
case CatchSkinComponents.Catcher:
decimal version = GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value ?? 1;

if (hasNewStyleCatcherSprite())
return new LegacyCatcherNew();
if (version < 2.3m)
{
if (hasOldStyleCatcherSprite())
return new LegacyCatcherOld();
}

return null;
if (hasNewStyleCatcherSprite())
return new LegacyCatcherNew();

case CatchSkinComponents.CatchComboCounter:
if (providesComboCounter)
return new LegacyCatchComboCounter();
return null;

return null;
case CatchSkinComponents.CatchComboCounter:
if (providesComboCounter)
return new LegacyCatchComboCounter();

case CatchSkinComponents.HitExplosion:
if (hasOldStyleCatcherSprite() || hasNewStyleCatcherSprite())
return new LegacyHitExplosion();
return null;

return null;
case CatchSkinComponents.HitExplosion:
if (hasOldStyleCatcherSprite() || hasNewStyleCatcherSprite())
return new LegacyHitExplosion();

return null;

default:
throw new UnsupportedSkinComponentException(component);
}

default:
throw new UnsupportedSkinComponentException(component);
}
case LegacyComboSplash.LegacyComboSplashComponent:
return new LegacyComboSplash.LegacyComboSplashSide("comboburst-fruits");
}

return base.GetDrawableComponent(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
Expand All @@ -14,6 +15,7 @@
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Objects.Legacy;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.HUD;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Mania.Skinning.Legacy
Expand Down Expand Up @@ -77,6 +79,22 @@ public override Drawable GetDrawableComponent(ISkinComponent component)
{
switch (component)
{
case SkinnableTargetComponent targetComponent:
if (targetComponent.Target == SkinnableTarget.MainHUDComponents)
{
var components = base.GetDrawableComponent(component) as SkinnableTargetComponentsContainer;
if (components == null) return null;

foreach (var comboSplash in components.OfType<LegacyComboSplash>())
{
comboSplash.BurstCondition = combo => combo > 0 && combo % 100 == 0;
}

return components;
}

break;
Comment on lines +82 to +96
Copy link
Member

@peppy peppy Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than doing this, it will be cleaner if you make a ManiaLegacyComboSplashSide and return it below, and then include the conditional logic within the subclass (you can likely make it a virutal / override pair if you do this).


case GameplaySkinComponent<HitResult> resultComponent:
return getResult(resultComponent.Component);

Expand Down Expand Up @@ -122,6 +140,9 @@ public override Drawable GetDrawableComponent(ISkinComponent component)
default:
throw new UnsupportedSkinComponentException(component);
}

case LegacyComboSplash.LegacyComboSplashComponent:
return new LegacyComboSplash.LegacyComboSplashSide("comboburst-mania");
}

return base.GetDrawableComponent(component);
Expand Down
147 changes: 76 additions & 71 deletions osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Screens.Play.HUD;
using osu.Game.Skinning;
using osuTK;

Expand All @@ -30,108 +31,112 @@ public OsuLegacySkinTransformer(ISkin skin)

public override Drawable GetDrawableComponent(ISkinComponent component)
{
if (component is OsuSkinComponent osuComponent)
switch (component)
{
switch (osuComponent.Component)
{
case OsuSkinComponents.FollowPoint:
return this.GetAnimation(component.LookupName, true, true, true, startAtCurrentTime: false);

case OsuSkinComponents.SliderScorePoint:
return this.GetAnimation(component.LookupName, false, false);
case OsuSkinComponent osuComponent:
switch (osuComponent.Component)
{
case OsuSkinComponents.FollowPoint:
return this.GetAnimation(component.LookupName, true, true, true, startAtCurrentTime: false);

case OsuSkinComponents.SliderFollowCircle:
var followCircleContent = this.GetAnimation("sliderfollowcircle", true, true, true);
if (followCircleContent != null)
return new LegacyFollowCircle(followCircleContent);
case OsuSkinComponents.SliderScorePoint:
return this.GetAnimation(component.LookupName, false, false);

return null;
case OsuSkinComponents.SliderFollowCircle:
var followCircleContent = this.GetAnimation("sliderfollowcircle", true, true, true);
if (followCircleContent != null)
return new LegacyFollowCircle(followCircleContent);

case OsuSkinComponents.SliderBall:
var sliderBallContent = this.GetAnimation("sliderb", true, true, animationSeparator: "");
return null;

// todo: slider ball has a custom frame delay based on velocity
// Math.Max((150 / Velocity) * GameBase.SIXTY_FRAME_TIME, GameBase.SIXTY_FRAME_TIME);
case OsuSkinComponents.SliderBall:
var sliderBallContent = this.GetAnimation("sliderb", true, true, animationSeparator: "");

if (sliderBallContent != null)
return new LegacySliderBall(sliderBallContent, this);
// todo: slider ball has a custom frame delay based on velocity
// Math.Max((150 / Velocity) * GameBase.SIXTY_FRAME_TIME, GameBase.SIXTY_FRAME_TIME);

return null;
if (sliderBallContent != null)
return new LegacySliderBall(sliderBallContent, this);

case OsuSkinComponents.SliderBody:
if (hasHitCircle.Value)
return new LegacySliderBody();
return null;

return null;
case OsuSkinComponents.SliderBody:
if (hasHitCircle.Value)
return new LegacySliderBody();

case OsuSkinComponents.SliderTailHitCircle:
if (hasHitCircle.Value)
return new LegacyMainCirclePiece("sliderendcircle", false);
return null;

return null;
case OsuSkinComponents.SliderTailHitCircle:
if (hasHitCircle.Value)
return new LegacyMainCirclePiece("sliderendcircle", false);

case OsuSkinComponents.SliderHeadHitCircle:
if (hasHitCircle.Value)
return new LegacySliderHeadHitCircle();
return null;

return null;
case OsuSkinComponents.SliderHeadHitCircle:
if (hasHitCircle.Value)
return new LegacySliderHeadHitCircle();

case OsuSkinComponents.ReverseArrow:
if (hasHitCircle.Value)
return new LegacyReverseArrow();
return null;

return null;
case OsuSkinComponents.ReverseArrow:
if (hasHitCircle.Value)
return new LegacyReverseArrow();

case OsuSkinComponents.HitCircle:
if (hasHitCircle.Value)
return new LegacyMainCirclePiece();
return null;

return null;
case OsuSkinComponents.HitCircle:
if (hasHitCircle.Value)
return new LegacyMainCirclePiece();

case OsuSkinComponents.Cursor:
if (GetTexture("cursor") != null)
return new LegacyCursor(this);
return null;

return null;
case OsuSkinComponents.Cursor:
if (GetTexture("cursor") != null)
return new LegacyCursor(this);

case OsuSkinComponents.CursorTrail:
if (GetTexture("cursortrail") != null)
return new LegacyCursorTrail(this);
return null;

return null;
case OsuSkinComponents.CursorTrail:
if (GetTexture("cursortrail") != null)
return new LegacyCursorTrail(this);

case OsuSkinComponents.CursorParticles:
if (GetTexture("star2") != null)
return new LegacyCursorParticles();
return null;

return null;
case OsuSkinComponents.CursorParticles:
if (GetTexture("star2") != null)
return new LegacyCursorParticles();

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.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 = GetTexture("spinner-background") != null;
case OsuSkinComponents.SpinnerBody:
bool hasBackground = GetTexture("spinner-background") != null;

if (GetTexture("spinner-top") != null && !hasBackground)
return new LegacyNewStyleSpinner();
else if (hasBackground)
return new LegacyOldStyleSpinner();
if (GetTexture("spinner-top") != null && !hasBackground)
return new LegacyNewStyleSpinner();
else if (hasBackground)
return new LegacyOldStyleSpinner();

return null;
return null;

case OsuSkinComponents.ApproachCircle:
return new LegacyApproachCircle();
case OsuSkinComponents.ApproachCircle:
return new LegacyApproachCircle();

default:
throw new UnsupportedSkinComponentException(component);
}

default:
throw new UnsupportedSkinComponentException(component);
}
case LegacyComboSplash.LegacyComboSplashComponent:
return new LegacyComboSplash.LegacyComboSplashSide("comboburst");
}

return base.GetDrawableComponent(component);
Expand Down
Loading