2019-01-24 08:43:03 +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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-09-19 16:30:25 +00:00
|
|
|
|
using System.Linq;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2018-09-19 16:30:25 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2018-09-19 16:30:25 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2020-04-24 16:15:59 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2018-09-19 16:30:25 +00:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Judgements;
|
2020-03-23 03:08:15 +00:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
2020-04-21 10:00:34 +00:00
|
|
|
|
using osu.Game.Skinning;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.UI
|
|
|
|
|
{
|
|
|
|
|
public class TaikoPlayfield : ScrollingPlayfield
|
|
|
|
|
{
|
2020-04-23 03:33:34 +00:00
|
|
|
|
private readonly ControlPointInfo controlPoints;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
/// <summary>
|
2019-03-19 14:44:15 +00:00
|
|
|
|
/// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="DrawableTaikoRuleset"/>.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
public const float DEFAULT_HEIGHT = 178;
|
|
|
|
|
|
2020-04-23 03:33:34 +00:00
|
|
|
|
private Container<HitExplosion> hitExplosionContainer;
|
|
|
|
|
private Container<KiaiHitExplosion> kiaiExplosionContainer;
|
|
|
|
|
private JudgementContainer<DrawableTaikoJudgement> judgementContainer;
|
2020-04-25 05:31:50 +00:00
|
|
|
|
private ScrollingHitObjectContainer drumRollHitContainer;
|
2020-04-23 03:33:34 +00:00
|
|
|
|
internal Drawable HitTarget;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-04-23 03:33:34 +00:00
|
|
|
|
private ProxyContainer topLevelHitContainer;
|
|
|
|
|
private ProxyContainer barlineContainer;
|
|
|
|
|
private Container rightArea;
|
|
|
|
|
private Container leftArea;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-04-23 03:33:34 +00:00
|
|
|
|
private Container hitTargetOffsetContent;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
public TaikoPlayfield(ControlPointInfo controlPoints)
|
|
|
|
|
{
|
2020-04-23 03:33:34 +00:00
|
|
|
|
this.controlPoints = controlPoints;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-04-25 05:47:20 +00:00
|
|
|
|
InternalChildren = new[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-04-23 04:23:49 +00:00
|
|
|
|
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundRight), _ => new PlayfieldBackgroundRight()),
|
2020-04-23 03:33:34 +00:00
|
|
|
|
rightArea = new Container
|
2019-03-26 04:31:49 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Right area",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-23 03:33:34 +00:00
|
|
|
|
RelativePositionAxes = Axes.Both,
|
2019-03-26 04:31:49 +00:00
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-03-26 04:31:49 +00:00
|
|
|
|
new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-03-26 04:31:49 +00:00
|
|
|
|
Name = "Masked elements before hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-23 03:33:34 +00:00
|
|
|
|
FillMode = FillMode.Fit,
|
2020-04-21 10:00:34 +00:00
|
|
|
|
Children = new[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-03-26 04:31:49 +00:00
|
|
|
|
hitExplosionContainer = new Container<HitExplosion>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-08-21 04:29:50 +00:00
|
|
|
|
Blending = BlendingParameters.Additive,
|
2019-03-26 04:31:49 +00:00
|
|
|
|
},
|
2020-04-23 03:10:26 +00:00
|
|
|
|
HitTarget = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.HitTarget), _ => new TaikoHitTarget())
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-03-26 04:31:49 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
2019-03-26 04:31:49 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-04-23 03:33:34 +00:00
|
|
|
|
hitTargetOffsetContent = new Container
|
2019-03-26 04:31:49 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-22 14:50:00 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-04-23 03:33:34 +00:00
|
|
|
|
barlineContainer = new ProxyContainer
|
2020-04-22 14:50:00 +00:00
|
|
|
|
{
|
2020-04-23 03:33:34 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-25 05:31:50 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
HitObjectContainer,
|
|
|
|
|
drumRollHitContainer = new ScrollingHitObjectContainer
|
|
|
|
|
{
|
|
|
|
|
Name = "Drumroll hit"
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-23 03:33:34 +00:00
|
|
|
|
},
|
|
|
|
|
kiaiExplosionContainer = new Container<KiaiHitExplosion>
|
|
|
|
|
{
|
|
|
|
|
Name = "Kiai hit explosions",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
Blending = BlendingParameters.Additive
|
|
|
|
|
},
|
|
|
|
|
judgementContainer = new JudgementContainer<DrawableTaikoJudgement>
|
|
|
|
|
{
|
|
|
|
|
Name = "Judgements",
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Blending = BlendingParameters.Additive
|
|
|
|
|
},
|
2020-04-22 14:50:00 +00:00
|
|
|
|
}
|
2019-03-26 04:31:49 +00:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-04-23 03:33:34 +00:00
|
|
|
|
leftArea = new Container
|
2019-03-26 04:31:49 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Left overlay",
|
2020-04-23 03:33:34 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
BorderColour = colours.Gray0,
|
2019-03-26 04:31:49 +00:00
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-04-23 04:23:49 +00:00
|
|
|
|
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
2019-03-26 04:31:49 +00:00
|
|
|
|
new InputDrum(controlPoints)
|
|
|
|
|
{
|
2020-04-23 03:33:34 +00:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2019-03-26 04:31:49 +00:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-08-28 04:20:28 +00:00
|
|
|
|
topLevelHitContainer = new ProxyContainer
|
2019-03-26 04:31:49 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Top level hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-23 10:15:12 +00:00
|
|
|
|
},
|
|
|
|
|
drumRollHitContainer.CreateProxy()
|
2018-09-21 06:08:43 +00:00
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-23 03:33:34 +00:00
|
|
|
|
protected override void Update()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-04-23 03:33:34 +00:00
|
|
|
|
base.Update();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-04-23 03:47:57 +00:00
|
|
|
|
// Padding is required to be updated for elements which are based on "absolute" X sized elements.
|
|
|
|
|
// This is basically allowing for correct alignment as relative pieces move around them.
|
2020-04-23 03:33:34 +00:00
|
|
|
|
rightArea.Padding = new MarginPadding { Left = leftArea.DrawWidth };
|
|
|
|
|
hitTargetOffsetContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
2020-04-25 05:31:50 +00:00
|
|
|
|
|
|
|
|
|
// When rewinding, make sure to remove any auxilliary hit notes that were
|
|
|
|
|
// spawned and played during a drumroll.
|
|
|
|
|
if (Time.Elapsed < 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var o in drumRollHitContainer.Objects)
|
|
|
|
|
{
|
|
|
|
|
if (o.HitObject.StartTime >= Time.Current)
|
|
|
|
|
drumRollHitContainer.Remove(o);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Add(DrawableHitObject h)
|
|
|
|
|
{
|
2018-08-06 01:54:16 +00:00
|
|
|
|
h.OnNewResult += OnNewResult;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
base.Add(h);
|
|
|
|
|
|
2018-07-17 05:35:09 +00:00
|
|
|
|
switch (h)
|
|
|
|
|
{
|
|
|
|
|
case DrawableBarLine barline:
|
|
|
|
|
barlineContainer.Add(barline.CreateProxy());
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-07-17 05:35:09 +00:00
|
|
|
|
case DrawableTaikoHitObject taikoObject:
|
|
|
|
|
topLevelHitContainer.Add(taikoObject.CreateProxiedContent());
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 01:54:16 +00:00
|
|
|
|
internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-02-21 09:56:34 +00:00
|
|
|
|
if (!DisplayJudgements.Value)
|
2018-07-20 08:04:33 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-08-06 02:31:46 +00:00
|
|
|
|
if (!judgedObject.DisplayResult)
|
2018-08-02 12:08:06 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-08-03 07:46:03 +00:00
|
|
|
|
switch (result.Judgement)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-08-03 07:56:46 +00:00
|
|
|
|
case TaikoStrongJudgement _:
|
2018-08-03 07:46:03 +00:00
|
|
|
|
if (result.IsHit)
|
2018-11-14 23:33:13 +00:00
|
|
|
|
hitExplosionContainer.Children.FirstOrDefault(e => e.JudgedObject == ((DrawableStrongNestedHit)judgedObject).MainObject)?.VisualiseSecondHit();
|
2018-08-03 07:46:03 +00:00
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2020-04-27 03:01:31 +00:00
|
|
|
|
case TaikoDrumRollTickJudgement _:
|
2020-04-27 03:23:53 +00:00
|
|
|
|
if (!result.IsHit)
|
2020-04-27 03:27:43 +00:00
|
|
|
|
break;
|
2020-04-27 03:23:53 +00:00
|
|
|
|
|
|
|
|
|
var drawableTick = (DrawableDrumRollTick)judgedObject;
|
|
|
|
|
|
|
|
|
|
addDrumRollHit(drawableTick);
|
|
|
|
|
addExplosion(drawableTick, drawableTick.JudgementType);
|
2020-04-27 03:01:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2018-08-03 07:46:03 +00:00
|
|
|
|
default:
|
|
|
|
|
judgementContainer.Add(new DrawableTaikoJudgement(result, judgedObject)
|
|
|
|
|
{
|
|
|
|
|
Anchor = result.IsHit ? Anchor.TopLeft : Anchor.CentreLeft,
|
|
|
|
|
Origin = result.IsHit ? Anchor.BottomCentre : Anchor.Centre,
|
|
|
|
|
RelativePositionAxes = Axes.X,
|
|
|
|
|
X = result.IsHit ? judgedObject.Position.X : 0,
|
|
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-08-03 07:46:03 +00:00
|
|
|
|
if (!result.IsHit)
|
|
|
|
|
break;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-04-27 03:23:53 +00:00
|
|
|
|
addExplosion(judgedObject, (judgedObject.HitObject as Hit)?.Type ?? HitType.Centre);
|
2018-08-03 07:46:03 +00:00
|
|
|
|
break;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-28 04:20:28 +00:00
|
|
|
|
|
2020-04-27 03:23:53 +00:00
|
|
|
|
private void addDrumRollHit(DrawableDrumRollTick drawableTick)
|
2020-04-27 03:01:31 +00:00
|
|
|
|
{
|
2020-04-27 03:23:53 +00:00
|
|
|
|
bool isStrong = drawableTick.HitObject.IsStrong;
|
|
|
|
|
double time = drawableTick.HitObject.GetEndTime();
|
2020-04-27 03:01:31 +00:00
|
|
|
|
|
|
|
|
|
DrawableHit drawableHit;
|
2020-04-27 03:23:53 +00:00
|
|
|
|
if (drawableTick.JudgementType == HitType.Rim)
|
2020-04-27 03:01:31 +00:00
|
|
|
|
drawableHit = new DrawableFlyingRimHit(time, isStrong);
|
|
|
|
|
else
|
|
|
|
|
drawableHit = new DrawableFlyingCentreHit(time, isStrong);
|
|
|
|
|
|
|
|
|
|
drumRollHitContainer.Add(drawableHit);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-27 03:23:53 +00:00
|
|
|
|
private void addExplosion(DrawableHitObject drawableObject, HitType type)
|
|
|
|
|
{
|
|
|
|
|
hitExplosionContainer.Add(new HitExplosion(drawableObject, type));
|
|
|
|
|
|
|
|
|
|
if (drawableObject.HitObject.Kiai)
|
|
|
|
|
kiaiExplosionContainer.Add(new KiaiHitExplosion(drawableObject, type));
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 04:20:28 +00:00
|
|
|
|
private class ProxyContainer : LifetimeManagementContainer
|
|
|
|
|
{
|
|
|
|
|
public new MarginPadding Padding
|
|
|
|
|
{
|
|
|
|
|
set => base.Padding = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(Drawable proxy) => AddInternal(proxy);
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|