2019-01-24 08:43:03 +00: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 09:19:50 +00: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 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-05-28 11:43:47 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-10-02 03:02:47 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2019-06-24 20:13:28 +00:00
|
|
|
|
using osu.Game.Rulesets;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Toolbar
|
|
|
|
|
{
|
2019-10-14 23:27:59 +00:00
|
|
|
|
public class Toolbar : VisibilityContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
public const float HEIGHT = 40;
|
|
|
|
|
public const float TOOLTIP_HEIGHT = 30;
|
|
|
|
|
|
|
|
|
|
public Action OnHome;
|
|
|
|
|
|
2019-03-28 05:01:06 +00:00
|
|
|
|
private ToolbarUserButton userButton;
|
2019-06-24 20:13:28 +00:00
|
|
|
|
private ToolbarRulesetSelector rulesetSelector;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
private const double transition_time = 500;
|
|
|
|
|
|
2020-08-27 18:07:24 +00:00
|
|
|
|
protected readonly IBindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
2018-05-28 11:43:47 +00:00
|
|
|
|
|
2020-04-25 09:23:09 +00:00
|
|
|
|
// Toolbar components like RulesetSelector should receive keyboard input events even when the toolbar is hidden.
|
2020-04-25 06:53:09 +00:00
|
|
|
|
public override bool PropagateNonPositionalInputSubTree => true;
|
|
|
|
|
|
2019-03-08 06:14:07 +00:00
|
|
|
|
public Toolbar()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Size = new Vector2(1, HEIGHT);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-08 03:01:40 +00:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2019-06-24 20:13:28 +00:00
|
|
|
|
private void load(OsuGame osuGame, Bindable<RulesetInfo> parentRuleset)
|
2018-04-13 09:19:50 +00: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-24 20:13:28 +00:00
|
|
|
|
rulesetSelector = new ToolbarRulesetSelector()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-07-16 11:48:40 +00:00
|
|
|
|
new ToolbarNewsButton(),
|
2019-05-13 08:01:17 +00:00
|
|
|
|
new ToolbarChangelogButton(),
|
2020-02-13 10:39:33 +00:00
|
|
|
|
new ToolbarRankingsButton(),
|
2020-04-21 07:00:00 +00:00
|
|
|
|
new ToolbarBeatmapListingButton(),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
new ToolbarChatButton(),
|
|
|
|
|
new ToolbarSocialButton(),
|
|
|
|
|
new ToolbarMusicButton(),
|
|
|
|
|
//new ToolbarButton
|
|
|
|
|
//{
|
2019-04-02 10:55:24 +00:00
|
|
|
|
// Icon = FontAwesome.Solid.search
|
2018-04-13 09:19:50 +00:00
|
|
|
|
//},
|
2019-03-28 05:01:06 +00:00
|
|
|
|
userButton = new ToolbarUserButton(),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
new ToolbarNotificationButton(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-26 08:52:25 +00: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-24 20:13:28 +00:00
|
|
|
|
|
2018-09-05 01:38:05 +00:00
|
|
|
|
if (osuGame != null)
|
2020-08-18 13:25:51 +00:00
|
|
|
|
OverlayActivationMode.BindTo(osuGame.OverlayActivationMode);
|
2018-05-28 11:43:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public class ToolbarBackground : Container
|
|
|
|
|
{
|
|
|
|
|
private readonly Box gradientBackground;
|
|
|
|
|
|
|
|
|
|
public ToolbarBackground()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-07-08 04:36:32 +00:00
|
|
|
|
new Box
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = OsuColour.Gray(0.1f),
|
|
|
|
|
},
|
|
|
|
|
gradientBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Alpha = 0,
|
2020-08-17 05:56:05 +00:00
|
|
|
|
Height = 100,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Colour = ColourInfo.GradientVertical(
|
2020-08-17 05:56:05 +00:00
|
|
|
|
OsuColour.Gray(0).Opacity(0.9f), OsuColour.Gray(0).Opacity(0)),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
gradientBackground.FadeIn(transition_time, Easing.OutQuint);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
gradientBackground.FadeOut(transition_time, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-18 13:25:51 +00:00
|
|
|
|
protected override void UpdateState(ValueChangedEvent<Visibility> state)
|
|
|
|
|
{
|
|
|
|
|
if (state.NewValue == Visibility.Visible && OverlayActivationMode.Value == OverlayActivation.Disabled)
|
|
|
|
|
{
|
|
|
|
|
State.Value = Visibility.Hidden;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.UpdateState(state);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
this.MoveToY(0, transition_time, Easing.OutQuint);
|
2020-07-08 06:06:40 +00:00
|
|
|
|
this.FadeIn(transition_time / 4, Easing.OutQuint);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2020-04-25 06:45:11 +00:00
|
|
|
|
userButton.StateContainer?.Hide();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
this.MoveToY(-DrawSize.Y, transition_time, Easing.OutQuint);
|
2020-07-08 06:06:40 +00:00
|
|
|
|
this.FadeOut(transition_time, Easing.InQuint);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|