mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Introduce better formatting to changelog entries; Sort by category
This commit is contained in:
@ -7,6 +7,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using System;
|
using System;
|
||||||
@ -17,6 +18,8 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
public class ChangelogContentGroup : FillFlowContainer
|
public class ChangelogContentGroup : FillFlowContainer
|
||||||
{
|
{
|
||||||
private readonly TooltipIconButton chevronPrevious, chevronNext;
|
private readonly TooltipIconButton chevronPrevious, chevronNext;
|
||||||
|
private readonly SortedDictionary<string, List<ChangelogEntry>> categories =
|
||||||
|
new SortedDictionary<string, List<ChangelogEntry>>();
|
||||||
|
|
||||||
public Action NextRequested, PreviousRequested;
|
public Action NextRequested, PreviousRequested;
|
||||||
public readonly FillFlowContainer ChangelogEntries;
|
public readonly FillFlowContainer ChangelogEntries;
|
||||||
@ -97,10 +100,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Font = @"Exo2.0-Medium",
|
Font = @"Exo2.0-Medium",
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Margin = new MarginPadding
|
Margin = new MarginPadding{ Top = 5, }
|
||||||
{
|
|
||||||
Top = 5,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
ChangelogEntries = new FillFlowContainer
|
ChangelogEntries = new FillFlowContainer
|
||||||
{
|
{
|
||||||
@ -127,7 +127,16 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
public void GenerateText(List<ChangelogEntry> changelogEntries)
|
public void GenerateText(List<ChangelogEntry> changelogEntries)
|
||||||
{
|
{
|
||||||
|
// sort entries by category
|
||||||
foreach (ChangelogEntry entry in changelogEntries)
|
foreach (ChangelogEntry entry in changelogEntries)
|
||||||
|
{
|
||||||
|
if (!categories.ContainsKey(entry.Category))
|
||||||
|
categories.Add(entry.Category, new List<ChangelogEntry> { entry });
|
||||||
|
else
|
||||||
|
categories[entry.Category].Add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, List<ChangelogEntry>> category in categories)
|
||||||
{
|
{
|
||||||
// textflowcontainer is unusable for formatting text
|
// textflowcontainer is unusable for formatting text
|
||||||
// this has to be a placeholder before we get a
|
// this has to be a placeholder before we get a
|
||||||
@ -135,47 +144,43 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
// it can't handle overflowing properly
|
// it can't handle overflowing properly
|
||||||
ChangelogEntries.Add(new SpriteText
|
ChangelogEntries.Add(new SpriteText
|
||||||
{
|
{
|
||||||
Text = entry.Category,
|
Text = category.Key,
|
||||||
TextSize = 24, // web: 18,
|
TextSize = 24, // web: 18,
|
||||||
Font = @"Exo2.0-Bold",
|
Font = @"Exo2.0-Bold",
|
||||||
Margin = new MarginPadding { Top = 35, Bottom = 15, },
|
Margin = new MarginPadding { Top = 35, Bottom = 15, },
|
||||||
});
|
});
|
||||||
ChangelogEntries.Add(new FillFlowContainer
|
foreach (ChangelogEntry entry in category.Value)
|
||||||
|
{
|
||||||
|
OsuTextFlowContainer title;
|
||||||
|
|
||||||
|
ChangelogEntries.Add(title = new OsuTextFlowContainer
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Full,
|
Direction = FillDirection.Full,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Children = new Drawable[]
|
LineSpacing = 0.25f,
|
||||||
{
|
|
||||||
new SpriteIcon
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopLeft,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
Icon = FontAwesome.fa_check,
|
|
||||||
Size = new Vector2(14),
|
|
||||||
Margin = new MarginPadding { Top = 2, Right = 4 },
|
|
||||||
},
|
|
||||||
new TextFlowContainer(t => t.TextSize = 18)
|
|
||||||
{
|
|
||||||
Text = entry.Title,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Text = !string.IsNullOrEmpty(entry.Repository) ?
|
|
||||||
$" ({entry.Repository.Substring(4)}#{entry.GithubPullRequestId})" :
|
|
||||||
null,
|
|
||||||
TextSize = 18,
|
|
||||||
Colour = new Color4(153, 238, 255, 255),
|
|
||||||
},
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Text = $" by {entry.GithubUser.DisplayName}",
|
|
||||||
TextSize = 14, // web: 12;
|
|
||||||
Margin = new MarginPadding { Top = 4, Left = 10, },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
title.AddIcon(FontAwesome.fa_check, t => { t.TextSize = 12; t.Padding = new MarginPadding { Left = -17, Right = 5 }; });
|
||||||
|
title.AddText(entry.Title, t => { t.TextSize = 18; }); //t.Padding = new MarginPadding(10); });
|
||||||
|
if (!string.IsNullOrEmpty(entry.Repository))
|
||||||
|
{
|
||||||
|
title.AddText($" ({entry.Repository.Substring(4)}#{entry.GithubPullRequestId})", t =>
|
||||||
|
{
|
||||||
|
t.TextSize = 18;
|
||||||
|
t.Colour = Color4.SkyBlue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
title.AddText($" by {entry.GithubUser.DisplayName}", t => t.TextSize = 14); //web: 12;
|
||||||
|
ChangelogEntries.Add(new SpriteText
|
||||||
|
{
|
||||||
|
TextSize = 14, // web: 12,
|
||||||
|
Colour = new Color4(235, 184, 254, 255),
|
||||||
|
Text = $"{entry.MessageHtml?.Replace("<p>", "").Replace("</p>", "")}\n",
|
||||||
|
Margin = new MarginPadding { Bottom = 10, },
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//public ChangelogContentGroup() { } // for listing
|
//public ChangelogContentGroup() { } // for listing
|
||||||
|
Reference in New Issue
Block a user