mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Preserve current channel if ChatOverlay is being loaded in
This commit is contained in:
@ -59,15 +59,16 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a channel to the ChannelTabControl.
|
/// Adds a channel to the ChannelTabControl.
|
||||||
/// The first channel added will automaticly selected.
|
/// The first channel added will automaticly selected if <paramref name="setChannel"/> is true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="channel">The channel that is going to be added.</param>
|
/// <param name="channel">The channel that is going to be added.</param>
|
||||||
public void AddChannel(Channel channel)
|
/// <param name="setChannel">If the current channel should be changed if none was selected before</param>
|
||||||
|
public void AddChannel(Channel channel, bool setChannel = true)
|
||||||
{
|
{
|
||||||
if (!Items.Contains(channel))
|
if (!Items.Contains(channel))
|
||||||
AddItem(channel);
|
AddItem(channel);
|
||||||
|
|
||||||
if (Current.Value == null)
|
if (Current.Value == null && setChannel)
|
||||||
Current.Value = channel;
|
Current.Value = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,8 +221,14 @@ namespace osu.Game.Overlays
|
|||||||
// TODO: consider scheduling bindable callbacks to not perform when overlay is not present.
|
// TODO: consider scheduling bindable callbacks to not perform when overlay is not present.
|
||||||
channelManager.JoinedChannels.ItemsAdded += onChannelAddedToJoinedChannels;
|
channelManager.JoinedChannels.ItemsAdded += onChannelAddedToJoinedChannels;
|
||||||
channelManager.JoinedChannels.ItemsRemoved += onChannelRemovedFromJoinedChannels;
|
channelManager.JoinedChannels.ItemsRemoved += onChannelRemovedFromJoinedChannels;
|
||||||
|
|
||||||
|
bool channelSelected = channelManager.CurrentChannel.Value != null;
|
||||||
|
|
||||||
foreach (Channel channel in channelManager.JoinedChannels)
|
foreach (Channel channel in channelManager.JoinedChannels)
|
||||||
ChannelTabControl.AddChannel(channel);
|
ChannelTabControl.AddChannel(channel, !channelSelected);
|
||||||
|
|
||||||
|
if (channelSelected)
|
||||||
|
ChannelTabControl.Current.Value = channelManager.CurrentChannel.Value;
|
||||||
|
|
||||||
channelManager.AvailableChannels.ItemsAdded += availableChannelsChanged;
|
channelManager.AvailableChannels.ItemsAdded += availableChannelsChanged;
|
||||||
channelManager.AvailableChannels.ItemsRemoved += availableChannelsChanged;
|
channelManager.AvailableChannels.ItemsRemoved += availableChannelsChanged;
|
||||||
|
Reference in New Issue
Block a user