From d2f933d6d487a592c7ff8a032e0b5a3d413e9c6b Mon Sep 17 00:00:00 2001 From: lzk <124214523+lzk228@users.noreply.github.com> Date: Thu, 29 Aug 2024 13:51:52 +0200 Subject: [PATCH 1/2] Add TTS name examine --- Content.Server/Corvax/TTS/TTSExamineSystem.cs | 68 +++++++++++++++++++ .../Locale/ru-RU/corvax/tts/tts-examine.ftl | 3 + 2 files changed, 71 insertions(+) create mode 100644 Content.Server/Corvax/TTS/TTSExamineSystem.cs create mode 100644 Resources/Locale/ru-RU/corvax/tts/tts-examine.ftl diff --git a/Content.Server/Corvax/TTS/TTSExamineSystem.cs b/Content.Server/Corvax/TTS/TTSExamineSystem.cs new file mode 100644 index 00000000000..9ddb944464b --- /dev/null +++ b/Content.Server/Corvax/TTS/TTSExamineSystem.cs @@ -0,0 +1,68 @@ +using Content.Server.VoiceMask; +using Content.Shared.Corvax.CCCVars; +using Content.Shared.Corvax.TTS; +using Content.Shared.Examine; +using Content.Shared.IdentityManagement; +using Content.Shared.Verbs; +using Robust.Shared.Configuration; +using Robust.Shared.Prototypes; +using Robust.Shared.Utility; + +namespace Content.Server.Corvax.TTS +{ + public sealed class DetailExaminableSystem : EntitySystem + { + [Dependency] private readonly ExamineSystemShared _examineSystem = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] protected readonly IConfigurationManager _configManager = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent>(OnGetExamineVerbs); + } + + private void OnGetExamineVerbs(EntityUid uid, TTSComponent component, GetVerbsEvent args) + { + // Don't show verb if no TTS enabled OR if user's name is hidden + if (!_configManager.GetCVar(CCCVars.TTSEnabled) || + Identity.Name(args.Target, EntityManager) != MetaData(args.Target).EntityName) + return; + + string? voiceId = string.Empty; + + // If user is wearing a voice mask, we will take its voice + if (TryComp(uid, out var voiceMask)) + voiceId = voiceMask.VoiceId; + else + voiceId = component.VoicePrototypeId; + + // Get the voice name + string voiceName = string.Empty; + if (_prototypeManager.TryIndex(voiceId ?? string.Empty, out var protoVoice)) + { + voiceName = Loc.GetString(protoVoice.Name); + } + + var detailsRange = _examineSystem.IsInDetailsRange(args.User, uid); + + var verb = new ExamineVerb() + { + Act = () => + { + var markup = new FormattedMessage(); + markup.AddMarkup(Loc.GetString("tts-examine-voice", ("name", voiceName))); + _examineSystem.SendExamineTooltip(args.User, uid, markup, false, false); + }, + Text = Loc.GetString("tts-examine"), + Category = VerbCategory.Examine, + Disabled = !detailsRange, + Message = detailsRange ? null : Loc.GetString("tts-examine-disabled"), + Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/Emotes/vocal.png")) + }; + + args.Verbs.Add(verb); + } + } +} diff --git a/Resources/Locale/ru-RU/corvax/tts/tts-examine.ftl b/Resources/Locale/ru-RU/corvax/tts/tts-examine.ftl new file mode 100644 index 00000000000..dbf2365d658 --- /dev/null +++ b/Resources/Locale/ru-RU/corvax/tts/tts-examine.ftl @@ -0,0 +1,3 @@ +tts-examine = Узнать голос TTS +tts-examine-voice = Голос TTS: [color=yellow]{$name}[/color]. +tts-examine-disabled = Осмотрите ближе From a0a5e3bfd080690a6d9889cbb45ca11a3be13f04 Mon Sep 17 00:00:00 2001 From: lzk <124214523+lzk228@users.noreply.github.com> Date: Thu, 29 Aug 2024 14:47:40 +0200 Subject: [PATCH 2/2] remove identity check --- Content.Server/Corvax/TTS/TTSExamineSystem.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Content.Server/Corvax/TTS/TTSExamineSystem.cs b/Content.Server/Corvax/TTS/TTSExamineSystem.cs index 9ddb944464b..1bdafc2b7f3 100644 --- a/Content.Server/Corvax/TTS/TTSExamineSystem.cs +++ b/Content.Server/Corvax/TTS/TTSExamineSystem.cs @@ -25,9 +25,8 @@ public override void Initialize() private void OnGetExamineVerbs(EntityUid uid, TTSComponent component, GetVerbsEvent args) { - // Don't show verb if no TTS enabled OR if user's name is hidden - if (!_configManager.GetCVar(CCCVars.TTSEnabled) || - Identity.Name(args.Target, EntityManager) != MetaData(args.Target).EntityName) + // Don't show verb if no TTS enabled + if (!_configManager.GetCVar(CCCVars.TTSEnabled)) return; string? voiceId = string.Empty;