Update events/UI to reflect new chat
This commit is contained in:
@@ -58,14 +58,14 @@ namespace Torch.API.Managers
|
||||
/// <param name="authorSteamId">Author's steam ID</param>
|
||||
/// <param name="message">Message</param>
|
||||
/// <param name="font">Font</param>
|
||||
public TorchChatMessage(ulong authorSteamId, string message, string font = MyFontEnum.Blue)
|
||||
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 = ChatChannel.Global;
|
||||
Target = 0;
|
||||
Channel = channel;
|
||||
Target = target;
|
||||
Font = font;
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,8 @@ using NLog;
|
||||
using Torch;
|
||||
using Sandbox;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Game.Gui;
|
||||
using Sandbox.Game.Multiplayer;
|
||||
using Sandbox.Game.World;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
@@ -131,6 +133,15 @@ namespace Torch.Server
|
||||
bool atBottom = ChatScroller.VerticalOffset + 8 > ChatScroller.ScrollableHeight;
|
||||
var span = new Span();
|
||||
span.Inlines.Add($"{msg.Timestamp} ");
|
||||
switch (msg.Channel)
|
||||
{
|
||||
case ChatChannel.Faction:
|
||||
span.Inlines.Add(new Run($"[{MySession.Static.Factions.TryGetFactionById(msg.Target)?.Tag ?? "???"}] ") { Foreground = Brushes.Green });
|
||||
break;
|
||||
case ChatChannel.Private:
|
||||
span.Inlines.Add(new Run($"[to {MySession.Static.Players.TryGetIdentity(msg.Target)?.DisplayName ?? "???"}] ") { Foreground = Brushes.DeepPink });
|
||||
break;
|
||||
}
|
||||
span.Inlines.Add(new Run(msg.Author) { Foreground = LookupBrush(msg.Font) });
|
||||
span.Inlines.Add($": {msg.Message}");
|
||||
span.Inlines.Add(new LineBreak());
|
||||
|
@@ -127,7 +127,7 @@ namespace Torch.Managers.ChatManager
|
||||
|
||||
private void Multiplayer_ChatMessageReceived(ulong steamUserId, string messageText, ChatChannel channel, long targetId, string customAuthorName)
|
||||
{
|
||||
var torchMsg = new TorchChatMessage(steamUserId, messageText,
|
||||
var torchMsg = new TorchChatMessage(steamUserId, messageText, channel, targetId,
|
||||
(steamUserId == MyGameService.UserId) ? MyFontEnum.DarkBlue : MyFontEnum.Blue);
|
||||
if (!RaiseMessageRecieved(torchMsg) && HasHud)
|
||||
_hudChatMessageReceived.Invoke(MyHud.Chat, steamUserId, messageText, channel, targetId, customAuthorName);
|
||||
|
@@ -61,7 +61,7 @@ namespace Torch.Managers.ChatManager
|
||||
{
|
||||
if (targetSteamId == Sync.MyId)
|
||||
{
|
||||
RaiseMessageRecieved(new TorchChatMessage(authorId, message));
|
||||
RaiseMessageRecieved(new TorchChatMessage(authorId, message, ChatChannel.Global, 0));
|
||||
return;
|
||||
}
|
||||
if (MyMultiplayer.Static == null)
|
||||
@@ -131,7 +131,7 @@ namespace Torch.Managers.ChatManager
|
||||
MessageProcessing?.Invoke(torchMsg, ref consumed);
|
||||
|
||||
if (!consumed)
|
||||
_chatLog.Info($"{torchMsg.Author}: {torchMsg.Message}");
|
||||
_chatLog.Info($"[{torchMsg.Channel}:{torchMsg.Target}] {torchMsg.Author}: {torchMsg.Message}");
|
||||
}
|
||||
|
||||
public static string GetMemberName(ulong steamId)
|
||||
|
Reference in New Issue
Block a user