1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-16 06:12:34 +08:00
Files
osu-lazer/osu.Game/Graphics/UserInterface/SectionHeader.cs
T
Krzysztof Gutkowski 86ef145f56 Switch online play screens to new header (#37074)
Specifically the one used on the daily challenge screen. Was bugging me
that playlists/multi have that old yellow header design used, so I've
changed it. Will probably come in handy once the footer/leaderboard
changes are in.

Also localized the headers while at it.

Multiplayer:


![osu_2026-03-23_20-03-22](https://github.com/user-attachments/assets/1f262aea-8bf9-412d-9c4a-89addd65bf38)

Playlists:


![osu_2026-03-23_20-34-18](https://github.com/user-attachments/assets/3f7d349e-7c03-4f56-8e57-1c65ae746235)

The only thing I'm wondering about is whether the detail thing
(participant count/playlist length) should be using the highlight colour
here. The old design had them be yellow, but I feel like the pink on
this one stands out too much.

---------

Co-authored-by: Dean Herbert <pe@ppy.sh>
2026-03-25 16:36:18 +09:00

85 lines
2.7 KiB
C#

// 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.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Graphics.UserInterface
{
public partial class SectionHeader : CompositeDrawable
{
/// <summary>
/// Extra text to be shown in brackets next to the header.
/// Unlike the header itself, this can be updated during runtime.
/// </summary>
public readonly Bindable<string> DetailsText = new Bindable<string>();
private readonly LocalisableString text;
private OsuTextFlowContainer textFlow = null!;
private ITextPart? detailsPart;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
public SectionHeader(LocalisableString text)
{
this.text = text;
Margin = new MarginPadding { Vertical = 10, Horizontal = 5 };
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
}
[BackgroundDependencyLoader]
private void load()
{
InternalChild = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(2),
Children = new Drawable[]
{
textFlow = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 16, weight: FontWeight.SemiBold))
{
Text = text,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
new Circle
{
Colour = colourProvider.Highlight1,
Size = new Vector2(28, 2),
}
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
DetailsText.BindValueChanged(updateDetails, true);
}
private void updateDetails(ValueChangedEvent<string> details)
{
if (detailsPart != null)
textFlow.RemovePart(detailsPart);
if (!string.IsNullOrEmpty(details.NewValue))
detailsPart = textFlow.AddText($" ({details.NewValue})", t => t.Colour = colourProvider.Highlight1);
}
}
}