Skip to content

Commit

Permalink
Sign Languages! (#553)
Browse files Browse the repository at this point in the history
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Gives a new way to speak, Sign Languages using the Language system by
only adding a nullable variable.
Sign Language uses the default Emote system, meaning its will not get
picked up by Radio or others devices or get blocked by accents.

When a Sign Language is on, "Say/Whisper" will talk in Sign Language,
Emote will still act like normal emotes.

The Glorious Sign Language has arrived... and there can be more then
one!

---

<!--
This is default collapsed, readers click to expand it and see all your
media
The PR media section can get very large at times, so this is a good way
to keep it clean
The title is written using HTML tags
The title must be within the <summary> tags or you won't see it
-->

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


![image](https://github.com/user-attachments/assets/ac0c1a57-da49-4419-bb75-da0a308eee7d)

![image](https://github.com/user-attachments/assets/0739a740-4adf-4ba1-a852-0a382a534d8d)

</p>
</details>

---

# Changelog

<!--
You can add an author after the `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

:cl: FoxxoTrystan
- add: Added the ability to speak with Sign Language.
  • Loading branch information
FoxxoTrystan authored Jul 19, 2024
1 parent 9e57377 commit 61719b7
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 @@ -573,7 +584,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 @@ -583,15 +596,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 @@ -705,7 +735,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 @@ -718,9 +748,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 61719b7

Please sign in to comment.