1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

Add retry button and hotkey support to results screen (#6691)

Add retry button and hotkey support to results screen

Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
Dean Herbert 2019-11-02 21:41:00 +09:00 committed by GitHub
commit cacb036c79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 91 additions and 14 deletions

View File

@ -8,7 +8,6 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets.Osu;
using osu.Game.Scoring;
using osu.Game.Users;
using osuTK;
using System;
using System.Collections.Generic;
using osu.Game.Screens.Ranking.Pages;
@ -42,7 +41,6 @@ namespace osu.Game.Tests.Visual.Gameplay
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(80, 40),
};
});
}

View File

@ -22,10 +22,10 @@ namespace osu.Game.Tests.Visual.Gameplay
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ScoreInfo),
typeof(Results),
typeof(ResultsPage),
typeof(ScoreResultsPage),
typeof(RetryButton),
typeof(ReplayDownloadButton),
typeof(LocalLeaderboardPage)
};

View File

@ -30,6 +30,7 @@ using osu.Game.Users;
namespace osu.Game.Screens.Play
{
[Cached]
public class Player : ScreenWithBeatmapBackground
{
public override bool AllowBackButton => false; // handled by HoldForMenuButton
@ -311,14 +312,19 @@ namespace osu.Game.Screens.Play
this.Exit();
}
/// <summary>
/// Restart gameplay via a parent <see cref="PlayerLoader"/>.
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
/// </summary>
public void Restart()
{
if (!this.IsCurrentScreen()) return;
sampleRestart?.Play();
RestartRequested?.Invoke();
performImmediateExit();
if (this.IsCurrentScreen())
performImmediateExit();
else
this.MakeCurrent();
}
private ScheduledDelegate completionProgressDelegate;

View File

@ -8,6 +8,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring;
using osuTK;
namespace osu.Game.Screens.Ranking.Pages
{
@ -33,6 +34,7 @@ namespace osu.Game.Screens.Ranking.Pages
public ReplayDownloadButton(ScoreInfo score)
: base(score)
{
Size = new Vector2(50, 30);
}
[BackgroundDependencyLoader(true)]

View File

@ -0,0 +1,54 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play;
using osuTK;
namespace osu.Game.Screens.Ranking.Pages
{
public class RetryButton : OsuAnimatedButton
{
private readonly Box background;
[Resolved(canBeNull: true)]
private Player player { get; set; }
public RetryButton()
{
Size = new Vector2(50, 30);
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue
},
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(13),
Icon = FontAwesome.Solid.ArrowCircleLeft,
},
};
TooltipText = "Retry";
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.Green;
if (player != null)
Action = () => player.Restart();
}
}
}

View File

@ -169,12 +169,19 @@ namespace osu.Game.Screens.Ranking.Pages
},
},
},
new ReplayDownloadButton(score)
new FillFlowContainer
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Margin = new MarginPadding { Bottom = 10 },
Size = new Vector2(50, 30),
Spacing = new Vector2(5),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new ReplayDownloadButton(score),
new RetryButton()
}
},
};

View File

@ -19,6 +19,7 @@ using osu.Game.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
namespace osu.Game.Screens.Ranking
{
@ -34,6 +35,9 @@ namespace osu.Game.Screens.Ranking
private ResultModeTabControl modeChangeButtons;
[Resolved(canBeNull: true)]
private Player player { get; set; }
public override bool DisallowExternalBeatmapRulesetChanges => true;
protected readonly ScoreInfo Score;
@ -100,10 +104,7 @@ namespace osu.Game.Screens.Ranking
public override bool OnExiting(IScreen next)
{
allCircles.ForEach(c =>
{
c.ScaleTo(0, transition_time, Easing.OutSine);
});
allCircles.ForEach(c => c.ScaleTo(0, transition_time, Easing.OutSine));
Background.ScaleTo(1f, transition_time / 4, Easing.OutQuint);
@ -253,7 +254,16 @@ namespace osu.Game.Screens.Ranking
}
}
}
}
},
new HotkeyRetryOverlay
{
Action = () =>
{
if (!this.IsCurrentScreen()) return;
player?.Restart();
},
},
};
var pages = CreateResultPages();