Typing indicator (typing chat bubble) (#8215)

This commit is contained in:
Alex Evgrashin
2022-05-17 12:55:19 +03:00
committed by GitHub
parent 2557e45662
commit af926c5279
55 changed files with 678 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
namespace Content.Shared.Chat.TypingIndicator;
/// <summary>
/// Sync typing indicator icon between client and server.
/// </summary>
public abstract class SharedTypingIndicatorSystem : EntitySystem
{
}

View File

@@ -0,0 +1,20 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Chat.TypingIndicator;
/// <summary>
/// Networked event from client.
/// Send to server when client started/stopped typing in chat input field.
/// </summary>
[Serializable, NetSerializable]
public sealed class TypingChangedEvent : EntityEventArgs
{
public readonly EntityUid Uid;
public readonly bool IsTyping;
public TypingChangedEvent(EntityUid uid, bool isTyping)
{
Uid = uid;
IsTyping = isTyping;
}
}

View File

@@ -0,0 +1,20 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Chat.TypingIndicator;
/// <summary>
/// Show typing indicator icon when player typing text in chat box.
/// Added automatically when player poses entity.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Friend(typeof(SharedTypingIndicatorSystem))]
public sealed class TypingIndicatorComponent : Component
{
/// <summary>
/// Prototype id that store all visual info about typing indicator.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("proto", customTypeSerializer: typeof(PrototypeIdSerializer<TypingIndicatorPrototype>))]
public string Prototype = "default";
}

View File

@@ -0,0 +1,27 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Chat.TypingIndicator;
/// <summary>
/// Prototype to store chat typing indicator visuals.
/// </summary>
[Prototype("typingIndicator")]
public sealed class TypingIndicatorPrototype : IPrototype
{
[IdDataFieldAttribute]
public string ID { get; } = default!;
[DataField("spritePath")]
public ResourcePath SpritePath = new("/Textures/Effects/speech.rsi");
[DataField("typingState", required: true)]
public string TypingState = default!;
[DataField("offset")]
public Vector2 Offset = new(0.5f, 0.5f);
[DataField("shader")]
public string Shader = "unshaded";
}

View File

@@ -0,0 +1,15 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Chat.TypingIndicator;
[Serializable, NetSerializable]
public enum TypingIndicatorVisuals : byte
{
IsTyping
}
[Serializable]
public enum TypingIndicatorLayers : byte
{
Base
}