1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-03 06:09:54 +08:00
Files
osu-lazer/osu.Game.Tests/Visual/RankedPlay/TestSceneRankedPlayUserDisplay.cs
T
Krzysztof Gutkowski 9a56aed1e9 Add current stage overlay to ranked play (#37202)
Displays the stage name and details like currently picking player
and damage multiplayer where applicable.

Currently only shown on the discard and pick stages.

# Move user retrieval to `RankedPlayScreen`

This is done because I need the relevant `APIUser` instances in order to
pass them to the overlay component. `RankedPlayScreen` seems like the
appropriate place to manage the overlays since it manages the stage
subscreens, hence the need to access the `APIUser`s in here.

# Add current stage overlay to ranked play

The actual change of this PR. Very much a dev design.


https://github.com/user-attachments/assets/2388e934-2fc7-4e15-9947-9f98412765d2

---------

Co-authored-by: Dean Herbert <pe@ppy.sh>
2026-04-06 03:00:58 +09:00

85 lines
3.3 KiB
C#

// 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 NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Online.Rooms;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay;
using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components;
using osu.Game.Tests.Visual.Multiplayer;
using osuTK;
namespace osu.Game.Tests.Visual.RankedPlay
{
public partial class TestSceneRankedPlayUserDisplay : MultiplayerTestScene
{
private readonly BindableInt health = new BindableInt
{
MaxValue = 1_000_000,
MinValue = 0,
Value = 1_000_000,
};
public TestSceneRankedPlayUserDisplay()
{
AddSliderStep("health", 0, 1_000_000, 1_000_000, value => health.Value = value);
}
public override void SetUpSteps()
{
base.SetUpSteps();
AddStep("join room", () => JoinRoom(CreateDefaultRoom(MatchType.RankedPlay)));
WaitForJoined();
AddStep("add display", () => Child = new RankedPlayUserDisplay(new APIUser { Id = 1001, Username = "User 1001" }, Anchor.BottomLeft, RankedPlayColourScheme.Blue)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(256, 72),
Health = { BindTarget = health }
});
}
[Test]
public void TesUserDisplay()
{
AddStep("blue color scheme", () => Child = new RankedPlayUserDisplay(new APIUser { Id = 1001, Username = "User 1001" }, Anchor.BottomLeft, RankedPlayColourScheme.Blue)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(256, 72),
Health = { BindTarget = health }
});
AddStep("red color scheme", () => Child = new RankedPlayUserDisplay(new APIUser { Id = 1001, Username = "User 1001" }, Anchor.BottomLeft, RankedPlayColourScheme.Red)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(256, 72),
Health = { BindTarget = health }
});
}
[Test]
public void TestBeatmapState()
{
float progress = 0;
AddStep("set unavailable", () => MultiplayerClient.ChangeBeatmapAvailability(BeatmapAvailability.NotDownloaded()));
AddStep("set downloading", () => MultiplayerClient.ChangeBeatmapAvailability(BeatmapAvailability.Downloading(progress = 0)));
AddUntilStep("increment progress", () =>
{
progress += RNG.NextSingle(0.1f);
MultiplayerClient.ChangeBeatmapAvailability(BeatmapAvailability.Downloading(progress));
return progress >= 1;
});
AddStep("set to importing", () => MultiplayerClient.ChangeBeatmapAvailability(BeatmapAvailability.Importing()));
AddStep("set to available", () => MultiplayerClient.ChangeBeatmapAvailability(BeatmapAvailability.LocallyAvailable()));
}
}
}