Files
OldThink/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs

134 lines
4.9 KiB
C#
Raw Permalink Normal View History

using Content.Client.UserInterface.Controls;
using System.Threading;
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 Content.Shared.CCVar;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
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.Configuration;
2023-04-14 12:57:47 -07:00
using Robust.Shared.Utility;
using Timer = Robust.Shared.Timing.Timer;
2021-06-09 22:19:39 +02:00
namespace Content.Client.Communications.UI
{
[GenerateTypedNameReferences]
public sealed partial class CommunicationsConsoleMenu : FancyWindow
{
private CommunicationsConsoleBoundUserInterface Owner { get; set; }
private readonly CancellationTokenSource _timerCancelTokenSource = new();
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
[Dependency] private readonly IConfigurationManager _cfg = default!;
public CommunicationsConsoleMenu(CommunicationsConsoleBoundUserInterface owner)
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
Owner = owner;
2023-04-14 12:57:47 -07:00
var loc = IoCManager.Resolve<ILocalizationManager>();
MessageInput.Placeholder = new Rope.Leaf(loc.GetString("comms-console-menu-announcement-placeholder"));
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
var maxAnnounceLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
MessageInput.OnTextChanged += (args) =>
{
if (args.Control.TextLength > maxAnnounceLength)
{
AnnounceButton.Disabled = true;
AnnounceButton.ToolTip = Loc.GetString("comms-console-message-too-long");
}
else
{
AnnounceButton.Disabled = !owner.CanAnnounce;
AnnounceButton.ToolTip = null;
}
};
AnnounceButton.OnPressed += (_) => Owner.AnnounceButtonPressed(Rope.Collapse(MessageInput.TextRope));
AnnounceButton.Disabled = !owner.CanAnnounce;
BroadcastButton.OnPressed += (_) => Owner.BroadcastButtonPressed(Rope.Collapse(MessageInput.TextRope));
BroadcastButton.Disabled = !owner.CanBroadcast;
2022-05-17 21:05:31 -07:00
AlertLevelButton.OnItemSelected += args =>
{
var metadata = AlertLevelButton.GetItemMetadata(args.Id);
if (metadata != null && metadata is string cast)
{
Owner.AlertLevelSelected(cast);
}
};
AlertLevelButton.Disabled = !owner.AlertLevelSelectable;
EmergencyShuttleButton.OnPressed += (_) => Owner.EmergencyShuttleButtonPressed();
EmergencyShuttleButton.Disabled = !owner.CanCall;
UpdateCountdown();
Timer.SpawnRepeating(1000, UpdateCountdown, _timerCancelTokenSource.Token);
}
2022-05-17 21:05:31 -07:00
// The current alert could make levels unselectable, so we need to ensure that the UI reacts properly.
// If the current alert is unselectable, the only item in the alerts list will be
// the current alert. Otherwise, it will be the list of alerts, with the current alert
// selected.
public void UpdateAlertLevels(List<string>? alerts, string currentAlert)
{
AlertLevelButton.Clear();
if (alerts == null)
{
var name = currentAlert;
if (Loc.TryGetString($"alert-level-{currentAlert}", out var locName))
{
name = locName;
}
AlertLevelButton.AddItem(name);
2022-05-17 21:05:31 -07:00
AlertLevelButton.SetItemMetadata(AlertLevelButton.ItemCount - 1, currentAlert);
}
else
{
foreach (var alert in alerts)
{
var name = alert;
if (Loc.TryGetString($"alert-level-{alert}", out var locName))
{
name = locName;
}
AlertLevelButton.AddItem(name);
AlertLevelButton.SetItemMetadata(AlertLevelButton.ItemCount - 1, alert);
if (alert == currentAlert)
{
AlertLevelButton.Select(AlertLevelButton.ItemCount - 1);
}
2022-05-17 21:05:31 -07:00
}
}
}
public void UpdateCountdown()
{
if (!Owner.CountdownStarted)
{
CountdownLabel.SetMessage("");
EmergencyShuttleButton.Text = Loc.GetString("comms-console-menu-call-shuttle");
return;
}
EmergencyShuttleButton.Text = Loc.GetString("comms-console-menu-recall-shuttle");
CountdownLabel.SetMessage($"Time remaining\n{Owner.Countdown.ToString()}s");
}
public override void Close()
{
base.Close();
_timerCancelTokenSource.Cancel();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
_timerCancelTokenSource.Cancel();
}
}
}