mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Add chat IPC and gameplay screen integration
This commit is contained in:
parent
c9e2ee8f56
commit
e3e92f4302
@ -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<string> chatChannel = new Bindable<string>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ namespace osu.Game.Tournament.IPC
|
||||
}
|
||||
|
||||
Mods.Value = (LegacyMods)mods;
|
||||
ChatChannel.Value = sr.ReadLine();
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
@ -13,6 +13,7 @@ namespace osu.Game.Tournament.IPC
|
||||
public Bindable<BeatmapInfo> Beatmap { get; } = new Bindable<BeatmapInfo>();
|
||||
public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>();
|
||||
public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>();
|
||||
public Bindable<string> ChatChannel { get; } = new Bindable<string>();
|
||||
public BindableInt Score1 { get; } = new BindableInt();
|
||||
public BindableInt Score2 { get; } = new BindableInt();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ namespace osu.Game.Online.Chat
|
||||
public enum ChannelType
|
||||
{
|
||||
PM,
|
||||
Public
|
||||
Public,
|
||||
Temporary
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user