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
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
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;
|
2020-02-27 19:39:10 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
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;
|
2020-02-27 19:39:10 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-07-18 01:35:54 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2023-11-24 12:16:04 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2021-07-18 02:23:12 +08:00
|
|
|
|
using osu.Game.Localisation;
|
2019-05-21 11:52:50 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2021-07-18 01:35:54 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Changelog
|
|
|
|
|
{
|
2019-12-28 09:57:41 +08:00
|
|
|
|
public partial class ChangelogHeader : BreadcrumbControlOverlayHeader
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2020-02-04 05:43:04 +08:00
|
|
|
|
public readonly Bindable<APIChangelogBuild> Build = new Bindable<APIChangelogBuild>();
|
2019-05-21 12:34:35 +08:00
|
|
|
|
|
2019-05-21 11:52:50 +08:00
|
|
|
|
public Action ListingSelected;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
2020-03-03 22:01:58 +08:00
|
|
|
|
public ChangelogUpdateStreamControl Streams;
|
2019-05-22 22:56:50 +08:00
|
|
|
|
|
2021-07-18 09:55:40 +08:00
|
|
|
|
public static LocalisableString ListingString => LayoutStrings.HeaderChangelogIndex;
|
2018-07-24 02:36:24 +08:00
|
|
|
|
|
2021-11-05 23:07:12 +08:00
|
|
|
|
private readonly Bindable<APIUpdateStream> currentStream = new Bindable<APIUpdateStream>();
|
|
|
|
|
|
2020-02-27 19:39:10 +08:00
|
|
|
|
private Box streamsBackground;
|
|
|
|
|
|
2019-05-21 11:52:50 +08:00
|
|
|
|
public ChangelogHeader()
|
|
|
|
|
{
|
2021-07-18 01:35:54 +08:00
|
|
|
|
TabControl.AddItem(ListingString);
|
2020-02-04 05:43:04 +08:00
|
|
|
|
Current.ValueChanged += e =>
|
2019-05-21 11:52:50 +08:00
|
|
|
|
{
|
2021-07-18 01:35:54 +08:00
|
|
|
|
if (e.NewValue == ListingString)
|
2019-05-21 11:52:50 +08:00
|
|
|
|
ListingSelected?.Invoke();
|
|
|
|
|
};
|
2019-05-21 12:34:35 +08:00
|
|
|
|
|
2020-02-04 05:43:04 +08:00
|
|
|
|
Build.ValueChanged += showBuild;
|
2021-11-05 23:07:12 +08:00
|
|
|
|
|
|
|
|
|
currentStream.ValueChanged += e =>
|
|
|
|
|
{
|
|
|
|
|
if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Build.Value?.UpdateStream))
|
|
|
|
|
Build.Value = e.NewValue.LatestBuild;
|
|
|
|
|
};
|
2019-05-21 11:52:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-27 19:39:10 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
streamsBackground.Colour = colourProvider.Background5;
|
|
|
|
|
}
|
|
|
|
|
|
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());
|
2020-02-04 05:43:04 +08:00
|
|
|
|
Current.Value = e.NewValue.ToString();
|
2019-05-21 11:52:50 +08:00
|
|
|
|
|
2020-01-27 13:52:21 +08:00
|
|
|
|
updateCurrentStream();
|
2019-05-21 12:34:35 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-05-21 11:52:50 +08:00
|
|
|
|
{
|
2021-07-18 01:35:54 +08:00
|
|
|
|
Current.Value = ListingString;
|
2021-11-05 23:07:12 +08:00
|
|
|
|
currentStream.Value = 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
|
|
|
|
|
2021-11-06 22:20:29 +08:00
|
|
|
|
protected override Drawable CreateContent() => new Container
|
2019-05-20 17:02:27 +08:00
|
|
|
|
{
|
2021-11-06 22:20:29 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2021-11-06 22:20:29 +08:00
|
|
|
|
streamsBackground = new Box
|
2020-02-27 19:47:31 +08:00
|
|
|
|
{
|
2021-11-06 22:20:29 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Padding = new MarginPadding
|
2020-02-27 19:47:31 +08:00
|
|
|
|
{
|
2023-04-03 11:45:09 +08:00
|
|
|
|
Horizontal = WaveOverlayContainer.HORIZONTAL_PADDING - ChangelogUpdateStreamItem.PADDING,
|
2021-11-06 22:20:29 +08:00
|
|
|
|
Vertical = 20
|
2020-02-27 19:47:31 +08:00
|
|
|
|
},
|
2021-11-06 22:20:29 +08:00
|
|
|
|
Child = Streams = new ChangelogUpdateStreamControl { Current = currentStream },
|
2020-02-27 19:47:31 +08:00
|
|
|
|
}
|
2021-11-06 22:20:29 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
2020-03-25 05:08:20 +08:00
|
|
|
|
protected override OverlayTitle CreateTitle() => 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()
|
|
|
|
|
{
|
2020-02-04 05:43:04 +08:00
|
|
|
|
if (Build.Value == null)
|
2020-01-27 13:52:21 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2021-11-05 23:07:12 +08:00
|
|
|
|
currentStream.Value = Streams.Items.FirstOrDefault(s => s.Name == Build.Value.UpdateStream.Name);
|
2020-01-27 13:52:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-25 05:08:20 +08:00
|
|
|
|
private partial class ChangelogHeaderTitle : OverlayTitle
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2019-05-20 17:02:27 +08:00
|
|
|
|
public ChangelogHeaderTitle()
|
|
|
|
|
{
|
2021-08-03 15:34:21 +08:00
|
|
|
|
Title = PageTitleStrings.MainChangelogControllerDefault;
|
2021-07-18 10:12:24 +08:00
|
|
|
|
Description = NamedOverlayComponentStrings.ChangelogDescription;
|
2023-12-27 22:35:03 +08:00
|
|
|
|
Icon = OsuIcon.ChangelogB;
|
2019-05-20 17:02:27 +08:00
|
|
|
|
}
|
2018-07-17 05:50:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|