Files
wwdpublic/Content.Shared/Language/LanguagePrototype.cs
Mnemotechnican 92dcd724d4 Refactor Sign Languages and Language Markers (#575)
# Description
This refactors #510 and #553. #553 specifically was reverted and
re-implemented from scratch. As a consequence to all of this, the chat
system was refactored a bit too, hopefully for the best.

Changes:
- InGameICChatType, InGameOOCChatType, ChatTransmitRange were all moved
to shared and made serializable
- Added a method to wrap whisper messages to reduce code duplication in
chat system
- Both WrapPublicMethod and WrapWhisperMessage call the same generic
WrapMessage method, which allows to add speech verbs to whispers and
more. That method is also fully responsible for adding language markers
and deducing speech verbs now.
- Everything related to speech was moved out of LanguagePrototype and
into SpeechOverrideInfo. LanguagePrototype now holds an instance of
that.
- Added AllowRadio, RequireSpeech, ChatTypeOverride,
SpeechVerbOverrides, MessageWrapOverrides to SpeechOverrideInfo, all of
which are used in implementing the sign language.
- Suffered a lot

# TODO
- [X] Cry
- [X] Fix the sign language not displaying properly over the character.
- [X] Find a way to circumvent being unable to speak??

<details><summary><h1>Media</h1></summary><p>


![image](https://github.com/user-attachments/assets/845ec5d3-20aa-4786-bdc8-c39c80e0a4a3)

See below

</p></details>

# Changelog
No cl no fun

---------

Signed-off-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com>
Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
2024-07-26 13:11:42 -07:00

81 lines
2.4 KiB
C#

using Content.Shared.Chat;
using Robust.Shared.Prototypes;
namespace Content.Shared.Language;
[Prototype("language")]
public sealed class LanguagePrototype : IPrototype
{
[IdDataField]
public string ID { get; private set; } = default!;
/// <summary>
/// Obfuscation method used by this language. By default, uses <see cref="ObfuscationMethod.Default"/>
/// </summary>
[DataField("obfuscation")]
public ObfuscationMethod Obfuscation = ObfuscationMethod.Default;
/// <summary>
/// Speech overrides used for messages sent in this language.
/// </summary>
[DataField("speech")]
public SpeechOverrideInfo SpeechOverride = new();
#region utility
/// <summary>
/// The in-world name of this language, localized.
/// </summary>
public string Name => Loc.GetString($"language-{ID}-name");
/// <summary>
/// The in-world description of this language, localized.
/// </summary>
public string Description => Loc.GetString($"language-{ID}-description");
#endregion utility
}
[DataDefinition]
public sealed partial class SpeechOverrideInfo
{
[DataField]
public Color Color = Color.White;
[DataField]
public string? FontId;
[DataField]
public int? FontSize;
[DataField]
public bool AllowRadio = true;
/// <summary>
/// If false, the entity can use this language even when it's unable to speak (i.e. muffled or muted),
/// and accents are not applied to messages in this language.
/// </summary>
[DataField]
public bool RequireSpeech = true;
/// <summary>
/// If not null, all messages in this language will be forced to be spoken in this chat type.
/// </summary>
[DataField]
public InGameICChatType? ChatTypeOverride;
/// <summary>
/// Speech verb overrides. If not provided, the default ones for the entity are used.
/// </summary>
[DataField]
public List<LocId>? SpeechVerbOverrides;
/// <summary>
/// Overrides for different kinds chat message wraps. If not provided, the default ones are used.
/// </summary>
/// <remarks>
/// Currently, only local chat and whispers support this. Radio and emotes are unaffected.
/// This is horrible.
/// </remarks>
[DataField]
public Dictionary<InGameICChatType, LocId> MessageWrapOverrides = new();
}