From b466e22ddfed908e5f8826900234432e71dc2aa0 Mon Sep 17 00:00:00 2001
From: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com>
Date: Thu, 4 Jan 2024 08:02:27 +0300
Subject: [PATCH] Implemented IFF search (#826)
---
Content.Client/Shuttles/UI/RadarControl.cs | 23 ++++++++-----------
.../Shuttles/UI/ShuttleConsoleWindow.xaml | 8 +++++++
.../Shuttles/UI/ShuttleConsoleWindow.xaml.cs | 16 +++++++++++++
Resources/Locale/en-US/shuttles/console.ftl | 2 ++
4 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/Content.Client/Shuttles/UI/RadarControl.cs b/Content.Client/Shuttles/UI/RadarControl.cs
index 151c19eb131..735fdf564e0 100644
--- a/Content.Client/Shuttles/UI/RadarControl.cs
+++ b/Content.Client/Shuttles/UI/RadarControl.cs
@@ -45,6 +45,11 @@ public sealed class RadarControl : MapGridControl
public bool ShowIFFShuttles { get; set; } = true;
public bool ShowDocks { get; set; } = true;
+ ///
+ /// If present, called for every IFF. Must determine if it should or should not be shown.
+ ///
+ public Func? IFFFilter { get; set; } = null;
+
///
/// Currently hovered docked to show on the map.
///
@@ -286,19 +291,11 @@ protected override void Draw(DrawingHandleScreen handle)
uiPosition = new Vector2(uiX + uiXCentre, uiY + uiYCentre);
}
- if (!ShowIFFShuttles)
- {
- if (iff != null && (iff.Flags & IFFFlags.IsPlayerShuttle) != 0x0)
- {
- label.Visible = false;
- }
- else
- label.Visible = true;
- }
- else
- {
- label.Visible = true;
- }
+ label.Visible = ShowIFFShuttles
+ || iff == null || (iff.Flags & IFFFlags.IsPlayerShuttle) == 0x0;
+
+ if (IFFFilter != null)
+ label.Visible &= IFFFilter(gUid, grid.Comp, iff);
label.Text = Loc.GetString("shuttle-console-iff-label", ("name", name), ("distance", $"{distance:0.0}"));
LayoutContainer.SetPosition(label, uiPosition);
diff --git a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml
index 653813f909f..2e62fd88f2e 100644
--- a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml
+++ b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml
@@ -103,6 +103,7 @@
Align="Right"/>
+
+
+
+
+
+
+
+
diff --git a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
index 973c72704e6..abd8d81e432 100644
--- a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
+++ b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
@@ -65,6 +65,9 @@ public ShuttleConsoleWindow()
DockToggle.Pressed = RadarScreen.ShowDocks;
UndockButton.OnPressed += OnUndockPressed;
+
+ // Frontier - IFF search
+ IffSearchCriteria.OnTextChanged += args => OnIffSearchChanged(args.Text);
}
private void WorldRangeChange(float value)
@@ -95,6 +98,19 @@ private void OnUndockPressed(BaseButton.ButtonEventArgs args)
UndockPressed?.Invoke(DockingScreen.ViewedDock.Value);
}
+ private void OnIffSearchChanged(string text)
+ {
+ text = text.Trim();
+
+ RadarScreen.IFFFilter = text.Length == 0
+ ? null // If empty, do not filter
+ : (entity, grid, iff) => // Otherwise use simple search criteria
+ {
+ _entManager.TryGetComponent(entity, out var metadata);
+ return metadata != null && metadata.EntityName.Contains(text, StringComparison.OrdinalIgnoreCase);
+ };
+ }
+
public void SetMatrix(EntityCoordinates? coordinates, Angle? angle)
{
_shuttleEntity = coordinates?.EntityId;
diff --git a/Resources/Locale/en-US/shuttles/console.ftl b/Resources/Locale/en-US/shuttles/console.ftl
index 564a1631730..b8bb9a83e56 100644
--- a/Resources/Locale/en-US/shuttles/console.ftl
+++ b/Resources/Locale/en-US/shuttles/console.ftl
@@ -34,6 +34,8 @@ shuttle-console-hyperspace-none = No destinations found
shuttle-console-unknown = Unknown
shuttle-console-iff-label = {$name} ({$distance}m)
+shuttle-console-iff-search = Search IFF
+
# Buttons
shuttle-console-strafing = Strafing mode
shuttle-console-iff-toggle = Show IFF