1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-19 02:52:55 +08:00
osu-lazer/osu.Game/Skinning/LegacySkinTransformer.cs

54 lines
1.9 KiB
C#
Raw Normal View History

2020-06-22 04:04:10 +08: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.
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
2024-06-25 06:01:26 +08:00
using osu.Framework.Graphics.Containers;
2020-06-22 04:04:10 +08:00
using osu.Game.Audio;
2020-06-22 04:44:35 +08:00
using osu.Game.Rulesets.Objects.Legacy;
using static osu.Game.Skinning.SkinConfiguration;
2020-06-22 04:04:10 +08:00
namespace osu.Game.Skinning
{
public class LegacySkinTransformer : SkinTransformer
2020-06-22 04:04:10 +08:00
{
/// <summary>
/// Whether the skin being transformed is able to provide legacy resources for the ruleset.
/// </summary>
public virtual bool IsProvidingLegacyResources => this.HasFont(LegacyFont.Combo);
public LegacySkinTransformer(ISkin skin)
: base(skin)
2020-06-22 04:04:10 +08:00
{
}
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
2024-06-25 06:01:26 +08:00
if (lookup is SkinComponentsContainerLookup containerLookup
&& containerLookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents
&& containerLookup.Ruleset != null)
{
2024-06-25 06:01:26 +08:00
return base.GetDrawableComponent(lookup) ?? new Container
{
RelativeSizeAxes = Axes.Both,
Child = new LegacyComboCounter(),
};
}
return base.GetDrawableComponent(lookup);
}
public override ISample? GetSample(ISampleInfo sampleInfo)
2020-06-22 04:44:35 +08:00
{
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
return Skin.GetSample(sampleInfo);
2020-06-22 04:44:35 +08:00
var playLayeredHitSounds = GetConfig<LegacySetting, bool>(LegacySetting.LayeredHitSounds);
2020-06-22 04:44:35 +08:00
if (legacySample.IsLayered && playLayeredHitSounds?.Value == false)
2021-01-19 16:11:40 +08:00
return new SampleVirtual();
2020-06-22 04:44:35 +08:00
return base.GetSample(sampleInfo);
2020-06-22 04:44:35 +08:00
}
2020-06-22 04:04:10 +08:00
}
}