|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using System.Threading.Tasks; |
| 6 | +using Sandbox.Engine.Multiplayer; |
| 7 | +using Sandbox.Game.Multiplayer; |
| 8 | +using VRage.Network; |
| 9 | + |
| 10 | +namespace Torch.API.Managers |
| 11 | +{ |
| 12 | + /// <summary> |
| 13 | + /// Represents a scripted or user chat message. |
| 14 | + /// </summary> |
| 15 | + public struct TorchChatMessage |
| 16 | + { |
| 17 | + /// <summary> |
| 18 | + /// Creates a new torch chat message with the given author and message. |
| 19 | + /// </summary> |
| 20 | + /// <param name="author">Author's name</param> |
| 21 | + /// <param name="message">Message</param> |
| 22 | + public TorchChatMessage(string author, string message) |
| 23 | + { |
| 24 | + Timestamp = DateTime.Now; |
| 25 | + AuthorSteamId = null; |
| 26 | + Author = author; |
| 27 | + Message = message; |
| 28 | + Font = "Blue"; |
| 29 | + } |
| 30 | + |
| 31 | + /// <summary> |
| 32 | + /// Creates a new torch chat message with the given author and message. |
| 33 | + /// </summary> |
| 34 | + /// <param name="authorSteamId">Author's steam ID</param> |
| 35 | + /// <param name="message">Message</param> |
| 36 | + public TorchChatMessage(ulong authorSteamId, string message) |
| 37 | + { |
| 38 | + Timestamp = DateTime.Now; |
| 39 | + AuthorSteamId = authorSteamId; |
| 40 | + Author = MyMultiplayer.Static?.GetMemberName(authorSteamId) ?? "Player"; |
| 41 | + Message = message; |
| 42 | + Font = "Blue"; |
| 43 | + } |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// This message's timestamp. |
| 47 | + /// </summary> |
| 48 | + public DateTime Timestamp; |
| 49 | + /// <summary> |
| 50 | + /// The author's steam ID, if available. Else, null. |
| 51 | + /// </summary> |
| 52 | + public ulong? AuthorSteamId; |
| 53 | + /// <summary> |
| 54 | + /// The author's name, if available. Else, null. |
| 55 | + /// </summary> |
| 56 | + public string Author; |
| 57 | + /// <summary> |
| 58 | + /// The message contents. |
| 59 | + /// </summary> |
| 60 | + public string Message; |
| 61 | + /// <summary> |
| 62 | + /// The font, or null if default. |
| 63 | + /// </summary> |
| 64 | + public string Font; |
| 65 | + } |
| 66 | + |
| 67 | + /// <summary> |
| 68 | + /// Callback used to indicate that a messaage has been recieved. |
| 69 | + /// </summary> |
| 70 | + /// <param name="msg"></param> |
| 71 | + /// <param name="consumed">If true, this event has been consumed and should be ignored</param> |
| 72 | + public delegate void MessageRecievedDel(TorchChatMessage msg, ref bool consumed); |
| 73 | + |
| 74 | + /// <summary> |
| 75 | + /// Callback used to indicate the user is attempting to send a message locally. |
| 76 | + /// </summary> |
| 77 | + /// <param name="msg">Message the user is attempting to send</param> |
| 78 | + /// <param name="consumed">If true, this event has been consumed and should be ignored</param> |
| 79 | + public delegate void MessageSendingDel(string msg, ref bool consumed); |
| 80 | + |
| 81 | + public interface IChatManagerClient : IManager |
| 82 | + { |
| 83 | + /// <summary> |
| 84 | + /// Event that is raised when a message addressed to us is recieved. <see cref="MessageRecievedDel"/> |
| 85 | + /// </summary> |
| 86 | + event MessageRecievedDel MessageRecieved; |
| 87 | + |
| 88 | + /// <summary> |
| 89 | + /// Event that is raised when we are attempting to send a message. <see cref="MessageSendingDel"/> |
| 90 | + /// </summary> |
| 91 | + event MessageSendingDel MessageSending; |
| 92 | + |
| 93 | + /// <summary> |
| 94 | + /// Triggers the <see cref="MessageSending"/> event, |
| 95 | + /// typically raised by the user entering text into the chat window. |
| 96 | + /// </summary> |
| 97 | + /// <param name="message">The message to send</param> |
| 98 | + void SendMessageAsSelf(string message); |
| 99 | + |
| 100 | + /// <summary> |
| 101 | + /// Displays a message on the UI given an author name and a message. |
| 102 | + /// </summary> |
| 103 | + /// <param name="author">Author name</param> |
| 104 | + /// <param name="message">Message content</param> |
| 105 | + /// <param name="font">font to use</param> |
| 106 | + void DisplayMessageOnSelf(string author, string message, string font = "Blue" ); |
| 107 | + } |
| 108 | +} |
0 commit comments