Nullables in APIChangelog; Primitive changelog entries display

This commit is contained in:
HoutarouOreki 2018-07-20 23:57:46 +02:00
parent c36a303b36
commit 8d4de68c39
3 changed files with 29 additions and 8 deletions

View File

@ -25,7 +25,7 @@ namespace osu.Game.Online.API.Requests.Responses
public bool IsFeatured { get; set; } public bool IsFeatured { get; set; }
[JsonProperty("created_at")] [JsonProperty("created_at")]
public DateTimeOffset CreatedAt { get; set; } public DateTimeOffset? CreatedAt { get; set; }
[JsonProperty("update_stream")] [JsonProperty("update_stream")]
public UpdateStream UpdateStream { get; set; } public UpdateStream UpdateStream { get; set; }
@ -49,19 +49,19 @@ namespace osu.Game.Online.API.Requests.Responses
public class ChangelogEntry public class ChangelogEntry
{ {
[JsonProperty("id")] [JsonProperty("id")]
public long Id { get; set; } public long? Id { get; set; }
[JsonProperty("repository")] [JsonProperty("repository")]
public string Repository { get; set; } public string Repository { get; set; }
[JsonProperty("github_pull_request_id")] [JsonProperty("github_pull_request_id")]
public long GithubPullRequestId { get; set; } public long? GithubPullRequestId { get; set; }
[JsonProperty("github_url")] [JsonProperty("github_url")]
public string GithubUrl { get; set; } public string GithubUrl { get; set; }
[JsonProperty("url")] [JsonProperty("url")]
public object Url { get; set; } public string Url { get; set; }
[JsonProperty("type")] [JsonProperty("type")]
public string Type { get; set; } public string Type { get; set; }
@ -76,10 +76,10 @@ namespace osu.Game.Online.API.Requests.Responses
public string MessageHtml { get; set; } public string MessageHtml { get; set; }
[JsonProperty("major")] [JsonProperty("major")]
public bool Major { get; set; } public bool? Major { get; set; }
[JsonProperty("created_at")] [JsonProperty("created_at")]
public DateTimeOffset CreatedAt { get; set; } public DateTimeOffset? CreatedAt { get; set; }
[JsonProperty("github_user")] [JsonProperty("github_user")]
public GithubUser GithubUser { get; set; } public GithubUser GithubUser { get; set; }
@ -88,7 +88,7 @@ namespace osu.Game.Online.API.Requests.Responses
public class GithubUser public class GithubUser
{ {
[JsonProperty("id")] [JsonProperty("id")]
public long Id { get; set; } public long? Id { get; set; }
[JsonProperty("display_name")] [JsonProperty("display_name")]
public string DisplayName { get; set; } public string DisplayName { get; set; }

View File

@ -83,6 +83,7 @@ namespace osu.Game.Overlays.Changelog
req.Success += res => req.Success += res =>
{ {
CurrentBuild = res; CurrentBuild = res;
changelogContentGroup.GenerateText(CurrentBuild.ChangelogEntries);
updateChevronTooltips(); updateChevronTooltips();
}; };
api.Queue(req); api.Queue(req);

View File

@ -9,6 +9,7 @@ using osu.Game.Graphics;
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;
using System.Collections.Generic;
namespace osu.Game.Overlays.Changelog namespace osu.Game.Overlays.Changelog
{ {
@ -17,6 +18,8 @@ namespace osu.Game.Overlays.Changelog
private readonly TooltipIconButton chevronPrevious, chevronNext; private readonly TooltipIconButton chevronPrevious, chevronNext;
public Action NextRequested, PreviousRequested; public Action NextRequested, PreviousRequested;
public readonly TextFlowContainer ChangelogEntries;
public ChangelogContentGroup(APIChangelog build) public ChangelogContentGroup(APIChangelog build)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -92,7 +95,8 @@ namespace osu.Game.Overlays.Changelog
{ {
// do we need .ToUniversalTime() here? // do we need .ToUniversalTime() here?
// also, this should be a temporary solution to weekdays in >localized< date strings // 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, TextSize = 17, // web: 14,
Colour = OsuColour.FromHex(@"FD5"), Colour = OsuColour.FromHex(@"FD5"),
Font = @"Exo2.0-Medium", Font = @"Exo2.0-Medium",
@ -103,6 +107,11 @@ namespace osu.Game.Overlays.Changelog
Top = 5, Top = 5,
}, },
}, },
ChangelogEntries = new TextFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
}; };
} }
@ -119,6 +128,17 @@ namespace osu.Game.Overlays.Changelog
chevronNext.IsEnabled = true; chevronNext.IsEnabled = true;
} }
} }
public void GenerateText(List<ChangelogEntry> 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 //public ChangelogContentGroup() { } // for listing
} }
} }