Play button base

This commit is contained in:
EnefFlow
2023-05-04 17:51:53 +03:00
committed by Aviu00
parent 043b20a938
commit 59b5f24842
9 changed files with 97 additions and 3 deletions

View File

@@ -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) =>

View File

@@ -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
}
}

View File

@@ -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">

View File

@@ -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;

View File

@@ -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);
}
}

View 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);
}
}