Fix command hiding, add new chat properties to TorchChatMessage
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Sandbox.Engine.Multiplayer;
|
using Sandbox.Engine.Multiplayer;
|
||||||
|
using Sandbox.Game.Gui;
|
||||||
using Sandbox.Game.Multiplayer;
|
using Sandbox.Game.Multiplayer;
|
||||||
using VRage.Game;
|
using VRage.Game;
|
||||||
using VRage.Network;
|
using VRage.Network;
|
||||||
@@ -28,6 +29,8 @@ namespace Torch.API.Managers
|
|||||||
AuthorSteamId = null;
|
AuthorSteamId = null;
|
||||||
Author = author;
|
Author = author;
|
||||||
Message = message;
|
Message = message;
|
||||||
|
Channel = ChatChannel.Global;
|
||||||
|
Target = 0;
|
||||||
Font = font;
|
Font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,12 +41,14 @@ namespace Torch.API.Managers
|
|||||||
/// <param name="authorSteamId">Author's steam ID</param>
|
/// <param name="authorSteamId">Author's steam ID</param>
|
||||||
/// <param name="message">Message</param>
|
/// <param name="message">Message</param>
|
||||||
/// <param name="font">Font</param>
|
/// <param name="font">Font</param>
|
||||||
public TorchChatMessage(string author, ulong authorSteamId, string message, string font = MyFontEnum.Blue)
|
public TorchChatMessage(string author, ulong authorSteamId, string message, ChatChannel channel, long target, string font = MyFontEnum.Blue)
|
||||||
{
|
{
|
||||||
Timestamp = DateTime.Now;
|
Timestamp = DateTime.Now;
|
||||||
AuthorSteamId = authorSteamId;
|
AuthorSteamId = authorSteamId;
|
||||||
Author = author;
|
Author = author;
|
||||||
Message = message;
|
Message = message;
|
||||||
|
Channel = channel;
|
||||||
|
Target = target;
|
||||||
Font = font;
|
Font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +64,8 @@ namespace Torch.API.Managers
|
|||||||
AuthorSteamId = authorSteamId;
|
AuthorSteamId = authorSteamId;
|
||||||
Author = MyMultiplayer.Static?.GetMemberName(authorSteamId) ?? "Player";
|
Author = MyMultiplayer.Static?.GetMemberName(authorSteamId) ?? "Player";
|
||||||
Message = message;
|
Message = message;
|
||||||
|
Channel = ChatChannel.Global;
|
||||||
|
Target = 0;
|
||||||
Font = font;
|
Font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +86,14 @@ namespace Torch.API.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly string Message;
|
public readonly string Message;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The chat channel the message is part of.
|
||||||
|
/// </summary>
|
||||||
|
public readonly ChatChannel Channel;
|
||||||
|
/// <summary>
|
||||||
|
/// The intended recipient of the message.
|
||||||
|
/// </summary>
|
||||||
|
public readonly long Target;
|
||||||
|
/// <summary>
|
||||||
/// The font, or null if default.
|
/// The font, or null if default.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly string Font;
|
public readonly string Font;
|
||||||
|
@@ -108,7 +108,7 @@ namespace Torch.Managers.ChatManager
|
|||||||
{
|
{
|
||||||
if (!sendToOthers)
|
if (!sendToOthers)
|
||||||
return;
|
return;
|
||||||
var torchMsg = new TorchChatMessage(MySession.Static.LocalHumanPlayer?.DisplayName ?? "Player", Sync.MyId, messageText);
|
var torchMsg = new TorchChatMessage(MySession.Static.LocalHumanPlayer?.DisplayName ?? "Player", Sync.MyId, messageText, ChatChannel.Global, 0);
|
||||||
bool consumed = RaiseMessageRecieved(torchMsg);
|
bool consumed = RaiseMessageRecieved(torchMsg);
|
||||||
if (!consumed)
|
if (!consumed)
|
||||||
consumed = OfflineMessageProcessor(torchMsg);
|
consumed = OfflineMessageProcessor(torchMsg);
|
||||||
|
@@ -34,10 +34,11 @@ namespace Torch.Managers.ChatManager
|
|||||||
context.GetPattern(target).Prefixes.Add(patchMethod);
|
context.GetPattern(target).Prefixes.Add(patchMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PrefixMessageProcessing(ref ChatMsg msg)
|
private static bool PrefixMessageProcessing(ref ChatMsg msg)
|
||||||
{
|
{
|
||||||
var consumed = false;
|
var consumed = false;
|
||||||
ChatManager?.RaiseMessageRecieved(msg, ref consumed);
|
ChatManager?.RaiseMessageRecieved(msg, ref consumed);
|
||||||
|
return !consumed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +161,7 @@ namespace Torch.Managers.ChatManager
|
|||||||
|
|
||||||
internal void RaiseMessageRecieved(ChatMsg message, ref bool consumed)
|
internal void RaiseMessageRecieved(ChatMsg message, ref bool consumed)
|
||||||
{
|
{
|
||||||
var torchMsg = new TorchChatMessage(GetMemberName(message.Author), message.Author, message.Text);
|
var torchMsg = new TorchChatMessage(GetMemberName(message.Author), message.Author, message.Text, (ChatChannel)message.Channel, message.TargetId);
|
||||||
MessageProcessing?.Invoke(torchMsg, ref consumed);
|
MessageProcessing?.Invoke(torchMsg, ref consumed);
|
||||||
|
|
||||||
if (!consumed)
|
if (!consumed)
|
||||||
|
Reference in New Issue
Block a user