Files
HSUI/Helpers/TexturesHelper.cs
T

35 lines
1.3 KiB
C#

using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
using Lumina.Excel;
using static Dalamud.Plugin.Services.ITextureProvider;
namespace HSUI.Helpers
{
public class TexturesHelper
{
public static IDalamudTextureWrap? GetTexture<T>(uint rowId, uint stackCount = 0, bool hdIcon = true) where T : struct, IExcelRow<T>
{
ExcelSheet<T> sheet = Plugin.DataManager.GetExcelSheet<T>();
return sheet == null ? null : GetTexture<T>(sheet.GetRow(rowId), stackCount, hdIcon);
}
public static IDalamudTextureWrap? GetTexture<T>(dynamic row, uint stackCount = 0, bool hdIcon = true) where T : struct, IExcelRow<T>
{
dynamic iconId = row.Icon;
return GetTextureFromIconId(iconId, stackCount, hdIcon);
}
public static IDalamudTextureWrap? GetTextureFromIconId(uint iconId, uint stackCount = 0, bool hdIcon = true)
{
GameIconLookup lookup = new GameIconLookup(iconId + stackCount, false, hdIcon);
return Plugin.TextureProvider.GetFromGameIcon(lookup).GetWrapOrDefault();
}
public static IDalamudTextureWrap? GetTextureFromPath(string path)
{
return Plugin.TextureProvider.GetFromGame(path).GetWrapOrDefault();
}
}
}