mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* ports chat follow function from AL and removes PJB implementation forgor to commit earlier so it's just one chunk * fixes accidental MiscTab.xaml restructuring * fix name color * remove unused function * cvar summary * typo * accidental doc removal * fix test fail * fix test fail * like i said first pr :| * inject in constructor * adds chat links to Local, Whisper, LOOC and Dead Chat respects Admin ghost privacy * i hate chat code * remove cvar * single events file * adds CanGhostWarp back * filter for admin ghosts * move tag * remove ChatLinkTag.cs * fix speechbubble rendering * i want to bash my brain in * kill chatcode * formatting * testfail * still not working * atleast deadchat works now * even prettier TextLinkTag.cs * fix speechbubble rendering for looc * docs * renaming and better docs * Revert "remove cvar" This reverts commit 1acb168f * final changes (hopefully) * requested changes * can't parse - * change TextLinkTag again * formatting and typo Co-authored-by: Connor Huffine <chuffine@gmail.com> * quickfix * no logging for now actually * i will work on this in the morning * restructuring * wip * final restructuring and docs * still not done btw * review * docfix * actually we can filter for admin ghosts * doc * fix color * fix fix color * review * all I care to clean up * bold names * doc * admin warp * fixed * fsaasffsa * GOD ONCE SAID: GOOD ENOUGH * they call me the shuffler * admin chat links * forgor newline * fix? * actual fix * dumb stuff * chungus --------- Co-authored-by: Connor Huffine <chuffine@gmail.com> Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
84 lines
2.9 KiB
C#
84 lines
2.9 KiB
C#
using System.IO;
|
|
using JetBrains.Annotations;
|
|
using Lidgren.Network;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Shared.Chat
|
|
{
|
|
[Serializable, NetSerializable]
|
|
public sealed class ChatMessage
|
|
{
|
|
public ChatChannel Channel;
|
|
|
|
/// <summary>
|
|
/// This is the text spoken by the entity, after accents and such were applied.
|
|
/// This should have <see cref="FormattedMessage.EscapeText"/> applied before using it in any rich text box.
|
|
/// </summary>
|
|
public string Message;
|
|
|
|
/// <summary>
|
|
/// This is the <see cref="Message"/> but with special characters escaped and wrapped in some rich text
|
|
/// formatting tags.
|
|
/// </summary>
|
|
public string WrappedMessage;
|
|
|
|
public NetEntity SenderEntity;
|
|
|
|
/// <summary>
|
|
/// Identifier sent when <see cref="SenderEntity"/> is <see cref="NetEntity.Invalid"/>
|
|
/// if this was sent by a player to assign a key to the sender of this message.
|
|
/// This is unique per sender.
|
|
/// </summary>
|
|
public int? SenderKey;
|
|
|
|
public bool HideChat;
|
|
public Color? MessageColorOverride;
|
|
public string? AudioPath;
|
|
public float AudioVolume;
|
|
|
|
[NonSerialized]
|
|
public bool Read;
|
|
|
|
public ChatMessage(ChatChannel channel, string message, string wrappedMessage, NetEntity source, int? senderKey, bool hideChat = false, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
|
|
{
|
|
Channel = channel;
|
|
Message = message;
|
|
WrappedMessage = wrappedMessage;
|
|
SenderEntity = source;
|
|
SenderKey = senderKey;
|
|
HideChat = hideChat;
|
|
MessageColorOverride = colorOverride;
|
|
AudioPath = audioPath;
|
|
AudioVolume = audioVolume;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sent from server to client to notify the client about a new chat message.
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public sealed class MsgChatMessage : NetMessage
|
|
{
|
|
public override MsgGroups MsgGroup => MsgGroups.Command;
|
|
|
|
public ChatMessage Message = default!;
|
|
|
|
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
|
|
{
|
|
var length = buffer.ReadVariableInt32();
|
|
using var stream = new MemoryStream(length);
|
|
buffer.ReadAlignedMemory(stream, length);
|
|
serializer.DeserializeDirect(stream, out Message);
|
|
}
|
|
|
|
public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
|
|
{
|
|
var stream = new MemoryStream();
|
|
serializer.SerializeDirect(stream, Message);
|
|
buffer.WriteVariableInt32((int) stream.Length);
|
|
buffer.Write(stream.AsSpan());
|
|
}
|
|
}
|
|
}
|