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
|
|
|
|
|
2020-11-27 13:34:12 +08:00
|
|
|
|
using System;
|
2018-09-20 00:30:25 +08:00
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2018-09-20 00:30:25 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
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;
|
2020-12-14 02:29:41 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2020-09-25 18:25:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
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;
|
2020-04-21 18:00:34 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2020-05-13 02:26:11 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.UI
|
|
|
|
|
{
|
|
|
|
|
public class TaikoPlayfield : ScrollingPlayfield
|
|
|
|
|
{
|
2020-04-23 11:33:34 +08:00
|
|
|
|
private readonly ControlPointInfo controlPoints;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
/// <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;
|
|
|
|
|
|
2020-04-23 11:33:34 +08:00
|
|
|
|
private Container<HitExplosion> hitExplosionContainer;
|
|
|
|
|
private Container<KiaiHitExplosion> kiaiExplosionContainer;
|
|
|
|
|
private JudgementContainer<DrawableTaikoJudgement> judgementContainer;
|
2020-04-25 13:31:50 +08:00
|
|
|
|
private ScrollingHitObjectContainer drumRollHitContainer;
|
2020-04-23 11:33:34 +08:00
|
|
|
|
internal Drawable HitTarget;
|
2020-05-13 02:26:11 +08:00
|
|
|
|
private SkinnableDrawable mascot;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-04-23 11:33:34 +08:00
|
|
|
|
private ProxyContainer topLevelHitContainer;
|
|
|
|
|
private Container rightArea;
|
|
|
|
|
private Container leftArea;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-12-14 02:29:41 +08:00
|
|
|
|
/// <remarks>
|
|
|
|
|
/// <see cref="Playfield.AddNested"/> is purposefully not called on this to prevent i.e. being able to interact
|
|
|
|
|
/// with bar lines in the editor.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private BarLinePlayfield barLinePlayfield;
|
|
|
|
|
|
2020-04-23 11:33:34 +08:00
|
|
|
|
private Container hitTargetOffsetContent;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public TaikoPlayfield(ControlPointInfo controlPoints)
|
2020-04-23 11:33:34 +08:00
|
|
|
|
{
|
|
|
|
|
this.controlPoints = controlPoints;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-04-25 13:47:20 +08:00
|
|
|
|
InternalChildren = new[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-04-23 12:23:49 +08:00
|
|
|
|
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundRight), _ => new PlayfieldBackgroundRight()),
|
2020-04-23 11:33:34 +08:00
|
|
|
|
rightArea = new Container
|
2019-03-26 12:31:49 +08:00
|
|
|
|
{
|
|
|
|
|
Name = "Right area",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-23 11:33:34 +08:00
|
|
|
|
RelativePositionAxes = Axes.Both,
|
2019-03-26 12:31:49 +08:00
|
|
|
|
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,
|
2020-04-23 11:33:34 +08:00
|
|
|
|
FillMode = FillMode.Fit,
|
2020-04-21 18:00:34 +08:00
|
|
|
|
Children = new[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
hitExplosionContainer = new Container<HitExplosion>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2020-04-23 11:10:26 +08:00
|
|
|
|
HitTarget = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.HitTarget), _ => new TaikoHitTarget())
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-03-26 12:31:49 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-04-23 11:33:34 +08:00
|
|
|
|
hitTargetOffsetContent = new Container
|
2019-03-26 12:31:49 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-23 11:33:34 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-12-14 02:29:41 +08:00
|
|
|
|
barLinePlayfield = new BarLinePlayfield(),
|
2020-04-23 11:33:34 +08:00
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-25 13:31:50 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
HitObjectContainer,
|
2020-04-27 15:13:28 +08:00
|
|
|
|
drumRollHitContainer = new DrumRollHitContainer()
|
2020-04-25 13:31:50 +08:00
|
|
|
|
}
|
2020-04-23 11:33:34 +08:00
|
|
|
|
},
|
|
|
|
|
kiaiExplosionContainer = new Container<KiaiHitExplosion>
|
|
|
|
|
{
|
|
|
|
|
Name = "Kiai hit explosions",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
},
|
|
|
|
|
judgementContainer = new JudgementContainer<DrawableTaikoJudgement>
|
|
|
|
|
{
|
|
|
|
|
Name = "Judgements",
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
},
|
|
|
|
|
}
|
2019-03-26 12:31:49 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-04-23 11:33:34 +08:00
|
|
|
|
leftArea = new Container
|
2019-03-26 12:31:49 +08:00
|
|
|
|
{
|
|
|
|
|
Name = "Left overlay",
|
2020-04-23 11:33:34 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
BorderColour = colours.Gray0,
|
2019-03-26 12:31:49 +08:00
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-04-23 12:23:49 +08:00
|
|
|
|
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
2019-03-26 12:31:49 +08:00
|
|
|
|
new InputDrum(controlPoints)
|
|
|
|
|
{
|
2020-04-23 11:33:34 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2019-03-26 12:31:49 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-05-14 09:02:47 +08:00
|
|
|
|
mascot = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Mascot), _ => Empty())
|
2020-05-01 06:19:12 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.TopLeft,
|
2020-05-13 02:26:11 +08:00
|
|
|
|
RelativePositionAxes = Axes.Y,
|
2020-05-01 06:19:12 +08:00
|
|
|
|
RelativeSizeAxes = Axes.None,
|
2020-05-13 02:26:11 +08:00
|
|
|
|
Y = 0.2f
|
2020-05-01 06:19:12 +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,
|
2020-04-22 21:19:29 +08:00
|
|
|
|
},
|
2020-04-27 18:43:51 +08:00
|
|
|
|
drumRollHitContainer.CreateProxy(),
|
2018-09-21 14:08:43 +08:00
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-21 01:07:59 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
NewResult += OnNewResult;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-21 01:11:29 +08:00
|
|
|
|
protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObject)
|
|
|
|
|
{
|
|
|
|
|
base.OnNewDrawableHitObject(drawableHitObject);
|
|
|
|
|
|
|
|
|
|
var taikoObject = (DrawableTaikoHitObject)drawableHitObject;
|
|
|
|
|
topLevelHitContainer.Add(taikoObject.CreateProxiedContent());
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-23 11:33:34 +08:00
|
|
|
|
protected override void Update()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-04-23 11:33:34 +08:00
|
|
|
|
base.Update();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-04-23 11:47:57 +08: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 11:33:34 +08:00
|
|
|
|
rightArea.Padding = new MarginPadding { Left = leftArea.DrawWidth };
|
|
|
|
|
hitTargetOffsetContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
2020-05-13 02:26:11 +08:00
|
|
|
|
|
2020-05-14 00:53:47 +08:00
|
|
|
|
mascot.Scale = new Vector2(DrawHeight / DEFAULT_HEIGHT);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 02:29:41 +08:00
|
|
|
|
#region Pooling support
|
|
|
|
|
|
|
|
|
|
public override void Add(HitObject h)
|
|
|
|
|
{
|
|
|
|
|
switch (h)
|
|
|
|
|
{
|
|
|
|
|
case BarLine barLine:
|
|
|
|
|
barLinePlayfield.Add(barLine);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TaikoHitObject taikoHitObject:
|
|
|
|
|
base.Add(taikoHitObject);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentException($"Unsupported {nameof(HitObject)} type: {h.GetType()}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Remove(HitObject h)
|
|
|
|
|
{
|
|
|
|
|
switch (h)
|
|
|
|
|
{
|
|
|
|
|
case BarLine barLine:
|
|
|
|
|
return barLinePlayfield.Remove(barLine);
|
|
|
|
|
|
|
|
|
|
case TaikoHitObject taikoHitObject:
|
|
|
|
|
return base.Remove(taikoHitObject);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentException($"Unsupported {nameof(HitObject)} type: {h.GetType()}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Non-pooling support
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public override void Add(DrawableHitObject h)
|
|
|
|
|
{
|
2018-07-17 13:35:09 +08:00
|
|
|
|
switch (h)
|
|
|
|
|
{
|
2020-12-14 02:29:41 +08:00
|
|
|
|
case DrawableBarLine barLine:
|
|
|
|
|
barLinePlayfield.Add(barLine);
|
2018-07-17 13:35:09 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2020-12-21 01:11:29 +08:00
|
|
|
|
case DrawableTaikoHitObject _:
|
2020-11-27 13:34:12 +08:00
|
|
|
|
base.Add(h);
|
2018-07-17 13:35:09 +08:00
|
|
|
|
break;
|
2020-11-27 13:34:12 +08:00
|
|
|
|
|
|
|
|
|
default:
|
2020-12-14 02:29:41 +08:00
|
|
|
|
throw new ArgumentException($"Unsupported {nameof(DrawableHitObject)} type: {h.GetType()}");
|
2020-11-27 13:34:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Remove(DrawableHitObject h)
|
|
|
|
|
{
|
|
|
|
|
switch (h)
|
|
|
|
|
{
|
2020-12-14 02:29:41 +08:00
|
|
|
|
case DrawableBarLine barLine:
|
|
|
|
|
return barLinePlayfield.Remove(barLine);
|
2020-11-27 13:34:12 +08:00
|
|
|
|
|
|
|
|
|
case DrawableTaikoHitObject _:
|
|
|
|
|
return base.Remove(h);
|
|
|
|
|
|
|
|
|
|
default:
|
2020-12-14 02:29:41 +08:00
|
|
|
|
throw new ArgumentException($"Unsupported {nameof(DrawableHitObject)} type: {h.GetType()}");
|
2018-07-17 13:35:09 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 02:29:41 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
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)
|
2020-12-15 06:21:19 +08:00
|
|
|
|
hitExplosionContainer.Children.FirstOrDefault(e => e.JudgedObject == ((DrawableStrongNestedHit)judgedObject).ParentHitObject)?.VisualiseSecondHit();
|
2018-08-03 15:46:03 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2020-04-27 11:01:31 +08:00
|
|
|
|
case TaikoDrumRollTickJudgement _:
|
2020-04-27 11:23:53 +08:00
|
|
|
|
if (!result.IsHit)
|
2020-04-27 11:27:43 +08:00
|
|
|
|
break;
|
2020-04-27 11:23:53 +08:00
|
|
|
|
|
|
|
|
|
var drawableTick = (DrawableDrumRollTick)judgedObject;
|
|
|
|
|
|
|
|
|
|
addDrumRollHit(drawableTick);
|
2020-04-27 11:01:31 +08:00
|
|
|
|
break;
|
|
|
|
|
|
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
|
|
|
|
|
2020-04-27 21:22:32 +08:00
|
|
|
|
var type = (judgedObject.HitObject as Hit)?.Type ?? HitType.Centre;
|
2020-09-25 18:25:58 +08:00
|
|
|
|
addExplosion(judgedObject, result.Type, type);
|
2018-08-03 15:46:03 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2020-04-22 21:19:29 +08:00
|
|
|
|
}
|
2019-08-28 12:20:28 +08:00
|
|
|
|
|
2020-04-27 15:48:17 +08:00
|
|
|
|
private void addDrumRollHit(DrawableDrumRollTick drawableTick) =>
|
|
|
|
|
drumRollHitContainer.Add(new DrawableFlyingHit(drawableTick));
|
2020-04-27 11:01:31 +08:00
|
|
|
|
|
2020-09-27 21:23:34 +08:00
|
|
|
|
private void addExplosion(DrawableHitObject drawableObject, HitResult result, HitType type)
|
2020-04-27 11:23:53 +08:00
|
|
|
|
{
|
2020-09-25 18:25:58 +08:00
|
|
|
|
hitExplosionContainer.Add(new HitExplosion(drawableObject, result));
|
2020-04-27 11:23:53 +08:00
|
|
|
|
if (drawableObject.HitObject.Kiai)
|
|
|
|
|
kiaiExplosionContainer.Add(new KiaiHitExplosion(drawableObject, type));
|
2020-09-27 21:23:34 +08:00
|
|
|
|
}
|
2020-04-27 11:23:53 +08:00
|
|
|
|
|
2020-04-27 07:40:57 +08:00
|
|
|
|
private class ProxyContainer : LifetimeManagementContainer
|
2020-04-22 21:19:29 +08:00
|
|
|
|
{
|
2020-04-27 07:40:57 +08:00
|
|
|
|
public new MarginPadding Padding
|
|
|
|
|
{
|
|
|
|
|
set => base.Padding = value;
|
|
|
|
|
}
|
2020-04-22 21:19:29 +08:00
|
|
|
|
|
2020-04-27 07:40:57 +08:00
|
|
|
|
public void Add(Drawable proxy) => AddInternal(proxy);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|