Merge IFF controls into one control. Make syndicate IFF turned off by default. (#42104)

* 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>
This commit is contained in:
EchoOfNothing
2025-12-27 16:18:45 +02:00
committed by GitHub
parent cd8d5a6a9c
commit ee2f1da8c2
7 changed files with 29 additions and 71 deletions

View 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);

View 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>

View 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;
}
}
}

View 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;
}

View 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)

View File

@@ -1,9 +0,0 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Shuttles.Events;
[Serializable, NetSerializable]
public sealed class IFFShowVesselMessage : BoundUserInterfaceMessage
{
public bool Show;
}

View File

@@ -283,6 +283,7 @@
allowedFlags:
- Hide
- HideLabel
hideOnInit: true
- type: ActivatableUI
key: enum.IFFConsoleUiKey.Key
- type: UserInterface