Update TextNotificationsManager to use Ui.Send
This commit is contained in:
@@ -10,14 +10,12 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class IngameTransientNotificationsLogic : ChromeLogic
|
||||
public class IngameTransientNotificationsLogic : ChromeLogic, INotificationHandler<TextNotification>
|
||||
{
|
||||
readonly OrderManager orderManager;
|
||||
readonly Ruleset modRules;
|
||||
|
||||
readonly TextNotificationsDisplayWidget displayWidget;
|
||||
@@ -28,22 +26,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
int repetitions;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public IngameTransientNotificationsLogic(Widget widget, OrderManager orderManager, ModData modData, Dictionary<string, MiniYaml> logicArgs)
|
||||
public IngameTransientNotificationsLogic(Widget widget, ModData modData, Dictionary<string, MiniYaml> logicArgs)
|
||||
{
|
||||
this.orderManager = orderManager;
|
||||
modRules = modData.DefaultRules;
|
||||
|
||||
displayWidget = widget.Get<TextNotificationsDisplayWidget>("TRANSIENTS_DISPLAY");
|
||||
|
||||
orderManager.AddTextNotification += AddNotificationWrapper;
|
||||
|
||||
if (logicArgs.TryGetValue("TransientLineSound", out var yaml))
|
||||
transientLineSound = yaml.Value;
|
||||
else
|
||||
ChromeMetrics.TryGet("TransientLineSound", out transientLineSound);
|
||||
}
|
||||
|
||||
public void AddNotificationWrapper(TextNotification notification)
|
||||
void INotificationHandler<TextNotification>.Handle(TextNotification notification)
|
||||
{
|
||||
if (!IsNotificationEligible(notification))
|
||||
return;
|
||||
@@ -83,17 +78,5 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
return notification.Pool == TextNotificationPool.Transients || notification.Pool == TextNotificationPool.Feedback;
|
||||
}
|
||||
|
||||
bool disposed = false;
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
orderManager.AddTextNotification -= AddNotificationWrapper;
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user