1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 15:53:51 +08:00

Provide XML doc in Channel.cs and ChannelManager.cs and ChatTabControl.cs

This commit is contained in:
miterosan 2018-07-24 05:14:33 +02:00
parent 3df1842e1c
commit e769c15d28
3 changed files with 54 additions and 2 deletions

View File

@ -21,16 +21,44 @@ namespace osu.Game.Online.Chat
/// </summary>
public readonly ObservableCollection<User> JoinedUsers = new ObservableCollection<User>();
/// <summary>
/// Contains all the messages send in the channel.
/// </summary>
public readonly SortedList<Message> Messages = new SortedList<Message>(Comparer<Message>.Default);
/// <summary>
/// Contains all the messages that are still pending for submission to the server.
/// </summary>
private readonly List<LocalEchoMessage> pendingMessages = new List<LocalEchoMessage>();
/// <summary>
/// An event that fires when new messages arrived.
/// </summary>
public event Action<IEnumerable<Message>> NewMessagesArrived;
/// <summary>
/// An event that fires when a pending message gets resolved.
/// </summary>
public event Action<LocalEchoMessage, Message> PendingMessageResolved;
/// <summary>
/// An event that fires when a pending message gets removed.
/// </summary>
public event Action<Message> MessageRemoved;
/// <summary>
/// Signalles if the current user joined this channel or not. Defaults to false.
/// </summary>
public readonly Bindable<bool> Joined = new Bindable<bool>();
/// <summary>
/// Signalles whether the channels target is a private channel or public channel.
/// </summary>
public TargetType Target { get; protected set; }
public bool ReadOnly => false; //todo not yet used.
public override string ToString() => Name;
[JsonProperty(@"name")]
@ -50,6 +78,10 @@ namespace osu.Game.Online.Chat
{
}
/// <summary>
/// Adds the argument message as a local echo. When this local echo is resolved <see cref="PendingMessageResolved"/> will get called.
/// </summary>
/// <param name="message"></param>
public void AddLocalEcho(LocalEchoMessage message)
{
pendingMessages.Add(message);
@ -58,6 +90,10 @@ namespace osu.Game.Online.Chat
NewMessagesArrived?.Invoke(new[] { message });
}
/// <summary>
/// Adds new messages to the channel and purges old messages. Triggers the <see cref="NewMessagesArrived"/> event.
/// </summary>
/// <param name="messages"></param>
public void AddNewMessages(params Message[] messages)
{
messages = messages.Except(Messages).ToArray();

View File

@ -70,7 +70,7 @@ namespace osu.Game.Online.Chat
/// <summary>
/// Opens a new private channel.
/// </summary>
/// <param name="user"></param>
/// <param name="user">The user the private channel is opened with.</param>
public void OpenPrivateChannel(User user)
{
if (user == null)
@ -139,6 +139,10 @@ namespace osu.Game.Online.Chat
api.Queue(req);
}
/// <summary>
/// Posts a command locally. Commands like /help will result in a help message written in the current channel.
/// </summary>
/// <param name="text">the text containing the command identifier and command parameters.</param>
public void PostCommand(string text)
{
if (CurrentChannel.Value == null)
@ -319,7 +323,9 @@ namespace osu.Game.Online.Chat
}
}
/// <summary>
/// An exception thrown when a channel could not been found.
/// </summary>
public class ChannelNotFoundException : Exception
{
public ChannelNotFoundException(string channelName)

View File

@ -47,6 +47,11 @@ namespace osu.Game.Overlays.Chat
ChannelTabControl.Current.Value = channel;
}
/// <summary>
/// Adds a channel to the ChatTabControl.
/// The first channel added will automaticly selected.
/// </summary>
/// <param name="channel">The channel that is going to be added.</param>
public void AddItem(Channel channel)
{
if (!ChannelTabControl.Items.Contains(channel))
@ -56,6 +61,11 @@ namespace osu.Game.Overlays.Chat
Current.Value = channel;
}
/// <summary>
/// Removes a channel from the ChatTabControl.
/// If the selected channel is the one that is beeing removed, the next available channel will be selected.
/// </summary>
/// <param name="channel">The channel that is going to be removed.</param>
public void RemoveItem(Channel channel)
{
ChannelTabControl.RemoveItem(channel);