2016-09-30 17:45:27 +08:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2016-10-13 22:57:05 +08:00
|
|
|
|
using System;
|
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;
|
2016-10-07 19:38:52 +08:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
2016-12-01 13:22:29 +08:00
|
|
|
|
using osu.Framework.Input;
|
2016-10-13 22:57:05 +08:00
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
using osu.Game.Graphics;
|
2016-11-14 17:03:20 +08:00
|
|
|
|
using osu.Game.Modes;
|
2016-12-01 12:03:40 +08:00
|
|
|
|
using osu.Game.Online.API;
|
2016-12-01 13:22:29 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
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
|
|
|
|
{
|
2016-10-13 22:57:05 +08:00
|
|
|
|
private const float height = 50;
|
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;
|
2016-11-30 12:50:30 +08:00
|
|
|
|
private Box solidBackground;
|
2016-11-15 15:25:41 +08:00
|
|
|
|
private Box gradientBackground;
|
2016-09-30 17:45:27 +08:00
|
|
|
|
|
2016-11-30 12:50:30 +08:00
|
|
|
|
private const int transition_time = 250;
|
|
|
|
|
|
|
|
|
|
private const float alpha_hovering = 0.8f;
|
|
|
|
|
private const float alpha_normal = 0.6f;
|
|
|
|
|
|
2016-10-07 19:38:52 +08:00
|
|
|
|
|
2016-10-13 22:57:05 +08:00
|
|
|
|
protected override void PopIn()
|
2016-10-07 19:38:52 +08:00
|
|
|
|
{
|
2016-10-13 22:57:05 +08:00
|
|
|
|
MoveToY(0, transition_time, EasingTypes.OutQuint);
|
|
|
|
|
FadeIn(transition_time, EasingTypes.OutQuint);
|
|
|
|
|
}
|
2016-10-07 19:38:52 +08:00
|
|
|
|
|
2016-10-13 22:57:05 +08:00
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2016-10-19 00:53:31 +08:00
|
|
|
|
MoveToY(-DrawSize.Y, transition_time, EasingTypes.InQuint);
|
2016-10-13 22:57:05 +08:00
|
|
|
|
FadeOut(transition_time, EasingTypes.InQuint);
|
2016-10-07 19:38:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 15:25:41 +08:00
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
2016-11-30 12:50:30 +08:00
|
|
|
|
solidBackground.FadeTo(alpha_hovering, transition_time, EasingTypes.OutQuint);
|
|
|
|
|
gradientBackground.FadeIn(transition_time, EasingTypes.OutQuint);
|
2016-11-15 19:35:47 +08:00
|
|
|
|
return true;
|
2016-11-15 15:25:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
2016-11-30 12:50:30 +08:00
|
|
|
|
solidBackground.FadeTo(alpha_normal, transition_time, EasingTypes.OutQuint);
|
|
|
|
|
gradientBackground.FadeOut(transition_time, EasingTypes.OutQuint);
|
2016-11-15 15:25:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 22:24:14 +08:00
|
|
|
|
public Toolbar()
|
2016-09-30 17:45:27 +08:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2016-11-30 12:50:30 +08:00
|
|
|
|
solidBackground = new Box
|
2016-09-30 17:45:27 +08:00
|
|
|
|
{
|
2016-10-01 17:40:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-01-13 05:38:27 +08:00
|
|
|
|
Colour = OsuColour.Gray(0.1f),
|
2016-11-30 12:50:30 +08:00
|
|
|
|
Alpha = alpha_normal,
|
2016-11-15 15:25:41 +08:00
|
|
|
|
},
|
|
|
|
|
gradientBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Height = 90,
|
2017-01-11 02:44:40 +08:00
|
|
|
|
ColourInfo = ColourInfo.GradientVertical(
|
2017-01-13 05:38:27 +08:00
|
|
|
|
OsuColour.Gray(0.1f).Opacity(0.5f), OsuColour.Gray(0.1f).Opacity(0)),
|
2016-10-03 19:39:32 +08:00
|
|
|
|
},
|
2016-10-04 18:57:32 +08:00
|
|
|
|
new FlowContainer
|
2016-10-03 19:39:32 +08:00
|
|
|
|
{
|
|
|
|
|
Direction = FlowDirection.HorizontalOnly,
|
|
|
|
|
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(),
|
|
|
|
|
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
|
|
|
|
|
{
|
2016-10-04 18:57:32 +08:00
|
|
|
|
OnPlayModeChange = OnPlayModeChange
|
2016-10-04 18:41:18 +08:00
|
|
|
|
}
|
2016-10-03 19:39:32 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2016-10-04 18:57:32 +08:00
|
|
|
|
new FlowContainer
|
2016-10-03 19:39:32 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Direction = FlowDirection.HorizontalOnly,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2016-10-22 17:05:46 +08:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
2016-10-03 19:39:32 +08:00
|
|
|
|
Children = new []
|
|
|
|
|
{
|
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
|
|
|
|
},
|
2016-12-01 15:05:54 +08:00
|
|
|
|
new ToolbarUserButton(),
|
2016-10-04 16:15:03 +08:00
|
|
|
|
new ToolbarButton
|
|
|
|
|
{
|
2016-11-07 16:58:32 +08:00
|
|
|
|
Icon = FontAwesome.fa_bars
|
2016-10-04 16:15:03 +08:00
|
|
|
|
},
|
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;
|
|
|
|
|
Size = new Vector2(1, height);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 18:41:18 +08:00
|
|
|
|
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);
|
2016-09-30 17:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|