1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 16:27:43 +08:00
osu-lazer/osu.Game/Overlays/Changelog/ChangelogBuild.cs

112 lines
4.0 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using System;
using System.Linq;
using osu.Game.Graphics.Sprites;
using osu.Framework.Allocation;
namespace osu.Game.Overlays.Changelog
{
2022-11-24 13:32:20 +08:00
public partial class ChangelogBuild : FillFlowContainer
{
public Action<APIChangelogBuild> SelectBuild;
protected readonly APIChangelogBuild Build;
public readonly FillFlowContainer ChangelogEntries;
public ChangelogBuild(APIChangelogBuild build)
{
Build = build;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
Padding = new MarginPadding { Horizontal = WaveOverlayContainer.HORIZONTAL_PADDING };
Children = new Drawable[]
{
CreateHeader(),
ChangelogEntries = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
},
};
}
[BackgroundDependencyLoader]
2022-01-15 08:06:39 +08:00
private void load()
{
foreach (var categoryEntries in Build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key))
{
ChangelogEntries.Add(new OsuSpriteText
{
Text = categoryEntries.Key,
2020-02-21 22:11:29 +08:00
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 18),
Margin = new MarginPadding { Top = 35, Bottom = 15 },
});
2020-12-26 03:31:12 +08:00
ChangelogEntries.AddRange(categoryEntries.Select(entry => new ChangelogEntry(entry)));
}
}
protected virtual FillFlowContainer CreateHeader() => new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Margin = new MarginPadding { Top = 20 },
Child = new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Child = new OsuHoverContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Action = () => SelectBuild?.Invoke(Build),
Child = new FillFlowContainer<SpriteText>
{
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Horizontal = 40 },
Children = new[]
{
new OsuSpriteText
{
Text = Build.UpdateStream.DisplayName,
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19),
},
new OsuSpriteText
{
Text = " ",
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19),
},
new OsuSpriteText
{
Text = Build.DisplayVersion,
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 19),
Colour = Build.UpdateStream.Colour,
},
}
}
},
}
};
}
}