-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch INotificationManager and ITitleScreenMenu to use ISharedImmediateTexture #1879
base: master
Are you sure you want to change the base?
Changes from 5 commits
50e0560
afcc920
4e545c4
c7d91e0
25565b4
878d4df
778f48d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
|
||
namespace Dalamud.Interface.ImGuiNotification; | ||
|
||
using Textures; | ||
|
||
/// <summary>Represents a blueprint for a notification.</summary> | ||
public sealed record Notification : INotification | ||
{ | ||
|
@@ -29,15 +31,34 @@ public sealed record Notification : INotification | |
/// <inheritdoc/> | ||
public INotificationIcon? Icon { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public ISharedImmediateTexture? ImmediateIconTexture { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public IDalamudTextureWrap? IconTexture | ||
{ | ||
get => this.IconTextureTask?.IsCompletedSuccessfully is true ? this.IconTextureTask.Result : null; | ||
set => this.IconTextureTask = value is null ? null : Task.FromResult(value); | ||
get => this.ImmediateIconTexture?.GetWrapOrDefault(); | ||
set => this.ImmediateIconTexture = value != null ? new ForwardingSharedImmediateTexture(value) : null; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Task<IDalamudTextureWrap?>? IconTextureTask { get; set; } | ||
public Task<IDalamudTextureWrap?>? IconTextureTask | ||
{ | ||
get => Task.FromResult(this.ImmediateIconTexture?.GetWrapOrDefault()); | ||
|
||
set | ||
{ | ||
if (value == null) | ||
{ | ||
this.ImmediateIconTexture = null; | ||
} | ||
else | ||
{ | ||
var dalamudTextureWrap = value.Result; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assigning failed tasks should not throw. IMO it's better to just leave previous properties/methods alone and add ISIT on its own, and only on drawing refer to ISIT at first and then check the rest to figure out the correct thing to draw. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd basically need to throw out everything I've already done if that's the route you want to go, as it'd be faster for me to start on a new branch and implement a ImmediateIconTexture there rather than trying to put back in what I've already removed Have added in a try/catch, not pretty but does aleviate that above concern There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hopefully nobody refers to the state of the task after assigning it to the notification, too. Not sure why would one do that, so I'd guess it's be safe for this property to be "inconsistent". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only thing I could think of is creating a new Task.FromException<IDalamudTextureWrap?>(exception), storing it in a field and returning that when IconTextureTask.get is called Then when a set resolves correctly, it sets the failed task field to null. Not sure why would want to do it either, if I don't do something like above, it shouldn't cause a crash as they'll still have to null check, just a bit incosnsistent as you said There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another possible way would be making ForwardingSIT store Task instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've considered it however it'd require the GetWrapOrEmpty function to call Now if we made it so you could only get a ForwardingSharedImmediateTexture's from the ITextureProvider and it injected the 4x4 into the ForwardingSharedImmediateTexture that'd be fine but it adds a hard dependency to an object that could concievably be constructed outside of Dalamud |
||
this.ImmediateIconTexture = dalamudTextureWrap == null ? null : new ForwardingSharedImmediateTexture(dalamudTextureWrap); | ||
} | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public DateTime HardExpiry { get; set; } = DateTime.MaxValue; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this line so that
IsOwnedByDalamud
check is also done for the IDTW stored insideForwardingSharedImmediateTexture
.