2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-05-03 11:37:47 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-05-03 11:37:47 +08:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
|
using osu.Game.Graphics;
|
2017-05-11 11:33:19 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2017-05-22 14:27:38 +08:00
|
|
|
|
using System;
|
2017-08-23 12:42:11 +08:00
|
|
|
|
using osu.Framework.Input.Bindings;
|
2017-09-12 16:37:37 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2018-01-04 18:22:15 +08:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2017-05-03 11:37:47 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.UI
|
|
|
|
|
{
|
2017-09-12 17:19:28 +08:00
|
|
|
|
public class Column : ScrollingPlayfield, IHasAccentColour
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
|
|
|
|
private const float key_icon_size = 10;
|
|
|
|
|
private const float key_icon_corner_radius = 3;
|
|
|
|
|
private const float key_icon_border_radius = 2;
|
|
|
|
|
|
|
|
|
|
private const float hit_target_height = 10;
|
|
|
|
|
private const float hit_target_bar_height = 2;
|
|
|
|
|
|
|
|
|
|
private const float column_width = 45;
|
|
|
|
|
private const float special_column_width = 70;
|
|
|
|
|
|
2017-08-23 12:42:11 +08:00
|
|
|
|
public ManiaAction Action;
|
2017-05-03 11:37:47 +08:00
|
|
|
|
|
2017-05-03 11:58:46 +08:00
|
|
|
|
private readonly Box background;
|
|
|
|
|
private readonly Container hitTargetBar;
|
|
|
|
|
private readonly Container keyIcon;
|
2017-05-03 11:37:47 +08:00
|
|
|
|
|
2017-09-11 12:44:39 +08:00
|
|
|
|
internal readonly Container TopLevelContainer;
|
|
|
|
|
private readonly Container explosionContainer;
|
|
|
|
|
|
2017-08-04 22:07:08 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
private readonly Container<Drawable> content;
|
2017-05-11 11:33:19 +08:00
|
|
|
|
|
2017-09-12 17:22:02 +08:00
|
|
|
|
private const float opacity_released = 0.1f;
|
|
|
|
|
private const float opacity_pressed = 0.25f;
|
|
|
|
|
|
2017-06-01 13:26:21 +08:00
|
|
|
|
public Column()
|
2018-01-04 21:05:20 +08:00
|
|
|
|
: base(ScrollingDirection.Up)
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
|
|
|
|
Width = column_width;
|
|
|
|
|
|
2017-08-04 22:07:08 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
2017-09-12 17:22:02 +08:00
|
|
|
|
Name = "Background",
|
2017-05-03 11:37:47 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-09-12 17:22:02 +08:00
|
|
|
|
Alpha = opacity_released
|
2017-05-03 11:37:47 +08:00
|
|
|
|
},
|
2017-05-11 11:33:19 +08:00
|
|
|
|
new Container
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-05-16 16:34:41 +08:00
|
|
|
|
Name = "Hit target + hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-06-08 15:27:35 +08:00
|
|
|
|
Padding = new MarginPadding { Top = ManiaPlayfield.HIT_TARGET_POSITION },
|
2017-05-11 11:33:19 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-05-16 16:34:41 +08:00
|
|
|
|
new Container
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-05-16 16:34:41 +08:00
|
|
|
|
Name = "Hit target",
|
2017-05-11 13:32:31 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-05-16 16:34:41 +08:00
|
|
|
|
Height = hit_target_height,
|
|
|
|
|
Children = new Drawable[]
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
2017-05-16 16:34:41 +08:00
|
|
|
|
Name = "Background",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black
|
|
|
|
|
},
|
|
|
|
|
hitTargetBar = new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Bar",
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = hit_target_bar_height,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-03 11:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-16 16:34:41 +08:00
|
|
|
|
},
|
2017-08-04 22:07:08 +08:00
|
|
|
|
content = new Container
|
2017-05-16 16:34:41 +08:00
|
|
|
|
{
|
|
|
|
|
Name = "Hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2017-05-22 14:25:37 +08:00
|
|
|
|
// For column lighting, we need to capture input events before the notes
|
|
|
|
|
new InputTarget
|
|
|
|
|
{
|
2017-08-23 12:42:11 +08:00
|
|
|
|
Pressed = onPressed,
|
|
|
|
|
Released = onReleased
|
2017-09-11 12:44:39 +08:00
|
|
|
|
},
|
|
|
|
|
explosionContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Hit explosions",
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2017-05-22 14:25:37 +08:00
|
|
|
|
}
|
2017-05-11 11:33:19 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
2017-05-11 13:32:31 +08:00
|
|
|
|
Name = "Key",
|
2017-05-11 11:33:19 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-05-11 13:32:31 +08:00
|
|
|
|
Height = ManiaPlayfield.HIT_TARGET_POSITION,
|
2017-05-11 11:33:19 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
2017-05-11 13:32:31 +08:00
|
|
|
|
Name = "Key gradient",
|
2017-05-11 11:33:19 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-07-23 13:30:50 +08:00
|
|
|
|
Colour = ColourInfo.GradientVertical(Color4.Black, Color4.Black.Opacity(0)),
|
2017-05-11 13:32:31 +08:00
|
|
|
|
Alpha = 0.5f
|
2017-05-03 11:37:47 +08:00
|
|
|
|
},
|
2017-05-11 13:32:31 +08:00
|
|
|
|
keyIcon = new Container
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-05-11 13:32:31 +08:00
|
|
|
|
Name = "Key icon",
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(key_icon_size),
|
2017-05-11 11:33:19 +08:00
|
|
|
|
Masking = true,
|
2017-05-11 13:32:31 +08:00
|
|
|
|
CornerRadius = key_icon_corner_radius,
|
|
|
|
|
BorderThickness = 2,
|
|
|
|
|
BorderColour = Color4.White, // Not true
|
2017-05-11 11:33:19 +08:00
|
|
|
|
Children = new[]
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
2017-05-11 13:32:31 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
AlwaysPresent = true
|
2017-05-03 11:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-11 12:44:39 +08:00
|
|
|
|
},
|
|
|
|
|
TopLevelContainer = new Container { RelativeSizeAxes = Axes.Both }
|
2017-05-03 11:37:47 +08:00
|
|
|
|
};
|
2017-09-11 12:44:39 +08:00
|
|
|
|
|
|
|
|
|
TopLevelContainer.Add(explosionContainer.CreateProxy());
|
2017-05-03 11:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-04 22:07:08 +08:00
|
|
|
|
public override Axes RelativeSizeAxes => Axes.Y;
|
|
|
|
|
|
2017-05-03 18:38:15 +08:00
|
|
|
|
private bool isSpecial;
|
|
|
|
|
public bool IsSpecial
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-05-03 18:38:15 +08:00
|
|
|
|
get { return isSpecial; }
|
|
|
|
|
set
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-05-03 18:38:15 +08:00
|
|
|
|
if (isSpecial == value)
|
|
|
|
|
return;
|
|
|
|
|
isSpecial = value;
|
|
|
|
|
|
|
|
|
|
Width = isSpecial ? special_column_width : column_width;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-03 11:37:47 +08:00
|
|
|
|
|
2017-05-03 18:38:15 +08:00
|
|
|
|
private Color4 accentColour;
|
|
|
|
|
public Color4 AccentColour
|
|
|
|
|
{
|
|
|
|
|
get { return accentColour; }
|
|
|
|
|
set
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-05-03 18:38:15 +08:00
|
|
|
|
if (accentColour == value)
|
|
|
|
|
return;
|
|
|
|
|
accentColour = value;
|
|
|
|
|
|
|
|
|
|
background.Colour = accentColour;
|
|
|
|
|
|
2017-06-12 11:48:47 +08:00
|
|
|
|
hitTargetBar.EdgeEffect = new EdgeEffectParameters
|
2017-05-03 18:38:15 +08:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Radius = 5,
|
|
|
|
|
Colour = accentColour.Opacity(0.5f),
|
|
|
|
|
};
|
|
|
|
|
|
2017-06-12 11:48:47 +08:00
|
|
|
|
keyIcon.EdgeEffect = new EdgeEffectParameters
|
2017-05-03 18:38:15 +08:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Radius = 5,
|
|
|
|
|
Colour = accentColour.Opacity(0.5f),
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-05-03 11:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-04 22:07:08 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds a DrawableHitObject to this Playfield.
|
|
|
|
|
/// </summary>
|
2017-08-07 16:34:57 +08:00
|
|
|
|
/// <param name="hitObject">The DrawableHitObject to add.</param>
|
2017-09-12 17:19:28 +08:00
|
|
|
|
public override void Add(DrawableHitObject hitObject)
|
2017-05-24 20:56:49 +08:00
|
|
|
|
{
|
2017-09-13 15:17:01 +08:00
|
|
|
|
hitObject.Depth = (float)hitObject.HitObject.StartTime;
|
|
|
|
|
|
2017-05-24 20:56:49 +08:00
|
|
|
|
hitObject.AccentColour = AccentColour;
|
2017-08-04 22:07:08 +08:00
|
|
|
|
HitObjects.Add(hitObject);
|
2017-05-24 20:56:49 +08:00
|
|
|
|
}
|
2017-05-10 13:56:39 +08:00
|
|
|
|
|
2017-09-12 16:37:37 +08:00
|
|
|
|
public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
|
2017-09-11 12:44:39 +08:00
|
|
|
|
{
|
2017-09-12 16:37:37 +08:00
|
|
|
|
if (!judgement.IsHit)
|
2017-09-11 12:44:39 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
explosionContainer.Add(new HitExplosion(judgedObject));
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:42:11 +08:00
|
|
|
|
private bool onPressed(ManiaAction action)
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-08-23 12:42:11 +08:00
|
|
|
|
if (action == Action)
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-09-12 17:22:02 +08:00
|
|
|
|
background.FadeTo(opacity_pressed, 50, Easing.OutQuint);
|
2017-07-23 02:50:25 +08:00
|
|
|
|
keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint);
|
2017-05-03 11:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:42:11 +08:00
|
|
|
|
private bool onReleased(ManiaAction action)
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-08-23 12:42:11 +08:00
|
|
|
|
if (action == Action)
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-09-12 17:22:02 +08:00
|
|
|
|
background.FadeTo(opacity_released, 800, Easing.OutQuart);
|
2017-07-23 02:50:25 +08:00
|
|
|
|
keyIcon.ScaleTo(1f, 400, Easing.OutQuart);
|
2017-05-03 11:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-05-22 14:25:37 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This is a simple container which delegates various input events that have to be captured before the notes.
|
|
|
|
|
/// </summary>
|
2017-08-23 12:42:11 +08:00
|
|
|
|
private class InputTarget : Container, IKeyBindingHandler<ManiaAction>
|
2017-05-22 14:25:37 +08:00
|
|
|
|
{
|
2017-08-23 12:42:11 +08:00
|
|
|
|
public Func<ManiaAction, bool> Pressed;
|
|
|
|
|
public Func<ManiaAction, bool> Released;
|
2017-05-22 14:25:37 +08:00
|
|
|
|
|
|
|
|
|
public InputTarget()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
AlwaysPresent = true;
|
|
|
|
|
Alpha = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:42:11 +08:00
|
|
|
|
public bool OnPressed(ManiaAction action) => Pressed?.Invoke(action) ?? false;
|
|
|
|
|
public bool OnReleased(ManiaAction action) => Released?.Invoke(action) ?? false;
|
2017-05-22 14:25:37 +08:00
|
|
|
|
}
|
2017-05-03 11:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|