// Copyright (c) ppy Pty Ltd . 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.Objects.Legacy; namespace osu.Game.Skinning { /// /// Transformer used to handle support of legacy features for individual rulesets. /// public abstract class LegacySkinTransformer : ISkin { /// /// Source of the which is being transformed. /// protected ISkinSource Source { get; } protected LegacySkinTransformer(ISkinSource source) { Source = source; } public abstract Drawable GetDrawableComponent(ISkinComponent component); public Texture GetTexture(string componentName) => Source.GetTexture(componentName); public virtual SampleChannel GetSample(ISampleInfo sampleInfo) { if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample)) return Source.GetSample(sampleInfo); var playLayeredHitSounds = GetConfig(GlobalSkinConfiguration.LayeredHitSounds); if (legacySample.IsLayered && playLayeredHitSounds?.Value == false) return new SampleChannelVirtual(); return Source.GetSample(sampleInfo); } public abstract IBindable GetConfig(TLookup lookup); } }