* UI is an abbreviation, in XAML. * Chat improvements. Changing the "selected" channel on the chat box is now only done via the tab cycle or clicking the button. Prefix chars like [ will temporarily replace the active chat channel. This is based 100% on message box contents so there's no input eating garbage or anything. Pressing specific channel focusing keys inserts the correct prefix character, potentially replacing an existing one. Existing chat contents are left in place just fine and selected so you can easily delete them (but are not forced to). Channel focusing keys now match the QWERTY key codes. Deadchat works now. Console can no longer be selected as a chat channel, but you can still use it with the / prefix. Refactored the connection between chat manager and chat box so that it's event based, reducing tons of spaghetti everywhere. Main chat box control uses XAML now. General cleanup. Added focus hotkeys for deadchat/console. Also added prefix for deadchat. Local chat is mapped to deadchat when a ghost. Probably more stuff I can't think of right now. * Add preferred channel system to chat box to automatically select local. I can't actually test this works because the non-lobby chat box code is complete disastrous spaghetti and i need to refactor it. * Move chatbox resizing and all that to a subclass. Refine preferred channel & deadchat mapping code further. * Don't do prefixes for channels you don't have access to. * Change format on channel select popup. * Clean up code with console handling somewhat.
81 lines
2.5 KiB
C#
81 lines
2.5 KiB
C#
using JetBrains.Annotations;
|
|
using Lidgren.Network;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Network;
|
|
|
|
namespace Content.Shared.Chat
|
|
{
|
|
/// <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;
|
|
|
|
/// <summary>
|
|
/// The channel the message is on. This can also change whether certain params are used.
|
|
/// </summary>
|
|
public ChatChannel Channel { get; set; }
|
|
|
|
/// <summary>
|
|
/// The actual message contents.
|
|
/// </summary>
|
|
public string Message { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// What to "wrap" the message contents with. Example is stuff like 'Joe says: "{0}"'
|
|
/// </summary>
|
|
public string MessageWrap { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// The sending entity.
|
|
/// Only applies to <see cref="ChatChannel.Local"/>, <see cref="ChatChannel.Dead"/> and <see cref="ChatChannel.Emotes"/>.
|
|
/// </summary>
|
|
public EntityUid SenderEntity { get; set; }
|
|
|
|
/// <summary>
|
|
/// The override color of the message
|
|
/// </summary>
|
|
public Color MessageColorOverride { get; set; } = Color.Transparent;
|
|
|
|
|
|
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
|
{
|
|
Channel = (ChatChannel) buffer.ReadInt16();
|
|
Message = buffer.ReadString();
|
|
MessageWrap = buffer.ReadString();
|
|
|
|
switch (Channel)
|
|
{
|
|
case ChatChannel.Local:
|
|
case ChatChannel.Dead:
|
|
case ChatChannel.Admin:
|
|
case ChatChannel.Emotes:
|
|
SenderEntity = buffer.ReadEntityUid();
|
|
break;
|
|
}
|
|
MessageColorOverride = buffer.ReadColor();
|
|
}
|
|
|
|
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
|
{
|
|
buffer.Write((short)Channel);
|
|
buffer.Write(Message);
|
|
buffer.Write(MessageWrap);
|
|
|
|
switch (Channel)
|
|
{
|
|
case ChatChannel.Local:
|
|
case ChatChannel.Dead:
|
|
case ChatChannel.Admin:
|
|
case ChatChannel.Emotes:
|
|
buffer.Write(SenderEntity);
|
|
break;
|
|
}
|
|
buffer.Write(MessageColorOverride);
|
|
}
|
|
}
|
|
}
|