Skip to content

Commit

Permalink
Merge pull request #135 from SpicyDarkFox/dbg
Browse files Browse the repository at this point in the history
Фиксы кода
  • Loading branch information
Evgencheg authored Sep 11, 2024
2 parents a950b84 + 92ea460 commit b8d809d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
9 changes: 4 additions & 5 deletions Content.Client/Corvax/TTS/LobbyUIController.TTS.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.Corvax.TTS;
using Content.Client.Corvax.TTS;
using Content.Shared.Preferences;
using Robust.Client.UserInterface;
using Robust.Shared.Random;
Expand All @@ -10,8 +10,6 @@ public sealed partial class LobbyUIController
[Dependency] private readonly IRobustRandom _rng = default!;
[UISystemDependency] private readonly TTSSystem _tts = default!;

private HumanoidCharacterProfile? _profile;

private readonly List<string> _sampleText =
new()
{
Expand All @@ -23,10 +21,11 @@ public sealed partial class LobbyUIController

public void PlayTTS()
{
var profile = _profileEditor?.Profile ?? (HumanoidCharacterProfile) _preferencesManager.Preferences!.SelectedCharacter;
// Test moment
if (_profile == null || _stateManager.CurrentState is not LobbyState)
if (profile == null || _stateManager.CurrentState is not LobbyState)
return;

_tts.RequestGlobalTTS(_rng.Pick(_sampleText), _profile.Voice);
_tts.RequestGlobalTTS(_rng.Pick(_sampleText), profile.Voice);
}
}
21 changes: 19 additions & 2 deletions Content.Client/Corvax/TTS/TTSSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public sealed class TTSSystem : EntitySystem

private float _volume = 0f;
private int _fileIdx = 0;
private Dictionary<ResPath, float> _filesToDelete = new();

public override void Initialize()
{
Expand All @@ -56,6 +57,21 @@ public override void Initialize()
SubscribeNetworkEvent<PlayTTSEvent>(OnPlayTTS);
}

public override void Update(float frameTime)
{
base.Update(frameTime);

if (_filesToDelete.Count > 0)
foreach (var key in _filesToDelete.Keys)
{
_filesToDelete[key] -= frameTime;
if (_filesToDelete[key] <= 0)
{
_filesToDelete.Remove(key);
}
}
}

public override void Shutdown()
{
base.Shutdown();
Expand All @@ -81,7 +97,7 @@ private void OnPlayTTS(PlayTTSEvent ev)
#endif
if (!canPlay)
return;
_sawmill.Debug($"Play TTS audio {ev.Data.Length} bytes from {ev.SourceUid} entity");
//_sawmill.Debug($"Play TTS audio {ev.Data.Length} bytes from {ev.SourceUid} entity");

var volume = AdjustVolume(ev.IsWhisper);

Expand Down Expand Up @@ -114,7 +130,8 @@ private void OnPlayTTS(PlayTTSEvent ev)
_audio.PlayGlobal(soundPath, Filter.Local(), false);
}

_contentRoot.RemoveFile(filePath);
_filesToDelete.Add(filePath, 50); //удаление файла отложено на 50 секунд (приблизительно)
//_contentRoot.RemoveFile(filePath);
}

private float AdjustVolume(bool isWhisper)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ent-LPPClothingUniformBlackNormandia = Униформа Эсдаса Экстард
.desc = Униформа офицера специальных операций
.suffix = { "Личные вещи, lxstvx" }
ent-LPPClothingTrenchCoatNormanida = Тренч Эсдаса Экстард
.desc = Именной тренч офицера Экстард
.suffix = { "Личные вещи, lxstvx" }
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ marking-LPPAlloldpain = Лорд Боли
marking-LPPAlltavrhorn = Минотавр
marking-LPPAlltelehorn = Телерог
marking-LPPAllvampirehorn = Рога Вампира
marking-LPPInariFoxStuff = Лисиьи штучки Инари

0 comments on commit b8d809d

Please sign in to comment.