1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-20 00:20:21 +08:00
Files
osu-lazer/osu.Game.Tests/Visual/RankedPlay/TestSceneRankedPlayUserDisplay.cs
T
Dan Balasescu a22c2eaadf Add small indicator for last stand (#37747)
This is _very_ uninspired. Although there are proposals for how this
could be displayed, I'm purposefully taking the easy path here to not
lock into a particular behaviour for this mechanic.


https://github.com/user-attachments/assets/e37a62ea-118a-4cbe-bcc1-2ba93f17972c
2026-05-15 09:38:36 +02:00

95 lines
3.5 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()));
}
[Test]
public void TestLastStand()
{
AddStep("active last stand", () =>
{
health.Value = 1_000_000;
health.Value = 1;
});
}
}
}