diff --git a/Dalamud/Data/DataManager.cs b/Dalamud/Data/DataManager.cs index a524a9e04..f0504c16c 100644 --- a/Dalamud/Data/DataManager.cs +++ b/Dalamud/Data/DataManager.cs @@ -4,7 +4,9 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Threading; - +using Dalamud.Data.LuminaExtensions; +using Dalamud.Interface; +using ImGuiScene; using JetBrains.Annotations; using Lumina; using Lumina.Data; @@ -20,6 +22,7 @@ namespace Dalamud.Data /// public class DataManager : IDisposable { + private readonly InterfaceManager interfaceManager; private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex"; /// @@ -33,8 +36,9 @@ namespace Dalamud.Data /// Initializes a new instance of the class. /// /// The language to load data with by default. - public DataManager(ClientLanguage language) + internal DataManager(ClientLanguage language, InterfaceManager interfaceManager) { + this.interfaceManager = interfaceManager; // Set up default values so plugins do not null-reference when data is being loaded. this.ServerOpCodes = new ReadOnlyDictionary(new Dictionary()); @@ -71,7 +75,7 @@ namespace Dalamud.Data /// Initialize this data manager. /// /// The directory to load data from. - public void Initialize(string baseDir) + internal void Initialize(string baseDir) { try { @@ -264,6 +268,39 @@ namespace Dalamud.Data return file; } + /// + /// Get the passed as a drawable ImGui TextureWrap. + /// + /// The Lumina . + /// A that can be used to draw the texture. + public TextureWrap GetImGuiTexture(TexFile tex) => + this.interfaceManager.LoadImageRaw(tex.GetRgbaImageData(), tex.Header.Width, tex.Header.Height, 4); + + /// + /// Get the passed texture path as a drawable ImGui TextureWrap. + /// + /// The internal path to the texture. + /// A that can be used to draw the texture. + public TextureWrap GetImGuiTexture(string path) => this.GetImGuiTexture(this.GetFile(path)); + + /// + /// Get a containing the icon with the given ID, of the given language. + /// + /// The requested language. + /// The icon ID. + /// The containing the icon. + public TextureWrap GetImGuiTextureIcon(ClientLanguage iconLanguage, int iconId) => + this.GetImGuiTexture(this.GetIcon(iconLanguage, iconId)); + + /// + /// Get a containing the icon with the given ID, of the given type. + /// + /// The type of the icon (e.g. 'hq' to get the HQ variant of an item icon). + /// The icon ID. + /// The containing the icon. + public TextureWrap GetImGuiTextureIcon(string type, int iconId) => + this.GetImGuiTexture(this.GetIcon(type, iconId)); + #endregion ///