Add INotification.RespectUiHidden

This commit is contained in:
Soreepeong 2024-03-14 13:05:46 +09:00
parent ecfbcfe194
commit 9724e511e9
7 changed files with 29 additions and 2 deletions

View file

@ -60,6 +60,9 @@ public interface INotification
/// <see cref="HardExpiry"/> is set to <see cref="DateTime.MaxValue"/>.</summary> /// <see cref="HardExpiry"/> is set to <see cref="DateTime.MaxValue"/>.</summary>
bool ShowIndeterminateIfNoExpiry { get; set; } bool ShowIndeterminateIfNoExpiry { get; set; }
/// <summary>Gets or sets a value indicating whether to respect the current UI visibility state.</summary>
bool RespectUiHidden { get; set; }
/// <summary>Gets or sets a value indicating whether the notification has been minimized.</summary> /// <summary>Gets or sets a value indicating whether the notification has been minimized.</summary>
bool Minimized { get; set; } bool Minimized { get; set; }

View file

@ -90,6 +90,13 @@ internal sealed partial class ActiveNotification : IActiveNotification
set => this.underlyingNotification.Title = value; set => this.underlyingNotification.Title = value;
} }
/// <inheritdoc/>
public bool RespectUiHidden
{
get => this.underlyingNotification.RespectUiHidden;
set => this.underlyingNotification.RespectUiHidden = value;
}
/// <inheritdoc/> /// <inheritdoc/>
public string? MinimizedText public string? MinimizedText
{ {

View file

@ -1,6 +1,7 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using Dalamud.Game.Gui;
using Dalamud.Interface.GameFonts; using Dalamud.Interface.GameFonts;
using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.ManagedFontAtlas; using Dalamud.Interface.ManagedFontAtlas;
@ -20,6 +21,9 @@ namespace Dalamud.Interface.ImGuiNotification.Internal;
[ServiceManager.EarlyLoadedService] [ServiceManager.EarlyLoadedService]
internal class NotificationManager : INotificationManager, IServiceType, IDisposable internal class NotificationManager : INotificationManager, IServiceType, IDisposable
{ {
[ServiceManager.ServiceDependency]
private readonly GameGui gameGui = Service<GameGui>.Get();
private readonly List<ActiveNotification> notifications = new(); private readonly List<ActiveNotification> notifications = new();
private readonly ConcurrentBag<ActiveNotification> pendingNotifications = new(); private readonly ConcurrentBag<ActiveNotification> pendingNotifications = new();
@ -98,6 +102,7 @@ internal class NotificationManager : INotificationManager, IServiceType, IDispos
{ {
var viewportSize = ImGuiHelpers.MainViewport.WorkSize; var viewportSize = ImGuiHelpers.MainViewport.WorkSize;
var height = 0f; var height = 0f;
var uiHidden = this.gameGui.GameUiHidden;
while (this.pendingNotifications.TryTake(out var newNotification)) while (this.pendingNotifications.TryTake(out var newNotification))
this.notifications.Add(newNotification); this.notifications.Add(newNotification);
@ -109,7 +114,11 @@ internal class NotificationManager : INotificationManager, IServiceType, IDispos
this.notifications.RemoveAll(static x => x.UpdateOrDisposeInternal()); this.notifications.RemoveAll(static x => x.UpdateOrDisposeInternal());
foreach (var tn in this.notifications) foreach (var tn in this.notifications)
{
if (uiHidden && tn.RespectUiHidden)
continue;
height += tn.Draw(width, height) + NotificationConstants.ScaledWindowGap; height += tn.Draw(width, height) + NotificationConstants.ScaledWindowGap;
}
} }
} }

View file

@ -38,6 +38,9 @@ public sealed record Notification : INotification
/// <inheritdoc/> /// <inheritdoc/>
public bool ShowIndeterminateIfNoExpiry { get; set; } = true; public bool ShowIndeterminateIfNoExpiry { get; set; } = true;
/// <inheritdoc/>
public bool RespectUiHidden { get; set; } = true;
/// <inheritdoc/> /// <inheritdoc/>
public bool Minimized { get; set; } = true; public bool Minimized { get; set; } = true;

View file

@ -923,7 +923,7 @@ internal class InterfaceManager : IDisposable, IServiceType
if (this.IsDispatchingEvents) if (this.IsDispatchingEvents)
{ {
this.Draw?.Invoke(); this.Draw?.Invoke();
Service<NotificationManager>.Get().Draw(); Service<NotificationManager>.GetNullable()?.Draw();
} }
ImGuiManagedAsserts.ReportProblems("Dalamud Core", snap); ImGuiManagedAsserts.ReportProblems("Dalamud Core", snap);

View file

@ -127,6 +127,8 @@ internal class ImGuiWidget : IDataWindowWidget
NotificationTemplate.ProgressModeTitles, NotificationTemplate.ProgressModeTitles,
NotificationTemplate.ProgressModeTitles.Length); NotificationTemplate.ProgressModeTitles.Length);
ImGui.Checkbox("Respect UI Hidden", ref this.notificationTemplate.RespectUiHidden);
ImGui.Checkbox("Minimized", ref this.notificationTemplate.Minimized); ImGui.Checkbox("Minimized", ref this.notificationTemplate.Minimized);
ImGui.Checkbox("Show Indeterminate If No Expiry", ref this.notificationTemplate.ShowIndeterminateIfNoExpiry); ImGui.Checkbox("Show Indeterminate If No Expiry", ref this.notificationTemplate.ShowIndeterminateIfNoExpiry);
@ -160,6 +162,7 @@ internal class ImGuiWidget : IDataWindowWidget
: null, : null,
Type = type, Type = type,
ShowIndeterminateIfNoExpiry = this.notificationTemplate.ShowIndeterminateIfNoExpiry, ShowIndeterminateIfNoExpiry = this.notificationTemplate.ShowIndeterminateIfNoExpiry,
RespectUiHidden = this.notificationTemplate.RespectUiHidden,
Minimized = this.notificationTemplate.Minimized, Minimized = this.notificationTemplate.Minimized,
UserDismissable = this.notificationTemplate.UserDismissable, UserDismissable = this.notificationTemplate.UserDismissable,
InitialDuration = InitialDuration =
@ -388,6 +391,7 @@ internal class ImGuiWidget : IDataWindowWidget
public int InitialDurationInt; public int InitialDurationInt;
public int HoverExtendDurationInt; public int HoverExtendDurationInt;
public bool ShowIndeterminateIfNoExpiry; public bool ShowIndeterminateIfNoExpiry;
public bool RespectUiHidden;
public bool Minimized; public bool Minimized;
public bool UserDismissable; public bool UserDismissable;
public bool ActionBar; public bool ActionBar;
@ -413,6 +417,7 @@ internal class ImGuiWidget : IDataWindowWidget
this.UserDismissable = true; this.UserDismissable = true;
this.ActionBar = true; this.ActionBar = true;
this.ProgressMode = 0; this.ProgressMode = 0;
this.RespectUiHidden = true;
} }
} }
} }

@ -1 +1 @@
Subproject commit 722a2c512238ac4b5324e3d343b316d8c8633a02 Subproject commit ac2ced26fc98153c65f5b8f0eaf0f464258ff683