Skip to content

Commit

Permalink
Refactor Sign Languages and Language Markers (Simple-Station#575)
Browse files Browse the repository at this point in the history
# Description
This refactors Simple-Station#510 and Simple-Station#553. Simple-Station#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 <[email protected]>
Co-authored-by: Danger Revolution! <[email protected]>
  • Loading branch information
Mnemotechnician and DangerRevolution authored Jul 26, 2024
1 parent 2ec1a03 commit 92dcd72
Show file tree
Hide file tree
Showing 37 changed files with 267 additions and 172 deletions.
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
1 change: 1 addition & 0 deletions Content.Server/Advertise/EntitySystems/AdvertiseSystem.cs
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,5 +1,6 @@
using System.Collections.Frozen;
using System.Linq;
using Content.Shared.Chat;
using Content.Shared.Chat.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand Down Expand Up @@ -87,7 +88,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
195 changes: 73 additions & 122 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
12 changes: 9 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 @@ -176,11 +179,14 @@ public void SendRadioMessage(EntityUid messageSource, string message, RadioChann
private string WrapRadioMessage(EntityUid source, RadioChannelPrototype channel, string name, string message, LanguagePrototype language)
{
var speech = _chat.GetSpeechVerb(source, message);
// TODO this is done just to preserve the old look of radio, perhaps we can change it as well?
var languageColor = language.SpeechOverride.Color == Color.White ? channel.Color : language.SpeechOverride.Color;

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", languageColor),
("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
7 changes: 6 additions & 1 deletion Content.Server/Speech/Muting/MutingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Abilities.Mime;
using Content.Server.Chat.Systems;
using Content.Server.Language;
using Content.Server.Popups;
using Content.Server.Speech.Components;
using Content.Server.Speech.EntitySystems;
Expand All @@ -12,7 +13,9 @@ namespace Content.Server.Speech.Muting
{
public sealed class MutingSystem : EntitySystem
{
[Dependency] private readonly LanguageSystem _languages = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;

public override void Initialize()
{
base.Initialize();
Expand Down Expand Up @@ -47,7 +50,9 @@ private void OnScreamAction(EntityUid uid, MutedComponent component, ScreamActio

private void OnSpeakAttempt(EntityUid uid, MutedComponent component, SpeakAttemptEvent args)
{
// TODO something better than this.
var language = _languages.GetLanguage(uid);
if (!language.SpeechOverride.RequireSpeech)
return; // Cannot mute if there's no speech involved

if (HasComp<MimePowersComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
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
}

/// <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
}
Loading

0 comments on commit 92dcd72

Please sign in to comment.