mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-14 19:30:01 +01:00
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:
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
- Hide
|
||||
- HideLabel
|
||||
hideOnInit: true
|
||||
- type: ActivatableUI
|
||||
key: enum.IFFConsoleUiKey.Key
|
||||
- type: UserInterface
|
||||
|
||||
Reference in New Issue
Block a user