glamourer 2099 updates
This commit is contained in:
@@ -24,10 +24,12 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
private readonly ICallGateSubscriber<string, Character?, object> _customizePlusSetBodyScaleToCharacter;
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly ICallGateSubscriber<int> _glamourerApiVersion;
|
||||
private readonly ICallGateSubscriber<(int, int)> _glamourerApiVersions;
|
||||
private readonly ICallGateSubscriber<string, GameObject?, object>? _glamourerApplyAll;
|
||||
private readonly ICallGateSubscriber<string, GameObject?, object>? _glamourerApplyOnlyCustomization;
|
||||
private readonly ICallGateSubscriber<string, GameObject?, object>? _glamourerApplyOnlyEquipment;
|
||||
private readonly ICallGateSubscriber<GameObject?, string>? _glamourerGetAllCustomization;
|
||||
private readonly ICallGateSubscriber<Character?, object?> _glamourerRevert;
|
||||
private readonly ICallGateSubscriber<(int, int)> _heelsGetApiVersion;
|
||||
private readonly ICallGateSubscriber<string> _heelsGetOffset;
|
||||
private readonly ICallGateSubscriber<string, object?> _heelsOffsetUpdate;
|
||||
@@ -67,6 +69,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
private bool _customizePlusAvailable = false;
|
||||
private CancellationTokenSource _disposalCts = new();
|
||||
private bool _glamourerAvailable = false;
|
||||
private bool _glamourerTestingAvailable = false;
|
||||
private bool _heelsAvailable = false;
|
||||
private bool _honorificAvailable = false;
|
||||
private bool _palettePlusAvailable = false;
|
||||
@@ -102,10 +105,12 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
_penumbraGameObjectResourcePathResolved = Penumbra.Api.Ipc.GameObjectResourcePathResolved.Subscriber(pi, ResourceLoaded);
|
||||
|
||||
_glamourerApiVersion = pi.GetIpcSubscriber<int>("Glamourer.ApiVersion");
|
||||
_glamourerApiVersions = pi.GetIpcSubscriber<(int, int)>("Glamourer.ApiVersions");
|
||||
_glamourerGetAllCustomization = pi.GetIpcSubscriber<GameObject?, string>("Glamourer.GetAllCustomizationFromCharacter");
|
||||
_glamourerApplyAll = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyAllToCharacter");
|
||||
_glamourerApplyOnlyCustomization = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyCustomizationToCharacter");
|
||||
_glamourerApplyOnlyEquipment = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyEquipmentToCharacter");
|
||||
_glamourerRevert = pi.GetIpcSubscriber<Character?, object?>("Glamourer.RevertCharacter");
|
||||
|
||||
_heelsGetApiVersion = pi.GetIpcSubscriber<(int, int)>("SimpleHeels.ApiVersion");
|
||||
_heelsGetOffset = pi.GetIpcSubscriber<string>("SimpleHeels.GetLocalPlayer");
|
||||
@@ -160,6 +165,8 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
|
||||
public bool CheckGlamourerApi() => _glamourerAvailable;
|
||||
|
||||
public bool CheckGlamourerTestingApi() => _glamourerTestingAvailable;
|
||||
|
||||
public bool CheckHeelsApi() => _heelsAvailable;
|
||||
|
||||
public bool CheckHonorificApi() => _honorificAvailable;
|
||||
@@ -238,6 +245,33 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
logger.LogDebug("[{appid}] Calling on IPC: GlamourerApplyAll", applicationId);
|
||||
_glamourerApplyAll!.InvokeAction(customization, chara);
|
||||
if (_glamourerTestingAvailable)
|
||||
{
|
||||
logger.LogDebug("[{appid}] Calling on IPC: PenumbraRedraw", applicationId);
|
||||
|
||||
_penumbraRedrawObject.Invoke(chara, RedrawType.Redraw);
|
||||
}
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_redrawSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GlamourerRevert(ILogger logger, GameObjectHandler handler, Guid applicationId, CancellationToken token)
|
||||
{
|
||||
if ((!CheckGlamourerApi() && !CheckGlamourerTestingApi()) || _dalamudUtil.IsZoning) return;
|
||||
try
|
||||
{
|
||||
await _redrawSemaphore.WaitAsync(token).ConfigureAwait(false);
|
||||
await PenumbraRedrawInternalAsync(logger, handler, applicationId, (chara) =>
|
||||
{
|
||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevert", applicationId);
|
||||
_glamourerRevert.InvokeAction(chara);
|
||||
logger.LogDebug("[{appid}] Calling On IPC: PenumbraRedraw", applicationId);
|
||||
_penumbraRedrawObject.Invoke(chara, RedrawType.Redraw);
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
@@ -568,6 +602,33 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckGlamourerTestingApiInternal()
|
||||
{
|
||||
bool apiAvailable = false;
|
||||
try
|
||||
{
|
||||
var version = _glamourerApiVersions.InvokeFunc();
|
||||
if (version.Item1 == 0 && version.Item2 >= 1)
|
||||
{
|
||||
apiAvailable = true;
|
||||
}
|
||||
_shownGlamourerUnavailable = _shownGlamourerUnavailable && !apiAvailable;
|
||||
return apiAvailable;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return apiAvailable;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!apiAvailable && !_shownGlamourerUnavailable)
|
||||
{
|
||||
_shownGlamourerUnavailable = true;
|
||||
Mediator.Publish(new NotificationMessage("Glamourer inactive", "Your Glamourer installation is not active or out of date. Update Glamourer to continue to use Mare.", NotificationType.Error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckHeelsApiInternal()
|
||||
{
|
||||
try
|
||||
@@ -707,6 +768,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
private void PeriodicApiStateCheck()
|
||||
{
|
||||
_glamourerAvailable = CheckGlamourerApiInternal();
|
||||
_glamourerTestingAvailable = CheckGlamourerTestingApiInternal();
|
||||
_penumbraAvailable = CheckPenumbraApiInternal();
|
||||
_heelsAvailable = CheckHeelsApiInternal();
|
||||
_customizePlusAvailable = CheckCustomizePlusApiInternal();
|
||||
|
||||
Reference in New Issue
Block a user