diff --git a/Dalamud/Data/DataManager.cs b/Dalamud/Data/DataManager.cs index e24fc6bdb..a6285e80b 100644 --- a/Dalamud/Data/DataManager.cs +++ b/Dalamud/Data/DataManager.cs @@ -81,7 +81,7 @@ namespace Dalamud.Data /// /// The excel sheet type to get. /// The , giving access to game rows. - public ExcelSheet GetExcelSheet() where T : ExcelRow + public ExcelSheet? GetExcelSheet() where T : ExcelRow { return this.Excel.GetSheet(); } @@ -92,7 +92,7 @@ namespace Dalamud.Data /// Language of the sheet to get. /// The excel sheet type to get. /// The , giving access to game rows. - public ExcelSheet GetExcelSheet(ClientLanguage language) where T : ExcelRow + public ExcelSheet? GetExcelSheet(ClientLanguage language) where T : ExcelRow { return this.Excel.GetSheet(language.ToLumina()); } @@ -102,7 +102,7 @@ namespace Dalamud.Data /// /// The path inside of the game files. /// The of the file. - public FileResource GetFile(string path) + public FileResource? GetFile(string path) { return this.GetFile(path); } @@ -113,7 +113,7 @@ namespace Dalamud.Data /// The type of resource. /// The path inside of the game files. /// The of the file. - public T GetFile(string path) where T : FileResource + public T? GetFile(string path) where T : FileResource { var filePath = GameData.ParseFilePath(path); if (filePath == null) @@ -136,7 +136,7 @@ namespace Dalamud.Data /// /// The icon ID. /// The containing the icon. - public TexFile GetIcon(uint iconId) + public TexFile? GetIcon(uint iconId) { return this.GetIcon(this.Language, iconId); } @@ -147,7 +147,7 @@ namespace Dalamud.Data /// A value indicating whether the icon should be HQ. /// The icon ID. /// The containing the icon. - public TexFile GetIcon(bool isHq, uint iconId) + public TexFile? GetIcon(bool isHq, uint iconId) { var type = isHq ? "hq/" : string.Empty; return this.GetIcon(type, iconId); @@ -159,7 +159,7 @@ namespace Dalamud.Data /// The requested language. /// The icon ID. /// The containing the icon. - public TexFile GetIcon(ClientLanguage iconLanguage, uint iconId) + public TexFile? GetIcon(ClientLanguage iconLanguage, uint iconId) { var type = iconLanguage switch { @@ -179,7 +179,7 @@ namespace Dalamud.Data /// 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 TexFile GetIcon(string type, uint iconId) + public TexFile? GetIcon(string type, uint iconId) { type ??= string.Empty; if (type.Length > 0 && !type.EndsWith("/")) @@ -202,7 +202,7 @@ namespace Dalamud.Data /// /// The icon ID. /// The containing the icon. - public TexFile GetHqIcon(uint iconId) + public TexFile? GetHqIcon(uint iconId) => this.GetIcon(true, iconId); /// @@ -210,15 +210,17 @@ namespace Dalamud.Data /// /// The Lumina . /// A that can be used to draw the texture. - public TextureWrap GetImGuiTexture(TexFile tex) - => Service.Get().LoadImageRaw(tex.GetRgbaImageData(), tex.Header.Width, tex.Header.Height, 4); + public TextureWrap? GetImGuiTexture(TexFile? tex) + { + return tex == null ? null : Service.Get().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) + public TextureWrap? GetImGuiTexture(string path) => this.GetImGuiTexture(this.GetFile(path)); /// @@ -226,7 +228,7 @@ namespace Dalamud.Data /// /// The icon ID. /// The containing the icon. - public TextureWrap GetImGuiTextureIcon(uint iconId) + public TextureWrap? GetImGuiTextureIcon(uint iconId) => this.GetImGuiTexture(this.GetIcon(iconId)); /// @@ -235,7 +237,7 @@ namespace Dalamud.Data /// A value indicating whether the icon should be HQ. /// The icon ID. /// The containing the icon. - public TextureWrap GetImGuiTextureIcon(bool isHq, uint iconId) + public TextureWrap? GetImGuiTextureIcon(bool isHq, uint iconId) => this.GetImGuiTexture(this.GetIcon(isHq, iconId)); /// @@ -244,7 +246,7 @@ namespace Dalamud.Data /// The requested language. /// The icon ID. /// The containing the icon. - public TextureWrap GetImGuiTextureIcon(ClientLanguage iconLanguage, uint iconId) + public TextureWrap? GetImGuiTextureIcon(ClientLanguage iconLanguage, uint iconId) => this.GetImGuiTexture(this.GetIcon(iconLanguage, iconId)); /// @@ -253,7 +255,7 @@ namespace Dalamud.Data /// 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, uint iconId) + public TextureWrap? GetImGuiTextureIcon(string type, uint iconId) => this.GetImGuiTexture(this.GetIcon(type, iconId)); /// @@ -261,7 +263,7 @@ namespace Dalamud.Data /// /// The icon ID. /// The containing the icon. - public TextureWrap GetImGuiTextureHqIcon(uint iconId) + public TextureWrap? GetImGuiTextureHqIcon(uint iconId) => this.GetImGuiTexture(this.GetHqIcon(iconId)); #endregion