IFF console (#10504)

* IFF console

* Silly

* Color

* a

* Const bool default

* Full stealth as well coz dork.

* Infiltrator update
This commit is contained in:
metalgearsloth
2022-08-12 02:58:44 +10:00
committed by GitHub
parent 6feb10502f
commit b4248482c5
20 changed files with 702 additions and 113 deletions

View File

@@ -0,0 +1,64 @@
using Content.Client.Shuttles.UI;
using Content.Shared.Shuttles.BUIStates;
using Content.Shared.Shuttles.Events;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client.Shuttles.BUI;
[UsedImplicitly]
public sealed class IFFConsoleBoundUserInterface : BoundUserInterface
{
private IFFConsoleWindow? _window;
public IFFConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new IFFConsoleWindow();
_window.OnClose += Close;
_window.ShowIFF += SendIFFMessage;
_window.ShowVessel += SendVesselMessage;
_window.OpenCenteredLeft();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not IFFConsoleBoundUserInterfaceState bState)
return;
_window?.UpdateState(bState);
}
private void SendIFFMessage(bool obj)
{
SendMessage(new IFFShowIFFMessage()
{
Show = obj,
});
}
private void SendVesselMessage(bool obj)
{
SendMessage(new IFFShowVesselMessage()
{
Show = obj,
});
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_window?.Close();
_window = null;
}
}
}

View File

@@ -1,6 +1,6 @@
<userInterface:FancyWindow xmlns="https://spacestation14.io"
xmlns:userInterface="clr-namespace:Content.Client.UserInterface"
Title="Emergency Shuttle Console"
Title="{Loc 'emergency-shuttle-console-window-title'}"
MinSize="400 400">
<BoxContainer Orientation="Vertical"
Margin="5">

View File

@@ -0,0 +1,20 @@
<userInterface:FancyWindow xmlns="https://spacestation14.io"
xmlns:userInterface="clr-namespace:Content.Client.UserInterface"
Title="{Loc 'iff-console-window-title'}"
MinSize="200 200">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<GridContainer Margin="4 0 0 0" Columns="2">
<Label Name="ShowIFFLabel" Text="{Loc 'iff-console-show-iff-label'}" HorizontalExpand="True" StyleClasses="StatusFieldTitle" />
<BoxContainer Orientation="Horizontal" MinWidth="120">
<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="StatusFieldTitle" />
<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>
</userInterface:FancyWindow>

View File

@@ -0,0 +1,86 @@
using Content.Client.Computer;
using Content.Client.UserInterface;
using Content.Shared.Shuttles.BUIStates;
using Content.Shared.Shuttles.Components;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Shuttles.UI;
[GenerateTypedNameReferences]
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()
{
RobustXamlLoader.Load(this);
ShowIFFOffButton.Group = _showIFFButtonGroup;
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)
{
ShowIFFOffButton.Disabled = false;
ShowIFFOnButton.Disabled = false;
if ((state.Flags & IFFFlags.HideLabel) != 0x0)
{
ShowIFFOffButton.Pressed = true;
}
else
{
ShowIFFOnButton.Pressed = true;
}
}
else
{
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

@@ -1,5 +1,6 @@
using Content.Client.Stylesheets;
using Content.Shared.Shuttles.BUIStates;
using Content.Shared.Shuttles.Components;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
@@ -210,6 +211,15 @@ public sealed class RadarControl : Control
continue;
}
_entManager.TryGetComponent<IFFComponent>(grid.GridEntityId, out var iff);
// Hide it entirely.
if (iff != null &&
(iff.Flags & IFFFlags.Hide) != 0x0)
{
continue;
}
shown.Add(grid.GridEntityId);
var name = metaQuery.GetComponent(grid.GridEntityId).EntityName;
@@ -220,8 +230,11 @@ public sealed class RadarControl : Control
var gridFixtures = fixturesQuery.GetComponent(grid.GridEntityId);
var gridMatrix = gridXform.WorldMatrix;
Matrix3.Multiply(in gridMatrix, in offsetMatrix, out var matty);
var color = iff?.Color ?? IFFComponent.IFFColor;
if (ShowIFF)
if (ShowIFF &&
(iff == null && IFFComponent.ShowIFFDefault ||
(iff.Flags & IFFFlags.HideLabel) == 0x0))
{
var gridBounds = grid.LocalAABB;
Label label;
@@ -231,7 +244,6 @@ public sealed class RadarControl : Control
label = new Label()
{
HorizontalAlignment = HAlignment.Left,
FontColorOverride = Color.Aquamarine,
};
_iffControls[grid.GridEntityId] = label;
@@ -242,6 +254,7 @@ public sealed class RadarControl : Control
label = (Label) control;
}
label.FontColorOverride = color;
var gridCentre = matty.Transform(gridBody.LocalCenter);
gridCentre.Y = -gridCentre.Y;
var distance = gridCentre.Length;
@@ -267,7 +280,7 @@ public sealed class RadarControl : Control
}
// Detailed view
DrawGrid(handle, matty, gridFixtures, Color.Aquamarine);
DrawGrid(handle, matty, gridFixtures, color);
DrawDocks(handle, grid.GridEntityId, matty);
}