1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 00:42:53 +08:00
osu-lazer/osu.Game/Screens/Multi/Header.cs

167 lines
5.7 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-16 07:34:14 +08:00
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
2018-05-16 07:34:14 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
2018-05-16 07:34:14 +08:00
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.SearchableList;
using osu.Game.Graphics.Sprites;
using osuTK;
2018-11-20 15:51:59 +08:00
using osuTK.Graphics;
2018-05-16 07:34:14 +08:00
namespace osu.Game.Screens.Multi
{
public class Header : Container
{
public const float HEIGHT = 121;
2018-05-17 17:19:55 +08:00
private readonly HeaderBreadcrumbControl breadcrumbs;
2018-05-16 07:34:14 +08:00
2019-01-23 19:52:00 +08:00
public Header(ScreenStack stack)
2018-05-16 07:34:14 +08:00
{
MultiHeaderTitle title;
2018-05-16 07:34:14 +08:00
RelativeSizeAxes = Axes.X;
Height = HEIGHT;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4Extensions.FromHex(@"2f2043"),
2018-05-16 07:34:14 +08:00
},
new Container
{
RelativeSizeAxes = Axes.Both,
2019-01-25 13:10:59 +08:00
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
2018-05-16 07:34:14 +08:00
Children = new Drawable[]
{
2019-03-12 01:37:36 +08:00
title = new MultiHeaderTitle
2018-05-16 07:34:14 +08:00
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomLeft,
X = -MultiHeaderTitle.ICON_WIDTH,
2018-05-16 07:34:14 +08:00
},
2019-01-23 19:52:00 +08:00
breadcrumbs = new HeaderBreadcrumbControl(stack)
2018-05-16 07:34:14 +08:00
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
},
},
},
};
2019-03-12 01:37:36 +08:00
breadcrumbs.Current.ValueChanged += screen =>
{
2019-03-12 01:37:36 +08:00
if (screen.NewValue is IMultiplayerSubScreen multiScreen)
title.Screen = multiScreen;
};
2018-05-16 07:34:14 +08:00
breadcrumbs.Current.TriggerChange();
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
breadcrumbs.StripColour = colours.Green;
}
2018-05-17 17:19:55 +08:00
private class MultiHeaderTitle : CompositeDrawable, IHasAccentColour
2019-03-12 01:37:36 +08:00
{
2020-03-27 00:18:01 +08:00
public const float ICON_WIDTH = icon_size + spacing;
2020-03-27 00:18:01 +08:00
private const float icon_size = 25;
private const float spacing = 6;
private const int text_offset = 2;
2020-03-26 23:11:58 +08:00
private readonly SpriteIcon iconSprite;
2020-03-27 00:18:01 +08:00
private readonly OsuSpriteText title, pageText;
public IMultiplayerSubScreen Screen
{
set => pageText.Text = value.ShortTitle.ToLowerInvariant();
}
public Color4 AccentColour
{
get => pageText.Colour;
set => pageText.Colour = value;
}
public MultiHeaderTitle()
{
AutoSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(spacing, 0),
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
iconSprite = new SpriteIcon
{
2020-03-27 00:18:01 +08:00
Size = new Vector2(icon_size),
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
2020-03-27 00:18:01 +08:00
title = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
Margin = new MarginPadding { Bottom = text_offset }
},
new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(4),
Colour = Color4.Gray,
},
pageText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 20),
Margin = new MarginPadding { Bottom = text_offset }
}
}
},
};
}
2019-03-12 01:37:36 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2020-03-27 00:18:01 +08:00
title.Text = "multi";
iconSprite.Icon = OsuIcon.Multi;
2019-03-12 01:37:36 +08:00
AccentColour = colours.Yellow;
}
}
2018-05-17 17:19:55 +08:00
private class HeaderBreadcrumbControl : ScreenBreadcrumbControl
{
2019-01-23 19:52:00 +08:00
public HeaderBreadcrumbControl(ScreenStack stack)
: base(stack)
2018-05-17 17:19:55 +08:00
{
}
protected override void LoadComplete()
{
base.LoadComplete();
AccentColour = Color4.White;
}
}
2018-05-16 07:34:14 +08:00
}
}