mirror of
https://github.com/ppy/osu
synced 2024-12-22 23:05:02 +00:00
111 lines
3.7 KiB
C#
111 lines
3.7 KiB
C#
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
using System;
|
|
using OpenTK;
|
|
using OpenTK.Graphics;
|
|
using osu.Framework;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Drawables;
|
|
using osu.Framework.Graphics.Transformations;
|
|
using osu.Game.Configuration;
|
|
using osu.Game.GameModes.Play;
|
|
using osu.Game.Graphics;
|
|
|
|
namespace osu.Game.Overlays
|
|
{
|
|
public class Toolbar : Overlay
|
|
{
|
|
private const float height = 50;
|
|
|
|
public Action OnSettings;
|
|
public Action OnHome;
|
|
public Action<PlayMode> OnPlayModeChange;
|
|
|
|
private ToolbarModeSelector modeSelector;
|
|
|
|
private const int transition_time = 200;
|
|
|
|
protected override void PopIn()
|
|
{
|
|
MoveToY(0, transition_time, EasingTypes.OutQuint);
|
|
FadeIn(transition_time, EasingTypes.OutQuint);
|
|
}
|
|
|
|
protected override void PopOut()
|
|
{
|
|
MoveToY(-Size.Y, transition_time, EasingTypes.InQuint);
|
|
FadeOut(transition_time, EasingTypes.InQuint);
|
|
}
|
|
|
|
public override void Load(BaseGame game)
|
|
{
|
|
base.Load(game);
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
Size = new Vector2(1, height);
|
|
|
|
Children = new Drawable[]
|
|
{
|
|
new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Colour = new Color4(0.1f, 0.1f, 0.1f, 0.4f)
|
|
},
|
|
new FlowContainer
|
|
{
|
|
Direction = FlowDirection.HorizontalOnly,
|
|
RelativeSizeAxes = Axes.Y,
|
|
Children = new Drawable[]
|
|
{
|
|
new ToolbarButton
|
|
{
|
|
Icon = FontAwesome.gear,
|
|
Action = OnSettings,
|
|
TooltipMain = "Settings",
|
|
TooltipSub = "Change your settings",
|
|
},
|
|
new ToolbarButton
|
|
{
|
|
Icon = FontAwesome.home,
|
|
TooltipMain = "Home",
|
|
TooltipSub = "Return to the main menu",
|
|
Action = OnHome
|
|
},
|
|
modeSelector = new ToolbarModeSelector
|
|
{
|
|
OnPlayModeChange = OnPlayModeChange
|
|
}
|
|
}
|
|
},
|
|
new FlowContainer
|
|
{
|
|
Anchor = Anchor.TopRight,
|
|
Origin = Anchor.TopRight,
|
|
Direction = FlowDirection.HorizontalOnly,
|
|
RelativeSizeAxes = Axes.Y,
|
|
Children = new []
|
|
{
|
|
new ToolbarButton
|
|
{
|
|
Icon = FontAwesome.search
|
|
},
|
|
new ToolbarButton
|
|
{
|
|
Icon = FontAwesome.user,
|
|
Text = ((OsuGame)game).Config.Get<string>(OsuConfig.Username)
|
|
},
|
|
new ToolbarButton
|
|
{
|
|
Icon = FontAwesome.bars
|
|
},
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);
|
|
}
|
|
}
|