Files
OldThink/Content.Client/Communications/UI/CommunicationsConsoleBoundUserInterface.cs

127 lines
4.1 KiB
C#
Raw Normal View History

using Content.Shared.CCVar;
using Content.Shared.Chat;
using Content.Shared.Communications;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;
Cherry picks 6 (#486) * inital * force them to WRITE * b * new system * aaaa * b * bbbb * translations * add tts support for evacuation reason * PaddedStool_Sprite&Prototype 8 colors of pudded stool. * PaddedStool_Crafting * ComfyChair_Sprites&Prototype * ComfyChair_Crafting * Sofa_Sprites&Prototype * Sofa_Crafting * Sofa_SpriteFix * Sofa_RemoveSomeSprites * Revert "Sofa_RemoveSomeSprites" This reverts commit b110e9bda9a75cf6337c4efacd4888967d0e1fe6. * Revert "Sofa_SpriteFix" This reverts commit bfa8a17c16c57d2f70d64eb8dd54ae94ac48b248. * Revert "Sofa_Crafting" This reverts commit 89daadcb1e9d45a84281a5fdf998ab6c6f6b0f9b. * Revert "Sofa_Sprites&Prototype" This reverts commit 73cd0be403e03b1852a4632e1b6a8ca7526c5622. * Revert "ComfyChair_Crafting" This reverts commit 940f9665dd998090b43bca596ef3800c0c6ba89b. * Revert "ComfyChair_Sprites&Prototype" This reverts commit 2c909de5d3e3f4ab5efa1cbef6b5feda32d05a80. * Revert "PaddedStool_Crafting" This reverts commit 82040ba82c0190f2a52614fd3573e77586d73802. * Revert "PaddedStool_Sprite&Prototype" This reverts commit c5241a03ffeccbb4a18ab0f108d05c4fe1e047ba. * Sprites&Meta * Crafting * Tweaks * PaddedStool_tweaks * Add Random Spawners * remove old colored chairs * Sprites&Meta * Changing prototypes * Adding to Theater vend * Sprite_Change * Sprite_Change * Prototype_Changes Is this exactly how it should be?... * add bouquet * Not very useful functionality has been removed * Update toys.yml * Now you need cloth to made bouquet * Update toys.yml * I hope. I done right * Update toys.yml * Update bouquet.yml * Update toys.yml * Update Resources/Prototypes/Recipes/Crafting/Graphs/toys.yml Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> * add musician jumpskirt to loadouts * better bouquet * pAIs can now be inserted into plushies. * No more bad bleed * More Tourniquets, hopefully fixed YML check. * deals a bit of bloodloss * Reduce Stack Count. * fix tourniquet * add migrations for old chair types and add few new --------- Co-authored-by: Mr. 27 <koolthunder019@gmail.com> Co-authored-by: Арт <123451459+JustArt1m@users.noreply.github.com> Co-authored-by: Green resomi <135062489+Yeah-I-listening-Hollywood-undead@users.noreply.github.com> Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> Co-authored-by: Moomoobeef <moomoobeef@protonmail.com> Co-authored-by: PoorMansDreams <andyroblox14@gmail.com>
2024-07-23 20:37:15 +03:00
using Robust.Shared.Prototypes;
2021-06-09 22:19:39 +02:00
namespace Content.Client.Communications.UI
{
public sealed class CommunicationsConsoleBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
2023-07-08 09:02:17 -07:00
[ViewVariables]
private CommunicationsConsoleMenu? _menu;
2023-07-08 09:02:17 -07:00
[ViewVariables]
public bool CanAnnounce { get; private set; }
[ViewVariables]
public bool CanBroadcast { get; private set; }
2023-07-08 09:02:17 -07:00
[ViewVariables]
public bool CanCall { get; private set; }
2023-07-08 09:02:17 -07:00
[ViewVariables]
public bool CountdownStarted { get; private set; }
2023-07-08 09:02:17 -07:00
[ViewVariables]
2022-05-17 21:05:31 -07:00
public bool AlertLevelSelectable { get; private set; }
2023-07-08 09:02:17 -07:00
[ViewVariables]
2022-05-17 21:05:31 -07:00
public string CurrentLevel { get; private set; } = default!;
2023-07-08 09:02:17 -07:00
[ViewVariables]
private TimeSpan? _expectedCountdownTime;
2023-07-08 09:02:17 -07:00
public int Countdown => _expectedCountdownTime == null ? 0 : Math.Max((int) _expectedCountdownTime.Value.Subtract(_gameTiming.CurTime).TotalSeconds, 0);
2023-07-08 09:02:17 -07:00
public CommunicationsConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_menu = new CommunicationsConsoleMenu(this);
_menu.OnClose += Close;
_menu.OpenCentered();
}
2022-05-17 21:05:31 -07:00
public void AlertLevelSelected(string level)
{
if (AlertLevelSelectable)
{
CurrentLevel = level;
SendMessage(new CommunicationsConsoleSelectAlertLevelMessage(level));
}
}
2020-04-09 01:43:28 +02:00
public void EmergencyShuttleButtonPressed()
{
if (CountdownStarted)
2020-04-09 01:43:28 +02:00
RecallShuttle();
else
CallShuttle();
}
public void AnnounceButtonPressed(string message)
{
var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
var msg = SharedChatSystem.SanitizeAnnouncement(message, maxLength);
SendMessage(new CommunicationsConsoleAnnounceMessage(msg));
}
public void BroadcastButtonPressed(string message)
{
SendMessage(new CommunicationsConsoleBroadcastMessage(message));
}
public void CallShuttle()
{
SendMessage(new CommunicationsConsoleCallEmergencyShuttleMessage());
}
2020-04-09 01:43:28 +02:00
public void RecallShuttle()
{
SendMessage(new CommunicationsConsoleRecallEmergencyShuttleMessage());
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not CommunicationsConsoleInterfaceState commsState)
return;
CanAnnounce = commsState.CanAnnounce;
CanBroadcast = commsState.CanBroadcast;
CanCall = commsState.CanCall;
_expectedCountdownTime = commsState.ExpectedCountdownEnd;
CountdownStarted = commsState.CountdownStarted;
2022-05-17 21:05:31 -07:00
AlertLevelSelectable = commsState.AlertLevels != null && !float.IsNaN(commsState.CurrentAlertDelay) && commsState.CurrentAlertDelay <= 0;
CurrentLevel = commsState.CurrentAlert;
if (_menu != null)
{
_menu.UpdateCountdown();
2022-05-17 21:05:31 -07:00
_menu.UpdateAlertLevels(commsState.AlertLevels, CurrentLevel);
_menu.AlertLevelButton.Disabled = !AlertLevelSelectable;
_menu.EmergencyShuttleButton.Disabled = !CanCall;
_menu.AnnounceButton.Disabled = !CanAnnounce;
_menu.BroadcastButton.Disabled = !CanBroadcast;
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
_menu?.Dispose();
}
}
}