osu/osu.Game/Screens/Multi/Header.cs

103 lines
3.1 KiB
C#
Raw Normal View History

// 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-05-15 23:34:14 +00:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.SearchableList;
2018-11-20 07:51:59 +00:00
using osuTK.Graphics;
2018-05-15 23:34:14 +00:00
namespace osu.Game.Screens.Multi
{
public class Header : Container
{
public const float HEIGHT = 121;
2018-05-17 09:19:55 +00:00
private readonly HeaderBreadcrumbControl breadcrumbs;
2018-05-15 23:34:14 +00:00
2019-01-23 11:52:00 +00:00
public Header(ScreenStack stack)
2018-05-15 23:34:14 +00:00
{
MultiHeaderTitle title;
2018-05-15 23:34:14 +00:00
RelativeSizeAxes = Axes.X;
Height = HEIGHT;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"2f2043"),
},
new Container
{
RelativeSizeAxes = Axes.Both,
2019-01-25 05:10:59 +00:00
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
2018-05-15 23:34:14 +00:00
Children = new Drawable[]
{
2019-03-11 17:37:36 +00:00
title = new MultiHeaderTitle
2018-05-15 23:34:14 +00:00
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomLeft,
2019-04-03 22:24:42 +00:00
X = -ScreenTitle.ICON_WIDTH,
2018-05-15 23:34:14 +00:00
},
2019-01-23 11:52:00 +00:00
breadcrumbs = new HeaderBreadcrumbControl(stack)
2018-05-15 23:34:14 +00:00
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
},
},
},
};
2019-03-11 17:37:36 +00:00
breadcrumbs.Current.ValueChanged += screen =>
{
2019-03-11 17:37:36 +00:00
if (screen.NewValue is IMultiplayerSubScreen multiScreen)
title.Screen = multiScreen;
};
2018-05-15 23:34:14 +00:00
breadcrumbs.Current.TriggerChange();
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
breadcrumbs.StripColour = colours.Green;
}
2018-05-17 09:19:55 +00:00
2019-03-11 17:37:36 +00:00
private class MultiHeaderTitle : ScreenTitle
{
public IMultiplayerSubScreen Screen
{
set => Section = value.ShortTitle.ToLowerInvariant();
}
2019-03-11 17:37:36 +00:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2019-04-23 05:44:43 +00:00
Title = "multi";
Icon = OsuIcon.Multi;
2019-03-11 17:37:36 +00:00
AccentColour = colours.Yellow;
}
}
2018-05-17 09:19:55 +00:00
private class HeaderBreadcrumbControl : ScreenBreadcrumbControl
{
2019-01-23 11:52:00 +00:00
public HeaderBreadcrumbControl(ScreenStack stack)
: base(stack)
2018-05-17 09:19:55 +00:00
{
}
protected override void LoadComplete()
{
base.LoadComplete();
AccentColour = Color4.White;
}
}
2018-05-15 23:34:14 +00:00
}
}