mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 21:24:16 +01:00
Switch INotificationManager and ITitleScreenMenu to use ISharedImmediateTexture (#1879)
* Switch INotificationManager and ITitleScreenMenu to use ISharedImmediateTexture #1879 * Remove SetIconTexture Remove some remarks that no longer apply * Cleanup StyleCop warnings
This commit is contained in:
parent
577977350f
commit
19ba6a961f
13 changed files with 176 additions and 274 deletions
|
|
@ -1,11 +1,9 @@
|
|||
using System.Runtime.Loader;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Interface.Animation;
|
||||
using Dalamud.Interface.Animation.EasingFunctions;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Textures;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Utility;
|
||||
|
||||
|
|
@ -23,9 +21,6 @@ internal sealed partial class ActiveNotification : IActiveNotification
|
|||
private readonly Easing progressEasing;
|
||||
private readonly Easing expandoEasing;
|
||||
|
||||
/// <summary>Whether to call <see cref="IDisposable.Dispose"/> on <see cref="DisposeInternal"/>.</summary>
|
||||
private bool hasIconTextureOwnership;
|
||||
|
||||
/// <summary>Gets the time of starting to count the timer for the expiration.</summary>
|
||||
private DateTime lastInterestTime;
|
||||
|
||||
|
|
@ -119,31 +114,10 @@ internal sealed partial class ActiveNotification : IActiveNotification
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IDalamudTextureWrap? IconTexture
|
||||
public ISharedImmediateTexture? IconTexture
|
||||
{
|
||||
get => this.underlyingNotification.IconTexture;
|
||||
set => this.IconTextureTask = value is null ? null : Task.FromResult(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<IDalamudTextureWrap?>? IconTextureTask
|
||||
{
|
||||
get => this.underlyingNotification.IconTextureTask;
|
||||
set
|
||||
{
|
||||
// Do nothing if the value did not change.
|
||||
if (this.underlyingNotification.IconTextureTask == value)
|
||||
return;
|
||||
|
||||
if (this.hasIconTextureOwnership)
|
||||
{
|
||||
_ = this.underlyingNotification.IconTextureTask?.ToContentDisposedTask(true);
|
||||
this.underlyingNotification.IconTextureTask = null;
|
||||
this.hasIconTextureOwnership = false;
|
||||
}
|
||||
|
||||
this.underlyingNotification.IconTextureTask = value;
|
||||
}
|
||||
set => this.underlyingNotification.IconTexture = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
@ -265,39 +239,6 @@ internal sealed partial class ActiveNotification : IActiveNotification
|
|||
this.extendedExpiry = newExpiry;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetIconTexture(IDalamudTextureWrap? textureWrap) =>
|
||||
this.SetIconTexture(textureWrap, false);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetIconTexture(IDalamudTextureWrap? textureWrap, bool leaveOpen) =>
|
||||
this.SetIconTexture(textureWrap is null ? null : Task.FromResult(textureWrap), leaveOpen);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetIconTexture(Task<IDalamudTextureWrap?>? textureWrapTask) =>
|
||||
this.SetIconTexture(textureWrapTask, false);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetIconTexture(Task<IDalamudTextureWrap?>? textureWrapTask, bool leaveOpen)
|
||||
{
|
||||
// If we're requested to replace the texture with the same texture, do nothing.
|
||||
if (this.underlyingNotification.IconTextureTask == textureWrapTask)
|
||||
return;
|
||||
|
||||
if (this.DismissReason is not null)
|
||||
{
|
||||
if (!leaveOpen)
|
||||
textureWrapTask?.ToContentDisposedTask(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.hasIconTextureOwnership)
|
||||
_ = this.underlyingNotification.IconTextureTask?.ToContentDisposedTask(true);
|
||||
|
||||
this.hasIconTextureOwnership = !leaveOpen;
|
||||
this.underlyingNotification.IconTextureTask = textureWrapTask;
|
||||
}
|
||||
|
||||
/// <summary>Removes non-Dalamud invocation targets from events.</summary>
|
||||
/// <remarks>
|
||||
/// This is done to prevent references of plugins being unloaded from outliving the plugin itself.
|
||||
|
|
@ -317,10 +258,8 @@ internal sealed partial class ActiveNotification : IActiveNotification
|
|||
if (this.Icon is { } previousIcon && !IsOwnedByDalamud(previousIcon.GetType()))
|
||||
this.Icon = null;
|
||||
|
||||
// Clear the texture if we don't have the ownership.
|
||||
// The texture probably was owned by the plugin being unloaded in such case.
|
||||
if (!this.hasIconTextureOwnership)
|
||||
this.IconTextureTask = null;
|
||||
if (this.IconTexture is { } previousTexture && !IsOwnedByDalamud(previousTexture.GetType()))
|
||||
this.IconTexture = null;
|
||||
|
||||
this.isInitiatorUnloaded = true;
|
||||
this.UserDismissable = true;
|
||||
|
|
@ -400,13 +339,6 @@ internal sealed partial class ActiveNotification : IActiveNotification
|
|||
/// <summary>Clears the resources associated with this instance of <see cref="ActiveNotification"/>.</summary>
|
||||
internal void DisposeInternal()
|
||||
{
|
||||
if (this.hasIconTextureOwnership)
|
||||
{
|
||||
_ = this.underlyingNotification.IconTextureTask?.ToContentDisposedTask(true);
|
||||
this.underlyingNotification.IconTextureTask = null;
|
||||
this.hasIconTextureOwnership = false;
|
||||
}
|
||||
|
||||
this.Dismiss = null;
|
||||
this.Click = null;
|
||||
this.DrawActions = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue