2019-10-19 10:15:31 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-03-19 10:04:07 +00:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2019-03-19 10:04:07 +00:00
|
|
|
using System;
|
|
|
|
using osu.Framework.Allocation;
|
2019-10-19 10:15:31 +00:00
|
|
|
using osu.Framework.Bindables;
|
2019-03-19 10:04:07 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
using osu.Framework.Input.Events;
|
2022-08-10 20:09:58 +00:00
|
|
|
using osu.Framework.Localisation;
|
2019-03-19 10:04:07 +00:00
|
|
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.UI
|
|
|
|
{
|
2022-11-24 05:32:20 +00:00
|
|
|
public partial class OsuResumeOverlay : ResumeOverlay
|
2019-03-19 10:04:07 +00:00
|
|
|
{
|
2019-10-15 20:44:04 +00:00
|
|
|
private Container cursorScaleContainer;
|
2019-03-19 10:04:07 +00:00
|
|
|
private OsuClickToResumeCursor clickToResumeCursor;
|
|
|
|
|
2019-10-14 08:13:36 +00:00
|
|
|
private OsuCursorContainer localCursorContainer;
|
2020-07-10 05:43:30 +00:00
|
|
|
private IBindable<float> localCursorScale;
|
2019-03-19 10:04:07 +00:00
|
|
|
|
2019-06-11 05:28:52 +00:00
|
|
|
public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null;
|
2019-03-19 10:04:07 +00:00
|
|
|
|
2022-08-10 20:09:58 +00:00
|
|
|
protected override LocalisableString Message => "Click the orange cursor to resume";
|
2019-03-19 10:04:07 +00:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-03-25 06:30:51 +00:00
|
|
|
private void load()
|
2019-03-19 10:04:07 +00:00
|
|
|
{
|
2019-10-15 20:44:04 +00:00
|
|
|
Add(cursorScaleContainer = new Container
|
|
|
|
{
|
|
|
|
Child = clickToResumeCursor = new OsuClickToResumeCursor { ResumeRequested = Resume }
|
|
|
|
});
|
2019-03-19 10:04:07 +00:00
|
|
|
}
|
|
|
|
|
2019-11-01 05:50:38 +00:00
|
|
|
protected override void PopIn()
|
2019-03-19 10:04:07 +00:00
|
|
|
{
|
2019-11-01 05:50:38 +00:00
|
|
|
base.PopIn();
|
|
|
|
|
2019-10-19 09:52:07 +00:00
|
|
|
GameplayCursor.ActiveCursor.Hide();
|
2021-04-20 14:57:12 +00:00
|
|
|
cursorScaleContainer.Position = ToLocalSpace(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre);
|
2019-10-15 20:44:04 +00:00
|
|
|
clickToResumeCursor.Appear();
|
2019-03-25 10:21:34 +00:00
|
|
|
|
|
|
|
if (localCursorContainer == null)
|
2019-10-12 09:51:14 +00:00
|
|
|
{
|
2019-10-14 08:13:36 +00:00
|
|
|
Add(localCursorContainer = new OsuCursorContainer());
|
2019-10-12 09:51:14 +00:00
|
|
|
|
2020-02-01 21:50:29 +00:00
|
|
|
localCursorScale = new BindableFloat();
|
2019-10-19 10:15:31 +00:00
|
|
|
localCursorScale.BindTo(localCursorContainer.CursorScale);
|
|
|
|
localCursorScale.BindValueChanged(scale => cursorScaleContainer.Scale = new Vector2(scale.NewValue), true);
|
2019-10-12 09:51:14 +00:00
|
|
|
}
|
2019-03-19 10:04:07 +00:00
|
|
|
}
|
|
|
|
|
2019-11-01 05:50:38 +00:00
|
|
|
protected override void PopOut()
|
2019-03-19 10:04:07 +00:00
|
|
|
{
|
2019-11-01 05:50:38 +00:00
|
|
|
base.PopOut();
|
|
|
|
|
2019-03-25 10:21:34 +00:00
|
|
|
localCursorContainer?.Expire();
|
|
|
|
localCursorContainer = null;
|
2019-11-01 06:33:38 +00:00
|
|
|
GameplayCursor?.ActiveCursor?.Show();
|
2019-03-19 10:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e) => true;
|
|
|
|
|
2022-11-24 05:32:20 +00:00
|
|
|
public partial class OsuClickToResumeCursor : OsuCursor, IKeyBindingHandler<OsuAction>
|
2019-03-19 10:04:07 +00:00
|
|
|
{
|
|
|
|
public override bool HandlePositionalInput => true;
|
|
|
|
|
|
|
|
public Action ResumeRequested;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-09-16 09:26:12 +00:00
|
|
|
public bool OnPressed(KeyBindingPressEvent<OsuAction> e)
|
2019-03-19 10:04:07 +00:00
|
|
|
{
|
2021-09-16 09:26:12 +00:00
|
|
|
switch (e.Action)
|
2019-03-19 10:04:07 +00:00
|
|
|
{
|
|
|
|
case OsuAction.LeftButton:
|
|
|
|
case OsuAction.RightButton:
|
|
|
|
if (!IsHovered) return false;
|
|
|
|
|
2019-10-15 20:44:04 +00:00
|
|
|
this.ScaleTo(2, TRANSITION_TIME, Easing.OutQuint);
|
2019-03-19 10:04:07 +00:00
|
|
|
|
|
|
|
ResumeRequested?.Invoke();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-09-16 09:26:12 +00:00
|
|
|
public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)
|
2020-01-22 04:22:34 +00:00
|
|
|
{
|
|
|
|
}
|
2019-03-19 10:04:07 +00:00
|
|
|
|
2019-10-15 20:44:04 +00:00
|
|
|
public void Appear() => Schedule(() =>
|
2019-03-19 10:04:07 +00:00
|
|
|
{
|
|
|
|
updateColour();
|
2019-10-15 20:44:04 +00:00
|
|
|
this.ScaleTo(4).Then().ScaleTo(1, 1000, Easing.OutQuint);
|
2019-03-19 10:04:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
private void updateColour()
|
|
|
|
{
|
|
|
|
this.FadeColour(IsHovered ? Color4.White : Color4.Orange, 400, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|