From 3c5f6271ceff934fa18f53f3cd2b258a4bb08631 Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 9 Aug 2021 12:02:59 -0400 Subject: [PATCH] GetIcon should be uint, add more overloads for HQ icons Apparently "hq" is a language internally. --- Dalamud/Data/DataManager.cs | 58 +++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/Dalamud/Data/DataManager.cs b/Dalamud/Data/DataManager.cs index f28a56e69..093c8bb1a 100644 --- a/Dalamud/Data/DataManager.cs +++ b/Dalamud/Data/DataManager.cs @@ -137,18 +137,30 @@ namespace Dalamud.Data /// /// The icon ID. /// The containing the icon. - public TexFile GetIcon(int iconId) + public TexFile GetIcon(uint iconId) { return this.GetIcon(this.Language, iconId); } + /// + /// Get a containing the icon with the given ID, of the given quality. + /// + /// A value indicating whether the icon should be HQ. + /// The icon ID. + /// The containing the icon. + public TexFile GetIcon(bool isHq, uint iconId) + { + var type = isHq ? "hq/" : string.Empty; + return this.GetIcon(type, iconId); + } + /// /// Get a containing the icon with the given ID, of the given language. /// /// The requested language. /// The icon ID. /// The containing the icon. - public TexFile GetIcon(ClientLanguage iconLanguage, int iconId) + public TexFile GetIcon(ClientLanguage iconLanguage, uint iconId) { var type = iconLanguage switch { @@ -168,7 +180,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, int iconId) + public TexFile GetIcon(string type, uint iconId) { type ??= string.Empty; if (type.Length > 0 && !type.EndsWith("/")) @@ -177,7 +189,8 @@ namespace Dalamud.Data var filePath = string.Format(IconFileFormat, iconId / 1000, type, iconId); var file = this.GetFile(filePath); - if (file != default(TexFile) || type.Length <= 0) return file; + if (type == string.Empty || file != default) + return file; // Couldn't get specific type, try for generic version. filePath = string.Format(IconFileFormat, iconId / 1000, string.Empty, iconId); @@ -185,6 +198,14 @@ namespace Dalamud.Data return file; } + /// + /// Get a containing the HQ icon with the given ID. + /// + /// The icon ID. + /// The containing the icon. + public TexFile GetHqIcon(uint iconId) + => this.GetIcon(true, iconId); + /// /// Get the passed as a drawable ImGui TextureWrap. /// @@ -201,13 +222,30 @@ namespace Dalamud.Data public TextureWrap GetImGuiTexture(string path) => this.GetImGuiTexture(this.GetFile(path)); + /// + /// Get a containing the icon with the given ID. + /// + /// The icon ID. + /// The containing the icon. + public TextureWrap GetImGuiTextureIcon(uint iconId) + => this.GetImGuiTexture(this.GetIcon(iconId)); + + /// + /// Get a containing the icon with the given ID, of the given quality. + /// + /// A value indicating whether the icon should be HQ. + /// The icon ID. + /// The containing the icon. + public TextureWrap GetImGuiTextureIcon(bool isHq, uint iconId) + => this.GetImGuiTexture(this.GetIcon(isHq, iconId)); + /// /// 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) + public TextureWrap GetImGuiTextureIcon(ClientLanguage iconLanguage, uint iconId) => this.GetImGuiTexture(this.GetIcon(iconLanguage, iconId)); /// @@ -216,9 +254,17 @@ 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, int iconId) + public TextureWrap GetImGuiTextureIcon(string type, uint iconId) => this.GetImGuiTexture(this.GetIcon(type, iconId)); + /// + /// Get a containing the HQ icon with the given ID. + /// + /// The icon ID. + /// The containing the icon. + public TextureWrap GetImGuiTextureHqIcon(uint iconId) + => this.GetImGuiTexture(this.GetHqIcon(iconId)); + #endregion ///