Update TextNotificationsManager to use Ui.Send

This commit is contained in:
tomas
2022-07-12 17:46:20 +02:00
committed by Gustas
parent b0329aad35
commit 5f4ed5f16b
6 changed files with 25 additions and 55 deletions

View File

@@ -21,9 +21,8 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
{
[ChromeLogicArgsHotkeys("OpenTeamChat", "OpenGeneralChat")]
public class IngameChatLogic : ChromeLogic
public class IngameChatLogic : ChromeLogic, INotificationHandler<TextNotification>
{
readonly OrderManager orderManager;
readonly Ruleset modRules;
readonly World world;
@@ -47,7 +46,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[ObjectCreator.UseCtor]
public IngameChatLogic(Widget widget, OrderManager orderManager, World world, ModData modData, bool isMenuChat, Dictionary<string, MiniYaml> logicArgs)
{
this.orderManager = orderManager;
modRules = modData.DefaultRules;
this.isMenuChat = isMenuChat;
this.world = world;
@@ -209,12 +207,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatScrollPanel.RemoveChildren();
chatScrollPanel.ScrollToBottom();
foreach (var notification in orderManager.NotificationsCache)
foreach (var notification in TextNotificationsManager.Notifications)
if (IsNotificationEligible(notification))
AddNotification(notification, true);
orderManager.AddTextNotification += AddNotificationWrapper;
chatText.IsDisabled = () => !chatEnabled || (world.IsReplay && !Game.Settings.Debug.EnableDebugCommandsInReplays);
if (!isMenuChat)
@@ -260,7 +256,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Ui.ResetTooltips();
}
public void AddNotificationWrapper(TextNotification notification)
void INotificationHandler<TextNotification>.Handle(TextNotification notification)
{
if (!IsNotificationEligible(notification))
return;
@@ -315,18 +311,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
notification.Pool == TextNotificationPool.Mission;
}
bool disposed = false;
protected override void Dispose(bool disposing)
{
if (!disposed)
{
orderManager.AddTextNotification -= AddNotificationWrapper;
disposed = true;
}
base.Dispose(disposing);
}
bool IsNotificationMuted(TextNotification notification)
{
return Game.Settings.Game.HideReplayChat && world.IsReplay && notification.ClientId != TextNotificationsManager.SystemClientId;