2024-01-21 13:14:01 +04:00
|
|
|
|
using Content.Shared.CCVar;
|
|
|
|
|
|
using Content.Shared.Chat;
|
|
|
|
|
|
using Content.Shared.Communications;
|
2024-07-21 14:48:13 +10:00
|
|
|
|
using Robust.Client.UserInterface;
|
2024-01-21 13:14:01 +04:00
|
|
|
|
using Robust.Shared.Configuration;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.Timing;
|
2020-04-09 00:28:56 +02:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Communications.UI
|
2020-04-09 00:28:56 +02:00
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class CommunicationsConsoleBoundUserInterface : BoundUserInterface
|
2020-04-09 00:28:56 +02:00
|
|
|
|
{
|
2024-01-21 13:14:01 +04:00
|
|
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
2020-04-09 00:28:56 +02:00
|
|
|
|
|
2023-07-08 09:02:17 -07:00
|
|
|
|
[ViewVariables]
|
|
|
|
|
|
private CommunicationsConsoleMenu? _menu;
|
2021-02-16 09:31:57 +01:00
|
|
|
|
|
2023-07-08 09:02:17 -07:00
|
|
|
|
public CommunicationsConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
|
|
|
|
{
|
2020-04-09 00:28:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Open();
|
|
|
|
|
|
|
2024-07-21 14:48:13 +10:00
|
|
|
|
_menu = this.CreateWindow<CommunicationsConsoleMenu>();
|
|
|
|
|
|
_menu.OnAnnounce += AnnounceButtonPressed;
|
|
|
|
|
|
_menu.OnBroadcast += BroadcastButtonPressed;
|
|
|
|
|
|
_menu.OnAlertLevel += AlertLevelSelected;
|
|
|
|
|
|
_menu.OnEmergencyLevel += EmergencyShuttleButtonPressed;
|
2020-04-09 00:28:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-17 21:05:31 -07:00
|
|
|
|
public void AlertLevelSelected(string level)
|
|
|
|
|
|
{
|
2024-07-21 14:48:13 +10:00
|
|
|
|
if (_menu!.AlertLevelSelectable)
|
2022-05-17 21:05:31 -07:00
|
|
|
|
{
|
2024-07-21 14:48:13 +10:00
|
|
|
|
_menu.CurrentLevel = level;
|
2022-05-17 21:05:31 -07:00
|
|
|
|
SendMessage(new CommunicationsConsoleSelectAlertLevelMessage(level));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-09 01:43:28 +02:00
|
|
|
|
public void EmergencyShuttleButtonPressed()
|
|
|
|
|
|
{
|
2024-07-21 14:48:13 +10:00
|
|
|
|
if (_menu!.CountdownStarted)
|
2020-04-09 01:43:28 +02:00
|
|
|
|
RecallShuttle();
|
|
|
|
|
|
else
|
|
|
|
|
|
CallShuttle();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-13 23:21:57 -06:00
|
|
|
|
public void AnnounceButtonPressed(string message)
|
|
|
|
|
|
{
|
2024-01-21 13:14:01 +04:00
|
|
|
|
var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
|
|
|
|
|
|
var msg = SharedChatSystem.SanitizeAnnouncement(message, maxLength);
|
|
|
|
|
|
SendMessage(new CommunicationsConsoleAnnounceMessage(msg));
|
2021-03-13 23:21:57 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-27 05:51:24 -08:00
|
|
|
|
public void BroadcastButtonPressed(string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
SendMessage(new CommunicationsConsoleBroadcastMessage(message));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-09 00:28:56 +02:00
|
|
|
|
public void CallShuttle()
|
|
|
|
|
|
{
|
|
|
|
|
|
SendMessage(new CommunicationsConsoleCallEmergencyShuttleMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-09 01:43:28 +02:00
|
|
|
|
public void RecallShuttle()
|
|
|
|
|
|
{
|
|
|
|
|
|
SendMessage(new CommunicationsConsoleRecallEmergencyShuttleMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-09 00:28:56 +02:00
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
|
|
|
|
{
|
2020-11-26 14:33:31 +01:00
|
|
|
|
base.UpdateState(state);
|
|
|
|
|
|
|
|
|
|
|
|
if (state is not CommunicationsConsoleInterfaceState commsState)
|
2020-04-09 00:28:56 +02:00
|
|
|
|
return;
|
|
|
|
|
|
|
2021-02-16 09:31:57 +01:00
|
|
|
|
if (_menu != null)
|
|
|
|
|
|
{
|
2024-07-21 14:48:13 +10:00
|
|
|
|
_menu.CanAnnounce = commsState.CanAnnounce;
|
|
|
|
|
|
_menu.CanBroadcast = commsState.CanBroadcast;
|
|
|
|
|
|
_menu.CanCall = commsState.CanCall;
|
|
|
|
|
|
_menu.CountdownStarted = commsState.CountdownStarted;
|
|
|
|
|
|
_menu.AlertLevelSelectable = commsState.AlertLevels != null && !float.IsNaN(commsState.CurrentAlertDelay) && commsState.CurrentAlertDelay <= 0;
|
|
|
|
|
|
_menu.CurrentLevel = commsState.CurrentAlert;
|
|
|
|
|
|
_menu.CountdownEnd = commsState.ExpectedCountdownEnd;
|
|
|
|
|
|
|
2021-02-16 09:31:57 +01:00
|
|
|
|
_menu.UpdateCountdown();
|
2024-07-21 14:48:13 +10:00
|
|
|
|
_menu.UpdateAlertLevels(commsState.AlertLevels, _menu.CurrentLevel);
|
|
|
|
|
|
_menu.AlertLevelButton.Disabled = !_menu.AlertLevelSelectable;
|
|
|
|
|
|
_menu.EmergencyShuttleButton.Disabled = !_menu.CanCall;
|
|
|
|
|
|
_menu.AnnounceButton.Disabled = !_menu.CanAnnounce;
|
|
|
|
|
|
_menu.BroadcastButton.Disabled = !_menu.CanBroadcast;
|
2021-02-16 09:31:57 +01:00
|
|
|
|
}
|
2020-04-09 00:28:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|