Add ITextureProvider.ConvertToKernelTexture (#2003)

* Add ITextureProvider.ConvertToKernelTexture

Lets you obtain an instance of Kernel::Texture from IDalamudTextureWrap.

* Docs wip
This commit is contained in:
srkizer 2024-11-05 00:06:42 +09:00 committed by GitHub
parent 9a0bc50e23
commit 74ab9191d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 125 additions and 5 deletions

View file

@ -1,7 +1,9 @@
using System.Numerics;
using Dalamud.Game;
using Dalamud.Game.Gui;
using Dalamud.Interface.ImGuiSeStringRenderer.Internal;
using Dalamud.Interface.Textures.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
@ -317,6 +319,32 @@ internal unsafe class UiDebug
ImGui.TreePop();
}
}
if (ImGui.Button($"Replace with a random image##{(ulong)textureInfo:X}"))
{
var texm = Service<TextureManager>.Get();
texm.Shared
.GetFromGame(
Random.Shared.Next(0, 1) == 0
? $"ui/loadingimage/-nowloading_base{Random.Shared.Next(1, 33)}.tex"
: $"ui/loadingimage/-nowloading_base{Random.Shared.Next(1, 33)}_hr1.tex")
.RentAsync()
.ContinueWith(
r => Service<Framework>.Get().RunOnFrameworkThread(
() =>
{
if (!r.IsCompletedSuccessfully)
return;
using (r.Result)
{
textureInfo->AtkTexture.ReleaseTexture();
textureInfo->AtkTexture.KernelTexture =
texm.ConvertToKernelTexture(r.Result);
textureInfo->AtkTexture.TextureType = TextureType.KernelTexture;
}
}));
}
}
}
else