2019-08-13 02:16:41 +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
|
|
|
|
|
|
2020-07-12 20:45:48 +08:00
|
|
|
|
using System;
|
2019-08-10 23:06:52 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-08-10 18:53:34 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-07-17 19:28:27 +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;
|
2021-07-18 00:28:32 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-08-10 18:53:34 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.News
|
|
|
|
|
{
|
2019-12-28 09:57:41 +08:00
|
|
|
|
public partial class NewsHeader : BreadcrumbControlOverlayHeader
|
2019-08-10 18:53:34 +08:00
|
|
|
|
{
|
2021-07-18 09:55:40 +08:00
|
|
|
|
public static LocalisableString FrontPageString => NewsStrings.IndexTitleInfo;
|
|
|
|
|
|
2020-07-12 20:45:48 +08:00
|
|
|
|
public Action ShowFrontPage;
|
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
|
private readonly Bindable<string> article = new Bindable<string>();
|
2019-08-10 23:06:52 +08:00
|
|
|
|
|
2019-08-10 18:53:34 +08:00
|
|
|
|
public NewsHeader()
|
|
|
|
|
{
|
2021-07-17 19:28:27 +08:00
|
|
|
|
TabControl.AddItem(FrontPageString);
|
2019-08-10 23:06:52 +08:00
|
|
|
|
|
2021-05-20 14:15:19 +08:00
|
|
|
|
article.BindValueChanged(onArticleChanged, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2020-07-12 20:45:48 +08:00
|
|
|
|
Current.BindValueChanged(e =>
|
|
|
|
|
{
|
2021-07-17 19:28:27 +08:00
|
|
|
|
if (e.NewValue == FrontPageString)
|
2020-07-12 20:45:48 +08:00
|
|
|
|
ShowFrontPage?.Invoke();
|
|
|
|
|
});
|
2019-08-10 18:53:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-12 20:45:48 +08:00
|
|
|
|
public void SetFrontPage() => article.Value = null;
|
|
|
|
|
|
|
|
|
|
public void SetArticle(string slug) => article.Value = slug;
|
|
|
|
|
|
|
|
|
|
private void onArticleChanged(ValueChangedEvent<string> e)
|
2019-08-10 23:06:52 +08:00
|
|
|
|
{
|
2020-07-12 20:45:48 +08:00
|
|
|
|
if (e.OldValue != null)
|
|
|
|
|
TabControl.RemoveItem(e.OldValue);
|
2019-08-10 23:06:52 +08:00
|
|
|
|
|
2020-07-12 20:45:48 +08:00
|
|
|
|
if (e.NewValue != null)
|
2019-08-10 23:06:52 +08:00
|
|
|
|
{
|
2020-07-12 20:45:48 +08:00
|
|
|
|
TabControl.AddItem(e.NewValue);
|
|
|
|
|
Current.Value = e.NewValue;
|
2019-08-10 23:06:52 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-07-17 19:28:27 +08:00
|
|
|
|
Current.Value = FrontPageString;
|
2019-08-10 23:06:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-27 20:36:19 +08:00
|
|
|
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news");
|
2019-08-10 18:53:34 +08:00
|
|
|
|
|
2020-03-25 05:08:20 +08:00
|
|
|
|
protected override OverlayTitle CreateTitle() => new NewsHeaderTitle();
|
2019-08-10 18:53:34 +08:00
|
|
|
|
|
2020-03-25 05:08:20 +08:00
|
|
|
|
private partial class NewsHeaderTitle : OverlayTitle
|
2019-08-10 18:53:34 +08:00
|
|
|
|
{
|
|
|
|
|
public NewsHeaderTitle()
|
|
|
|
|
{
|
2021-08-03 15:34:21 +08:00
|
|
|
|
Title = PageTitleStrings.MainNewsControllerDefault;
|
2021-07-18 10:12:24 +08:00
|
|
|
|
Description = NamedOverlayComponentStrings.NewsDescription;
|
2023-12-27 22:35:03 +08:00
|
|
|
|
Icon = OsuIcon.News;
|
2019-08-10 18:53:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|