1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 15:12:57 +08:00

Disable retry hotkey overlay when viewing results from leaderbo… (#6702)

Disable retry hotkey overlay when viewing results from leaderboard
This commit is contained in:
Dean Herbert 2019-11-04 12:34:18 +09:00 committed by GitHub
commit eb1ec78b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 215 additions and 152 deletions

View File

@ -3,11 +3,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Game.Screens.Ranking.Pages; using osu.Game.Screens.Ranking.Pages;
@ -27,7 +32,8 @@ namespace osu.Game.Tests.Visual.Gameplay
typeof(ScoreResultsPage), typeof(ScoreResultsPage),
typeof(RetryButton), typeof(RetryButton),
typeof(ReplayDownloadButton), typeof(ReplayDownloadButton),
typeof(LocalLeaderboardPage) typeof(LocalLeaderboardPage),
typeof(TestPlayer)
}; };
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -43,8 +49,9 @@ namespace osu.Game.Tests.Visual.Gameplay
var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0); var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0);
if (beatmapInfo != null) if (beatmapInfo != null)
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo); Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
}
LoadScreen(new SoloResults(new ScoreInfo private TestSoloResults createResultsScreen() => new TestSoloResults(new ScoreInfo
{ {
TotalScore = 2845370, TotalScore = 2845370,
Accuracy = 0.98, Accuracy = 0.98,
@ -62,7 +69,62 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
Username = "peppy", Username = "peppy",
} }
})); });
[Test]
public void ResultsWithoutPlayer()
{
TestSoloResults screen = null;
AddStep("load results", () => Child = new OsuScreenStack(screen = createResultsScreen())
{
RelativeSizeAxes = Axes.Both
});
AddUntilStep("wait for loaded", () => screen.IsLoaded);
AddAssert("retry overlay not present", () => screen.RetryOverlay == null);
}
[Test]
public void ResultsWithPlayer()
{
TestSoloResults screen = null;
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
AddUntilStep("wait for loaded", () => screen.IsLoaded);
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
}
private class TestResultsContainer : Container
{
[Cached(typeof(Player))]
private readonly Player player = new TestPlayer();
public TestResultsContainer(IScreen screen)
{
RelativeSizeAxes = Axes.Both;
InternalChild = new OsuScreenStack(screen)
{
RelativeSizeAxes = Axes.Both,
};
}
}
private class TestSoloResults : SoloResults
{
public HotkeyRetryOverlay RetryOverlay;
public TestSoloResults(ScoreInfo score)
: base(score)
{
}
protected override void LoadComplete()
{
base.LoadComplete();
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
}
} }
} }
} }

View File

@ -116,9 +116,7 @@ namespace osu.Game.Screens.Ranking
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
InternalChildren = new Drawable[] InternalChild = new AspectContainer
{
new AspectContainer
{ {
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -254,8 +252,11 @@ namespace osu.Game.Screens.Ranking
} }
} }
} }
}, };
new HotkeyRetryOverlay
if (player != null)
{
AddInternal(new HotkeyRetryOverlay
{ {
Action = () => Action = () =>
{ {
@ -263,8 +264,8 @@ namespace osu.Game.Screens.Ranking
player?.Restart(); player?.Restart();
}, },
}, });
}; }
var pages = CreateResultPages(); var pages = CreateResultPages();