From a0ddc6d77a3930bad3abb540b2a91e2caed863da Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 May 2019 00:13:59 +0900 Subject: [PATCH] Use linq instead of a temporary sorted list --- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index 6d0b7a8739..a76211a0ae 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics; @@ -8,7 +8,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online.API.Requests.Responses; using System; -using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; using osu.Game.Graphics.Sprites; using osu.Game.Users; @@ -44,30 +44,20 @@ namespace osu.Game.Overlays.Changelog }, }; - var categories = new SortedDictionary>(); - - // sort entries by category - foreach (APIChangelogEntry entry in build.ChangelogEntries) - { - if (!categories.ContainsKey(entry.Category)) - categories.Add(entry.Category, new List { entry }); - else - categories[entry.Category].Add(entry); - } - - foreach (KeyValuePair> category in categories) + foreach (var categoryEntries in build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key)) { ChangelogEntries.Add(new OsuSpriteText { - Text = category.Key, + Text = categoryEntries.Key, Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); - foreach (APIChangelogEntry entry in category.Value) + var fontLarge = OsuFont.GetFont(size: 18); var fontMedium = OsuFont.GetFont(size: 14); var fontSmall = OsuFont.GetFont(size: 12); + foreach (APIChangelogEntry entry in categoryEntries) { LinkFlowContainer title = new LinkFlowContainer {