55
66using System ;
77using System . Linq ;
8+ using JetBrains . Annotations ;
9+ using osu . Framework . Allocation ;
810using osu . Framework . Bindables ;
911using osu . Framework . Graphics ;
12+ using osu . Framework . Graphics . Containers ;
13+ using osu . Framework . Graphics . Sprites ;
1014using osu . Framework . Localisation ;
1115using osu . Game . Graphics ;
16+ using osu . Game . Graphics . UserInterfaceV2 ;
1217using osu . Game . Localisation ;
18+ using osu . Game . Online ;
1319using osu . Game . Online . API . Requests . Responses ;
1420using osu . Game . Resources . Localisation . Web ;
21+ using osuTK ;
1522
1623namespace osu . Game . Overlays . Wiki
1724{
1825public partial class WikiHeader : BreadcrumbControlOverlayHeader
1926{
2027public static LocalisableString IndexPageString => LayoutStrings . HeaderHelpIndex ;
2128
29+ private const string github_wiki_base = @"https://github.com/ppy/osu-wiki/blob/master/wiki" ;
30+
2231public readonly Bindable < APIWikiPage > WikiPageData = new Bindable < APIWikiPage > ( ) ;
2332
2433public Action ShowIndexPage ;
2534public Action ShowParentPage ;
2635
36+ private readonly Bindable < string > githubPath = new Bindable < string > ( ) ;
37+
2738public WikiHeader ( )
2839{
2940TabControl . AddItem ( IndexPageString ) ;
@@ -35,13 +46,17 @@ public WikiHeader()
3546
3647private void onWikiPageChange ( ValueChangedEvent < APIWikiPage > e )
3748{
49+ // Clear the path beforehand in case we got an error page.
50+ githubPath . Value = null ;
51+
3852if ( e . NewValue == null )
3953return ;
4054
4155TabControl . Clear ( ) ;
4256Current . Value = null ;
4357
4458TabControl . AddItem ( IndexPageString ) ;
59+ githubPath . Value = $ "{ github_wiki_base } /{ e . NewValue . Path } /{ e . NewValue . Locale } .md";
4560
4661if ( e . NewValue . Path == WikiOverlay . INDEX_PATH )
4762{
@@ -56,6 +71,27 @@ private void onWikiPageChange(ValueChangedEvent<APIWikiPage> e)
5671Current . Value = e . NewValue . Title ;
5772}
5873
74+ protected override Drawable CreateTabControlContent ( )
75+ {
76+ return new FillFlowContainer
77+ {
78+ Height = 40 ,
79+ AutoSizeAxes = Axes . X ,
80+ Direction = FillDirection . Horizontal ,
81+ Spacing = new Vector2 ( 5 ) ,
82+ Children = new Drawable [ ]
83+ {
84+ new ShowOnGitHubButton
85+ {
86+ Anchor = Anchor . CentreRight ,
87+ Origin = Anchor . CentreRight ,
88+ Size = new Vector2 ( 32 ) ,
89+ TargetPath = { BindTarget = githubPath } ,
90+ } ,
91+ } ,
92+ } ;
93+ }
94+
5995private void onCurrentChange ( ValueChangedEvent < LocalisableString ? > e )
6096{
6197if ( e . NewValue == TabControl . Items . LastOrDefault ( ) )
@@ -83,5 +119,39 @@ public WikiHeaderTitle()
83119Icon = OsuIcon . Wiki ;
84120}
85121}
122+
123+ private partial class ShowOnGitHubButton : RoundedButton
124+ {
125+ public override LocalisableString TooltipText => WikiStrings . ShowEditLink ;
126+
127+ public readonly Bindable < string > TargetPath = new Bindable < string > ( ) ;
128+
129+ [ BackgroundDependencyLoader ( true ) ]
130+ private void load ( [ CanBeNull ] ILinkHandler linkHandler )
131+ {
132+ Width = 42 ;
133+
134+ Add ( new SpriteIcon
135+ {
136+ Size = new Vector2 ( 12 ) ,
137+ Anchor = Anchor . Centre ,
138+ Origin = Anchor . Centre ,
139+ Icon = FontAwesome . Brands . Github ,
140+ } ) ;
141+
142+ Action = ( ) => linkHandler ? . HandleLink ( TargetPath . Value ) ;
143+ }
144+
145+ protected override void LoadComplete ( )
146+ {
147+ base . LoadComplete ( ) ;
148+
149+ TargetPath . BindValueChanged ( e=>
150+ {
151+ this . FadeTo ( e . NewValue != null ? 1 : 0 ) ;
152+ Enabled . Value = e . NewValue != null ;
153+ } , true ) ;
154+ }
155+ }
86156}
87157}