using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Sandbox.Engine.Multiplayer; using Sandbox.Game.Gui; using Sandbox.Game.Multiplayer; using VRage.Game; using VRage.Network; using VRage.Replication; namespace Torch.API.Managers { /// /// Represents a scripted or user chat message. /// public struct TorchChatMessage { /// /// Creates a new torch chat message with the given author and message. /// /// Author's name /// Message /// Font public TorchChatMessage(string author, string message, string font = MyFontEnum.Blue) { Timestamp = DateTime.Now; AuthorSteamId = null; Author = author; Message = message; Channel = ChatChannel.Global; Target = 0; Font = font; } /// /// Creates a new torch chat message with the given author and message. /// /// Author's name /// Author's steam ID /// Message /// Font public TorchChatMessage(string author, ulong authorSteamId, string message, ChatChannel channel, long target, string font = MyFontEnum.Blue) { Timestamp = DateTime.Now; AuthorSteamId = authorSteamId; Author = author; Message = message; Channel = channel; Target = target; Font = font; } /// /// Creates a new torch chat message with the given author and message. /// /// Author's steam ID /// Message /// Font public TorchChatMessage(ulong authorSteamId, string message, ChatChannel channel, long target, string font = MyFontEnum.Blue) { Timestamp = DateTime.Now; AuthorSteamId = authorSteamId; Author = MyMultiplayer.Static?.GetMemberName(authorSteamId) ?? "Player"; Message = message; Channel = channel; Target = target; Font = font; } /// /// This message's timestamp. /// public readonly DateTime Timestamp; /// /// The author's steam ID, if available. Else, null. /// public readonly ulong? AuthorSteamId; /// /// The author's name, if available. Else, null. /// public readonly string Author; /// /// The message contents. /// public readonly string Message; /// /// The chat channel the message is part of. /// public readonly ChatChannel Channel; /// /// The intended recipient of the message. /// public readonly long Target; /// /// The font, or null if default. /// public readonly string Font; } /// /// Callback used to indicate that a messaage has been recieved. /// /// /// If true, this event has been consumed and should be ignored public delegate void MessageRecievedDel(TorchChatMessage msg, ref bool consumed); /// /// Callback used to indicate the user is attempting to send a message locally. /// /// Message the user is attempting to send /// If true, this event has been consumed and should be ignored public delegate void MessageSendingDel(string msg, ref bool consumed); public interface IChatManagerClient : IManager { /// /// Event that is raised when a message addressed to us is recieved. /// event MessageRecievedDel MessageRecieved; /// /// Event that is raised when we are attempting to send a message. /// event MessageSendingDel MessageSending; /// /// Triggers the event, /// typically raised by the user entering text into the chat window. /// /// The message to send void SendMessageAsSelf(string message); /// /// Displays a message on the UI given an author name and a message. /// /// Author name /// Message content /// font to use void DisplayMessageOnSelf(string author, string message, string font = "Blue" ); } }