Skip to content

Commit

Permalink
Merge pull request #29027 from normalid-awa/feature/skin/legacy-input…
Browse files Browse the repository at this point in the history
…-overlay

Add legacy key counter support
  • Loading branch information
peppy authored Aug 7, 2024
2 parents bab1c61 + 725dc4d commit b1488fd
Show file tree
Hide file tree
Showing 17 changed files with 510 additions and 185 deletions.
115 changes: 72 additions & 43 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Catch.Skinning.Legacy
Expand All @@ -28,11 +29,15 @@ public CatchLegacySkinTransformer(ISkin skin)

public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
if (lookup is SkinComponentsContainerLookup containerLookup)
switch (lookup)
{
switch (containerLookup.Target)
{
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents:
case SkinComponentsContainerLookup containerLookup:
if (containerLookup.Target != SkinComponentsContainerLookup.TargetArea.MainHUDComponents)
return base.GetDrawableComponent(lookup);

// Modifications for global components.
if (containerLookup.Ruleset == null)
{
var components = base.GetDrawableComponent(lookup) as Container;

if (providesComboCounter && components != null)
Expand All @@ -44,60 +49,84 @@ public CatchLegacySkinTransformer(ISkin skin)
}

return components;
}
}
}

if (lookup is CatchSkinComponentLookup catchSkinComponent)
{
switch (catchSkinComponent.Component)
{
case CatchSkinComponents.Fruit:
if (hasPear)
return new LegacyFruitPiece();
// Skin has configuration.
if (base.GetDrawableComponent(lookup) is Drawable d)
return d;

return null;
// Our own ruleset components default.
return new DefaultSkinComponentsContainer(container =>
{
var keyCounter = container.OfType<LegacyKeyCounterDisplay>().FirstOrDefault();
case CatchSkinComponents.Banana:
if (GetTexture("fruit-bananas") != null)
return new LegacyBananaPiece();
if (keyCounter != null)
{
// set the anchor to top right so that it won't squash to the return button to the top
keyCounter.Anchor = Anchor.CentreRight;
keyCounter.Origin = Anchor.CentreRight;
keyCounter.X = 0;
// 340px is the default height inherit from stable
keyCounter.Y = container.ToLocalSpace(new Vector2(0, container.ScreenSpaceDrawQuad.Centre.Y - 340f)).Y;
}
})
{
Children = new Drawable[]
{
new LegacyKeyCounterDisplay(),
}
};

return null;
case CatchSkinComponentLookup catchSkinComponent:
switch (catchSkinComponent.Component)
{
case CatchSkinComponents.Fruit:
if (hasPear)
return new LegacyFruitPiece();

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

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

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.Droplet:
if (GetTexture("fruit-drop") != null)
return new LegacyDropletPiece();

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

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

case CatchSkinComponents.CatchComboCounter:
if (providesComboCounter)
return new LegacyCatchComboCounter();
if (version < 2.3m)
{
if (hasOldStyleCatcherSprite())
return new LegacyCatcherOld();
}

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

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

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

return null;

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

return null;

default:
throw new UnsupportedSkinComponentException(lookup);
}
default:
throw new UnsupportedSkinComponentException(lookup);
}
}

return base.GetDrawableComponent(lookup);
Expand Down
Loading

0 comments on commit b1488fd

Please sign in to comment.