2018-07-17 05:50:22 +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
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
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.Extensions.Color4Extensions;
|
|
|
|
|
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;
|
|
|
|
|
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;
|
2018-07-23 02:27:50 +08:00
|
|
|
|
using System;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
|
|
|
|
public class ChangelogOverlay : WaveOverlayContainer
|
|
|
|
|
{
|
2018-07-19 01:32:15 +08:00
|
|
|
|
private readonly ChangelogHeader header;
|
2018-07-23 00:35:29 +08:00
|
|
|
|
private readonly ChangelogBadges badges;
|
2018-07-27 06:34:44 +08:00
|
|
|
|
//private readonly ChangelogChart chart;
|
2018-07-25 03:42:25 +08:00
|
|
|
|
private readonly ChangelogContent listing;
|
2018-07-23 00:35:29 +08:00
|
|
|
|
private readonly ChangelogContent content;
|
|
|
|
|
|
2018-07-25 02:57:09 +08:00
|
|
|
|
private readonly ScrollContainer scroll;
|
|
|
|
|
|
2018-07-23 00:35:29 +08:00
|
|
|
|
private readonly Color4 purple = new Color4(191, 4, 255, 255);
|
2018-07-20 01:07:24 +08:00
|
|
|
|
|
2018-07-25 00:41:47 +08:00
|
|
|
|
private SampleChannel sampleBack;
|
|
|
|
|
|
2018-07-20 01:07:24 +08:00
|
|
|
|
private APIAccess api;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
2018-07-23 00:35:29 +08:00
|
|
|
|
private bool isAtListing;
|
2018-07-25 02:57:09 +08:00
|
|
|
|
private float savedScrollPosition;
|
2018-07-18 00:32:11 +08:00
|
|
|
|
|
2018-07-25 00:41:47 +08:00
|
|
|
|
// receive input outside our bounds so we can trigger a close event on ourselves.
|
2018-10-19 02:56:43 +08:00
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
2018-07-25 00:41:47 +08:00
|
|
|
|
|
2018-07-17 05:50:22 +08:00
|
|
|
|
public ChangelogOverlay()
|
|
|
|
|
{
|
2018-07-18 00:32:11 +08:00
|
|
|
|
// these possibly need adjusting?
|
|
|
|
|
Waves.FirstWaveColour = OsuColour.FromHex(@"bf04ff");
|
|
|
|
|
Waves.SecondWaveColour = OsuColour.FromHex(@"8F03BF");
|
|
|
|
|
Waves.ThirdWaveColour = OsuColour.FromHex(@"600280");
|
|
|
|
|
Waves.FourthWaveColour = OsuColour.FromHex(@"300140");
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
|
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
|
Origin = Anchor.TopCentre;
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Width = 0.85f;
|
|
|
|
|
Masking = true;
|
2018-07-18 00:32:11 +08:00
|
|
|
|
|
2018-07-17 05:50:22 +08:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0),
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Radius = 3,
|
|
|
|
|
Offset = new Vector2(0f, 1f),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
},
|
2018-07-25 02:57:09 +08:00
|
|
|
|
scroll = 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(),
|
2018-07-23 00:35:29 +08:00
|
|
|
|
badges = new ChangelogBadges(),
|
2018-07-27 06:34:44 +08:00
|
|
|
|
//chart = new ChangelogChart(),
|
2018-07-25 03:42:25 +08:00
|
|
|
|
listing = new ChangelogContent(),
|
2018-07-22 19:04:39 +08:00
|
|
|
|
content = new ChangelogContent()
|
2018-07-17 05:50:22 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2018-07-25 03:42:25 +08:00
|
|
|
|
header.ListingSelected += ShowListing;
|
2018-07-23 02:27:50 +08:00
|
|
|
|
badges.Selected += onBuildSelected;
|
2018-07-25 03:42:25 +08:00
|
|
|
|
listing.BuildSelected += onBuildSelected;
|
2018-07-24 02:36:24 +08:00
|
|
|
|
content.BuildSelected += onBuildSelected;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-25 00:41:47 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(APIAccess api, AudioManager audio)
|
2018-07-19 01:32:15 +08:00
|
|
|
|
{
|
2018-07-25 00:41:47 +08:00
|
|
|
|
this.api = api;
|
|
|
|
|
sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); // @"UI/screen-back" feels non-fitting here
|
|
|
|
|
}
|
2018-07-19 01:32:15 +08:00
|
|
|
|
|
2018-07-25 00:41:47 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
var req = new GetChangelogLatestBuildsRequest();
|
|
|
|
|
req.Success += badges.Populate;
|
|
|
|
|
api.Queue(req);
|
2018-07-25 03:42:25 +08:00
|
|
|
|
fetchListing();
|
2018-07-25 00:41:47 +08:00
|
|
|
|
base.LoadComplete();
|
2018-07-19 01:32:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-17 05:50:22 +08:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
|
|
|
|
FadeEdgeEffectTo(0.25f, WaveContainer.APPEAR_DURATION, Easing.In);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
|
|
|
|
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out);
|
|
|
|
|
}
|
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:
|
|
|
|
|
if (isAtListing)
|
2018-07-25 06:12:05 +08:00
|
|
|
|
{
|
|
|
|
|
if (scroll.Current > scroll.GetChildPosInContent(listing))
|
|
|
|
|
{
|
|
|
|
|
scroll.ScrollTo(0);
|
|
|
|
|
sampleBack?.Play();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
State = Visibility.Hidden;
|
|
|
|
|
}
|
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();
|
|
|
|
|
}
|
|
|
|
|
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-10-19 03:04:21 +08:00
|
|
|
|
private void onBuildSelected(APIChangelogBuild build, EventArgs e) => FetchAndShowBuild(build);
|
2018-07-23 04:13:14 +08:00
|
|
|
|
|
2018-07-25 03:42:25 +08:00
|
|
|
|
private void fetchListing()
|
2018-07-20 01:07:24 +08:00
|
|
|
|
{
|
2018-07-25 01:34:40 +08:00
|
|
|
|
header.ShowListing();
|
|
|
|
|
if (isAtListing)
|
|
|
|
|
return;
|
2018-07-23 04:13:14 +08:00
|
|
|
|
isAtListing = true;
|
|
|
|
|
var req = new GetChangelogRequest();
|
2018-07-23 00:35:29 +08:00
|
|
|
|
badges.SelectNone();
|
2018-07-25 03:42:25 +08:00
|
|
|
|
req.Success += listing.ShowListing;
|
2018-07-23 00:35:29 +08:00
|
|
|
|
api.Queue(req);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-25 03:42:25 +08:00
|
|
|
|
public void ShowListing()
|
|
|
|
|
{
|
|
|
|
|
header.ShowListing();
|
|
|
|
|
if (isAtListing)
|
|
|
|
|
return;
|
|
|
|
|
isAtListing = true;
|
|
|
|
|
content.Hide();
|
|
|
|
|
listing.Show();
|
|
|
|
|
badges.SelectNone();
|
2018-07-27 06:34:44 +08:00
|
|
|
|
//chart.ShowAllUpdateStreams();
|
2018-07-25 03:42:25 +08:00
|
|
|
|
listing.Show();
|
|
|
|
|
scroll.ScrollTo(savedScrollPosition);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-23 00:35:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches and shows a specific build from a specific update stream.
|
|
|
|
|
/// </summary>
|
2018-10-19 03:04:21 +08:00
|
|
|
|
/// <param name="build">Must contain at least <see cref="APIChangelogBuild.UpdateStream.Name"/> and
|
|
|
|
|
/// <see cref="APIChangelogBuild.Version"/>. If <see cref="APIChangelogBuild.UpdateStream.DisplayName"/> and
|
|
|
|
|
/// <see cref="APIChangelogBuild.DisplayVersion"/> are specified, the header will instantly display them.</param>
|
2018-07-27 06:34:44 +08:00
|
|
|
|
/// <param name="updateBadges">Whether to update badges. Should be set to false in case
|
|
|
|
|
/// the function is called by selecting a badge, to avoid an infinite loop.</param>
|
2018-10-19 03:04:21 +08:00
|
|
|
|
public void FetchAndShowBuild(APIChangelogBuild build, bool updateBadges = true)
|
2018-07-23 00:35:29 +08:00
|
|
|
|
{
|
2018-07-24 03:38:14 +08:00
|
|
|
|
var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);
|
|
|
|
|
|
|
|
|
|
if (build.UpdateStream.DisplayName != null && build.DisplayVersion != null)
|
|
|
|
|
header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion);
|
|
|
|
|
else
|
|
|
|
|
req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion);
|
|
|
|
|
|
2018-07-27 06:34:44 +08:00
|
|
|
|
if (updateBadges)
|
2018-07-24 03:38:14 +08:00
|
|
|
|
badges.SelectUpdateStream(build.UpdateStream.Name);
|
|
|
|
|
|
2018-07-27 06:34:44 +08:00
|
|
|
|
//chart.ShowUpdateStream(build.UpdateStream.Name);
|
2018-07-25 06:59:21 +08:00
|
|
|
|
req.Success += apiChangelog =>
|
2018-07-25 02:57:09 +08:00
|
|
|
|
{
|
2018-07-25 03:42:25 +08:00
|
|
|
|
listing.Hide();
|
|
|
|
|
content.Show();
|
2018-07-25 06:59:21 +08:00
|
|
|
|
content.ShowBuild(apiChangelog);
|
2018-07-25 02:57:09 +08:00
|
|
|
|
if (scroll.Current > scroll.GetChildPosInContent(content))
|
2018-07-27 06:34:44 +08:00
|
|
|
|
scroll.ScrollTo(content);
|
2018-07-25 03:19:29 +08:00
|
|
|
|
if (isAtListing)
|
|
|
|
|
savedScrollPosition = scroll.Current;
|
|
|
|
|
isAtListing = false;
|
2018-07-25 02:57:09 +08:00
|
|
|
|
};
|
2018-07-20 01:07:24 +08:00
|
|
|
|
api.Queue(req);
|
|
|
|
|
}
|
2018-07-17 05:50:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|