mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
fix: explicitly declare InterfaceManagerWithScene as a dependency for PluginImageCache
This commit is contained in:
parent
80bf56ab5b
commit
261d8a167f
2 changed files with 11 additions and 11 deletions
|
|
@ -45,6 +45,9 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
private const string MainRepoImageUrl = "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/api6/{0}/{1}/images/{2}";
|
private const string MainRepoImageUrl = "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/api6/{0}/{1}/images/{2}";
|
||||||
private const string MainRepoDip17ImageUrl = "https://raw.githubusercontent.com/goatcorp/PluginDistD17/main/{0}/{1}/images/{2}";
|
private const string MainRepoDip17ImageUrl = "https://raw.githubusercontent.com/goatcorp/PluginDistD17/main/{0}/{1}/images/{2}";
|
||||||
|
|
||||||
|
[ServiceManager.ServiceDependency]
|
||||||
|
private readonly InterfaceManager.InterfaceManagerWithScene imWithScene = Service<InterfaceManager.InterfaceManagerWithScene>.Get();
|
||||||
|
|
||||||
private readonly BlockingCollection<Tuple<ulong, Func<Task>>> downloadQueue = new();
|
private readonly BlockingCollection<Tuple<ulong, Func<Task>>> downloadQueue = new();
|
||||||
private readonly BlockingCollection<Func<Task>> loadQueue = new();
|
private readonly BlockingCollection<Func<Task>> loadQueue = new();
|
||||||
private readonly CancellationTokenSource cancelToken = new();
|
private readonly CancellationTokenSource cancelToken = new();
|
||||||
|
|
@ -68,9 +71,8 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
[ServiceManager.ServiceConstructor]
|
[ServiceManager.ServiceConstructor]
|
||||||
private PluginImageCache(Dalamud dalamud)
|
private PluginImageCache(Dalamud dalamud)
|
||||||
{
|
{
|
||||||
var imwst = Service<InterfaceManager.InterfaceManagerWithScene>.GetAsync();
|
|
||||||
|
|
||||||
Task<TextureWrap>? TaskWrapIfNonNull(TextureWrap? tw) => tw == null ? null : Task.FromResult(tw!);
|
Task<TextureWrap>? TaskWrapIfNonNull(TextureWrap? tw) => tw == null ? null : Task.FromResult(tw!);
|
||||||
|
var imwst = Task.Run(() => this.imWithScene);
|
||||||
|
|
||||||
this.emptyTextureTask = imwst.ContinueWith(task => task.Result.Manager.LoadImageRaw(new byte[64], 8, 8, 4)!);
|
this.emptyTextureTask = imwst.ContinueWith(task => task.Result.Manager.LoadImageRaw(new byte[64], 8, 8, 4)!);
|
||||||
this.defaultIconTask = imwst.ContinueWith(task => TaskWrapIfNonNull(task.Result.Manager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "defaultIcon.png"))) ?? this.emptyTextureTask).Unwrap();
|
this.defaultIconTask = imwst.ContinueWith(task => TaskWrapIfNonNull(task.Result.Manager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "defaultIcon.png"))) ?? this.emptyTextureTask).Unwrap();
|
||||||
|
|
@ -297,7 +299,7 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<TextureWrap?> TryLoadImage(
|
private async Task<TextureWrap?> TryLoadImage(
|
||||||
byte[]? bytes,
|
byte[]? bytes,
|
||||||
string name,
|
string name,
|
||||||
string? loc,
|
string? loc,
|
||||||
|
|
@ -309,7 +311,7 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
if (bytes == null)
|
if (bytes == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var interfaceManager = (await Service<InterfaceManager.InterfaceManagerWithScene>.GetAsync()).Manager;
|
var interfaceManager = this.imWithScene.Manager;
|
||||||
var framework = await Service<Framework>.GetAsync();
|
var framework = await Service<Framework>.GetAsync();
|
||||||
|
|
||||||
TextureWrap? image;
|
TextureWrap? image;
|
||||||
|
|
@ -453,8 +455,6 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
|
|
||||||
private async Task LoadTask(int concurrency)
|
private async Task LoadTask(int concurrency)
|
||||||
{
|
{
|
||||||
await Service<InterfaceManager.InterfaceManagerWithScene>.GetAsync();
|
|
||||||
|
|
||||||
var token = this.cancelToken.Token;
|
var token = this.cancelToken.Token;
|
||||||
var runningTasks = new List<Task>();
|
var runningTasks = new List<Task>();
|
||||||
while (true)
|
while (true)
|
||||||
|
|
@ -500,7 +500,7 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
() => File.ReadAllBytesAsync(file.FullName),
|
() => File.ReadAllBytesAsync(file.FullName),
|
||||||
requestedFrame);
|
requestedFrame);
|
||||||
var fileIcon = await this.RunInLoadQueue(
|
var fileIcon = await this.RunInLoadQueue(
|
||||||
() => TryLoadImage(
|
() => this.TryLoadImage(
|
||||||
fileBytes,
|
fileBytes,
|
||||||
"icon",
|
"icon",
|
||||||
file.FullName,
|
file.FullName,
|
||||||
|
|
@ -548,7 +548,7 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var icon = await this.RunInLoadQueue(
|
var icon = await this.RunInLoadQueue(
|
||||||
() => TryLoadImage(bytes, "icon", url, manifest, PluginIconWidth, PluginIconHeight, true));
|
() => this.TryLoadImage(bytes, "icon", url, manifest, PluginIconWidth, PluginIconHeight, true));
|
||||||
if (icon != null)
|
if (icon != null)
|
||||||
Log.Verbose($"Plugin icon for {manifest.InternalName} loaded");
|
Log.Verbose($"Plugin icon for {manifest.InternalName} loaded");
|
||||||
return icon;
|
return icon;
|
||||||
|
|
@ -573,7 +573,7 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
() => File.ReadAllBytesAsync(file.FullName),
|
() => File.ReadAllBytesAsync(file.FullName),
|
||||||
requestedFrame);
|
requestedFrame);
|
||||||
var image = await this.RunInLoadQueue(
|
var image = await this.RunInLoadQueue(
|
||||||
() => TryLoadImage(
|
() => this.TryLoadImage(
|
||||||
bytes,
|
bytes,
|
||||||
$"image{i2 + 1}",
|
$"image{i2 + 1}",
|
||||||
file.FullName,
|
file.FullName,
|
||||||
|
|
@ -639,7 +639,7 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
if (bytes == null)
|
if (bytes == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var image = await TryLoadImage(
|
var image = await this.TryLoadImage(
|
||||||
bytes,
|
bytes,
|
||||||
$"image{i2 + 1}",
|
$"image{i2 + 1}",
|
||||||
"queue",
|
"queue",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue