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
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions Content.Client/Audio/ContentAudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public sealed partial class ContentAudioSystem : SharedContentAudioSystem
public const float LobbyMultiplier = 3f;
public const float InterfaceMultiplier = 2f;
public const float CombatMultiplier = 3f; //Mono
public const float BarksMultiplier = 3f; // Corvax-Frontier-Barks
public const float TtsMultiplier = 3f; // Corvax-TTS

public override void Initialize()
{
Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
using Robust.Shared.Replays;
using Robust.Shared.Timing;
using Content.Client._NF.Emp.Overlays; // Frontier
using Content.Client._Forge.DiscordAuth; // Forge-Change
using Content.Client._Forge.Sponsor; // Forge-Change

namespace Content.Client.Entry
{
Expand Down
2 changes: 2 additions & 0 deletions Content.Client/IoC/ClientContentIoC.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Client._Forge.Sponsor; // Forge-Change
using Content.Client.Administration.Managers;
using Content.Client.Changelog;
using Content.Client.Chat.Managers;
Expand All @@ -20,6 +21,7 @@
using Content.Shared.Administration.Logs;
using Content.Client.Lobby;
using Content.Client.Players.RateLimiting;
using Content.Shared._Forge.Sponsor; // Forge-Change
using Content.Shared.Administration.Managers;
using Content.Shared.Chat;
using Content.Shared.Players.PlayTimeTracking;
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 @@ -105,6 +105,14 @@
<Slider Name="WidthSlider" MinValue="0.8" MaxValue="1.2" Value="1.0" HorizontalAlignment="Right" MinSize="200 0" />
<Button Name="WidthResetButton" Text="{Loc 'humanoid-profile-editor-reset-button'}" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Corvax-Frontier-Barks-Start -->
<BoxContainer HorizontalExpand="True" Visible="False" Name="BarksContainer">
<Label Text="{Loc 'humanoid-profile-editor-voice-label'}" />
<Control HorizontalExpand="True"/>
<OptionButton Name="BarkVoiceButton" HorizontalAlignment="Right" />
<Button Name="BarkVoicePlayButton" Text="{Loc 'humanoid-profile-editor-BarkVoice-play'}" MaxWidth="80" />
</BoxContainer>
<!-- Corvax-Frontier-Barks-End -->
</BoxContainer>
<!-- Skin -->
<BoxContainer Margin="10" HorizontalExpand="True" Orientation="Vertical">
Expand Down
18 changes: 17 additions & 1 deletion Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1708,12 +1708,28 @@ private void SetName(string newName)
_entManager.System<MetaDataSystem>().SetEntityName(PreviewDummy, newName);
}

private void SetSpawnPriority(SpawnPriorityPreference newSpawnPriority)
private void SetSpawnPriority(SpawnPriorityPreference newSpawnPriority)
{
Profile = Profile?.WithSpawnPriorityPreference(newSpawnPriority);
SetDirty();
}

// Corvax-Frontier-Barks-start
private void SetBarkVoice(string newVoice)
{
Profile = Profile?.WithBarkVoice(newVoice);
IsDirty = true;
}
// Corvax-Frontier-Barks-end

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

private void SetHeight(float newHeight)
{
Profile = Profile?.WithCharacterAppearance(Profile.Appearance.WithHeight(newHeight));
Expand Down
8 changes: 7 additions & 1 deletion Content.Client/Options/UI/Tabs/AudioTab.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Control xmlns="https://spacestation14.io"
<Control xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Content.Client.Options.UI">
<BoxContainer Orientation="Vertical">
Expand All @@ -15,6 +15,12 @@
<ui:OptionSlider Name="SliderVolumeInterface" Title="{Loc 'ui-options-interface-volume'}" />
<ui:OptionSlider Name="SliderMaxAmbienceSounds" Title="{Loc 'ui-options-ambience-max-sounds'}"
Margin="0 0 0 8" />
<!-- Corvax-Frontier-Barks-start -->
<ui:OptionSlider Name="SliderVolumeBarks" Title="{Loc 'ui-options-barks-volume'}" />
<!-- Corvax-Frontier-Barks-end -->
<!-- Corvax-TTS-Start -->
<ui:OptionSlider Name="SliderVolumeTts" Title="{Loc 'ui-options-tts-volume'}" />
<!-- Corvax-TTS-End -->
<ui:OptionSlider Name="SliderVolumeCombatMusic" Title="{Loc 'ui-options-combat-music-volume'}" />
<ui:OptionSlider Name="SliderWindUpCombatMusic" Title="{Loc 'ui-options-combat-music-windup'}" />
<ui:OptionSlider Name="SliderWindDownCombatMusic" Title="{Loc 'ui-options-combat-music-winddown'}" />
Expand Down
15 changes: 15 additions & 0 deletions Content.Client/Options/UI/Tabs/AudioTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Client.Administration.Managers;
using Content.Client.Audio;
using Content.Shared.CCVar;
using Content.Shared._Forge; // Corvax-Frontier-Barks
using Content.Shared._Mono.CCVar;
using Robust.Client.Audio;
using Robust.Client.AutoGenerated;
Expand Down Expand Up @@ -29,6 +30,20 @@ public AudioTab()
scale: ContentAudioSystem.MasterVolumeMultiplier);
masterVolume.ImmediateValueChanged += OnMasterVolumeSliderChanged;

// Corvax-Frontier-Barks-start
Control.AddOptionPercentSlider(
ForgeVars.BarksVolume,
SliderVolumeBarks,
scale: ContentAudioSystem.BarksMultiplier);
// Corvax-Frontier-Barks-end

// Corvax-TTS-Start
Control.AddOptionPercentSlider(
ForgeVars.TTSVolume,
SliderVolumeTts,
scale: ContentAudioSystem.TtsMultiplier);
// Corvax-TTS-End

Control.AddOptionPercentSlider(
CVars.MidiVolume,
SliderVolumeMidi,
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Options/UI/Tabs/MiscTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Client.UserInterface.Screens;
using Content.Shared._Forge; // Corvax-Frontier
using Content.Shared._Mono.CCVar;
using Content.Shared.CCVar;
using Content.Shared.HUD;
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected override void Open()

_window.OnNameChange += OnNameSelected;
_window.OnVerbChange += verb => SendMessage(new VoiceMaskChangeVerbMessage(verb));
_window.OnVoiceChange += voice => SendMessage(new VoiceMaskChangeVoiceMessage(voice)); // Corvax-TTS
}

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

_window.UpdateState(cast.Name, cast.Verb);
_window.UpdateState(cast.Name, cast.Voice, cast.Verb); // Corvax-TTS
}

protected override void Dispose(bool disposing)
Expand Down
7 changes: 7 additions & 0 deletions Content.Client/VoiceMask/VoiceMaskNameChangeWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@
<Label Text="{Loc 'voice-mask-name-change-speech-style'}" />
<OptionButton Name="SpeechVerbSelector" /> <!-- Populated in LoadVerbs -->
</BoxContainer>
<!-- Corvax-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>
<!-- Corvax-TTS-End -->
</BoxContainer>
</controls:FancyWindow>
46 changes: 45 additions & 1 deletion Content.Client/VoiceMask/VoiceMaskNameChangeWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using Content.Client.UserInterface.Controls;
using Content.Shared._Forge;
using Content.Shared._Forge.TTS;
using Content.Shared.Speech;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using System.Linq;

namespace Content.Client.VoiceMask;

Expand All @@ -12,8 +16,10 @@ public sealed partial class VoiceMaskNameChangeWindow : FancyWindow
{
public Action<string>? OnNameChange;
public Action<string?>? OnVerbChange;
public Action<string>? OnVoiceChange; // Corvax-TTS

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

private string? _verb;

Expand All @@ -31,6 +37,14 @@ public VoiceMaskNameChangeWindow()
OnVerbChange?.Invoke((string?) args.Button.GetItemMetadata(args.Id));
SpeechVerbSelector.SelectId(args.Id);
};

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

public void ReloadVerbs(IPrototypeManager proto)
Expand All @@ -53,6 +67,30 @@ public void AddVerbs()
}
}


// Corvax-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);
}
}
// Corvax-TTS-End

private void AddVerb(string name, string? verb)
{
var id = SpeechVerbSelector.ItemCount;
Expand All @@ -64,7 +102,7 @@ private void AddVerb(string name, string? verb)
SpeechVerbSelector.SelectId(id);
}

public void UpdateState(string name, string? verb)
public void UpdateState(string name, string voice, string? verb) // Corvax-TTS
{
NameSelector.Text = name;
_verb = verb;
Expand All @@ -77,5 +115,11 @@ public void UpdateState(string name, string? verb)
break;
}
}

// Corvax-TTS-Start
var voiceIdx = _voices.FindIndex(v => v.ID == voice);
if (voiceIdx != -1)
VoiceSelector.Select(voiceIdx);
// Corvax-TTS-End
}
}
89 changes: 89 additions & 0 deletions Content.Client/_Forge/Barks/BarkSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using Content.Client.Audio;
using Content.Shared._Forge.Speech.Synthesis;
using Content.Shared.Chat;
using Content.Shared._Forge;
using Robust.Client.Audio;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client._Forge.Speech.Synthesis.System;

/// <summary>
/// The system responsible for the sound transmission for each subscriber
/// </summary>
public sealed class BarkSystem : EntitySystem
{
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _player = default!;

private const float MinimalVolume = -10f;
private const float WhisperFade = 4f;

public override void Initialize()
{
SubscribeNetworkEvent<PlayBarkEvent>(OnPlayBark);
}

public void RequestPreviewBark(string barkVoiceId)
{
RaiseNetworkEvent(new RequestPreviewBarkEvent(barkVoiceId));
}

private void OnPlayBark(PlayBarkEvent ev)
{
var sourceEntity = _entityManager.GetEntity(ev.SourceUid);
if (!_entityManager.EntityExists(sourceEntity) || _entityManager.Deleted(sourceEntity) || !HasComp<TransformComponent>(sourceEntity))
return;

if (_player.LocalEntity != null && HasComp<TransformComponent>(_player.LocalEntity.Value))
{
var sourceTransform = Transform(sourceEntity);
var playerTransform = Transform(_player.LocalEntity.Value);

if (sourceTransform.Coordinates.TryDistance(EntityManager, playerTransform.Coordinates, out var distance))
return;
}

var userVolume = _cfg.GetCVar(ForgeVars.BarksVolume);
var baseVolume = SharedAudioSystem.GainToVolume(userVolume * ContentAudioSystem.BarksMultiplier);

float volume = MinimalVolume + baseVolume;
if (ev.Obfuscated) volume -= WhisperFade;

var audioParams = new AudioParams
{
Volume = volume,
Variation = 0.125f
};

int messageLength = ev.Message.Length;
float totalDuration = messageLength * 0.05f;
float soundInterval = 0.15f / ev.PlaybackSpeed;

int soundCount = (int)(totalDuration / soundInterval);
soundCount = Math.Max(soundCount, 1);

var audioResource = new AudioResource();
audioResource.Load(IoCManager.Instance!, new ResPath(ev.SoundPath));

var soundSpecifier = new ResolvedPathSpecifier(ev.SoundPath);

for (int i = 0; i < soundCount; i++)
{
Timer.Spawn(TimeSpan.FromSeconds(i * soundInterval), () =>
{
if (!_entityManager.EntityExists(sourceEntity) || _entityManager.Deleted(sourceEntity))
return;

_audio.PlayEntity(audioResource.AudioStream, sourceEntity, soundSpecifier, audioParams);
});
}
}
}
Loading
Loading