mirror of
https://github.com/ppy/osu.git
synced 2025-03-16 09:47:18 +08:00
Move basic transformer behaviour to base abstract
class
This commit is contained in:
parent
f8e9a960ba
commit
74aefdc5bd
osu.Game.Rulesets.Osu/Skinning/Argon
osu.Game/Skinning
@ -1,26 +1,20 @@
|
||||
// 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 osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
||||
{
|
||||
public class OsuArgonSkinTransformer : ISkinTransformer
|
||||
public class OsuArgonSkinTransformer : SkinTransformer
|
||||
{
|
||||
public ISkin Skin { get; }
|
||||
|
||||
public OsuArgonSkinTransformer(ISkin skin)
|
||||
: base(skin)
|
||||
{
|
||||
Skin = skin;
|
||||
}
|
||||
|
||||
public Drawable? GetDrawableComponent(ISkinComponent component)
|
||||
public override Drawable? GetDrawableComponent(ISkinComponent component)
|
||||
{
|
||||
switch (component)
|
||||
{
|
||||
@ -55,16 +49,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT);
|
||||
|
||||
public ISample? GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo);
|
||||
|
||||
public IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) where TLookup : notnull where TValue : notnull
|
||||
{
|
||||
return null;
|
||||
return base.GetDrawableComponent(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,7 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
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.Rulesets.Objects.Legacy;
|
||||
using static osu.Game.Skinning.SkinConfiguration;
|
||||
@ -18,24 +11,14 @@ namespace osu.Game.Skinning
|
||||
/// <summary>
|
||||
/// Transformer used to handle support of legacy features for individual rulesets.
|
||||
/// </summary>
|
||||
public abstract class LegacySkinTransformer : ISkinTransformer
|
||||
public abstract class LegacySkinTransformer : SkinTransformer
|
||||
{
|
||||
[NotNull]
|
||||
public ISkin Skin { get; }
|
||||
|
||||
protected LegacySkinTransformer([NotNull] ISkin skin)
|
||||
protected LegacySkinTransformer(ISkin skin)
|
||||
: base(skin)
|
||||
{
|
||||
Skin = skin ?? throw new ArgumentNullException(nameof(skin));
|
||||
}
|
||||
|
||||
public virtual Drawable GetDrawableComponent(ISkinComponent component) => Skin.GetDrawableComponent(component);
|
||||
|
||||
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)
|
||||
public override ISample? GetSample(ISampleInfo sampleInfo)
|
||||
{
|
||||
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
|
||||
return Skin.GetSample(sampleInfo);
|
||||
@ -44,9 +27,7 @@ namespace osu.Game.Skinning
|
||||
if (legacySample.IsLayered && playLayeredHitSounds?.Value == false)
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user