1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 09:27:34 +08:00

Rework ChannelTabControl's AddChannel method to not auto select and let ChatOverlay handle this

This commit is contained in:
Craftplacer 2020-01-19 18:20:42 +01:00
parent 5f96940b7d
commit 1681e16738
2 changed files with 3 additions and 11 deletions

View File

@ -59,17 +59,12 @@ namespace osu.Game.Overlays.Chat.Tabs
/// <summary>
/// Adds a channel to the ChannelTabControl.
/// The first channel added will automaticly selected if <paramref name="setChannel"/> is true.
/// </summary>
/// <param name="channel">The channel that is going to be added.</param>
/// <param name="setChannel">If the current channel should be changed if none was selected before</param>
public void AddChannel(Channel channel, bool setChannel = true)
public void AddChannel(Channel channel)
{
if (!Items.Contains(channel))
AddItem(channel);
if (Current.Value == null && setChannel)
Current.Value = channel;
}
/// <summary>

View File

@ -222,13 +222,10 @@ namespace osu.Game.Overlays
channelManager.JoinedChannels.ItemsAdded += onChannelAddedToJoinedChannels;
channelManager.JoinedChannels.ItemsRemoved += onChannelRemovedFromJoinedChannels;
bool channelSelected = channelManager.CurrentChannel.Value != null;
foreach (Channel channel in channelManager.JoinedChannels)
ChannelTabControl.AddChannel(channel, !channelSelected);
ChannelTabControl.AddChannel(channel);
if (channelSelected)
ChannelTabControl.Current.Value = channelManager.CurrentChannel.Value;
ChannelTabControl.Current.Value = channelManager.CurrentChannel.Value ?? channelManager.JoinedChannels.First();
channelManager.AvailableChannels.ItemsAdded += availableChannelsChanged;
channelManager.AvailableChannels.ItemsRemoved += availableChannelsChanged;