2020-01-02 05:26:32 +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-04-28 02:08:19 +00:00
|
|
|
using System;
|
2020-01-02 05:26:32 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Audio.Sample;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Audio;
|
2020-10-07 09:36:34 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-04-22 13:19:29 +00:00
|
|
|
using osu.Game.Rulesets.Taiko.UI;
|
2020-01-02 05:26:32 +00:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
2020-12-07 03:30:25 +00:00
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
2020-01-02 05:26:32 +00:00
|
|
|
{
|
2020-06-21 20:04:10 +00:00
|
|
|
public class TaikoLegacySkinTransformer : LegacySkinTransformer
|
2020-01-02 05:26:32 +00:00
|
|
|
{
|
2022-10-12 08:47:20 +00:00
|
|
|
public override bool IsProvidingLegacyResources => base.IsProvidingLegacyResources || hasHitCircle || hasBarLeft;
|
|
|
|
|
2021-06-09 10:34:42 +00:00
|
|
|
private readonly Lazy<bool> hasExplosion;
|
2020-10-07 09:36:34 +00:00
|
|
|
|
2022-10-12 08:47:20 +00:00
|
|
|
private bool hasHitCircle => GetTexture("taikohitcircle") != null;
|
|
|
|
private bool hasBarLeft => GetTexture("taiko-bar-left") != null;
|
|
|
|
|
2021-06-09 10:34:42 +00:00
|
|
|
public TaikoLegacySkinTransformer(ISkin skin)
|
|
|
|
: base(skin)
|
2020-01-02 05:26:32 +00:00
|
|
|
{
|
2021-06-11 09:44:44 +00:00
|
|
|
hasExplosion = new Lazy<bool>(() => GetTexture(getHitName(TaikoSkinComponents.TaikoExplosionGreat)) != null);
|
2020-01-02 05:26:32 +00:00
|
|
|
}
|
|
|
|
|
2022-11-09 07:04:56 +00:00
|
|
|
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
2022-11-09 07:04:56 +00:00
|
|
|
if (lookup is GameplaySkinComponentLookup<HitResult>)
|
2020-10-07 09:36:34 +00:00
|
|
|
{
|
|
|
|
// if a taiko skin is providing explosion sprites, hide the judgements completely
|
|
|
|
if (hasExplosion.Value)
|
2021-03-06 17:54:25 +00:00
|
|
|
return Drawable.Empty().With(d => d.Expire());
|
2020-10-07 09:36:34 +00:00
|
|
|
}
|
|
|
|
|
2022-11-09 07:04:56 +00:00
|
|
|
if (lookup is TaikoSkinComponentLookup taikoComponent)
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
2021-05-30 10:15:59 +00:00
|
|
|
switch (taikoComponent.Component)
|
|
|
|
{
|
|
|
|
case TaikoSkinComponents.DrumRollBody:
|
|
|
|
if (GetTexture("taiko-roll-middle") != null)
|
|
|
|
return new LegacyDrumRoll();
|
2020-04-15 08:50:57 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-04-03 09:23:03 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.InputDrum:
|
2022-10-12 08:47:20 +00:00
|
|
|
if (hasBarLeft)
|
2021-05-30 10:15:59 +00:00
|
|
|
return new LegacyInputDrum();
|
2020-04-03 09:23:03 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-04-11 05:20:09 +00:00
|
|
|
|
2023-06-30 06:07:07 +00:00
|
|
|
case TaikoSkinComponents.DrumSamplePlayer:
|
|
|
|
return null;
|
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.CentreHit:
|
|
|
|
case TaikoSkinComponents.RimHit:
|
2022-10-12 08:47:20 +00:00
|
|
|
if (hasHitCircle)
|
2021-05-30 10:15:59 +00:00
|
|
|
return new LegacyHit(taikoComponent.Component);
|
2020-04-15 10:24:50 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-04-21 10:00:34 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.DrumRollTick:
|
|
|
|
return this.GetAnimation("sliderscorepoint", false, false);
|
2020-04-21 10:00:34 +00:00
|
|
|
|
2022-04-22 22:08:53 +00:00
|
|
|
case TaikoSkinComponents.Swell:
|
|
|
|
// todo: support taiko legacy swell (https://github.com/ppy/osu/issues/13601).
|
|
|
|
return null;
|
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.HitTarget:
|
|
|
|
if (GetTexture("taikobigcircle") != null)
|
|
|
|
return new TaikoLegacyHitTarget();
|
2020-04-23 03:33:34 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-04-23 03:33:34 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.PlayfieldBackgroundRight:
|
|
|
|
if (GetTexture("taiko-bar-right") != null)
|
|
|
|
return new TaikoLegacyPlayfieldBackgroundRight();
|
2020-04-23 03:33:34 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-04-21 10:00:34 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.PlayfieldBackgroundLeft:
|
|
|
|
// This is displayed inside LegacyInputDrum. It is required to be there for layout purposes (can be seen on legacy skins).
|
|
|
|
if (GetTexture("taiko-bar-right") != null)
|
|
|
|
return Drawable.Empty();
|
2020-04-03 09:23:03 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-04-23 05:32:48 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.BarLine:
|
|
|
|
if (GetTexture("taiko-barline") != null)
|
|
|
|
return new LegacyBarLine();
|
2020-04-03 09:23:03 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-09-27 13:33:18 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.TaikoExplosionMiss:
|
|
|
|
var missSprite = this.GetAnimation(getHitName(taikoComponent.Component), true, false);
|
|
|
|
if (missSprite != null)
|
|
|
|
return new LegacyHitExplosion(missSprite);
|
2020-09-27 13:33:18 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-04-27 13:22:32 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.TaikoExplosionOk:
|
|
|
|
case TaikoSkinComponents.TaikoExplosionGreat:
|
2021-10-27 04:04:41 +00:00
|
|
|
string hitName = getHitName(taikoComponent.Component);
|
2021-05-30 10:15:59 +00:00
|
|
|
var hitSprite = this.GetAnimation(hitName, true, false);
|
2020-10-07 09:36:34 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
if (hitSprite != null)
|
|
|
|
{
|
|
|
|
var strongHitSprite = this.GetAnimation($"{hitName}k", true, false);
|
2020-04-27 13:22:32 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return new LegacyHitExplosion(hitSprite, strongHitSprite);
|
|
|
|
}
|
2020-04-28 21:46:42 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-11-10 13:08:27 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.TaikoExplosionKiai:
|
|
|
|
// suppress the default kiai explosion if the skin brings its own sprites.
|
|
|
|
// the drawable needs to expire as soon as possible to avoid accumulating empty drawables on the playfield.
|
|
|
|
if (hasExplosion.Value)
|
|
|
|
return Drawable.Empty().With(d => d.Expire());
|
2020-11-10 13:08:27 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-04-30 08:38:37 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.Scroller:
|
|
|
|
if (GetTexture("taiko-slider") != null)
|
|
|
|
return new LegacyTaikoScroller();
|
2020-05-11 05:13:06 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
return null;
|
2020-04-03 09:23:03 +00:00
|
|
|
|
2021-05-30 10:15:59 +00:00
|
|
|
case TaikoSkinComponents.Mascot:
|
|
|
|
return new DrawableTaikoMascot();
|
2022-04-22 22:08:53 +00:00
|
|
|
|
2022-11-29 23:44:20 +00:00
|
|
|
case TaikoSkinComponents.KiaiGlow:
|
|
|
|
if (GetTexture("taiko-glow") != null)
|
|
|
|
return new LegacyKiaiGlow();
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
2022-04-22 22:08:53 +00:00
|
|
|
default:
|
2022-11-09 05:11:41 +00:00
|
|
|
throw new UnsupportedSkinComponentException(lookup);
|
2021-05-30 10:15:59 +00:00
|
|
|
}
|
2021-05-27 02:15:29 +00:00
|
|
|
}
|
2021-05-30 10:15:59 +00:00
|
|
|
|
2022-11-09 05:11:41 +00:00
|
|
|
return base.GetDrawableComponent(lookup);
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
2020-01-02 05:26:32 +00:00
|
|
|
|
2020-04-28 02:08:19 +00:00
|
|
|
private string getHitName(TaikoSkinComponents component)
|
2020-04-27 13:22:32 +00:00
|
|
|
{
|
|
|
|
switch (component)
|
|
|
|
{
|
|
|
|
case TaikoSkinComponents.TaikoExplosionMiss:
|
|
|
|
return "taiko-hit0";
|
|
|
|
|
2020-09-29 08:16:55 +00:00
|
|
|
case TaikoSkinComponents.TaikoExplosionOk:
|
2020-04-27 13:22:32 +00:00
|
|
|
return "taiko-hit100";
|
2020-04-22 13:19:29 +00:00
|
|
|
|
2020-04-27 13:22:32 +00:00
|
|
|
case TaikoSkinComponents.TaikoExplosionGreat:
|
|
|
|
return "taiko-hit300";
|
2020-04-22 13:19:29 +00:00
|
|
|
}
|
2020-04-27 13:22:32 +00:00
|
|
|
|
2020-09-27 13:33:18 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(component), $"Invalid component type: {component}");
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
2020-01-02 05:26:32 +00:00
|
|
|
|
2022-07-30 06:33:23 +00:00
|
|
|
public override ISample? GetSample(ISampleInfo sampleInfo)
|
2021-06-01 09:56:22 +00:00
|
|
|
{
|
|
|
|
if (sampleInfo is HitSampleInfo hitSampleInfo)
|
2021-06-11 09:44:44 +00:00
|
|
|
return base.GetSample(new LegacyTaikoSampleInfo(hitSampleInfo));
|
2021-06-01 09:56:22 +00:00
|
|
|
|
|
|
|
return base.GetSample(sampleInfo);
|
|
|
|
}
|
2020-01-02 05:26:32 +00:00
|
|
|
|
2021-06-01 09:56:22 +00:00
|
|
|
private class LegacyTaikoSampleInfo : HitSampleInfo
|
2020-01-02 05:26:32 +00:00
|
|
|
{
|
2021-06-01 09:56:22 +00:00
|
|
|
public LegacyTaikoSampleInfo(HitSampleInfo sampleInfo)
|
|
|
|
: base(sampleInfo.Name, sampleInfo.Bank, sampleInfo.Suffix, sampleInfo.Volume)
|
2020-01-02 05:26:32 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-01 09:56:22 +00:00
|
|
|
public override IEnumerable<string> LookupNames
|
2020-01-02 05:26:32 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2021-10-27 04:04:41 +00:00
|
|
|
foreach (string name in base.LookupNames)
|
2020-10-30 02:52:08 +00:00
|
|
|
yield return name.Insert(name.LastIndexOf('/') + 1, "taiko-");
|
2020-01-02 05:26:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|