This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
43 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
using Dalamud.Interface.Internal; | ||
using Dalamud.Interface.Textures; | ||
using Dalamud.Interface.Textures.TextureWraps; | ||
using Dalamud.Utility; | ||
using ECommons.DalamudServices; | ||
using Lumina.Data.Files; | ||
using System.Collections.Generic; | ||
|
||
namespace XIVSlothCombo.Window | ||
{ | ||
internal static class Icons | ||
{ | ||
public static Dictionary<uint, IDalamudTextureWrap> CachedModdedIcons = new(); | ||
public static IDalamudTextureWrap? GetJobIcon(uint jobId) | ||
{ | ||
if (jobId == 0 || jobId > 42) return null; | ||
var icon = Svc.Texture.GetFromGameIcon(62100 + jobId); | ||
if (!icon.TryGetWrap(out var wrap, out _)) | ||
return null; | ||
return wrap; | ||
var icon = GetTextureFromIconId(62100 + jobId); | ||
|
||
return icon; | ||
} | ||
|
||
private static string ResolvePath(string path) => Svc.TextureSubstitution.GetSubstitutedPath(path); | ||
|
||
public static IDalamudTextureWrap? GetTextureFromIconId(uint iconId, uint stackCount = 0, bool hdIcon = true) | ||
{ | ||
GameIconLookup lookup = new GameIconLookup(iconId + stackCount, false, hdIcon); | ||
string path = Svc.Texture.GetIconPath(lookup); | ||
string resolvePath = ResolvePath(path); | ||
|
||
var wrap = Svc.Texture.GetFromFile(resolvePath); | ||
if (wrap.TryGetWrap(out var icon, out _)) | ||
return icon; | ||
|
||
try | ||
{ | ||
if (CachedModdedIcons.ContainsKey(iconId)) return CachedModdedIcons[iconId]; | ||
var tex = Svc.Data.GameData.GetFileFromDisk<TexFile>(resolvePath); | ||
var output = Svc.Texture.CreateFromRaw(RawImageSpecification.Rgba32(tex.Header.Width, tex.Header.Width), tex.GetRgbaImageData()); | ||
if (output != null) | ||
{ | ||
CachedModdedIcons[iconId] = output; | ||
return output; | ||
} | ||
} | ||
catch { } | ||
|
||
|
||
return Svc.Texture.GetFromGame(path).GetWrapOrDefault(); | ||
} | ||
} | ||
} |