mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:52:54 +08:00
Rename var chatmanager -> channelManager
Apply requested changes
This commit is contained in:
parent
b997f0f3fa
commit
e39f5a1adf
@ -22,8 +22,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
typeof(ChatTabControl),
|
||||
typeof(ChannelTabControl),
|
||||
typeof(UserTabControl),
|
||||
|
||||
typeof(UserTabControl)
|
||||
};
|
||||
|
||||
private readonly ChatTabControl chatTabControl;
|
||||
|
@ -23,15 +23,15 @@ namespace osu.Game.Graphics.Containers
|
||||
public override bool HandleMouseInput => true;
|
||||
|
||||
private OsuGame game;
|
||||
private ChannelManager chatManager;
|
||||
private ChannelManager channelManager;
|
||||
private Action showNotImplementedError;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame game, NotificationOverlay notifications, ChannelManager chatManager)
|
||||
private void load(OsuGame game, NotificationOverlay notifications, ChannelManager channelManager)
|
||||
{
|
||||
// will be null in tests
|
||||
this.game = game;
|
||||
this.chatManager = chatManager;
|
||||
this.channelManager = channelManager;
|
||||
showNotImplementedError = () => notifications?.Post(new SimpleNotification
|
||||
{
|
||||
Text = @"This link type is not yet supported!",
|
||||
@ -80,9 +80,14 @@ namespace osu.Game.Graphics.Containers
|
||||
game?.ShowBeatmapSet(setId);
|
||||
break;
|
||||
case LinkAction.OpenChannel:
|
||||
var channel = chatManager.AvailableChannels.FirstOrDefault(c => c.Name == linkArgument);
|
||||
if (channel != null)
|
||||
chatManager.CurrentChannel.Value = channel;
|
||||
try
|
||||
{
|
||||
channelManager.OpenChannel(linkArgument);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
//channel was not found
|
||||
}
|
||||
break;
|
||||
case LinkAction.OpenEditorTimestamp:
|
||||
case LinkAction.JoinMultiplayerMatch:
|
||||
|
@ -9,12 +9,12 @@ using osu.Game.Online.Chat;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetChannelMessagesRequest : APIRequest<List<Message>>
|
||||
public class GetMessagesRequest : APIRequest<List<Message>>
|
||||
{
|
||||
private readonly IEnumerable<Channel> channels;
|
||||
private long? since;
|
||||
|
||||
public GetChannelMessagesRequest(IEnumerable<Channel> channels, long? sinceId)
|
||||
public GetMessagesRequest(IEnumerable<Channel> channels, long? sinceId)
|
||||
{
|
||||
if (channels == null)
|
||||
throw new ArgumentNullException(nameof(channels));
|
@ -7,11 +7,11 @@ using osu.Game.Online.Chat;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetUserMessagesRequest : APIRequest<List<Message>>
|
||||
public class GetPrivateMessagesRequest : APIRequest<List<Message>>
|
||||
{
|
||||
private long? since;
|
||||
|
||||
public GetUserMessagesRequest(long? sinceId = null)
|
||||
public GetPrivateMessagesRequest(long? sinceId = null)
|
||||
{
|
||||
since = sinceId;
|
||||
}
|
@ -34,7 +34,7 @@ namespace osu.Game.Online.Chat
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contructs a privatechannel
|
||||
/// Contructs a private channel
|
||||
/// TODO this class needs to be serialized from something like channels/private, instead of creating from a contructor
|
||||
/// </summary>
|
||||
/// <param name="user">The user </param>
|
||||
|
@ -50,8 +50,8 @@ namespace osu.Game.Online.Chat
|
||||
private APIAccess api;
|
||||
private readonly Scheduler scheduler;
|
||||
private ScheduledDelegate fetchMessagesScheduleder;
|
||||
private GetChannelMessagesRequest fetchChannelMsgReq;
|
||||
private GetUserMessagesRequest fetchUserMsgReq;
|
||||
private GetMessagesRequest fetchMsgReq;
|
||||
private GetPrivateMessagesRequest fetchPrivateMsgReq;
|
||||
private long? lastChannelMsgId;
|
||||
private long? lastUserMsgId;
|
||||
|
||||
@ -151,26 +151,26 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
private void fetchNewMessages()
|
||||
{
|
||||
if (fetchChannelMsgReq == null)
|
||||
if (fetchMsgReq == null)
|
||||
fetchNewChannelMessages();
|
||||
|
||||
if (fetchUserMsgReq == null)
|
||||
if (fetchPrivateMsgReq == null)
|
||||
fetchNewUserMessages();
|
||||
}
|
||||
|
||||
private void fetchNewUserMessages()
|
||||
{
|
||||
fetchUserMsgReq = new GetUserMessagesRequest(lastUserMsgId);
|
||||
fetchPrivateMsgReq = new GetPrivateMessagesRequest(lastUserMsgId);
|
||||
|
||||
fetchUserMsgReq.Success += messages =>
|
||||
fetchPrivateMsgReq.Success += messages =>
|
||||
{
|
||||
handleUserMessages(messages);
|
||||
lastUserMsgId = messages.LastOrDefault()?.Id ?? lastUserMsgId;
|
||||
fetchUserMsgReq = null;
|
||||
fetchPrivateMsgReq = null;
|
||||
};
|
||||
fetchUserMsgReq.Failure += exception => Logger.Error(exception, "Fetching user messages failed.");
|
||||
fetchPrivateMsgReq.Failure += exception => Logger.Error(exception, "Fetching user messages failed.");
|
||||
|
||||
api.Queue(fetchUserMsgReq);
|
||||
api.Queue(fetchPrivateMsgReq);
|
||||
}
|
||||
|
||||
private void handleUserMessages(IEnumerable<Message> messages)
|
||||
@ -220,19 +220,19 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
private void fetchNewChannelMessages()
|
||||
{
|
||||
fetchChannelMsgReq = new GetChannelMessagesRequest(JoinedChannels.Where(c => c.Target == TargetType.Channel), lastChannelMsgId);
|
||||
fetchMsgReq = new GetMessagesRequest(JoinedChannels.Where(c => c.Target == TargetType.Channel), lastChannelMsgId);
|
||||
|
||||
fetchChannelMsgReq.Success += messages =>
|
||||
fetchMsgReq.Success += messages =>
|
||||
{
|
||||
if (messages == null)
|
||||
return;
|
||||
handleChannelMessages(messages);
|
||||
lastChannelMsgId = messages.LastOrDefault()?.Id ?? lastChannelMsgId;
|
||||
fetchChannelMsgReq = null;
|
||||
fetchMsgReq = null;
|
||||
};
|
||||
fetchChannelMsgReq.Failure += exception => Logger.Error(exception, "Fetching channel messages failed.");
|
||||
fetchMsgReq.Failure += exception => Logger.Error(exception, "Fetching channel messages failed.");
|
||||
|
||||
api.Queue(fetchChannelMsgReq);
|
||||
api.Queue(fetchMsgReq);
|
||||
}
|
||||
|
||||
private void handleChannelMessages(IEnumerable<Message> messages)
|
||||
@ -258,7 +258,7 @@ namespace osu.Game.Online.Chat
|
||||
{
|
||||
JoinedChannels.Add(channel);
|
||||
|
||||
var fetchInitialMsgReq = new GetChannelMessagesRequest(new[] { channel }, null);
|
||||
var fetchInitialMsgReq = new GetMessagesRequest(new[] { channel }, null);
|
||||
fetchInitialMsgReq.Success += handleChannelMessages;
|
||||
fetchInitialMsgReq.Failure += exception => Logger.Error(exception, "Failed to fetch inital messages.");
|
||||
api.Queue(fetchInitialMsgReq);
|
||||
@ -281,8 +281,8 @@ namespace osu.Game.Online.Chat
|
||||
fetchMessagesScheduleder = scheduler.AddDelayed(fetchNewMessages, 1000, true);
|
||||
break;
|
||||
default:
|
||||
fetchChannelMsgReq?.Cancel();
|
||||
fetchChannelMsgReq = null;
|
||||
fetchMsgReq?.Cancel();
|
||||
fetchMsgReq = null;
|
||||
fetchMessagesScheduleder?.Cancel();
|
||||
break;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Overlays
|
||||
private const float textbox_height = 60;
|
||||
private const float channel_selection_min_height = 0.3f;
|
||||
|
||||
private ChannelManager chatManager;
|
||||
private ChannelManager channelManager;
|
||||
|
||||
private readonly Container<DrawableChat> currentChatContainer;
|
||||
private readonly List<DrawableChat> loadedChannels = new List<DrawableChat>();
|
||||
@ -157,7 +157,7 @@ namespace osu.Game.Overlays
|
||||
chatTabControl = new ChatTabControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
OnRequestLeave = channel => chatManager.JoinedChannels.Remove(channel)
|
||||
OnRequestLeave = channel => channelManager.JoinedChannels.Remove(channel)
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -165,7 +165,7 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
};
|
||||
|
||||
chatTabControl.Current.ValueChanged += chat => chatManager.CurrentChannel.Value = chat;
|
||||
chatTabControl.Current.ValueChanged += chat => channelManager.CurrentChannel.Value = chat;
|
||||
chatTabControl.ChannelTabControl.ChannelSelectorActive.ValueChanged += value => channelSelection.State = value ? Visibility.Visible : Visibility.Hidden;
|
||||
channelSelection.StateChanged += state =>
|
||||
{
|
||||
@ -182,10 +182,10 @@ namespace osu.Game.Overlays
|
||||
};
|
||||
channelSelection.OnRequestJoin = channel =>
|
||||
{
|
||||
if (!chatManager.JoinedChannels.Contains(channel))
|
||||
chatManager.JoinedChannels.Add(channel);
|
||||
if (!channelManager.JoinedChannels.Contains(channel))
|
||||
channelManager.JoinedChannels.Add(channel);
|
||||
};
|
||||
channelSelection.OnRequestLeave = channel => chatManager.JoinedChannels.Remove(channel);
|
||||
channelSelection.OnRequestLeave = channel => channelManager.JoinedChannels.Remove(channel);
|
||||
}
|
||||
|
||||
private void availableChannelsChanged(object sender, NotifyCollectionChangedEventArgs args)
|
||||
@ -195,7 +195,7 @@ namespace osu.Game.Overlays
|
||||
new ChannelSection
|
||||
{
|
||||
Header = "All Channels",
|
||||
Channels = chatManager.AvailableChannels,
|
||||
Channels = channelManager.AvailableChannels,
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -328,10 +328,8 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(APIAccess api, OsuConfigManager config, OsuColour colours, ChannelManager chatManager)
|
||||
private void load(OsuConfigManager config, OsuColour colours, ChannelManager channelManager)
|
||||
{
|
||||
api.Register(chatManager);
|
||||
|
||||
ChatHeight = config.GetBindable<double>(OsuSetting.ChatDisplayHeight);
|
||||
ChatHeight.ValueChanged += h =>
|
||||
{
|
||||
@ -344,10 +342,10 @@ namespace osu.Game.Overlays
|
||||
chatBackground.Colour = colours.ChatBlue;
|
||||
loading.Show();
|
||||
|
||||
this.chatManager = chatManager;
|
||||
chatManager.CurrentChannel.ValueChanged += currentChatChanged;
|
||||
chatManager.JoinedChannels.CollectionChanged += joinedChannelsChanged;
|
||||
chatManager.AvailableChannels.CollectionChanged += availableChannelsChanged;
|
||||
this.channelManager = channelManager;
|
||||
channelManager.CurrentChannel.ValueChanged += currentChatChanged;
|
||||
channelManager.JoinedChannels.CollectionChanged += joinedChannelsChanged;
|
||||
channelManager.AvailableChannels.CollectionChanged += availableChannelsChanged;
|
||||
}
|
||||
|
||||
private void postMessage(TextBox textbox, bool newText)
|
||||
@ -358,9 +356,9 @@ namespace osu.Game.Overlays
|
||||
return;
|
||||
|
||||
if (text[0] == '/')
|
||||
chatManager.PostCommand(text.Substring(1));
|
||||
channelManager.PostCommand(text.Substring(1));
|
||||
else
|
||||
chatManager.PostMessage(text);
|
||||
channelManager.PostMessage(text);
|
||||
|
||||
textbox.Text = string.Empty;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user