Adds a link limit and UI to device list (#11017)
* adds a link limit to device list * locale strings * uhhh what's efcore doing there * adds a UI for device list on the device * merge conflict fixing
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Content.Client.NetworkConfigurator;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class NetworkConfiguratorDeviceList : ScrollContainer
|
||||
{
|
||||
public void UpdateState(NetworkConfiguratorBoundUserInterface? ui, HashSet<(string address, string name)> devices)
|
||||
{
|
||||
DeviceList.RemoveAllChildren();
|
||||
|
||||
foreach (var device in devices)
|
||||
{
|
||||
DeviceList.AddChild(BuildDeviceListRow(ui, device));
|
||||
}
|
||||
}
|
||||
|
||||
private static BoxContainer BuildDeviceListRow(NetworkConfiguratorBoundUserInterface? ui, (string address, string name) savedDevice)
|
||||
{
|
||||
var row = new BoxContainer()
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Horizontal,
|
||||
Margin = new Thickness(8)
|
||||
};
|
||||
|
||||
var name = new Label()
|
||||
{
|
||||
Text = savedDevice.name[..Math.Min(11, savedDevice.name.Length)],
|
||||
SetWidth = 84
|
||||
};
|
||||
|
||||
var address = new Label()
|
||||
{
|
||||
Text = savedDevice.address,
|
||||
HorizontalExpand = true,
|
||||
Align = Label.AlignMode.Center
|
||||
};
|
||||
|
||||
var removeButton = new TextureButton()
|
||||
{
|
||||
StyleClasses = { "CrossButtonRed" },
|
||||
VerticalAlignment = VAlignment.Center,
|
||||
Scale = new Vector2(0.5f, 0.5f)
|
||||
};
|
||||
|
||||
row.AddChild(name);
|
||||
row.AddChild(address);
|
||||
|
||||
if (ui != null)
|
||||
{
|
||||
row.AddChild(removeButton);
|
||||
removeButton.OnPressed += _ => ui.OnRemoveButtonPressed(savedDevice.address);
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user