diff --git a/Content.Client/NetworkConfigurator/NetworkConfiguratorActiveLinkOverlayComponent.cs b/Content.Client/NetworkConfigurator/NetworkConfiguratorActiveLinkOverlayComponent.cs new file mode 100644 index 0000000000..b74f8f9af5 --- /dev/null +++ b/Content.Client/NetworkConfigurator/NetworkConfiguratorActiveLinkOverlayComponent.cs @@ -0,0 +1,15 @@ +namespace Content.Client.NetworkConfigurator; + +/// +/// This is used for... +/// +[RegisterComponent] +public sealed class NetworkConfiguratorActiveLinkOverlayComponent : Component +{ + /// + /// The entities linked to this network configurator. + /// This could just... couldn't this just be grabbed + /// if DeviceList was shared? + /// + public HashSet Devices = new(); +} diff --git a/Content.Client/NetworkConfigurator/NetworkConfiguratorBoundUserInterface.cs b/Content.Client/NetworkConfigurator/NetworkConfiguratorBoundUserInterface.cs index 86490b5147..168615ca0b 100644 --- a/Content.Client/NetworkConfigurator/NetworkConfiguratorBoundUserInterface.cs +++ b/Content.Client/NetworkConfigurator/NetworkConfiguratorBoundUserInterface.cs @@ -1,16 +1,24 @@ using Content.Shared.DeviceNetwork; using JetBrains.Annotations; using Robust.Client.GameObjects; +using Robust.Client.UserInterface.Controls; namespace Content.Client.NetworkConfigurator; public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface { + [Dependency] private readonly IEntityManager _entityManager = default!; private NetworkConfiguratorListMenu? _listMenu; private NetworkConfiguratorConfigurationMenu? _configurationMenu; + private NetworkConfiguratorSystem _netConfig; + private DeviceListSystem _deviceList; + public NetworkConfiguratorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) { + IoCManager.InjectDependencies(this); + _netConfig = _entityManager.System(); + _deviceList = _entityManager.System(); } public void OnRemoveButtonPressed(string address) @@ -38,12 +46,31 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface //_configurationMenu.Edit.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Edit); _configurationMenu.Clear.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Clear); _configurationMenu.Copy.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Copy); - _configurationMenu.Show.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Show); + _configurationMenu.Show.OnPressed += OnShowPressed; + _configurationMenu.Show.Pressed = _netConfig.ConfiguredListIsTracked(Owner.Owner); _configurationMenu.OpenCentered(); break; } } + private void OnShowPressed(BaseButton.ButtonEventArgs args) + { + if (!args.Button.Pressed) + { + _netConfig.ToggleVisualization(Owner.Owner, false); + return; + } + + if (_entityManager.GetComponent(Owner.Owner).EntityLifeStage == EntityLifeStage.Initialized) + { + // We're in mapping mode. Do something hacky. + SendMessage(new ManualDeviceListSyncMessage(null, null)); + return; + } + + _netConfig.ToggleVisualization(Owner.Owner, true); + } + protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); @@ -52,6 +79,25 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface _listMenu?.UpdateState(castState); } + protected override void ReceiveMessage(BoundUserInterfaceMessage message) + { + base.ReceiveMessage(message); + + if (_configurationMenu == null + || _entityManager.GetComponent(Owner.Owner).EntityLifeStage > EntityLifeStage.Initialized + || message is not ManualDeviceListSyncMessage cast + || cast.Device == null + || cast.Devices == null) + { + return; + } + + _netConfig.SetActiveDeviceList(Owner.Owner, cast.Device.Value); + _deviceList.UpdateDeviceList(cast.Device.Value, cast.Devices); + _netConfig.ToggleVisualization(Owner.Owner, true); + _configurationMenu.Show.Pressed = true; + } + protected override void Dispose(bool disposing) { base.Dispose(disposing); diff --git a/Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml b/Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml index 0c1affe6a3..7be6c47b7a 100644 --- a/Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml +++ b/Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml @@ -11,7 +11,7 @@