1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:47:52 +08:00

Adjust design and feel

This commit is contained in:
Dean Herbert 2018-05-22 00:49:33 +09:00
parent d5afccd610
commit f9c162dee9

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using OpenTK; using OpenTK;
@ -26,7 +27,7 @@ namespace osu.Game.Screens.Play.HUD
set => button.ExitAction = value; set => button.ExitAction = value;
} }
OsuSpriteText text; private readonly OsuSpriteText text;
public QuitButton() public QuitButton()
{ {
@ -65,15 +66,32 @@ namespace osu.Game.Screens.Play.HUD
base.OnHoverLost(state); base.OnHoverLost(state);
} }
protected override void Update()
{
base.Update();
float adjust = Vector2.Distance(GetContainingInputManager().CurrentState.Mouse.NativeState.Position, button.ScreenSpaceDrawQuad.Centre) / 200;
double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000);
bool stayVisible = text.Alpha > 0 || button.Progress > 0 || IsHovered;
Alpha = stayVisible ? 1 : Interpolation.ValueAt(elapsed, Alpha, MathHelper.Clamp(1 - adjust, 0.04f, 1), 0, 200, Easing.OutQuint);
}
private class Button : CircularContainer private class Button : CircularContainer
{ {
private SpriteIcon icon; private SpriteIcon icon;
private CircularProgress progress; private CircularProgress progress;
private Circle innerCircle;
private bool triggered;
public Action ExitAction { get; set; } public Action ExitAction { get; set; }
public double Progress => progress.Current.Value;
private const int fade_duration = 200; private const int fade_duration = 200;
private const int progress_duration = 1000; private const int progress_duration = 600;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
@ -86,31 +104,55 @@ namespace osu.Game.Screens.Play.HUD
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colours.Gray1, Colour = colours.Gray1,
Alpha = 0.8f, Alpha = 0.5f,
},
progress = new CircularProgress
{
RelativeSizeAxes = Axes.Both,
InnerRadius = 1
},
innerCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = colours.Gray1,
Size = new Vector2(0.9f),
}, },
icon = new SpriteIcon icon = new SpriteIcon
{ {
Shadow = false,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(15), Size = new Vector2(15),
Icon = FontAwesome.fa_close Icon = FontAwesome.fa_close
}, },
progress = new CircularProgress { RelativeSizeAxes = Axes.Both, InnerRadius = 0.1f }
}); });
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{ {
icon.ScaleTo(1.5f); if (state.Mouse.Buttons.Count > 1 || triggered)
progress.FillTo(1, progress_duration).OnComplete(cp => ExitAction()); return true;
icon.ScaleTo(1.4f, progress_duration);
progress.FillTo(1, progress_duration, Easing.OutSine).OnComplete(_ =>
{
innerCircle.ScaleTo(0, 100).Then().FadeOut().ScaleTo(1).FadeIn(500);
triggered = true;
ExitAction();
});
return base.OnMouseDown(state, args); return base.OnMouseDown(state, args);
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{ {
icon.ScaleTo(1f); if (state.Mouse.Buttons.Count > 0 || triggered)
progress.FillTo(0, progress_duration / 4f).OnComplete(cp => progress.Current.SetDefault()); return true;
icon.ScaleTo(1, 800, Easing.OutElastic);
progress.FillTo(0, progress_duration, Easing.OutQuint).OnComplete(cp => progress.Current.SetDefault());
return base.OnMouseUp(state, args); return base.OnMouseUp(state, args);
} }