2020-04-30 08:38:37 +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.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
2020-05-01 11:05:56 +00:00
|
|
|
using osu.Framework.Bindables;
|
2020-04-30 08:38:37 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-05-03 14:55:44 +00:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-05-01 11:05:56 +00:00
|
|
|
using osu.Game.Screens.Play;
|
2020-04-30 08:38:37 +00:00
|
|
|
using osu.Game.Skinning;
|
2020-05-01 10:49:30 +00:00
|
|
|
using osuTK;
|
2020-04-30 08:38:37 +00:00
|
|
|
|
2020-12-07 03:30:25 +00:00
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
2020-04-30 08:38:37 +00:00
|
|
|
{
|
|
|
|
public class LegacyTaikoScroller : CompositeDrawable
|
|
|
|
{
|
2020-05-13 10:19:58 +00:00
|
|
|
public Bindable<JudgementResult> LastResult = new Bindable<JudgementResult>();
|
|
|
|
|
2020-04-30 08:38:37 +00:00
|
|
|
public LegacyTaikoScroller()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
2020-05-01 11:05:56 +00:00
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
private void load(GameplayBeatmap gameplayBeatmap)
|
2020-05-01 10:49:30 +00:00
|
|
|
{
|
2020-05-01 11:05:56 +00:00
|
|
|
if (gameplayBeatmap != null)
|
2020-05-03 14:55:44 +00:00
|
|
|
((IBindable<JudgementResult>)LastResult).BindTo(gameplayBeatmap.LastJudgementResult);
|
2020-05-01 11:05:56 +00:00
|
|
|
}
|
2020-05-01 10:49:30 +00:00
|
|
|
|
2020-05-08 10:15:19 +00:00
|
|
|
private bool passing;
|
|
|
|
|
2020-05-01 11:05:56 +00:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2020-05-01 10:49:30 +00:00
|
|
|
|
2020-05-03 14:55:44 +00:00
|
|
|
LastResult.BindValueChanged(result =>
|
2020-05-01 11:05:56 +00:00
|
|
|
{
|
2020-05-08 10:13:41 +00:00
|
|
|
var r = result.NewValue;
|
|
|
|
|
2020-05-09 22:51:39 +00:00
|
|
|
// always ignore hitobjects that don't affect combo (drumroll ticks etc.)
|
2020-09-29 06:13:11 +00:00
|
|
|
if (r?.Type.AffectsCombo() == false)
|
2020-05-09 22:51:39 +00:00
|
|
|
return;
|
|
|
|
|
2020-10-02 20:57:49 +00:00
|
|
|
passing = r == null || r.IsHit;
|
2020-05-08 10:13:41 +00:00
|
|
|
|
2020-05-01 10:49:30 +00:00
|
|
|
foreach (var sprite in InternalChildren.OfType<ScrollerSprite>())
|
2020-05-08 10:13:41 +00:00
|
|
|
sprite.Passing = passing;
|
2020-05-01 11:05:56 +00:00
|
|
|
}, true);
|
2020-05-01 10:49:30 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 08:38:37 +00:00
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
2020-05-12 06:23:47 +00:00
|
|
|
// store X before checking wide enough so if we perform layout there is no positional discrepancy.
|
|
|
|
float currentX = (InternalChildren?.FirstOrDefault()?.X ?? 0) - (float)Clock.ElapsedFrameTime * 0.1f;
|
2020-04-30 08:38:37 +00:00
|
|
|
|
2020-05-12 06:23:47 +00:00
|
|
|
// ensure we have enough sprites
|
2020-05-13 10:19:58 +00:00
|
|
|
if (!InternalChildren.Any()
|
|
|
|
|| InternalChildren.First().ScreenSpaceDrawQuad.Width * InternalChildren.Count < ScreenSpaceDrawQuad.Width * 2)
|
2020-05-12 07:58:47 +00:00
|
|
|
AddInternal(new ScrollerSprite { Passing = passing });
|
2020-05-01 10:49:01 +00:00
|
|
|
|
2020-05-12 06:23:47 +00:00
|
|
|
var first = InternalChildren.First();
|
|
|
|
var last = InternalChildren.Last();
|
2020-05-01 10:49:01 +00:00
|
|
|
|
2020-05-12 06:23:47 +00: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 = currentX;
|
2020-05-12 06:44:14 +00:00
|
|
|
currentX += sprite.DrawWidth;
|
2020-05-12 06:23:47 +00:00
|
|
|
}
|
2020-05-01 10:49:01 +00:00
|
|
|
|
2020-05-12 06:23:47 +00:00
|
|
|
if (first.ScreenSpaceDrawQuad.TopLeft.X >= ScreenSpaceDrawQuad.TopLeft.X)
|
|
|
|
{
|
|
|
|
foreach (var internalChild in InternalChildren)
|
|
|
|
internalChild.X -= first.DrawWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (last.ScreenSpaceDrawQuad.TopRight.X <= ScreenSpaceDrawQuad.TopRight.X)
|
|
|
|
{
|
|
|
|
foreach (var internalChild in InternalChildren)
|
|
|
|
internalChild.X += first.DrawWidth;
|
2020-04-30 08:38:37 +00: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;
|
|
|
|
|
2020-05-09 22:52:54 +00:00
|
|
|
if (IsLoaded)
|
|
|
|
updatePassing();
|
2020-04-30 08:38:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(ISkinSource skin)
|
|
|
|
{
|
2020-05-01 10:49:23 +00:00
|
|
|
AutoSizeAxes = Axes.X;
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
FillMode = FillMode.Fit;
|
2020-04-30 08:38:37 +00: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-09 22:52:54 +00:00
|
|
|
|
|
|
|
updatePassing();
|
2020-04-30 08:38:37 +00:00
|
|
|
}
|
2020-05-01 10:49:23 +00:00
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
foreach (var c in InternalChildren)
|
|
|
|
c.Scale = new Vector2(DrawHeight / c.Height);
|
|
|
|
}
|
2020-05-09 22:52:54 +00:00
|
|
|
|
|
|
|
private void updatePassing()
|
|
|
|
{
|
|
|
|
if (passing)
|
|
|
|
{
|
|
|
|
passingSprite.Show();
|
|
|
|
failingSprite.FadeOut(200);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
failingSprite.FadeIn(200);
|
|
|
|
passingSprite.Delay(200).FadeOut();
|
|
|
|
}
|
|
|
|
}
|
2020-04-30 08:38:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|