Fix admin fax (#20006)
This commit is contained in:
@@ -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<IEntityManager>();
|
||||
_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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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<EntityUid>? OnFollowFax;
|
||||
public Action<(NetEntity entity, string title, string stampedBy, string message, string stampSprite, Color stampColor)>? OnMessageSend;
|
||||
public Action<NetEntity>? 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<ILocalizationManager>();
|
||||
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<IResourceCache>().GetResource<RSIResource>(StampsRsiPath).RSI;
|
||||
var rsi = _resCache.GetResource<RSIResource>(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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user