1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-05 13:42:59 +08:00

change header breadcrumb when page change

This commit is contained in:
Gagah Pangeran Rosfatiputra 2021-05-20 00:28:26 +07:00
parent f2de28814a
commit bc1cad0963
No known key found for this signature in database
GPG Key ID: 25F6F17FD29031E2
2 changed files with 32 additions and 0 deletions

View File

@ -1,17 +1,48 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Wiki namespace osu.Game.Overlays.Wiki
{ {
public class WikiHeader : BreadcrumbControlOverlayHeader public class WikiHeader : BreadcrumbControlOverlayHeader
{ {
private const string index_page_string = "index"; private const string index_page_string = "index";
private const string index_path = "Main_Page";
public Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
public WikiHeader() public WikiHeader()
{ {
TabControl.AddItem(index_page_string); TabControl.AddItem(index_page_string);
Current.Value = index_page_string;
WikiPageData.BindValueChanged(onWikiPageChange);
}
private void onWikiPageChange(ValueChangedEvent<APIWikiPage> e)
{
if (e.NewValue == null)
return;
TabControl.Clear();
Current.Value = null;
TabControl.AddItem(index_page_string);
if (e.NewValue.Path == index_path)
{
Current.Value = index_page_string;
return;
}
if (e.NewValue.Subtitle != null)
TabControl.AddItem(e.NewValue.Subtitle);
TabControl.AddItem(e.NewValue.Title);
Current.Value = e.NewValue.Title;
} }
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/wiki"); protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/wiki");

View File

@ -74,6 +74,7 @@ namespace osu.Game.Overlays
{ {
base.LoadComplete(); base.LoadComplete();
path.BindValueChanged(onPathChanged); path.BindValueChanged(onPathChanged);
wikiData.BindTo(Header.WikiPageData);
} }
protected override void PopIn() protected override void PopIn()