osu/osu.Game/Skinning/LegacySkinTransformer.cs

61 lines
2.1 KiB
C#
Raw Normal View History

2020-06-21 20:04:10 +00:00
// 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.
2021-05-31 08:25:21 +00:00
using System;
2020-06-21 20:04:10 +00:00
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
2020-07-17 07:54:30 +00:00
using osu.Framework.Graphics.OpenGL.Textures;
2020-06-21 20:04:10 +00:00
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
2020-06-21 20:44:35 +00:00
using osu.Game.Rulesets.Objects.Legacy;
using static osu.Game.Skinning.LegacySkinConfiguration;
2020-06-21 20:04:10 +00:00
namespace osu.Game.Skinning
{
/// <summary>
/// Transformer used to handle support of legacy features for individual rulesets.
/// </summary>
public abstract class LegacySkinTransformer : ISkinSource
2020-06-21 20:04:10 +00:00
{
/// <summary>
/// Source of the <see cref="ISkin"/> which is being transformed.
/// </summary>
protected ISkinSource Source { get; }
protected LegacySkinTransformer(ISkinSource source)
{
Source = source;
}
public abstract Drawable GetDrawableComponent(ISkinComponent component);
2020-07-17 07:54:30 +00:00
public Texture GetTexture(string componentName) => GetTexture(componentName, default, default);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
=> Source.GetTexture(componentName, wrapModeS, wrapModeT);
2020-06-21 20:04:10 +00:00
public virtual ISample GetSample(ISampleInfo sampleInfo)
2020-06-21 20:44:35 +00:00
{
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
return Source.GetSample(sampleInfo);
var playLayeredHitSounds = GetConfig<LegacySetting, bool>(LegacySetting.LayeredHitSounds);
2020-06-21 20:44:35 +00:00
if (legacySample.IsLayered && playLayeredHitSounds?.Value == false)
2021-01-19 08:11:40 +00:00
return new SampleVirtual();
2020-06-21 20:44:35 +00:00
return Source.GetSample(sampleInfo);
}
2020-06-21 20:04:10 +00:00
public abstract IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup);
2021-05-31 08:25:21 +00:00
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => Source.FindProvider(lookupFunction);
public event Action SourceChanged
{
add { throw new NotSupportedException(); }
remove { }
}
2020-06-21 20:04:10 +00:00
}
}