2021-04-19 09:24:47 +00: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.
|
|
|
|
|
2021-05-20 07:00:22 +00:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
2021-05-19 17:28:26 +00:00
|
|
|
using osu.Framework.Bindables;
|
2021-04-19 09:24:47 +00:00
|
|
|
using osu.Framework.Graphics;
|
2021-07-17 11:25:25 +00:00
|
|
|
using osu.Framework.Localisation;
|
2021-07-19 11:23:26 +00:00
|
|
|
using osu.Game.Localisation;
|
2021-05-19 17:28:26 +00:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2021-07-17 16:28:32 +00:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2021-04-19 09:24:47 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Wiki
|
|
|
|
{
|
|
|
|
public class WikiHeader : BreadcrumbControlOverlayHeader
|
|
|
|
{
|
2021-05-19 17:28:26 +00:00
|
|
|
private const string index_path = "Main_Page";
|
2021-07-18 01:55:40 +00:00
|
|
|
|
|
|
|
public static LocalisableString IndexPageString => LayoutStrings.HeaderHelpIndex;
|
2021-05-19 17:28:26 +00:00
|
|
|
|
2021-05-20 07:00:22 +00:00
|
|
|
public readonly Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
|
|
|
|
|
|
|
|
public Action ShowIndexPage;
|
|
|
|
public Action ShowParentPage;
|
2021-04-19 09:24:47 +00:00
|
|
|
|
|
|
|
public WikiHeader()
|
|
|
|
{
|
2021-07-17 11:25:25 +00:00
|
|
|
TabControl.AddItem(IndexPageString);
|
|
|
|
Current.Value = IndexPageString;
|
2021-05-19 17:28:26 +00:00
|
|
|
|
|
|
|
WikiPageData.BindValueChanged(onWikiPageChange);
|
2021-05-20 07:00:22 +00:00
|
|
|
Current.BindValueChanged(onCurrentChange);
|
2021-05-19 17:28:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onWikiPageChange(ValueChangedEvent<APIWikiPage> e)
|
|
|
|
{
|
|
|
|
if (e.NewValue == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TabControl.Clear();
|
2021-07-19 23:36:04 +00:00
|
|
|
Current.Value = null;
|
2021-05-19 17:28:26 +00:00
|
|
|
|
2021-07-17 11:25:25 +00:00
|
|
|
TabControl.AddItem(IndexPageString);
|
2021-05-19 17:28:26 +00:00
|
|
|
|
|
|
|
if (e.NewValue.Path == index_path)
|
|
|
|
{
|
2021-07-17 11:25:25 +00:00
|
|
|
Current.Value = IndexPageString;
|
2021-05-19 17:28:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e.NewValue.Subtitle != null)
|
|
|
|
TabControl.AddItem(e.NewValue.Subtitle);
|
|
|
|
|
|
|
|
TabControl.AddItem(e.NewValue.Title);
|
|
|
|
Current.Value = e.NewValue.Title;
|
2021-04-19 09:24:47 +00:00
|
|
|
}
|
|
|
|
|
2021-07-17 12:33:26 +00:00
|
|
|
private void onCurrentChange(ValueChangedEvent<LocalisableString?> e)
|
2021-05-20 07:00:22 +00:00
|
|
|
{
|
|
|
|
if (e.NewValue == TabControl.Items.LastOrDefault())
|
|
|
|
return;
|
|
|
|
|
2021-07-17 11:25:25 +00:00
|
|
|
if (e.NewValue == IndexPageString)
|
2021-05-20 07:00:22 +00:00
|
|
|
{
|
|
|
|
ShowIndexPage?.Invoke();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShowParentPage?.Invoke();
|
|
|
|
}
|
|
|
|
|
2021-04-19 09:24:47 +00:00
|
|
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/wiki");
|
|
|
|
|
|
|
|
protected override OverlayTitle CreateTitle() => new WikiHeaderTitle();
|
|
|
|
|
|
|
|
private class WikiHeaderTitle : OverlayTitle
|
|
|
|
{
|
|
|
|
public WikiHeaderTitle()
|
|
|
|
{
|
2021-08-03 07:34:21 +00:00
|
|
|
Title = PageTitleStrings.MainWikiControllerDefault;
|
2021-07-19 11:23:26 +00:00
|
|
|
Description = NamedOverlayComponentStrings.WikiDescription;
|
2021-04-19 09:24:47 +00:00
|
|
|
IconTexture = "Icons/Hexacons/wiki";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|