[feat] TTS
# Conflicts: # Content.Client/Options/UI/Tabs/AudioTab.xaml.cs # Content.Client/Preferences/UI/HumanoidProfileEditor.xaml # Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs # Content.Server/Database/ServerDbBase.cs # Content.Server/Entry/EntryPoint.cs # Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs # Content.Server/IoC/ServerContentIoC.cs # Content.Server/VoiceMask/VoiceMaskSystem.cs # Resources/Prototypes/Entities/Mobs/Species/base.yml
This commit is contained in:
@@ -20,6 +20,7 @@ public sealed class VoiceMaskBoundUserInterface : BoundUserInterface
|
||||
|
||||
_window.OpenCentered();
|
||||
_window.OnNameChange += OnNameSelected;
|
||||
_window.OnVoiceChange += (value) => SendMessage(new VoiceMaskChangeVoiceMessage(value));
|
||||
_window.OnClose += Close;
|
||||
}
|
||||
|
||||
@@ -35,7 +36,8 @@ public sealed class VoiceMaskBoundUserInterface : BoundUserInterface
|
||||
return;
|
||||
}
|
||||
|
||||
_window.UpdateState(cast.Name);
|
||||
_window.UpdateState(cast.Name, cast.Voice);
|
||||
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
@@ -7,5 +7,9 @@
|
||||
<LineEdit Name="NameSelector" HorizontalExpand="True" />
|
||||
<Button Name="NameSelectorSet" Text="{Loc 'voice-mask-name-change-set'}" />
|
||||
</BoxContainer>
|
||||
<Label Text="{Loc 'voice-mask-voice-change-info'}" />
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<OptionButton Name="VoiceSelector" HorizontalExpand="True" />
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.White.TTS;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.VoiceMask;
|
||||
|
||||
@@ -9,6 +12,9 @@ public sealed partial class VoiceMaskNameChangeWindow : DefaultWindow
|
||||
{
|
||||
public Action<string>? OnNameChange;
|
||||
|
||||
private readonly List<TTSVoicePrototype> _voices; // TTS
|
||||
public Action<string>? OnVoiceChange;
|
||||
|
||||
public VoiceMaskNameChangeWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
@@ -17,10 +23,31 @@ public sealed partial class VoiceMaskNameChangeWindow : DefaultWindow
|
||||
{
|
||||
OnNameChange!(NameSelector.Text);
|
||||
};
|
||||
|
||||
VoiceSelector.OnItemSelected += args =>
|
||||
{
|
||||
VoiceSelector.SelectId(args.Id);
|
||||
if (VoiceSelector.SelectedMetadata != null)
|
||||
OnVoiceChange!((string)VoiceSelector.SelectedMetadata);
|
||||
};
|
||||
_voices = IoCManager
|
||||
.Resolve<IPrototypeManager>()
|
||||
.EnumeratePrototypes<TTSVoicePrototype>()
|
||||
.Where(o => o.RoundStart)
|
||||
.ToList();
|
||||
for (var i = 0; i < _voices.Count; i++)
|
||||
{
|
||||
var name = Loc.GetString(_voices[i].Name);
|
||||
VoiceSelector.AddItem(name);
|
||||
VoiceSelector.SetItemMetadata(i, _voices[i].ID);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateState(string name)
|
||||
public void UpdateState(string name, string voice)
|
||||
{
|
||||
NameSelector.Text = name;
|
||||
var voiceIdx = _voices.FindIndex(v => v.ID == voice);
|
||||
if (voiceIdx != -1)
|
||||
VoiceSelector.Select(voiceIdx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user