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 19:51:31 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
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;
|
|
|
|
|
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-21 04:11:51 +08:00
|
|
|
|
public APIChangelog CurrentBuild { get; private set; }
|
|
|
|
|
public Action OnBuildChanged;
|
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-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-22 11:28:43 +08:00
|
|
|
|
Padding = new MarginPadding{ Bottom = 100, };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void add(APIChangelog[] changelog)
|
|
|
|
|
{
|
|
|
|
|
DateTime currentDate = new DateTime();
|
|
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
|
|
foreach (APIChangelog 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),
|
|
|
|
|
Margin = new MarginPadding { Top = 30, },
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
Add(changelogContentGroup = new ChangelogContentGroup(build, true)
|
|
|
|
|
{
|
|
|
|
|
BuildRequested = () => showBuild(build),
|
|
|
|
|
});
|
|
|
|
|
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
|
|
|
|
currentDate = build.CreatedAt.Date;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
changelogContentGroup.Add(new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 1,
|
|
|
|
|
Colour = new Color4(32, 24, 35, 255),
|
|
|
|
|
Margin = new MarginPadding { Top = 30, },
|
|
|
|
|
});
|
|
|
|
|
Add(changelogContentGroup = new ChangelogContentGroup(build, false)
|
|
|
|
|
{
|
2018-07-22 11:34:55 +08:00
|
|
|
|
BuildRequested = () => showBuild(build),
|
2018-07-22 11:28:43 +08:00
|
|
|
|
});
|
|
|
|
|
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-20 01:07:24 +08:00
|
|
|
|
}
|
2018-07-20 19:51:31 +08:00
|
|
|
|
|
2018-07-20 23:24:21 +08:00
|
|
|
|
private void add(APIChangelog changelogBuild)
|
2018-07-20 19:51:31 +08:00
|
|
|
|
{
|
2018-07-21 12:37:42 +08:00
|
|
|
|
Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild)
|
2018-07-21 04:11:51 +08:00
|
|
|
|
{
|
|
|
|
|
PreviousRequested = showPrevious,
|
|
|
|
|
NextRequested = showNext,
|
2018-07-21 12:37:42 +08:00
|
|
|
|
};
|
2018-07-20 19:51:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-22 11:34:55 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Doesn't send back that the build has changed
|
|
|
|
|
/// </summary>
|
2018-07-20 19:51:31 +08:00
|
|
|
|
public void ShowBuild(APIChangelog changelog)
|
|
|
|
|
{
|
2018-07-22 11:28:43 +08:00
|
|
|
|
fetchAndShowChangelogBuild(changelog);
|
2018-07-21 04:11:51 +08:00
|
|
|
|
CurrentBuild = changelog;
|
2018-07-20 19:51:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-22 11:34:55 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends back that the build has changed
|
|
|
|
|
/// </summary>
|
2018-07-21 04:11:51 +08:00
|
|
|
|
private void showBuild(APIChangelog changelog)
|
|
|
|
|
{
|
|
|
|
|
ShowBuild(changelog);
|
|
|
|
|
OnBuildChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-22 11:34:55 +08:00
|
|
|
|
public void ShowListing() => fetchAndShowChangelog();
|
|
|
|
|
|
2018-07-20 21:48:20 +08:00
|
|
|
|
private void showNext()
|
2018-07-20 19:51:31 +08:00
|
|
|
|
{
|
2018-07-21 04:11:51 +08:00
|
|
|
|
if (CurrentBuild.Versions.Next != null)
|
|
|
|
|
showBuild(CurrentBuild.Versions.Next);
|
2018-07-20 19:51:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-20 21:48:20 +08:00
|
|
|
|
private void showPrevious()
|
2018-07-20 19:51:31 +08:00
|
|
|
|
{
|
2018-07-21 04:11:51 +08:00
|
|
|
|
if (CurrentBuild.Versions.Previous != null)
|
|
|
|
|
showBuild(CurrentBuild.Versions.Previous);
|
2018-07-20 23:24:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateChevronTooltips()
|
|
|
|
|
{
|
2018-07-21 04:11:51 +08:00
|
|
|
|
changelogContentGroup.UpdateChevronTooltips(CurrentBuild.Versions.Previous?.DisplayVersion,
|
|
|
|
|
CurrentBuild.Versions.Next?.DisplayVersion);
|
2018-07-20 19:51:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(APIAccess api)
|
|
|
|
|
{
|
|
|
|
|
this.api = api;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-22 11:28:43 +08:00
|
|
|
|
private void fetchAndShowChangelog()
|
|
|
|
|
{
|
|
|
|
|
var req = new GetChangelogRequest();
|
2018-07-22 16:28:53 +08:00
|
|
|
|
req.Success += add;
|
2018-07-22 11:28:43 +08:00
|
|
|
|
api.Queue(req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fetchAndShowChangelogBuild(APIChangelog build)
|
2018-07-20 19:51:31 +08:00
|
|
|
|
{
|
2018-07-21 00:23:25 +08:00
|
|
|
|
var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);
|
2018-07-20 23:24:21 +08:00
|
|
|
|
req.Success += res =>
|
|
|
|
|
{
|
2018-07-21 04:11:51 +08:00
|
|
|
|
CurrentBuild = res;
|
2018-07-21 12:37:42 +08:00
|
|
|
|
add(CurrentBuild);
|
2018-07-21 05:57:46 +08:00
|
|
|
|
changelogContentGroup.GenerateText(CurrentBuild.ChangelogEntries);
|
2018-07-20 23:24:21 +08:00
|
|
|
|
updateChevronTooltips();
|
|
|
|
|
};
|
2018-07-20 19:51:31 +08:00
|
|
|
|
api.Queue(req);
|
|
|
|
|
}
|
2018-07-20 01:07:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|