From b5207d65f7ab6fceb76c9ac423f63d4e999818f7 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 10:05:12 +0200 Subject: [PATCH] Show listing graph; Slight refactor --- osu.Game/Graphics/StreamColour.cs | 2 +- .../API/Requests/GetChangelogChartRequest.cs | 1 - .../Requests/Responses/APIChangelogChart.cs | 1 - osu.Game/Overlays/Changelog/ChangelogChart.cs | 21 ++++++++++++++++--- osu.Game/Overlays/ChangelogOverlay.cs | 2 ++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs index 3ee31c90e6..71626a0e3a 100644 --- a/osu.Game/Graphics/StreamColour.cs +++ b/osu.Game/Graphics/StreamColour.cs @@ -31,7 +31,7 @@ namespace osu.Game.Graphics if (!string.IsNullOrEmpty(name)) if (colours.TryGetValue(name, out ColourInfo colour)) return colour; - return new Color4(255, 255, 255, 255); + return new Color4(0, 0, 0, 255); } } } diff --git a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs index 4a9568af0b..1e131fb91f 100644 --- a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Online.API.Requests.Responses; -using System.Collections.Generic; namespace osu.Game.Online.API.Requests { diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs index aa8c462018..3509ff7de1 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using Newtonsoft.Json; -using osu.Framework.Lists; using System; using System.Collections.Generic; diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index cb2d60c649..b8df166a19 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -18,8 +18,8 @@ namespace osu.Game.Overlays.Changelog // placeholder json file: https://api.myjson.com/bins/10ye8a public class ChangelogChart : BufferedContainer { - private Box background; - private SpriteText text; + private readonly Box background; + private readonly SpriteText text; private APIAccess api; public ChangelogChart() @@ -43,6 +43,14 @@ namespace osu.Game.Overlays.Changelog }; } + /// + /// Draw the graph with all builds + /// + public void ShowChart() => fetchAndShowChangelogChart(); + + /// + /// Draw the graph for a specific build + /// public void ShowChart(APIChangelog releaseStream) => fetchAndShowChangelogChart(releaseStream); private bool isEmpty(APIChangelogChart changelogChart) @@ -53,7 +61,7 @@ namespace osu.Game.Overlays.Changelog return true; } - private void showChart(APIChangelogChart chartInfo, string updateStreamName) + private void showChart(APIChangelogChart chartInfo, string updateStreamName = null) { if (!isEmpty(chartInfo)) { @@ -79,5 +87,12 @@ namespace osu.Game.Overlays.Changelog req.Success += res => showChart(res, build.UpdateStream.Name); api.Queue(req); } + + private void fetchAndShowChangelogChart() + { + var req = new GetChangelogChartRequest(); + req.Success += res => showChart(res); + api.Queue(req); + } } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index f2df54ac99..ce2878858f 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -101,6 +101,7 @@ namespace osu.Game.Overlays else foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Deactivate(); + chart.ShowChart(); }; content.OnBuildChanged = () => { @@ -155,6 +156,7 @@ namespace osu.Game.Overlays Streams.BadgesContainer.Clear(); foreach (APIChangelog item in res) Streams.BadgesContainer.Add(new StreamBadge(item)); + chart.ShowChart(); }; api.Queue(req); }