1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-28 17:43:12 +08:00

Merge branch 'master' into argon-pro-skin-hide-highest-judgement

This commit is contained in:
Bartłomiej Dach 2022-12-24 09:41:18 +01:00
commit 75ddeaeeb8
No known key found for this signature in database
3 changed files with 31 additions and 7 deletions

View File

@ -4,8 +4,11 @@
#nullable disable #nullable disable
using System; using System;
using System.Linq;
using System.Net; using System.Net;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -29,6 +32,15 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Show main page", () => wiki.Show()); 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] [Test]
public void TestArticlePage() public void TestArticlePage()
{ {
@ -56,7 +68,9 @@ namespace osu.Game.Tests.Visual.Online
public void TestErrorPage() public void TestErrorPage()
{ {
setUpWikiResponse(responseArticlePage); 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) private void setUpWikiResponse(APIWikiPage r, string redirectionPath = null)

View File

@ -52,8 +52,8 @@ namespace osu.Game.Graphics.UserInterface
public readonly SpriteIcon Chevron; public readonly SpriteIcon Chevron;
//don't allow clicking between transitions and don't make the chevron clickable //don't allow clicking between transitions
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Alpha == 1f && Text.ReceivePositionalInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Alpha == 1f && base.ReceivePositionalInputAt(screenSpacePos);
public override bool HandleNonPositionalInput => State == Visibility.Visible; public override bool HandleNonPositionalInput => State == Visibility.Visible;
public override bool HandlePositionalInput => 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.Font = Text.Font.With(size: 18);
Text.Margin = new MarginPadding { Vertical = 8 }; Text.Margin = new MarginPadding { Vertical = 8 };
Padding = new MarginPadding { Right = padding + ChevronSize }; Margin = new MarginPadding { Right = padding + ChevronSize };
Add(Chevron = new SpriteIcon Add(Chevron = new SpriteIcon
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,

View File

@ -21,6 +21,8 @@ namespace osu.Game.Overlays
{ {
private const string index_path = @"main_page"; 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<string> path = new Bindable<string>(index_path);
private readonly Bindable<APIWikiPage> wikiData = new Bindable<APIWikiPage>(); private readonly Bindable<APIWikiPage> wikiData = new Bindable<APIWikiPage>();
@ -105,6 +107,9 @@ namespace osu.Game.Overlays
if (e.NewValue == wikiData.Value?.Path) if (e.NewValue == wikiData.Value?.Path)
return; return;
if (e.NewValue == "error")
return;
cancellationToken?.Cancel(); cancellationToken?.Cancel();
request?.Cancel(); request?.Cancel();
@ -118,7 +123,11 @@ namespace osu.Game.Overlays
Loading.Show(); Loading.Show();
request.Success += response => Schedule(() => onSuccess(response)); 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); 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/", 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() private void showParentPage()