Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/osuPublic

Commit89b443b

Browse files
CloneWithbdach
andauthored
Add GitHub link button to the wiki overlay header (#35595)
* Add Github link button to wiki overlay header* Localize jump link string* Mark ILinkHandler dependency as nullable* Make the button actually look like it does on the website* Use existing web string instead of inventing a new one* Bind value change callback more reliably---------Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
1 parentbe91708 commit89b443b

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

‎osu.Game/Overlays/Wiki/WikiHeader.cs‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,36 @@
55

66
usingSystem;
77
usingSystem.Linq;
8+
usingJetBrains.Annotations;
9+
usingosu.Framework.Allocation;
810
usingosu.Framework.Bindables;
911
usingosu.Framework.Graphics;
12+
usingosu.Framework.Graphics.Containers;
13+
usingosu.Framework.Graphics.Sprites;
1014
usingosu.Framework.Localisation;
1115
usingosu.Game.Graphics;
16+
usingosu.Game.Graphics.UserInterfaceV2;
1217
usingosu.Game.Localisation;
18+
usingosu.Game.Online;
1319
usingosu.Game.Online.API.Requests.Responses;
1420
usingosu.Game.Resources.Localisation.Web;
21+
usingosuTK;
1522

1623
namespaceosu.Game.Overlays.Wiki
1724
{
1825
publicpartialclassWikiHeader:BreadcrumbControlOverlayHeader
1926
{
2027
publicstaticLocalisableStringIndexPageString=>LayoutStrings.HeaderHelpIndex;
2128

29+
privateconststringgithub_wiki_base=@"https://github.com/ppy/osu-wiki/blob/master/wiki";
30+
2231
publicreadonlyBindable<APIWikiPage>WikiPageData=newBindable<APIWikiPage>();
2332

2433
publicActionShowIndexPage;
2534
publicActionShowParentPage;
2635

36+
privatereadonlyBindable<string>githubPath=newBindable<string>();
37+
2738
publicWikiHeader()
2839
{
2940
TabControl.AddItem(IndexPageString);
@@ -35,13 +46,17 @@ public WikiHeader()
3546

3647
privatevoidonWikiPageChange(ValueChangedEvent<APIWikiPage>e)
3748
{
49+
// Clear the path beforehand in case we got an error page.
50+
githubPath.Value=null;
51+
3852
if(e.NewValue==null)
3953
return;
4054

4155
TabControl.Clear();
4256
Current.Value=null;
4357

4458
TabControl.AddItem(IndexPageString);
59+
githubPath.Value=$"{github_wiki_base}/{e.NewValue.Path}/{e.NewValue.Locale}.md";
4560

4661
if(e.NewValue.Path==WikiOverlay.INDEX_PATH)
4762
{
@@ -56,6 +71,27 @@ private void onWikiPageChange(ValueChangedEvent<APIWikiPage> e)
5671
Current.Value=e.NewValue.Title;
5772
}
5873

74+
protectedoverrideDrawableCreateTabControlContent()
75+
{
76+
returnnewFillFlowContainer
77+
{
78+
Height=40,
79+
AutoSizeAxes=Axes.X,
80+
Direction=FillDirection.Horizontal,
81+
Spacing=newVector2(5),
82+
Children=newDrawable[]
83+
{
84+
newShowOnGitHubButton
85+
{
86+
Anchor=Anchor.CentreRight,
87+
Origin=Anchor.CentreRight,
88+
Size=newVector2(32),
89+
TargetPath={BindTarget=githubPath},
90+
},
91+
},
92+
};
93+
}
94+
5995
privatevoidonCurrentChange(ValueChangedEvent<LocalisableString?>e)
6096
{
6197
if(e.NewValue==TabControl.Items.LastOrDefault())
@@ -83,5 +119,39 @@ public WikiHeaderTitle()
83119
Icon=OsuIcon.Wiki;
84120
}
85121
}
122+
123+
privatepartialclassShowOnGitHubButton:RoundedButton
124+
{
125+
publicoverrideLocalisableStringTooltipText=>WikiStrings.ShowEditLink;
126+
127+
publicreadonlyBindable<string>TargetPath=newBindable<string>();
128+
129+
[BackgroundDependencyLoader(true)]
130+
privatevoidload([CanBeNull]ILinkHandlerlinkHandler)
131+
{
132+
Width=42;
133+
134+
Add(newSpriteIcon
135+
{
136+
Size=newVector2(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+
protectedoverridevoidLoadComplete()
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
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp