update UldWrapper

This commit is contained in:
Soreepeong 2024-02-22 18:31:08 +09:00
parent e12563d20f
commit aa35052a15

View file

@ -4,6 +4,7 @@ using System.Linq;
using Dalamud.Data; using Dalamud.Data;
using Dalamud.Interface.Internal; using Dalamud.Interface.Internal;
using Dalamud.Plugin.Services;
using Dalamud.Utility; using Dalamud.Utility;
using Lumina.Data.Files; using Lumina.Data.Files;
using Lumina.Data.Parsing.Uld; using Lumina.Data.Parsing.Uld;
@ -14,16 +15,17 @@ namespace Dalamud.Interface;
public class UldWrapper : IDisposable public class UldWrapper : IDisposable
{ {
private readonly DataManager data; private readonly DataManager data;
private readonly UiBuilder uiBuilder; private readonly TextureManager textureManager;
private readonly Dictionary<string, (uint Id, int Width, int Height, bool HD, byte[] RgbaData)> textures = new(); private readonly Dictionary<string, (uint Id, int Width, int Height, bool HD, byte[] RgbaData)> textures = new();
/// <summary> Initializes a new instance of the <see cref="UldWrapper"/> class, wrapping an ULD file. </summary> /// <summary> Initializes a new instance of the <see cref="UldWrapper"/> class, wrapping an ULD file. </summary>
/// <param name="uiBuilder">The UiBuilder used to load textures.</param> /// <param name="uiBuilder">The UiBuilder used to load textures.</param>
/// <param name="uldPath">The requested ULD file.</param> /// <param name="uldPath">The requested ULD file.</param>
internal UldWrapper(UiBuilder uiBuilder, string uldPath) internal UldWrapper(UiBuilder? uiBuilder, string uldPath)
{ {
this.uiBuilder = uiBuilder; _ = uiBuilder;
this.data = Service<DataManager>.Get(); this.data = Service<DataManager>.Get();
this.textureManager = Service<TextureManager>.Get();
this.Uld = this.data.GetFile<UldFile>(uldPath); this.Uld = this.data.GetFile<UldFile>(uldPath);
} }
@ -123,7 +125,7 @@ public class UldWrapper : IDisposable
inputSlice.CopyTo(outputSlice); inputSlice.CopyTo(outputSlice);
} }
return this.uiBuilder.LoadImageRaw(imageData, part.W, part.H, 4); return this.textureManager.GetFromRaw(RawImageSpecification.Rgba32(part.W, part.H), imageData);
} }
private (uint Id, int Width, int Height, bool HD, byte[] RgbaData)? GetTexture(string texturePath) private (uint Id, int Width, int Height, bool HD, byte[] RgbaData)? GetTexture(string texturePath)