From 9724e511e95e98c52f1a7981e6a1e2a1989371ba Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Thu, 14 Mar 2024 13:05:46 +0900 Subject: [PATCH] Add INotification.RespectUiHidden --- Dalamud/Interface/ImGuiNotification/INotification.cs | 3 +++ .../ImGuiNotification/Internal/ActiveNotification.cs | 7 +++++++ .../ImGuiNotification/Internal/NotificationManager.cs | 9 +++++++++ Dalamud/Interface/ImGuiNotification/Notification.cs | 3 +++ Dalamud/Interface/Internal/InterfaceManager.cs | 2 +- .../Internal/Windows/Data/Widgets/ImGuiWidget.cs | 5 +++++ lib/FFXIVClientStructs | 2 +- 7 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Dalamud/Interface/ImGuiNotification/INotification.cs b/Dalamud/Interface/ImGuiNotification/INotification.cs index 207722c56..f9a043c0b 100644 --- a/Dalamud/Interface/ImGuiNotification/INotification.cs +++ b/Dalamud/Interface/ImGuiNotification/INotification.cs @@ -60,6 +60,9 @@ public interface INotification /// is set to . bool ShowIndeterminateIfNoExpiry { get; set; } + /// Gets or sets a value indicating whether to respect the current UI visibility state. + bool RespectUiHidden { get; set; } + /// Gets or sets a value indicating whether the notification has been minimized. bool Minimized { get; set; } diff --git a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs index 019d9e281..3bc7c3837 100644 --- a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs +++ b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs @@ -90,6 +90,13 @@ internal sealed partial class ActiveNotification : IActiveNotification set => this.underlyingNotification.Title = value; } + /// + public bool RespectUiHidden + { + get => this.underlyingNotification.RespectUiHidden; + set => this.underlyingNotification.RespectUiHidden = value; + } + /// public string? MinimizedText { diff --git a/Dalamud/Interface/ImGuiNotification/Internal/NotificationManager.cs b/Dalamud/Interface/ImGuiNotification/Internal/NotificationManager.cs index 973e93c72..272407615 100644 --- a/Dalamud/Interface/ImGuiNotification/Internal/NotificationManager.cs +++ b/Dalamud/Interface/ImGuiNotification/Internal/NotificationManager.cs @@ -1,6 +1,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; +using Dalamud.Game.Gui; using Dalamud.Interface.GameFonts; using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.ManagedFontAtlas; @@ -20,6 +21,9 @@ namespace Dalamud.Interface.ImGuiNotification.Internal; [ServiceManager.EarlyLoadedService] internal class NotificationManager : INotificationManager, IServiceType, IDisposable { + [ServiceManager.ServiceDependency] + private readonly GameGui gameGui = Service.Get(); + private readonly List notifications = new(); private readonly ConcurrentBag pendingNotifications = new(); @@ -98,6 +102,7 @@ internal class NotificationManager : INotificationManager, IServiceType, IDispos { var viewportSize = ImGuiHelpers.MainViewport.WorkSize; var height = 0f; + var uiHidden = this.gameGui.GameUiHidden; while (this.pendingNotifications.TryTake(out var newNotification)) this.notifications.Add(newNotification); @@ -109,7 +114,11 @@ internal class NotificationManager : INotificationManager, IServiceType, IDispos this.notifications.RemoveAll(static x => x.UpdateOrDisposeInternal()); foreach (var tn in this.notifications) + { + if (uiHidden && tn.RespectUiHidden) + continue; height += tn.Draw(width, height) + NotificationConstants.ScaledWindowGap; + } } } diff --git a/Dalamud/Interface/ImGuiNotification/Notification.cs b/Dalamud/Interface/ImGuiNotification/Notification.cs index 612533cb8..5175985c7 100644 --- a/Dalamud/Interface/ImGuiNotification/Notification.cs +++ b/Dalamud/Interface/ImGuiNotification/Notification.cs @@ -38,6 +38,9 @@ public sealed record Notification : INotification /// public bool ShowIndeterminateIfNoExpiry { get; set; } = true; + /// + public bool RespectUiHidden { get; set; } = true; + /// public bool Minimized { get; set; } = true; diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index c811e9287..67e444cbe 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -923,7 +923,7 @@ internal class InterfaceManager : IDisposable, IServiceType if (this.IsDispatchingEvents) { this.Draw?.Invoke(); - Service.Get().Draw(); + Service.GetNullable()?.Draw(); } ImGuiManagedAsserts.ReportProblems("Dalamud Core", snap); diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/ImGuiWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/ImGuiWidget.cs index 95119bb48..086b0c1ad 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/ImGuiWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/ImGuiWidget.cs @@ -127,6 +127,8 @@ internal class ImGuiWidget : IDataWindowWidget NotificationTemplate.ProgressModeTitles, NotificationTemplate.ProgressModeTitles.Length); + ImGui.Checkbox("Respect UI Hidden", ref this.notificationTemplate.RespectUiHidden); + ImGui.Checkbox("Minimized", ref this.notificationTemplate.Minimized); ImGui.Checkbox("Show Indeterminate If No Expiry", ref this.notificationTemplate.ShowIndeterminateIfNoExpiry); @@ -160,6 +162,7 @@ internal class ImGuiWidget : IDataWindowWidget : null, Type = type, ShowIndeterminateIfNoExpiry = this.notificationTemplate.ShowIndeterminateIfNoExpiry, + RespectUiHidden = this.notificationTemplate.RespectUiHidden, Minimized = this.notificationTemplate.Minimized, UserDismissable = this.notificationTemplate.UserDismissable, InitialDuration = @@ -388,6 +391,7 @@ internal class ImGuiWidget : IDataWindowWidget public int InitialDurationInt; public int HoverExtendDurationInt; public bool ShowIndeterminateIfNoExpiry; + public bool RespectUiHidden; public bool Minimized; public bool UserDismissable; public bool ActionBar; @@ -413,6 +417,7 @@ internal class ImGuiWidget : IDataWindowWidget this.UserDismissable = true; this.ActionBar = true; this.ProgressMode = 0; + this.RespectUiHidden = true; } } } diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 722a2c512..ac2ced26f 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 722a2c512238ac4b5324e3d343b316d8c8633a02 +Subproject commit ac2ced26fc98153c65f5b8f0eaf0f464258ff683