* 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>
_window = this.CreateWindowCenteredLeft<IFFConsoleWindow>();
_window.ShowIFF += SendIFFMessage;
- _window.ShowVessel += SendVesselMessage;
}
protected override void UpdateState(BoundUserInterfaceState state)
});
}
- private void SendVesselMessage(bool obj)
- {
- SendMessage(new IFFShowVesselMessage()
- {
- Show = obj,
- });
- }
-
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
<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>
IComputerWindow<IFFConsoleBoundUserInterfaceState>
{
private readonly ButtonGroup _showIFFButtonGroup = new();
- private readonly ButtonGroup _showVesselButtonGroup = new();
public event Action<bool>? ShowIFF;
- public event Action<bool>? ShowVessel;
public IFFConsoleWindow()
{
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)
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;
}
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;
- }
}
}
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("allowedFlags")]
public IFFFlags AllowedFlags = IFFFlags.HideLabel;
+
+ [DataField]
+ public bool HideOnInit = false;
}
{
SubscribeLocalEvent<IFFConsoleComponent, AnchorStateChangedEvent>(OnIFFConsoleAnchor);
SubscribeLocalEvent<IFFConsoleComponent, IFFShowIFFMessage>(OnIFFShow);
- SubscribeLocalEvent<IFFConsoleComponent, IFFShowVesselMessage>(OnIFFShowVessel);
+ SubscribeLocalEvent<IFFConsoleComponent, MapInitEvent>(OnInitIFFConsole);
SubscribeLocalEvent<GridSplitEvent>(OnGridSplit);
}
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)
+++ /dev/null
-using Robust.Shared.Serialization;
-
-namespace Content.Shared.Shuttles.Events;
-
-[Serializable, NetSerializable]
-public sealed class IFFShowVesselMessage : BoundUserInterfaceMessage
-{
- public bool Show;
-}
allowedFlags:
- Hide
- HideLabel
+ hideOnInit: true
- type: ActivatableUI
key: enum.IFFConsoleUiKey.Key
- type: UserInterface