Play button base
This commit is contained in:
@@ -26,6 +26,7 @@ using Content.Client.White.Jukebox;
|
||||
using Content.Client.White.Sponsors;
|
||||
using Content.Shared.Ame;
|
||||
using Content.Client.White.Stalin;
|
||||
using Content.Client.White.TTS;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Localizations;
|
||||
using Robust.Client;
|
||||
@@ -80,6 +81,7 @@ namespace Content.Client.Entry
|
||||
[Dependency] private readonly JoinQueueManager _queueManager = default!;
|
||||
[Dependency] private readonly StalinManager _stalinManager = default!;
|
||||
[Dependency] private readonly ClientJukeboxSongsSyncManager _jukeboxSyncManager = default!;
|
||||
[Dependency] private readonly TTSManager _ttsManager = default!;
|
||||
//WD-EDIT
|
||||
|
||||
public override void Init()
|
||||
@@ -186,6 +188,7 @@ namespace Content.Client.Entry
|
||||
_sponsorsManager.Initialize();
|
||||
_queueManager.Initialize();
|
||||
_jukeboxSyncManager.Initialize();
|
||||
_ttsManager.Initialize();
|
||||
//WD-EDIT
|
||||
|
||||
_baseClient.RunLevelChanged += (_, args) =>
|
||||
|
||||
@@ -21,6 +21,7 @@ using Content.Client.White.JoinQueue;
|
||||
using Content.Client.White.Jukebox;
|
||||
using Content.Client.White.Sponsors;
|
||||
using Content.Client.White.Stalin;
|
||||
using Content.Client.White.TTS;
|
||||
using Content.Shared.Administration.Managers;
|
||||
|
||||
namespace Content.Client.IoC
|
||||
@@ -55,6 +56,7 @@ namespace Content.Client.IoC
|
||||
IoCManager.Register<SponsorsManager>();
|
||||
IoCManager.Register<StalinManager>();
|
||||
IoCManager.Register<ClientJukeboxSongsSyncManager>();
|
||||
IoCManager.Register<TTSManager>();
|
||||
//WD-EDIT
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
<Label Text="{Loc 'humanoid-profile-editor-voice-label'}" />
|
||||
<Control HorizontalExpand="True"/>
|
||||
<OptionButton Name="CVoiceButton" HorizontalAlignment="Right" />
|
||||
<Button Name="CVoicePlayButton" Text="{Loc 'humanoid-profile-editor-voice-play'}" MaxWidth="80" />
|
||||
</BoxContainer>
|
||||
<!-- Show clothing -->
|
||||
<BoxContainer HorizontalExpand="True">
|
||||
|
||||
@@ -84,6 +84,7 @@ namespace Content.Client.Preferences.UI
|
||||
|
||||
//WD-EDIT
|
||||
private OptionButton _voiceButton => CVoiceButton;
|
||||
private Button _voicePlayButton => CVoicePlayButton;
|
||||
//WD-EDIT
|
||||
|
||||
private Slider _skinColor => CSkin;
|
||||
|
||||
@@ -1,16 +1,29 @@
|
||||
using System.Linq;
|
||||
using Content.Client.White.Sponsors;
|
||||
using Content.Client.White.TTS;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.White.TTS;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Client.Preferences.UI;
|
||||
|
||||
public sealed partial class HumanoidProfileEditor
|
||||
{
|
||||
private TTSManager _ttsMgr = default!;
|
||||
private TTSSystem _ttsSys = default!;
|
||||
private List<TTSVoicePrototype> _voiceList = default!;
|
||||
private readonly List<string> _sampleText = new()
|
||||
{
|
||||
"Съешь же ещё этих мягких французских булок, да выпей чаю.",
|
||||
"Клоун, прекрати разбрасывать банановые кожурки офицерам под ноги!",
|
||||
"Капитан, вы уверены что хотите назначить клоуна на должность главы персонала?",
|
||||
"Эс Бэ! Тут человек в сером костюме, с тулбоксом и в маске! Помогите!!"
|
||||
};
|
||||
|
||||
private void InitializeVoice()
|
||||
{
|
||||
_ttsMgr = IoCManager.Resolve<TTSManager>();
|
||||
_ttsSys = _entMan.System<TTSSystem>();
|
||||
_voiceList = _prototypeManager.EnumeratePrototypes<TTSVoicePrototype>().Where(o => o.RoundStart).ToList();
|
||||
|
||||
_voiceButton.OnItemSelected += args =>
|
||||
@@ -19,6 +32,8 @@ public sealed partial class HumanoidProfileEditor
|
||||
SetVoice(_voiceList[args.Id].ID);
|
||||
};
|
||||
|
||||
_voicePlayButton.OnPressed += _ => { PlayTTS(); };
|
||||
|
||||
}
|
||||
|
||||
private void UpdateTTSVoicesControls()
|
||||
@@ -58,4 +73,13 @@ public sealed partial class HumanoidProfileEditor
|
||||
SetVoice(_voiceList[firstVoiceChoiceId].ID);
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayTTS()
|
||||
{
|
||||
if (_previewDummy is null || Profile is null)
|
||||
return;
|
||||
|
||||
_ttsSys.StopAllStreams();
|
||||
_ttsMgr.RequestTTS(_previewDummy.Value, _random.Pick(_sampleText), Profile.Voice);
|
||||
}
|
||||
}
|
||||
|
||||
22
Content.Client/White/TTS/TTSManager.cs
Normal file
22
Content.Client/White/TTS/TTSManager.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Content.Shared.White.TTS;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Client.White.TTS;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public sealed class TTSManager
|
||||
{
|
||||
[Dependency] private readonly IClientNetManager _netMgr = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_netMgr.RegisterNetMessage<MsgRequestTTS>();
|
||||
}
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public void RequestTTS(EntityUid uid, string text, string voiceId)
|
||||
{
|
||||
var msg = new MsgRequestTTS() { Text = text, Uid = uid, VoiceId = voiceId };
|
||||
_netMgr.ClientSendMessage(msg);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ using Content.Server.Chat.Systems;
|
||||
using Content.Shared.White.TTS;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.White;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
@@ -19,6 +21,8 @@ public sealed partial class TTSSystem : EntitySystem
|
||||
[Dependency] private readonly TTSManager _ttsManager = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _xforms = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IServerNetManager _netMgr = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
private const int MaxMessageChars = 100 * 2; // same as SingleBubbleCharLimit * 2
|
||||
private bool _isEnabled = false;
|
||||
@@ -32,12 +36,19 @@ public sealed partial class TTSSystem : EntitySystem
|
||||
SubscribeLocalEvent<TransformSpeechEvent>(OnTransformSpeech);
|
||||
SubscribeLocalEvent<TTSComponent, EntitySpokeEvent>(OnEntitySpoke);
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestartCleanup);
|
||||
SubscribeNetworkEvent<RequestTTSEvent>(OnRequestTTS);
|
||||
|
||||
_netMgr.RegisterNetMessage<MsgRequestTTS>(OnRequestTTS);
|
||||
}
|
||||
|
||||
private void OnRequestTTS(RequestTTSEvent ev)
|
||||
private async void OnRequestTTS(MsgRequestTTS ev)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (!_playerManager.TryGetSessionByChannel(ev.MsgChannel, out var session) ||
|
||||
!_prototypeManager.TryIndex<TTSVoicePrototype>(ev.VoiceId, out var protoVoice))
|
||||
return;
|
||||
|
||||
var soundData = await GenerateTTS(ev.Uid, ev.Text, protoVoice.Speaker);
|
||||
if (soundData != null)
|
||||
RaiseNetworkEvent(new PlayTTSEvent(ev.Uid, soundData), Filter.SinglePlayer(session));
|
||||
}
|
||||
|
||||
private async void OnEntitySpoke(EntityUid uid, TTSComponent component, EntitySpokeEvent args)
|
||||
|
||||
29
Content.Shared/White/TTS/MsgRequestTTS.cs
Normal file
29
Content.Shared/White/TTS/MsgRequestTTS.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.White.TTS;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public sealed class MsgRequestTTS : NetMessage
|
||||
{
|
||||
public override MsgGroups MsgGroup => MsgGroups.Command;
|
||||
|
||||
public EntityUid Uid { get; set; } = EntityUid.Invalid;
|
||||
public string Text { get; set; } = String.Empty;
|
||||
public string VoiceId { get; set; } = String.Empty;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
|
||||
{
|
||||
Uid = new EntityUid(buffer.ReadInt32());
|
||||
Text = buffer.ReadString();
|
||||
VoiceId = buffer.ReadString();
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
|
||||
{
|
||||
buffer.Write((int)Uid);
|
||||
buffer.Write(Text);
|
||||
buffer.Write(VoiceId);
|
||||
}
|
||||
}
|
||||
@@ -43,3 +43,4 @@ humanoid-profile-editor-job-priority-never-button = Никогда
|
||||
humanoid-profile-editor-naming-rules-warning = Внимание: Оскорбительные или странные имена и описания могут повлечь за собой беседу с администрацией. Прочитайте \[Правила\].
|
||||
humanoid-profile-editor-markings-tab = Черты внешности
|
||||
humanoid-profile-editor-flavortext-tab = Описание
|
||||
humanoid-profile-editor-voice-play = ▶
|
||||
|
||||
Reference in New Issue
Block a user