diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs deleted file mode 100644 index 57b3022724..0000000000 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ /dev/null @@ -1,156 +0,0 @@ -// 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.Colour; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; -using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; -using osu.Game.Online.API; -using osu.Game.Online.API.Requests; -using osu.Game.Online.API.Requests.Responses; -using System; -using System.Collections.Generic; - -namespace osu.Game.Overlays.Changelog -{ - public class ChangelogChart : Container - { - private const float height = 100; - private const float transition_duration = 300; - - // why make the child buffered? https://streamable.com/swbdj - private readonly Container container; - private readonly Box background; - private APIAccess api; - - public ChangelogChart() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Child = container = new Container - { - RelativeSizeAxes = Axes.X, - Height = height, - }; - } - - private bool isEmpty(APIChangelogChart changelogChart) - { - if (changelogChart != null) - foreach (BuildHistory buildHistory in changelogChart.BuildHistory) - if (buildHistory.UserCount > 0) - return false; - return true; - } - - private void showChart(APIChangelogChart chartInfo, string updateStreamName = null) - { - if (!isEmpty(chartInfo)) - { - container.MoveToY(0, transition_duration, Easing.InOutQuad).FadeIn(transition_duration); - if (string.IsNullOrEmpty(updateStreamName)) - plotCharts(chartInfo); - else - plotChart(chartInfo, StreamColour.FromStreamName(updateStreamName)); - } - else - container.MoveToY(-height, transition_duration, Easing.InOutQuad).FadeOut(transition_duration); - } - - [BackgroundDependencyLoader] - private void load(APIAccess api) - { - this.api = api; - } - - public void ShowUpdateStream(string updateStream) - { - var req = new GetChangelogChartRequest(updateStream); - req.Success += res => showChart(res, updateStream); - api.Queue(req); - } - - public void ShowAllUpdateStreams() - { - var req = new GetChangelogChartRequest(); - req.Success += res => showChart(res); - api.Queue(req); - } - - // this could probably be combined with isEmpty, todo - private float getMaxUserCount(APIChangelogChart changelogChartInfo) - { - var maxUserCount = 0l; - foreach (BuildHistory build in changelogChartInfo.BuildHistory) - { - if (build.UserCount > maxUserCount) - maxUserCount = build.UserCount; - } - return maxUserCount; - } - - private List clearUpDips(List buildHistories, float maxUserCount) - { - var buildHistory = new List(); - foreach (BuildHistory build in buildHistories) - { - if (build.UserCount / maxUserCount > 0.2f) - buildHistory.Add(build.UserCount); - } - return buildHistory; - } - - private void plotChart(APIChangelogChart changelogChartInfo, ColourInfo colour) - { - var maxUserCount = getMaxUserCount(changelogChartInfo); - - container.Child = new BarGraph - { - Colour = colour, - Values = clearUpDips(changelogChartInfo.BuildHistory, maxUserCount), - RelativeSizeAxes = Axes.Both, - Direction = BarDirection.BottomToTop, - }; - } - - private void plotCharts(APIChangelogChart changelogChartInfo) - { - var maxUserCount = getMaxUserCount(changelogChartInfo); - - var releaseStreams = new Dictionary>(changelogChartInfo.Order.Count); - var highestUserCounts = new Dictionary(changelogChartInfo.Order.Count); - - foreach (string updateStream in changelogChartInfo.Order) - { - releaseStreams.Add(updateStream, new List()); - highestUserCounts.Add(updateStream, 0); - } - - foreach (BuildHistory build in changelogChartInfo.BuildHistory) - { - releaseStreams[build.Label].Add(build.UserCount); - if (highestUserCounts[build.Label] < build.UserCount) - highestUserCounts[build.Label] = build.UserCount; - } - - container.Clear(); - - foreach (KeyValuePair> releaseStream in releaseStreams) - { - var barGraph = new BarGraph - { - Colour = StreamColour.FromStreamName(releaseStream.Key), - Values = releaseStream.Value, - RelativeSizeAxes = Axes.Both, - Direction = BarDirection.BottomToTop, - //Height = highestUserCounts[releaseStream.Key] / maxUserCount, - }; - container.Add(barGraph); - } - } - } -} diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index a0d0726c01..a14fa77da3 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -25,7 +25,7 @@ namespace osu.Game.Overlays { private readonly ChangelogHeader header; private readonly ChangelogBadges badges; - private readonly ChangelogChart chart; + //private readonly ChangelogChart chart; private readonly ChangelogContent listing; private readonly ChangelogContent content; @@ -85,7 +85,7 @@ namespace osu.Game.Overlays { header = new ChangelogHeader(), badges = new ChangelogBadges(), - chart = new ChangelogChart(), + //chart = new ChangelogChart(), listing = new ChangelogContent(), content = new ChangelogContent() }, @@ -162,7 +162,6 @@ namespace osu.Game.Overlays isAtListing = true; var req = new GetChangelogRequest(); badges.SelectNone(); - chart.ShowAllUpdateStreams(); req.Success += listing.ShowListing; api.Queue(req); } @@ -176,7 +175,7 @@ namespace osu.Game.Overlays content.Hide(); listing.Show(); badges.SelectNone(); - chart.ShowAllUpdateStreams(); + //chart.ShowAllUpdateStreams(); listing.Show(); scroll.ScrollTo(savedScrollPosition); } @@ -184,7 +183,12 @@ namespace osu.Game.Overlays /// /// Fetches and shows a specific build from a specific update stream. /// - public void FetchAndShowBuild(APIChangelog build, bool sentByBadges = false) + /// Must contain at least and + /// . If and + /// are specified, the header will instantly display them. + /// Whether to update badges. Should be set to false in case + /// the function is called by selecting a badge, to avoid an infinite loop. + public void FetchAndShowBuild(APIChangelog build, bool updateBadges = true) { var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); @@ -193,17 +197,17 @@ namespace osu.Game.Overlays else req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); - if (!sentByBadges) + if (updateBadges) badges.SelectUpdateStream(build.UpdateStream.Name); - chart.ShowUpdateStream(build.UpdateStream.Name); + //chart.ShowUpdateStream(build.UpdateStream.Name); req.Success += apiChangelog => { listing.Hide(); content.Show(); content.ShowBuild(apiChangelog); if (scroll.Current > scroll.GetChildPosInContent(content)) - scroll.ScrollTo(chart); + scroll.ScrollTo(content); if (isAtListing) savedScrollPosition = scroll.Current; isAtListing = false;