Revert "Remove some BUI boilerplate" (#30214)

Revert "Remove some BUI boilerplate (#28399)"

This reverts commit cbf329a82d.
This commit is contained in:
Nemanja
2024-07-20 20:42:27 -04:00
committed by GitHub
parent 6d664c9157
commit cb0ba66be3
137 changed files with 1755 additions and 1096 deletions

View File

@@ -7,19 +7,17 @@ namespace Content.Client.NetworkConfigurator;
[GenerateTypedNameReferences]
public sealed partial class NetworkConfiguratorDeviceList : ScrollContainer
{
public event Action<string>? OnRemoveAddress;
public void UpdateState(HashSet<(string address, string name)> devices, bool ui)
public void UpdateState(NetworkConfiguratorBoundUserInterface? ui, HashSet<(string address, string name)> devices)
{
DeviceList.RemoveAllChildren();
foreach (var device in devices)
{
DeviceList.AddChild(BuildDeviceListRow(device, ui));
DeviceList.AddChild(BuildDeviceListRow(ui, device));
}
}
private BoxContainer BuildDeviceListRow((string address, string name) savedDevice, bool ui)
private static BoxContainer BuildDeviceListRow(NetworkConfiguratorBoundUserInterface? ui, (string address, string name) savedDevice)
{
var row = new BoxContainer()
{
@@ -50,10 +48,10 @@ public sealed partial class NetworkConfiguratorDeviceList : ScrollContainer
row.AddChild(name);
row.AddChild(address);
if (ui)
if (ui != null)
{
row.AddChild(removeButton);
removeButton.OnPressed += _ => OnRemoveAddress?.Invoke(savedDevice.address);
removeButton.OnPressed += _ => ui.OnRemoveButtonPressed(savedDevice.address);
}
return row;