Device link visualizer (#11054)
* shuffles devicelist to shared, adds an overlay for devicelist * adds space property to overlay * moves networkconfigurator to shared, makes devicelistsystem clientside check activedevicelist * dirties components upon change, adds networkedcomponent to sharednetworkconfigurator * state handlers for networked components * whoops * lots of shuffling, renaming, and access changes * randomizes color for every new entity added to the overlay * adds a client-side action to clear all network overlays if they're active * clones action (oops) * localization, adds a command for clearing network link overlays (in case the action disappears) * moves the entity manager up into the bui fields * makes that a dependency * attempts to just directly get the color from the dict when drawing, now * fixes up a few comments * adds dirty on init to devicelistcomponent * hacky solution related to mapping with a networkconfigurator * more stricter bound on that hacky solution * just checks if the life stage is initialized instead of if the entity was initialized * moves getalldevices to shared * readds linq import * tries to ensure that the show button is toggled on if the device we're trying to configure is currently being tracked by the overlay * some reorganization
This commit is contained in:
@@ -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<NetworkConfiguratorSystem>();
|
||||
_deviceList = _entityManager.System<DeviceListSystem>();
|
||||
}
|
||||
|
||||
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<MetaDataComponent>(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<MetaDataComponent>(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);
|
||||
|
||||
Reference in New Issue
Block a user