diff --git a/osu.Game.Tournament.Tests/TestCaseGameplay.cs b/osu.Game.Tournament.Tests/TestCaseGameplayScreen.cs similarity index 66% rename from osu.Game.Tournament.Tests/TestCaseGameplay.cs rename to osu.Game.Tournament.Tests/TestCaseGameplayScreen.cs index c881f09cb9..b44cb11ec4 100644 --- a/osu.Game.Tournament.Tests/TestCaseGameplay.cs +++ b/osu.Game.Tournament.Tests/TestCaseGameplayScreen.cs @@ -1,25 +1,23 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; -using System.Collections.Generic; using osu.Framework.Allocation; using osu.Game.Tests.Visual; +using osu.Game.Tournament.Components; using osu.Game.Tournament.Screens.Gameplay; namespace osu.Game.Tournament.Tests { - public class TestCaseGameplay : OsuTestScene + public class TestCaseGameplayScreen : OsuTestScene { - public override IReadOnlyList RequiredTypes => new[] - { - typeof(GameplayScreen) - }; + [Cached] + private MatchChatDisplay chat = new MatchChatDisplay(); [BackgroundDependencyLoader] private void load() { Add(new GameplayScreen()); + Add(chat); } } } diff --git a/osu.Game.Tournament/Components/MatchChatDisplay.cs b/osu.Game.Tournament/Components/MatchChatDisplay.cs index 174b215732..fbf6949540 100644 --- a/osu.Game.Tournament/Components/MatchChatDisplay.cs +++ b/osu.Game.Tournament/Components/MatchChatDisplay.cs @@ -4,9 +4,11 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Game.Online.Chat; using osu.Game.Overlays.Chat; using osu.Game.Tournament.IPC; +using osuTK; using osuTK.Graphics; namespace osu.Game.Tournament.Components @@ -17,6 +19,16 @@ namespace osu.Game.Tournament.Components private ChannelManager manager; + public MatchChatDisplay() + { + RelativeSizeAxes = Axes.X; + Y = 100; + Size = new Vector2(0.45f, 112); + Margin = new MarginPadding(10); + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; + } + [BackgroundDependencyLoader(true)] private void load(MatchIPCInfo ipc) { diff --git a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs index 9883f03581..ca7d017bf3 100644 --- a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs +++ b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs @@ -32,13 +32,15 @@ namespace osu.Game.Tournament.Screens.Gameplay private readonly Color4 red = new Color4(186, 0, 18, 255); private readonly Color4 blue = new Color4(17, 136, 170, 255); - [Resolved] + [Resolved(canBeNull: true)] private TournamentSceneManager sceneManager { get; set; } + [Resolved] + private MatchChatDisplay chat { get; set; } + [BackgroundDependencyLoader] - private void load(LadderInfo ladder, MatchIPCInfo ipc, MatchChatDisplay chat) + private void load(LadderInfo ladder, MatchIPCInfo ipc) { - this.chat = chat; this.ipc = ipc; AddRangeInternal(new Drawable[] @@ -132,7 +134,6 @@ namespace osu.Game.Tournament.Screens.Gameplay } private ScheduledDelegate scheduledOperation; - private MatchChatDisplay chat; private MatchScoreDisplay scoreDisplay; private TourneyState lastState; @@ -155,7 +156,7 @@ namespace osu.Game.Tournament.Screens.Gameplay void expand() { - chat.Expand(); + chat?.Expand(); using (BeginDelayedSequence(300, true)) { @@ -168,8 +169,8 @@ namespace osu.Game.Tournament.Screens.Gameplay { SongBar.Expanded = false; scoreDisplay.FadeOut(100); - using (chat.BeginDelayedSequence(500)) - chat.Contract(); + using (chat?.BeginDelayedSequence(500)) + chat?.Contract(); } switch (state.NewValue) diff --git a/osu.Game.Tournament/Screens/TournamentSceneManager.cs b/osu.Game.Tournament/Screens/TournamentSceneManager.cs index 6bc624dca0..cec4f52751 100644 --- a/osu.Game.Tournament/Screens/TournamentSceneManager.cs +++ b/osu.Game.Tournament/Screens/TournamentSceneManager.cs @@ -32,17 +32,8 @@ namespace osu.Game.Tournament.Screens private Container screens; private VideoSprite video; - //todo: make less temporary [Cached] - private MatchChatDisplay chat = new MatchChatDisplay - { - RelativeSizeAxes = Axes.X, - Y = 100, - Size = new Vector2(0.45f, 112), - Margin = new MarginPadding(10), - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - }; + private MatchChatDisplay chat = new MatchChatDisplay(); private Container chatContainer;