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-06-10 10:41:41 +00:00
|
|
|
using System;
|
|
|
|
using JetBrains.Annotations;
|
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;
|
2020-07-29 07:34:09 +00:00
|
|
|
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>
|
2021-06-09 10:34:42 +00:00
|
|
|
public abstract class LegacySkinTransformer : ISkin
|
2020-06-21 20:04:10 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
2021-06-09 10:34:42 +00:00
|
|
|
/// The <see cref="ISkin"/> which is being transformed.
|
2020-06-21 20:04:10 +00:00
|
|
|
/// </summary>
|
2021-06-10 10:41:41 +00:00
|
|
|
[NotNull]
|
2021-06-09 10:34:42 +00:00
|
|
|
protected ISkin Skin { get; }
|
2020-06-21 20:04:10 +00:00
|
|
|
|
2021-06-10 10:41:41 +00:00
|
|
|
protected LegacySkinTransformer([NotNull] ISkin skin)
|
2020-06-21 20:04:10 +00:00
|
|
|
{
|
2021-06-10 10:41:41 +00:00
|
|
|
Skin = skin ?? throw new ArgumentNullException(nameof(skin));
|
2020-06-21 20:04:10 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 09:44:25 +00:00
|
|
|
public virtual Drawable GetDrawableComponent(ISkinComponent component) => Skin.GetDrawableComponent(component);
|
2020-06-21 20:04:10 +00:00
|
|
|
|
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)
|
2021-06-09 10:34:42 +00:00
|
|
|
=> Skin.GetTexture(componentName, wrapModeS, wrapModeT);
|
2020-06-21 20:04:10 +00:00
|
|
|
|
2021-02-18 09:32:28 +00:00
|
|
|
public virtual ISample GetSample(ISampleInfo sampleInfo)
|
2020-06-21 20:44:35 +00:00
|
|
|
{
|
|
|
|
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
|
2021-06-09 10:34:42 +00:00
|
|
|
return Skin.GetSample(sampleInfo);
|
2020-06-21 20:44:35 +00:00
|
|
|
|
2020-07-29 07:34:09 +00:00
|
|
|
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
|
|
|
|
2021-06-09 10:34:42 +00:00
|
|
|
return Skin.GetSample(sampleInfo);
|
2020-06-21 20:44:35 +00:00
|
|
|
}
|
2020-06-21 20:04:10 +00:00
|
|
|
|
2021-06-11 09:44:25 +00:00
|
|
|
public virtual IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Skin.GetConfig<TLookup, TValue>(lookup);
|
2020-06-21 20:04:10 +00:00
|
|
|
}
|
|
|
|
}
|