2017-04-09 22:44:19 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using OpenTK.Input;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-04-10 11:06:10 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-04-10 11:06:10 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2017-04-09 22:44:19 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
|
{
|
2017-04-10 11:06:10 +08:00
|
|
|
|
public class HotkeyRetryOverlay : Container
|
2017-04-09 22:44:19 +08:00
|
|
|
|
{
|
|
|
|
|
public Action Action;
|
|
|
|
|
|
2017-04-10 11:06:10 +08:00
|
|
|
|
private Box overlay;
|
|
|
|
|
|
2017-04-10 16:25:56 +08:00
|
|
|
|
private const int activate_delay = 400;
|
2017-04-10 11:06:10 +08:00
|
|
|
|
private const int fadeout_delay = 200;
|
2017-04-09 22:44:19 +08:00
|
|
|
|
|
2017-04-10 16:25:46 +08:00
|
|
|
|
private bool fired;
|
|
|
|
|
|
2017-04-09 22:44:19 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-06-30 03:05:37 +08:00
|
|
|
|
private void load()
|
2017-04-09 22:44:19 +08:00
|
|
|
|
{
|
2017-04-10 11:06:10 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2017-04-09 22:44:19 +08:00
|
|
|
|
AlwaysPresent = true;
|
2017-04-10 11:06:10 +08:00
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
overlay = new Box
|
|
|
|
|
{
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-04-09 22:44:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Repeat) return false;
|
|
|
|
|
|
|
|
|
|
if (args.Key == Key.Tilde)
|
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
overlay.FadeIn(activate_delay, Easing.Out);
|
2017-04-09 22:44:19 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.OnKeyDown(state, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
|
|
|
|
|
{
|
2017-04-10 16:25:46 +08:00
|
|
|
|
if (args.Key == Key.Tilde && !fired)
|
2017-04-09 22:44:19 +08:00
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
overlay.FadeOut(fadeout_delay, Easing.Out);
|
2017-04-09 22:44:19 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.OnKeyUp(state, args);
|
|
|
|
|
}
|
2017-04-10 16:25:46 +08:00
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
if (!fired && overlay.Alpha == 1)
|
|
|
|
|
{
|
|
|
|
|
fired = true;
|
|
|
|
|
Action?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-09 22:44:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|