]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Merge IFF controls into one control. Make syndicate IFF turned off by default. ...
authorEchoOfNothing <52498373+EchoOfNothing@users.noreply.github.com>
Sat, 27 Dec 2025 14:18:45 +0000 (16:18 +0200)
committerGitHub <noreply@github.com>
Sat, 27 Dec 2025 14:18:45 +0000 (14:18 +0000)
* Merge IFF controls into one control.

* Implement logic to hide IFF of sydicate IFF console on map load. Add hideOnInit property to IFFConsoleComponent

* DataField

---------

Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Content.Client/Shuttles/BUI/IFFConsoleBoundUserInterface.cs
Content.Client/Shuttles/UI/IFFConsoleWindow.xaml
Content.Client/Shuttles/UI/IFFConsoleWindow.xaml.cs
Content.Server/Shuttles/Components/IFFConsoleComponent.cs
Content.Server/Shuttles/Systems/ShuttleSystem.IFF.cs
Content.Shared/Shuttles/Events/IFFShowVesselMessage.cs [deleted file]
Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml

index 8d84abed8a5c4c0da52deae998957bdb9c581fc0..704307f06b792779899bd29952073fdae33d6d83 100644 (file)
@@ -23,7 +23,6 @@ public sealed class IFFConsoleBoundUserInterface : BoundUserInterface
 
         _window = this.CreateWindowCenteredLeft<IFFConsoleWindow>();
         _window.ShowIFF += SendIFFMessage;
-        _window.ShowVessel += SendVesselMessage;
     }
 
     protected override void UpdateState(BoundUserInterfaceState state)
@@ -44,14 +43,6 @@ public sealed class IFFConsoleBoundUserInterface : BoundUserInterface
         });
     }
 
-    private void SendVesselMessage(bool obj)
-    {
-        SendMessage(new IFFShowVesselMessage()
-        {
-            Show = obj,
-        });
-    }
-
     protected override void Dispose(bool disposing)
     {
         base.Dispose(disposing);
index dab11a7b622704c760b271b171bcedbf0c38ad9a..90684889a688e895c3a5a914ca99e52395b027d2 100644 (file)
@@ -9,12 +9,6 @@
                 <Button Name="ShowIFFOnButton" Text="{Loc 'iff-console-on'}" StyleClasses="OpenRight" />
                 <Button Name="ShowIFFOffButton" Text="{Loc 'iff-console-off'}" StyleClasses="OpenLeft" />
             </BoxContainer>
-
-            <Label Name="ShowVesselLabel" Text="{Loc 'iff-console-show-vessel-label'}" HorizontalExpand="True" StyleClasses="highlight" />
-            <BoxContainer Orientation="Horizontal" MinWidth="120">
-                <Button Name="ShowVesselOnButton" Text="{Loc 'iff-console-on'}" StyleClasses="OpenRight" />
-                <Button Name="ShowVesselOffButton" Text="{Loc 'iff-console-off'}" StyleClasses="OpenLeft" />
-            </BoxContainer>
         </GridContainer>
     </BoxContainer>
 </controls:FancyWindow>
index f14ef22c3c3abfa5a5e920e2a705d2cc58ddc7ec..d61486d2d8613c160ae3b10ae94fd6ba94618940 100644 (file)
@@ -13,9 +13,7 @@ public sealed partial class IFFConsoleWindow : FancyWindow,
     IComputerWindow<IFFConsoleBoundUserInterfaceState>
 {
     private readonly ButtonGroup _showIFFButtonGroup = new();
-    private readonly ButtonGroup _showVesselButtonGroup = new();
     public event Action<bool>? ShowIFF;
-    public event Action<bool>? ShowVessel;
 
     public IFFConsoleWindow()
     {
@@ -24,11 +22,6 @@ public sealed partial class IFFConsoleWindow : FancyWindow,
         ShowIFFOnButton.Group = _showIFFButtonGroup;
         ShowIFFOnButton.OnPressed += args => ShowIFFPressed(true);
         ShowIFFOffButton.OnPressed += args => ShowIFFPressed(false);
-
-        ShowVesselOffButton.Group = _showVesselButtonGroup;
-        ShowVesselOnButton.Group = _showVesselButtonGroup;
-        ShowVesselOnButton.OnPressed += args => ShowVesselPressed(true);
-        ShowVesselOffButton.OnPressed += args => ShowVesselPressed(false);
     }
 
     private void ShowIFFPressed(bool pressed)
@@ -36,19 +29,14 @@ public sealed partial class IFFConsoleWindow : FancyWindow,
         ShowIFF?.Invoke(pressed);
     }
 
-    private void ShowVesselPressed(bool pressed)
-    {
-        ShowVessel?.Invoke(pressed);
-    }
-
     public void UpdateState(IFFConsoleBoundUserInterfaceState state)
     {
-        if ((state.AllowedFlags & IFFFlags.HideLabel) != 0x0)
+        if ((state.AllowedFlags & IFFFlags.HideLabel) != 0x0 || (state.AllowedFlags & IFFFlags.Hide) != 0x0)
         {
             ShowIFFOffButton.Disabled = false;
             ShowIFFOnButton.Disabled = false;
 
-            if ((state.Flags & IFFFlags.HideLabel) != 0x0)
+            if ((state.Flags & IFFFlags.HideLabel) != 0x0 || (state.Flags & IFFFlags.Hide) != 0x0)
             {
                 ShowIFFOffButton.Pressed = true;
             }
@@ -62,25 +50,5 @@ public sealed partial class IFFConsoleWindow : FancyWindow,
             ShowIFFOffButton.Disabled = true;
             ShowIFFOnButton.Disabled = true;
         }
-
-        if ((state.AllowedFlags & IFFFlags.Hide) != 0x0)
-        {
-            ShowVesselOffButton.Disabled = false;
-            ShowVesselOnButton.Disabled = false;
-
-            if ((state.Flags & IFFFlags.Hide) != 0x0)
-            {
-                ShowVesselOffButton.Pressed = true;
-            }
-            else
-            {
-                ShowVesselOnButton.Pressed = true;
-            }
-        }
-        else
-        {
-            ShowVesselOffButton.Disabled = true;
-            ShowVesselOnButton.Disabled = true;
-        }
     }
 }
index 562bec51c26b01dc55c2f2ccad5004371029f3da..8db81dc1fd58746c5ab4ac789ca0d7e1281a5fae 100644 (file)
@@ -11,4 +11,7 @@ public sealed partial class IFFConsoleComponent : Component
     /// </summary>
     [ViewVariables(VVAccess.ReadWrite), DataField("allowedFlags")]
     public IFFFlags AllowedFlags = IFFFlags.HideLabel;
+
+    [DataField]
+    public bool HideOnInit = false;
 }
index 5e746fd49538ddba6cb96918a6d09c06a0681f1a..e8d2e13e800825fe80c6b919f145abaf51b98596 100644 (file)
@@ -12,7 +12,7 @@ public sealed partial class ShuttleSystem
     {
         SubscribeLocalEvent<IFFConsoleComponent, AnchorStateChangedEvent>(OnIFFConsoleAnchor);
         SubscribeLocalEvent<IFFConsoleComponent, IFFShowIFFMessage>(OnIFFShow);
-        SubscribeLocalEvent<IFFConsoleComponent, IFFShowVesselMessage>(OnIFFShowVessel);
+        SubscribeLocalEvent<IFFConsoleComponent, MapInitEvent>(OnInitIFFConsole);
         SubscribeLocalEvent<GridSplitEvent>(OnGridSplit);
     }
 
@@ -37,38 +37,48 @@ public sealed partial class ShuttleSystem
 
     private void OnIFFShow(EntityUid uid, IFFConsoleComponent component, IFFShowIFFMessage args)
     {
-        if (!TryComp(uid, out TransformComponent? xform) || xform.GridUid == null ||
-            (component.AllowedFlags & IFFFlags.HideLabel) == 0x0)
+        if (!TryComp(uid, out TransformComponent? xform) || xform.GridUid == null)
         {
             return;
         }
 
+        // Merged toggle controls both HideLabel and Hide flags
         if (!args.Show)
         {
-            AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
+            if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
+            {
+                AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
+            }
+            if ((component.AllowedFlags & IFFFlags.Hide) != 0x0)
+            {
+                AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
+            }
         }
         else
         {
-            RemoveIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
+            if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
+            {
+                RemoveIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
+            }
+            if ((component.AllowedFlags & IFFFlags.Hide) != 0x0)
+            {
+                RemoveIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
+            }
         }
     }
 
-    private void OnIFFShowVessel(EntityUid uid, IFFConsoleComponent component, IFFShowVesselMessage args)
+    private void OnInitIFFConsole(EntityUid uid, IFFConsoleComponent component, MapInitEvent args)
     {
-        if (!TryComp(uid, out TransformComponent? xform) || xform.GridUid == null ||
-            (component.AllowedFlags & IFFFlags.Hide) == 0x0)
+        if (!TryComp(uid, out TransformComponent? xform) || xform.GridUid == null)
         {
             return;
         }
 
-        if (!args.Show)
+        if (component.HideOnInit)
         {
+            AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
             AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
         }
-        else
-        {
-            RemoveIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
-        }
     }
 
     private void OnIFFConsoleAnchor(EntityUid uid, IFFConsoleComponent component, ref AnchorStateChangedEvent args)
diff --git a/Content.Shared/Shuttles/Events/IFFShowVesselMessage.cs b/Content.Shared/Shuttles/Events/IFFShowVesselMessage.cs
deleted file mode 100644 (file)
index 77ccaf2..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-using Robust.Shared.Serialization;
-
-namespace Content.Shared.Shuttles.Events;
-
-[Serializable, NetSerializable]
-public sealed class IFFShowVesselMessage : BoundUserInterfaceMessage
-{
-    public bool Show;
-}
index 91db6d2fb093cb5b30246f2ff820207ea7b1fdb9..0bc3e0487e5457fdad9aeb450b59398174ae6cd0 100644 (file)
     allowedFlags:
       - Hide
       - HideLabel
+    hideOnInit: true
   - type: ActivatableUI
     key: enum.IFFConsoleUiKey.Key
   - type: UserInterface