Machine Port Prototypes (#7659)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -197,7 +197,6 @@ namespace Content.Client.Entry
|
||||
"SignalReceiver",
|
||||
"SignalSwitch",
|
||||
"SignalTransmitter",
|
||||
"SignalButton",
|
||||
"SignalLinker",
|
||||
"ItemCabinet",
|
||||
"FireExtinguisher",
|
||||
|
||||
@@ -5,6 +5,7 @@ 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
|
||||
{
|
||||
@@ -12,18 +13,20 @@ namespace Content.Client.MachineLinking.UI
|
||||
public sealed partial class SignalPortSelectorMenu : DefaultWindow
|
||||
{
|
||||
private SignalPortSelectorBoundUserInterface _bui;
|
||||
private LinksRender links;
|
||||
private LinksRender _links;
|
||||
|
||||
private ButtonGroup buttonGroup = new();
|
||||
private ButtonGroup _buttonGroup = new();
|
||||
private IPrototypeManager _protoMan;
|
||||
|
||||
public SignalPortSelectorMenu(SignalPortSelectorBoundUserInterface boundUserInterface)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_bui = boundUserInterface;
|
||||
links = new(ButtonContainerLeft, ButtonContainerRight);
|
||||
ContainerMiddle.AddChild(links);
|
||||
_links = new(ButtonContainerLeft, ButtonContainerRight);
|
||||
ContainerMiddle.AddChild(_links);
|
||||
ButtonClear.OnPressed += _ => _bui.OnClearPressed();
|
||||
ButtonLinkDefault.OnPressed += _ => _bui.OnLinkDefaultPressed();
|
||||
_protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
}
|
||||
|
||||
public void UpdateState(SignalPortsState state)
|
||||
@@ -32,7 +35,14 @@ namespace Content.Client.MachineLinking.UI
|
||||
ButtonContainerLeft.DisposeAllChildren();
|
||||
foreach (var port in state.TransmitterPorts)
|
||||
{
|
||||
var portButton = new Button() { Text = port, ToggleMode = true, Group = buttonGroup };
|
||||
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);
|
||||
}
|
||||
@@ -41,12 +51,19 @@ namespace Content.Client.MachineLinking.UI
|
||||
ButtonContainerRight.DisposeAllChildren();
|
||||
foreach (var port in state.ReceiverPorts)
|
||||
{
|
||||
var portButton = new Button() { Text = port, ToggleMode = true, Group = buttonGroup };
|
||||
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;
|
||||
_links.Links = state.Links;
|
||||
}
|
||||
|
||||
private sealed class LinksRender : Control
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Content.Client.Popups
|
||||
_userInterfaceManager.PopupRoot.AddChild(label);
|
||||
label.Measure(Vector2.Infinity);
|
||||
|
||||
var mapCoordinates = _eyeManager.ScreenToMap(coordinates.Position / label.UIScale - label.DesiredSize / 2);
|
||||
var mapCoordinates = _eyeManager.ScreenToMap(coordinates.Position);
|
||||
label.InitialPos = mapCoordinates;
|
||||
LayoutContainer.SetPosition(label, label.InitialPos.Position);
|
||||
_aliveLabels.Add(label);
|
||||
@@ -204,7 +204,7 @@ namespace Content.Client.Popups
|
||||
|
||||
Vector2 position;
|
||||
if (Entity == null)
|
||||
position = InitialPos.Position;
|
||||
position = _eyeManager.WorldToScreen(InitialPos.Position) / UIScale - DesiredSize / 2;
|
||||
else if (_entityManager.TryGetComponent(Entity.Value, out TransformComponent xform))
|
||||
position = (_eyeManager.CoordinatesToScreen(xform.Coordinates).Position / UIScale) - DesiredSize / 2;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user