2019-01-24 17:43:03 +09: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-05-15 20:34:14 -03:00
|
|
|
|
|
2020-06-25 21:58:40 +09:00
|
|
|
|
using Humanizer;
|
2018-05-15 20:34:14 -03:00
|
|
|
|
using osu.Framework.Allocation;
|
2020-03-11 10:18:41 +09:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2018-05-15 20:34:14 -03:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2020-06-25 21:58:40 +09:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2018-05-15 20:34:14 -03:00
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Graphics;
|
2020-03-24 22:03:16 +01:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2020-12-25 16:50:00 +01:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-09-03 16:28:14 +09:00
|
|
|
|
using osu.Game.Overlays;
|
2020-03-24 22:03:16 +01:00
|
|
|
|
using osuTK;
|
2018-11-20 16:51:59 +09:00
|
|
|
|
using osuTK.Graphics;
|
2018-05-15 20:34:14 -03:00
|
|
|
|
|
2020-12-25 16:50:00 +01:00
|
|
|
|
namespace osu.Game.Screens.OnlinePlay
|
2018-05-15 20:34:14 -03:00
|
|
|
|
{
|
|
|
|
|
public class Header : Container
|
|
|
|
|
{
|
2020-06-25 22:22:24 +09:00
|
|
|
|
public const float HEIGHT = 80;
|
2018-05-15 20:34:14 -03:00
|
|
|
|
|
2020-12-24 16:18:35 +01:00
|
|
|
|
public Header(string mainTitle, ScreenStack stack)
|
2018-05-15 20:34:14 -03:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = HEIGHT;
|
|
|
|
|
|
2020-06-25 21:58:40 +09:00
|
|
|
|
HeaderBreadcrumbControl breadcrumbs;
|
|
|
|
|
MultiHeaderTitle title;
|
|
|
|
|
|
2018-05-15 20:34:14 -03:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-06-25 21:58:40 +09:00
|
|
|
|
Colour = Color4Extensions.FromHex(@"#1f1921"),
|
2018-05-15 20:34:14 -03:00
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
2020-06-25 21:58:40 +09:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2018-05-15 20:34:14 -03:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-09-03 16:28:14 +09:00
|
|
|
|
Padding = new MarginPadding { Left = WaveOverlayContainer.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
|
2018-05-15 20:34:14 -03:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-12-24 16:18:35 +01:00
|
|
|
|
title = new MultiHeaderTitle(mainTitle)
|
2018-05-15 20:34:14 -03:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2020-06-25 22:22:24 +09:00
|
|
|
|
Origin = Anchor.BottomLeft,
|
2018-05-15 20:34:14 -03:00
|
|
|
|
},
|
2019-01-23 20:52:00 +09:00
|
|
|
|
breadcrumbs = new HeaderBreadcrumbControl(stack)
|
2018-05-15 20:34:14 -03:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
2020-06-25 21:58:40 +09:00
|
|
|
|
Origin = Anchor.BottomLeft
|
|
|
|
|
}
|
2018-05-15 20:34:14 -03:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-11 18:37:36 +01:00
|
|
|
|
breadcrumbs.Current.ValueChanged += screen =>
|
2018-12-11 17:32:01 +09:00
|
|
|
|
{
|
2020-12-25 17:05:29 +01:00
|
|
|
|
if (screen.NewValue is IOnlinePlaySubScreen onlineSubScreen)
|
|
|
|
|
title.Screen = onlineSubScreen;
|
2018-12-11 17:32:01 +09:00
|
|
|
|
};
|
|
|
|
|
|
2018-05-15 20:34:14 -03:00
|
|
|
|
breadcrumbs.Current.TriggerChange();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-25 21:58:40 +09:00
|
|
|
|
private class MultiHeaderTitle : CompositeDrawable
|
2019-03-11 18:37:36 +01:00
|
|
|
|
{
|
2020-03-24 22:03:16 +01:00
|
|
|
|
private const float spacing = 6;
|
|
|
|
|
|
2020-06-25 21:58:40 +09:00
|
|
|
|
private readonly OsuSpriteText dot;
|
|
|
|
|
private readonly OsuSpriteText pageTitle;
|
2020-03-24 22:03:16 +01:00
|
|
|
|
|
2020-12-25 17:05:29 +01:00
|
|
|
|
public IOnlinePlaySubScreen Screen
|
2019-03-11 19:10:37 +01:00
|
|
|
|
{
|
2020-06-25 21:58:40 +09:00
|
|
|
|
set => pageTitle.Text = value.ShortTitle.Titleize();
|
2020-03-24 22:03:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-24 16:18:35 +01:00
|
|
|
|
public MultiHeaderTitle(string mainTitle)
|
2020-03-24 22:03:16 +01:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Spacing = new Vector2(spacing, 0),
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-06-25 21:58:40 +09:00
|
|
|
|
new OsuSpriteText
|
2020-03-24 22:03:16 +01:00
|
|
|
|
{
|
2020-07-08 19:01:12 -07:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2020-06-25 21:58:40 +09:00
|
|
|
|
Font = OsuFont.GetFont(size: 24),
|
2020-12-24 16:18:35 +01:00
|
|
|
|
Text = mainTitle
|
2020-03-24 22:03:16 +01:00
|
|
|
|
},
|
2020-06-25 21:58:40 +09:00
|
|
|
|
dot = new OsuSpriteText
|
2020-03-24 22:03:16 +01:00
|
|
|
|
{
|
2020-07-08 19:01:12 -07:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2020-06-25 21:58:40 +09:00
|
|
|
|
Font = OsuFont.GetFont(size: 24),
|
|
|
|
|
Text = "·"
|
2020-03-24 22:03:16 +01:00
|
|
|
|
},
|
2020-06-25 21:58:40 +09:00
|
|
|
|
pageTitle = new OsuSpriteText
|
2020-03-24 22:03:16 +01:00
|
|
|
|
{
|
2020-07-08 19:01:12 -07:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2020-06-25 21:58:40 +09:00
|
|
|
|
Font = OsuFont.GetFont(size: 24),
|
|
|
|
|
Text = "Lounge"
|
2020-03-24 22:03:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
2019-03-11 19:10:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 18:37:36 +01:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2020-06-25 21:58:40 +09:00
|
|
|
|
pageTitle.Colour = dot.Colour = colours.Yellow;
|
2019-03-11 18:37:36 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 06:19:55 -03:00
|
|
|
|
private class HeaderBreadcrumbControl : ScreenBreadcrumbControl
|
|
|
|
|
{
|
2019-01-23 20:52:00 +09:00
|
|
|
|
public HeaderBreadcrumbControl(ScreenStack stack)
|
|
|
|
|
: base(stack)
|
2018-05-17 06:19:55 -03:00
|
|
|
|
{
|
2020-06-25 21:58:40 +09:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
StripColour = Color4.Transparent;
|
2018-05-17 06:19:55 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2020-06-25 21:58:40 +09:00
|
|
|
|
AccentColour = Color4Extensions.FromHex("#e35c99");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override TabItem<IScreen> CreateTabItem(IScreen value) => new HeaderBreadcrumbTabItem(value)
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private class HeaderBreadcrumbTabItem : BreadcrumbTabItem
|
|
|
|
|
{
|
|
|
|
|
public HeaderBreadcrumbTabItem(IScreen value)
|
|
|
|
|
: base(value)
|
|
|
|
|
{
|
|
|
|
|
Bar.Colour = Color4.Transparent;
|
|
|
|
|
}
|
2018-05-17 06:19:55 -03:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-15 20:34:14 -03:00
|
|
|
|
}
|
|
|
|
|
}
|