machine linking refactor to ecs (#4323)

* started work

* some more work, ui working (somewhat)

* stuff

* reorganization

* some more reorg

* conveyors

* conveyors working

* finalized (dis)connection
added linkattempt
added feedback text
work on conveyors

* removed command
add rangecheck

* fixed inrange check

* handling

* ui no longer kanser, ship it

* adresses reviews

* reformats file

* reformats file

Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
This commit is contained in:
Paul Ritter
2021-08-27 17:46:02 +02:00
committed by GitHub
parent 4a68032ea1
commit e11a9b282a
47 changed files with 1059 additions and 633 deletions

View File

@@ -0,0 +1,50 @@
using Content.Shared.MachineLinking;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.MachineLinking.UI
{
public class SignalPortSelectorBoundUserInterface : BoundUserInterface
{
private SignalPortSelectorMenu? _menu;
public SignalPortSelectorBoundUserInterface([NotNull] ClientUserInterfaceComponent owner, [NotNull] object uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_menu = new SignalPortSelectorMenu(this);
_menu.OnClose += Close;
_menu.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
switch (state)
{
case SignalPortsState data:
_menu?.UpdateState(data);
break;
}
}
public void OnPortSelected(string port)
{
SendMessage(new SignalPortSelected(port));
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_menu?.Dispose();
}
}
}

View File

@@ -0,0 +1,4 @@
<customControls:SS14Window xmlns:customControls="https://spacestation14.io"
Title="Port Selector" MinSize="200 200">
<customControls:ItemList Name="ButtonContainer" VerticalExpand="True" HorizontalExpand="True" SelectMode="Button"/>
</customControls:SS14Window>

View File

@@ -0,0 +1,36 @@
using System.Collections.Generic;
using Content.Shared.MachineLinking;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.MachineLinking.UI
{
[GenerateTypedNameReferences]
public partial class SignalPortSelectorMenu : SS14Window
{
private SignalPortSelectorBoundUserInterface _bui;
public SignalPortSelectorMenu(SignalPortSelectorBoundUserInterface boundUserInterface)
{
RobustXamlLoader.Load(this);
_bui = boundUserInterface;
}
public void UpdateState(SignalPortsState state)
{
ButtonContainer.Clear();
foreach (var port in state.Ports)
{
var portBtn = new ItemList.Item(ButtonContainer)
{
Text = port.Key,
Disabled = !port.Value
};
portBtn.OnSelected += _ => _bui.OnPortSelected(port.Key);
ButtonContainer.Add(portBtn);
}
}
}
}