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-22 11:28:43 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-07-22 11:28:43 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-07-20 19:51:31 +08:00
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-07-21 04:11:51 +08:00
|
|
|
|
using System;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Changelog
|
|
|
|
|
{
|
2018-07-22 11:28:43 +08:00
|
|
|
|
public class ChangelogContent : FillFlowContainer
|
2018-07-20 01:07:24 +08:00
|
|
|
|
{
|
2018-07-20 19:51:31 +08:00
|
|
|
|
private APIAccess api;
|
2018-07-20 23:24:21 +08:00
|
|
|
|
private ChangelogContentGroup changelogContentGroup;
|
2018-07-20 19:51:31 +08:00
|
|
|
|
|
2018-10-19 03:04:21 +08:00
|
|
|
|
public delegate void BuildSelectedEventHandler(APIChangelogBuild build, EventArgs args);
|
2018-07-23 02:14:28 +08:00
|
|
|
|
|
|
|
|
|
public event BuildSelectedEventHandler BuildSelected;
|
|
|
|
|
|
2018-07-20 01:07:24 +08:00
|
|
|
|
public ChangelogContent()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2018-07-20 03:49:13 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
Direction = FillDirection.Vertical;
|
2018-07-25 23:04:36 +08:00
|
|
|
|
Padding = new MarginPadding{ Bottom = 100 };
|
2018-07-22 11:28:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-19 03:04:21 +08:00
|
|
|
|
public void ShowListing(APIChangelogBuild[] changelog)
|
2018-07-22 11:28:43 +08:00
|
|
|
|
{
|
|
|
|
|
DateTime currentDate = new DateTime();
|
|
|
|
|
Clear();
|
|
|
|
|
|
2018-10-19 03:04:21 +08:00
|
|
|
|
foreach (APIChangelogBuild build in changelog)
|
2018-07-20 03:49:13 +08:00
|
|
|
|
{
|
2018-07-22 11:28:43 +08:00
|
|
|
|
if (build.CreatedAt.Date != currentDate)
|
|
|
|
|
{
|
|
|
|
|
if (Children.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
Add(new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 2,
|
|
|
|
|
Colour = new Color4(17, 17, 17, 255),
|
2018-07-25 23:04:36 +08:00
|
|
|
|
Margin = new MarginPadding { Top = 30 },
|
2018-07-22 11:28:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2018-07-24 00:38:20 +08:00
|
|
|
|
changelogContentGroup = new ChangelogContentGroup(build, true);
|
2018-07-23 04:31:24 +08:00
|
|
|
|
changelogContentGroup.BuildSelected += OnBuildSelected;
|
2018-07-22 11:28:43 +08:00
|
|
|
|
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
2018-07-24 00:38:20 +08:00
|
|
|
|
Add(changelogContentGroup);
|
2018-07-22 11:28:43 +08:00
|
|
|
|
currentDate = build.CreatedAt.Date;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
changelogContentGroup.Add(new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 1,
|
|
|
|
|
Colour = new Color4(32, 24, 35, 255),
|
2018-07-25 23:04:36 +08:00
|
|
|
|
Margin = new MarginPadding { Top = 30 },
|
2018-07-22 11:28:43 +08:00
|
|
|
|
});
|
2018-07-24 00:38:20 +08:00
|
|
|
|
|
|
|
|
|
changelogContentGroup = new ChangelogContentGroup(build, false);
|
2018-07-23 04:31:24 +08:00
|
|
|
|
changelogContentGroup.BuildSelected += OnBuildSelected;
|
2018-07-22 11:28:43 +08:00
|
|
|
|
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
2018-07-24 00:38:20 +08:00
|
|
|
|
Add(changelogContentGroup);
|
2018-07-22 11:28:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-20 01:07:24 +08:00
|
|
|
|
}
|
2018-07-20 19:51:31 +08:00
|
|
|
|
|
2018-10-19 03:04:21 +08:00
|
|
|
|
public void ShowBuild(APIChangelogBuild changelogBuild)
|
2018-07-20 23:24:21 +08:00
|
|
|
|
{
|
2018-07-23 02:27:50 +08:00
|
|
|
|
Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild);
|
2018-07-24 01:40:58 +08:00
|
|
|
|
changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries);
|
|
|
|
|
changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion,
|
|
|
|
|
changelogBuild.Versions.Next?.DisplayVersion);
|
2018-07-24 02:36:24 +08:00
|
|
|
|
changelogContentGroup.BuildSelected += OnBuildSelected;
|
2018-07-20 19:51:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-19 03:04:21 +08:00
|
|
|
|
protected virtual void OnBuildSelected(APIChangelogBuild build, EventArgs args)
|
2018-07-20 19:51:31 +08:00
|
|
|
|
{
|
2018-07-24 03:38:14 +08:00
|
|
|
|
BuildSelected?.Invoke(build, EventArgs.Empty);
|
2018-07-20 19:51:31 +08:00
|
|
|
|
}
|
2018-07-20 01:07:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|