From 7c6be4a07538077759630b6e2e2069f400423ebf Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 21:38:14 +0200 Subject: [PATCH] Handle around an APIChangelog instead of just Name and Version: Makes showing up the header immediately possible --- .../Overlays/Changelog/ChangelogBadges.cs | 15 ++---------- .../Overlays/Changelog/ChangelogContent.cs | 6 ++--- .../Changelog/ChangelogContentGroup.cs | 14 +++++------ osu.Game/Overlays/ChangelogOverlay.cs | 24 +++++++++++-------- 4 files changed, 25 insertions(+), 34 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 0cfd220601..6f088677d9 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Changelog private const float padding_y = 20; private const float padding_x = 85; - public delegate void SelectionHandler(string updateStream, string version, EventArgs args); + public delegate void SelectionHandler(APIChangelog releaseStream, EventArgs args); public event SelectionHandler Selected; @@ -49,17 +49,6 @@ namespace osu.Game.Overlays.Changelog }, }, }; - //foreach (StreamBadge streamBadge in BadgesContainer.Children) - //{ - // streamBadge.OnActivation = () => - // { - // SelectedRelease = streamBadge.ChangelogEntry; - // foreach (StreamBadge item in BadgesContainer.Children) - // if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id) - // item.Deactivate(); - // OnSelection?.Invoke(); - // }; - //} } public void Populate(List latestBuilds) @@ -109,7 +98,7 @@ namespace osu.Game.Overlays.Changelog protected virtual void OnSelected(StreamBadge source) { - Selected?.Invoke(source.ChangelogEntry.UpdateStream.Name, source.ChangelogEntry.Version, EventArgs.Empty); + Selected?.Invoke(source.ChangelogEntry, EventArgs.Empty); } protected override bool OnHover(InputState state) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 3b64003104..7e92ab4c26 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Changelog private APIAccess api; private ChangelogContentGroup changelogContentGroup; - public delegate void BuildSelectedEventHandler(string updateStream, string version, EventArgs args); + public delegate void BuildSelectedEventHandler(APIChangelog build, EventArgs args); public event BuildSelectedEventHandler BuildSelected; @@ -80,9 +80,9 @@ namespace osu.Game.Overlays.Changelog changelogContentGroup.BuildSelected += OnBuildSelected; } - protected virtual void OnBuildSelected(string updateStream, string version, EventArgs args) + protected virtual void OnBuildSelected(APIChangelog build, EventArgs args) { - BuildSelected?.Invoke(updateStream, version, EventArgs.Empty); + BuildSelected?.Invoke(build, EventArgs.Empty); } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index aabc390d49..444e81a75d 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Changelog private readonly SortedDictionary> categories = new SortedDictionary>(); - public delegate void BuildSelectedEventHandler(string updateStream, string version, EventArgs args); + public delegate void BuildSelectedEventHandler(APIChangelog build, EventArgs args); public event BuildSelectedEventHandler BuildSelected; @@ -53,8 +53,7 @@ namespace osu.Game.Overlays.Changelog IsEnabled = false, Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), - Action = () => OnBuildSelected(build.Versions.Previous.UpdateStream.Name, - build.Versions.Previous.Version), + Action = () => OnBuildSelected(build.Versions.Previous), }, new FillFlowContainer { @@ -91,8 +90,7 @@ namespace osu.Game.Overlays.Changelog IsEnabled = false, Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), - Action = () => OnBuildSelected(build.Versions.Next.UpdateStream.Name, - build.Versions.Next.Version), + Action = () => OnBuildSelected(build.Versions.Next), }, } }, @@ -160,7 +158,7 @@ namespace osu.Game.Overlays.Changelog TextSize = 20, // web: 18, Font = @"Exo2.0-Light", Colour = StreamColour.FromStreamName(build.UpdateStream.Name), - Action = () => OnBuildSelected(build.UpdateStream.Name, build.Version), + Action = () => OnBuildSelected(build), IsClickMuted = true, }, } @@ -188,9 +186,9 @@ namespace osu.Game.Overlays.Changelog } } - protected virtual void OnBuildSelected(string updateStream, string version) + protected virtual void OnBuildSelected(APIChangelog build) { - BuildSelected?.Invoke(updateStream, version, EventArgs.Empty); + BuildSelected?.Invoke(build, EventArgs.Empty); } public void GenerateText(List changelogEntries) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index a4e3e8a91c..fd0515a0b3 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -13,6 +13,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Input.Bindings; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog; using System; @@ -114,9 +115,9 @@ namespace osu.Game.Overlays FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out); } - private void onBuildSelected(string updateStream, string version, EventArgs e) + private void onBuildSelected(APIChangelog build, EventArgs e) { - FetchAndShowBuild(updateStream, version); + FetchAndShowBuild(build); } [BackgroundDependencyLoader] @@ -151,18 +152,21 @@ namespace osu.Game.Overlays /// /// Fetches and shows a specific build from a specific update stream. /// - public void FetchAndShowBuild(string updateStream, string version, bool sentByBadges = false) + public void FetchAndShowBuild(APIChangelog build, bool sentByBadges = false) { - //// I should probably change this to take APIChangelog as an argument, - //// instantly update the header and badge, and if it doesn't contain the - //// needed info, just subscribe to when the info will be available isAtListing = false; - var req = new GetChangelogBuildRequest(updateStream, version); + var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); + + if (build.UpdateStream.DisplayName != null && build.DisplayVersion != null) + header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion); + else + req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); + if (!sentByBadges) - badges.SelectUpdateStream(updateStream); - chart.ShowUpdateStream(updateStream); + badges.SelectUpdateStream(build.UpdateStream.Name); + + chart.ShowUpdateStream(build.UpdateStream.Name); req.Success += content.ShowBuild; - req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); api.Queue(req); } }