2019-03-19 18:04:07 +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.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
2019-03-25 19:25:16 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2019-03-19 18:04:07 +08:00
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.UI
|
|
|
|
|
{
|
|
|
|
|
public class OsuResumeOverlay : ResumeOverlay
|
|
|
|
|
{
|
|
|
|
|
private OsuClickToResumeCursor clickToResumeCursor;
|
|
|
|
|
|
|
|
|
|
private GameplayCursorContainer localCursorContainer;
|
|
|
|
|
|
2019-06-11 13:28:52 +08:00
|
|
|
|
public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null;
|
2019-03-19 18:04:07 +08:00
|
|
|
|
|
|
|
|
|
protected override string Message => "Click the orange cursor to resume";
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-03-25 14:30:51 +08:00
|
|
|
|
private void load()
|
2019-03-19 18:04:07 +08:00
|
|
|
|
{
|
|
|
|
|
Add(clickToResumeCursor = new OsuClickToResumeCursor { ResumeRequested = Resume });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Show()
|
|
|
|
|
{
|
|
|
|
|
base.Show();
|
|
|
|
|
clickToResumeCursor.ShowAt(GameplayCursor.ActiveCursor.Position);
|
2019-03-25 18:21:34 +08:00
|
|
|
|
|
|
|
|
|
if (localCursorContainer == null)
|
2019-10-12 17:51:14 +08:00
|
|
|
|
{
|
|
|
|
|
var newContainer = new OsuCursorContainer();
|
|
|
|
|
Add(localCursorContainer = newContainer);
|
|
|
|
|
|
|
|
|
|
clickToResumeCursor.CursorScale = newContainer.CalculatedCursorScale.Value;
|
2019-10-12 17:59:22 +08:00
|
|
|
|
clickToResumeCursor.Scale = new Vector2(newContainer.CalculatedCursorScale.Value);
|
|
|
|
|
|
|
|
|
|
newContainer.CalculatedCursorScale.ValueChanged += e =>
|
|
|
|
|
{
|
|
|
|
|
clickToResumeCursor.CursorScale = e.NewValue;
|
|
|
|
|
clickToResumeCursor.Scale = new Vector2(e.NewValue);
|
|
|
|
|
};
|
2019-10-12 17:51:14 +08:00
|
|
|
|
}
|
2019-03-19 18:04:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Hide()
|
|
|
|
|
{
|
2019-03-25 18:21:34 +08:00
|
|
|
|
localCursorContainer?.Expire();
|
|
|
|
|
localCursorContainer = null;
|
|
|
|
|
|
2019-03-19 18:04:07 +08:00
|
|
|
|
base.Hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e) => true;
|
|
|
|
|
|
|
|
|
|
public class OsuClickToResumeCursor : OsuCursor, IKeyBindingHandler<OsuAction>
|
|
|
|
|
{
|
|
|
|
|
public override bool HandlePositionalInput => true;
|
|
|
|
|
|
|
|
|
|
public Action ResumeRequested;
|
|
|
|
|
|
2019-10-12 17:51:14 +08:00
|
|
|
|
public float CursorScale;
|
|
|
|
|
|
2019-03-19 18:04:07 +08:00
|
|
|
|
public OsuClickToResumeCursor()
|
|
|
|
|
{
|
|
|
|
|
RelativePositionAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
|
|
|
|
updateColour();
|
|
|
|
|
return base.OnHover(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
updateColour();
|
|
|
|
|
base.OnHoverLost(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool OnPressed(OsuAction action)
|
|
|
|
|
{
|
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case OsuAction.LeftButton:
|
|
|
|
|
case OsuAction.RightButton:
|
|
|
|
|
if (!IsHovered) return false;
|
|
|
|
|
|
2019-10-12 17:51:14 +08:00
|
|
|
|
this.ScaleTo(2 * CursorScale, TRANSITION_TIME, Easing.OutQuint);
|
2019-03-19 18:04:07 +08:00
|
|
|
|
|
|
|
|
|
ResumeRequested?.Invoke();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool OnReleased(OsuAction action) => false;
|
|
|
|
|
|
|
|
|
|
public void ShowAt(Vector2 activeCursorPosition) => Schedule(() =>
|
|
|
|
|
{
|
|
|
|
|
updateColour();
|
|
|
|
|
this.MoveTo(activeCursorPosition);
|
2019-10-12 17:51:14 +08:00
|
|
|
|
this.ScaleTo(4 * CursorScale).Then().ScaleTo(CursorScale, 1000, Easing.OutQuint);
|
2019-03-19 18:04:07 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
private void updateColour()
|
|
|
|
|
{
|
|
|
|
|
this.FadeColour(IsHovered ? Color4.White : Color4.Orange, 400, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|