1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-10 06:27:19 +08:00

61 lines
1.6 KiB
C#
Raw Normal View History

// 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.
2019-08-10 17:06:52 +02:00
using osu.Framework.Bindables;
2019-08-10 12:53:34 +02:00
using osu.Framework.Graphics;
2019-08-10 17:06:52 +02:00
using System;
2019-08-10 12:53:34 +02:00
namespace osu.Game.Overlays.News
{
public class NewsHeader : BreadcrumbControlOverlayHeader
2019-08-10 12:53:34 +02:00
{
2019-12-26 21:03:39 +03:00
private const string front_page_string = "frontpage";
2019-08-10 12:53:34 +02:00
public readonly Bindable<string> Post = new Bindable<string>(null);
2019-08-10 17:06:52 +02:00
public Action ShowFrontPage;
2019-08-10 12:53:34 +02:00
public NewsHeader()
{
2020-01-21 06:00:12 +03:00
TabControl.AddItem(front_page_string);
2019-08-10 17:06:52 +02:00
Current.ValueChanged += e =>
2019-08-10 17:06:52 +02:00
{
if (e.NewValue == front_page_string)
ShowFrontPage?.Invoke();
};
Post.ValueChanged += showPost;
2019-08-10 12:53:34 +02:00
}
2019-12-26 21:03:39 +03:00
private void showPost(ValueChangedEvent<string> e)
2019-08-10 17:06:52 +02:00
{
if (e.OldValue != null)
2020-01-21 06:00:12 +03:00
TabControl.RemoveItem(e.OldValue);
2019-08-10 17:06:52 +02:00
if (e.NewValue != null)
{
2020-01-21 06:00:12 +03:00
TabControl.AddItem(e.NewValue);
Current.Value = e.NewValue;
2019-08-10 17:06:52 +02:00
}
else
{
Current.Value = front_page_string;
2019-08-10 17:06:52 +02:00
}
}
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news");
2019-08-10 12:53:34 +02:00
protected override OverlayTitle CreateTitle() => new NewsHeaderTitle();
2019-08-10 12:53:34 +02:00
private class NewsHeaderTitle : OverlayTitle
2019-08-10 12:53:34 +02:00
{
public NewsHeaderTitle()
{
2019-12-26 21:03:39 +03:00
Title = "news";
IconTexture = "Icons/news";
2019-08-10 12:53:34 +02:00
}
}
}
}