mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-23 00:27:50 +03:00
* Revert "[Fix] TTS (#137)" This reverts commitc5bd6b70a2. * Revert "[Fix] Исправление ТТСа (#136)" This reverts commit3759acb84e. * Revert "[Port] TTS (#121)" This reverts commit0db8f3aaa4. * new TTS * new TTS * new TTS * new TTS * fix
68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
using System.Linq;
|
|
using Content.Client._White.TTS;
|
|
using Content.Shared._White.TTS;
|
|
using Content.Shared.Preferences;
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
// ReSharper disable once CheckNamespace
|
|
namespace Content.Client.Lobby.UI;
|
|
|
|
public sealed partial class HumanoidProfileEditor
|
|
{
|
|
private List<TTSVoicePrototype> _voiceList = new();
|
|
|
|
private void InitializeVoice()
|
|
{
|
|
_voiceList = _prototypeManager
|
|
.EnumeratePrototypes<TTSVoicePrototype>()
|
|
.Where(o => o.RoundStart)
|
|
.OrderBy(o => Loc.GetString(o.Name))
|
|
.ToList();
|
|
|
|
VoiceButton.OnItemSelected += args =>
|
|
{
|
|
VoiceButton.SelectId(args.Id);
|
|
SetVoice(_voiceList[args.Id].ID);
|
|
};
|
|
|
|
VoicePlayButton.OnPressed += _ => PlayPreviewTTS();
|
|
}
|
|
|
|
private void UpdateTTSVoicesControls()
|
|
{
|
|
if (Profile is null)
|
|
return;
|
|
|
|
VoiceButton.Clear();
|
|
|
|
var firstVoiceChoiceId = 1;
|
|
for (var i = 0; i < _voiceList.Count; i++)
|
|
{
|
|
var voice = _voiceList[i];
|
|
if (!HumanoidCharacterProfile.CanHaveVoice(voice, Profile.Sex))
|
|
continue;
|
|
|
|
var name = Loc.GetString(voice.Name);
|
|
VoiceButton.AddItem(name, i);
|
|
|
|
if (firstVoiceChoiceId == 1)
|
|
firstVoiceChoiceId = i;
|
|
}
|
|
|
|
var voiceChoiceId = _voiceList.FindIndex(x => x.ID == Profile.Voice);
|
|
if (!VoiceButton.TrySelectId(voiceChoiceId) &&
|
|
VoiceButton.TrySelectId(firstVoiceChoiceId))
|
|
{
|
|
SetVoice(_voiceList[firstVoiceChoiceId].ID);
|
|
}
|
|
}
|
|
|
|
private void PlayPreviewTTS()
|
|
{
|
|
if (Profile is null)
|
|
return;
|
|
|
|
_entManager.System<TTSSystem>().RequestGlobalTTS(VoiceRequestType.Preview,Profile.Voice);
|
|
}
|
|
}
|