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.
|
|
|
|
|
2023-12-30 08:47:42 +08:00
|
|
|
using System.Linq;
|
2020-06-22 04:04:10 +08:00
|
|
|
using osu.Framework.Audio.Sample;
|
2023-12-30 08:47:42 +08:00
|
|
|
using osu.Framework.Graphics;
|
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;
|
2023-12-30 08:47:42 +08:00
|
|
|
using osuTK;
|
2021-10-22 13:41:59 +08:00
|
|
|
using static osu.Game.Skinning.SkinConfiguration;
|
2020-06-22 04:04:10 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
2023-12-30 08:47:42 +08:00
|
|
|
public class LegacySkinTransformer : SkinTransformer
|
2020-06-22 04:04:10 +08:00
|
|
|
{
|
2022-10-12 16:47:20 +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);
|
|
|
|
|
2023-12-30 08:47:42 +08:00
|
|
|
public LegacySkinTransformer(ISkin skin)
|
2022-09-22 17:50:19 +08:00
|
|
|
: base(skin)
|
2020-06-22 04:04:10 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-30 08:47:42 +08:00
|
|
|
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
|
|
|
|
{
|
|
|
|
switch (lookup)
|
|
|
|
{
|
|
|
|
case SkinComponentsContainerLookup containerLookup:
|
|
|
|
switch (containerLookup.Target)
|
|
|
|
{
|
|
|
|
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null:
|
|
|
|
var rulesetHUDComponents = base.GetDrawableComponent(lookup);
|
|
|
|
|
|
|
|
rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container =>
|
|
|
|
{
|
2023-12-30 10:29:18 +08:00
|
|
|
var combo = container.OfType<LegacyDefaultComboCounter>().FirstOrDefault();
|
2023-12-30 08:47:42 +08:00
|
|
|
|
|
|
|
if (combo != null)
|
|
|
|
{
|
|
|
|
combo.Anchor = Anchor.BottomLeft;
|
|
|
|
combo.Origin = Anchor.BottomLeft;
|
|
|
|
combo.Scale = new Vector2(1.28f);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
{
|
2023-12-30 10:29:18 +08:00
|
|
|
new LegacyDefaultComboCounter()
|
2023-12-30 08:47:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return rulesetHUDComponents;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.GetDrawableComponent(lookup);
|
|
|
|
}
|
|
|
|
|
2022-09-22 17:50:19 +08:00
|
|
|
public override ISample? GetSample(ISampleInfo sampleInfo)
|
2020-06-22 04:44:35 +08:00
|
|
|
{
|
|
|
|
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
|
2021-06-09 18:34:42 +08:00
|
|
|
return Skin.GetSample(sampleInfo);
|
2020-06-22 04:44:35 +08:00
|
|
|
|
2020-07-29 15:34:09 +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
|
|
|
|
2022-09-22 17:50:19 +08:00
|
|
|
return base.GetSample(sampleInfo);
|
2020-06-22 04:44:35 +08:00
|
|
|
}
|
2020-06-22 04:04:10 +08:00
|
|
|
}
|
|
|
|
}
|