mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-02-25 06:01:48 +01:00
Optional Addition: Include IPC to get the current state of Auto-Reload Gear, and an IPC Event call for when the option changes.
- Should help clear up ambiguity with any external plugins intending to call ReapplyState on a mod-change to themselves, to know if Glamourer has it handled for them.
This commit is contained in:
parent
d6c36ca4f7
commit
48bef12555
8 changed files with 68 additions and 13 deletions
|
|
@ -3,7 +3,7 @@ using OtterGui.Services;
|
|||
|
||||
namespace Glamourer.Api;
|
||||
|
||||
public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService
|
||||
public class GlamourerApi(Configuration config, DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService
|
||||
{
|
||||
public const int CurrentApiVersionMajor = 1;
|
||||
public const int CurrentApiVersionMinor = 6;
|
||||
|
|
@ -11,6 +11,9 @@ public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) :
|
|||
public (int Major, int Minor) ApiVersion
|
||||
=> (CurrentApiVersionMajor, CurrentApiVersionMinor);
|
||||
|
||||
public bool AutoReloadGearEnabled
|
||||
=> config.AutoRedrawEquipOnChanges;
|
||||
|
||||
public IGlamourerApiDesigns Designs
|
||||
=> designs;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public sealed class IpcProviders : IDisposable, IApiService
|
|||
new FuncProvider<(int Major, int Minor)>(pi, "Glamourer.ApiVersions", () => api.ApiVersion), // backward compatibility
|
||||
new FuncProvider<int>(pi, "Glamourer.ApiVersion", () => api.ApiVersion.Major), // backward compatibility
|
||||
IpcSubscribers.ApiVersion.Provider(pi, api),
|
||||
IpcSubscribers.AutoReloadGearEnabled.Provider(pi, api),
|
||||
|
||||
IpcSubscribers.GetDesignList.Provider(pi, api.Designs),
|
||||
IpcSubscribers.GetDesignListExtended.Provider(pi, api.Designs),
|
||||
|
|
@ -59,6 +60,7 @@ public sealed class IpcProviders : IDisposable, IApiService
|
|||
IpcSubscribers.UnlockAll.Provider(pi, api.State),
|
||||
IpcSubscribers.RevertToAutomation.Provider(pi, api.State),
|
||||
IpcSubscribers.RevertToAutomationName.Provider(pi, api.State),
|
||||
IpcSubscribers.AutoReloadGearChanged.Provider(pi, api.State),
|
||||
IpcSubscribers.StateChanged.Provider(pi, api.State),
|
||||
IpcSubscribers.StateChangedWithType.Provider(pi, api.State),
|
||||
IpcSubscribers.StateFinalized.Provider(pi, api.State),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
|
|||
private readonly Configuration _config;
|
||||
private readonly AutoDesignApplier _autoDesigns;
|
||||
private readonly ActorObjectManager _objects;
|
||||
private readonly AutoRedrawChanged _autoRedraw;
|
||||
private readonly StateChanged _stateChanged;
|
||||
private readonly StateFinalized _stateFinalized;
|
||||
private readonly GPoseService _gPose;
|
||||
|
|
@ -30,6 +31,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
|
|||
Configuration config,
|
||||
AutoDesignApplier autoDesigns,
|
||||
ActorObjectManager objects,
|
||||
AutoRedrawChanged autoRedraw,
|
||||
StateChanged stateChanged,
|
||||
StateFinalized stateFinalized,
|
||||
GPoseService gPose)
|
||||
|
|
@ -40,9 +42,11 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
|
|||
_config = config;
|
||||
_autoDesigns = autoDesigns;
|
||||
_objects = objects;
|
||||
_autoRedraw = autoRedraw;
|
||||
_stateChanged = stateChanged;
|
||||
_stateFinalized = stateFinalized;
|
||||
_gPose = gPose;
|
||||
_autoRedraw.Subscribe(OnAutoRedrawChange, AutoRedrawChanged.Priority.StateApi);
|
||||
_stateChanged.Subscribe(OnStateChanged, Events.StateChanged.Priority.GlamourerIpc);
|
||||
_stateFinalized.Subscribe(OnStateFinalized, Events.StateFinalized.Priority.StateApi);
|
||||
_gPose.Subscribe(OnGPoseChange, GPoseService.Priority.StateApi);
|
||||
|
|
@ -50,6 +54,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
_autoRedraw.Unsubscribe(OnAutoRedrawChange);
|
||||
_stateChanged.Unsubscribe(OnStateChanged);
|
||||
_stateFinalized.Unsubscribe(OnStateFinalized);
|
||||
_gPose.Unsubscribe(OnGPoseChange);
|
||||
|
|
@ -293,6 +298,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
|
|||
return ApiHelpers.Return(GlamourerApiEc.Success, args);
|
||||
}
|
||||
|
||||
public event Action<bool>? AutoReloadGearChanged;
|
||||
public event Action<nint>? StateChanged;
|
||||
public event Action<IntPtr, StateChangeType>? StateChangedWithType;
|
||||
public event Action<IntPtr, StateFinalizationType>? StateFinalized;
|
||||
|
|
@ -385,8 +391,8 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
|
|||
};
|
||||
}
|
||||
|
||||
private void OnGPoseChange(bool gPose)
|
||||
=> GPoseChanged?.Invoke(gPose);
|
||||
private void OnAutoRedrawChange(bool autoReload)
|
||||
=> AutoReloadGearChanged?.Invoke(autoReload);
|
||||
|
||||
private void OnStateChanged(StateChangeType type, StateSource _2, ActorState _3, ActorData actors, ITransaction? _5)
|
||||
{
|
||||
|
|
@ -407,4 +413,7 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
|
|||
foreach (var actor in actors.Objects)
|
||||
StateFinalized.Invoke(actor.Address, type);
|
||||
}
|
||||
|
||||
private void OnGPoseChange(bool gPose)
|
||||
=> GPoseChanged?.Invoke(gPose);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue