2019-01-24 16:43:03 +08: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-16 07:34:14 +08:00
|
|
|
|
|
2020-06-25 20:58:40 +08:00
|
|
|
|
using Humanizer;
|
2018-05-16 07:34:14 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2024-05-30 18:02:16 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2018-05-16 07:34:14 +08:00
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Graphics;
|
2020-03-25 05:03:16 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2020-09-03 15:28:14 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2020-03-25 05:03:16 +08:00
|
|
|
|
using osuTK;
|
2018-05-16 07:34:14 +08:00
|
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
|
namespace osu.Game.Screens.OnlinePlay
|
2018-05-16 07:34:14 +08:00
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class Header : Container
|
2018-05-16 07:34:14 +08:00
|
|
|
|
{
|
2020-06-25 21:22:24 +08:00
|
|
|
|
public const float HEIGHT = 80;
|
2018-05-16 07:34:14 +08:00
|
|
|
|
|
2024-05-30 18:02:16 +08:00
|
|
|
|
private readonly ScreenStack? stack;
|
2021-08-12 15:52:30 +08:00
|
|
|
|
private readonly MultiHeaderTitle title;
|
|
|
|
|
|
2024-05-30 18:02:16 +08:00
|
|
|
|
public Header(LocalisableString mainTitle, ScreenStack? stack)
|
2018-05-16 07:34:14 +08:00
|
|
|
|
{
|
2021-08-12 15:52:30 +08:00
|
|
|
|
this.stack = stack;
|
|
|
|
|
|
2018-05-16 07:34:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = HEIGHT;
|
2021-08-12 15:52:30 +08:00
|
|
|
|
Padding = new MarginPadding { Left = WaveOverlayContainer.WIDTH_PADDING };
|
2018-05-16 07:34:14 +08:00
|
|
|
|
|
2021-08-12 15:52:30 +08:00
|
|
|
|
Child = title = new MultiHeaderTitle(mainTitle)
|
2018-05-16 07:34:14 +08:00
|
|
|
|
{
|
2021-08-12 15:52:30 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2021-08-12 17:02:00 +08:00
|
|
|
|
Origin = Anchor.CentreLeft,
|
2018-05-16 07:34:14 +08:00
|
|
|
|
};
|
|
|
|
|
|
2024-05-30 18:02:16 +08:00
|
|
|
|
if (stack != null)
|
|
|
|
|
{
|
|
|
|
|
// unnecessary to unbind these as this header has the same lifetime as the screen stack we are attaching to.
|
|
|
|
|
stack.ScreenPushed += (_, _) => updateSubScreenTitle();
|
|
|
|
|
stack.ScreenExited += (_, _) => updateSubScreenTitle();
|
|
|
|
|
}
|
2018-05-16 07:34:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 18:02:16 +08:00
|
|
|
|
private void updateSubScreenTitle() => title.Screen = stack?.CurrentScreen as IOnlinePlaySubScreen;
|
2021-08-12 15:52:30 +08:00
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
private partial class MultiHeaderTitle : CompositeDrawable
|
2019-03-12 01:37:36 +08:00
|
|
|
|
{
|
2020-03-25 05:03:16 +08:00
|
|
|
|
private const float spacing = 6;
|
|
|
|
|
|
2020-06-25 20:58:40 +08:00
|
|
|
|
private readonly OsuSpriteText dot;
|
|
|
|
|
private readonly OsuSpriteText pageTitle;
|
2020-03-25 05:03:16 +08:00
|
|
|
|
|
2024-05-30 18:02:16 +08:00
|
|
|
|
public IOnlinePlaySubScreen? Screen
|
2019-03-12 02:10:37 +08:00
|
|
|
|
{
|
2024-05-30 18:02:16 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
pageTitle.Text = value?.ShortTitle.Titleize() ?? default(LocalisableString);
|
|
|
|
|
dot.Alpha = pageTitle.Text == default ? 0 : 1;
|
|
|
|
|
}
|
2020-03-25 05:03:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 18:02:16 +08:00
|
|
|
|
public MultiHeaderTitle(LocalisableString mainTitle)
|
2020-03-25 05:03:16 +08: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 20:58:40 +08:00
|
|
|
|
new OsuSpriteText
|
2020-03-25 05:03:16 +08:00
|
|
|
|
{
|
2020-07-09 10:01:12 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2021-10-04 06:21:36 +08:00
|
|
|
|
Font = OsuFont.TorusAlternate.With(size: 24),
|
2020-12-24 23:18:35 +08:00
|
|
|
|
Text = mainTitle
|
2020-03-25 05:03:16 +08:00
|
|
|
|
},
|
2020-06-25 20:58:40 +08:00
|
|
|
|
dot = new OsuSpriteText
|
2020-03-25 05:03:16 +08:00
|
|
|
|
{
|
2020-07-09 10:01:12 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2021-10-04 06:21:36 +08:00
|
|
|
|
Font = OsuFont.TorusAlternate.With(size: 24),
|
2024-05-30 18:02:16 +08:00
|
|
|
|
Text = "·",
|
|
|
|
|
Alpha = 0,
|
2020-03-25 05:03:16 +08:00
|
|
|
|
},
|
2020-06-25 20:58:40 +08:00
|
|
|
|
pageTitle = new OsuSpriteText
|
2020-03-25 05:03:16 +08:00
|
|
|
|
{
|
2020-07-09 10:01:12 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2021-10-04 06:21:36 +08:00
|
|
|
|
Font = OsuFont.TorusAlternate.With(size: 24),
|
2020-03-25 05:03:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
2019-03-12 02:10:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-12 01:37:36 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2020-06-25 20:58:40 +08:00
|
|
|
|
pageTitle.Colour = dot.Colour = colours.Yellow;
|
2019-03-12 01:37:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-16 07:34:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|