mirror of
https://github.com/ppy/osu.git
synced 2025-03-14 05:47:20 +08:00
handle page change when clicking breadcrumb
This commit is contained in:
parent
1578b0462d
commit
9c824ece1b
@ -1,6 +1,8 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
@ -12,7 +14,10 @@ namespace osu.Game.Overlays.Wiki
|
||||
private const string index_page_string = "index";
|
||||
private const string index_path = "Main_Page";
|
||||
|
||||
public Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
|
||||
public readonly Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
|
||||
|
||||
public Action ShowIndexPage;
|
||||
public Action ShowParentPage;
|
||||
|
||||
public WikiHeader()
|
||||
{
|
||||
@ -20,6 +25,7 @@ namespace osu.Game.Overlays.Wiki
|
||||
Current.Value = index_page_string;
|
||||
|
||||
WikiPageData.BindValueChanged(onWikiPageChange);
|
||||
Current.BindValueChanged(onCurrentChange);
|
||||
}
|
||||
|
||||
private void onWikiPageChange(ValueChangedEvent<APIWikiPage> e)
|
||||
@ -45,6 +51,20 @@ namespace osu.Game.Overlays.Wiki
|
||||
Current.Value = e.NewValue.Title;
|
||||
}
|
||||
|
||||
private void onCurrentChange(ValueChangedEvent<string> e)
|
||||
{
|
||||
if (e.NewValue == TabControl.Items.LastOrDefault())
|
||||
return;
|
||||
|
||||
if (e.NewValue == index_page_string)
|
||||
{
|
||||
ShowIndexPage?.Invoke();
|
||||
return;
|
||||
}
|
||||
|
||||
ShowParentPage?.Invoke();
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/wiki");
|
||||
|
||||
protected override OverlayTitle CreateTitle() => new WikiHeaderTitle();
|
||||
|
@ -75,7 +75,11 @@ namespace osu.Game.Overlays
|
||||
Show();
|
||||
}
|
||||
|
||||
protected override WikiHeader CreateHeader() => new WikiHeader();
|
||||
protected override WikiHeader CreateHeader() => new WikiHeader
|
||||
{
|
||||
ShowIndexPage = () => ShowPage(),
|
||||
ShowParentPage = showParentPage,
|
||||
};
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user