1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-25 03:07:34 +08:00

Rename the currentChatChanged to currentChannelContainer, move drawing specific part into from chatoverlay to ChannelSelectionOverlay

This commit is contained in:
miterosan 2018-07-09 20:13:34 +02:00
parent 0c62726fd7
commit f22f62ef40
2 changed files with 39 additions and 41 deletions

View File

@ -35,23 +35,6 @@ namespace osu.Game.Overlays.Chat.Selection
public Action<Channel> OnRequestJoin;
public Action<Channel> OnRequestLeave;
public IEnumerable<ChannelSection> Sections
{
set
{
sectionsFlow.ChildrenEnumerable = value;
foreach (ChannelSection s in sectionsFlow.Children)
{
foreach (ChannelListItem c in s.ChannelFlow.Children)
{
c.OnRequestJoin = channel => { OnRequestJoin?.Invoke(channel); };
c.OnRequestLeave = channel => { OnRequestLeave?.Invoke(channel); };
}
}
}
}
public ChannelSelectionOverlay()
{
RelativeSizeAxes = Axes.X;
@ -140,6 +123,27 @@ namespace osu.Game.Overlays.Chat.Selection
search.Current.ValueChanged += newValue => sectionsFlow.SearchTerm = newValue;
}
public void UpdateAvailableChannels(IEnumerable<Channel> channels)
{
sectionsFlow.ChildrenEnumerable = new[]
{
new ChannelSection
{
Header = "All Channels",
Channels = channels,
},
};
foreach (ChannelSection s in sectionsFlow.Children)
{
foreach (ChannelListItem c in s.ChannelFlow.Children)
{
c.OnRequestJoin = channel => { OnRequestJoin?.Invoke(channel); };
c.OnRequestLeave = channel => { OnRequestLeave?.Invoke(channel); };
}
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{

View File

@ -30,7 +30,7 @@ namespace osu.Game.Overlays
private ChannelManager channelManager;
private readonly Container<DrawableChannel> currentChatContainer;
private readonly Container<DrawableChannel> currentChannelContainer;
private readonly List<DrawableChannel> loadedChannels = new List<DrawableChannel>();
private readonly LoadingAnimation loading;
@ -102,7 +102,7 @@ namespace osu.Game.Overlays
{
RelativeSizeAxes = Axes.Both,
},
currentChatContainer = new Container<DrawableChannel>
currentChannelContainer = new Container<DrawableChannel>
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding
@ -188,14 +188,8 @@ namespace osu.Game.Overlays
private void availableChannelsChanged(object sender, NotifyCollectionChangedEventArgs args)
{
channelSelection.Sections = new[]
{
new ChannelSection
{
Header = "All Channels",
Channels = channelManager.AvailableChannels,
},
};
channelSelection.UpdateAvailableChannels(channelManager.);
}
private void joinedChannelsChanged(object sender, NotifyCollectionChangedEventArgs args)
@ -220,42 +214,42 @@ namespace osu.Game.Overlays
}
}
private void currentChatChanged(Channel chat)
private void currentChatChanged(Channel channel)
{
if (chat == null)
if (channel == null)
{
textbox.Current.Disabled = true;
currentChatContainer.Clear(false);
currentChannelContainer.Clear(false);
chatTabControl.Current.Value = null;
return;
}
textbox.Current.Disabled = chat.ReadOnly;
textbox.Current.Disabled = channel.ReadOnly;
if (chatTabControl.Current.Value != chat)
Scheduler.Add(() => chatTabControl.Current.Value = chat);
if (chatTabControl.Current.Value != channel)
Scheduler.Add(() => chatTabControl.Current.Value = channel);
var loaded = loadedChannels.Find(d => d.Channel == chat);
var loaded = loadedChannels.Find(d => d.Channel == channel);
if (loaded == null)
{
currentChatContainer.FadeOut(500, Easing.OutQuint);
currentChannelContainer.FadeOut(500, Easing.OutQuint);
loading.Show();
loaded = new DrawableChannel(chat);
loaded = new DrawableChannel(channel);
loadedChannels.Add(loaded);
LoadComponentAsync(loaded, l =>
{
loading.Hide();
currentChatContainer.Clear(false);
currentChatContainer.Add(loaded);
currentChatContainer.FadeIn(500, Easing.OutQuint);
currentChannelContainer.Clear(false);
currentChannelContainer.Add(loaded);
currentChannelContainer.FadeIn(500, Easing.OutQuint);
});
}
else
{
currentChatContainer.Clear(false);
currentChatContainer.Add(loaded);
currentChannelContainer.Clear(false);
currentChannelContainer.Add(loaded);
}
}