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
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|
|
|
|
{
|
2019-03-05 09:06:24 +00:00
|
|
|
|
public class GameplayCursorContainer : CursorContainer, IKeyBindingHandler<OsuAction>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
protected override Drawable CreateCursor() => new OsuCursor();
|
|
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => fadeContainer;
|
|
|
|
|
|
|
|
|
|
private readonly Container<Drawable> fadeContainer;
|
|
|
|
|
|
2019-03-05 09:06:24 +00:00
|
|
|
|
public GameplayCursorContainer()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-01-10 05:20:44 +00:00
|
|
|
|
InternalChild = fadeContainer = new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-01-10 05:20:44 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-01-10 05:20:44 +00:00
|
|
|
|
new CursorTrail { Depth = 1 }
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int downCount;
|
|
|
|
|
|
2019-01-07 09:28:22 +00:00
|
|
|
|
private void updateExpandedState()
|
|
|
|
|
{
|
|
|
|
|
if (downCount > 0)
|
|
|
|
|
(ActiveCursor as OsuCursor)?.Expand();
|
|
|
|
|
else
|
|
|
|
|
(ActiveCursor as OsuCursor)?.Contract();
|
|
|
|
|
}
|
2018-07-10 05:41:07 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public bool OnPressed(OsuAction action)
|
|
|
|
|
{
|
2018-12-10 23:38:03 +00:00
|
|
|
|
switch (action)
|
2018-12-11 20:02:12 +00:00
|
|
|
|
{
|
|
|
|
|
case OsuAction.LeftButton:
|
|
|
|
|
case OsuAction.RightButton:
|
|
|
|
|
downCount++;
|
2019-01-07 09:28:22 +00:00
|
|
|
|
updateExpandedState();
|
2018-12-11 20:02:12 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool OnReleased(OsuAction action)
|
|
|
|
|
{
|
2018-12-10 23:38:03 +00:00
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case OsuAction.LeftButton:
|
|
|
|
|
case OsuAction.RightButton:
|
|
|
|
|
if (--downCount == 0)
|
2019-01-07 09:28:22 +00:00
|
|
|
|
updateExpandedState();
|
2018-12-10 23:38:03 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-26 05:01:15 +00:00
|
|
|
|
public override bool HandlePositionalInput => true; // OverlayContainer will set this false when we go hidden, but we always want to receive input.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
fadeContainer.FadeTo(1, 300, Easing.OutQuint);
|
2019-01-07 09:28:22 +00:00
|
|
|
|
ActiveCursor.ScaleTo(1, 400, Easing.OutQuint);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint);
|
2019-01-07 09:28:22 +00:00
|
|
|
|
ActiveCursor.ScaleTo(0.8f, 450, Easing.OutQuint);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
2018-12-11 17:06:41 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|