-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Device network DeviceLists and the NetworkConfigurator (Makes air alarms usable) #7697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wrexbe
merged 22 commits into
space-wizards:master
from
juliangiebel:2022.04.18-device-net-designation
Jun 10, 2022
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ad78dea
Implement DeviceList
juliangiebel c7259e7
Remove ApcNetworkComponent from vents, scrubbers anf firelocks
juliangiebel 2d16e26
Change BeforeBroadcastAttemptEvent#Recepients to readonly IReadonlySe…
juliangiebel 420236d
Address revievs in NetworkConfigurationSystem
juliangiebel d9a99e1
Fix red and green button styles
juliangiebel 53bb5ac
Change NetworkConfiguratorSystem#UpdateState to remove saved entites …
juliangiebel 0908969
Add AtmosDevices device net id
juliangiebel dfba8b5
Add const strings for style classes
juliangiebel cd3c3f5
Hello? Github?
juliangiebel 762f485
Add access check before opening the configuration ui
juliangiebel 7bc08ff
Merge branch 'master' into 2022.04.18-device-net-designation
juliangiebel 176c98f
Address reviews
juliangiebel 9e018ee
Merge branch 'master' into 2022.04.18-device-net-designation
juliangiebel 735c0b8
Fix call to access reader
juliangiebel e8734b7
You shall not live again IgnoreComponent
wrexbe af8f5bb
Merge github.com:space-wizards/space-station-14 into 2022.04.18-devic…
juliangiebel 404a4e1
Merge branch '2022.04.18-device-net-designation' of github.com:julian…
juliangiebel 5f113cc
Fix interaction verb check
juliangiebel ef6317d
Fix configuration window not closing when target gets deleted / out o…
juliangiebel ac3023d
Change device is already saved message to say 'network device: ... is…
juliangiebel 47e4a06
Apply suggestions from code review
juliangiebel 6a6a9ef
Fix applied suggestion
juliangiebel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
Content.Client/NetworkConfigurator/NetworkConfiguratorBoundUserInterface.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| using Content.Shared.DeviceNetwork; | ||
| using JetBrains.Annotations; | ||
| using Robust.Client.GameObjects; | ||
|
|
||
| namespace Content.Client.NetworkConfigurator; | ||
|
|
||
| public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface | ||
| { | ||
| private NetworkConfiguratorListMenu? _listMenu; | ||
| private NetworkConfiguratorConfigurationMenu? _configurationMenu; | ||
|
|
||
| public NetworkConfiguratorBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) | ||
| { | ||
| } | ||
|
|
||
| public void OnRemoveButtonPressed(string address) | ||
| { | ||
| SendMessage(new NetworkConfiguratorRemoveDeviceMessage(address)); | ||
| } | ||
|
|
||
| protected override void Open() | ||
| { | ||
| base.Open(); | ||
|
|
||
| switch (UiKey) | ||
| { | ||
| case NetworkConfiguratorUiKey.List: | ||
| _listMenu = new NetworkConfiguratorListMenu(this); | ||
| _listMenu.OnClose += Close; | ||
| _listMenu.ClearButton.OnPressed += _ => OnClearButtonPressed(); | ||
| _listMenu.OpenCentered(); | ||
| break; | ||
| case NetworkConfiguratorUiKey.Configure: | ||
| _configurationMenu = new NetworkConfiguratorConfigurationMenu(); | ||
| _configurationMenu.OnClose += Close; | ||
| _configurationMenu.Set.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Set); | ||
| _configurationMenu.Add.OnPressed += _ => OnConfigButtonPressed(NetworkConfiguratorButtonKey.Add); | ||
| //_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.OpenCentered(); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| protected override void UpdateState(BoundUserInterfaceState state) | ||
| { | ||
| base.UpdateState(state); | ||
|
|
||
| var castState = (NetworkConfiguratorUserInterfaceState) state; | ||
| _listMenu?.UpdateState(castState); | ||
| } | ||
|
|
||
| protected override void Dispose(bool disposing) | ||
| { | ||
| base.Dispose(disposing); | ||
| if (!disposing) return; | ||
|
|
||
| _listMenu?.Dispose(); | ||
| _configurationMenu?.Dispose(); | ||
| } | ||
|
|
||
| private void OnClearButtonPressed() | ||
| { | ||
| SendMessage(new NetworkConfiguratorClearDevicesMessage()); | ||
| } | ||
|
|
||
| private void OnConfigButtonPressed(NetworkConfiguratorButtonKey buttonKey) | ||
| { | ||
| SendMessage(new NetworkConfiguratorButtonPressedMessage(buttonKey)); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <ui:FancyWindow xmlns="https://spacestation14.io" | ||
| xmlns:ui="clr-namespace:Content.Client.UserInterface" | ||
| Title="Network Configurator" MinSize="350 100"> | ||
| <BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True"> | ||
| <BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="8 8 8 1"> | ||
| <Button Name="Set" Text="Set" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-set'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/> | ||
| <Button Name="Add" Text="Add" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-add'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/> | ||
| <!-- Edit might not be needed --> | ||
| <!--<Button Name="Edit" Text="Edit" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-edit'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/>--> | ||
| <Button Name="Clear" Text="Clear" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-clear'}" HorizontalExpand="True"/> | ||
| </BoxContainer> | ||
| <BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="8 0 8 8"> | ||
| <Button Name="Copy" Text="Copy" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-copy'}" HorizontalExpand="True" StyleClasses="OpenRight"/> | ||
| <Button Name="Show" Text="Show" Access="Public" Disabled="True" ToolTip="{Loc 'network-configurator-tooltip-show'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/> | ||
| </BoxContainer> | ||
| </BoxContainer> | ||
| </ui:FancyWindow> |
22 changes: 22 additions & 0 deletions
22
Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| using Content.Client.Stylesheets; | ||
| using Content.Client.UserInterface; | ||
| using Robust.Client.AutoGenerated; | ||
| using Robust.Client.UserInterface.Controls; | ||
| using Robust.Client.UserInterface.CustomControls; | ||
| using Robust.Client.UserInterface.XAML; | ||
| using Robust.Client.Graphics; | ||
|
|
||
| namespace Content.Client.NetworkConfigurator; | ||
|
|
||
| [GenerateTypedNameReferences] | ||
| public sealed partial class NetworkConfiguratorConfigurationMenu : FancyWindow | ||
| { | ||
|
|
||
| public NetworkConfiguratorConfigurationMenu() | ||
| { | ||
| RobustXamlLoader.Load(this); | ||
|
|
||
| Clear.StyleClasses.Add(StyleBase.ButtonOpenLeft); | ||
| Clear.StyleClasses.Add(StyleNano.StyleClassButtonColorRed); | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
Content.Client/NetworkConfigurator/NetworkConfiguratorListMenu.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <ui:FancyWindow xmlns="https://spacestation14.io" | ||
| xmlns:ui="clr-namespace:Content.Client.UserInterface" | ||
| Title="Network Configurator" MinSize="220 400"> | ||
| <BoxContainer Orientation="Vertical" VerticalExpand="True"> | ||
| <ScrollContainer HorizontalExpand="True" VerticalExpand="True"> | ||
| <Control VerticalExpand="True"> | ||
| <PanelContainer StyleClasses="PanelBackgroundBaseDark"></PanelContainer> | ||
| <BoxContainer Orientation="Vertical" Name="DeviceList" VerticalExpand="True" SeparationOverride="4"> | ||
| </BoxContainer> | ||
| </Control> | ||
| </ScrollContainer> | ||
| <BoxContainer Orientation="Horizontal" Margin="8 8 8 8"> | ||
| <Label Name="DeviceCountLabel" Margin="16 0 0 0" MaxWidth="64"></Label> | ||
| <Control HorizontalExpand="True" /> | ||
| <Button Name="ClearButton" Access="Public" Text="{Loc 'network-configurator-ui-clear-button'}"></Button> | ||
| </BoxContainer> | ||
| </BoxContainer> | ||
| </ui:FancyWindow> |
67 changes: 67 additions & 0 deletions
67
Content.Client/NetworkConfigurator/NetworkConfiguratorListMenu.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| using Content.Client.UserInterface; | ||
| using Content.Shared.DeviceNetwork; | ||
| using Robust.Client.AutoGenerated; | ||
| using Robust.Client.UserInterface.Controls; | ||
| using Robust.Client.UserInterface.XAML; | ||
|
|
||
| namespace Content.Client.NetworkConfigurator; | ||
|
|
||
| [GenerateTypedNameReferences] | ||
| public sealed partial class NetworkConfiguratorListMenu : FancyWindow | ||
| { | ||
| private readonly NetworkConfiguratorBoundUserInterface _ui; | ||
| public NetworkConfiguratorListMenu(NetworkConfiguratorBoundUserInterface ui) | ||
| { | ||
| RobustXamlLoader.Load(this); | ||
|
|
||
| _ui = ui; | ||
| } | ||
|
|
||
| public void UpdateState(NetworkConfiguratorUserInterfaceState state) | ||
| { | ||
| DeviceCountLabel.Text = Loc.GetString("network-configurator-ui-count-label", ("count", state.DeviceList.Count)); | ||
| DeviceList.RemoveAllChildren(); | ||
|
|
||
| foreach (var savedDevice in state.DeviceList) | ||
| { | ||
| DeviceList.AddChild(BuildDeviceListRow(savedDevice)); | ||
| } | ||
| } | ||
|
|
||
| private BoxContainer BuildDeviceListRow((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) | ||
| }; | ||
|
|
||
| removeButton.OnPressed += _ => _ui.OnRemoveButtonPressed(savedDevice.address); | ||
|
|
||
| row.AddChild(name); | ||
| row.AddChild(address); | ||
| row.AddChild(removeButton); | ||
|
|
||
| return row; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Content.Server/DeviceNetwork/Components/DeviceListComponent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| using Content.Server.DeviceNetwork.Systems; | ||
|
|
||
| namespace Content.Server.DeviceNetwork.Components; | ||
|
|
||
| [RegisterComponent] | ||
| [Friend(typeof(DeviceListSystem))] | ||
| public sealed class DeviceListComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// The list of devices can or can't connect to, depending on the <see cref="IsAllowList"/> field. | ||
| /// </summary> | ||
| [DataField("devices")] | ||
| public HashSet<EntityUid> Devices = new(); | ||
|
|
||
| /// <summary> | ||
| /// Whether the device list is used as an allow or deny list | ||
| /// </summary> | ||
| [ViewVariables(VVAccess.ReadWrite)] | ||
| [DataField("isAllowList")] | ||
| public bool IsAllowList = true; | ||
|
|
||
| /// <summary> | ||
| /// Whether this device list also handles incoming device net packets | ||
| /// </summary> | ||
| [ViewVariables(VVAccess.ReadWrite)] | ||
| [DataField("handleIncoming")] | ||
| public bool HandleIncomingPackets = false; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Content.Server/DeviceNetwork/Components/NetworkConfiguratorComponent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| using Content.Server.DeviceNetwork.Systems; | ||
| using Content.Shared.Sound; | ||
|
|
||
| namespace Content.Server.DeviceNetwork.Components; | ||
|
|
||
| [RegisterComponent] | ||
| [Friend(typeof(NetworkConfiguratorSystem))] | ||
| public sealed class NetworkConfiguratorComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// The list of devices stored in the configurator- | ||
| /// </summary> | ||
| [DataField("devices")] | ||
| public Dictionary<string, EntityUid> Devices = new(); | ||
|
|
||
| /// <summary> | ||
| /// The entity containing a <see cref="DeviceListComponent"/> this configurator is currently interacting with | ||
| /// </summary> | ||
| [DataField("activeDeviceList")] | ||
| public EntityUid? ActiveDeviceList = null; | ||
juliangiebel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [DataField("soundNoAccess")] | ||
| public SoundSpecifier SoundNoAccess = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg"); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.