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

Add TTS name examine #2535

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions Content.Server/Corvax/TTS/TTSExamineSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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<TTSComponent, GetVerbsEvent<ExamineVerb>>(OnGetExamineVerbs);
}

private void OnGetExamineVerbs(EntityUid uid, TTSComponent component, GetVerbsEvent<ExamineVerb> args)
{
// Don't show verb if no TTS enabled
if (!_configManager.GetCVar(CCCVars.TTSEnabled))
return;

string? voiceId = string.Empty;

// If user is wearing a voice mask, we will take its voice
if (TryComp<VoiceMaskComponent>(uid, out var voiceMask))
voiceId = voiceMask.VoiceId;
else
voiceId = component.VoicePrototypeId;

// Get the voice name
string voiceName = string.Empty;
if (_prototypeManager.TryIndex<TTSVoicePrototype>(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);
}
}
}
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/corvax/tts/tts-examine.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tts-examine = Узнать голос TTS
tts-examine-voice = Голос TTS: [color=yellow]{$name}[/color].
tts-examine-disabled = Осмотрите ближе
Loading