mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Scope creep my ass * why was this shit not pushed???? * gone... * fix that * review plus buildd * asfsafsafsafsafas * grug * burber * I'll fix this later * shrimply die * also this * it's snerf or snuthin * assaads * round snend * aaaa * fix this shit for real * actually, don't start GameRules until MapInit now that I think aboot it. * forgot u * don't actually need this part nullable * Deffer comp removal * one liner * do that too * chungus * Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?) * deferred removal :V * aaaaaaaaaaaaaaa * whhop * Whoop * better * landmine that I placed for myself then forgot about lmao * cleanup * FUCKING `!` * gotovo * amogus * please don't check by metadata I beg * waawsasfdfsasfa * sfafsasfafsas * fdsaasffsasfa * code * fix * fasasffasfasfsad * chungaas * I may be stupid * gra * graaaaaaaaaaaaaaaaa * comment * gra * clearing is not predicted and would require major refactors, so don't cache on client. * lame shit :P * last holes * nukeopsfsafsasafsfafsa * why was that shit public bruh * bubrbgwahrghfaka * dynamic * revert change that did nothing lmao
101 lines
3.8 KiB
C#
101 lines
3.8 KiB
C#
using Content.Shared.CCVar;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.AlertLevel;
|
|
using Content.Shared.Communications;
|
|
using Content.Shared.Station.Systems;
|
|
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 StationSystem _station = default!;
|
|
[Dependency] private AlertLevelSystem _alertLevel = default!;
|
|
|
|
[ViewVariables]
|
|
private CommunicationsConsoleMenu? _menu;
|
|
|
|
private static readonly EntProtoId FallbackScreen = "Screen";
|
|
|
|
/// <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);
|
|
else
|
|
_menu.SetBroadcastDisplayEntity(FallbackScreen);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|