From 0689e864e7e9516252cd27a32b79807b137a8ffa Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 11 Sep 2023 15:13:18 +1000 Subject: [PATCH] Fix admin fax (#20006) --- Content.Client/Fax/AdminUI/AdminFaxEui.cs | 6 ++--- .../Fax/AdminUI/AdminFaxWindow.xaml.cs | 24 +++++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Content.Client/Fax/AdminUI/AdminFaxEui.cs b/Content.Client/Fax/AdminUI/AdminFaxEui.cs index 239f0ecc93..ace3f3eb7b 100644 --- a/Content.Client/Fax/AdminUI/AdminFaxEui.cs +++ b/Content.Client/Fax/AdminUI/AdminFaxEui.cs @@ -8,16 +8,14 @@ namespace Content.Client.Fax.AdminUI; [UsedImplicitly] public sealed class AdminFaxEui : BaseEui { - private IEntityManager _entManager; private readonly AdminFaxWindow _window; public AdminFaxEui() { - _entManager = IoCManager.Resolve(); _window = new AdminFaxWindow(); _window.OnClose += () => SendMessage(new AdminFaxEuiMsg.Close()); - _window.OnFollowFax += uid => SendMessage(new AdminFaxEuiMsg.Follow(_entManager.GetNetEntity(uid))); - _window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(_entManager.GetNetEntity(args.uid), args.title, + _window.OnFollowFax += entity => SendMessage(new AdminFaxEuiMsg.Follow(entity)); + _window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(args.entity, args.title, args.stampedBy, args.message, args.stampSprite, args.stampColor)); } diff --git a/Content.Client/Fax/AdminUI/AdminFaxWindow.xaml.cs b/Content.Client/Fax/AdminUI/AdminFaxWindow.xaml.cs index 642d89b517..c1fba48309 100644 --- a/Content.Client/Fax/AdminUI/AdminFaxWindow.xaml.cs +++ b/Content.Client/Fax/AdminUI/AdminFaxWindow.xaml.cs @@ -4,6 +4,7 @@ using Robust.Client.ResourceManagement; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; +using Robust.Shared.ContentPack; using Robust.Shared.Utility; namespace Content.Client.Fax.AdminUI; @@ -13,8 +14,10 @@ public sealed partial class AdminFaxWindow : DefaultWindow { private const string StampsRsiPath = "/Textures/Objects/Misc/bureaucracy.rsi"; - public Action<(EntityUid uid, string title, string stampedBy, string message, string stampSprite, Color stampColor)>? OnMessageSend; - public Action? OnFollowFax; + public Action<(NetEntity entity, string title, string stampedBy, string message, string stampSprite, Color stampColor)>? OnMessageSend; + public Action? OnFollowFax; + + [Dependency] private readonly IResourceCache _resCache = default!; public AdminFaxWindow() { @@ -29,7 +32,8 @@ public sealed partial class AdminFaxWindow : DefaultWindow SendButton.OnPressed += SendMessage; // Don't use this, but ColorSelectorSliders requires it: - StampColorSelector.OnColorChanged += (Color) => {}; + // what the fok + StampColorSelector.OnColorChanged += (color) => {}; var loc = IoCManager.Resolve(); MessageEdit.Placeholder = new Rope.Leaf(loc.GetString("admin-fax-message-placeholder")); // TextEdit work only with Nodes @@ -47,7 +51,7 @@ public sealed partial class AdminFaxWindow : DefaultWindow private void PopulateStamps() { - var rsi = IoCManager.Resolve().GetResource(StampsRsiPath).RSI; + var rsi = _resCache.GetResource(StampsRsiPath).RSI; using (var enumerator = rsi.GetEnumerator()) { var i = 0; @@ -67,17 +71,17 @@ public sealed partial class AdminFaxWindow : DefaultWindow private void FollowFax(BaseButton.ButtonEventArgs obj) { - var faxUid = (EntityUid?) FaxSelector.SelectedMetadata; - if (faxUid == null) + var faxEntity = (NetEntity?) FaxSelector.SelectedMetadata; + if (faxEntity == null) return; - OnFollowFax?.Invoke(faxUid.Value); + OnFollowFax?.Invoke(faxEntity.Value); } private void SendMessage(BaseButton.ButtonEventArgs obj) { - var faxUid = (EntityUid?) FaxSelector.SelectedMetadata; - if (faxUid == null) + var faxEntity = (NetEntity?) FaxSelector.SelectedMetadata; + if (faxEntity == null) return; var stamp = (string?) StampSelector.SelectedMetadata; @@ -94,6 +98,6 @@ public sealed partial class AdminFaxWindow : DefaultWindow var from = FromEdit.Text; var stampColor = StampColorSelector.Color; - OnMessageSend?.Invoke((faxUid.Value, title, from, message, stamp, stampColor)); + OnMessageSend?.Invoke((faxEntity.Value, title, from, message, stamp, stampColor)); } }