API 10
This commit is contained in:
parent
b5125d4b3f
commit
6c8e89c49d
@ -14,13 +14,13 @@ namespace LLib;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class DalamudReflector : IDisposable
|
public sealed class DalamudReflector : IDisposable
|
||||||
{
|
{
|
||||||
private readonly DalamudPluginInterface _pluginInterface;
|
private readonly IDalamudPluginInterface _pluginInterface;
|
||||||
private readonly IFramework _framework;
|
private readonly IFramework _framework;
|
||||||
private readonly IPluginLog _pluginLog;
|
private readonly IPluginLog _pluginLog;
|
||||||
private readonly Dictionary<string, IDalamudPlugin> _pluginCache = new();
|
private readonly Dictionary<string, IDalamudPlugin> _pluginCache = new();
|
||||||
private bool _pluginsChanged;
|
private bool _pluginsChanged;
|
||||||
|
|
||||||
public DalamudReflector(DalamudPluginInterface pluginInterface, IFramework framework, IPluginLog pluginLog)
|
public DalamudReflector(IDalamudPluginInterface pluginInterface, IFramework framework, IPluginLog pluginLog)
|
||||||
{
|
{
|
||||||
_pluginInterface = pluginInterface;
|
_pluginInterface = pluginInterface;
|
||||||
_framework = framework;
|
_framework = framework;
|
||||||
|
@ -11,14 +11,14 @@ public static class LAddon
|
|||||||
|
|
||||||
public static unsafe AtkUnitBase* GetAddonById(uint id)
|
public static unsafe AtkUnitBase* GetAddonById(uint id)
|
||||||
{
|
{
|
||||||
var unitManagers = &AtkStage.GetSingleton()->RaptureAtkUnitManager->AtkUnitManager.DepthLayerOneList;
|
var unitManagers = &AtkStage.Instance()->RaptureAtkUnitManager->AtkUnitManager.DepthLayerOneList;
|
||||||
for (var i = 0; i < UnitListCount; i++)
|
for (var i = 0; i < UnitListCount; i++)
|
||||||
{
|
{
|
||||||
var unitManager = &unitManagers[i];
|
var unitManager = &unitManagers[i];
|
||||||
foreach (var j in Enumerable.Range(0, Math.Min(unitManager->Count, unitManager->EntriesSpan.Length)))
|
foreach (var j in Enumerable.Range(0, Math.Min(unitManager->Count, unitManager->Entries.Length)))
|
||||||
{
|
{
|
||||||
var unitBase = unitManager->EntriesSpan[j].Value;
|
var unitBase = unitManager->Entries[j].Value;
|
||||||
if (unitBase != null && unitBase->ID == id)
|
if (unitBase != null && unitBase->Id == id)
|
||||||
{
|
{
|
||||||
return unitBase;
|
return unitBase;
|
||||||
}
|
}
|
||||||
|
37
IconCache.cs
37
IconCache.cs
@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Dalamud.Interface.Internal;
|
using Dalamud.Interface.Internal;
|
||||||
|
using Dalamud.Interface.Textures;
|
||||||
|
using Dalamud.Interface.Textures.TextureWraps;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
|
|
||||||
namespace LLib;
|
namespace LLib;
|
||||||
@ -8,46 +10,25 @@ namespace LLib;
|
|||||||
public sealed class IconCache : IDisposable
|
public sealed class IconCache : IDisposable
|
||||||
{
|
{
|
||||||
private readonly ITextureProvider _textureProvider;
|
private readonly ITextureProvider _textureProvider;
|
||||||
private readonly Dictionary<uint, TextureContainer> _textureWraps = new();
|
private readonly Dictionary<uint, ISharedImmediateTexture> _textureWraps = new();
|
||||||
|
|
||||||
public IconCache(ITextureProvider textureProvider)
|
public IconCache(ITextureProvider textureProvider)
|
||||||
{
|
{
|
||||||
_textureProvider = textureProvider;
|
_textureProvider = textureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDalamudTextureWrap? GetIcon(uint iconId)
|
public ISharedImmediateTexture GetIcon(uint iconId)
|
||||||
{
|
{
|
||||||
if (_textureWraps.TryGetValue(iconId, out TextureContainer? container))
|
if (_textureWraps.TryGetValue(iconId, out ISharedImmediateTexture? iconTex))
|
||||||
return container.Texture;
|
return iconTex;
|
||||||
|
|
||||||
var iconTex = _textureProvider.GetIcon(iconId);
|
iconTex = _textureProvider.GetFromGameIcon(new GameIconLookup(iconId));
|
||||||
if (iconTex != null)
|
_textureWraps[iconId] = iconTex;
|
||||||
{
|
return iconTex;
|
||||||
if (iconTex.ImGuiHandle != nint.Zero)
|
|
||||||
{
|
|
||||||
_textureWraps[iconId] = new TextureContainer { Texture = iconTex };
|
|
||||||
return iconTex;
|
|
||||||
}
|
|
||||||
|
|
||||||
iconTex.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
_textureWraps[iconId] = new TextureContainer { Texture = null };
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
foreach (TextureContainer container in _textureWraps.Values)
|
|
||||||
container.Dispose();
|
|
||||||
|
|
||||||
_textureWraps.Clear();
|
_textureWraps.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class TextureContainer : IDisposable
|
|
||||||
{
|
|
||||||
public required IDalamudTextureWrap? Texture { get; init; }
|
|
||||||
|
|
||||||
public void Dispose() => Texture?.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user