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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-03-30 14:17:32 +00:00
|
|
|
using System;
|
2020-06-12 13:22:22 +00:00
|
|
|
using System.Collections.Generic;
|
2020-06-21 20:44:35 +00:00
|
|
|
using osu.Framework.Audio.Sample;
|
2020-12-07 03:32:52 +00:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
2020-06-21 20:44:35 +00:00
|
|
|
using osu.Game.Audio;
|
2022-10-05 10:21:38 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2020-12-07 03:32:52 +00:00
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
2020-06-21 20:44:35 +00:00
|
|
|
using osu.Game.Rulesets.Objects.Legacy;
|
2020-12-07 03:32:52 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Skinning;
|
2019-12-26 13:03:21 +00:00
|
|
|
|
2020-12-07 03:32:52 +00:00
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
2019-12-26 13:03:21 +00:00
|
|
|
{
|
2020-06-21 20:04:10 +00:00
|
|
|
public class ManiaLegacySkinTransformer : LegacySkinTransformer
|
2019-12-26 13:03:21 +00:00
|
|
|
{
|
2022-10-12 08:47:20 +00:00
|
|
|
public override bool IsProvidingLegacyResources => base.IsProvidingLegacyResources || hasKeyTexture.Value;
|
|
|
|
|
2020-06-12 13:22:22 +00:00
|
|
|
/// <summary>
|
2020-06-13 10:47:40 +00:00
|
|
|
/// Mapping of <see cref="HitResult"/> to their corresponding
|
2020-06-12 13:22:22 +00:00
|
|
|
/// <see cref="LegacyManiaSkinConfigurationLookups"/> value.
|
|
|
|
/// </summary>
|
2021-12-10 05:15:00 +00:00
|
|
|
private static readonly IReadOnlyDictionary<HitResult, LegacyManiaSkinConfigurationLookups> hit_result_mapping
|
2020-06-12 13:22:22 +00:00
|
|
|
= new Dictionary<HitResult, LegacyManiaSkinConfigurationLookups>
|
2020-06-13 03:31:34 +00:00
|
|
|
{
|
|
|
|
{ HitResult.Perfect, LegacyManiaSkinConfigurationLookups.Hit300g },
|
|
|
|
{ HitResult.Great, LegacyManiaSkinConfigurationLookups.Hit300 },
|
|
|
|
{ HitResult.Good, LegacyManiaSkinConfigurationLookups.Hit200 },
|
|
|
|
{ HitResult.Ok, LegacyManiaSkinConfigurationLookups.Hit100 },
|
|
|
|
{ HitResult.Meh, LegacyManiaSkinConfigurationLookups.Hit50 },
|
|
|
|
{ HitResult.Miss, LegacyManiaSkinConfigurationLookups.Hit0 }
|
|
|
|
};
|
2020-06-12 13:22:22 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Mapping of <see cref="HitResult"/> to their corresponding
|
|
|
|
/// default filenames.
|
|
|
|
/// </summary>
|
2021-12-10 05:15:00 +00:00
|
|
|
private static readonly IReadOnlyDictionary<HitResult, string> default_hit_result_skin_filenames
|
2020-06-12 13:22:22 +00:00
|
|
|
= new Dictionary<HitResult, string>
|
2020-06-13 03:31:34 +00:00
|
|
|
{
|
|
|
|
{ HitResult.Perfect, "mania-hit300g" },
|
|
|
|
{ HitResult.Great, "mania-hit300" },
|
|
|
|
{ HitResult.Good, "mania-hit200" },
|
|
|
|
{ HitResult.Ok, "mania-hit100" },
|
|
|
|
{ HitResult.Meh, "mania-hit50" },
|
|
|
|
{ HitResult.Miss, "mania-hit0" }
|
|
|
|
};
|
2020-06-12 13:22:22 +00:00
|
|
|
|
2021-06-09 10:34:42 +00:00
|
|
|
private readonly Lazy<bool> isLegacySkin;
|
2020-03-30 14:17:32 +00:00
|
|
|
|
2020-04-01 03:04:29 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Whether texture for the keys exists.
|
|
|
|
/// Used to determine if the mania ruleset is skinned.
|
|
|
|
/// </summary>
|
2021-06-09 10:34:42 +00:00
|
|
|
private readonly Lazy<bool> hasKeyTexture;
|
2020-04-01 03:04:29 +00:00
|
|
|
|
2022-10-05 10:21:38 +00:00
|
|
|
private readonly ManiaBeatmap beatmap;
|
|
|
|
|
|
|
|
public ManiaLegacySkinTransformer(ISkin skin, IBeatmap beatmap)
|
2021-06-09 10:34:42 +00:00
|
|
|
: base(skin)
|
2019-12-26 13:03:21 +00:00
|
|
|
{
|
2022-10-05 10:21:38 +00:00
|
|
|
this.beatmap = (ManiaBeatmap)beatmap;
|
|
|
|
|
2021-10-22 05:41:59 +00:00
|
|
|
isLegacySkin = new Lazy<bool>(() => GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version) != null);
|
2021-06-09 10:34:42 +00:00
|
|
|
hasKeyTexture = new Lazy<bool>(() =>
|
|
|
|
{
|
2022-10-06 05:10:39 +00:00
|
|
|
string keyImage = this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value ?? "mania-key1";
|
2021-06-11 09:44:44 +00:00
|
|
|
return this.GetAnimation(keyImage, true, true) != null;
|
2021-06-09 10:34:42 +00:00
|
|
|
});
|
2019-12-26 13:03:21 +00:00
|
|
|
}
|
|
|
|
|
2022-11-09 07:04:56 +00:00
|
|
|
public override Drawable GetDrawableComponent(ISkinComponentLookup lookup)
|
2019-12-26 13:03:21 +00:00
|
|
|
{
|
2022-11-09 05:11:41 +00:00
|
|
|
switch (lookup)
|
2019-12-26 13:03:21 +00:00
|
|
|
{
|
2022-11-09 07:04:56 +00:00
|
|
|
case GameplaySkinComponentLookup<HitResult> resultComponent:
|
2020-06-12 13:22:22 +00:00
|
|
|
return getResult(resultComponent.Component);
|
2020-03-30 14:17:32 +00:00
|
|
|
|
2022-11-09 07:04:56 +00:00
|
|
|
case ManiaSkinComponentLookup maniaComponent:
|
2020-06-13 10:45:06 +00:00
|
|
|
if (!isLegacySkin.Value || !hasKeyTexture.Value)
|
|
|
|
return null;
|
|
|
|
|
2020-03-30 14:14:30 +00:00
|
|
|
switch (maniaComponent.Component)
|
|
|
|
{
|
|
|
|
case ManiaSkinComponents.ColumnBackground:
|
2020-08-24 16:21:27 +00:00
|
|
|
return new LegacyColumnBackground();
|
2020-03-31 06:24:13 +00:00
|
|
|
|
2020-03-31 03:17:44 +00:00
|
|
|
case ManiaSkinComponents.HitTarget:
|
2020-08-24 16:21:27 +00:00
|
|
|
// Legacy skins sandwich the hit target between the column background and the column light.
|
|
|
|
// To preserve this ordering, it's created manually inside LegacyStageBackground.
|
2020-08-24 13:36:37 +00:00
|
|
|
return Drawable.Empty();
|
2020-03-31 06:24:13 +00:00
|
|
|
|
2020-03-31 02:23:33 +00:00
|
|
|
case ManiaSkinComponents.KeyArea:
|
|
|
|
return new LegacyKeyArea();
|
2020-03-31 06:29:25 +00:00
|
|
|
|
|
|
|
case ManiaSkinComponents.Note:
|
|
|
|
return new LegacyNotePiece();
|
|
|
|
|
|
|
|
case ManiaSkinComponents.HoldNoteHead:
|
|
|
|
return new LegacyHoldNoteHeadPiece();
|
|
|
|
|
|
|
|
case ManiaSkinComponents.HoldNoteTail:
|
|
|
|
return new LegacyHoldNoteTailPiece();
|
2020-03-31 07:42:35 +00:00
|
|
|
|
|
|
|
case ManiaSkinComponents.HoldNoteBody:
|
|
|
|
return new LegacyBodyPiece();
|
2020-04-02 05:29:16 +00:00
|
|
|
|
|
|
|
case ManiaSkinComponents.HitExplosion:
|
|
|
|
return new LegacyHitExplosion();
|
2020-04-08 06:08:13 +00:00
|
|
|
|
|
|
|
case ManiaSkinComponents.StageBackground:
|
2022-10-04 09:26:27 +00:00
|
|
|
return new LegacyStageBackground();
|
2020-04-08 07:20:26 +00:00
|
|
|
|
|
|
|
case ManiaSkinComponents.StageForeground:
|
|
|
|
return new LegacyStageForeground();
|
2020-03-30 14:14:30 +00:00
|
|
|
|
2023-08-15 04:33:49 +00:00
|
|
|
case ManiaSkinComponents.BarLine:
|
|
|
|
return null; // Not yet implemented.
|
|
|
|
|
2022-04-22 22:08:53 +00:00
|
|
|
default:
|
2022-11-09 05:11:41 +00:00
|
|
|
throw new UnsupportedSkinComponentException(lookup);
|
2022-04-22 22:08:53 +00:00
|
|
|
}
|
2019-12-27 02:37:05 +00:00
|
|
|
}
|
2021-05-30 10:15:59 +00:00
|
|
|
|
2022-11-09 05:11:41 +00:00
|
|
|
return base.GetDrawableComponent(lookup);
|
2019-12-27 02:37:05 +00:00
|
|
|
}
|
2019-12-26 13:03:21 +00:00
|
|
|
|
2020-06-12 13:22:22 +00:00
|
|
|
private Drawable getResult(HitResult result)
|
2019-12-27 02:37:05 +00:00
|
|
|
{
|
2021-12-10 05:15:00 +00:00
|
|
|
if (!hit_result_mapping.ContainsKey(result))
|
2020-09-29 05:29:43 +00:00
|
|
|
return null;
|
|
|
|
|
2022-10-06 05:10:39 +00:00
|
|
|
string filename = this.GetManiaSkinConfig<string>(hit_result_mapping[result])?.Value
|
2021-12-10 05:15:00 +00:00
|
|
|
?? default_hit_result_skin_filenames[result];
|
2019-12-26 13:03:21 +00:00
|
|
|
|
2020-12-14 04:07:55 +00:00
|
|
|
var animation = this.GetAnimation(filename, true, true);
|
|
|
|
return animation == null ? null : new LegacyManiaJudgementPiece(result, animation);
|
2019-12-26 13:03:21 +00:00
|
|
|
}
|
|
|
|
|
2021-02-18 09:32:28 +00:00
|
|
|
public override ISample GetSample(ISampleInfo sampleInfo)
|
2020-06-21 20:44:35 +00:00
|
|
|
{
|
|
|
|
// layered hit sounds never play in mania
|
|
|
|
if (sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample && legacySample.IsLayered)
|
2021-01-19 08:11:40 +00:00
|
|
|
return new SampleVirtual();
|
2020-06-21 20:44:35 +00:00
|
|
|
|
2021-06-11 09:44:44 +00:00
|
|
|
return base.GetSample(sampleInfo);
|
2020-06-21 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2020-06-21 20:04:10 +00:00
|
|
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
2020-04-02 09:39:49 +00:00
|
|
|
{
|
|
|
|
if (lookup is ManiaSkinConfigurationLookup maniaLookup)
|
2022-10-05 13:41:20 +00:00
|
|
|
{
|
2022-10-07 07:12:10 +00:00
|
|
|
return base.GetConfig<LegacyManiaSkinConfigurationLookup, TValue>(new LegacyManiaSkinConfigurationLookup(beatmap.TotalColumns, maniaLookup.Lookup, maniaLookup.ColumnIndex));
|
2022-10-05 13:41:20 +00:00
|
|
|
}
|
2020-04-02 09:39:49 +00:00
|
|
|
|
2021-06-11 09:44:44 +00:00
|
|
|
return base.GetConfig<TLookup, TValue>(lookup);
|
2020-04-02 09:39:49 +00:00
|
|
|
}
|
2019-12-26 13:03:21 +00:00
|
|
|
}
|
|
|
|
}
|