mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 19:32:55 +08:00
Merge pull request #20401 from peppy/fix-argon-sprite-lookup
Fix "argon" skin not supporting user loaded sprites in gameplay
This commit is contained in:
commit
a612fe70f9
@ -1,23 +1,20 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Game.Audio;
|
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
||||||
{
|
{
|
||||||
public class OsuArgonSkinTransformer : ISkin
|
public class OsuArgonSkinTransformer : SkinTransformer
|
||||||
{
|
{
|
||||||
public OsuArgonSkinTransformer(ISkin skin)
|
public OsuArgonSkinTransformer(ISkin skin)
|
||||||
|
: base(skin)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable? GetDrawableComponent(ISkinComponent component)
|
public override Drawable? GetDrawableComponent(ISkinComponent component)
|
||||||
{
|
{
|
||||||
switch (component)
|
switch (component)
|
||||||
{
|
{
|
||||||
@ -52,22 +49,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return base.GetDrawableComponent(component);
|
||||||
}
|
|
||||||
|
|
||||||
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ISample? GetSample(ISampleInfo sampleInfo)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) where TLookup : notnull where TValue : notnull
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
|
|
||||||
var topProvider = source.FindProvider(s => s.GetTexture("spinner-top") != null);
|
var topProvider = source.FindProvider(s => s.GetTexture("spinner-top") != null);
|
||||||
|
|
||||||
if (topProvider is LegacySkinTransformer transformer && !(transformer.Skin is DefaultLegacySkin))
|
if (topProvider is ISkinTransformer transformer && !(transformer.Skin is DefaultLegacySkin))
|
||||||
{
|
{
|
||||||
AddInternal(ApproachCircle = new Sprite
|
AddInternal(ApproachCircle = new Sprite
|
||||||
{
|
{
|
||||||
|
17
osu.Game/Skinning/ISkinTransformer.cs
Normal file
17
osu.Game/Skinning/ISkinTransformer.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// 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 skin transformer takes in an <see cref="ISkin"/> and applies transformations to it.
|
||||||
|
/// The most common use case is allowing individual rulesets to add skinnable components without directly coupling to underlying skins.
|
||||||
|
/// </summary>
|
||||||
|
public interface ISkinTransformer : ISkin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The original skin that is being transformed.
|
||||||
|
/// </summary>
|
||||||
|
ISkin Skin { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Rulesets.Objects.Legacy;
|
using osu.Game.Rulesets.Objects.Legacy;
|
||||||
using static osu.Game.Skinning.SkinConfiguration;
|
using static osu.Game.Skinning.SkinConfiguration;
|
||||||
@ -18,27 +11,14 @@ namespace osu.Game.Skinning
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Transformer used to handle support of legacy features for individual rulesets.
|
/// Transformer used to handle support of legacy features for individual rulesets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class LegacySkinTransformer : ISkin
|
public abstract class LegacySkinTransformer : SkinTransformer
|
||||||
{
|
{
|
||||||
/// <summary>
|
protected LegacySkinTransformer(ISkin skin)
|
||||||
/// The <see cref="ISkin"/> which is being transformed.
|
: base(skin)
|
||||||
/// </summary>
|
|
||||||
[NotNull]
|
|
||||||
public ISkin Skin { get; }
|
|
||||||
|
|
||||||
protected LegacySkinTransformer([NotNull] ISkin skin)
|
|
||||||
{
|
{
|
||||||
Skin = skin ?? throw new ArgumentNullException(nameof(skin));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Drawable GetDrawableComponent(ISkinComponent component) => Skin.GetDrawableComponent(component);
|
public override ISample? GetSample(ISampleInfo sampleInfo)
|
||||||
|
|
||||||
public Texture GetTexture(string componentName) => GetTexture(componentName, default, default);
|
|
||||||
|
|
||||||
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
|
|
||||||
=> Skin.GetTexture(componentName, wrapModeS, wrapModeT);
|
|
||||||
|
|
||||||
public virtual ISample GetSample(ISampleInfo sampleInfo)
|
|
||||||
{
|
{
|
||||||
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
|
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
|
||||||
return Skin.GetSample(sampleInfo);
|
return Skin.GetSample(sampleInfo);
|
||||||
@ -47,9 +27,7 @@ namespace osu.Game.Skinning
|
|||||||
if (legacySample.IsLayered && playLayeredHitSounds?.Value == false)
|
if (legacySample.IsLayered && playLayeredHitSounds?.Value == false)
|
||||||
return new SampleVirtual();
|
return new SampleVirtual();
|
||||||
|
|
||||||
return Skin.GetSample(sampleInfo);
|
return base.GetSample(sampleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Skin.GetConfig<TLookup, TValue>(lookup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
osu.Game/Skinning/SkinTransformer.cs
Normal file
32
osu.Game/Skinning/SkinTransformer.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
|
namespace osu.Game.Skinning
|
||||||
|
{
|
||||||
|
public abstract class SkinTransformer : ISkinTransformer
|
||||||
|
{
|
||||||
|
public ISkin Skin { get; }
|
||||||
|
|
||||||
|
protected SkinTransformer(ISkin skin)
|
||||||
|
{
|
||||||
|
Skin = skin ?? throw new ArgumentNullException(nameof(skin));
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Drawable? GetDrawableComponent(ISkinComponent component) => Skin.GetDrawableComponent(component);
|
||||||
|
|
||||||
|
public virtual Texture? GetTexture(string componentName) => GetTexture(componentName, default, default);
|
||||||
|
|
||||||
|
public virtual Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT);
|
||||||
|
|
||||||
|
public virtual ISample? GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo);
|
||||||
|
|
||||||
|
public virtual IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) where TLookup : notnull where TValue : notnull => Skin.GetConfig<TLookup, TValue>(lookup);
|
||||||
|
}
|
||||||
|
}
|
@ -100,7 +100,7 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
foreach (var skin in skins)
|
foreach (var skin in skins)
|
||||||
{
|
{
|
||||||
if (skin is LegacySkinTransformer transformer && isUserSkin(transformer.Skin))
|
if (skin is ISkinTransformer transformer && isUserSkin(transformer.Skin))
|
||||||
return transformer.Skin;
|
return transformer.Skin;
|
||||||
|
|
||||||
if (isUserSkin(skin))
|
if (isUserSkin(skin))
|
||||||
|
Loading…
Reference in New Issue
Block a user