]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
uichange Communications Console (#14236)
authorDEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
Sat, 25 Mar 2023 14:51:16 +0000 (07:51 -0700)
committerGitHub <noreply@github.com>
Sat, 25 Mar 2023 14:51:16 +0000 (10:51 -0400)
Content.Client/Communications/UI/CommunicationsConsoleBoundUserInterface.cs
Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml [new file with mode: 0644]
Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs [moved from Content.Client/Communications/UI/CommunicationsConsoleMenu.cs with 61% similarity]

index f8dbfc0fe477916f2a3faf42a1e8a3c8e20c58ed..2a0da896f1684294bfc5ea447ae284c8bc2b5c6a 100644 (file)
@@ -28,6 +28,7 @@ namespace Content.Client.Communications.UI
 
         public CommunicationsConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
         {
+
         }
 
         protected override void Open()
diff --git a/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml b/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml
new file mode 100644 (file)
index 0000000..1f5ec1d
--- /dev/null
@@ -0,0 +1,16 @@
+<controls:FancyWindow xmlns="https://spacestation14.io"
+    xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
+    Title="{Loc 'comms-console-menu-title'}"
+    MinSize="350 225">
+    <BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True" Margin="5">
+        <LineEdit Name="MessageInput" PlaceHolder="{Loc 'comms-console-menu-announcement-placeholder'}" HorizontalExpand="True" Margin="0 0 0 5" />
+        <Button Name="AnnounceButton" Text="{Loc 'comms-console-menu-announcement-button'}" StyleClasses="OpenLeft" Access="Public" />
+
+        <OptionButton Name="AlertLevelButton" StyleClasses="OpenRight" Access="Public" />
+
+        <Control MinSize="10 10" />
+
+        <RichTextLabel Name="CountdownLabel" VerticalExpand="True" />
+        <Button Name="EmergencyShuttleButton" Text="Placeholder Text" Access="Public" />
+    </BoxContainer>
+</controls:FancyWindow>
similarity index 61%
rename from Content.Client/Communications/UI/CommunicationsConsoleMenu.cs
rename to Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs
index 293ab3ba5e47cb2dbb09281e61c8d9f825c60741..48bd0c014c73281655d0ce013531bf59d31dce93 100644 (file)
@@ -1,7 +1,10 @@
-using System.Threading;
+using Content.Client.UserInterface.Controls;
+using System.Threading;
+using Robust.Client.AutoGenerated;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.CustomControls;
+using Robust.Client.UserInterface.XAML;
 using Robust.Shared.IoC;
 using Robust.Shared.Localization;
 using Robust.Shared.Maths;
@@ -10,36 +13,22 @@ using Timer = Robust.Shared.Timing.Timer;
 
 namespace Content.Client.Communications.UI
 {
-    public sealed class CommunicationsConsoleMenu : DefaultWindow
+    [GenerateTypedNameReferences]
+    public sealed partial class CommunicationsConsoleMenu : FancyWindow
     {
         private CommunicationsConsoleBoundUserInterface Owner { get; set; }
         private readonly CancellationTokenSource _timerCancelTokenSource = new();
-        private LineEdit _messageInput { get; set; }
-        public readonly Button AnnounceButton;
-        public readonly Button EmergencyShuttleButton;
-        private readonly RichTextLabel _countdownLabel;
-        public readonly OptionButton AlertLevelButton;
 
         public CommunicationsConsoleMenu(CommunicationsConsoleBoundUserInterface owner)
         {
-            SetSize = MinSize = (600, 400);
             IoCManager.InjectDependencies(this);
+            RobustXamlLoader.Load(this);
 
-            Title = Loc.GetString("comms-console-menu-title");
             Owner = owner;
 
-            _messageInput = new LineEdit
-            {
-                PlaceHolder = Loc.GetString("comms-console-menu-announcement-placeholder"),
-                HorizontalExpand = true,
-                SizeFlagsStretchRatio = 1
-            };
-            AnnounceButton = new Button();
-            AnnounceButton.Text = Loc.GetString("comms-console-menu-announcement-button");
-            AnnounceButton.OnPressed += (_) => Owner.AnnounceButtonPressed(_messageInput.Text.Trim());
+            AnnounceButton.OnPressed += (_) => Owner.AnnounceButtonPressed(MessageInput.Text.Trim());
             AnnounceButton.Disabled = !owner.CanAnnounce;
 
-            AlertLevelButton = new OptionButton();
             AlertLevelButton.OnItemSelected += args =>
             {
                 var metadata = AlertLevelButton.GetItemMetadata(args.Id);
@@ -50,37 +39,9 @@ namespace Content.Client.Communications.UI
             };
             AlertLevelButton.Disabled = !owner.AlertLevelSelectable;
 
-            _countdownLabel = new RichTextLabel(){MinSize = new Vector2(0, 200)};
-            EmergencyShuttleButton = new Button();
             EmergencyShuttleButton.OnPressed += (_) => Owner.EmergencyShuttleButtonPressed();
             EmergencyShuttleButton.Disabled = !owner.CanCall;
 
-            var vbox = new BoxContainer
-            {
-                Orientation = LayoutOrientation.Vertical,
-                HorizontalExpand = true,
-                VerticalExpand = true
-            };
-            vbox.AddChild(_messageInput);
-            vbox.AddChild(new Control(){MinSize = new Vector2(0,10), HorizontalExpand = true});
-            vbox.AddChild(AnnounceButton);
-            vbox.AddChild(AlertLevelButton);
-            vbox.AddChild(new Control(){MinSize = new Vector2(0,10), HorizontalExpand = true});
-            vbox.AddChild(_countdownLabel);
-            vbox.AddChild(EmergencyShuttleButton);
-
-            var hbox = new BoxContainer
-            {
-                Orientation = LayoutOrientation.Horizontal,
-                HorizontalExpand = true,
-                VerticalExpand = true
-            };
-            hbox.AddChild(new Control(){MinSize = new Vector2(100,0), HorizontalExpand = true});
-            hbox.AddChild(vbox);
-            hbox.AddChild(new Control(){MinSize = new Vector2(100,0), HorizontalExpand = true});
-
-            Contents.AddChild(hbox);
-
             UpdateCountdown();
             Timer.SpawnRepeating(1000, UpdateCountdown, _timerCancelTokenSource.Token);
         }
@@ -126,13 +87,13 @@ namespace Content.Client.Communications.UI
         {
             if (!Owner.CountdownStarted)
             {
-                _countdownLabel.SetMessage("");
+                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");
+            CountdownLabel.SetMessage($"Time remaining\n{Owner.Countdown.ToString()}s");
         }
 
         public override void Close()