Skip to content

Commit

Permalink
Merge remote-tracking branch 'EE-Fox/Sign/Language' into sign/language
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxoTrystan committed Jul 20, 2024
2 parents 4f6f763 + c6c1b14 commit fa82d5a
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 9 deletions.
54 changes: 46 additions & 8 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,17 @@ public void TrySendInGameICMessage(
if (string.IsNullOrEmpty(message))
return;

// Check if the message is in sign language
if (desiredType == InGameICChatType.Speak || desiredType == InGameICChatType.Whisper)
{
var language = languageOverride ?? _language.GetLanguage(source);
if (language.SignLanguage ?? false)
{
SendEntityEmote(source, message, range, nameOverride, ignoreActionBlocker, signLanguage: true, languageOverride: languageOverride);
return;
}
}

// This message may have a radio prefix, and should then be whispered to the resolved radio channel
if (checkRadioPrefix)
{
Expand Down Expand Up @@ -576,7 +587,9 @@ private void SendEntityEmote(
bool hideLog = false,
bool checkEmote = true,
bool ignoreActionBlocker = false,
NetUserId? author = null
NetUserId? author = null,
LanguagePrototype? languageOverride = null,
bool? signLanguage = false
)
{
if (!_actionBlocker.CanEmote(source) && !ignoreActionBlocker)
Expand All @@ -586,15 +599,32 @@ private void SendEntityEmote(
var ent = Identity.Entity(source, EntityManager);
string name = FormattedMessage.EscapeText(nameOverride ?? Name(ent));

var language = languageOverride ?? _language.GetLanguage(source);

// Emotes use Identity.Name, since it doesn't actually involve your voice at all.
var wrappedMessage = Loc.GetString("chat-manager-entity-me-wrap-message",
("entityName", name),
("entity", ent),
("message", FormattedMessage.RemoveMarkup(action)));
var wrappedMessage = "";
var obfuscatedWrappedMessage = "";
if (signLanguage == true)
{
wrappedMessage = Loc.GetString("entity-signlanguage-message",
("entityName", name),
("message", FormattedMessage.EscapeText(action)));

obfuscatedWrappedMessage = Loc.GetString(_language.ObfuscateSpeech(action, language),
("entityName", name));
}
else
{
wrappedMessage = Loc.GetString("chat-manager-entity-me-wrap-message",
("entityName", name),
("entity", ent),
("message", FormattedMessage.RemoveMarkup(action)));

}

if (checkEmote)
TryEmoteChatInput(source, action);
SendInVoiceRange(ChatChannel.Emotes, name, action, wrappedMessage, obfuscated: "", obfuscatedWrappedMessage: "", source, range, author);
SendInVoiceRange(ChatChannel.Emotes, name, action, wrappedMessage, obfuscated: "", obfuscatedWrappedMessage, source, range, author, signLanguage: true);
if (!hideLog)
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Emote from {ToPrettyString(source):user} as {name}: {action}");
Expand Down Expand Up @@ -749,7 +779,7 @@ private MessageRangeCheckResult MessageRangeCheck(ICommonSession session, ICChat
/// <summary>
/// Sends a chat message to the given players in range of the source entity.
/// </summary>
private void SendInVoiceRange(ChatChannel channel, string name, string message, string wrappedMessage, string obfuscated, string obfuscatedWrappedMessage, EntityUid source, ChatTransmitRange range, NetUserId? author = null, LanguagePrototype? languageOverride = null)
private void SendInVoiceRange(ChatChannel channel, string name, string message, string wrappedMessage, string obfuscated, string obfuscatedWrappedMessage, EntityUid source, ChatTransmitRange range, NetUserId? author = null, LanguagePrototype? languageOverride = null, bool? signLanguage = false)
{
var language = languageOverride ?? _language.GetLanguage(source);
foreach (var (session, data) in GetRecipients(source, VoiceRange))
Expand All @@ -762,9 +792,17 @@ private void SendInVoiceRange(ChatChannel channel, string name, string message,
continue;
EntityUid listener = session.AttachedEntity.Value;

// Quickly Checking if the Emote is a real one or Sign Language.
var notSignLanguage = false;
if (channel == ChatChannel.Emotes)
{
notSignLanguage = true;
if (signLanguage == true)
notSignLanguage = false;
}

// If the channel does not support languages, or the entity can understand the message, send the original message, otherwise send the obfuscated version
if (channel == ChatChannel.LOOC || channel == ChatChannel.Emotes || _language.CanUnderstand(listener, language.ID))
if (channel == ChatChannel.LOOC || notSignLanguage || _language.CanUnderstand(listener, language.ID))
{
_chatManager.ChatMessageToOne(channel, message, wrappedMessage, source, entHideChat, session.Channel, author: author);
}
Expand Down
8 changes: 7 additions & 1 deletion Content.Shared/Language/LanguagePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public sealed class LanguagePrototype : IPrototype

[DataField("fontSize")]
public int? FontSize;


/// <summary>
/// If true, will mark the language as a SignLanguage and will be handled as such.
/// </summary>
[DataField("signLanguage")]
public bool? SignLanguage;

/// <summary>
/// Obfuscation method used by this language. By default, uses <see cref="ObfuscationMethod.Default"/>
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/language/languages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ language-Universal-description = What are you?
language-GalacticCommon-name = Galactic common
language-GalacticCommon-description = The standard Galatic language, most commonly used for inter-species communications and legal work.
language-SignLanguage-name = Sign Language
language-SignLanguage-description = The standard Galactic sign language, used by those that are unable to speak Galactic Common or at all.
language-Bubblish-name = Bubblish
language-Bubblish-description = The language of Slimes. Being a mixture of bubbling noises and pops it's very difficult to speak for humans without the use of mechanical aids.
Expand Down
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/language/sign-language.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
entity-signlanguage-message = [italic]{$entityName} signs "[BubbleContent]{$message}[/BubbleContent]"[/italic]
language-signlanguage-1 = [italic]{$entityName} signs something.[/italic]
language-signlanguage-2 = [italic]{$entityName} makes weird hand gestures.[/italic]
9 changes: 9 additions & 0 deletions Resources/Prototypes/Language/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
- nah
- wah

- type: language
id: SignLanguage
signLanguage: true
obfuscation:
!type:ReplacementObfuscation
replacement:
- "language-signlanguage-1"
- "language-signlanguage-2"

# Spoken by slimes.
- type: language
id: Bubblish
Expand Down

0 comments on commit fa82d5a

Please sign in to comment.