From 227394925a0603905989ba47f4e8a112d313ac3e Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 13:51:31 +0200 Subject: [PATCH] Add neighboring builds handling; + provoke angry AppVeyor --- .../API/Requests/GetChangelogBuildRequest.cs | 16 +++--- .../Overlays/Changelog/ChangelogContent.cs | 54 +++++++++++++++++++ .../Changelog/ChangelogContentGroup.cs | 4 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 2 +- osu.Game/Overlays/ChangelogOverlay.cs | 3 +- 5 files changed, 67 insertions(+), 12 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs index 64bc6b4b59..c4ddb9a0cc 100644 --- a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs @@ -7,14 +7,16 @@ namespace osu.Game.Online.API.Requests { public class GetChangelogBuildRequest : APIRequest { - private string url; - /// This will need to be changed to "long Id" - /// Placeholder for testing - GetChangelogBuildRequest(string url) + private readonly string name; + private readonly string version; + + public GetChangelogBuildRequest(string streamName, string buildVersion) { - this.url = url; + name = streamName; + version = buildVersion; } - protected override string Uri => @""; - protected override string Target => url; + + //protected override string Target => $@"changelog/{name}/{version}"; + protected override string Uri => @"https://api.myjson.com/bins/ya5q2"; // for testing } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 325ec802d4..9b35f51721 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -1,13 +1,20 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Changelog { public class ChangelogContent : FillFlowContainer { + private APIChangelog currentBuild; + private APIAccess api; + public ChangelogContent() { RelativeSizeAxes = Axes.X; @@ -19,5 +26,52 @@ namespace osu.Game.Overlays.Changelog Right = 70, }; } + + public override void Add(ChangelogContentGroup changelogContentGroup) + { + changelogContentGroup.PreviousRequested = ShowPrevious; + changelogContentGroup.NextRequested = ShowNext; + base.Add(changelogContentGroup); + } + + public void ShowBuild(APIChangelog changelog) + { + Clear(); + Add(new ChangelogContentGroup(changelog)); + FetchChangelogBuild(changelog); + } + + private void ShowNext() + { + if (currentBuild.Versions.Next != null) + { + Clear(); + Add(new ChangelogContentGroup(currentBuild.Versions.Next)); + FetchChangelogBuild(currentBuild.Versions.Next); + } + } + + private void ShowPrevious() + { + if (currentBuild.Versions.Previous != null) + { + Clear(); + Add(new ChangelogContentGroup(currentBuild.Versions.Previous)); + FetchChangelogBuild(currentBuild.Versions.Previous); + } + } + + [BackgroundDependencyLoader] + private void load(APIAccess api) + { + this.api = api; + } + + private void FetchChangelogBuild(APIChangelog build) + { + var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); + req.Success += res => currentBuild = res; + api.Queue(req); + } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 07577e18c1..4826379682 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -47,7 +47,7 @@ namespace osu.Game.Overlays.Changelog Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), TooltipText = "Previous", - OnPressed = PreviousRequested, + OnPressed = () => PreviousRequested(), }, new FillFlowContainer { @@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Changelog Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), TooltipText = "Next", - OnPressed = NextRequested, + OnPressed = () => NextRequested(), }, } }, diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 7e367a63fa..ba98e0a4f7 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Changelog new SpriteText { Text = ChangelogEntry.Users > 0 ? - string.Format($"{ChangelogEntry.Users:N0} users online") : + $"{ChangelogEntry.Users:N0} users online" : null, TextSize = 12, Font = @"Exo2.0-Regular", diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 081b501cad..417b4f7a30 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -87,8 +87,7 @@ namespace osu.Game.Overlays header.ChangelogEntry = Streams.SelectedRelease; } header.ShowReleaseStream(); - content.Clear(); // this should probably happen with some transition - content.Add(new ChangelogContentGroup(Streams.SelectedRelease)); + content.ShowBuild(Streams.SelectedRelease); }; header.OnListingActivated += () => {