2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-05-28 19:43:47 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-10-02 11:02:47 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2019-06-25 04:13:28 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Toolbar
|
|
|
|
|
{
|
|
|
|
|
public class Toolbar : OverlayContainer
|
|
|
|
|
{
|
|
|
|
|
public const float HEIGHT = 40;
|
|
|
|
|
public const float TOOLTIP_HEIGHT = 30;
|
|
|
|
|
|
|
|
|
|
public Action OnHome;
|
|
|
|
|
|
2019-03-28 13:01:06 +08:00
|
|
|
|
private ToolbarUserButton userButton;
|
2019-06-25 04:13:28 +08:00
|
|
|
|
private ToolbarRulesetSelector rulesetSelector;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-09-26 13:01:15 +08:00
|
|
|
|
protected override bool BlockPositionalInput => false;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private const double transition_time = 500;
|
|
|
|
|
|
|
|
|
|
private const float alpha_hovering = 0.8f;
|
|
|
|
|
private const float alpha_normal = 0.6f;
|
|
|
|
|
|
2018-06-06 15:55:16 +08:00
|
|
|
|
private readonly Bindable<OverlayActivation> overlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
2018-05-28 19:43:47 +08:00
|
|
|
|
|
2019-03-08 14:14:07 +08:00
|
|
|
|
public Toolbar()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Size = new Vector2(1, HEIGHT);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-08 11:01:40 +08:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2019-06-25 04:13:28 +08:00
|
|
|
|
private void load(OsuGame osuGame, Bindable<RulesetInfo> parentRuleset)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new ToolbarBackground(),
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new ToolbarSettingsButton(),
|
|
|
|
|
new ToolbarHomeButton
|
|
|
|
|
{
|
|
|
|
|
Action = () => OnHome?.Invoke()
|
|
|
|
|
},
|
2019-06-25 04:13:28 +08:00
|
|
|
|
rulesetSelector = new ToolbarRulesetSelector()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-05-13 16:01:17 +08:00
|
|
|
|
new ToolbarChangelogButton(),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
new ToolbarDirectButton(),
|
|
|
|
|
new ToolbarChatButton(),
|
|
|
|
|
new ToolbarSocialButton(),
|
|
|
|
|
new ToolbarMusicButton(),
|
|
|
|
|
//new ToolbarButton
|
|
|
|
|
//{
|
2019-04-02 18:55:24 +08:00
|
|
|
|
// Icon = FontAwesome.Solid.search
|
2018-04-13 17:19:50 +08:00
|
|
|
|
//},
|
2019-03-28 13:01:06 +08:00
|
|
|
|
userButton = new ToolbarUserButton(),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
new ToolbarNotificationButton(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-26 16:52:25 +08:00
|
|
|
|
// Bound after the selector is added to the hierarchy to give it a chance to load the available rulesets
|
|
|
|
|
rulesetSelector.Current.BindTo(parentRuleset);
|
2019-06-25 04:13:28 +08:00
|
|
|
|
|
2019-06-11 13:28:52 +08:00
|
|
|
|
State.ValueChanged += visibility =>
|
2018-05-28 19:43:47 +08:00
|
|
|
|
{
|
2019-02-21 17:56:34 +08:00
|
|
|
|
if (overlayActivationMode.Value == OverlayActivation.Disabled)
|
2019-06-11 13:28:52 +08:00
|
|
|
|
Hide();
|
2018-05-28 19:43:47 +08:00
|
|
|
|
};
|
2018-09-05 09:38:05 +08:00
|
|
|
|
|
|
|
|
|
if (osuGame != null)
|
|
|
|
|
overlayActivationMode.BindTo(osuGame.OverlayActivationMode);
|
2018-05-28 19:43:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public class ToolbarBackground : Container
|
|
|
|
|
{
|
|
|
|
|
private readonly Box solidBackground;
|
|
|
|
|
private readonly 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,
|
|
|
|
|
Colour = ColourInfo.GradientVertical(
|
|
|
|
|
OsuColour.Gray(0.1f).Opacity(0.5f), OsuColour.Gray(0.1f).Opacity(0)),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
solidBackground.FadeTo(alpha_hovering, transition_time, Easing.OutQuint);
|
|
|
|
|
gradientBackground.FadeIn(transition_time, Easing.OutQuint);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
solidBackground.FadeTo(alpha_normal, transition_time, Easing.OutQuint);
|
|
|
|
|
gradientBackground.FadeOut(transition_time, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
this.MoveToY(0, transition_time, Easing.OutQuint);
|
|
|
|
|
this.FadeIn(transition_time / 2, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2019-03-28 13:01:06 +08:00
|
|
|
|
userButton?.StateContainer.Hide();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
this.MoveToY(-DrawSize.Y, transition_time, Easing.OutQuint);
|
|
|
|
|
this.FadeOut(transition_time);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|