Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion Content.Client/Audio/ContentAudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public sealed partial class ContentAudioSystem : SharedContentAudioSystem
public const float AmbientMusicMultiplier = 3f;
public const float LobbyMultiplier = 3f;
public const float InterfaceMultiplier = 2f;

public const float TTSMultiplier = 3f; // OpenSpace TTS

public override void Initialize()
{
base.Initialize();
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Credits/CreditsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ void AddSection(string title, string path, bool markup = false)
ss14ContributorsContainer.AddChild(label);
}

AddSection(Loc.GetString("credits-window-tts-title"), "TTS.txt"); // OpenSpace-TTS
AddSection(Loc.GetString("credits-window-contributors-section-title"), "GitHub.txt");
AddSection(Loc.GetString("credits-window-codebases-section-title"), "SpaceStation13.txt");
AddSection(Loc.GetString("credits-window-original-remake-team-section-title"), "OriginalRemake.txt");
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Content.Client.UserInterface;
using Content.Client.Viewport;
using Content.Client.Voting;
using Content.Client._OpenSpace.TTS; // OpenSpace TTS
using Content.Shared.Ame.Components;
using Content.Shared.FeedbackSystem;
using Content.Shared.Gravity;
Expand Down
1 change: 1 addition & 0 deletions Content.Client/IoC/ClientContentIoC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Content.Shared.Administration.Logs;
using Content.Client.Lobby;
using Content.Client.Players.RateLimiting;
using Content.Client._OpenSpace.TTS; // OpenSpace TTS
using Content.Shared.Administration.Managers;
using Content.Shared.Chat;
using Content.Shared.FeedbackSystem;
Expand Down
9 changes: 9 additions & 0 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.Appearance.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Client.UserInterface.Systems.Guidebook;
using Content.Shared._OpenSpace.TTS; // OpenSpace-TTS
using Content.Shared.Guidebook;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
Expand Down Expand Up @@ -226,6 +227,14 @@ private void SetGender(Gender newGender)
ReloadPreview();
}

// OpenSpace-TTS Start
private void SetVoice(string newVoice)
{
Profile = Profile?.WithVoice(newVoice);
IsDirty = true;
}
// OpenSpace-TTS End

private void SetSpawnPriority(SpawnPriorityPreference newSpawnPriority)
{
Profile = Profile?.WithSpawnPriorityPreference(newSpawnPriority);
Expand Down
8 changes: 8 additions & 0 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@
<Control HorizontalExpand="True"/>
<OptionButton Name="SpawnPriorityButton" HorizontalAlignment="Right" />
</BoxContainer>
<!-- OpenSpace-TTS-Start -->
<BoxContainer HorizontalExpand="True" Visible="False" Name="TTSContainer">
<Label Text="{Loc 'humanoid-profile-editor-voice-label'}" />
<Control HorizontalExpand="True"/>
<OptionButton Name="VoiceButton" HorizontalAlignment="Right" />
<Button Name="VoicePlayButton" Text="{Loc 'humanoid-profile-editor-voice-play'}" MaxWidth="80" />
</BoxContainer>
<!-- OpenSpace-TTS-End -->
</BoxContainer>
<!-- Skin -->
<BoxContainer Margin="10" HorizontalExpand="True" Orientation="Vertical">
Expand Down
16 changes: 16 additions & 0 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Client.Message;
using Content.Client.Players.PlayTimeTracking;
using Content.Client.Sprite;
using Content.Shared._OpenSpace.OpenCVars; // OpenSpace-TTS
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Content.Shared.Humanoid;
Expand Down Expand Up @@ -191,6 +192,18 @@ public HumanoidProfileEditor(

#endregion Gender

// OpenSpace-TTS Start
#region Voice

if (configurationManager.GetCVar(OpenCVars.TTSEnabled))
{
TTSContainer.Visible = true;
InitializeVoice();
}

#endregion
// OpenSpace-TTS End

RefreshSpecies();

SpeciesButton.OnItemSelected += args =>
Expand Down Expand Up @@ -288,6 +301,8 @@ public HumanoidProfileEditor(

RefreshFlavorText();

UpdateTtsVoicesControls(); // OpenSpace-TTS

#region Dummy

SpriteRotateLeft.OnPressed += _ =>
Expand Down Expand Up @@ -375,6 +390,7 @@ public void SetProfile(HumanoidCharacterProfile? profile, int? slot)
UpdateAgeEdit();
UpdateEyePickers();
UpdateSaveButton();
UpdateTtsVoicesControls(); // OpenSpace-TTS
UpdateMarkings();

RefreshAntags();
Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Options/UI/Tabs/AudioTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<Label Text="{Loc 'ui-options-volume-label'}"
StyleClasses="LabelKeyText"/>
<BoxContainer Orientation="Vertical" Margin="0 3 0 0">
<ui:OptionSlider Name="SliderVolumeTTS" Title="{Loc 'ui-options-TTS-volume'}"
Margin="0 0 0 8" />
<ui:OptionSlider Name="SliderVolumeMaster" Title="{Loc 'ui-options-master-volume'}"
Margin="0 0 0 8" />
<ui:OptionSlider Name="SliderVolumeMidi" Title="{Loc 'ui-options-midi-volume'}" />
Expand Down
8 changes: 8 additions & 0 deletions Content.Client/Options/UI/Tabs/AudioTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Client.Administration.Managers;
using Content.Client.Audio;
using Content.Shared._OpenSpace.OpenCVars; // OpenSpace-TTS
using Content.Shared.CCVar;
using Robust.Client.Audio;
using Robust.Client.AutoGenerated;
Expand Down Expand Up @@ -53,6 +54,13 @@ public AudioTab()
SliderVolumeInterface,
scale: ContentAudioSystem.InterfaceMultiplier);

// OpenSpace-TTS Start
Control.AddOptionPercentSlider(
OpenCVars.TTSVolume,
SliderVolumeTTS,
scale: ContentAudioSystem.TTSMultiplier);
// OpenSpace-TTS End

Control.AddOptionSlider(
CCVars.MaxAmbientSources,
SliderMaxAmbienceSounds,
Expand Down
4 changes: 3 additions & 1 deletion Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected override void Open()
_window.OnVerbChange += verb => SendMessage(new VoiceMaskChangeVerbMessage(verb));
_window.OnToggle += OnToggle;
_window.OnAccentToggle += OnAccentToggle;
_window.OnVoiceChange += voice => SendMessage(new VoiceMaskChangeVoiceMessage(voice)); // OpenSpace-TTS
}

private void OnNameSelected(string name)
Expand All @@ -52,7 +53,8 @@ protected override void UpdateState(BoundUserInterfaceState state)
return;
}

_window.UpdateState(cast.Name, cast.Verb, cast.Active, cast.AccentHide);
_window.UpdateState(cast.Name, cast.Verb, cast.Active, cast.AccentHide, cast.Voice); //cast.Voice OpenSpace-TTS

}

protected override void Dispose(bool disposing)
Expand Down
6 changes: 6 additions & 0 deletions Content.Client/VoiceMask/VoiceMaskNameChangeWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@
</BoxContainer>
<Button Name="ToggleAccentButton" Text="{Loc 'voice-mask-name-change-accent-toggle'}" HorizontalExpand="True" ToggleMode="True" Margin="5"/>
<Button Name="ToggleButton" Text="{Loc 'voice-mask-name-change-toggle'}" HorizontalExpand="True" ToggleMode="True" Margin="5"/>
<!-- OpenSpace-TTS Start -->
<BoxContainer Orientation="Horizontal" Margin="5" Visible="False" Name="TTSContainer">
<Label Text="{Loc 'voice-mask-voice-change-info'}" />
<OptionButton Name="VoiceSelector" /> <!-- Populated in LoadVerbs -->
</BoxContainer>
<!-- OpenSpace-TTS End -->
</BoxContainer>
</controls:FancyWindow>
45 changes: 44 additions & 1 deletion Content.Client/VoiceMask/VoiceMaskNameChangeWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System.Linq; // OpenSpace-TTS
using Content.Shared._OpenSpace.TTS; // OpenSpace-TTS
using Content.Client.UserInterface.Controls;
using Content.Shared._OpenSpace.OpenCVars; // OpenSpace-TTS
using Content.Shared.Speech;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration; // OpenSpace-TTS
using Robust.Shared.Prototypes;

namespace Content.Client.VoiceMask;
Expand All @@ -14,8 +18,10 @@ public sealed partial class VoiceMaskNameChangeWindow : FancyWindow
public Action<string?>? OnVerbChange;
public Action? OnToggle;
public Action? OnAccentToggle;
public Action<string>? OnVoiceChange; // OpenSpace-TTS

private List<(string, string)> _verbs = new();
private List<TTSVoicePrototype> _voices = new(); // OpenSpace-TTS

private string? _verb;

Expand All @@ -36,6 +42,14 @@ public VoiceMaskNameChangeWindow()

ToggleButton.OnPressed += args => OnToggle?.Invoke();
ToggleAccentButton.OnPressed += args => OnAccentToggle?.Invoke();

// OpenSpace-TTS Start
if (IoCManager.Resolve<IConfigurationManager>().GetCVar(OpenCVars.TTSEnabled))
{
TTSContainer.Visible = true;
ReloadVoices(IoCManager.Resolve<IPrototypeManager>());
}
// OpenSpace-TTS End
}

public void ReloadVerbs(IPrototypeManager proto)
Expand Down Expand Up @@ -69,7 +83,30 @@ private void AddVerb(string name, string? verb)
SpeechVerbSelector.SelectId(id);
}

public void UpdateState(string name, string? verb, bool active, bool accentHide)
// OpenSpace-TTS Start
private void ReloadVoices(IPrototypeManager proto)
{
VoiceSelector.OnItemSelected += args =>
{
VoiceSelector.SelectId(args.Id);
if (VoiceSelector.SelectedMetadata != null)
OnVoiceChange!((string)VoiceSelector.SelectedMetadata);
};
_voices = proto
.EnumeratePrototypes<TTSVoicePrototype>()
.Where(o => o.RoundStart)
.OrderBy(o => Loc.GetString(o.Name))
.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);
}
}
// OpenSpace-TTS End

public void UpdateState(string name, string? verb, bool active, bool accentHide, string voice) // OpenSpace-TTS
{
NameSelector.Text = name;
_verb = verb;
Expand All @@ -84,5 +121,11 @@ public void UpdateState(string name, string? verb, bool active, bool accentHide)
break;
}
}

// OpenSpace-TTS Start
var voiceIdx = _voices.FindIndex(v => v.ID == voice);
if (voiceIdx != -1)
VoiceSelector.Select(voiceIdx);
// OpenSpace-TTS End
}
}
67 changes: 67 additions & 0 deletions Content.Client/_OpenSpace/TTS/HumanoidProfileEditor.TTS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System.Linq;
using Content.Client._OpenSpace.TTS;
using Content.Client.Lobby;
// using Content._OpenSpace.Interfaces.Shared;
using Content.Shared._OpenSpace.TTS;
using Content.Shared.Preferences;

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>().RequestPreviewTTS(Profile.Voice);
}
}
Loading
Loading