diff --git a/osu.Game.Tournament/Components/MatchChatDisplay.cs b/osu.Game.Tournament/Components/MatchChatDisplay.cs index a68507044d..c44eb88ef8 100644 --- a/osu.Game.Tournament/Components/MatchChatDisplay.cs +++ b/osu.Game.Tournament/Components/MatchChatDisplay.cs @@ -12,6 +12,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; +using osu.Game.Tournament.IPC; using OpenTK; using OpenTK.Graphics; @@ -25,7 +26,7 @@ namespace osu.Game.Tournament.Components public MatchChatDisplay() { - CornerRadius = 5; + CornerRadius = 10; Masking = true; InternalChildren = new Drawable[] @@ -51,13 +52,46 @@ namespace osu.Game.Tournament.Components Channel.BindValueChanged(channelChanged); } + private readonly Bindable chatChannel = new Bindable(); + + private ChannelManager manager; + + [BackgroundDependencyLoader(true)] + private void load(MatchIPCInfo ipc) + { + if (ipc != null) + { + AddInternal(manager = new ChannelManager()); + + Channel.BindTo(manager.CurrentChannel); + + chatChannel.BindTo(ipc.ChatChannel); + chatChannel.BindValueChanged(channelString => + { + if (string.IsNullOrWhiteSpace(channelString)) + return; + + int id = int.Parse(channelString); + + var channel = manager.JoinedChannels.FirstOrDefault(ch => ch.Id == id) ?? new Channel + { + Id = id, + Type = ChannelType.Public + }; + + manager.JoinChannel(channel); + manager.CurrentChannel.Value = channel; + + }, true); + } + } + private void channelChanged(Channel channel) { if (lastChannel != null) lastChannel.NewMessagesArrived -= newMessages; lastChannel = channel; - channel.NewMessagesArrived += newMessages; } diff --git a/osu.Game.Tournament/Components/SongBar.cs b/osu.Game.Tournament/Components/SongBar.cs index 94848b9130..53dec8e0a4 100644 --- a/osu.Game.Tournament/Components/SongBar.cs +++ b/osu.Game.Tournament/Components/SongBar.cs @@ -62,7 +62,7 @@ namespace osu.Game.Tournament.Components set { expanded = value; - panel.ResizeWidthTo(panelWidth, 800, Easing.OutQuint); + panel?.ResizeWidthTo(panelWidth, 800, Easing.OutQuint); if (expanded) { @@ -72,7 +72,7 @@ namespace osu.Game.Tournament.Components else { innerPanel.ResizeWidthTo(1, 800, Easing.OutQuint); - outerPanel.ResizeWidthTo(0.2f, 800, Easing.OutQuint); + outerPanel.ResizeWidthTo(0.25f, 800, Easing.OutQuint); } } } diff --git a/osu.Game.Tournament/IPC/FileBasedIPC.cs b/osu.Game.Tournament/IPC/FileBasedIPC.cs index 6759122c16..87c6fb4c83 100644 --- a/osu.Game.Tournament/IPC/FileBasedIPC.cs +++ b/osu.Game.Tournament/IPC/FileBasedIPC.cs @@ -53,6 +53,7 @@ namespace osu.Game.Tournament.IPC } Mods.Value = (LegacyMods)mods; + ChatChannel.Value = sr.ReadLine(); } } catch diff --git a/osu.Game.Tournament/IPC/MatchIPCInfo.cs b/osu.Game.Tournament/IPC/MatchIPCInfo.cs index d40ec35808..be31df8009 100644 --- a/osu.Game.Tournament/IPC/MatchIPCInfo.cs +++ b/osu.Game.Tournament/IPC/MatchIPCInfo.cs @@ -13,6 +13,7 @@ namespace osu.Game.Tournament.IPC public Bindable Beatmap { get; } = new Bindable(); public Bindable Mods { get; } = new Bindable(); public Bindable State { get; } = new Bindable(); + public Bindable ChatChannel { get; } = new Bindable(); public BindableInt Score1 { get; } = new BindableInt(); public BindableInt Score2 { get; } = new BindableInt(); } diff --git a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs index d3fd08bb8b..3c6ea39ae7 100644 --- a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs +++ b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs @@ -13,6 +13,7 @@ using osu.Game.Tournament.Components; using osu.Game.Tournament.IPC; using osu.Game.Tournament.Screens.Gameplay.Components; using osu.Game.Tournament.Screens.Ladder.Components; +using OpenTK; using OpenTK.Graphics; namespace osu.Game.Tournament.Screens.Gameplay @@ -82,6 +83,14 @@ namespace osu.Game.Tournament.Screens.Gameplay }, } }, + chat = new MatchChatDisplay + { + RelativeSizeAxes = Axes.X, + Size = new Vector2(0.45f, 120), + Margin = new MarginPadding(10), + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + }, new ControlPanel { Children = new Drawable[] @@ -102,8 +111,8 @@ namespace osu.Game.Tournament.Screens.Gameplay } }); - State.BindValueChanged(stateChanged); State.BindTo(ipc.State); + State.BindValueChanged(stateChanged, true); currentMatch.BindValueChanged(m => warmup.Value = m.Team1Score + m.Team2Score == 0); currentMatch.BindTo(ladder.CurrentMatch); @@ -112,6 +121,7 @@ namespace osu.Game.Tournament.Screens.Gameplay } private ScheduledDelegate scheduledBarContract; + private MatchChatDisplay chat; private void stateChanged(TourneyState state) { @@ -132,12 +142,21 @@ namespace osu.Game.Tournament.Screens.Gameplay case TourneyState.Idle: // show chat SongBar.Expanded = false; + using (chat.BeginDelayedSequence(500)) + { + chat.FadeIn(300); + chat.MoveToY(100).MoveToY(0, 500, Easing.OutQuint); + } + break; case TourneyState.Ranking: scheduledBarContract = Scheduler.AddDelayed(() => SongBar.Expanded = false, 15000); break; default: - SongBar.Expanded = true; + chat.FadeOut(200); + chat.MoveToY(100, 500, Easing.In); + using (SongBar.BeginDelayedSequence(300, true)) + SongBar.Expanded = true; break; } } diff --git a/osu.Game/Online/Chat/ChannelType.cs b/osu.Game/Online/Chat/ChannelType.cs index 4ac0a99fc6..2fbc48fb92 100644 --- a/osu.Game/Online/Chat/ChannelType.cs +++ b/osu.Game/Online/Chat/ChannelType.cs @@ -6,6 +6,7 @@ namespace osu.Game.Online.Chat public enum ChannelType { PM, - Public + Public, + Temporary } }