Remove superseded machine linking code (#18244)
This commit is contained in:
@@ -1,89 +0,0 @@
|
||||
using Content.Shared.MachineLinking;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.MachineLinking.UI
|
||||
{
|
||||
public sealed class SignalPortSelectorBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[ViewVariables]
|
||||
private SignalPortSelectorMenu? _menu;
|
||||
|
||||
[ViewVariables]
|
||||
private string? _selectedTransmitterPort;
|
||||
|
||||
[ViewVariables]
|
||||
private string? _selectedReceiverPort;
|
||||
|
||||
public SignalPortSelectorBoundUserInterface([NotNull] EntityUid owner, [NotNull] Enum 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);
|
||||
_selectedTransmitterPort = null;
|
||||
_selectedReceiverPort = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTransmitterPortSelected(string port)
|
||||
{
|
||||
_selectedTransmitterPort = port;
|
||||
if (_selectedReceiverPort != null)
|
||||
{
|
||||
SendMessage(new SignalPortSelected(_selectedTransmitterPort, _selectedReceiverPort));
|
||||
_selectedTransmitterPort = null;
|
||||
_selectedReceiverPort = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnReceiverPortSelected(string port)
|
||||
{
|
||||
_selectedReceiverPort = port;
|
||||
if (_selectedTransmitterPort != null)
|
||||
{
|
||||
SendMessage(new SignalPortSelected(_selectedTransmitterPort, _selectedReceiverPort));
|
||||
_selectedTransmitterPort = null;
|
||||
_selectedReceiverPort = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClearPressed()
|
||||
{
|
||||
_selectedTransmitterPort = null;
|
||||
_selectedReceiverPort = null;
|
||||
SendMessage(new LinkerClearSelected());
|
||||
}
|
||||
|
||||
public void OnLinkDefaultPressed()
|
||||
{
|
||||
_selectedTransmitterPort = null;
|
||||
_selectedReceiverPort = null;
|
||||
SendMessage(new LinkerLinkDefaultSelected());
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_menu?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<DefaultWindow xmlns="https://spacestation14.io" Title="{Loc signal-port-selector-menu-title}" MinSize="400 200">
|
||||
<BoxContainer Orientation="Vertical" VerticalExpand="True">
|
||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="True">
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="0.3">
|
||||
<RichTextLabel Name="HeaderLeft"/>
|
||||
<BoxContainer Name="ButtonContainerLeft" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True"/>
|
||||
</BoxContainer>
|
||||
<BoxContainer Name="ContainerMiddle" Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="0.2"/>
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="0.3">
|
||||
<RichTextLabel Name="HeaderRight"/>
|
||||
<BoxContainer Name="ButtonContainerRight" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True"/>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
||||
<Button Name="ButtonClear" Text="{Loc signal-port-selector-menu-clear}"/>
|
||||
<Button Name="ButtonLinkDefault" Text="{Loc signal-port-selector-menu-link-defaults}"/>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
@@ -1,97 +0,0 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.MachineLinking;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.MachineLinking.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class SignalPortSelectorMenu : DefaultWindow
|
||||
{
|
||||
private SignalPortSelectorBoundUserInterface _bui;
|
||||
private LinksRender _links;
|
||||
|
||||
private ButtonGroup _buttonGroup = new();
|
||||
private IPrototypeManager _protoMan;
|
||||
|
||||
public SignalPortSelectorMenu(SignalPortSelectorBoundUserInterface boundUserInterface)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_bui = boundUserInterface;
|
||||
_links = new(ButtonContainerLeft, ButtonContainerRight);
|
||||
ContainerMiddle.AddChild(_links);
|
||||
ButtonClear.OnPressed += _ => _bui.OnClearPressed();
|
||||
ButtonLinkDefault.OnPressed += _ => _bui.OnLinkDefaultPressed();
|
||||
_protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
}
|
||||
|
||||
public void UpdateState(SignalPortsState state)
|
||||
{
|
||||
HeaderLeft.SetMessage(state.TransmitterName);
|
||||
ButtonContainerLeft.DisposeAllChildren();
|
||||
foreach (var port in state.TransmitterPorts)
|
||||
{
|
||||
var proto = _protoMan.Index<TransmitterPortPrototype>(port);
|
||||
var portButton = new Button()
|
||||
{
|
||||
Text = Loc.GetString(proto.Name),
|
||||
ToolTip = Loc.GetString(proto.Description),
|
||||
ToggleMode = true,
|
||||
Group = _buttonGroup
|
||||
};
|
||||
portButton.OnPressed += _ => _bui.OnTransmitterPortSelected(port);
|
||||
ButtonContainerLeft.AddChild(portButton);
|
||||
}
|
||||
|
||||
HeaderRight.SetMessage(state.ReceiverName);
|
||||
ButtonContainerRight.DisposeAllChildren();
|
||||
foreach (var port in state.ReceiverPorts)
|
||||
{
|
||||
var proto = _protoMan.Index<ReceiverPortPrototype>(port);
|
||||
var portButton = new Button()
|
||||
{
|
||||
Text = Loc.GetString(proto.Name),
|
||||
ToolTip = Loc.GetString(proto.Description),
|
||||
ToggleMode = true,
|
||||
Group = _buttonGroup
|
||||
};
|
||||
portButton.OnPressed += _ => _bui.OnReceiverPortSelected(port);
|
||||
ButtonContainerRight.AddChild(portButton);
|
||||
}
|
||||
|
||||
_links.Links = state.Links;
|
||||
}
|
||||
|
||||
private sealed class LinksRender : Control
|
||||
{
|
||||
public List<(int, int)> Links = new();
|
||||
public BoxContainer LeftButton;
|
||||
public BoxContainer RightButton;
|
||||
|
||||
public LinksRender(BoxContainer leftButton, BoxContainer rightButton)
|
||||
{
|
||||
LeftButton = leftButton;
|
||||
RightButton = rightButton;
|
||||
}
|
||||
|
||||
protected override void Draw(DrawingHandleScreen handle)
|
||||
{
|
||||
var leftOffset = LeftButton.PixelPosition.Y;
|
||||
var rightOffset = RightButton.PixelPosition.Y;
|
||||
foreach (var (left, right) in Links)
|
||||
{
|
||||
var leftChild = LeftButton.GetChild(left);
|
||||
var rightChild = RightButton.GetChild(right);
|
||||
var y1 = leftChild.PixelPosition.Y + leftChild.PixelHeight / 2 + leftOffset;
|
||||
var y2 = rightChild.PixelPosition.Y + rightChild.PixelHeight / 2 + rightOffset;
|
||||
handle.DrawLine(new Vector2(0, y1), new Vector2(PixelWidth, y2), Color.Cyan);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user