1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 07:23:14 +08:00

Handle all changelog entry types correctly

This commit is contained in:
Bartłomiej Dach 2020-12-25 20:08:57 +01:00
parent 5f43299d37
commit 3ac618778f
2 changed files with 37 additions and 4 deletions

View File

@ -105,9 +105,23 @@ namespace osu.Game.Tests.Visual.Online
{ {
new APIChangelogEntry new APIChangelogEntry
{ {
Category = "Test", Type = ChangelogEntryType.Fix,
Title = "Title", Category = "osu!",
MessageHtml = "Message", Title = "Fix thing",
MessageHtml = "Additional info goes here.",
},
new APIChangelogEntry
{
Type = ChangelogEntryType.Add,
Category = "osu!",
Title = "Add thing",
Major = true
},
new APIChangelogEntry
{
Type = ChangelogEntryType.Misc,
Category = "Code quality",
Title = "Clean up thing"
} }
} }
}); });

View File

@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Changelog
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Size = new Vector2(10), Size = new Vector2(10),
Icon = entry.Type == ChangelogEntryType.Fix ? FontAwesome.Solid.Check : FontAwesome.Solid.Plus, Icon = getIconForChangelogEntry(entry.Type),
Colour = entryColour.Opacity(0.5f), Colour = entryColour.Opacity(0.5f),
Margin = new MarginPadding { Right = 5 }, Margin = new MarginPadding { Right = 5 },
}, },
@ -186,6 +186,25 @@ namespace osu.Game.Overlays.Changelog
} }
} }
private static IconUsage getIconForChangelogEntry(ChangelogEntryType entryType)
{
// compare: https://github.com/ppy/osu-web/blob/master/resources/assets/coffee/react/_components/changelog-entry.coffee#L8-L11
switch (entryType)
{
case ChangelogEntryType.Add:
return FontAwesome.Solid.Plus;
case ChangelogEntryType.Fix:
return FontAwesome.Solid.Check;
case ChangelogEntryType.Misc:
return FontAwesome.Regular.Circle;
default:
throw new ArgumentOutOfRangeException(nameof(entryType), $"Unrecognised entry type {entryType}");
}
}
protected virtual FillFlowContainer CreateHeader() => new FillFlowContainer protected virtual FillFlowContainer CreateHeader() => new FillFlowContainer
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,