2019-12-26 21:03:21 +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.
|
|
|
|
|
2020-03-30 22:17:32 +08:00
|
|
|
using System;
|
2019-12-26 21:03:21 +08: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 22:17:32 +08:00
|
|
|
private Lazy<bool> isLegacySkin;
|
|
|
|
|
2020-04-01 11:04:29 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether texture for the keys exists.
|
|
|
|
/// Used to determine if the mania ruleset is skinned.
|
|
|
|
/// </summary>
|
|
|
|
private Lazy<bool> hasKeyTexture;
|
|
|
|
|
2020-03-30 22:17:32 +08:00
|
|
|
public ManiaLegacySkinTransformer(ISkinSource source)
|
2019-12-26 21:03:21 +08:00
|
|
|
{
|
|
|
|
this.source = source;
|
2020-03-30 22:17:32 +08:00
|
|
|
|
|
|
|
source.SourceChanged += sourceChanged;
|
|
|
|
sourceChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void sourceChanged()
|
|
|
|
{
|
|
|
|
isLegacySkin = new Lazy<bool>(() => source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
2020-04-01 14:17:23 +08:00
|
|
|
hasKeyTexture = new Lazy<bool>(() => source.GetAnimation(
|
2020-04-01 11:04:29 +08:00
|
|
|
source.GetConfig<LegacyManiaSkinConfigurationLookup, string>(
|
|
|
|
new LegacyManiaSkinConfigurationLookup(4, LegacyManiaSkinConfigurationLookups.KeyImage, 0))?.Value
|
2020-04-01 17:19:11 +08:00
|
|
|
?? "mania-key1", true, true) != null);
|
2019-12-26 21:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public Drawable GetDrawableComponent(ISkinComponent component)
|
|
|
|
{
|
|
|
|
switch (component)
|
|
|
|
{
|
|
|
|
case GameplaySkinComponent<HitResult> resultComponent:
|
2019-12-27 10:37:05 +08:00
|
|
|
return getResult(resultComponent);
|
2020-03-30 22:17:32 +08:00
|
|
|
|
2020-03-30 22:14:30 +08:00
|
|
|
case ManiaSkinComponent maniaComponent:
|
2020-04-01 11:04:29 +08:00
|
|
|
if (!isLegacySkin.Value || !hasKeyTexture.Value)
|
2020-03-30 22:17:32 +08:00
|
|
|
return null;
|
|
|
|
|
2020-03-30 22:14:30 +08:00
|
|
|
switch (maniaComponent.Component)
|
|
|
|
{
|
|
|
|
case ManiaSkinComponents.ColumnBackground:
|
|
|
|
return new LegacyColumnBackground();
|
2020-03-31 14:24:13 +08:00
|
|
|
|
2020-03-31 11:17:44 +08:00
|
|
|
case ManiaSkinComponents.HitTarget:
|
|
|
|
return new LegacyHitTarget();
|
2020-03-31 14:24:13 +08:00
|
|
|
|
2020-03-31 10:23:33 +08:00
|
|
|
case ManiaSkinComponents.KeyArea:
|
|
|
|
return new LegacyKeyArea();
|
2020-03-31 14:29:25 +08:00
|
|
|
|
|
|
|
case ManiaSkinComponents.Note:
|
|
|
|
return new LegacyNotePiece();
|
|
|
|
|
|
|
|
case ManiaSkinComponents.HoldNoteHead:
|
|
|
|
return new LegacyHoldNoteHeadPiece();
|
|
|
|
|
|
|
|
case ManiaSkinComponents.HoldNoteTail:
|
|
|
|
return new LegacyHoldNoteTailPiece();
|
2020-03-31 15:42:35 +08:00
|
|
|
|
|
|
|
case ManiaSkinComponents.HoldNoteBody:
|
|
|
|
return new LegacyBodyPiece();
|
2020-04-02 13:29:16 +08:00
|
|
|
|
|
|
|
case ManiaSkinComponents.HitExplosion:
|
|
|
|
return new LegacyHitExplosion();
|
2020-03-30 22:14:30 +08:00
|
|
|
}
|
|
|
|
|
2020-03-30 22:17:32 +08:00
|
|
|
break;
|
2019-12-27 10:37:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2019-12-26 21:03:21 +08:00
|
|
|
|
2019-12-27 10:37:05 +08:00
|
|
|
private Drawable getResult(GameplaySkinComponent<HitResult> resultComponent)
|
|
|
|
{
|
|
|
|
switch (resultComponent.Component)
|
|
|
|
{
|
|
|
|
case HitResult.Miss:
|
|
|
|
return this.GetAnimation("mania-hit0", true, true);
|
2019-12-26 21:03:21 +08:00
|
|
|
|
2019-12-27 10:37:05 +08:00
|
|
|
case HitResult.Meh:
|
|
|
|
return this.GetAnimation("mania-hit50", true, true);
|
2019-12-26 21:03:21 +08:00
|
|
|
|
2019-12-27 10:37:05 +08:00
|
|
|
case HitResult.Ok:
|
|
|
|
return this.GetAnimation("mania-hit100", true, true);
|
2019-12-26 21:03:21 +08:00
|
|
|
|
2019-12-27 10:37:05 +08:00
|
|
|
case HitResult.Good:
|
|
|
|
return this.GetAnimation("mania-hit200", true, true);
|
2019-12-26 21:03:21 +08:00
|
|
|
|
2019-12-27 10:37:05 +08:00
|
|
|
case HitResult.Great:
|
|
|
|
return this.GetAnimation("mania-hit300", true, true);
|
2019-12-26 21:03:21 +08:00
|
|
|
|
2019-12-27 10:37:05 +08:00
|
|
|
case HitResult.Perfect:
|
|
|
|
return this.GetAnimation("mania-hit300g", true, true);
|
2019-12-26 21:03:21 +08: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);
|
|
|
|
}
|
|
|
|
}
|