mirror of
https://github.com/ppy/osu
synced 2024-12-18 21:06:38 +00:00
Merge branch 'master' into argon-pro-skin-hide-highest-judgement
This commit is contained in:
commit
75ddeaeeb8
@ -4,8 +4,11 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
@ -29,6 +32,15 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Show main page", () => wiki.Show());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCancellationDoesntShowError()
|
||||
{
|
||||
AddStep("Show main page", () => wiki.Show());
|
||||
AddStep("Show another page", () => wiki.ShowPage("Article_styling_criteria/Formatting"));
|
||||
|
||||
AddUntilStep("Current path is not error", () => wiki.CurrentPath != "error");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestArticlePage()
|
||||
{
|
||||
@ -56,7 +68,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
public void TestErrorPage()
|
||||
{
|
||||
setUpWikiResponse(responseArticlePage);
|
||||
AddStep("Show Error Page", () => wiki.ShowPage("Error"));
|
||||
AddStep("Show nonexistent page", () => wiki.ShowPage("This_page_will_error_out"));
|
||||
AddUntilStep("Wait for error page", () => wiki.CurrentPath == "error");
|
||||
AddUntilStep("Error message correct", () => wiki.ChildrenOfType<SpriteText>().Any(text => text.Text == "\"This_page_will_error_out\"."));
|
||||
}
|
||||
|
||||
private void setUpWikiResponse(APIWikiPage r, string redirectionPath = null)
|
||||
|
@ -52,8 +52,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public readonly SpriteIcon Chevron;
|
||||
|
||||
//don't allow clicking between transitions and don't make the chevron clickable
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Alpha == 1f && Text.ReceivePositionalInputAt(screenSpacePos);
|
||||
//don't allow clicking between transitions
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Alpha == 1f && base.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
public override bool HandleNonPositionalInput => State == Visibility.Visible;
|
||||
public override bool HandlePositionalInput => State == Visibility.Visible;
|
||||
@ -95,7 +95,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Text.Font = Text.Font.With(size: 18);
|
||||
Text.Margin = new MarginPadding { Vertical = 8 };
|
||||
Padding = new MarginPadding { Right = padding + ChevronSize };
|
||||
Margin = new MarginPadding { Right = padding + ChevronSize };
|
||||
Add(Chevron = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
|
@ -21,6 +21,8 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
private const string index_path = @"main_page";
|
||||
|
||||
public string CurrentPath => path.Value;
|
||||
|
||||
private readonly Bindable<string> path = new Bindable<string>(index_path);
|
||||
|
||||
private readonly Bindable<APIWikiPage> wikiData = new Bindable<APIWikiPage>();
|
||||
@ -105,6 +107,9 @@ namespace osu.Game.Overlays
|
||||
if (e.NewValue == wikiData.Value?.Path)
|
||||
return;
|
||||
|
||||
if (e.NewValue == "error")
|
||||
return;
|
||||
|
||||
cancellationToken?.Cancel();
|
||||
request?.Cancel();
|
||||
|
||||
@ -118,7 +123,11 @@ namespace osu.Game.Overlays
|
||||
Loading.Show();
|
||||
|
||||
request.Success += response => Schedule(() => onSuccess(response));
|
||||
request.Failure += _ => Schedule(onFail);
|
||||
request.Failure += ex =>
|
||||
{
|
||||
if (ex is not OperationCanceledException)
|
||||
Schedule(onFail, request.Path);
|
||||
};
|
||||
|
||||
api.PerformAsync(request);
|
||||
}
|
||||
@ -146,10 +155,11 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
|
||||
private void onFail()
|
||||
private void onFail(string originalPath)
|
||||
{
|
||||
path.Value = "error";
|
||||
LoadDisplay(articlePage = new WikiArticlePage($@"{api.WebsiteRootUrl}/wiki/",
|
||||
$"Something went wrong when trying to fetch page \"{path.Value}\".\n\n[Return to the main page](Main_Page)."));
|
||||
$"Something went wrong when trying to fetch page \"{originalPath}\".\n\n[Return to the main page](Main_Page)."));
|
||||
}
|
||||
|
||||
private void showParentPage()
|
||||
|
Loading…
Reference in New Issue
Block a user