mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 05:33:07 +08:00
Plotting the chart 1
This commit is contained in:
parent
a8b0e23ed6
commit
2d8277f413
@ -3,13 +3,16 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog
|
namespace osu.Game.Overlays.Changelog
|
||||||
{
|
{
|
||||||
@ -19,7 +22,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
private const float transition_duration = 300;
|
private const float transition_duration = 300;
|
||||||
|
|
||||||
// why make the child buffered? https://streamable.com/swbdj
|
// why make the child buffered? https://streamable.com/swbdj
|
||||||
private readonly BufferedContainer container;
|
private readonly Container container;
|
||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
private APIAccess api;
|
private APIAccess api;
|
||||||
|
|
||||||
@ -27,17 +30,17 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
Child = container = new BufferedContainer
|
Child = container = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = height,
|
Height = height,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
background = new Box
|
//background = new Box
|
||||||
{
|
//{
|
||||||
Colour = OsuColour.Gray(0),
|
// Colour = OsuColour.Gray(0),
|
||||||
RelativeSizeAxes = Axes.Both,
|
// RelativeSizeAxes = Axes.Both,
|
||||||
},
|
//},
|
||||||
new SpriteText
|
new SpriteText
|
||||||
{
|
{
|
||||||
Text = "Graph Placeholder",
|
Text = "Graph Placeholder",
|
||||||
@ -63,8 +66,8 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
{
|
{
|
||||||
if (!isEmpty(chartInfo))
|
if (!isEmpty(chartInfo))
|
||||||
{
|
{
|
||||||
background.Colour = StreamColour.FromStreamName(updateStreamName);
|
|
||||||
container.MoveToY(0, transition_duration, Easing.InOutQuad).FadeIn(transition_duration);
|
container.MoveToY(0, transition_duration, Easing.InOutQuad).FadeIn(transition_duration);
|
||||||
|
plotChart(chartInfo, StreamColour.FromStreamName(updateStreamName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
container.MoveToY(-height, transition_duration, Easing.InOutQuad).FadeOut(transition_duration);
|
container.MoveToY(-height, transition_duration, Easing.InOutQuad).FadeOut(transition_duration);
|
||||||
@ -89,5 +92,40 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
req.Success += res => showChart(res);
|
req.Success += res => showChart(res);
|
||||||
api.Queue(req);
|
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 void plotChart(APIChangelogChart changelogChartInfo, ColourInfo colour)
|
||||||
|
{
|
||||||
|
var maxUserCount = getMaxUserCount(changelogChartInfo);
|
||||||
|
var currentPos = 0f;
|
||||||
|
|
||||||
|
container.Clear();
|
||||||
|
|
||||||
|
foreach (BuildHistory build in changelogChartInfo.BuildHistory)
|
||||||
|
{
|
||||||
|
container.Add(new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Width = Math.Max(container.DrawWidth / changelogChartInfo.BuildHistory.Count, 2),
|
||||||
|
Height = build.UserCount / maxUserCount,
|
||||||
|
X = currentPos,
|
||||||
|
Colour = colour,
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
});
|
||||||
|
currentPos += container.DrawWidth / changelogChartInfo.BuildHistory.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user