mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 04:02:59 +08:00
Merge spectator list classes into one skinnable
This commit is contained in:
parent
c8b38f05d5
commit
3c4bfc0a01
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||
return new DefaultSkinComponentsContainer(container =>
|
||||
{
|
||||
var keyCounter = container.OfType<LegacyKeyCounterDisplay>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SkinnableSpectatorList>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SpectatorList>().FirstOrDefault();
|
||||
|
||||
if (keyCounter != null)
|
||||
{
|
||||
@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new LegacyKeyCounterDisplay(),
|
||||
new SkinnableSpectatorList(),
|
||||
new SpectatorList(),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
|
||||
return new DefaultSkinComponentsContainer(container =>
|
||||
{
|
||||
var combo = container.ChildrenOfType<ArgonManiaComboCounter>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SkinnableSpectatorList>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SpectatorList>().FirstOrDefault();
|
||||
|
||||
if (combo != null)
|
||||
{
|
||||
@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
|
||||
})
|
||||
{
|
||||
new ArgonManiaComboCounter(),
|
||||
new SkinnableSpectatorList
|
||||
new SpectatorList
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
|
@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
return new DefaultSkinComponentsContainer(container =>
|
||||
{
|
||||
var combo = container.ChildrenOfType<LegacyManiaComboCounter>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SkinnableSpectatorList>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SpectatorList>().FirstOrDefault();
|
||||
|
||||
if (combo != null)
|
||||
{
|
||||
@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
})
|
||||
{
|
||||
new LegacyManiaComboCounter(),
|
||||
new SkinnableSpectatorList(),
|
||||
new SpectatorList(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
}
|
||||
|
||||
var combo = container.OfType<LegacyDefaultComboCounter>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SkinnableSpectatorList>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SpectatorList>().FirstOrDefault();
|
||||
|
||||
Vector2 pos = new Vector2();
|
||||
|
||||
@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
{
|
||||
new LegacyDefaultComboCounter(),
|
||||
new LegacyKeyCounterDisplay(),
|
||||
new SkinnableSpectatorList(),
|
||||
new SpectatorList(),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Binary file not shown.
@ -6,53 +6,74 @@ using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.Spectator;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Tests.Visual.Spectator;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
[TestFixture]
|
||||
public partial class TestSceneSpectatorList : OsuTestScene
|
||||
{
|
||||
private readonly BindableList<SpectatorUser> spectators = new BindableList<SpectatorUser>();
|
||||
private readonly Bindable<LocalUserPlayingState> localUserPlayingState = new Bindable<LocalUserPlayingState>();
|
||||
|
||||
private int counter;
|
||||
|
||||
[Test]
|
||||
public void TestBasics()
|
||||
{
|
||||
SpectatorList list = null!;
|
||||
AddStep("create spectator list", () => Child = list = new SpectatorList
|
||||
Bindable<LocalUserPlayingState> playingState = new Bindable<LocalUserPlayingState>();
|
||||
GameplayState gameplayState = new GameplayState(new Beatmap(), new OsuRuleset(), healthProcessor: new OsuHealthProcessor(0), localUserPlayingState: playingState);
|
||||
TestSpectatorClient client = new TestSpectatorClient();
|
||||
|
||||
AddStep("create spectator list", () =>
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
client,
|
||||
new DependencyProvidingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CachedDependencies =
|
||||
[
|
||||
(typeof(GameplayState), gameplayState),
|
||||
(typeof(SpectatorClient), client)
|
||||
],
|
||||
Child = list = new SpectatorList
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Spectators = { BindTarget = spectators },
|
||||
UserPlayingState = { BindTarget = localUserPlayingState }
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("start playing", () => localUserPlayingState.Value = LocalUserPlayingState.Playing);
|
||||
AddStep("start playing", () => playingState.Value = LocalUserPlayingState.Playing);
|
||||
|
||||
AddRepeatStep("add a user", () =>
|
||||
{
|
||||
int id = Interlocked.Increment(ref counter);
|
||||
spectators.Add(new SpectatorUser
|
||||
((ISpectatorClient)client).UserStartedWatching([
|
||||
new SpectatorUser
|
||||
{
|
||||
OnlineID = id,
|
||||
Username = $"User {id}"
|
||||
});
|
||||
}
|
||||
]);
|
||||
}, 10);
|
||||
|
||||
AddRepeatStep("remove random user", () => spectators.RemoveAt(RNG.Next(0, spectators.Count)), 5);
|
||||
AddRepeatStep("remove random user", () => ((ISpectatorClient)client).UserEndedWatching(client.WatchingUsers[RNG.Next(client.WatchingUsers.Count)].OnlineID), 5);
|
||||
|
||||
AddStep("change font to venera", () => list.Font.Value = Typeface.Venera);
|
||||
AddStep("change font to torus", () => list.Font.Value = Typeface.Torus);
|
||||
AddStep("change header colour", () => list.HeaderColour.Value = new Colour4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1));
|
||||
|
||||
AddStep("enter break", () => localUserPlayingState.Value = LocalUserPlayingState.Break);
|
||||
AddStep("stop playing", () => localUserPlayingState.Value = LocalUserPlayingState.NotPlaying);
|
||||
AddStep("enter break", () => playingState.Value = LocalUserPlayingState.Break);
|
||||
AddStep("stop playing", () => playingState.Value = LocalUserPlayingState.NotPlaying);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public partial class SpectatorList : CompositeDrawable
|
||||
public partial class SpectatorList : CompositeDrawable, ISerialisableDrawable
|
||||
{
|
||||
private const int max_spectators_displayed = 10;
|
||||
|
||||
@ -44,7 +44,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
private DrawablePool<SpectatorListEntry> pool = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OsuColour colours, SpectatorClient client, GameplayState gameplayState)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
@ -73,6 +73,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
};
|
||||
|
||||
HeaderColour.Value = Header.Colour;
|
||||
|
||||
((IBindableList<SpectatorUser>)Spectators).BindTo(client.WatchingUsers);
|
||||
((IBindable<LocalUserPlayingState>)UserPlayingState).BindTo(gameplayState.PlayingState);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -236,17 +239,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
linkCompiler.Enabled.Value = UserPlayingState.Value != LocalUserPlayingState.Playing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class SkinnableSpectatorList : SpectatorList, ISerialisableDrawable
|
||||
{
|
||||
public bool UsesFixedAnchor { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(SpectatorClient client, GameplayState gameplayState)
|
||||
{
|
||||
((IBindableList<SpectatorUser>)Spectators).BindTo(client.WatchingUsers);
|
||||
((IBindable<LocalUserPlayingState>)UserPlayingState).BindTo(gameplayState.PlayingState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ namespace osu.Game.Skinning
|
||||
return new DefaultSkinComponentsContainer(container =>
|
||||
{
|
||||
var comboCounter = container.OfType<ArgonComboCounter>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SkinnableSpectatorList>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SpectatorList>().FirstOrDefault();
|
||||
|
||||
Vector2 pos = new Vector2(36, -66);
|
||||
|
||||
@ -135,7 +135,7 @@ namespace osu.Game.Skinning
|
||||
Origin = Anchor.BottomLeft,
|
||||
Scale = new Vector2(1.3f),
|
||||
},
|
||||
new SkinnableSpectatorList
|
||||
new SpectatorList
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
|
@ -367,7 +367,7 @@ namespace osu.Game.Skinning
|
||||
return new DefaultSkinComponentsContainer(container =>
|
||||
{
|
||||
var combo = container.OfType<LegacyDefaultComboCounter>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SkinnableSpectatorList>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SpectatorList>().FirstOrDefault();
|
||||
|
||||
Vector2 pos = new Vector2();
|
||||
|
||||
@ -389,7 +389,7 @@ namespace osu.Game.Skinning
|
||||
})
|
||||
{
|
||||
new LegacyDefaultComboCounter(),
|
||||
new SkinnableSpectatorList(),
|
||||
new SpectatorList(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ namespace osu.Game.Skinning
|
||||
var ppCounter = container.OfType<PerformancePointsCounter>().FirstOrDefault();
|
||||
var songProgress = container.OfType<DefaultSongProgress>().FirstOrDefault();
|
||||
var keyCounter = container.OfType<DefaultKeyCounterDisplay>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SkinnableSpectatorList>().FirstOrDefault();
|
||||
var spectatorList = container.OfType<SpectatorList>().FirstOrDefault();
|
||||
|
||||
if (score != null)
|
||||
{
|
||||
@ -177,7 +177,7 @@ namespace osu.Game.Skinning
|
||||
new BarHitErrorMeter(),
|
||||
new BarHitErrorMeter(),
|
||||
new TrianglesPerformancePointsCounter(),
|
||||
new SkinnableSpectatorList(),
|
||||
new SpectatorList(),
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user