mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 10:03:05 +08:00
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
// 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.Graphics.Textures;
|
|
using osu.Game.Audio;
|
|
using osu.Game.Rulesets.Objects.Legacy;
|
|
using static osu.Game.Skinning.SkinConfiguration;
|
|
|
|
namespace osu.Game.Skinning
|
|
{
|
|
/// <summary>
|
|
/// Transformer used to handle support of legacy features for individual rulesets.
|
|
/// </summary>
|
|
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)
|
|
: base(skin)
|
|
{
|
|
}
|
|
|
|
public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
|
|
{
|
|
switch (componentName)
|
|
{
|
|
case "fountain-star":
|
|
componentName = "star2";
|
|
break;
|
|
}
|
|
|
|
return base.GetTexture(componentName, wrapModeS, wrapModeT);
|
|
}
|
|
|
|
public override ISample? GetSample(ISampleInfo sampleInfo)
|
|
{
|
|
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
|
|
return Skin.GetSample(sampleInfo);
|
|
|
|
var playLayeredHitSounds = GetConfig<LegacySetting, bool>(LegacySetting.LayeredHitSounds);
|
|
if (legacySample.IsLayered && playLayeredHitSounds?.Value == false)
|
|
return new SampleVirtual();
|
|
|
|
return base.GetSample(sampleInfo);
|
|
}
|
|
}
|
|
}
|