implement new penumbra and glamourer api probably
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Dalamud.Game.ClientState.Objects.Types;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
using Dalamud.Interface.Internal.Notifications;
|
using Dalamud.Interface.Internal.Notifications;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
|
using Dalamud.Plugin.Ipc;
|
||||||
using Glamourer.Api.Helpers;
|
using Glamourer.Api.Helpers;
|
||||||
using Glamourer.Api.IpcSubscribers;
|
using Glamourer.Api.IpcSubscribers;
|
||||||
using MareSynchronos.PlayerData.Handlers;
|
using MareSynchronos.PlayerData.Handlers;
|
||||||
@@ -12,6 +13,12 @@ namespace MareSynchronos.Interop.Ipc;
|
|||||||
|
|
||||||
public sealed class IpcCallerGlamourer : IIpcCaller
|
public sealed class IpcCallerGlamourer : IIpcCaller
|
||||||
{
|
{
|
||||||
|
private readonly ILogger<IpcCallerGlamourer> _logger;
|
||||||
|
private readonly DalamudPluginInterface _pi;
|
||||||
|
private readonly DalamudUtilService _dalamudUtil;
|
||||||
|
private readonly MareMediator _mareMediator;
|
||||||
|
private readonly RedrawManager _redrawManager;
|
||||||
|
|
||||||
private readonly ApiVersion _glamourerApiVersions;
|
private readonly ApiVersion _glamourerApiVersions;
|
||||||
private readonly ApplyState? _glamourerApplyAll;
|
private readonly ApplyState? _glamourerApplyAll;
|
||||||
private readonly GetStateBase64? _glamourerGetAllCustomization;
|
private readonly GetStateBase64? _glamourerGetAllCustomization;
|
||||||
@@ -19,13 +26,18 @@ public sealed class IpcCallerGlamourer : IIpcCaller
|
|||||||
private readonly RevertStateName _glamourerRevertByName;
|
private readonly RevertStateName _glamourerRevertByName;
|
||||||
private readonly UnlockState _glamourerUnlock;
|
private readonly UnlockState _glamourerUnlock;
|
||||||
private readonly UnlockStateName _glamourerUnlockByName;
|
private readonly UnlockStateName _glamourerUnlockByName;
|
||||||
private readonly EventSubscriber<nint> _glamourerStateChanged;
|
private readonly EventSubscriber<nint>? _glamourerStateChanged;
|
||||||
private readonly ILogger<IpcCallerGlamourer> _logger;
|
|
||||||
private readonly DalamudPluginInterface _pi;
|
private readonly Glamourer.Api.IpcSubscribers.Legacy.ApiVersions _glamourerApiVersionLegacy;
|
||||||
private readonly DalamudUtilService _dalamudUtil;
|
private readonly ICallGateSubscriber<string, GameObject?, uint, object>? _glamourerApplyAllLegacy;
|
||||||
private readonly MareMediator _mareMediator;
|
private readonly ICallGateSubscriber<GameObject?, string>? _glamourerGetAllCustomizationLegacy;
|
||||||
private readonly RedrawManager _redrawManager;
|
private readonly ICallGateSubscriber<Character?, uint, object?> _glamourerRevertLegacy;
|
||||||
|
private readonly Glamourer.Api.IpcSubscribers.Legacy.RevertLock _glamourerRevertByNameLegacy;
|
||||||
|
private readonly Glamourer.Api.IpcSubscribers.Legacy.UnlockName _glamourerUnlockLegacy;
|
||||||
|
private readonly EventSubscriber<int, nint, Lazy<string>>? _glamourerStateChangedLegacy;
|
||||||
|
|
||||||
private bool _shownGlamourerUnavailable = false;
|
private bool _shownGlamourerUnavailable = false;
|
||||||
|
private bool _useLegacyGlamourer = false;
|
||||||
private readonly uint LockCode = 0x6D617265;
|
private readonly uint LockCode = 0x6D617265;
|
||||||
|
|
||||||
public IpcCallerGlamourer(ILogger<IpcCallerGlamourer> logger, DalamudPluginInterface pi, DalamudUtilService dalamudUtil, MareMediator mareMediator,
|
public IpcCallerGlamourer(ILogger<IpcCallerGlamourer> logger, DalamudPluginInterface pi, DalamudUtilService dalamudUtil, MareMediator mareMediator,
|
||||||
@@ -39,14 +51,30 @@ public sealed class IpcCallerGlamourer : IIpcCaller
|
|||||||
_glamourerUnlock = new UnlockState(pi);
|
_glamourerUnlock = new UnlockState(pi);
|
||||||
_glamourerUnlockByName = new UnlockStateName(pi);
|
_glamourerUnlockByName = new UnlockStateName(pi);
|
||||||
|
|
||||||
_glamourerStateChanged = StateChanged.Subscriber(pi, GlamourerChanged);
|
_glamourerApiVersionLegacy = new(pi);
|
||||||
_glamourerStateChanged.Enable();
|
_glamourerApplyAllLegacy = pi.GetIpcSubscriber<string, GameObject?, uint, object>("Glamourer.ApplyAllToCharacterLock");
|
||||||
|
_glamourerGetAllCustomizationLegacy = pi.GetIpcSubscriber<GameObject?, string>("Glamourer.GetAllCustomizationFromCharacter");
|
||||||
|
_glamourerRevertLegacy = pi.GetIpcSubscriber<Character?, uint, object?>("Glamourer.RevertCharacterLock");
|
||||||
|
_glamourerRevertByNameLegacy = new(pi);
|
||||||
|
_glamourerUnlockLegacy = new(pi);
|
||||||
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_pi = pi;
|
_pi = pi;
|
||||||
_dalamudUtil = dalamudUtil;
|
_dalamudUtil = dalamudUtil;
|
||||||
_mareMediator = mareMediator;
|
_mareMediator = mareMediator;
|
||||||
_redrawManager = redrawManager;
|
_redrawManager = redrawManager;
|
||||||
CheckAPI();
|
CheckAPI();
|
||||||
|
|
||||||
|
if (_useLegacyGlamourer)
|
||||||
|
{
|
||||||
|
_glamourerStateChangedLegacy = Glamourer.Api.IpcSubscribers.Legacy.StateChanged.Subscriber(pi, (t, a, c) => GlamourerChanged(a));
|
||||||
|
_glamourerStateChangedLegacy.Enable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_glamourerStateChanged = StateChanged.Subscriber(pi, GlamourerChanged);
|
||||||
|
_glamourerStateChanged.Enable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool APIAvailable { get; private set; }
|
public bool APIAvailable { get; private set; }
|
||||||
@@ -56,13 +84,25 @@ public sealed class IpcCallerGlamourer : IIpcCaller
|
|||||||
bool apiAvailable = false;
|
bool apiAvailable = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var version = _glamourerApiVersions.Invoke();
|
|
||||||
bool versionValid = (_pi.InstalledPlugins
|
bool versionValid = (_pi.InstalledPlugins
|
||||||
.FirstOrDefault(p => string.Equals(p.InternalName, "Glamourer", StringComparison.OrdinalIgnoreCase))
|
.FirstOrDefault(p => string.Equals(p.InternalName, "Glamourer", StringComparison.OrdinalIgnoreCase))
|
||||||
?.Version ?? new Version(0, 0, 0, 0)) >= new Version(1, 2, 1, 4);
|
?.Version ?? new Version(0, 0, 0, 0)) >= new Version(1, 0, 6, 1);
|
||||||
if (version is { Major: 1, Minor: >= 1 } && versionValid)
|
try
|
||||||
{
|
{
|
||||||
apiAvailable = true;
|
var version = _glamourerApiVersions.Invoke();
|
||||||
|
if (version is { Major: 1, Minor: >= 1 } && versionValid)
|
||||||
|
{
|
||||||
|
apiAvailable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
var version = _glamourerApiVersionLegacy.Invoke();
|
||||||
|
if (version is { Major: 0, Minor: >= 1 } && versionValid)
|
||||||
|
{
|
||||||
|
apiAvailable = true;
|
||||||
|
_useLegacyGlamourer = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_shownGlamourerUnavailable = _shownGlamourerUnavailable && !apiAvailable;
|
_shownGlamourerUnavailable = _shownGlamourerUnavailable && !apiAvailable;
|
||||||
|
|
||||||
@@ -85,7 +125,8 @@ public sealed class IpcCallerGlamourer : IIpcCaller
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_glamourerStateChanged.Dispose();
|
_glamourerStateChanged?.Dispose();
|
||||||
|
_glamourerStateChangedLegacy?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ApplyAllAsync(ILogger logger, GameObjectHandler handler, string? customization, Guid applicationId, CancellationToken token, bool fireAndForget = false)
|
public async Task ApplyAllAsync(ILogger logger, GameObjectHandler handler, string? customization, Guid applicationId, CancellationToken token, bool fireAndForget = false)
|
||||||
@@ -102,11 +143,18 @@ public sealed class IpcCallerGlamourer : IIpcCaller
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogDebug("[{appid}] Calling on IPC: GlamourerApplyAll", applicationId);
|
logger.LogDebug("[{appid}] Calling on IPC: GlamourerApplyAll", applicationId);
|
||||||
_glamourerApplyAll!.Invoke(customization, chara.ObjectIndex, LockCode);
|
if (_useLegacyGlamourer)
|
||||||
|
{
|
||||||
|
_glamourerApplyAllLegacy.InvokeAction(customization, chara, LockCode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_glamourerApplyAll!.Invoke(customization, chara.ObjectIndex, LockCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.LogWarning("[{appid}] Failed to apply Glamourer data", applicationId);
|
logger.LogWarning(ex, "[{appid}] Failed to apply Glamourer data", applicationId);
|
||||||
}
|
}
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -126,7 +174,10 @@ public sealed class IpcCallerGlamourer : IIpcCaller
|
|||||||
var gameObj = _dalamudUtil.CreateGameObject(character);
|
var gameObj = _dalamudUtil.CreateGameObject(character);
|
||||||
if (gameObj is Character c)
|
if (gameObj is Character c)
|
||||||
{
|
{
|
||||||
return _glamourerGetAllCustomization!.Invoke(c.ObjectIndex).Item2 ?? string.Empty;
|
if (_useLegacyGlamourer)
|
||||||
|
return _glamourerGetAllCustomizationLegacy.InvokeFunc(c) ?? string.Empty;
|
||||||
|
else
|
||||||
|
return _glamourerGetAllCustomization!.Invoke(c.ObjectIndex).Item2 ?? string.Empty;
|
||||||
}
|
}
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
@@ -147,11 +198,23 @@ public sealed class IpcCallerGlamourer : IIpcCaller
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
if (_useLegacyGlamourer)
|
||||||
_glamourerUnlock.Invoke(chara.ObjectIndex, LockCode);
|
{
|
||||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevert", applicationId);
|
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
||||||
_glamourerRevert.Invoke(chara.ObjectIndex, LockCode);
|
_glamourerUnlockLegacy.Invoke(name, LockCode);
|
||||||
logger.LogDebug("[{appid}] Calling On IPC: PenumbraRedraw", applicationId);
|
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevert", applicationId);
|
||||||
|
_glamourerRevertLegacy.InvokeAction(chara, LockCode);
|
||||||
|
logger.LogDebug("[{appid}] Calling On IPC: PenumbraRedraw", applicationId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
||||||
|
_glamourerUnlock.Invoke(chara.ObjectIndex, LockCode);
|
||||||
|
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevert", applicationId);
|
||||||
|
_glamourerRevert.Invoke(chara.ObjectIndex, LockCode);
|
||||||
|
logger.LogDebug("[{appid}] Calling On IPC: PenumbraRedraw", applicationId);
|
||||||
|
}
|
||||||
|
|
||||||
_mareMediator.Publish(new PenumbraRedrawCharacterMessage(chara));
|
_mareMediator.Publish(new PenumbraRedrawCharacterMessage(chara));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -172,29 +235,31 @@ public sealed class IpcCallerGlamourer : IIpcCaller
|
|||||||
|
|
||||||
await _dalamudUtil.RunOnFrameworkThread(() =>
|
await _dalamudUtil.RunOnFrameworkThread(() =>
|
||||||
{
|
{
|
||||||
try
|
RevertByName(logger, name, applicationId);
|
||||||
{
|
|
||||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevertByName", applicationId);
|
|
||||||
_glamourerRevertByName.Invoke(name, LockCode);
|
|
||||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
|
||||||
_glamourerUnlockByName.Invoke(name, LockCode);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogWarning(ex, "Error during Glamourer RevertByName");
|
|
||||||
}
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RevertByName(ILogger logger, string name, Guid applicationId)
|
public void RevertByName(ILogger logger, string name, Guid applicationId)
|
||||||
{
|
{
|
||||||
if ((!APIAvailable) || _dalamudUtil.IsZoning) return;
|
if ((!APIAvailable) || _dalamudUtil.IsZoning) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevertByName", applicationId);
|
if (_useLegacyGlamourer)
|
||||||
_glamourerRevertByName.Invoke(name, LockCode);
|
{
|
||||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevertByName", applicationId);
|
||||||
_glamourerUnlockByName.Invoke(name, LockCode);
|
_glamourerRevertByNameLegacy.Invoke(name, LockCode);
|
||||||
|
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
||||||
|
_glamourerUnlockLegacy.Invoke(name, LockCode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevertByName", applicationId);
|
||||||
|
_glamourerRevertByName.Invoke(name, LockCode);
|
||||||
|
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
||||||
|
_glamourerUnlockByName.Invoke(name, LockCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
private readonly MareMediator _mareMediator;
|
private readonly MareMediator _mareMediator;
|
||||||
private readonly RedrawManager _redrawManager;
|
private readonly RedrawManager _redrawManager;
|
||||||
private bool _shownPenumbraUnavailable = false;
|
private bool _shownPenumbraUnavailable = false;
|
||||||
|
private bool _useLegacyPenumbraApi = false;
|
||||||
private string? _penumbraModDirectory;
|
private string? _penumbraModDirectory;
|
||||||
public string? ModDirectory
|
public string? ModDirectory
|
||||||
{
|
{
|
||||||
@@ -52,6 +53,15 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
private readonly GetModDirectory _penumbraResolveModDir;
|
private readonly GetModDirectory _penumbraResolveModDir;
|
||||||
private readonly ResolvePlayerPathsAsync _penumbraResolvePaths;
|
private readonly ResolvePlayerPathsAsync _penumbraResolvePaths;
|
||||||
private readonly GetGameObjectResourcePaths _penumbraResourcePaths;
|
private readonly GetGameObjectResourcePaths _penumbraResourcePaths;
|
||||||
|
private readonly ApiVersion _penumbraApiVersion;
|
||||||
|
|
||||||
|
private readonly Penumbra.Api.IpcSubscribers.Legacy.AddTemporaryMod _penumbraAddTemporaryModLegacy;
|
||||||
|
private readonly Penumbra.Api.IpcSubscribers.Legacy.RemoveTemporaryMod _penumbraRemoveTemporaryModLegacy;
|
||||||
|
private readonly Penumbra.Api.IpcSubscribers.Legacy.CreateNamedTemporaryCollection _penumbraCreateNamedTemporaryCollectionLegacy;
|
||||||
|
private readonly Penumbra.Api.IpcSubscribers.Legacy.AssignTemporaryCollection _penumbraAssignTemporaryCollectionLegacy;
|
||||||
|
private readonly Penumbra.Api.IpcSubscribers.Legacy.RemoveTemporaryCollectionByName _penumbraRemoveTemporaryCollectionLegacy;
|
||||||
|
private readonly Penumbra.Api.IpcSubscribers.Legacy.RedrawObjectByIndex _penumbraRedrawLegacy;
|
||||||
|
private readonly Penumbra.Api.IpcSubscribers.Legacy.GetGameObjectResourcePaths _penumbraResourcePathsLegacy;
|
||||||
|
|
||||||
public IpcCallerPenumbra(ILogger<IpcCallerPenumbra> logger, DalamudPluginInterface pi, DalamudUtilService dalamudUtil,
|
public IpcCallerPenumbra(ILogger<IpcCallerPenumbra> logger, DalamudPluginInterface pi, DalamudUtilService dalamudUtil,
|
||||||
MareMediator mareMediator, RedrawManager redrawManager) : base(logger, mareMediator)
|
MareMediator mareMediator, RedrawManager redrawManager) : base(logger, mareMediator)
|
||||||
@@ -80,13 +90,28 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
});
|
});
|
||||||
_penumbraConvertTextureFile = new ConvertTextureFile(pi);
|
_penumbraConvertTextureFile = new ConvertTextureFile(pi);
|
||||||
_penumbraResourcePaths = new GetGameObjectResourcePaths(pi);
|
_penumbraResourcePaths = new GetGameObjectResourcePaths(pi);
|
||||||
|
_penumbraApiVersion = new(pi);
|
||||||
|
|
||||||
|
_penumbraAddTemporaryModLegacy = new(pi);
|
||||||
|
_penumbraAssignTemporaryCollectionLegacy = new(pi);
|
||||||
|
_penumbraCreateNamedTemporaryCollectionLegacy = new(pi);
|
||||||
|
_penumbraRemoveTemporaryCollectionLegacy = new(pi);
|
||||||
|
_penumbraRedrawLegacy = new(pi);
|
||||||
|
_penumbraRemoveTemporaryModLegacy = new(pi);
|
||||||
|
_penumbraResourcePathsLegacy = new(pi);
|
||||||
|
|
||||||
_penumbraGameObjectResourcePathResolved = GameObjectResourcePathResolved.Subscriber(pi, ResourceLoaded);
|
_penumbraGameObjectResourcePathResolved = GameObjectResourcePathResolved.Subscriber(pi, ResourceLoaded);
|
||||||
|
|
||||||
CheckAPI();
|
CheckAPI();
|
||||||
CheckModDirectory();
|
CheckModDirectory();
|
||||||
|
|
||||||
Mediator.Subscribe<PenumbraRedrawCharacterMessage>(this, (msg) => _penumbraRedraw.Invoke(msg.Character.ObjectIndex, RedrawType.AfterGPose));
|
Mediator.Subscribe<PenumbraRedrawCharacterMessage>(this, (msg) =>
|
||||||
|
{
|
||||||
|
if (_useLegacyPenumbraApi)
|
||||||
|
_penumbraRedrawLegacy.Invoke(msg.Character.ObjectIndex, RedrawType.AfterGPose);
|
||||||
|
else
|
||||||
|
_penumbraRedraw.Invoke(msg.Character.ObjectIndex, RedrawType.AfterGPose);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool APIAvailable { get; private set; } = false;
|
public bool APIAvailable { get; private set; } = false;
|
||||||
@@ -96,9 +121,18 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
bool penumbraAvailable = false;
|
bool penumbraAvailable = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
penumbraAvailable = (_pi.InstalledPlugins
|
var penumbraVersion = (_pi.InstalledPlugins
|
||||||
.FirstOrDefault(p => string.Equals(p.InternalName, "Penumbra", StringComparison.OrdinalIgnoreCase))
|
.FirstOrDefault(p => string.Equals(p.InternalName, "Penumbra", StringComparison.OrdinalIgnoreCase))
|
||||||
?.Version ?? new Version(0, 0, 0, 0)) >= new Version(1, 0, 2, 7);
|
?.Version ?? new Version(0, 0, 0, 0));
|
||||||
|
penumbraAvailable = penumbraVersion >= new Version(1, 0, 1, 0);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_ = _penumbraApiVersion.Invoke();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_useLegacyPenumbraApi = true;
|
||||||
|
}
|
||||||
penumbraAvailable &= _penumbraEnabled.Invoke();
|
penumbraAvailable &= _penumbraEnabled.Invoke();
|
||||||
_shownPenumbraUnavailable = _shownPenumbraUnavailable && !penumbraAvailable;
|
_shownPenumbraUnavailable = _shownPenumbraUnavailable && !penumbraAvailable;
|
||||||
APIAvailable = penumbraAvailable;
|
APIAvailable = penumbraAvailable;
|
||||||
@@ -150,7 +184,9 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
|
|
||||||
await _dalamudUtil.RunOnFrameworkThread(() =>
|
await _dalamudUtil.RunOnFrameworkThread(() =>
|
||||||
{
|
{
|
||||||
var retAssign = _penumbraAssignTemporaryCollection.Invoke(collName, idx, forceAssignment: true);
|
var retAssign = _useLegacyPenumbraApi
|
||||||
|
? _penumbraAssignTemporaryCollectionLegacy.Invoke(collName.ToString(), idx, true)
|
||||||
|
: _penumbraAssignTemporaryCollection.Invoke(collName, idx, forceAssignment: true);
|
||||||
logger.LogTrace("Assigning Temp Collection {collName} to index {idx}, Success: {ret}", collName, idx, retAssign);
|
logger.LogTrace("Assigning Temp Collection {collName} to index {idx}, Success: {ret}", collName, idx, retAssign);
|
||||||
return collName;
|
return collName;
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
@@ -192,7 +228,10 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
await _dalamudUtil.RunOnFrameworkThread(async () =>
|
await _dalamudUtil.RunOnFrameworkThread(async () =>
|
||||||
{
|
{
|
||||||
var gameObject = await _dalamudUtil.CreateGameObjectAsync(await _dalamudUtil.GetPlayerPointerAsync().ConfigureAwait(false)).ConfigureAwait(false);
|
var gameObject = await _dalamudUtil.CreateGameObjectAsync(await _dalamudUtil.GetPlayerPointerAsync().ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
_penumbraRedraw.Invoke(gameObject!.ObjectIndex, setting: RedrawType.Redraw);
|
if (_useLegacyPenumbraApi)
|
||||||
|
_penumbraRedrawLegacy.Invoke(gameObject!.ObjectIndex, RedrawType.Redraw);
|
||||||
|
else
|
||||||
|
_penumbraRedraw.Invoke(gameObject!.ObjectIndex, setting: RedrawType.Redraw);
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,14 +241,25 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
|
|
||||||
return await _dalamudUtil.RunOnFrameworkThread(() =>
|
return await _dalamudUtil.RunOnFrameworkThread(() =>
|
||||||
{
|
{
|
||||||
var collName = "Mare_" + uid;
|
if (!_useLegacyPenumbraApi)
|
||||||
var collId = _penumbraCreateNamedTemporaryCollection.Invoke(collName);
|
{
|
||||||
logger.LogTrace("Creating Temp Collection {collName}, GUID: {collId}", collName, collId);
|
var collName = "Mare_" + uid;
|
||||||
return collId;
|
var collId = _penumbraCreateNamedTemporaryCollection.Invoke(collName);
|
||||||
|
logger.LogTrace("Creating Temp Collection {collName}, GUID: {collId}", collName, collId);
|
||||||
|
return collId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var collid = Guid.NewGuid();
|
||||||
|
_penumbraCreateNamedTemporaryCollectionLegacy.Invoke(collid.ToString());
|
||||||
|
logger.LogTrace("Creating Temp Collection {collName}", collid);
|
||||||
|
return collid;
|
||||||
|
}
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Dictionary<string, HashSet<string>>?[]?> GetCharacterData(ILogger logger, GameObjectHandler handler)
|
public async Task<Dictionary<string, HashSet<string>>?> GetCharacterData(ILogger logger, GameObjectHandler handler)
|
||||||
{
|
{
|
||||||
if (!APIAvailable) return null;
|
if (!APIAvailable) return null;
|
||||||
|
|
||||||
@@ -218,7 +268,16 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
logger.LogTrace("Calling On IPC: Penumbra.GetGameObjectResourcePaths");
|
logger.LogTrace("Calling On IPC: Penumbra.GetGameObjectResourcePaths");
|
||||||
var idx = handler.GetGameObject()?.ObjectIndex;
|
var idx = handler.GetGameObject()?.ObjectIndex;
|
||||||
if (idx == null) return null;
|
if (idx == null) return null;
|
||||||
return _penumbraResourcePaths.Invoke(idx.Value);
|
if (_useLegacyPenumbraApi)
|
||||||
|
{
|
||||||
|
IReadOnlyDictionary<string, string[]>?[] ret = _penumbraResourcePathsLegacy.Invoke(idx.Value);
|
||||||
|
if (!ret.Any()) return null;
|
||||||
|
return ret[0]!.ToDictionary(r => r.Key, r => new HashSet<string>(r.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _penumbraResourcePaths.Invoke(idx.Value)[0];
|
||||||
|
}
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +296,11 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
await _redrawManager.PenumbraRedrawInternalAsync(logger, handler, applicationId, (chara) =>
|
await _redrawManager.PenumbraRedrawInternalAsync(logger, handler, applicationId, (chara) =>
|
||||||
{
|
{
|
||||||
logger.LogDebug("[{appid}] Calling on IPC: PenumbraRedraw", applicationId);
|
logger.LogDebug("[{appid}] Calling on IPC: PenumbraRedraw", applicationId);
|
||||||
_penumbraRedraw!.Invoke(chara.ObjectIndex, setting: RedrawType.Redraw);
|
if (_useLegacyPenumbraApi)
|
||||||
|
_penumbraRedrawLegacy.Invoke(chara.ObjectIndex, RedrawType.Redraw);
|
||||||
|
else
|
||||||
|
_penumbraRedraw!.Invoke(chara.ObjectIndex, setting: RedrawType.Redraw);
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -252,7 +315,9 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
await _dalamudUtil.RunOnFrameworkThread(() =>
|
await _dalamudUtil.RunOnFrameworkThread(() =>
|
||||||
{
|
{
|
||||||
logger.LogTrace("[{applicationId}] Removing temp collection for {collId}", applicationId, collId);
|
logger.LogTrace("[{applicationId}] Removing temp collection for {collId}", applicationId, collId);
|
||||||
var ret2 = _penumbraRemoveTemporaryCollection.Invoke(collId);
|
var ret2 = _useLegacyPenumbraApi
|
||||||
|
? _penumbraRemoveTemporaryCollectionLegacy.Invoke(collId.ToString())
|
||||||
|
: _penumbraRemoveTemporaryCollection.Invoke(collId);
|
||||||
logger.LogTrace("[{applicationId}] RemoveTemporaryCollection: {ret2}", applicationId, ret2);
|
logger.LogTrace("[{applicationId}] RemoveTemporaryCollection: {ret2}", applicationId, ret2);
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -269,7 +334,9 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
await _dalamudUtil.RunOnFrameworkThread(() =>
|
await _dalamudUtil.RunOnFrameworkThread(() =>
|
||||||
{
|
{
|
||||||
logger.LogTrace("[{applicationId}] Manip: {data}", applicationId, manipulationData);
|
logger.LogTrace("[{applicationId}] Manip: {data}", applicationId, manipulationData);
|
||||||
var retAdd = _penumbraAddTemporaryMod.Invoke("MareChara_Meta", collId, [], manipulationData, 0);
|
var retAdd = _useLegacyPenumbraApi
|
||||||
|
? _penumbraAddTemporaryModLegacy.Invoke("MareChara_Meta", collId.ToString(), [], manipulationData, 0)
|
||||||
|
: _penumbraAddTemporaryMod.Invoke("MareChara_Meta", collId, [], manipulationData, 0);
|
||||||
logger.LogTrace("[{applicationId}] Setting temp meta mod for {collId}, Success: {ret}", applicationId, collId, retAdd);
|
logger.LogTrace("[{applicationId}] Setting temp meta mod for {collId}, Success: {ret}", applicationId, collId, retAdd);
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -284,9 +351,13 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
{
|
{
|
||||||
logger.LogTrace("[{applicationId}] Change: {from} => {to}", applicationId, mod.Key, mod.Value);
|
logger.LogTrace("[{applicationId}] Change: {from} => {to}", applicationId, mod.Key, mod.Value);
|
||||||
}
|
}
|
||||||
var retRemove = _penumbraRemoveTemporaryMod.Invoke("MareChara_Files", collId, 0);
|
var retRemove = _useLegacyPenumbraApi
|
||||||
|
? _penumbraRemoveTemporaryModLegacy.Invoke("MareChara_Files", collId.ToString(), 0)
|
||||||
|
: _penumbraRemoveTemporaryMod.Invoke("MareChara_Files", collId, 0);
|
||||||
logger.LogTrace("[{applicationId}] Removing temp files mod for {collId}, Success: {ret}", applicationId, collId, retRemove);
|
logger.LogTrace("[{applicationId}] Removing temp files mod for {collId}, Success: {ret}", applicationId, collId, retRemove);
|
||||||
var retAdd = _penumbraAddTemporaryMod.Invoke("MareChara_Files", collId, modPaths, string.Empty, 0);
|
var retAdd = _useLegacyPenumbraApi
|
||||||
|
? _penumbraAddTemporaryModLegacy.Invoke("MareChara_Files", collId.ToString(), modPaths, string.Empty, 0)
|
||||||
|
: _penumbraAddTemporaryMod.Invoke("MareChara_Files", collId, modPaths, string.Empty, 0);
|
||||||
logger.LogTrace("[{applicationId}] Setting temp files mod for {collId}, Success: {ret}", applicationId, collId, retAdd);
|
logger.LogTrace("[{applicationId}] Setting temp files mod for {collId}, Success: {ret}", applicationId, collId, retAdd);
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -323,6 +394,10 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
|||||||
APIAvailable = true;
|
APIAvailable = true;
|
||||||
ModDirectory = _penumbraResolveModDir.Invoke();
|
ModDirectory = _penumbraResolveModDir.Invoke();
|
||||||
_mareMediator.Publish(new PenumbraInitializedMessage());
|
_mareMediator.Publish(new PenumbraInitializedMessage());
|
||||||
_penumbraRedraw!.Invoke(0, setting: RedrawType.Redraw);
|
if (_useLegacyPenumbraApi)
|
||||||
|
_penumbraRedrawLegacy.Invoke(0, RedrawType.Redraw);
|
||||||
|
else
|
||||||
|
_penumbraRedraw!.Invoke(0, setting: RedrawType.Redraw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.5" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.5" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.5" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.5" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="Glamourer.Api" Version="1.0.0" />
|
<PackageReference Include="Glamourer.Api" Version="2.0.0" />
|
||||||
<PackageReference Include="Penumbra.Api" Version="5.0.0" />
|
<PackageReference Include="Penumbra.Api" Version="5.0.0" />
|
||||||
<PackageReference Include="Penumbra.String" Version="1.0.4" />
|
<PackageReference Include="Penumbra.String" Version="1.0.4" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public class PlayerDataFactory
|
|||||||
// penumbra call, it's currently broken
|
// penumbra call, it's currently broken
|
||||||
Dictionary<string, HashSet<string>>? resolvedPaths;
|
Dictionary<string, HashSet<string>>? resolvedPaths;
|
||||||
|
|
||||||
resolvedPaths = (await _ipcManager.Penumbra.GetCharacterData(_logger, playerRelatedObject).ConfigureAwait(false))?[0];
|
resolvedPaths = (await _ipcManager.Penumbra.GetCharacterData(_logger, playerRelatedObject).ConfigureAwait(false));
|
||||||
if (resolvedPaths == null) throw new InvalidOperationException("Penumbra returned null data");
|
if (resolvedPaths == null) throw new InvalidOperationException("Penumbra returned null data");
|
||||||
|
|
||||||
previousData.FileReplacements[objectKind] =
|
previousData.FileReplacements[objectKind] =
|
||||||
|
|||||||
Reference in New Issue
Block a user