From 8d4de68c39e246ed01586a6e5a112d02a55048f6 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 23:57:46 +0200 Subject: [PATCH] Nullables in APIChangelog; Primitive changelog entries display --- .../API/Requests/Responses/APIChangelog.cs | 14 ++++++------ .../Overlays/Changelog/ChangelogContent.cs | 1 + .../Changelog/ChangelogContentGroup.cs | 22 ++++++++++++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs index 4ba7077863..9d3357b071 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs @@ -25,7 +25,7 @@ namespace osu.Game.Online.API.Requests.Responses public bool IsFeatured { get; set; } [JsonProperty("created_at")] - public DateTimeOffset CreatedAt { get; set; } + public DateTimeOffset? CreatedAt { get; set; } [JsonProperty("update_stream")] public UpdateStream UpdateStream { get; set; } @@ -49,19 +49,19 @@ namespace osu.Game.Online.API.Requests.Responses public class ChangelogEntry { [JsonProperty("id")] - public long Id { get; set; } + public long? Id { get; set; } [JsonProperty("repository")] public string Repository { get; set; } [JsonProperty("github_pull_request_id")] - public long GithubPullRequestId { get; set; } + public long? GithubPullRequestId { get; set; } [JsonProperty("github_url")] public string GithubUrl { get; set; } [JsonProperty("url")] - public object Url { get; set; } + public string Url { get; set; } [JsonProperty("type")] public string Type { get; set; } @@ -76,10 +76,10 @@ namespace osu.Game.Online.API.Requests.Responses public string MessageHtml { get; set; } [JsonProperty("major")] - public bool Major { get; set; } + public bool? Major { get; set; } [JsonProperty("created_at")] - public DateTimeOffset CreatedAt { get; set; } + public DateTimeOffset? CreatedAt { get; set; } [JsonProperty("github_user")] public GithubUser GithubUser { get; set; } @@ -88,7 +88,7 @@ namespace osu.Game.Online.API.Requests.Responses public class GithubUser { [JsonProperty("id")] - public long Id { get; set; } + public long? Id { get; set; } [JsonProperty("display_name")] public string DisplayName { get; set; } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 8795c040ef..1bae32b4ef 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -83,6 +83,7 @@ namespace osu.Game.Overlays.Changelog req.Success += res => { CurrentBuild = res; + changelogContentGroup.GenerateText(CurrentBuild.ChangelogEntries); updateChevronTooltips(); }; api.Queue(req); diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 3ec11beb35..bc6428450e 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -9,6 +9,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; +using System.Collections.Generic; namespace osu.Game.Overlays.Changelog { @@ -17,6 +18,8 @@ namespace osu.Game.Overlays.Changelog private readonly TooltipIconButton chevronPrevious, chevronNext; public Action NextRequested, PreviousRequested; + public readonly TextFlowContainer ChangelogEntries; + public ChangelogContentGroup(APIChangelog build) { RelativeSizeAxes = Axes.X; @@ -92,7 +95,8 @@ namespace osu.Game.Overlays.Changelog { // do we need .ToUniversalTime() here? // also, this should be a temporary solution to weekdays in >localized< date strings - Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), + Text = build.CreatedAt.HasValue ? build.CreatedAt.Value.Date.ToLongDateString() + .Replace(build.CreatedAt.Value.ToString("dddd") + ", ", "") : null, TextSize = 17, // web: 14, Colour = OsuColour.FromHex(@"FD5"), Font = @"Exo2.0-Medium", @@ -103,6 +107,11 @@ namespace osu.Game.Overlays.Changelog Top = 5, }, }, + ChangelogEntries = new TextFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, }; } @@ -119,6 +128,17 @@ namespace osu.Game.Overlays.Changelog chevronNext.IsEnabled = true; } } + + public void GenerateText(List changelogEntries) + { + foreach (ChangelogEntry entry in changelogEntries) + { + ChangelogEntries.AddParagraph(entry.Type); + ChangelogEntries.AddParagraph(entry.Title); + ChangelogEntries.AddText($"({entry.Repository}#{entry.GithubPullRequestId})"); + ChangelogEntries.AddText($"by {entry.GithubUser.DisplayName}"); + } + } //public ChangelogContentGroup() { } // for listing } }