use penumbra ipc for getting character data

This commit is contained in:
rootdarkarchon
2023-10-05 01:13:04 +02:00
parent f371df7aa1
commit 61a2fe9168
9 changed files with 42 additions and 295 deletions

View File

@@ -1,33 +0,0 @@
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.Graphics.Render;
namespace MareSynchronos.Interop.FFXIV;
[StructLayout(LayoutKind.Explicit)]
public unsafe struct RenderModel
{
[FieldOffset(0x18)]
public RenderModel* PreviousModel;
[FieldOffset(0x20)]
public RenderModel* NextModel;
[FieldOffset(0x30)]
public ResourceHandle* ResourceHandle;
[FieldOffset(0x40)]
public Skeleton* Skeleton;
[FieldOffset(0x58)]
public void** BoneList;
[FieldOffset(0x60)]
public int BoneListCount;
[FieldOffset(0x98)]
public void** Materials;
[FieldOffset(0xA0)]
public int MaterialCount;
}

View File

@@ -1,32 +0,0 @@
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.System.Resource;
namespace MareSynchronos.Interop.FFXIV;
[StructLayout(LayoutKind.Explicit)]
public unsafe struct ResourceHandle
{
public const int SsoSize = 15;
public byte* FileName()
{
if (FileNameLength > SsoSize)
{
return FileNameData;
}
fixed (byte** name = &FileNameData)
{
return (byte*)name;
}
}
[FieldOffset(0x08)]
public ResourceCategory Category;
[FieldOffset(0x48)]
public byte* FileNameData;
[FieldOffset(0x58)]
public int FileNameLength;
}

View File

@@ -1,12 +0,0 @@
using System.Runtime.InteropServices;
namespace MareSynchronos.Interop.FFXIV;
[StructLayout(LayoutKind.Explicit)]
public unsafe struct Weapon
{
[FieldOffset(0x18)] public IntPtr Parent;
[FieldOffset(0x20)] public IntPtr NextSibling;
[FieldOffset(0x28)] public IntPtr PreviousSibling;
[FieldOffset(0xA8)] public WeaponDrawObject* WeaponRenderModel;
}

View File

@@ -1,9 +0,0 @@
using System.Runtime.InteropServices;
namespace MareSynchronos.Interop.FFXIV;
[StructLayout(LayoutKind.Explicit)]
public unsafe struct WeaponDrawObject
{
[FieldOffset(0x00)] public RenderModel* RenderModel;
}

View File

@@ -67,6 +67,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
private readonly FuncSubscriber<string, string, int, PenumbraApiEc> _penumbraRemoveTemporaryMod;
private readonly FuncSubscriber<string> _penumbraResolveModDir;
private readonly FuncSubscriber<string[], string[], (string[], string[][])> _penumbraResolvePaths;
private readonly ParamsFuncSubscriber<ushort, IReadOnlyDictionary<string, string[]>?[]> _penumbraResourcePaths;
private readonly SemaphoreSlim _redrawSemaphore = new(2);
private bool _customizePlusAvailable = false;
private CancellationTokenSource _disposalCts = new();
@@ -103,6 +104,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
Mediator.Publish(new PenumbraModSettingChangedMessage());
});
_penumbraConvertTextureFile = Penumbra.Api.Ipc.ConvertTextureFile.Subscriber(pi);
_penumbraResourcePaths = Penumbra.Api.Ipc.GetGameObjectResourcePaths.Subscriber(pi);
_penumbraGameObjectResourcePathResolved = Penumbra.Api.Ipc.GameObjectResourcePathResolved.Subscriber(pi, ResourceLoaded);
@@ -292,7 +294,8 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevertByName", applicationId);
_glamourerRevertByName.InvokeAction(name, LockCode);
}
catch (Exception ex) {
catch (Exception ex)
{
Logger.LogWarning(ex, "Error during Glamourer RevertByName");
}
}
@@ -573,8 +576,24 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
}
Mediator.Publish(new ResumeScanMessage("TextureConversion"));
var gameObject = await _dalamudUtil.CreateGameObjectAsync(await _dalamudUtil.GetPlayerPointerAsync());
_penumbraRedrawObject.Invoke(gameObject!, RedrawType.Redraw);
await _dalamudUtil.RunOnFrameworkThread(async () =>
{
var gameObject = await _dalamudUtil.CreateGameObjectAsync(await _dalamudUtil.GetPlayerPointerAsync().ConfigureAwait(false)).ConfigureAwait(false);
_penumbraRedrawObject.Invoke(gameObject!, RedrawType.Redraw);
}).ConfigureAwait(false);
}
public async Task<IReadOnlyDictionary<string, string[]>?[]?> PenumbraGetCharacterData(ILogger logger, GameObjectHandler handler)
{
if (!CheckPenumbraApi()) return null;
return await _dalamudUtil.RunOnFrameworkThread(() =>
{
logger.LogTrace("Calling On IPC: Penumbra.GetGameObjectResourcePaths");
var idx = handler.GetGameObject()?.ObjectIndex;
if (idx == null) return null;
return _penumbraResourcePaths.Invoke(idx.Value);
}).ConfigureAwait(false);
}
protected override void Dispose(bool disposing)