2020-04-30 16:38:37 +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.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
2020-05-01 19:05:56 +08:00
|
|
|
using osu.Framework.Bindables;
|
2020-04-30 16:38:37 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-05-03 22:55:44 +08:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-05-01 19:05:56 +08:00
|
|
|
using osu.Game.Screens.Play;
|
2020-04-30 16:38:37 +08:00
|
|
|
using osu.Game.Skinning;
|
2020-05-01 18:49:30 +08:00
|
|
|
using osuTK;
|
2020-04-30 16:38:37 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning
|
|
|
|
{
|
|
|
|
public class LegacyTaikoScroller : CompositeDrawable
|
|
|
|
{
|
|
|
|
public LegacyTaikoScroller()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
2020-05-01 19:05:56 +08:00
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
private void load(GameplayBeatmap gameplayBeatmap)
|
2020-05-01 18:49:30 +08:00
|
|
|
{
|
2020-05-01 19:05:56 +08:00
|
|
|
if (gameplayBeatmap != null)
|
2020-05-03 22:55:44 +08:00
|
|
|
((IBindable<JudgementResult>)LastResult).BindTo(gameplayBeatmap.LastJudgementResult);
|
2020-05-01 19:05:56 +08:00
|
|
|
}
|
2020-05-01 18:49:30 +08:00
|
|
|
|
2020-05-08 18:15:19 +08:00
|
|
|
private bool passing;
|
|
|
|
|
2020-05-01 19:05:56 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2020-05-01 18:49:30 +08:00
|
|
|
|
2020-05-03 22:55:44 +08:00
|
|
|
LastResult.BindValueChanged(result =>
|
2020-05-01 19:05:56 +08:00
|
|
|
{
|
2020-05-08 18:13:41 +08:00
|
|
|
var r = result.NewValue;
|
|
|
|
|
2020-05-10 06:51:39 +08:00
|
|
|
// always ignore hitobjects that don't affect combo (drumroll ticks etc.)
|
|
|
|
if (r?.Judgement.AffectsCombo == false)
|
|
|
|
return;
|
|
|
|
|
|
|
|
passing = r == null || r.Type > HitResult.Miss;
|
2020-05-08 18:13:41 +08:00
|
|
|
|
2020-05-01 18:49:30 +08:00
|
|
|
foreach (var sprite in InternalChildren.OfType<ScrollerSprite>())
|
2020-05-08 18:13:41 +08:00
|
|
|
sprite.Passing = passing;
|
2020-05-01 19:05:56 +08:00
|
|
|
}, true);
|
2020-05-01 18:49:30 +08:00
|
|
|
}
|
|
|
|
|
2020-05-03 22:55:44 +08:00
|
|
|
public Bindable<JudgementResult> LastResult = new Bindable<JudgementResult>();
|
2020-05-01 19:05:56 +08:00
|
|
|
|
2020-04-30 16:38:37 +08:00
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
2020-05-01 18:49:01 +08:00
|
|
|
while (true)
|
2020-04-30 16:38:37 +08:00
|
|
|
{
|
2020-05-01 18:49:01 +08:00
|
|
|
float? additiveX = null;
|
2020-04-30 16:38:37 +08:00
|
|
|
|
2020-05-01 18:49:01 +08:00
|
|
|
foreach (var sprite in InternalChildren)
|
|
|
|
{
|
|
|
|
// add the x coordinates and perform re-layout on all sprites as spacing may change with gameplay scale.
|
|
|
|
sprite.X = additiveX ??= sprite.X - (float)Time.Elapsed * 0.1f;
|
2020-04-30 16:38:37 +08:00
|
|
|
|
2020-05-01 18:49:01 +08:00
|
|
|
additiveX += sprite.DrawWidth - 1;
|
2020-04-30 16:38:37 +08:00
|
|
|
|
2020-05-01 18:49:01 +08:00
|
|
|
if (sprite.X + sprite.DrawWidth < 0)
|
|
|
|
sprite.Expire();
|
|
|
|
}
|
|
|
|
|
|
|
|
var last = InternalChildren.LastOrDefault();
|
|
|
|
|
|
|
|
// only break from this loop once we have saturated horizontal space completely.
|
|
|
|
if (last != null && last.ScreenSpaceDrawQuad.TopRight.X >= ScreenSpaceDrawQuad.TopRight.X)
|
|
|
|
break;
|
|
|
|
|
2020-05-08 18:15:19 +08:00
|
|
|
AddInternal(new ScrollerSprite
|
|
|
|
{
|
|
|
|
Passing = passing
|
|
|
|
});
|
2020-04-30 16:38:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class ScrollerSprite : CompositeDrawable
|
|
|
|
{
|
|
|
|
private Sprite passingSprite;
|
|
|
|
private Sprite failingSprite;
|
|
|
|
|
|
|
|
private bool passing = true;
|
|
|
|
|
|
|
|
public bool Passing
|
|
|
|
{
|
|
|
|
get => passing;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == passing)
|
|
|
|
return;
|
|
|
|
|
|
|
|
passing = value;
|
|
|
|
|
|
|
|
if (passing)
|
|
|
|
{
|
|
|
|
passingSprite.Show();
|
|
|
|
failingSprite.FadeOut(200);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
failingSprite.FadeIn(200);
|
|
|
|
passingSprite.Delay(200).FadeOut();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(ISkinSource skin)
|
|
|
|
{
|
2020-05-01 18:49:23 +08:00
|
|
|
AutoSizeAxes = Axes.X;
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
FillMode = FillMode.Fit;
|
2020-04-30 16:38:37 +08:00
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
passingSprite = new Sprite { Texture = skin.GetTexture("taiko-slider") },
|
|
|
|
failingSprite = new Sprite { Texture = skin.GetTexture("taiko-slider-fail"), Alpha = 0 },
|
|
|
|
};
|
|
|
|
}
|
2020-05-01 18:49:23 +08:00
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
foreach (var c in InternalChildren)
|
|
|
|
c.Scale = new Vector2(DrawHeight / c.Height);
|
|
|
|
}
|
2020-04-30 16:38:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|