2019-12-26 13:03:21 +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.
|
|
|
|
|
2020-03-30 14:17:32 +00:00
|
|
|
using System;
|
2019-12-26 13:03:21 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Framework.Audio.Sample;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Audio;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning
|
|
|
|
{
|
|
|
|
public class ManiaLegacySkinTransformer : ISkin
|
|
|
|
{
|
|
|
|
private readonly ISkin source;
|
|
|
|
|
2020-03-30 14:17:32 +00:00
|
|
|
private Lazy<bool> isLegacySkin;
|
|
|
|
|
|
|
|
public ManiaLegacySkinTransformer(ISkinSource source)
|
2019-12-26 13:03:21 +00:00
|
|
|
{
|
|
|
|
this.source = source;
|
2020-03-30 14:17:32 +00:00
|
|
|
|
|
|
|
source.SourceChanged += sourceChanged;
|
|
|
|
sourceChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void sourceChanged()
|
|
|
|
{
|
|
|
|
isLegacySkin = new Lazy<bool>(() => source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
2019-12-26 13:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Drawable GetDrawableComponent(ISkinComponent component)
|
|
|
|
{
|
|
|
|
switch (component)
|
|
|
|
{
|
|
|
|
case GameplaySkinComponent<HitResult> resultComponent:
|
2019-12-27 02:37:05 +00:00
|
|
|
return getResult(resultComponent);
|
2020-03-30 14:17:32 +00:00
|
|
|
|
2020-03-31 02:23:33 +00:00
|
|
|
case ManiaSkinComponent maniaComponent:
|
2020-03-30 14:17:32 +00:00
|
|
|
if (!isLegacySkin.Value)
|
|
|
|
return null;
|
|
|
|
|
2020-03-31 02:23:33 +00:00
|
|
|
switch (maniaComponent.Component)
|
|
|
|
{
|
|
|
|
case ManiaSkinComponents.KeyArea:
|
|
|
|
return new LegacyKeyArea();
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:17:32 +00:00
|
|
|
break;
|
2019-12-27 02:37:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2019-12-26 13:03:21 +00:00
|
|
|
|
2019-12-27 02:37:05 +00:00
|
|
|
private Drawable getResult(GameplaySkinComponent<HitResult> resultComponent)
|
|
|
|
{
|
|
|
|
switch (resultComponent.Component)
|
|
|
|
{
|
|
|
|
case HitResult.Miss:
|
|
|
|
return this.GetAnimation("mania-hit0", true, true);
|
2019-12-26 13:03:21 +00:00
|
|
|
|
2019-12-27 02:37:05 +00:00
|
|
|
case HitResult.Meh:
|
|
|
|
return this.GetAnimation("mania-hit50", true, true);
|
2019-12-26 13:03:21 +00:00
|
|
|
|
2019-12-27 02:37:05 +00:00
|
|
|
case HitResult.Ok:
|
|
|
|
return this.GetAnimation("mania-hit100", true, true);
|
2019-12-26 13:03:21 +00:00
|
|
|
|
2019-12-27 02:37:05 +00:00
|
|
|
case HitResult.Good:
|
|
|
|
return this.GetAnimation("mania-hit200", true, true);
|
2019-12-26 13:03:21 +00:00
|
|
|
|
2019-12-27 02:37:05 +00:00
|
|
|
case HitResult.Great:
|
|
|
|
return this.GetAnimation("mania-hit300", true, true);
|
2019-12-26 13:03:21 +00:00
|
|
|
|
2019-12-27 02:37:05 +00:00
|
|
|
case HitResult.Perfect:
|
|
|
|
return this.GetAnimation("mania-hit300g", true, true);
|
2019-12-26 13:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
|
|
|
|
|
|
|
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
|
|
|
|
|
|
|
|
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) =>
|
|
|
|
source.GetConfig<TLookup, TValue>(lookup);
|
|
|
|
}
|
|
|
|
}
|