2020-01-02 13:26:32 +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-04-28 10:08:19 +08:00
|
|
|
using System;
|
2020-01-02 13:26:32 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Audio.Sample;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Audio;
|
2020-10-07 17:36:34 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-04-22 21:19:29 +08:00
|
|
|
using osu.Game.Rulesets.Taiko.UI;
|
2020-01-02 13:26:32 +08:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning
|
|
|
|
{
|
2020-06-22 04:04:10 +08:00
|
|
|
public class TaikoLegacySkinTransformer : LegacySkinTransformer
|
2020-01-02 13:26:32 +08:00
|
|
|
{
|
2020-10-07 17:36:34 +08:00
|
|
|
private Lazy<bool> hasExplosion;
|
|
|
|
|
2020-01-02 13:26:32 +08:00
|
|
|
public TaikoLegacySkinTransformer(ISkinSource source)
|
2020-06-22 04:04:10 +08:00
|
|
|
: base(source)
|
2020-01-02 13:26:32 +08:00
|
|
|
{
|
2020-10-07 17:36:34 +08:00
|
|
|
Source.SourceChanged += sourceChanged;
|
|
|
|
sourceChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void sourceChanged()
|
|
|
|
{
|
|
|
|
hasExplosion = new Lazy<bool>(() => Source.GetTexture(getHitName(TaikoSkinComponents.TaikoExplosionGreat)) != null);
|
2020-01-02 13:26:32 +08:00
|
|
|
}
|
|
|
|
|
2020-06-22 04:04:10 +08:00
|
|
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
2020-04-03 17:23:03 +08:00
|
|
|
{
|
2020-10-07 17:36:34 +08:00
|
|
|
if (component is GameplaySkinComponent<HitResult>)
|
|
|
|
{
|
|
|
|
// if a taiko skin is providing explosion sprites, hide the judgements completely
|
|
|
|
if (hasExplosion.Value)
|
|
|
|
return Drawable.Empty();
|
|
|
|
}
|
|
|
|
|
2020-04-03 17:23:03 +08:00
|
|
|
if (!(component is TaikoSkinComponent taikoComponent))
|
|
|
|
return null;
|
|
|
|
|
|
|
|
switch (taikoComponent.Component)
|
|
|
|
{
|
2020-04-15 16:50:57 +08:00
|
|
|
case TaikoSkinComponents.DrumRollBody:
|
|
|
|
if (GetTexture("taiko-roll-middle") != null)
|
|
|
|
return new LegacyDrumRoll();
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
2020-04-03 17:23:03 +08:00
|
|
|
case TaikoSkinComponents.InputDrum:
|
|
|
|
if (GetTexture("taiko-bar-left") != null)
|
|
|
|
return new LegacyInputDrum();
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
2020-04-11 13:20:09 +08:00
|
|
|
case TaikoSkinComponents.CentreHit:
|
|
|
|
case TaikoSkinComponents.RimHit:
|
|
|
|
|
|
|
|
if (GetTexture("taikohitcircle") != null)
|
|
|
|
return new LegacyHit(taikoComponent.Component);
|
|
|
|
|
|
|
|
return null;
|
2020-04-15 18:24:50 +08:00
|
|
|
|
|
|
|
case TaikoSkinComponents.DrumRollTick:
|
|
|
|
return this.GetAnimation("sliderscorepoint", false, false);
|
2020-04-21 18:00:34 +08:00
|
|
|
|
|
|
|
case TaikoSkinComponents.HitTarget:
|
|
|
|
if (GetTexture("taikobigcircle") != null)
|
2020-04-23 11:10:26 +08:00
|
|
|
return new TaikoLegacyHitTarget();
|
2020-04-21 18:00:34 +08:00
|
|
|
|
|
|
|
return null;
|
2020-04-23 11:33:34 +08:00
|
|
|
|
|
|
|
case TaikoSkinComponents.PlayfieldBackgroundRight:
|
|
|
|
if (GetTexture("taiko-bar-right") != null)
|
2020-04-30 15:42:38 +08:00
|
|
|
return new TaikoLegacyPlayfieldBackgroundRight();
|
2020-04-23 11:33:34 +08:00
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
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-21 18:00:34 +08:00
|
|
|
|
|
|
|
return null;
|
2020-04-03 17:23:03 +08:00
|
|
|
|
2020-04-23 13:32:48 +08:00
|
|
|
case TaikoSkinComponents.BarLine:
|
|
|
|
if (GetTexture("taiko-barline") != null)
|
|
|
|
return new LegacyBarLine();
|
|
|
|
|
|
|
|
return null;
|
2020-04-03 17:23:03 +08:00
|
|
|
|
2020-09-27 21:33:18 +08:00
|
|
|
case TaikoSkinComponents.TaikoExplosionMiss:
|
|
|
|
|
|
|
|
var missSprite = this.GetAnimation(getHitName(taikoComponent.Component), true, false);
|
|
|
|
if (missSprite != null)
|
|
|
|
return new LegacyHitExplosion(missSprite);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
2020-09-29 16:16:55 +08:00
|
|
|
case TaikoSkinComponents.TaikoExplosionOk:
|
2020-04-27 21:22:32 +08:00
|
|
|
case TaikoSkinComponents.TaikoExplosionGreat:
|
|
|
|
|
2020-09-27 21:33:18 +08:00
|
|
|
var hitName = getHitName(taikoComponent.Component);
|
|
|
|
var hitSprite = this.GetAnimation(hitName, true, false);
|
|
|
|
|
|
|
|
if (hitSprite != null)
|
2020-10-07 17:36:34 +08:00
|
|
|
{
|
|
|
|
var strongHitSprite = this.GetAnimation($"{hitName}k", true, false);
|
|
|
|
|
2020-09-27 21:33:18 +08:00
|
|
|
return new LegacyHitExplosion(hitSprite, strongHitSprite);
|
2020-10-07 17:36:34 +08:00
|
|
|
}
|
2020-04-27 21:22:32 +08:00
|
|
|
|
|
|
|
return null;
|
2020-04-29 05:46:42 +08:00
|
|
|
|
2020-11-10 21:08:27 +08:00
|
|
|
case TaikoSkinComponents.TaikoExplosionKiai:
|
|
|
|
// suppress the default kiai explosion if the skin brings its own sprites.
|
2020-11-10 21:50:19 +08:00
|
|
|
// the drawable needs to expire as soon as possible to avoid accumulating empty drawables on the playfield.
|
2020-11-10 21:08:27 +08:00
|
|
|
if (hasExplosion.Value)
|
2020-11-11 16:11:33 +08:00
|
|
|
return Drawable.Empty().With(d => d.LifetimeEnd = double.MinValue);
|
2020-11-10 21:08:27 +08:00
|
|
|
|
|
|
|
return null;
|
|
|
|
|
2020-05-14 09:02:47 +08:00
|
|
|
case TaikoSkinComponents.Scroller:
|
2020-04-30 16:38:37 +08:00
|
|
|
if (GetTexture("taiko-slider") != null)
|
|
|
|
return new LegacyTaikoScroller();
|
|
|
|
|
2020-05-11 13:13:06 +08:00
|
|
|
return null;
|
|
|
|
|
2020-05-14 09:02:47 +08:00
|
|
|
case TaikoSkinComponents.Mascot:
|
2020-07-25 18:03:54 +08:00
|
|
|
return new DrawableTaikoMascot();
|
2020-04-03 17:23:03 +08:00
|
|
|
}
|
|
|
|
|
2020-06-22 04:04:10 +08:00
|
|
|
return Source.GetDrawableComponent(component);
|
2020-04-03 17:23:03 +08:00
|
|
|
}
|
2020-01-02 13:26:32 +08:00
|
|
|
|
2020-04-28 10:08:19 +08:00
|
|
|
private string getHitName(TaikoSkinComponents component)
|
2020-04-27 21:22:32 +08:00
|
|
|
{
|
|
|
|
switch (component)
|
|
|
|
{
|
|
|
|
case TaikoSkinComponents.TaikoExplosionMiss:
|
|
|
|
return "taiko-hit0";
|
|
|
|
|
2020-09-29 16:16:55 +08:00
|
|
|
case TaikoSkinComponents.TaikoExplosionOk:
|
2020-04-27 21:22:32 +08:00
|
|
|
return "taiko-hit100";
|
2020-04-22 21:19:29 +08:00
|
|
|
|
2020-04-27 21:22:32 +08:00
|
|
|
case TaikoSkinComponents.TaikoExplosionGreat:
|
|
|
|
return "taiko-hit300";
|
2020-04-22 21:19:29 +08:00
|
|
|
}
|
2020-04-27 21:22:32 +08:00
|
|
|
|
2020-09-27 21:33:18 +08:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(component), $"Invalid component type: {component}");
|
2020-04-03 17:23:03 +08:00
|
|
|
}
|
2020-01-02 13:26:32 +08:00
|
|
|
|
2020-06-22 04:04:10 +08:00
|
|
|
public override SampleChannel GetSample(ISampleInfo sampleInfo) => Source.GetSample(new LegacyTaikoSampleInfo(sampleInfo));
|
2020-01-02 13:26:32 +08:00
|
|
|
|
2020-06-22 04:04:10 +08:00
|
|
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Source.GetConfig<TLookup, TValue>(lookup);
|
2020-01-02 13:26:32 +08:00
|
|
|
|
|
|
|
private class LegacyTaikoSampleInfo : ISampleInfo
|
|
|
|
{
|
|
|
|
private readonly ISampleInfo source;
|
|
|
|
|
|
|
|
public LegacyTaikoSampleInfo(ISampleInfo source)
|
|
|
|
{
|
|
|
|
this.source = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<string> LookupNames
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
foreach (var name in source.LookupNames)
|
2020-10-30 10:52:08 +08:00
|
|
|
yield return name.Insert(name.LastIndexOf('/') + 1, "taiko-");
|
2020-01-02 13:26:32 +08:00
|
|
|
|
|
|
|
foreach (var name in source.LookupNames)
|
|
|
|
yield return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int Volume => source.Volume;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|