2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-09-20 00:30:25 +08:00
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-09-20 00:30:25 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2018-09-20 00:30:25 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-04-02 13:51:28 +08:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-09-20 00:30:25 +08:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2018-09-20 00:30:25 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2018-09-20 00:30:25 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Judgements;
|
2020-03-23 11:08:15 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.UI
|
|
|
|
|
{
|
|
|
|
|
public class TaikoPlayfield : ScrollingPlayfield
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2019-03-19 22:44:15 +08:00
|
|
|
|
/// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="DrawableTaikoRuleset"/>.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public const float DEFAULT_HEIGHT = 178;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The offset from <see cref="left_area_size"/> which the center of the hit target lies at.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const float HIT_TARGET_OFFSET = 100;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The size of the left area of the playfield. This area contains the input drum.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float left_area_size = 240;
|
|
|
|
|
|
2018-11-15 07:33:13 +08:00
|
|
|
|
private readonly Container<HitExplosion> hitExplosionContainer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private readonly Container<KiaiHitExplosion> kiaiExplosionContainer;
|
|
|
|
|
private readonly JudgementContainer<DrawableTaikoJudgement> judgementContainer;
|
2020-04-07 16:40:32 +08:00
|
|
|
|
private readonly ScrollingHitObjectContainer drumRollHitContainer;
|
2018-11-15 07:33:13 +08:00
|
|
|
|
internal readonly HitTarget HitTarget;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-08-28 12:20:28 +08:00
|
|
|
|
private readonly ProxyContainer topLevelHitContainer;
|
|
|
|
|
private readonly ProxyContainer barlineContainer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private readonly Container overlayBackgroundContainer;
|
|
|
|
|
private readonly Container backgroundContainer;
|
|
|
|
|
|
|
|
|
|
private readonly Box overlayBackground;
|
|
|
|
|
private readonly Box background;
|
|
|
|
|
|
|
|
|
|
public TaikoPlayfield(ControlPointInfo controlPoints)
|
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
backgroundContainer = new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
Name = "Transparent playfield background",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.2f),
|
|
|
|
|
Radius = 5,
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0.6f
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2019-03-26 12:31:49 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Right area",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Left = left_area_size },
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
Name = "Masked elements before hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Left = HIT_TARGET_OFFSET },
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
hitExplosionContainer = new Container<HitExplosion>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit,
|
2019-08-21 12:29:50 +08:00
|
|
|
|
Blending = BlendingParameters.Additive,
|
2019-03-26 12:31:49 +08:00
|
|
|
|
},
|
|
|
|
|
HitTarget = new HitTarget
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-03-26 12:31:49 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-08-28 12:20:28 +08:00
|
|
|
|
barlineContainer = new ProxyContainer
|
2019-03-26 12:31:49 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Left = HIT_TARGET_OFFSET }
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Left = HIT_TARGET_OFFSET },
|
|
|
|
|
Masking = true,
|
|
|
|
|
Child = HitObjectContainer
|
|
|
|
|
},
|
|
|
|
|
kiaiExplosionContainer = new Container<KiaiHitExplosion>
|
|
|
|
|
{
|
|
|
|
|
Name = "Kiai hit explosions",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
Margin = new MarginPadding { Left = HIT_TARGET_OFFSET },
|
2019-08-21 12:29:50 +08:00
|
|
|
|
Blending = BlendingParameters.Additive
|
2019-03-26 12:31:49 +08:00
|
|
|
|
},
|
|
|
|
|
judgementContainer = new JudgementContainer<DrawableTaikoJudgement>
|
|
|
|
|
{
|
|
|
|
|
Name = "Judgements",
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Margin = new MarginPadding { Left = HIT_TARGET_OFFSET },
|
2019-08-21 12:29:50 +08:00
|
|
|
|
Blending = BlendingParameters.Additive
|
2019-03-26 12:31:49 +08:00
|
|
|
|
},
|
2020-04-07 16:40:32 +08:00
|
|
|
|
drumRollHitContainer = new ScrollingHitObjectContainer
|
|
|
|
|
{
|
|
|
|
|
Name = "Drumroll hit",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Stretch,
|
|
|
|
|
Margin = new MarginPadding { Left = HIT_TARGET_OFFSET },
|
|
|
|
|
Width = 1.0f
|
|
|
|
|
}
|
2019-03-26 12:31:49 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
overlayBackgroundContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Left overlay",
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Size = new Vector2(left_area_size, 1),
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
overlayBackground = new Box
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new InputDrum(controlPoints)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Scale = new Vector2(0.9f),
|
|
|
|
|
Margin = new MarginPadding { Right = 20 }
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = 10,
|
|
|
|
|
Colour = Framework.Graphics.Colour.ColourInfo.GradientHorizontal(Color4.Black.Opacity(0.6f), Color4.Black.Opacity(0)),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Border",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
MaskingSmoothness = 0,
|
|
|
|
|
BorderThickness = 2,
|
|
|
|
|
AlwaysPresent = true,
|
|
|
|
|
Children = new[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
new Box
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
AlwaysPresent = true
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-26 12:31:49 +08:00
|
|
|
|
},
|
2019-08-28 12:20:28 +08:00
|
|
|
|
topLevelHitContainer = new ProxyContainer
|
2019-03-26 12:31:49 +08:00
|
|
|
|
{
|
|
|
|
|
Name = "Top level hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2018-09-21 14:08:43 +08:00
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
overlayBackgroundContainer.BorderColour = colours.Gray0;
|
|
|
|
|
overlayBackground.Colour = colours.Gray1;
|
|
|
|
|
|
|
|
|
|
backgroundContainer.BorderColour = colours.Gray1;
|
|
|
|
|
background.Colour = colours.Gray0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Add(DrawableHitObject h)
|
|
|
|
|
{
|
2018-08-06 09:54:16 +08:00
|
|
|
|
h.OnNewResult += OnNewResult;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
base.Add(h);
|
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
switch (h)
|
|
|
|
|
{
|
|
|
|
|
case DrawableBarLine barline:
|
|
|
|
|
barlineContainer.Add(barline.CreateProxy());
|
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2020-04-07 16:40:32 +08:00
|
|
|
|
case DrawableDrumRoll drumRoll:
|
|
|
|
|
drumRoll.OnHit += onDrumrollArbitraryHit;
|
|
|
|
|
break;
|
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
case DrawableTaikoHitObject taikoObject:
|
|
|
|
|
topLevelHitContainer.Add(taikoObject.CreateProxiedContent());
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-07 17:25:47 +08:00
|
|
|
|
private void onDrumrollArbitraryHit(TaikoAction action, bool isStrong)
|
2020-04-07 16:40:32 +08:00
|
|
|
|
{
|
|
|
|
|
DrawableHit drawableHit;
|
|
|
|
|
|
|
|
|
|
if (action == TaikoAction.LeftRim || action == TaikoAction.RightRim)
|
2020-04-07 17:25:47 +08:00
|
|
|
|
drawableHit = new DrawableFlyingRimHit(Time.Current, isStrong);
|
2020-04-07 16:40:32 +08:00
|
|
|
|
else
|
2020-04-07 17:25:47 +08:00
|
|
|
|
drawableHit = new DrawableFlyingCentreHit(Time.Current, isStrong);
|
2020-04-07 16:40:32 +08:00
|
|
|
|
|
|
|
|
|
drumRollHitContainer.Add(drawableHit);
|
2020-04-08 12:12:59 +08:00
|
|
|
|
topLevelHitContainer.Add(drawableHit.CreateProxiedContent());
|
2020-04-07 16:40:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 09:54:16 +08:00
|
|
|
|
internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-02-21 17:56:34 +08:00
|
|
|
|
if (!DisplayJudgements.Value)
|
2018-07-20 16:04:33 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
if (!judgedObject.DisplayResult)
|
2018-08-02 20:08:06 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2018-08-03 15:46:03 +08:00
|
|
|
|
switch (result.Judgement)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-08-03 15:56:46 +08:00
|
|
|
|
case TaikoStrongJudgement _:
|
2018-08-03 15:46:03 +08:00
|
|
|
|
if (result.IsHit)
|
2018-11-15 07:33:13 +08:00
|
|
|
|
hitExplosionContainer.Children.FirstOrDefault(e => e.JudgedObject == ((DrawableStrongNestedHit)judgedObject).MainObject)?.VisualiseSecondHit();
|
2018-08-03 15:46:03 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-08-03 15:46:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2018-08-03 15:46:03 +08:00
|
|
|
|
if (!result.IsHit)
|
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-03-23 11:08:15 +08:00
|
|
|
|
bool isRim = (judgedObject.HitObject as Hit)?.Type == HitType.Rim;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-11-15 07:33:13 +08:00
|
|
|
|
hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-08-03 15:46:03 +08:00
|
|
|
|
if (judgedObject.HitObject.Kiai)
|
|
|
|
|
kiaiExplosionContainer.Add(new KiaiHitExplosion(judgedObject, isRim));
|
|
|
|
|
|
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-28 12:20:28 +08:00
|
|
|
|
|
|
|
|
|
private class ProxyContainer : LifetimeManagementContainer
|
|
|
|
|
{
|
|
|
|
|
public new MarginPadding Padding
|
|
|
|
|
{
|
|
|
|
|
set => base.Padding = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(Drawable proxy) => AddInternal(proxy);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|