2019-05-19 01:09:08 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-05-19 10:28:34 +08:00
|
|
|
using System;
|
2019-05-19 01:09:08 +08:00
|
|
|
using System.Threading;
|
|
|
|
using osu.Framework.Allocation;
|
2019-05-19 10:28:34 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2022-12-16 07:05:47 +08:00
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2019-05-19 01:09:08 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-02-21 22:29:51 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-05-19 01:09:08 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-05-19 10:28:34 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-05-19 01:09:08 +08:00
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.API.Requests;
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-02-21 13:02:40 +08:00
|
|
|
using osu.Game.Overlays.Comments;
|
2019-05-19 01:09:08 +08:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Changelog
|
|
|
|
{
|
|
|
|
public partial class ChangelogSingleBuild : ChangelogContent
|
|
|
|
{
|
|
|
|
private APIChangelogBuild build;
|
|
|
|
|
|
|
|
public ChangelogSingleBuild(APIChangelogBuild build)
|
|
|
|
{
|
|
|
|
this.build = build;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-02-21 22:29:51 +08:00
|
|
|
private void load(CancellationToken? cancellation, IAPIProvider api, OverlayColourProvider colourProvider)
|
2019-05-19 01:09:08 +08:00
|
|
|
{
|
|
|
|
bool complete = false;
|
|
|
|
|
2019-05-23 10:38:13 +08:00
|
|
|
var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);
|
2019-05-19 01:09:08 +08:00
|
|
|
req.Success += res =>
|
|
|
|
{
|
|
|
|
build = res;
|
|
|
|
complete = true;
|
|
|
|
};
|
|
|
|
req.Failure += _ => complete = true;
|
|
|
|
|
2019-11-29 19:03:14 +08:00
|
|
|
api.PerformAsync(req);
|
2019-05-23 10:38:13 +08:00
|
|
|
|
|
|
|
while (!complete)
|
|
|
|
{
|
|
|
|
if (cancellation?.IsCancellationRequested == true)
|
|
|
|
{
|
|
|
|
req.Cancel();
|
|
|
|
return;
|
|
|
|
}
|
2019-05-19 01:09:08 +08:00
|
|
|
|
2019-05-31 12:38:48 +08:00
|
|
|
Thread.Sleep(10);
|
2019-05-23 10:38:13 +08:00
|
|
|
}
|
2019-05-19 01:09:08 +08:00
|
|
|
|
2019-05-23 10:38:13 +08:00
|
|
|
if (build != null)
|
2019-11-11 19:53:22 +08:00
|
|
|
{
|
2020-02-21 13:02:40 +08:00
|
|
|
CommentsContainer comments;
|
|
|
|
|
2019-07-04 14:47:06 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild },
|
2020-02-21 22:29:51 +08:00
|
|
|
new Box
|
2020-02-21 13:02:40 +08:00
|
|
|
{
|
2020-02-21 22:29:51 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 2,
|
|
|
|
Colour = colourProvider.Background6,
|
|
|
|
Margin = new MarginPadding { Top = 30 },
|
|
|
|
},
|
2021-08-10 15:56:54 +08:00
|
|
|
new ChangelogSupporterPromo
|
|
|
|
{
|
|
|
|
Alpha = api.LocalUser.Value.IsSupporter ? 0 : 1,
|
|
|
|
},
|
2021-08-10 15:55:57 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 2,
|
|
|
|
Colour = colourProvider.Background6,
|
2021-08-10 15:56:54 +08:00
|
|
|
Alpha = api.LocalUser.Value.IsSupporter ? 0 : 1,
|
2021-08-10 15:55:57 +08:00
|
|
|
},
|
2020-02-21 22:29:51 +08:00
|
|
|
comments = new CommentsContainer()
|
2019-07-04 14:47:06 +08:00
|
|
|
};
|
2020-02-21 13:02:40 +08:00
|
|
|
|
|
|
|
comments.ShowComments(CommentableType.Build, build.Id);
|
2019-11-11 19:53:22 +08:00
|
|
|
}
|
2019-05-19 01:09:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public partial class ChangelogBuildWithNavigation : ChangelogBuild
|
|
|
|
{
|
|
|
|
public ChangelogBuildWithNavigation(APIChangelogBuild build)
|
|
|
|
: base(build)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-02-21 21:55:12 +08:00
|
|
|
private OsuSpriteText date;
|
|
|
|
|
2019-05-19 01:09:08 +08:00
|
|
|
protected override FillFlowContainer CreateHeader()
|
|
|
|
{
|
|
|
|
var fill = base.CreateHeader();
|
|
|
|
|
2022-12-12 16:38:39 +08:00
|
|
|
var nestedFill = (FillFlowContainer)fill.Child;
|
2019-05-19 01:09:08 +08:00
|
|
|
|
2022-12-12 16:38:39 +08:00
|
|
|
var buildDisplay = (OsuHoverContainer)nestedFill.Child;
|
2022-12-12 12:10:06 +08:00
|
|
|
|
|
|
|
buildDisplay.Scale = new Vector2(1.25f);
|
|
|
|
buildDisplay.Action = null;
|
|
|
|
|
|
|
|
fill.Add(date = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2022-12-16 07:05:47 +08:00
|
|
|
Text = Build.CreatedAt.Date.ToLocalisableString("dd MMMM yyyy"),
|
2022-12-12 12:10:06 +08:00
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 14),
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
Scale = new Vector2(1.25f),
|
|
|
|
});
|
2019-05-19 01:09:08 +08:00
|
|
|
|
2022-12-12 12:10:06 +08:00
|
|
|
nestedFill.Insert(-1, new NavigationIconButton(Build.Versions?.Previous)
|
2019-05-19 01:09:08 +08:00
|
|
|
{
|
2019-07-01 23:41:08 +08:00
|
|
|
Icon = FontAwesome.Solid.ChevronLeft,
|
|
|
|
SelectBuild = b => SelectBuild(b)
|
|
|
|
});
|
2022-12-12 12:10:06 +08:00
|
|
|
nestedFill.Insert(1, new NavigationIconButton(Build.Versions?.Next)
|
2019-07-01 23:41:08 +08:00
|
|
|
{
|
|
|
|
Icon = FontAwesome.Solid.ChevronRight,
|
|
|
|
SelectBuild = b => SelectBuild(b)
|
2019-05-19 01:09:08 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
return fill;
|
|
|
|
}
|
2020-02-21 21:55:12 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
{
|
|
|
|
date.Colour = colourProvider.Light1;
|
|
|
|
}
|
2019-05-19 01:09:08 +08:00
|
|
|
}
|
2019-05-19 10:28:34 +08:00
|
|
|
|
|
|
|
private partial class NavigationIconButton : IconButton
|
|
|
|
{
|
|
|
|
public Action<APIChangelogBuild> SelectBuild;
|
|
|
|
|
|
|
|
public NavigationIconButton(APIChangelogBuild build)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
if (build == null) return;
|
|
|
|
|
|
|
|
TooltipText = build.DisplayVersion;
|
|
|
|
|
|
|
|
Action = () =>
|
|
|
|
{
|
|
|
|
SelectBuild?.Invoke(build);
|
|
|
|
Enabled.Value = false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
HoverColour = colours.GreyVioletLight.Opacity(0.6f);
|
|
|
|
FlashColour = colours.GreyVioletLighter;
|
|
|
|
}
|
|
|
|
}
|
2019-05-19 01:09:08 +08:00
|
|
|
}
|
|
|
|
}
|