2019-05-13 16:14:52 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
2019-05-17 16:15:51 +08:00
|
|
|
|
using System.Collections.Generic;
|
2019-05-17 16:47:28 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-07-24 05:15:14 +08:00
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-07-19 01:32:15 +08:00
|
|
|
|
using osu.Game.Input.Bindings;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
using osu.Game.Online.API.Requests;
|
2018-07-24 03:38:14 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
using osu.Game.Overlays.Changelog;
|
2019-05-12 23:36:05 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2019-05-14 13:18:36 +08:00
|
|
|
|
public class ChangelogOverlay : FullscreenOverlay
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2019-05-14 13:18:36 +08:00
|
|
|
|
private ChangelogHeader header;
|
2019-05-12 23:36:05 +08:00
|
|
|
|
|
2019-05-15 17:08:19 +08:00
|
|
|
|
private BadgeDisplay badges;
|
2019-05-12 23:36:05 +08:00
|
|
|
|
|
2019-05-17 16:47:28 +08:00
|
|
|
|
private Container<ChangelogContent> content;
|
2018-07-23 00:35:29 +08:00
|
|
|
|
|
2018-07-25 00:41:47 +08:00
|
|
|
|
private SampleChannel sampleBack;
|
|
|
|
|
|
2019-05-17 16:15:51 +08:00
|
|
|
|
private List<APIChangelogBuild> builds;
|
|
|
|
|
|
2019-05-14 13:18:36 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(AudioManager audio, OsuColour colour)
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2019-05-17 16:20:50 +08:00
|
|
|
|
Waves.FirstWaveColour = colour.GreyVioletLight;
|
|
|
|
|
Waves.SecondWaveColour = colour.GreyViolet;
|
|
|
|
|
Waves.ThirdWaveColour = colour.GreyVioletDark;
|
|
|
|
|
Waves.FourthWaveColour = colour.GreyVioletDarker;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-07-22 05:00:05 +08:00
|
|
|
|
Colour = new Color4(49, 36, 54, 255),
|
2018-07-17 05:50:22 +08:00
|
|
|
|
},
|
2019-05-17 11:42:08 +08:00
|
|
|
|
new ScrollContainer
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ScrollbarVisible = false,
|
|
|
|
|
Child = new ReverseChildIDFillFlowContainer<Drawable>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
header = new ChangelogHeader(),
|
2019-05-15 17:08:19 +08:00
|
|
|
|
badges = new BadgeDisplay(),
|
2019-05-17 16:47:28 +08:00
|
|
|
|
content = new Container<ChangelogContent>
|
2019-05-17 16:15:51 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
}
|
2018-07-17 05:50:22 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2019-05-15 16:55:26 +08:00
|
|
|
|
|
2018-07-25 03:42:25 +08:00
|
|
|
|
header.ListingSelected += ShowListing;
|
2019-05-15 17:08:19 +08:00
|
|
|
|
|
2019-05-17 10:43:36 +08:00
|
|
|
|
// todo: better
|
2019-05-17 11:40:15 +08:00
|
|
|
|
badges.Current.ValueChanged += e =>
|
|
|
|
|
{
|
|
|
|
|
if (e.NewValue?.LatestBuild != null)
|
|
|
|
|
ShowBuild(e.NewValue.LatestBuild);
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-17 16:15:51 +08:00
|
|
|
|
sampleBack = audio.Sample.Get(@"UI/generic-select-soft");
|
2018-07-25 00:41:47 +08:00
|
|
|
|
}
|
2018-07-19 01:32:15 +08:00
|
|
|
|
|
2018-07-17 05:50:22 +08:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
|
|
|
|
|
2019-05-17 16:49:05 +08:00
|
|
|
|
if (!initialFetchPerformed)
|
|
|
|
|
fetchListing();
|
2018-07-17 05:50:22 +08:00
|
|
|
|
}
|
2018-07-20 01:07:24 +08:00
|
|
|
|
|
2018-07-25 00:41:47 +08:00
|
|
|
|
public override bool OnPressed(GlobalAction action)
|
2018-07-23 02:27:50 +08:00
|
|
|
|
{
|
2018-07-25 00:41:47 +08:00
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case GlobalAction.Back:
|
2019-05-17 16:47:28 +08:00
|
|
|
|
if (content.Child is ChangelogListing)
|
2018-07-25 06:12:05 +08:00
|
|
|
|
{
|
2019-05-17 11:42:08 +08:00
|
|
|
|
State = Visibility.Hidden;
|
2018-07-25 06:12:05 +08:00
|
|
|
|
}
|
2018-07-25 00:41:47 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-07-25 03:42:25 +08:00
|
|
|
|
ShowListing();
|
2018-07-25 00:41:47 +08:00
|
|
|
|
sampleBack?.Play();
|
|
|
|
|
}
|
2019-05-12 23:36:05 +08:00
|
|
|
|
|
2018-07-25 00:41:47 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-07-23 02:27:50 +08:00
|
|
|
|
|
2018-07-25 00:41:47 +08:00
|
|
|
|
return false;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-25 03:42:25 +08:00
|
|
|
|
public void ShowListing()
|
|
|
|
|
{
|
2019-05-17 16:47:28 +08:00
|
|
|
|
if (content.Children.FirstOrDefault() is ChangelogListing)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-07-25 03:42:25 +08:00
|
|
|
|
header.ShowListing();
|
2019-05-17 11:40:15 +08:00
|
|
|
|
badges.Current.Value = null;
|
2019-05-17 16:47:28 +08:00
|
|
|
|
loadContent(new ChangelogListing(builds));
|
2018-07-25 03:42:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-23 00:35:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches and shows a specific build from a specific update stream.
|
|
|
|
|
/// </summary>
|
2019-05-13 16:24:33 +08:00
|
|
|
|
/// <param name="build">Must contain at least <see cref="APIUpdateStream.Name"/> and
|
|
|
|
|
/// <see cref="APIChangelogBuild.Version"/>. If <see cref="APIUpdateStream.DisplayName"/> and
|
2018-10-19 03:04:21 +08:00
|
|
|
|
/// <see cref="APIChangelogBuild.DisplayVersion"/> are specified, the header will instantly display them.</param>
|
2019-05-15 17:08:19 +08:00
|
|
|
|
public void ShowBuild(APIChangelogBuild build)
|
2018-07-23 00:35:29 +08:00
|
|
|
|
{
|
2019-05-17 10:43:36 +08:00
|
|
|
|
if (build == null)
|
|
|
|
|
{
|
|
|
|
|
ShowListing();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-15 17:21:06 +08:00
|
|
|
|
header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion);
|
2019-05-17 10:43:36 +08:00
|
|
|
|
badges.Current.Value = build.UpdateStream;
|
2018-07-24 03:38:14 +08:00
|
|
|
|
|
2019-05-19 01:09:08 +08:00
|
|
|
|
loadContent(new ChangelogSingleBuild(build));
|
2019-05-17 16:47:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 16:49:05 +08:00
|
|
|
|
private bool initialFetchPerformed;
|
|
|
|
|
|
2019-05-17 16:47:28 +08:00
|
|
|
|
private void fetchListing()
|
|
|
|
|
{
|
2019-05-17 16:49:05 +08:00
|
|
|
|
initialFetchPerformed = true;
|
|
|
|
|
|
2019-05-17 16:47:28 +08:00
|
|
|
|
var req = new GetChangelogRequest();
|
|
|
|
|
req.Success += res =>
|
|
|
|
|
{
|
|
|
|
|
// remap streams to builds to ensure model equality
|
|
|
|
|
res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id));
|
|
|
|
|
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
|
|
|
|
|
|
|
|
|
|
builds = res.Builds;
|
|
|
|
|
badges.Populate(res.Streams);
|
2019-05-14 13:18:36 +08:00
|
|
|
|
|
2019-05-17 16:47:28 +08:00
|
|
|
|
ShowListing();
|
|
|
|
|
};
|
2019-05-17 16:49:05 +08:00
|
|
|
|
req.Failure += _ => initialFetchPerformed = false;
|
2019-05-17 16:47:28 +08:00
|
|
|
|
|
|
|
|
|
API.Queue(req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CancellationTokenSource loadContentTask;
|
|
|
|
|
|
|
|
|
|
private void loadContent(ChangelogContent newContent)
|
|
|
|
|
{
|
|
|
|
|
content.FadeTo(0.2f, 300, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
loadContentTask?.Cancel();
|
|
|
|
|
|
|
|
|
|
LoadComponentAsync(newContent, c =>
|
2019-05-15 17:21:06 +08:00
|
|
|
|
{
|
2019-05-17 16:47:28 +08:00
|
|
|
|
content.FadeIn(300, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
c.BuildSelected = ShowBuild;
|
|
|
|
|
content.Child = c;
|
|
|
|
|
}, (loadContentTask = new CancellationTokenSource()).Token);
|
2018-07-20 01:07:24 +08:00
|
|
|
|
}
|
2018-07-17 05:50:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|