2018-07-20 01:07:24 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-07-21 15:45:14 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-07-21 15:45:14 +08:00
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
2018-07-21 13:16:22 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Changelog
|
|
|
|
|
{
|
|
|
|
|
public class ChangelogChart : BufferedContainer
|
|
|
|
|
{
|
2018-07-25 06:59:21 +08:00
|
|
|
|
private const float height = 100;
|
|
|
|
|
private const float transition_duration = 300;
|
|
|
|
|
|
|
|
|
|
private readonly Container container;
|
2018-07-21 16:05:12 +08:00
|
|
|
|
private readonly Box background;
|
2018-07-21 15:45:14 +08:00
|
|
|
|
private APIAccess api;
|
2018-07-21 13:16:22 +08:00
|
|
|
|
|
2018-07-20 01:07:24 +08:00
|
|
|
|
public ChangelogChart()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2018-07-25 06:59:21 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
Child = container = new Container
|
2018-07-20 01:07:24 +08:00
|
|
|
|
{
|
2018-07-25 06:59:21 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = height,
|
|
|
|
|
Children = new Drawable[]
|
2018-07-20 01:07:24 +08:00
|
|
|
|
{
|
2018-07-25 06:59:21 +08:00
|
|
|
|
background = new Box
|
|
|
|
|
{
|
2018-07-25 20:31:41 +08:00
|
|
|
|
Colour = OsuColour.Gray(0),
|
2018-07-25 06:59:21 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2018-07-25 09:58:08 +08:00
|
|
|
|
new SpriteText
|
2018-07-25 06:59:21 +08:00
|
|
|
|
{
|
|
|
|
|
Text = "Graph Placeholder",
|
|
|
|
|
TextSize = 28,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-07-25 20:31:41 +08:00
|
|
|
|
Colour = OsuColour.Gray(1),
|
2018-07-25 06:59:21 +08:00
|
|
|
|
},
|
2018-07-20 01:07:24 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-07-21 13:16:22 +08:00
|
|
|
|
|
2018-07-21 15:45:14 +08:00
|
|
|
|
private bool isEmpty(APIChangelogChart changelogChart)
|
|
|
|
|
{
|
|
|
|
|
if (changelogChart != null)
|
|
|
|
|
foreach (BuildHistory buildHistory in changelogChart.BuildHistory)
|
|
|
|
|
if (buildHistory.UserCount > 0) return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-21 16:05:12 +08:00
|
|
|
|
private void showChart(APIChangelogChart chartInfo, string updateStreamName = null)
|
2018-07-21 15:45:14 +08:00
|
|
|
|
{
|
|
|
|
|
if (!isEmpty(chartInfo))
|
|
|
|
|
{
|
|
|
|
|
background.Colour = StreamColour.FromStreamName(updateStreamName);
|
2018-07-25 06:59:21 +08:00
|
|
|
|
container.MoveToY(0, transition_duration, Easing.InOutQuad).FadeIn(transition_duration);
|
2018-07-21 15:45:14 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
2018-07-25 06:59:21 +08:00
|
|
|
|
container.MoveToY(-height, transition_duration, Easing.InOutQuad).FadeOut(transition_duration);
|
2018-07-21 15:45:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(APIAccess api)
|
|
|
|
|
{
|
|
|
|
|
this.api = api;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-23 02:27:50 +08:00
|
|
|
|
public void ShowUpdateStream(string updateStream)
|
2018-07-21 13:16:22 +08:00
|
|
|
|
{
|
2018-07-23 02:27:50 +08:00
|
|
|
|
var req = new GetChangelogChartRequest(updateStream);
|
|
|
|
|
req.Success += res => showChart(res, updateStream);
|
2018-07-21 15:45:14 +08:00
|
|
|
|
api.Queue(req);
|
2018-07-21 13:16:22 +08:00
|
|
|
|
}
|
2018-07-21 16:05:12 +08:00
|
|
|
|
|
2018-07-23 02:27:50 +08:00
|
|
|
|
public void ShowAllUpdateStreams()
|
2018-07-21 16:05:12 +08:00
|
|
|
|
{
|
|
|
|
|
var req = new GetChangelogChartRequest();
|
|
|
|
|
req.Success += res => showChart(res);
|
|
|
|
|
api.Queue(req);
|
|
|
|
|
}
|
2018-07-20 01:07:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|