mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:02:55 +08:00
Add basic spectator screen
This commit is contained in:
parent
df5348cd93
commit
5fd97bd043
20
osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs
Normal file
20
osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.Game.Screens.Play;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneSpectator : ScreenTestScene
|
||||
{
|
||||
private readonly User user = new User { Id = 1234, Username = "Test user" };
|
||||
|
||||
[Test]
|
||||
public void TestSpectating()
|
||||
{
|
||||
AddStep("load screen", () => LoadScreen(new Spectator(user)));
|
||||
}
|
||||
}
|
||||
}
|
36
osu.Game/Screens/Play/Spectator.cs
Normal file
36
osu.Game/Screens/Play/Spectator.cs
Normal file
@ -0,0 +1,36 @@
|
||||
// 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 System;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class Spectator : OsuScreen
|
||||
{
|
||||
private readonly User targetUser;
|
||||
|
||||
public Spectator([NotNull] User targetUser)
|
||||
{
|
||||
this.targetUser = targetUser ?? throw new ArgumentNullException(nameof(targetUser));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = $"Watching {targetUser}",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user