1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-07 22:22:59 +08:00

Add more comprehensive certification flow (and remove "difficulty" terminology)

This commit is contained in:
Dean Herbert 2022-06-07 22:52:24 +09:00
parent 0561e9cc75
commit c1ef59ab03

View File

@ -13,6 +13,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input; using osu.Framework.Input;
@ -24,6 +25,7 @@ using osu.Framework.Screens;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
using osuTK; using osuTK;
@ -66,11 +68,13 @@ namespace osu.Game.Screens
private const int rounds_to_complete = 5; private const int rounds_to_complete = 5;
private const int rounds_to_complete_certified = 20;
private int round; private int round;
private int correctCount; private int correctCount;
private int targetRoundCount = rounds_to_complete; private int targetRoundCount = rounds_to_complete;
private int difficulty = 1; private int difficultyLevel = 1;
private double lastPoll; private double lastPoll;
private int pollingMax; private int pollingMax;
@ -124,6 +128,10 @@ Use the Tab key to change focus.
Do whatever you need to try and perceive the difference in latency, then choose your best side. Do whatever you need to try and perceive the difference in latency, then choose your best side.
", ",
}, },
resultsArea = new Container
{
RelativeSizeAxes = Axes.Both,
},
statusText = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 40)) statusText = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 40))
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
@ -133,10 +141,6 @@ Do whatever you need to try and perceive the difference in latency, then choose
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
}, },
resultsArea = new Container
{
RelativeSizeAxes = Axes.Both,
},
}; };
} }
@ -206,20 +210,20 @@ Do whatever you need to try and perceive the difference in latency, then choose
private void loadNextRound() private void loadNextRound()
{ {
round++; round++;
statusText.Text = $"Difficulty {difficulty}\nRound {round} of {targetRoundCount}"; statusText.Text = $"Level {difficultyLevel}\nRound {round} of {targetRoundCount}";
mainArea.Clear(); mainArea.Clear();
int betterSide = RNG.Next(0, 2); int betterSide = RNG.Next(0, 2);
mainArea.Add(new LatencyArea(Key.Number1, betterSide == 1 ? mapDifficultyToTargetFrameRate(difficulty) : 0) mainArea.Add(new LatencyArea(Key.Number1, betterSide == 1 ? mapDifficultyToTargetFrameRate(difficultyLevel) : 0)
{ {
Width = 0.5f, Width = 0.5f,
ReportBetter = () => recordResult(betterSide == 0), ReportBetter = () => recordResult(betterSide == 0),
IsActiveArea = { Value = true } IsActiveArea = { Value = true }
}); });
mainArea.Add(new LatencyArea(Key.Number2, betterSide == 0 ? mapDifficultyToTargetFrameRate(difficulty) : 0) mainArea.Add(new LatencyArea(Key.Number2, betterSide == 0 ? mapDifficultyToTargetFrameRate(difficultyLevel) : 0)
{ {
Width = 0.5f, Width = 0.5f,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
@ -251,10 +255,10 @@ Do whatever you need to try and perceive the difference in latency, then choose
statusText.Clear(); statusText.Clear();
float successRate = (float)correctCount / targetRoundCount; float successRate = (float)correctCount / targetRoundCount;
bool isPass = successRate > 0.8f; bool isPass = successRate == 1;
statusText.AddParagraph($"You scored {correctCount} out of {targetRoundCount} ({successRate:0%})!", cp => cp.Colour = isPass ? colours.Green : colours.Red); statusText.AddParagraph($"You scored {correctCount} out of {targetRoundCount} ({successRate:0%})!", cp => cp.Colour = isPass ? colours.Green : colours.Red);
statusText.AddParagraph($"Level {difficulty} ({mapDifficultyToTargetFrameRate(difficulty):N0} hz)", statusText.AddParagraph($"Level {difficultyLevel} ({mapDifficultyToTargetFrameRate(difficultyLevel):N0} hz)",
cp => cp.Font = OsuFont.Default.With(size: 24)); cp => cp.Font = OsuFont.Default.With(size: 24));
statusText.AddParagraph(string.Empty); statusText.AddParagraph(string.Empty);
@ -262,6 +266,12 @@ Do whatever you need to try and perceive the difference in latency, then choose
statusText.AddIcon(isPass ? FontAwesome.Regular.CheckCircle : FontAwesome.Regular.TimesCircle, cp => cp.Colour = isPass ? colours.Green : colours.Red); statusText.AddIcon(isPass ? FontAwesome.Regular.CheckCircle : FontAwesome.Regular.TimesCircle, cp => cp.Colour = isPass ? colours.Green : colours.Red);
statusText.AddParagraph(string.Empty); statusText.AddParagraph(string.Empty);
if (!isPass && difficultyLevel > 1)
{
statusText.AddParagraph("To complete certification, decrease the difficulty level until you can get 20 tests correct in a row!", cp => cp.Font = OsuFont.Default.With(size: 24));
statusText.AddParagraph(string.Empty);
}
statusText.AddParagraph($"Polling: {pollingMax} hz Monitor: {displayMode.RefreshRate:N0} hz Exclusive: {exclusive}", cp => cp.Font = OsuFont.Default.With(size: 15)); statusText.AddParagraph($"Polling: {pollingMax} hz Monitor: {displayMode.RefreshRate:N0} hz Exclusive: {exclusive}", cp => cp.Font = OsuFont.Default.With(size: 15));
statusText.AddParagraph($"Input: {host.InputThread.Clock.FramesPerSecond} hz " statusText.AddParagraph($"Input: {host.InputThread.Clock.FramesPerSecond} hz "
@ -269,13 +279,55 @@ Do whatever you need to try and perceive the difference in latency, then choose
+ $"Draw: {host.DrawThread.Clock.FramesPerSecond} hz" + $"Draw: {host.DrawThread.Clock.FramesPerSecond} hz"
, cp => cp.Font = OsuFont.Default.With(size: 15)); , cp => cp.Font = OsuFont.Default.With(size: 15));
int certificationRemaining = !isPass ? rounds_to_complete_certified : rounds_to_complete_certified - correctCount;
if (isPass && certificationRemaining <= 0)
{
Drawable background;
Drawable certifiedText;
resultsArea.AddRange(new[]
{
background = new Box
{
Colour = overlayColourProvider.Background4,
RelativeSizeAxes = Axes.Both,
},
(certifiedText = new OsuSpriteText
{
Alpha = 0,
Font = OsuFont.TorusAlternate.With(size: 80, weight: FontWeight.Bold),
Text = "Certified!",
Blending = BlendingParameters.Additive,
}).WithEffect(new GlowEffect
{
Colour = overlayColourProvider.Colour1,
}).With(e =>
{
e.Anchor = Anchor.Centre;
e.Origin = Anchor.Centre;
})
});
background.FadeInFromZero(1000, Easing.OutQuint);
certifiedText.FadeInFromZero(500, Easing.InQuint);
certifiedText
.ScaleTo(10)
.ScaleTo(1, 600, Easing.InQuad)
.Then()
.ScaleTo(1.05f, 10000, Easing.OutQuint);
return;
}
string cannotIncreaseReason = string.Empty; string cannotIncreaseReason = string.Empty;
if (!isPass) if (!isPass)
cannotIncreaseReason = "You didn't score high enough (over 80% required)!"; cannotIncreaseReason = "You didn't get a perfect score.";
else if (mapDifficultyToTargetFrameRate(difficulty + 1) > target_host_update_frames) else if (mapDifficultyToTargetFrameRate(difficultyLevel + 1) > target_host_update_frames)
cannotIncreaseReason = "You've reached the limits of this comparison mode."; cannotIncreaseReason = "You've reached the limits of this comparison mode.";
else if (mapDifficultyToTargetFrameRate(difficulty + 1) > Clock.FramesPerSecond) else if (mapDifficultyToTargetFrameRate(difficultyLevel + 1) > Clock.FramesPerSecond)
cannotIncreaseReason = "Game is not running fast enough to test this level"; cannotIncreaseReason = "Game is not running fast enough to test this level";
resultsArea.Add(new FillFlowContainer resultsArea.Add(new FillFlowContainer
@ -288,9 +340,27 @@ Do whatever you need to try and perceive the difference in latency, then choose
Padding = new MarginPadding(20), Padding = new MarginPadding(20),
Children = new Drawable[] Children = new Drawable[]
{ {
new Button(Key.Enter)
{
Text = "Continue to next level",
BackgroundColour = colours.Red2,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Action = () => changeDifficulty(difficultyLevel + 1),
Enabled = { Value = string.IsNullOrEmpty(cannotIncreaseReason) },
TooltipText = cannotIncreaseReason
},
new Button(Key.D)
{
Text = difficultyLevel == 1 ? "Retry" : "Return to last level",
BackgroundColour = colours.Green,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Action = () => changeDifficulty(Math.Max(difficultyLevel - 1, 1)),
},
new Button(Key.R) new Button(Key.R)
{ {
Text = "Increase confidence at current level", Text = $"Continue towards certification at this level ({certificationRemaining} more)",
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Action = () => Action = () =>
@ -299,27 +369,9 @@ Do whatever you need to try and perceive the difference in latency, then choose
targetRoundCount += rounds_to_complete; targetRoundCount += rounds_to_complete;
loadNextRound(); loadNextRound();
}, },
TooltipText = isPass ? "The longer you chain, the more sure you will be!" : "You've reached your limits", TooltipText = isPass ? $"Chain {rounds_to_complete_certified} to confirm your perception!" : "You've reached your limits. Go to the previous level to complete certification!",
Enabled = { Value = string.IsNullOrEmpty(cannotIncreaseReason) }, Enabled = { Value = isPass },
}, },
new Button(Key.I)
{
Text = "Increase difficulty",
BackgroundColour = colours.Red2,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Action = () => changeDifficulty(difficulty + 1),
Enabled = { Value = string.IsNullOrEmpty(cannotIncreaseReason) },
TooltipText = cannotIncreaseReason
},
new Button(Key.D)
{
Text = difficulty == 1 ? "Restart" : "Decrease difficulty",
BackgroundColour = colours.Green,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Action = () => changeDifficulty(Math.Max(difficulty - 1, 1)),
}
} }
}); });
} }
@ -336,7 +388,7 @@ Do whatever you need to try and perceive the difference in latency, then choose
lastPoll = 0; lastPoll = 0;
targetRoundCount = rounds_to_complete; targetRoundCount = rounds_to_complete;
difficulty = diff; difficultyLevel = diff;
loadNextRound(); loadNextRound();
} }