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:
parent
0a6a32e8a1
commit
9e2b871882
|
|
@ -23,7 +23,6 @@ public sealed class IFFConsoleBoundUserInterface : BoundUserInterface
|
||||||
|
|
||||||
_window = this.CreateWindowCenteredLeft<IFFConsoleWindow>();
|
_window = this.CreateWindowCenteredLeft<IFFConsoleWindow>();
|
||||||
_window.ShowIFF += SendIFFMessage;
|
_window.ShowIFF += SendIFFMessage;
|
||||||
_window.ShowVessel += SendVesselMessage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateState(BoundUserInterfaceState state)
|
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)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,6 @@
|
||||||
<Button Name="ShowIFFOnButton" Text="{Loc 'iff-console-on'}" StyleClasses="OpenRight" />
|
<Button Name="ShowIFFOnButton" Text="{Loc 'iff-console-on'}" StyleClasses="OpenRight" />
|
||||||
<Button Name="ShowIFFOffButton" Text="{Loc 'iff-console-off'}" StyleClasses="OpenLeft" />
|
<Button Name="ShowIFFOffButton" Text="{Loc 'iff-console-off'}" StyleClasses="OpenLeft" />
|
||||||
</BoxContainer>
|
</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>
|
</GridContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</controls:FancyWindow>
|
</controls:FancyWindow>
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,7 @@ public sealed partial class IFFConsoleWindow : FancyWindow,
|
||||||
IComputerWindow<IFFConsoleBoundUserInterfaceState>
|
IComputerWindow<IFFConsoleBoundUserInterfaceState>
|
||||||
{
|
{
|
||||||
private readonly ButtonGroup _showIFFButtonGroup = new();
|
private readonly ButtonGroup _showIFFButtonGroup = new();
|
||||||
private readonly ButtonGroup _showVesselButtonGroup = new();
|
|
||||||
public event Action<bool>? ShowIFF;
|
public event Action<bool>? ShowIFF;
|
||||||
public event Action<bool>? ShowVessel;
|
|
||||||
|
|
||||||
public IFFConsoleWindow()
|
public IFFConsoleWindow()
|
||||||
{
|
{
|
||||||
|
|
@ -24,11 +22,6 @@ public sealed partial class IFFConsoleWindow : FancyWindow,
|
||||||
ShowIFFOnButton.Group = _showIFFButtonGroup;
|
ShowIFFOnButton.Group = _showIFFButtonGroup;
|
||||||
ShowIFFOnButton.OnPressed += args => ShowIFFPressed(true);
|
ShowIFFOnButton.OnPressed += args => ShowIFFPressed(true);
|
||||||
ShowIFFOffButton.OnPressed += args => ShowIFFPressed(false);
|
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)
|
private void ShowIFFPressed(bool pressed)
|
||||||
|
|
@ -36,19 +29,14 @@ public sealed partial class IFFConsoleWindow : FancyWindow,
|
||||||
ShowIFF?.Invoke(pressed);
|
ShowIFF?.Invoke(pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowVesselPressed(bool pressed)
|
|
||||||
{
|
|
||||||
ShowVessel?.Invoke(pressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateState(IFFConsoleBoundUserInterfaceState state)
|
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;
|
ShowIFFOffButton.Disabled = false;
|
||||||
ShowIFFOnButton.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.Pressed = true;
|
||||||
}
|
}
|
||||||
|
|
@ -62,25 +50,5 @@ public sealed partial class IFFConsoleWindow : FancyWindow,
|
||||||
ShowIFFOffButton.Disabled = true;
|
ShowIFFOffButton.Disabled = true;
|
||||||
ShowIFFOnButton.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,7 @@ public sealed partial class IFFConsoleComponent : Component
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("allowedFlags")]
|
[ViewVariables(VVAccess.ReadWrite), DataField("allowedFlags")]
|
||||||
public IFFFlags AllowedFlags = IFFFlags.HideLabel;
|
public IFFFlags AllowedFlags = IFFFlags.HideLabel;
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public bool HideOnInit = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public sealed partial class ShuttleSystem
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<IFFConsoleComponent, AnchorStateChangedEvent>(OnIFFConsoleAnchor);
|
SubscribeLocalEvent<IFFConsoleComponent, AnchorStateChangedEvent>(OnIFFConsoleAnchor);
|
||||||
SubscribeLocalEvent<IFFConsoleComponent, IFFShowIFFMessage>(OnIFFShow);
|
SubscribeLocalEvent<IFFConsoleComponent, IFFShowIFFMessage>(OnIFFShow);
|
||||||
SubscribeLocalEvent<IFFConsoleComponent, IFFShowVesselMessage>(OnIFFShowVessel);
|
SubscribeLocalEvent<IFFConsoleComponent, MapInitEvent>(OnInitIFFConsole);
|
||||||
SubscribeLocalEvent<GridSplitEvent>(OnGridSplit);
|
SubscribeLocalEvent<GridSplitEvent>(OnGridSplit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,38 +37,48 @@ public sealed partial class ShuttleSystem
|
||||||
|
|
||||||
private void OnIFFShow(EntityUid uid, IFFConsoleComponent component, IFFShowIFFMessage args)
|
private void OnIFFShow(EntityUid uid, IFFConsoleComponent component, IFFShowIFFMessage args)
|
||||||
{
|
{
|
||||||
if (!TryComp(uid, out TransformComponent? xform) || xform.GridUid == null ||
|
if (!TryComp(uid, out TransformComponent? xform) || xform.GridUid == null)
|
||||||
(component.AllowedFlags & IFFFlags.HideLabel) == 0x0)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merged toggle controls both HideLabel and Hide flags
|
||||||
if (!args.Show)
|
if (!args.Show)
|
||||||
|
{
|
||||||
|
if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
|
||||||
{
|
{
|
||||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
||||||
}
|
}
|
||||||
|
if ((component.AllowedFlags & IFFFlags.Hide) != 0x0)
|
||||||
|
{
|
||||||
|
AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
|
||||||
{
|
{
|
||||||
RemoveIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
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 ||
|
if (!TryComp(uid, out TransformComponent? xform) || xform.GridUid == null)
|
||||||
(component.AllowedFlags & IFFFlags.Hide) == 0x0)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.Show)
|
if (component.HideOnInit)
|
||||||
{
|
{
|
||||||
|
AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
||||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
RemoveIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnIFFConsoleAnchor(EntityUid uid, IFFConsoleComponent component, ref AnchorStateChangedEvent args)
|
private void OnIFFConsoleAnchor(EntityUid uid, IFFConsoleComponent component, ref AnchorStateChangedEvent args)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
|
|
||||||
namespace Content.Shared.Shuttles.Events;
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public sealed class IFFShowVesselMessage : BoundUserInterfaceMessage
|
|
||||||
{
|
|
||||||
public bool Show;
|
|
||||||
}
|
|
||||||
|
|
@ -283,6 +283,7 @@
|
||||||
allowedFlags:
|
allowedFlags:
|
||||||
- Hide
|
- Hide
|
||||||
- HideLabel
|
- HideLabel
|
||||||
|
hideOnInit: true
|
||||||
- type: ActivatableUI
|
- type: ActivatableUI
|
||||||
key: enum.IFFConsoleUiKey.Key
|
key: enum.IFFConsoleUiKey.Key
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue