Фикс голосовой маски
This commit is contained in:
parent
0a91b468b4
commit
1b104845e5
5 changed files with 26 additions and 18 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using Content.Shared._Sunrise.SunriseCCVars;
|
||||
using Content.Shared.VoiceMask;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.VoiceMask;
|
||||
|
|
@ -23,6 +24,12 @@ public sealed class VoiceMaskBoundUserInterface : BoundUserInterface
|
|||
_window = this.CreateWindow<VoiceMaskNameChangeWindow>();
|
||||
_window.ReloadVerbs(_protomanager);
|
||||
_window.AddVerbs();
|
||||
// Sunrise-TTS-Start
|
||||
if (IoCManager.Resolve<IConfigurationManager>().GetCVar(SunriseCCVars.TTSEnabled))
|
||||
{
|
||||
_window.ReloadVoices(IoCManager.Resolve<IPrototypeManager>());
|
||||
}
|
||||
// Sunrise-TTS-End
|
||||
|
||||
_window.OnNameChange += OnNameSelected;
|
||||
_window.OnVerbChange += verb => SendMessage(new VoiceMaskChangeVerbMessage(verb));
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
using System.Linq;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared._Sunrise.SunriseCCVars;
|
||||
using Content.Shared._Sunrise.TTS;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.VoiceMask;
|
||||
|
|
@ -70,7 +68,7 @@ public sealed partial class VoiceMaskNameChangeWindow : FancyWindow
|
|||
}
|
||||
|
||||
// Sunrise-TTS-Start
|
||||
private void ReloadVoices(IPrototypeManager proto)
|
||||
public void ReloadVoices(IPrototypeManager proto)
|
||||
{
|
||||
VoiceSelector.OnItemSelected += args =>
|
||||
{
|
||||
|
|
@ -89,6 +87,9 @@ public sealed partial class VoiceMaskNameChangeWindow : FancyWindow
|
|||
VoiceSelector.AddItem(name);
|
||||
VoiceSelector.SetItemMetadata(i, _voices[i].ID);
|
||||
}
|
||||
|
||||
if (_voices.Count > 0)
|
||||
TTSContainer.Visible = true;
|
||||
}
|
||||
// Sunrise-TTS-End
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
|||
private void UpdateUI(Entity<VoiceMaskComponent> entity)
|
||||
{
|
||||
if (_uiSystem.HasUi(entity, VoiceMaskUIKey.Key))
|
||||
_uiSystem.SetUiState(entity.Owner, VoiceMaskUIKey.Key, new VoiceMaskBuiState(GetCurrentVoiceName(entity), entity.Comp.VoiceMaskSpeechVerb));
|
||||
_uiSystem.SetUiState(entity.Owner, VoiceMaskUIKey.Key, new VoiceMaskBuiState(GetCurrentVoiceName(entity), entity.Comp.VoiceId, entity.Comp.VoiceMaskSpeechVerb));
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace Content.Server.Voting.Managers
|
|||
|
||||
if (totalPlayers <= playerVoteMaximum || ghostVoterPercentage >= ghostVotePercentageRequirement)
|
||||
{
|
||||
StartVote(initiator);
|
||||
StartVote(initiator, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -134,7 +134,7 @@ namespace Content.Server.Voting.Managers
|
|||
return eligibleCount;
|
||||
}
|
||||
|
||||
private void StartVote(ICommonSession? initiator)
|
||||
private void StartVote(ICommonSession? initiator, bool displayVotes = true)
|
||||
{
|
||||
var alone = _playerManager.PlayerCount == 1 && initiator != null;
|
||||
var options = new VoteOptions
|
||||
|
|
@ -149,7 +149,8 @@ namespace Content.Server.Voting.Managers
|
|||
Duration = alone
|
||||
? TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerAlone))
|
||||
: TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerRestart)),
|
||||
InitiatorTimeout = TimeSpan.FromMinutes(5)
|
||||
InitiatorTimeout = TimeSpan.FromMinutes(5),
|
||||
DisplayVotes = displayVotes
|
||||
};
|
||||
|
||||
if (alone)
|
||||
|
|
@ -223,7 +224,8 @@ namespace Content.Server.Voting.Managers
|
|||
Title = Loc.GetString("ui-vote-gamemode-title"),
|
||||
Duration = alone
|
||||
? TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerAlone))
|
||||
: TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerPreset))
|
||||
: TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerPreset)),
|
||||
DisplayVotes = false // Sunrise-Edit
|
||||
};
|
||||
|
||||
if (alone)
|
||||
|
|
@ -275,7 +277,8 @@ namespace Content.Server.Voting.Managers
|
|||
Title = Loc.GetString("ui-vote-map-title"),
|
||||
Duration = alone
|
||||
? TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerAlone))
|
||||
: TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerMap))
|
||||
: TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerMap)),
|
||||
DisplayVotes = false // Sunrise-Edit
|
||||
};
|
||||
|
||||
if (alone)
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ public partial class VoiceMaskSystem
|
|||
|
||||
private void OnSpeakerVoiceTransform(EntityUid uid, VoiceMaskComponent component, TransformSpeakerVoiceEvent args)
|
||||
{
|
||||
if (component.Enabled)
|
||||
args.VoiceId = component.VoiceId;
|
||||
args.VoiceId = component.VoiceId;
|
||||
}
|
||||
|
||||
private void OnChangeVoice(EntityUid uid, VoiceMaskComponent component, VoiceMaskChangeVoiceMessage message)
|
||||
|
|
@ -25,18 +24,16 @@ public partial class VoiceMaskSystem
|
|||
|
||||
TrySetLastKnownVoice(uid, message.Voice);
|
||||
|
||||
UpdateUI(uid, component);
|
||||
UpdateUI((uid, component));
|
||||
}
|
||||
|
||||
private void TrySetLastKnownVoice(EntityUid maskWearer, string? voiceId)
|
||||
private void TrySetLastKnownVoice(EntityUid maskWearer, string voiceId)
|
||||
{
|
||||
if (!HasComp<VoiceMaskComponent>(maskWearer)
|
||||
|| !_inventory.TryGetSlotEntity(maskWearer, MaskSlot, out var maskEntity)
|
||||
|| !TryComp<VoiceMaskerComponent>(maskEntity, out var maskComp))
|
||||
if (!TryComp<VoiceMaskComponent>(maskWearer, out var maskComp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
maskComp.LastSetVoice = voiceId;
|
||||
maskComp.VoiceId = voiceId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue