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
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Drawables;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2016-10-03 19:39:32 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Configuration;
|
2016-10-04 16:15:03 +08:00
|
|
|
|
using System;
|
2016-10-07 19:38:52 +08:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
|
|
|
|
using osu.Framework.Timing;
|
2016-10-04 16:15:03 +08:00
|
|
|
|
using osu.Game.GameModes.Play;
|
2016-10-10 16:17:26 +08:00
|
|
|
|
using osu.Framework;
|
2016-09-30 17:45:27 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2016-10-13 22:21:15 +08:00
|
|
|
|
public class Toolbar : Container, IStateful<Visibility>
|
2016-09-30 17:45:27 +08:00
|
|
|
|
{
|
|
|
|
|
const float height = 50;
|
2016-10-04 16:15:03 +08:00
|
|
|
|
|
|
|
|
|
public Action OnSettings;
|
|
|
|
|
public Action OnHome;
|
|
|
|
|
public Action<PlayMode> OnPlayModeChange;
|
|
|
|
|
|
2016-10-04 18:41:18 +08:00
|
|
|
|
private ToolbarModeSelector modeSelector;
|
2016-09-30 17:45:27 +08:00
|
|
|
|
|
2016-10-13 22:21:15 +08:00
|
|
|
|
private Visibility state;
|
2016-10-07 19:38:52 +08:00
|
|
|
|
|
2016-10-13 22:21:15 +08:00
|
|
|
|
public Visibility State
|
2016-10-07 19:38:52 +08:00
|
|
|
|
{
|
2016-10-08 11:53:46 +08:00
|
|
|
|
get { return state; }
|
|
|
|
|
set
|
2016-10-07 19:38:52 +08:00
|
|
|
|
{
|
2016-10-08 11:53:46 +08:00
|
|
|
|
state = value;
|
2016-10-07 23:41:31 +08:00
|
|
|
|
|
2016-10-08 11:53:46 +08:00
|
|
|
|
const int transition_time = 200;
|
2016-10-07 19:38:52 +08:00
|
|
|
|
|
2016-10-08 11:53:46 +08:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
2016-10-13 22:21:15 +08:00
|
|
|
|
case Visibility.Hidden:
|
2016-10-08 11:53:46 +08:00
|
|
|
|
MoveToY(-Size.Y, transition_time, EasingTypes.InQuint);
|
2016-10-08 12:05:15 +08:00
|
|
|
|
FadeOut(transition_time, EasingTypes.InQuint);
|
2016-10-08 11:53:46 +08:00
|
|
|
|
break;
|
2016-10-13 22:21:15 +08:00
|
|
|
|
case Visibility.Visible:
|
2016-10-08 11:53:46 +08:00
|
|
|
|
MoveToY(0, transition_time, EasingTypes.OutQuint);
|
2016-10-08 12:05:15 +08:00
|
|
|
|
FadeIn(transition_time, EasingTypes.OutQuint);
|
2016-10-08 11:53:46 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2016-10-07 19:38:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 16:17:26 +08:00
|
|
|
|
public override void Load(BaseGame game)
|
2016-09-30 17:45:27 +08:00
|
|
|
|
{
|
2016-10-10 16:17:26 +08:00
|
|
|
|
base.Load(game);
|
2016-09-30 17:45:27 +08:00
|
|
|
|
|
2016-10-01 17:40:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2016-09-30 17:45:27 +08:00
|
|
|
|
Size = new Vector2(1, height);
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
2016-10-01 17:40:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2016-10-04 18:41:18 +08:00
|
|
|
|
Colour = new Color4(0.1f, 0.1f, 0.1f, 0.4f)
|
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-04 18:41:18 +08:00
|
|
|
|
Children = new Drawable[]
|
2016-10-03 19:39:32 +08:00
|
|
|
|
{
|
2016-10-04 16:15:03 +08:00
|
|
|
|
new ToolbarButton
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.gear,
|
2016-10-04 18:41:18 +08:00
|
|
|
|
Action = OnSettings,
|
2016-10-04 18:57:32 +08:00
|
|
|
|
TooltipMain = "Settings",
|
|
|
|
|
TooltipSub = "Change your settings",
|
2016-10-04 16:15:03 +08:00
|
|
|
|
},
|
|
|
|
|
new ToolbarButton
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.home,
|
2016-10-04 18:41:18 +08:00
|
|
|
|
TooltipMain = "Home",
|
2016-10-04 18:57:32 +08:00
|
|
|
|
TooltipSub = "Return to the main menu",
|
2016-10-04 16:15:03 +08:00
|
|
|
|
Action = OnHome
|
|
|
|
|
},
|
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,
|
|
|
|
|
Children = new []
|
|
|
|
|
{
|
2016-10-04 16:15:03 +08:00
|
|
|
|
new ToolbarButton
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.search
|
|
|
|
|
},
|
|
|
|
|
new ToolbarButton
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.user,
|
2016-10-10 16:17:26 +08:00
|
|
|
|
Text = ((OsuGame)game).Config.Get<string>(OsuConfig.Username)
|
2016-10-04 16:15:03 +08:00
|
|
|
|
},
|
|
|
|
|
new ToolbarButton
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.bars
|
|
|
|
|
},
|
2016-10-03 19:39:32 +08:00
|
|
|
|
}
|
2016-09-30 17:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2016-10-03 19:39:32 +08:00
|
|
|
|
|
2016-10-04 18:41:18 +08:00
|
|
|
|
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);
|
2016-09-30 17:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|