Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Sign Languages and Language Markers #575

Merged
1 change: 1 addition & 0 deletions Content.Server/Administration/Commands/DSay.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Shared.Console;

namespace Content.Server.Administration.Commands
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Administration/Commands/OSay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Administration.Logs;
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Content.Shared.Database;
using Robust.Shared.Console;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Advertise.Components;
using Content.Server.Chat.Systems;
using Content.Server.Power.Components;
using Content.Shared.Chat;
using Content.Shared.VendingMachines;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Chat.Systems;
using Content.Server.UserInterface;
using Content.Shared.Advertise;
using Content.Shared.Chat;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

Expand Down
1 change: 1 addition & 0 deletions Content.Server/Chat/Commands/LOOCCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Shared.Console;
using Robust.Shared.Enums;

Expand Down
1 change: 1 addition & 0 deletions Content.Server/Chat/Commands/MeCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Shared.Console;
using Robust.Shared.Enums;

Expand Down
1 change: 1 addition & 0 deletions Content.Server/Chat/Commands/SayCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Shared.Console;
using Robust.Shared.Enums;

Expand Down
1 change: 1 addition & 0 deletions Content.Server/Chat/Commands/WhisperCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Shared.Console;
using Robust.Shared.Enums;

Expand Down
1 change: 1 addition & 0 deletions Content.Server/Chat/Systems/AutoEmoteSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Shared.Chat;
using Content.Shared.Chat.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand Down
4 changes: 3 additions & 1 deletion Content.Server/Chat/Systems/ChatSystem.Emote.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Frozen;
using Content.Shared.Chat;
using Content.Shared.Chat.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand Down Expand Up @@ -85,7 +86,8 @@ public void TryEmoteWithChat(
{
// not all emotes are loc'd, but for the ones that are we pass in entity
var action = Loc.GetString(_random.Pick(emote.ChatMessages), ("entity", source));
SendEntityEmote(source, action, range, nameOverride, hideLog: hideLog, checkEmote: false, ignoreActionBlocker: ignoreActionBlocker);
var language = _language.GetLanguage(source);
SendEntityEmote(source, action, range, nameOverride, language, hideLog: hideLog, checkEmote: false, ignoreActionBlocker: ignoreActionBlocker);
}

// do the rest of emote event logic here
Expand Down
176 changes: 62 additions & 114 deletions Content.Server/Chat/Systems/ChatSystem.cs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Content.Server/Chat/Systems/EmoteOnDamageSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Content.Shared.Chat;

namespace Content.Server.Chat.Systems;

using Content.Shared.Chat.Prototypes;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Chemistry/ReagentEffects/Emote.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Chat.Systems;
using Content.Shared.Chat;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Cloning/CloningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
using Content.Shared.SSDIndicator;
using Content.Shared.Damage.ForceSay;
using Content.Server.Polymorph.Components;
using Content.Shared.Chat;

namespace Content.Server.Cloning
{
Expand Down Expand Up @@ -248,7 +249,7 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponen
}
// end of genetic damage checks

var mob = FetchAndSpawnMob(clonePod, pref, speciesPrototype, humanoid, bodyToClone, karmaBonus); //DeltaV Replaces CloneAppearance with Metem/Clone via FetchAndSpawnMob
var mob = FetchAndSpawnMob(clonePod, pref, speciesPrototype, humanoid, bodyToClone, karmaBonus); //DeltaV Replaces CloneAppearance with Metem/Clone via FetchAndSpawnMob

///Nyano - Summary: adds the potential psionic trait to the reanimated mob.
EnsureComp<PotentialPsionicComponent>(mob);
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Cluwne/CluwneSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Robust.Shared.Prototypes;
using Content.Server.Emoting.Systems;
using Content.Server.Speech.EntitySystems;
using Content.Shared.Chat;
using Content.Shared.Cluwne;
using Content.Shared.Interaction.Components;
using Robust.Shared.Audio;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/DeltaV/NPC/Roboisseur/RoboisseurSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Shared.Kitchen;
using Robust.Server.GameObjects;
using Content.Server.Materials;
using Content.Shared.Chat;
using Robust.Shared.Player;
using Robust.Shared.Timing;

Expand Down
1 change: 1 addition & 0 deletions Content.Server/Language/Commands/SayLanguageCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Shared.Console;
using Robust.Shared.Enums;

Expand Down
1 change: 1 addition & 0 deletions Content.Server/Magic/MagicSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Server.Weapons.Ranged.Systems;
using Content.Shared.Actions;
using Content.Shared.Body.Components;
using Content.Shared.Chat;
using Content.Shared.Coordinates.Helpers;
using Content.Shared.DoAfter;
using Content.Shared.Doors.Components;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Medical/DefibrillatorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Server.Ghost;
using Content.Server.Popups;
using Content.Server.PowerCell;
using Content.Shared.Chat;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
using Content.Shared.Interaction;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Mobs/CritMobActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Chat.Systems;
using Content.Server.Popups;
using Content.Server.Speech.Muting;
using Content.Shared.Chat;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Chat.Systems;
using Content.Shared.Chat;

namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Chat.Systems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.NPC.Components;
using Content.Shared.Chat;
using Content.Shared.Damage;
using Content.Shared.Emag.Components;
using Content.Shared.Interaction;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Nyanotrasen/Chat/TSayCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Nyanotrasen/Mail/MailSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using Content.Shared.Access;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Chat;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Damage;
using Content.Shared.Emag.Components;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Server.Radio.Components;
using Content.Server.Radio.EntitySystems;
using Content.Server.StationEvents.Events;
using Content.Shared.Chat;
using Content.Shared.Interaction;
using Content.Shared.Psionics.Glimmer;
using Content.Shared.Radio;
Expand Down
9 changes: 6 additions & 3 deletions Content.Server/Radio/EntitySystems/RadioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public void SendRadioMessage(EntityUid messageSource, string message, RadioChann
if (language == null)
language = _language.GetLanguage(messageSource);

if (!language.SpeechOverride.AllowRadio)
return;

// TODO if radios ever garble / modify messages, feedback-prevention needs to be handled better than this.
if (!_messages.Add(message))
return;
Expand Down Expand Up @@ -178,9 +181,9 @@ private string WrapRadioMessage(EntityUid source, RadioChannelPrototype channel,
var speech = _chat.GetSpeechVerb(source, message);
return Loc.GetString(speech.Bold ? "chat-radio-message-wrap-bold" : "chat-radio-message-wrap",
("color", channel.Color),
("languageColor", language.Color ?? channel.Color),
("fontType", language.FontId ?? speech.FontId),
("fontSize", language.FontSize ?? speech.FontSize),
("languageColor", language.SpeechOverride.Color),
("fontType", language.SpeechOverride.FontId ?? speech.FontId),
("fontSize", language.SpeechOverride.FontSize ?? speech.FontSize),
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
("channel", $"\\[{channel.LocalizedName}\\]"),
("name", name),
Expand Down
1 change: 1 addition & 0 deletions Content.Server/RatKing/RatKingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Server.NPC.Systems;
using Content.Server.Popups;
using Content.Shared.Atmos;
using Content.Shared.Chat;
using Content.Shared.Dataset;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Speech/Systems/RandomBarkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Mind.Components;
using Robust.Shared.Random;
using Content.Server.Speech.Components;
using Content.Shared.Chat;

namespace Content.Server.Speech.Systems;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Chat.Systems;
using Content.Server.Speech;
using Content.Shared.Chat;
using Content.Shared.Speech;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Weapons/Melee/MeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Robust.Shared.Random;
using System.Linq;
using System.Numerics;
using Content.Shared.Chat;

namespace Content.Server.Weapons.Melee;

Expand Down
42 changes: 41 additions & 1 deletion Content.Shared/Chat/SharedChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Radio;
using Content.Shared.Speech;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;

namespace Content.Shared.Chat;
Expand All @@ -21,7 +22,7 @@ public abstract class SharedChatSystem : EntitySystem
public const char EmotesAltPrefix = '*';
public const char AdminPrefix = ']';
public const char WhisperPrefix = ',';
public const char TelepathicPrefix = '='; //Nyano - Summary: Adds the telepathic channel's prefix.
public const char TelepathicPrefix = '='; //Nyano - Summary: Adds the telepathic channel's prefix.
public const char DefaultChannelKey = 'h';

[ValidatePrototypeId<RadioChannelPrototype>]
Expand Down Expand Up @@ -243,3 +244,42 @@ public static string GetStringInsideTag(ChatMessage message, string tag)
return rawmsg.Substring(tagStart, tagEnd - tagStart);
}
}

/// <summary>
/// InGame IC chat is for chat that is specifically ingame (not lobby) but is also in character, i.e. speaking.
/// </summary>
// ReSharper disable once InconsistentNaming
[Serializable, NetSerializable]
public enum InGameICChatType : byte
{
Speak,
Emote,
Whisper,
Telepathic //Nyano - Summary: adds telepathic as a type of message users can receive.
}

/// <summary>
/// InGame OOC chat is for chat that is specifically ingame (not lobby) but is OOC, like deadchat or LOOC.
/// </summary>
[Serializable, NetSerializable]
public enum InGameOOCChatType : byte
{
Looc,
Dead
}

/// <summary>
/// Controls transmission of chat.
/// </summary>
[Serializable, NetSerializable]
public enum ChatTransmitRange : byte
{
/// Acts normal, ghosts can hear across the map, etc.
Normal,
/// Normal but ghosts are still range-limited.
GhostRangeLimit,
/// Hidden from the chat window.
HideChat,
/// Ghosts can't hear or see it at all. Regular players can if in-range.
NoGhosts
}
60 changes: 45 additions & 15 deletions Content.Shared/Language/LanguagePrototype.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.Chat;
using Robust.Shared.Prototypes;

namespace Content.Shared.Language;
Expand All @@ -8,27 +9,18 @@ public sealed class LanguagePrototype : IPrototype
[IdDataField]
public string ID { get; private set; } = default!;

[DataField("color")]
public Color? Color;

[DataField("fontId")]
public string? FontId;

[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>
[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.
Expand All @@ -41,3 +33,41 @@ public sealed class LanguagePrototype : IPrototype
public string Description => Loc.GetString($"language-{ID}-description");
#endregion utility
}

[DataDefinition]
public sealed partial class SpeechOverrideInfo
{
[DataField]
public Color Color = Color.LightGray;

[DataField]
public string? FontId;

[DataField]
public int? FontSize;

[DataField]
public bool AllowRadio = 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();
}
6 changes: 6 additions & 0 deletions Resources/Locale/en-US/language/languages-sign.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
chat-sign-language-message-wrap = [italic]{$entityName} {$verb} [font="{$fontType}" size={$fontSize}][color={$color}]{$message}[/color][/font][/italic]
chat-sign-language-whisper-wrap = [italic]{$entityName} subtly {$verb} [font="{$fontType}" size={$fontSize}][color={$color}]{$message}[/color][/font][/italic]

chat-speech-verb-sign-1 = gestures
chat-speech-verb-sign-2 = signs
chat-speech-verb-sign-3 = waves
Loading
Loading