1
0
mirror of https://github.com/ppy/osu synced 2025-03-23 03:16:53 +00:00

Merge pull request from peppy/fix-beatmap-skin-fallbakcs

Fix legacy fallbacks not working correctly for beatmap skins
This commit is contained in:
Dan Balasescu 2022-10-13 10:08:40 +09:00 committed by GitHub
commit 565e5586fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 10 deletions
osu.Game.Rulesets.Catch/Skinning/Legacy
osu.Game.Rulesets.Mania/Skinning/Legacy
osu.Game.Rulesets.Osu/Skinning/Legacy
osu.Game.Rulesets.Taiko/Skinning/Legacy
osu.Game/Skinning

View File

@ -13,6 +13,10 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{ {
public class CatchLegacySkinTransformer : LegacySkinTransformer public class CatchLegacySkinTransformer : LegacySkinTransformer
{ {
public override bool IsProvidingLegacyResources => base.IsProvidingLegacyResources || hasPear;
private bool hasPear => GetTexture("fruit-pear") != null;
/// <summary> /// <summary>
/// For simplicity, let's use legacy combo font texture existence as a way to identify legacy skins from default. /// For simplicity, let's use legacy combo font texture existence as a way to identify legacy skins from default.
/// </summary> /// </summary>
@ -49,7 +53,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
switch (catchSkinComponent.Component) switch (catchSkinComponent.Component)
{ {
case CatchSkinComponents.Fruit: case CatchSkinComponents.Fruit:
if (GetTexture("fruit-pear") != null) if (hasPear)
return new LegacyFruitPiece(); return new LegacyFruitPiece();
return null; return null;

View File

@ -19,6 +19,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{ {
public class ManiaLegacySkinTransformer : LegacySkinTransformer public class ManiaLegacySkinTransformer : LegacySkinTransformer
{ {
public override bool IsProvidingLegacyResources => base.IsProvidingLegacyResources || hasKeyTexture.Value;
/// <summary> /// <summary>
/// Mapping of <see cref="HitResult"/> to their corresponding /// Mapping of <see cref="HitResult"/> to their corresponding
/// <see cref="LegacyManiaSkinConfigurationLookups"/> value. /// <see cref="LegacyManiaSkinConfigurationLookups"/> value.

View File

@ -13,6 +13,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{ {
public class OsuLegacySkinTransformer : LegacySkinTransformer public class OsuLegacySkinTransformer : LegacySkinTransformer
{ {
public override bool IsProvidingLegacyResources => base.IsProvidingLegacyResources || hasHitCircle.Value;
private readonly Lazy<bool> hasHitCircle; private readonly Lazy<bool> hasHitCircle;
/// <summary> /// <summary>

View File

@ -14,8 +14,13 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
{ {
public class TaikoLegacySkinTransformer : LegacySkinTransformer public class TaikoLegacySkinTransformer : LegacySkinTransformer
{ {
public override bool IsProvidingLegacyResources => base.IsProvidingLegacyResources || hasHitCircle || hasBarLeft;
private readonly Lazy<bool> hasExplosion; private readonly Lazy<bool> hasExplosion;
private bool hasHitCircle => GetTexture("taikohitcircle") != null;
private bool hasBarLeft => GetTexture("taiko-bar-left") != null;
public TaikoLegacySkinTransformer(ISkin skin) public TaikoLegacySkinTransformer(ISkin skin)
: base(skin) : base(skin)
{ {
@ -42,14 +47,14 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
return null; return null;
case TaikoSkinComponents.InputDrum: case TaikoSkinComponents.InputDrum:
if (GetTexture("taiko-bar-left") != null) if (hasBarLeft)
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 (hasHitCircle)
return new LegacyHit(taikoComponent.Component); return new LegacyHit(taikoComponent.Component);
return null; return null;

View File

@ -67,9 +67,12 @@ namespace osu.Game.Skinning
return sampleInfo is StoryboardSampleInfo || beatmapHitsounds.Value; return sampleInfo is StoryboardSampleInfo || beatmapHitsounds.Value;
} }
private readonly ISkin skin;
public BeatmapSkinProvidingContainer(ISkin skin) public BeatmapSkinProvidingContainer(ISkin skin)
: base(skin) : base(skin)
{ {
this.skin = skin;
} }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@ -84,11 +87,21 @@ namespace osu.Game.Skinning
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(SkinManager skins)
{ {
beatmapSkins.BindValueChanged(_ => TriggerSourceChanged()); beatmapSkins.BindValueChanged(_ => TriggerSourceChanged());
beatmapColours.BindValueChanged(_ => TriggerSourceChanged()); beatmapColours.BindValueChanged(_ => TriggerSourceChanged());
beatmapHitsounds.BindValueChanged(_ => TriggerSourceChanged()); beatmapHitsounds.BindValueChanged(_ => TriggerSourceChanged());
// If the beatmap skin looks to have skinnable resources, add the default classic skin as a fallback opportunity.
if (skin is LegacySkinTransformer legacySkin && legacySkin.IsProvidingLegacyResources)
{
SetSources(new[]
{
skin,
skins.DefaultClassicSkin
});
}
} }
} }
} }

View File

@ -389,18 +389,17 @@ namespace osu.Game.Skinning
if (particle != null) if (particle != null)
return new LegacyJudgementPieceNew(resultComponent.Component, createDrawable, particle); return new LegacyJudgementPieceNew(resultComponent.Component, createDrawable, particle);
else
return new LegacyJudgementPieceOld(resultComponent.Component, createDrawable); return new LegacyJudgementPieceOld(resultComponent.Component, createDrawable);
} }
return null; return null;
case SkinnableSprite.SpriteComponent sprite: case SkinnableSprite.SpriteComponent sprite:
return this.GetAnimation(sprite.LookupName, false, false); return this.GetAnimation(sprite.LookupName, false, false);
default:
throw new UnsupportedSkinComponentException(component);
} }
return null;
} }
private Texture? getParticleTexture(HitResult result) private Texture? getParticleTexture(HitResult result)

View File

@ -13,6 +13,11 @@ namespace osu.Game.Skinning
/// </summary> /// </summary>
public abstract class LegacySkinTransformer : SkinTransformer public abstract class LegacySkinTransformer : SkinTransformer
{ {
/// <summary>
/// Whether the skin being transformed is able to provide legacy resources for the ruleset.
/// </summary>
public virtual bool IsProvidingLegacyResources => this.HasFont(LegacyFont.Combo);
protected LegacySkinTransformer(ISkin skin) protected LegacySkinTransformer(ISkin skin)
: base(skin) : base(skin)
{ {

View File

@ -41,7 +41,7 @@ namespace osu.Game.Skinning
Ruleset = ruleset; Ruleset = ruleset;
Beatmap = beatmap; Beatmap = beatmap;
InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin is LegacySkin ? GetRulesetTransformedSkin(beatmapSkin) : beatmapSkin) InternalChild = new BeatmapSkinProvidingContainer(GetRulesetTransformedSkin(beatmapSkin))
{ {
Child = Content = new Container Child = Content = new Container
{ {