Fix admin fax (#20006)
This commit is contained in:
@@ -8,16 +8,14 @@ namespace Content.Client.Fax.AdminUI;
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class AdminFaxEui : BaseEui
|
public sealed class AdminFaxEui : BaseEui
|
||||||
{
|
{
|
||||||
private IEntityManager _entManager;
|
|
||||||
private readonly AdminFaxWindow _window;
|
private readonly AdminFaxWindow _window;
|
||||||
|
|
||||||
public AdminFaxEui()
|
public AdminFaxEui()
|
||||||
{
|
{
|
||||||
_entManager = IoCManager.Resolve<IEntityManager>();
|
|
||||||
_window = new AdminFaxWindow();
|
_window = new AdminFaxWindow();
|
||||||
_window.OnClose += () => SendMessage(new AdminFaxEuiMsg.Close());
|
_window.OnClose += () => SendMessage(new AdminFaxEuiMsg.Close());
|
||||||
_window.OnFollowFax += uid => SendMessage(new AdminFaxEuiMsg.Follow(_entManager.GetNetEntity(uid)));
|
_window.OnFollowFax += entity => SendMessage(new AdminFaxEuiMsg.Follow(entity));
|
||||||
_window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(_entManager.GetNetEntity(args.uid), args.title,
|
_window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(args.entity, args.title,
|
||||||
args.stampedBy, args.message, args.stampSprite, args.stampColor));
|
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.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.ContentPack;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Client.Fax.AdminUI;
|
namespace Content.Client.Fax.AdminUI;
|
||||||
@@ -13,8 +14,10 @@ public sealed partial class AdminFaxWindow : DefaultWindow
|
|||||||
{
|
{
|
||||||
private const string StampsRsiPath = "/Textures/Objects/Misc/bureaucracy.rsi";
|
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<(NetEntity entity, string title, string stampedBy, string message, string stampSprite, Color stampColor)>? OnMessageSend;
|
||||||
public Action<EntityUid>? OnFollowFax;
|
public Action<NetEntity>? OnFollowFax;
|
||||||
|
|
||||||
|
[Dependency] private readonly IResourceCache _resCache = default!;
|
||||||
|
|
||||||
public AdminFaxWindow()
|
public AdminFaxWindow()
|
||||||
{
|
{
|
||||||
@@ -29,7 +32,8 @@ public sealed partial class AdminFaxWindow : DefaultWindow
|
|||||||
SendButton.OnPressed += SendMessage;
|
SendButton.OnPressed += SendMessage;
|
||||||
|
|
||||||
// Don't use this, but ColorSelectorSliders requires it:
|
// Don't use this, but ColorSelectorSliders requires it:
|
||||||
StampColorSelector.OnColorChanged += (Color) => {};
|
// what the fok
|
||||||
|
StampColorSelector.OnColorChanged += (color) => {};
|
||||||
|
|
||||||
var loc = IoCManager.Resolve<ILocalizationManager>();
|
var loc = IoCManager.Resolve<ILocalizationManager>();
|
||||||
MessageEdit.Placeholder = new Rope.Leaf(loc.GetString("admin-fax-message-placeholder")); // TextEdit work only with Nodes
|
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()
|
private void PopulateStamps()
|
||||||
{
|
{
|
||||||
var rsi = IoCManager.Resolve<IResourceCache>().GetResource<RSIResource>(StampsRsiPath).RSI;
|
var rsi = _resCache.GetResource<RSIResource>(StampsRsiPath).RSI;
|
||||||
using (var enumerator = rsi.GetEnumerator())
|
using (var enumerator = rsi.GetEnumerator())
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
@@ -67,17 +71,17 @@ public sealed partial class AdminFaxWindow : DefaultWindow
|
|||||||
|
|
||||||
private void FollowFax(BaseButton.ButtonEventArgs obj)
|
private void FollowFax(BaseButton.ButtonEventArgs obj)
|
||||||
{
|
{
|
||||||
var faxUid = (EntityUid?) FaxSelector.SelectedMetadata;
|
var faxEntity = (NetEntity?) FaxSelector.SelectedMetadata;
|
||||||
if (faxUid == null)
|
if (faxEntity == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OnFollowFax?.Invoke(faxUid.Value);
|
OnFollowFax?.Invoke(faxEntity.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SendMessage(BaseButton.ButtonEventArgs obj)
|
private void SendMessage(BaseButton.ButtonEventArgs obj)
|
||||||
{
|
{
|
||||||
var faxUid = (EntityUid?) FaxSelector.SelectedMetadata;
|
var faxEntity = (NetEntity?) FaxSelector.SelectedMetadata;
|
||||||
if (faxUid == null)
|
if (faxEntity == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var stamp = (string?) StampSelector.SelectedMetadata;
|
var stamp = (string?) StampSelector.SelectedMetadata;
|
||||||
@@ -94,6 +98,6 @@ public sealed partial class AdminFaxWindow : DefaultWindow
|
|||||||
|
|
||||||
var from = FromEdit.Text;
|
var from = FromEdit.Text;
|
||||||
var stampColor = StampColorSelector.Color;
|
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