Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Фиксы кода #135

Merged
merged 14 commits into from
Sep 11, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = Лисиьи штучки Инари
Loading