2019-05-17 10:43:36 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-05-13 16:14:52 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
2019-05-21 11:52:50 +08:00
|
|
|
|
using System;
|
2020-01-27 13:52:21 +08:00
|
|
|
|
using System.Collections.Generic;
|
2019-05-24 10:04:36 +08:00
|
|
|
|
using System.Linq;
|
2019-05-21 12:34:35 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-05-20 17:02:27 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-05-21 11:52:50 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Changelog
|
|
|
|
|
{
|
2019-12-28 09:57:41 +08:00
|
|
|
|
public class ChangelogHeader : BreadcrumbControlOverlayHeader
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2019-05-21 12:34:35 +08:00
|
|
|
|
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
|
|
|
|
|
|
2019-05-21 11:52:50 +08:00
|
|
|
|
public Action ListingSelected;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
2019-05-22 22:56:50 +08:00
|
|
|
|
public UpdateStreamBadgeArea Streams;
|
|
|
|
|
|
2019-12-28 09:57:41 +08:00
|
|
|
|
private const string listing_string = "listing";
|
2018-07-24 02:36:24 +08:00
|
|
|
|
|
2019-05-21 11:52:50 +08:00
|
|
|
|
public ChangelogHeader()
|
|
|
|
|
{
|
2020-01-21 11:00:12 +08:00
|
|
|
|
TabControl.AddItem(listing_string);
|
|
|
|
|
TabControl.Current.ValueChanged += e =>
|
2019-05-21 11:52:50 +08:00
|
|
|
|
{
|
|
|
|
|
if (e.NewValue == listing_string)
|
|
|
|
|
ListingSelected?.Invoke();
|
|
|
|
|
};
|
2019-05-21 12:34:35 +08:00
|
|
|
|
|
|
|
|
|
Current.ValueChanged += showBuild;
|
2019-05-22 22:56:50 +08:00
|
|
|
|
|
|
|
|
|
Streams.Current.ValueChanged += e =>
|
|
|
|
|
{
|
2020-01-27 13:52:21 +08:00
|
|
|
|
if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Current.Value?.UpdateStream))
|
2019-05-22 22:56:50 +08:00
|
|
|
|
Current.Value = e.NewValue.LatestBuild;
|
|
|
|
|
};
|
2019-05-21 11:52:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ChangelogHeaderTitle title;
|
|
|
|
|
|
2019-05-21 12:34:35 +08:00
|
|
|
|
private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
|
2019-05-20 17:02:27 +08:00
|
|
|
|
{
|
2019-05-21 12:34:35 +08:00
|
|
|
|
if (e.OldValue != null)
|
2020-01-21 11:00:12 +08:00
|
|
|
|
TabControl.RemoveItem(e.OldValue.ToString());
|
2019-05-20 17:02:27 +08:00
|
|
|
|
|
2019-05-21 12:34:35 +08:00
|
|
|
|
if (e.NewValue != null)
|
|
|
|
|
{
|
2020-01-21 11:00:12 +08:00
|
|
|
|
TabControl.AddItem(e.NewValue.ToString());
|
|
|
|
|
TabControl.Current.Value = e.NewValue.ToString();
|
2019-05-21 11:52:50 +08:00
|
|
|
|
|
2020-01-27 13:52:21 +08:00
|
|
|
|
updateCurrentStream();
|
2019-05-22 22:56:50 +08:00
|
|
|
|
|
2019-05-21 12:34:35 +08:00
|
|
|
|
title.Version = e.NewValue.UpdateStream.DisplayName;
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-05-21 11:52:50 +08:00
|
|
|
|
{
|
2020-01-21 11:00:12 +08:00
|
|
|
|
TabControl.Current.Value = listing_string;
|
2019-05-22 22:56:50 +08:00
|
|
|
|
Streams.Current.Value = null;
|
2019-05-21 12:34:35 +08:00
|
|
|
|
title.Version = null;
|
2019-05-21 11:52:50 +08:00
|
|
|
|
}
|
2019-05-20 17:02:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-27 20:36:19 +08:00
|
|
|
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/changelog");
|
2019-05-13 16:32:49 +08:00
|
|
|
|
|
2019-12-27 11:36:41 +08:00
|
|
|
|
protected override Drawable CreateContent() => new Container
|
2019-05-20 17:02:27 +08:00
|
|
|
|
{
|
2019-05-22 22:56:50 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2018-07-17 05:50:22 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-05-22 22:56:50 +08:00
|
|
|
|
Streams = new UpdateStreamBadgeArea(),
|
2019-05-20 17:02:27 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
2019-05-21 11:52:50 +08:00
|
|
|
|
protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle();
|
2019-05-20 17:02:27 +08:00
|
|
|
|
|
2020-01-27 13:52:21 +08:00
|
|
|
|
public void Populate(List<APIUpdateStream> streams)
|
|
|
|
|
{
|
|
|
|
|
Streams.Populate(streams);
|
|
|
|
|
updateCurrentStream();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateCurrentStream()
|
|
|
|
|
{
|
|
|
|
|
if (Current.Value == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Current.Value.UpdateStream.Name);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-20 17:02:27 +08:00
|
|
|
|
private class ChangelogHeaderTitle : ScreenTitle
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2019-05-21 11:52:50 +08:00
|
|
|
|
public string Version
|
|
|
|
|
{
|
|
|
|
|
set => Section = value ?? listing_string;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-20 17:02:27 +08:00
|
|
|
|
public ChangelogHeaderTitle()
|
|
|
|
|
{
|
2019-12-27 02:03:39 +08:00
|
|
|
|
Title = "changelog";
|
2019-05-21 11:52:50 +08:00
|
|
|
|
Version = null;
|
2019-05-20 17:02:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-11 15:15:44 +08:00
|
|
|
|
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/changelog");
|
2018-07-17 05:50:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|