use index from gameobject to set set temp mods
This commit is contained in:
@@ -131,11 +131,6 @@ public sealed class FileCacheManager : IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ResolveFileReplacement(string gamePath)
|
|
||||||
{
|
|
||||||
return _ipcManager.PenumbraResolvePath(gamePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateHash(FileCacheEntity fileCache)
|
public void UpdateHash(FileCacheEntity fileCache)
|
||||||
{
|
{
|
||||||
_logger.LogTrace("Updating hash for {path}", fileCache.ResolvedFilepath);
|
_logger.LogTrace("Updating hash for {path}", fileCache.ResolvedFilepath);
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
private readonly ICallGateSubscriber<string, GameObject?, object>? _glamourerApplyOnlyCustomization;
|
private readonly ICallGateSubscriber<string, GameObject?, object>? _glamourerApplyOnlyCustomization;
|
||||||
private readonly ICallGateSubscriber<string, GameObject?, object>? _glamourerApplyOnlyEquipment;
|
private readonly ICallGateSubscriber<string, GameObject?, object>? _glamourerApplyOnlyEquipment;
|
||||||
private readonly ICallGateSubscriber<GameObject?, string>? _glamourerGetAllCustomization;
|
private readonly ICallGateSubscriber<GameObject?, string>? _glamourerGetAllCustomization;
|
||||||
private readonly ICallGateSubscriber<GameObject?, object> _glamourerRevertCustomization;
|
|
||||||
private readonly ConcurrentQueue<Action> _gposeActionQueue = new();
|
private readonly ConcurrentQueue<Action> _gposeActionQueue = new();
|
||||||
private readonly ICallGateSubscriber<string> _heelsGetApiVersion;
|
private readonly ICallGateSubscriber<string> _heelsGetApiVersion;
|
||||||
private readonly ICallGateSubscriber<float> _heelsGetOffset;
|
private readonly ICallGateSubscriber<float> _heelsGetOffset;
|
||||||
@@ -58,8 +57,6 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
private readonly FuncSubscriber<string, string, int, PenumbraApiEc> _penumbraRemoveTemporaryMod;
|
private readonly FuncSubscriber<string, string, int, PenumbraApiEc> _penumbraRemoveTemporaryMod;
|
||||||
private readonly FuncSubscriber<string> _penumbraResolveModDir;
|
private readonly FuncSubscriber<string> _penumbraResolveModDir;
|
||||||
private readonly FuncSubscriber<string[], string[], (string[], string[][])> _penumbraResolvePaths;
|
private readonly FuncSubscriber<string[], string[], (string[], string[][])> _penumbraResolvePaths;
|
||||||
private readonly FuncSubscriber<string, string> _penumbraResolvePlayer;
|
|
||||||
private readonly FuncSubscriber<string, string[]> _reverseResolvePlayer;
|
|
||||||
private bool _customizePlusAvailable = false;
|
private bool _customizePlusAvailable = false;
|
||||||
private CancellationTokenSource _disposalCts = new();
|
private CancellationTokenSource _disposalCts = new();
|
||||||
private bool _glamourerAvailable = false;
|
private bool _glamourerAvailable = false;
|
||||||
@@ -76,11 +73,9 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
_penumbraInit = Penumbra.Api.Ipc.Initialized.Subscriber(pi, PenumbraInit);
|
_penumbraInit = Penumbra.Api.Ipc.Initialized.Subscriber(pi, PenumbraInit);
|
||||||
_penumbraDispose = Penumbra.Api.Ipc.Disposed.Subscriber(pi, PenumbraDispose);
|
_penumbraDispose = Penumbra.Api.Ipc.Disposed.Subscriber(pi, PenumbraDispose);
|
||||||
_penumbraResolvePlayer = Penumbra.Api.Ipc.ResolvePlayerPath.Subscriber(pi);
|
|
||||||
_penumbraResolveModDir = Penumbra.Api.Ipc.GetModDirectory.Subscriber(pi);
|
_penumbraResolveModDir = Penumbra.Api.Ipc.GetModDirectory.Subscriber(pi);
|
||||||
_penumbraRedraw = Penumbra.Api.Ipc.RedrawObjectByName.Subscriber(pi);
|
_penumbraRedraw = Penumbra.Api.Ipc.RedrawObjectByName.Subscriber(pi);
|
||||||
_penumbraRedrawObject = Penumbra.Api.Ipc.RedrawObject.Subscriber(pi);
|
_penumbraRedrawObject = Penumbra.Api.Ipc.RedrawObject.Subscriber(pi);
|
||||||
_reverseResolvePlayer = Penumbra.Api.Ipc.ReverseResolvePlayerPath.Subscriber(pi);
|
|
||||||
_penumbraApiVersion = Penumbra.Api.Ipc.ApiVersions.Subscriber(pi);
|
_penumbraApiVersion = Penumbra.Api.Ipc.ApiVersions.Subscriber(pi);
|
||||||
_penumbraObjectIsRedrawn = Penumbra.Api.Ipc.GameObjectRedrawn.Subscriber(pi, RedrawEvent);
|
_penumbraObjectIsRedrawn = Penumbra.Api.Ipc.GameObjectRedrawn.Subscriber(pi, RedrawEvent);
|
||||||
_penumbraGetMetaManipulations = Penumbra.Api.Ipc.GetPlayerMetaManipulations.Subscriber(pi);
|
_penumbraGetMetaManipulations = Penumbra.Api.Ipc.GetPlayerMetaManipulations.Subscriber(pi);
|
||||||
@@ -104,7 +99,6 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
_glamourerApplyAll = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyAllToCharacter");
|
_glamourerApplyAll = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyAllToCharacter");
|
||||||
_glamourerApplyOnlyCustomization = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyCustomizationToCharacter");
|
_glamourerApplyOnlyCustomization = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyCustomizationToCharacter");
|
||||||
_glamourerApplyOnlyEquipment = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyEquipmentToCharacter");
|
_glamourerApplyOnlyEquipment = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyEquipmentToCharacter");
|
||||||
_glamourerRevertCustomization = pi.GetIpcSubscriber<GameObject?, object>("Glamourer.RevertCharacter");
|
|
||||||
|
|
||||||
_heelsGetApiVersion = pi.GetIpcSubscriber<string>("HeelsPlugin.ApiVersion");
|
_heelsGetApiVersion = pi.GetIpcSubscriber<string>("HeelsPlugin.ApiVersion");
|
||||||
_heelsGetOffset = pi.GetIpcSubscriber<float>("HeelsPlugin.GetOffset");
|
_heelsGetOffset = pi.GetIpcSubscriber<float>("HeelsPlugin.GetOffset");
|
||||||
@@ -147,7 +141,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
public bool CheckCustomizePlusApi() => _customizePlusAvailable;
|
public bool CheckCustomizePlusApi() => _customizePlusAvailable;
|
||||||
|
|
||||||
public bool CheckCustomizePlusApiInternal()
|
private bool CheckCustomizePlusApiInternal()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,7 +155,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
public bool CheckGlamourerApi() => _glamourerAvailable;
|
public bool CheckGlamourerApi() => _glamourerAvailable;
|
||||||
|
|
||||||
public bool CheckGlamourerApiInternal()
|
private bool CheckGlamourerApiInternal()
|
||||||
{
|
{
|
||||||
bool apiAvailable = false;
|
bool apiAvailable = false;
|
||||||
try
|
try
|
||||||
@@ -186,7 +180,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
public bool CheckHeelsApi() => _heelsAvailable;
|
public bool CheckHeelsApi() => _heelsAvailable;
|
||||||
|
|
||||||
public bool CheckHeelsApiInternal()
|
private bool CheckHeelsApiInternal()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -200,7 +194,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
public bool CheckPalettePlusApi() => _palettePlusAvailable;
|
public bool CheckPalettePlusApi() => _palettePlusAvailable;
|
||||||
|
|
||||||
public bool CheckPalettePlusApiInternal()
|
private bool CheckPalettePlusApiInternal()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -214,7 +208,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
public bool CheckPenumbraApi() => _penumbraAvailable;
|
public bool CheckPenumbraApi() => _penumbraAvailable;
|
||||||
|
|
||||||
public bool CheckPenumbraApiInternal()
|
private bool CheckPenumbraApiInternal()
|
||||||
{
|
{
|
||||||
bool apiAvailable = false;
|
bool apiAvailable = false;
|
||||||
try
|
try
|
||||||
@@ -339,12 +333,6 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GlamourerRevertCharacterCustomization(GameObject character)
|
|
||||||
{
|
|
||||||
if (!CheckGlamourerApi() || _dalamudUtil.IsZoning) return;
|
|
||||||
ActionQueue.Enqueue(() => _glamourerRevertCustomization!.InvokeAction(character));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task HeelsRestoreOffsetForPlayer(IntPtr character)
|
public async Task HeelsRestoreOffsetForPlayer(IntPtr character)
|
||||||
{
|
{
|
||||||
if (!CheckHeelsApi()) return;
|
if (!CheckHeelsApi()) return;
|
||||||
@@ -446,43 +434,20 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
logger.LogTrace("[{applicationId}] RemoveTemporaryCollection: {ret2}", applicationId, ret2);
|
logger.LogTrace("[{applicationId}] RemoveTemporaryCollection: {ret2}", applicationId, ret2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string PenumbraResolvePath(string path)
|
|
||||||
{
|
|
||||||
if (!CheckPenumbraApi()) return path;
|
|
||||||
var resolvedPath = _penumbraResolvePlayer!.Invoke(path);
|
|
||||||
return resolvedPath ?? path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public (string[] forward, string[][] reverse) PenumbraResolvePaths(string[] forward, string[] reverse)
|
public (string[] forward, string[][] reverse) PenumbraResolvePaths(string[] forward, string[] reverse)
|
||||||
{
|
{
|
||||||
return _penumbraResolvePaths.Invoke(forward, reverse);
|
return _penumbraResolvePaths.Invoke(forward, reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] PenumbraReverseResolvePlayer(string path)
|
public void PenumbraSetTemporaryMods(ILogger logger, Guid applicationId, string characterName, int? idx, Dictionary<string, string> modPaths, string manipulationData)
|
||||||
{
|
{
|
||||||
if (!CheckPenumbraApi()) return new[] { path };
|
if (!CheckPenumbraApi() || idx == null) return;
|
||||||
var resolvedPaths = _reverseResolvePlayer.Invoke(path);
|
|
||||||
if (resolvedPaths.Length == 0)
|
|
||||||
{
|
|
||||||
resolvedPaths = new[] { path };
|
|
||||||
}
|
|
||||||
return resolvedPaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PenumbraSetTemporaryMods(ILogger logger, Guid applicationId, string characterName, Dictionary<string, string> modPaths, string manipulationData)
|
|
||||||
{
|
|
||||||
if (!CheckPenumbraApi()) return;
|
|
||||||
|
|
||||||
var idx = _dalamudUtil.GetIndexFromObjectTableByName(characterName);
|
|
||||||
if (idx == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var collName = "Mare_" + characterName;
|
var collName = "Mare_" + characterName;
|
||||||
var ret = _penumbraCreateNamedTemporaryCollection.Invoke(collName);
|
var ret = _penumbraCreateNamedTemporaryCollection.Invoke(collName);
|
||||||
logger.LogTrace("[{applicationId}] Creating Temp Collection {collName}, Success: {ret}", applicationId, collName, ret);
|
logger.LogTrace("[{applicationId}] Creating Temp Collection {collName}, Success: {ret}", applicationId, collName, ret);
|
||||||
var retAssign = _penumbraAssignTemporaryCollection.Invoke(collName, idx.Value, c: true);
|
var retAssign = _penumbraAssignTemporaryCollection.Invoke(collName, idx.Value, c: true);
|
||||||
logger.LogTrace("[{applicationId}] Assigning Temp Collection {collName} to index {idx}", applicationId, collName, idx.Value);
|
logger.LogTrace("[{applicationId}] Assigning Temp Collection {collName} to index {idx}, Success: {ret}", applicationId, collName, idx, retAssign);
|
||||||
foreach (var mod in modPaths)
|
foreach (var mod in modPaths)
|
||||||
{
|
{
|
||||||
logger.LogTrace("[{applicationId}] Change: {from} => {to}", applicationId, mod.Key, mod.Value);
|
logger.LogTrace("[{applicationId}] Change: {from} => {to}", applicationId, mod.Key, mod.Value);
|
||||||
@@ -497,16 +462,6 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
_inGposeQueueMode = on;
|
_inGposeQueueMode = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool RequestedRedraw(nint address)
|
|
||||||
{
|
|
||||||
if (_penumbraRedrawRequests.TryGetValue(address, out var requested))
|
|
||||||
{
|
|
||||||
return requested;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using MareSynchronos.PlayerData.Handlers;
|
using MareSynchronos.PlayerData.Handlers;
|
||||||
using MareSynchronos.Interop;
|
using MareSynchronos.Interop;
|
||||||
using MareSynchronos.Services;
|
using MareSynchronos.Services;
|
||||||
|
using MareSynchronos.Utils;
|
||||||
|
|
||||||
namespace MareSynchronos.PlayerData.Export;
|
namespace MareSynchronos.PlayerData.Export;
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ public class MareCharaFileManager
|
|||||||
var applicationId = Guid.NewGuid();
|
var applicationId = Guid.NewGuid();
|
||||||
_ipcManager.ToggleGposeQueueMode(on: true);
|
_ipcManager.ToggleGposeQueueMode(on: true);
|
||||||
_ipcManager.PenumbraRemoveTemporaryCollection(_logger, applicationId, charaTarget.Name.TextValue);
|
_ipcManager.PenumbraRemoveTemporaryCollection(_logger, applicationId, charaTarget.Name.TextValue);
|
||||||
_ipcManager.PenumbraSetTemporaryMods(_logger, applicationId, charaTarget.Name.TextValue,
|
_ipcManager.PenumbraSetTemporaryMods(_logger, applicationId, charaTarget.Name.TextValue, charaTarget.ObjectTableIndex(),
|
||||||
extractedFiles.Union(fileSwaps).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal),
|
extractedFiles.Union(fileSwaps).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal),
|
||||||
LoadedCharaFile.CharaFileData.ManipulationData);
|
LoadedCharaFile.CharaFileData.ManipulationData);
|
||||||
using GameObjectHandler tempHandler = _gameObjectHandlerFactory(ObjectKind.Player, () => charaTarget.Address, false);
|
using GameObjectHandler tempHandler = _gameObjectHandlerFactory(ObjectKind.Player, () => charaTarget.Address, false);
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase
|
|||||||
{
|
{
|
||||||
await _dalamudUtil.RunOnFrameworkThread(() => _ipcManager.PenumbraRemoveTemporaryCollection(Logger, applicationId, PlayerName!)).ConfigureAwait(false);
|
await _dalamudUtil.RunOnFrameworkThread(() => _ipcManager.PenumbraRemoveTemporaryCollection(Logger, applicationId, PlayerName!)).ConfigureAwait(false);
|
||||||
token.ThrowIfCancellationRequested();
|
token.ThrowIfCancellationRequested();
|
||||||
await _dalamudUtil.RunOnFrameworkThread(() => _ipcManager.PenumbraSetTemporaryMods(Logger, applicationId, PlayerName!, moddedPaths, manipulationData)).ConfigureAwait(false);
|
await _dalamudUtil.RunOnFrameworkThread(() => _ipcManager.PenumbraSetTemporaryMods(Logger, applicationId, PlayerName!, _charaHandler?.GameObjectLazy?.Value.ObjectTableIndex(), moddedPaths, manipulationData)).ConfigureAwait(false);
|
||||||
token.ThrowIfCancellationRequested();
|
token.ThrowIfCancellationRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,18 +92,6 @@ public class DalamudUtilService : IHostedService
|
|||||||
return (IntPtr)mgr->LookupBuddyByOwnerObject((BattleChara*)playerPointer);
|
return (IntPtr)mgr->LookupBuddyByOwnerObject((BattleChara*)playerPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int? GetIndexFromObjectTableByName(string characterName)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _objectTable.Length; i++)
|
|
||||||
{
|
|
||||||
if (_objectTable[i] == null) continue;
|
|
||||||
if (_objectTable[i]!.ObjectKind != Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Player) continue;
|
|
||||||
if (string.Equals(_objectTable[i]!.Name.ToString(), characterName, StringComparison.Ordinal)) return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe IntPtr GetMinion(IntPtr? playerPointer = null)
|
public unsafe IntPtr GetMinion(IntPtr? playerPointer = null)
|
||||||
{
|
{
|
||||||
playerPointer ??= PlayerPointer;
|
playerPointer ??= PlayerPointer;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Text.Json;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace MareSynchronos.Utils;
|
namespace MareSynchronos.Utils;
|
||||||
|
|
||||||
@@ -8,4 +9,14 @@ public static class VariousExtensions
|
|||||||
{
|
{
|
||||||
return JsonSerializer.Deserialize<T>(JsonSerializer.Serialize(obj))!;
|
return JsonSerializer.Deserialize<T>(JsonSerializer.Serialize(obj))!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static unsafe int? ObjectTableIndex(this GameObject? gameObject)
|
||||||
|
{
|
||||||
|
if (gameObject == null || gameObject.Address == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)gameObject.Address)->ObjectIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user