Adds the NetProbe cartridge (#12543)
* Implement NetProbeCartridge * Add audio and a popup when scanning a device Add some doc comments * Set program icon * Add NetProbe cartridge as rare loot to maintenance loot tool spawner * Make the maximum amount of saved entries configurable Add a scrollbar that shows when there are more entries than fit on the screen * Make device net id names translatable
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
using Content.Shared.CartridgeLoader.Cartridges;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.CartridgeLoader.Cartridges;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class NetProbeUiFragment : BoxContainer
|
||||
{
|
||||
private readonly StyleBoxFlat _styleBox = new()
|
||||
{
|
||||
BackgroundColor = Color.Transparent,
|
||||
BorderColor = Color.FromHex("#5a5a5a"),
|
||||
BorderThickness = new Thickness(0, 0, 0, 1)
|
||||
};
|
||||
|
||||
public NetProbeUiFragment()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
Orientation = LayoutOrientation.Vertical;
|
||||
HorizontalExpand = true;
|
||||
VerticalExpand = true;
|
||||
HeaderPanel.PanelOverride = _styleBox;
|
||||
}
|
||||
|
||||
public void UpdateState(List<ProbedNetworkDevice> devices)
|
||||
{
|
||||
ProbedDeviceContainer.RemoveAllChildren();
|
||||
|
||||
//Reverse the list so the oldest entries appear at the bottom
|
||||
devices.Reverse();
|
||||
|
||||
//Enable scrolling if there are more entries that can fit on the screen
|
||||
ScrollContainer.HScrollEnabled = devices.Count > 9;
|
||||
|
||||
foreach (var device in devices)
|
||||
{
|
||||
AddProbedDevice(device);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddProbedDevice(ProbedNetworkDevice device)
|
||||
{
|
||||
var row = new BoxContainer();
|
||||
row.HorizontalExpand = true;
|
||||
row.Orientation = LayoutOrientation.Horizontal;
|
||||
row.Margin = new Thickness(4);
|
||||
|
||||
var nameLabel = new Label();
|
||||
nameLabel.Text = device.Name;
|
||||
nameLabel.HorizontalExpand = true;
|
||||
nameLabel.ClipText = true;
|
||||
row.AddChild(nameLabel);
|
||||
|
||||
var addressLabel = new Label();
|
||||
addressLabel.Text = device.Address;
|
||||
addressLabel.HorizontalExpand = true;
|
||||
addressLabel.ClipText = true;
|
||||
row.AddChild(addressLabel);
|
||||
|
||||
var frequencyLabel = new Label();
|
||||
frequencyLabel.Text = device.Frequency;
|
||||
frequencyLabel.HorizontalExpand = true;
|
||||
frequencyLabel.ClipText = true;
|
||||
row.AddChild(frequencyLabel);
|
||||
|
||||
var networkLabel = new Label();
|
||||
networkLabel.Text = device.NetId;
|
||||
networkLabel.HorizontalExpand = true;
|
||||
networkLabel.ClipText = true;
|
||||
row.AddChild(networkLabel);
|
||||
|
||||
ProbedDeviceContainer.AddChild(row);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user