diff --git a/Content.Client/Lobby/UI/HumanoidProfileEditor.Appearance.cs b/Content.Client/Lobby/UI/HumanoidProfileEditor.Appearance.cs index ddc9752b1e..c61e3fb678 100644 --- a/Content.Client/Lobby/UI/HumanoidProfileEditor.Appearance.cs +++ b/Content.Client/Lobby/UI/HumanoidProfileEditor.Appearance.cs @@ -1,9 +1,11 @@ using System.Linq; using Content.Client.UserInterface.Systems.Guidebook; +using Content.Shared.Chat.Prototypes; using Content.Shared.Guidebook; using Content.Shared.Humanoid; using Content.Shared.Humanoid.Prototypes; using Content.Shared.Preferences; +using Content.Shared.Speech.Components; using Robust.Client.UserInterface.Controls; using Robust.Shared.Enums; using Robust.Shared.Prototypes; @@ -16,6 +18,7 @@ public sealed partial class HumanoidProfileEditor private ColorSelectorSliders _rgbSkinColorSelector; private List _species = new(); + private List _voices = new(); private static readonly ProtoId DefaultSpeciesGuidebook = "Species"; public void UpdateSpeciesGuidebookIcon() @@ -97,6 +100,34 @@ public sealed partial class HumanoidProfileEditor EyeColorPicker.SetData(Profile.Appearance.EyeColor); } + private void UpdateVoiceControls() + { + if (Profile == null) + return; + + VoiceButton.Clear(); + _voices.Clear(); + + var speciesPrototype = _prototypeManager.Index(Profile.Species); + var availableVoices = speciesPrototype.Voices; + + _voices.AddRange(availableVoices.Select(protoId => _prototypeManager.Index(protoId))); + + if (_voices.All(proto => Profile?.Voice != proto.ID)) + SetVoice(speciesPrototype.DefaultSoundsBySex[(int)Profile.Sex]); + + for (var i = 0; i < availableVoices.Count; i++) + { + var name = Loc.GetString(_voices[i].VoiceSelectorName); + VoiceButton.AddItem(name, i); + + if (Profile?.Voice.Equals(_voices[i].ID) == true) + { + VoiceButton.SelectId(i); + } + } + } + private void UpdateSkinColor() { if (Profile == null) @@ -188,6 +219,7 @@ public sealed partial class HumanoidProfileEditor // In case there's species restrictions for loadouts RefreshLoadouts(); UpdateSexControls(); // update sex for new species + UpdateVoiceControls(); UpdateSpeciesGuidebookIcon(); ReloadPreview(); } @@ -215,11 +247,22 @@ public sealed partial class HumanoidProfileEditor break; } + // this does the same as above but for voice + if (_prototypeManager.TryIndex(Profile?.Species, out var prototype)) + SetVoice(prototype.DefaultSoundsBySex[(int)newSex]); + UpdateGenderControls(); + UpdateVoiceControls(); _markingsModel.SetOrganSexes(newSex); ReloadPreview(); } + private void SetVoice(ProtoId newVoice) + { + Profile = Profile?.WithVoice(newVoice); + IsDirty = true; + } + private void SetGender(Gender newGender) { Profile = Profile?.WithGender(newGender); diff --git a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml index 84c5b75d1c..cce8ad6296 100644 --- a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml +++ b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml @@ -74,6 +74,12 @@ + + +