2017-02-07 12:59:30 +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
|
2016-09-30 17:45:27 +08:00
|
|
|
|
|
2016-10-13 22:57:05 +08:00
|
|
|
|
using System;
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-09-30 17:45:27 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-12-01 13:22:29 +08:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2016-09-30 17:45:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2016-12-01 13:22:29 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-02-25 20:12:39 +08:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2016-12-01 13:22:29 +08:00
|
|
|
|
using osu.Framework.Input;
|
2016-10-13 22:57:05 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2016-11-14 17:03:20 +08:00
|
|
|
|
using osu.Game.Modes;
|
2016-12-01 13:22:29 +08:00
|
|
|
|
using OpenTK;
|
2016-09-30 17:45:27 +08:00
|
|
|
|
|
2016-12-01 13:22:29 +08:00
|
|
|
|
namespace osu.Game.Overlays.Toolbar
|
2016-09-30 17:45:27 +08:00
|
|
|
|
{
|
2016-12-01 15:05:54 +08:00
|
|
|
|
public class Toolbar : OverlayContainer
|
2016-09-30 17:45:27 +08:00
|
|
|
|
{
|
2017-02-08 19:14:17 +08:00
|
|
|
|
public const float HEIGHT = 40;
|
2017-02-10 15:26:43 +08:00
|
|
|
|
public const float TOOLTIP_HEIGHT = 30;
|
2016-10-04 16:15:03 +08:00
|
|
|
|
|
|
|
|
|
public Action OnHome;
|
|
|
|
|
public Action<PlayMode> OnPlayModeChange;
|
|
|
|
|
|
2016-10-04 18:41:18 +08:00
|
|
|
|
private ToolbarModeSelector modeSelector;
|
2017-02-08 18:53:50 +08:00
|
|
|
|
private ToolbarUserArea userArea;
|
2016-09-30 17:45:27 +08:00
|
|
|
|
|
2017-02-09 11:46:53 +08:00
|
|
|
|
protected override bool HideOnEscape => false;
|
|
|
|
|
|
|
|
|
|
protected override bool BlockPassThroughInput => false;
|
|
|
|
|
|
2017-03-09 14:52:40 +08:00
|
|
|
|
private const double transition_time = 500;
|
2016-11-30 12:50:30 +08:00
|
|
|
|
|
|
|
|
|
private const float alpha_hovering = 0.8f;
|
|
|
|
|
private const float alpha_normal = 0.6f;
|
|
|
|
|
|
2016-11-01 22:24:14 +08:00
|
|
|
|
public Toolbar()
|
2016-09-30 17:45:27 +08:00
|
|
|
|
{
|
2017-03-16 16:38:36 +08:00
|
|
|
|
AlwaysReceiveInput = true;
|
|
|
|
|
|
2016-09-30 17:45:27 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-01-30 22:24:30 +08:00
|
|
|
|
new ToolbarBackground(),
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2016-10-03 19:39:32 +08:00
|
|
|
|
{
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2016-10-03 19:39:32 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2016-10-22 17:05:46 +08:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
2016-10-04 18:41:18 +08:00
|
|
|
|
Children = new Drawable[]
|
2016-10-03 19:39:32 +08:00
|
|
|
|
{
|
2016-12-02 17:43:01 +08:00
|
|
|
|
new ToolbarSettingsButton(),
|
2017-03-07 09:59:19 +08:00
|
|
|
|
new ToolbarHomeButton
|
2016-10-04 16:15:03 +08:00
|
|
|
|
{
|
2016-11-04 11:27:43 +08:00
|
|
|
|
Action = () => OnHome?.Invoke()
|
2016-10-04 16:15:03 +08:00
|
|
|
|
},
|
2016-10-04 18:41:18 +08:00
|
|
|
|
modeSelector = new ToolbarModeSelector
|
|
|
|
|
{
|
2017-03-09 13:25:49 +08:00
|
|
|
|
OnPlayModeChange = mode =>
|
2017-03-02 21:01:24 +08:00
|
|
|
|
{
|
|
|
|
|
OnPlayModeChange?.Invoke(mode);
|
|
|
|
|
}
|
2016-10-04 18:41:18 +08:00
|
|
|
|
}
|
2016-10-03 19:39:32 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2017-03-16 16:38:36 +08:00
|
|
|
|
new FillFlowContainer
|
2016-10-03 19:39:32 +08:00
|
|
|
|
{
|
2017-03-16 16:38:36 +08:00
|
|
|
|
AlwaysReceiveInput = true,
|
2016-10-03 19:39:32 +08:00
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2016-10-03 19:39:32 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2016-10-22 17:05:46 +08:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
2017-01-31 15:59:38 +08:00
|
|
|
|
Children = new Drawable[]
|
2016-10-03 19:39:32 +08:00
|
|
|
|
{
|
2016-12-02 17:43:01 +08:00
|
|
|
|
new ToolbarMusicButton(),
|
2016-10-04 16:15:03 +08:00
|
|
|
|
new ToolbarButton
|
|
|
|
|
{
|
2016-11-07 16:58:32 +08:00
|
|
|
|
Icon = FontAwesome.fa_search
|
2016-10-04 16:15:03 +08:00
|
|
|
|
},
|
2017-02-08 18:53:50 +08:00
|
|
|
|
userArea = new ToolbarUserArea(),
|
2017-02-10 15:26:43 +08:00
|
|
|
|
new ToolbarNotificationButton(),
|
2016-10-03 19:39:32 +08:00
|
|
|
|
}
|
2016-09-30 17:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2016-11-01 22:24:14 +08:00
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2017-01-30 21:00:23 +08:00
|
|
|
|
Size = new Vector2(1, HEIGHT);
|
2016-11-01 22:24:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-30 22:24:30 +08:00
|
|
|
|
public class ToolbarBackground : Container
|
|
|
|
|
{
|
|
|
|
|
private Box solidBackground;
|
|
|
|
|
private Box gradientBackground;
|
|
|
|
|
|
|
|
|
|
public ToolbarBackground()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
solidBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = OsuColour.Gray(0.1f),
|
|
|
|
|
Alpha = alpha_normal,
|
|
|
|
|
},
|
|
|
|
|
gradientBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Height = 90,
|
|
|
|
|
ColourInfo = ColourInfo.GradientVertical(
|
|
|
|
|
OsuColour.Gray(0.1f).Opacity(0.5f), OsuColour.Gray(0.1f).Opacity(0)),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
|
|
|
|
solidBackground.FadeTo(alpha_hovering, transition_time, EasingTypes.OutQuint);
|
|
|
|
|
gradientBackground.FadeIn(transition_time, EasingTypes.OutQuint);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
|
|
|
|
solidBackground.FadeTo(alpha_normal, transition_time, EasingTypes.OutQuint);
|
|
|
|
|
gradientBackground.FadeOut(transition_time, EasingTypes.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 18:41:18 +08:00
|
|
|
|
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);
|
2017-01-30 21:53:50 +08:00
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
MoveToY(0, transition_time, EasingTypes.OutQuint);
|
2017-02-08 18:46:05 +08:00
|
|
|
|
FadeIn(transition_time / 2, EasingTypes.OutQuint);
|
2017-01-30 21:53:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2017-02-08 18:53:50 +08:00
|
|
|
|
userArea?.LoginOverlay.Hide();
|
|
|
|
|
|
2017-02-08 18:32:55 +08:00
|
|
|
|
MoveToY(-DrawSize.Y, transition_time, EasingTypes.OutQuint);
|
|
|
|
|
FadeOut(transition_time);
|
2017-01-30 21:53:50 +08:00
|
|
|
|
}
|
2016-09-30 17:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|