mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-15 13:21:11 +03:00
* Scrolling text screens * remove ScrollingTextScreenComponent, fix comments * shave a pixel off of the frame, commas cut off * logMissing to false, state does may not exist * variable timing, offset array serializer * namespaces are a state of mind * Use CustomArraySerializer instead of a one-off * better alphabetize punctuation text * Unneeded VV access, 4-space meta.json * Subscription attributes * cleanup pass * shift left * AJCM's suggestions Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com> * PadRight returns a string. * kill the loop, use funny division instead * smoother animations, dark stripe on outer frame * Update for the new comms console UI * communications console changes * can't spell pain without UI * the ocho * it's big brain time * just a touch wider * UI polish pass - forgive the sins * look at my attributions dog * EDITED * Text screen layer init deferred until startup * that's a new one --------- Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
97 lines
3.6 KiB
C#
97 lines
3.6 KiB
C#
using Content.Shared.CCVar;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.AlertLevel;
|
|
using Content.Shared.Communications;
|
|
using Content.Shared.Station;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Communications.UI;
|
|
|
|
/// <summary>
|
|
/// The BUI for the communications console.
|
|
/// Handles sending messages back to the server to call the shuttle,
|
|
/// send messages, set the alert level, and set the text on screens.
|
|
/// </summary>
|
|
/// <seealso cref="CommunicationsConsoleComponent"/>
|
|
public sealed partial class CommunicationsConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
|
|
{
|
|
[Dependency] private IConfigurationManager _cfg = default!;
|
|
[Dependency] private SharedStationSystem _station = default!;
|
|
[Dependency] private AlertLevelSystem _alertLevel = default!;
|
|
|
|
[ViewVariables]
|
|
private CommunicationsConsoleMenu? _menu;
|
|
|
|
/// <inheritdoc/>
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_menu = this.CreateWindow<CommunicationsConsoleMenu>();
|
|
_menu.OnRadioAnnounce += RadioAnnounceButtonPressed;
|
|
_menu.OnScreenBroadcast += ScreenBroadcastButtonPressed;
|
|
_menu.OnAlertLevelChanged += AlertLevelSelected;
|
|
_menu.OnShuttleCalled += CallShuttle;
|
|
_menu.OnShuttleRecalled += RecallShuttle;
|
|
|
|
if (EntMan.TryGetComponent<CommunicationsConsoleComponent>(Owner, out var console))
|
|
_menu.SetBroadcastDisplayEntity(console.ScreenDisplayId);
|
|
}
|
|
|
|
public void AlertLevelSelected(ProtoId<AlertLevelPrototype> level)
|
|
{
|
|
// TODO: This does not work until the console UI is predicted and uses component states.
|
|
// Also someone decided to send BUI states regularly in an update loop, so this just gets randomly bulldozed until the message reaches the server.
|
|
// _menu.CurrentAlertLevel = level;
|
|
// _menu.AlertLevelSelectable = false;
|
|
// _menu.AlertLevelButton.Disabled = true;
|
|
SendMessage(new CommunicationsConsoleSelectAlertLevelMessage(level));
|
|
}
|
|
|
|
public void RadioAnnounceButtonPressed(string message)
|
|
{
|
|
var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
|
|
var msg = SharedChatSystem.SanitizeAnnouncement(message, maxLength);
|
|
SendMessage(new CommunicationsConsoleAnnounceMessage(msg));
|
|
}
|
|
|
|
public void ScreenBroadcastButtonPressed(string message)
|
|
{
|
|
SendMessage(new CommunicationsConsoleBroadcastMessage(message));
|
|
}
|
|
|
|
public void CallShuttle()
|
|
{
|
|
SendMessage(new CommunicationsConsoleCallEmergencyShuttleMessage());
|
|
}
|
|
|
|
public void RecallShuttle()
|
|
{
|
|
SendMessage(new CommunicationsConsoleRecallEmergencyShuttleMessage());
|
|
}
|
|
|
|
// TODO: Use component states and update in an AfterAutoHandleState subscription
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
|
|
if (state is not CommunicationsConsoleInterfaceState commsState)
|
|
return;
|
|
|
|
var stationUid = _station.GetOwningStation(Owner);
|
|
|
|
if (!EntMan.TryGetComponent<AlertLevelComponent>(stationUid, out var alertComp))
|
|
return;
|
|
|
|
if (_menu != null)
|
|
{
|
|
var currentAlertLevel = alertComp.CurrentAlertLevel;
|
|
var selectableAlertLevels = _alertLevel.GetSelectableAlertLevels((stationUid.Value, alertComp));
|
|
var canChangeAlertLevel = _alertLevel.CanChangeAlertLevel((stationUid.Value, alertComp));
|
|
|
|
_menu.UpdateState(commsState, currentAlertLevel, selectableAlertLevels, canChangeAlertLevel);
|
|
}
|
|
}
|
|
}
|