Skip to content

Commit 9dec14c

Browse files
authored
Merge pull request #607 from TorchAPI/ChatFix
Added new chat options from a few updates ago....
2 parents dd8e241 + 7f51215 commit 9dec14c

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

‎Torch.API/Managers/IChatManagerClient.cs‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
using System;
1+
using Sandbox.Engine.Multiplayer;
2+
using Sandbox.Game.Gui;
3+
using Sandbox.Game.Multiplayer;
4+
using System;
25
using System.Collections.Generic;
36
using System.Linq;
47
using System.Text;
58
using System.Threading.Tasks;
6-
using Sandbox.Engine.Multiplayer;
7-
using Sandbox.Game.Gui;
8-
using Sandbox.Game.Multiplayer;
99
using Torch.Utils;
1010
using VRage.Game;
11+
using VRage.GameServices;
1112
using VRage.Network;
1213
using VRage.Replication;
1314
using VRageMath;
@@ -54,6 +55,7 @@ public TorchChatMessage(string author, string message, Color color, string font
5455
Target = 0;
5556
Font = font;
5657
Color = color == default ? ColorUtils.TranslateColor(font) : color;
58+
CustomData = null;
5759
}
5860

5961
/// <summary>
@@ -73,6 +75,7 @@ public TorchChatMessage(string author, ulong authorSteamId, string message, Chat
7375
Target = target;
7476
Font = font;
7577
Color = color == default ? ColorUtils.TranslateColor(font) : color;
78+
CustomData = null;
7679
}
7780

7881
/// <summary>
@@ -91,6 +94,20 @@ public TorchChatMessage(ulong authorSteamId, string message, ChatChannel channel
9194
Target = target;
9295
Font = font;
9396
Color = color == default ? ColorUtils.TranslateColor(font) : color;
97+
CustomData = null;
98+
}
99+
100+
public TorchChatMessage(ChatMsg msg)
101+
{
102+
Timestamp = DateTime.Now;
103+
AuthorSteamId = msg.Author;
104+
Author = MyMultiplayer.Static?.GetMemberName(msg.Author) ?? "Player";
105+
Message = msg.Text;
106+
Channel = (ChatChannel)msg.Channel;
107+
Target = msg.TargetId;
108+
Font = DEFAULT_FONT;
109+
Color = default;
110+
CustomData = msg.CustomData;
94111
}
95112

96113
/// <summary>
@@ -125,6 +142,11 @@ public TorchChatMessage(ulong authorSteamId, string message, ChatChannel channel
125142
/// The chat message color.
126143
/// </summary>
127144
public readonly Color Color;
145+
146+
/// <summary>
147+
/// Chat message custom data, if any.
148+
/// </summary>
149+
public readonly ChatMessageCustomData? CustomData;
128150
}
129151

130152
/// <summary>

‎Torch/Managers/ChatManager/ChatManagerServer.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ internal static void Patch(PatchContext context)
4141

4242
private static bool PrefixMessageProcessing(ref ChatMsg msg)
4343
{
44+
45+
4446
var consumed = false;
4547
OnChatRecvAccess?.Invoke(ref msg);
4648
ChatManager.RaiseMessageRecieved(msg, ref consumed);
@@ -158,7 +160,7 @@ protected override bool OfflineMessageProcessor(TorchChatMessage msg)
158160

159161
internal void RaiseMessageRecieved(ChatMsg message, ref bool consumed)
160162
{
161-
var torchMsg = new TorchChatMessage(GetMemberName(message.Author), message.Author, message.Text, (ChatChannel)message.Channel, message.TargetId);
163+
var torchMsg = new TorchChatMessage(message);
162164
if (_muted.Contains(message.Author))
163165
{
164166
consumed = true;

0 commit comments

Comments
 (0)