using Dalamud.Plugin; using Penumbra.Api.Api; using Penumbra.Api.Enums; using Penumbra.Api.Helpers; namespace Penumbra.Api.IpcSubscribers; using CurrentSettingsBase = ValueTuple>, bool)?>; using CurrentSettings = ValueTuple>, bool)?>; using CurrentSettingsTempBase = ValueTuple>, bool, bool)?>; using CurrentSettingsTemp = ValueTuple>, bool, bool)?>; /// public sealed class GetAvailableModSettings(IDalamudPluginInterface pi) : FuncSubscriber?>(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(GetAvailableModSettings)}.V5"; /// public new IReadOnlyDictionary? Invoke(string modDirectory, string modName = "") => AvailableModSettings.Create(base.Invoke(modDirectory, modName)); /// Create a provider. public static FuncProvider?> Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b) => api.GetAvailableModSettings(a, b)?.Original); } /// public sealed class GetCurrentModSettings(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(GetCurrentModSettings)}.V5"; /// public new CurrentSettings Invoke(Guid collectionId, string modDirectory, string modName = "", bool ignoreInheritance = false) { var (ret, t) = base.Invoke(collectionId, modDirectory, modName, ignoreInheritance); return ((PenumbraApiEc)ret, t); } /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b, c, d) => { var (ret, t) = api.GetCurrentModSettings(a, b, c, d); return ((int)ret, t); }); } /// public sealed class GetCurrentModSettingsWithTemp(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(GetCurrentModSettingsWithTemp)}"; /// public new CurrentSettingsTemp Invoke(Guid collectionId, string modDirectory, string modName = "", bool ignoreInheritance = false, bool ignoreTemporary = false, int key = 0) { var (ret, t) = base.Invoke(collectionId, modDirectory, modName, ignoreInheritance, ignoreTemporary, key); return ((PenumbraApiEc)ret, t); } /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b, c, d, e, f) => { var (ret, t) = api.GetCurrentModSettingsWithTemp(a, b, c, d, e, f); return ((int)ret, t); }); } /// public sealed class GetAllModSettings(IDalamudPluginInterface pi) : FuncSubscriber>, bool, bool)>?)>(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(GetAllModSettings)}"; /// public new (PenumbraApiEc, Dictionary>, bool, bool)>?) Invoke(Guid collectionId, bool ignoreInheritance = false, bool ignoreTemporary = false, int key = 0) { var (ret, t) = base.Invoke(collectionId, ignoreInheritance, ignoreTemporary, key); return ((PenumbraApiEc)ret, t); } /// Create a provider. public static FuncProvider>, bool, bool)>?)> Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b, c, d) => { var (ret, t) = api.GetAllModSettings(a, b, c, d); return ((int)ret, t); }); } /// public sealed class TryInheritMod(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(TryInheritMod)}.V5"; /// public PenumbraApiEc Invoke(Guid collectionId, string modDirectory, bool inherit, string modName = "") => (PenumbraApiEc)Invoke(collectionId, modDirectory, modName, inherit); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b, c, d) => (int)api.TryInheritMod(a, b, c, d)); } /// public sealed class TrySetMod(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(TrySetMod)}.V5"; /// public PenumbraApiEc Invoke(Guid collectionId, string modDirectory, bool inherit, string modName = "") => (PenumbraApiEc)Invoke(collectionId, modDirectory, modName, inherit); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b, c, d) => (int)api.TrySetMod(a, b, c, d)); } /// public sealed class TrySetModPriority(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(TrySetModPriority)}.V5"; /// public PenumbraApiEc Invoke(Guid collectionId, string modDirectory, int priority, string modName = "") => (PenumbraApiEc)Invoke(collectionId, modDirectory, modName, priority); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b, c, d) => (int)api.TrySetModPriority(a, b, c, d)); } /// public sealed class TrySetModSetting(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(TrySetModSetting)}.V5"; /// public new PenumbraApiEc Invoke(Guid collectionId, string modDirectory, string optionGroupName, string optionName, string modName = "") => (PenumbraApiEc)base.Invoke(collectionId, modDirectory, modName, optionGroupName, optionName); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b, c, d, e) => (int)api.TrySetModSetting(a, b, c, d, e)); } /// public sealed class TrySetModSettings(IDalamudPluginInterface pi) : FuncSubscriber, int>(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(TrySetModSettings)}.V5"; /// public PenumbraApiEc Invoke(Guid collectionId, string modDirectory, string optionGroupName, IReadOnlyList optionNames, string modName = "") => (PenumbraApiEc)Invoke(collectionId, modDirectory, modName, optionGroupName, optionNames); /// Create a provider. public static FuncProvider, int> Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b, c, d, e) => (int)api.TrySetModSettings(a, b, c, d, e)); } /// public static class ModSettingChanged { /// The label. public const string Label = $"Penumbra.{nameof(ModSettingChanged)}.V5"; /// Create a new event subscriber. public static EventSubscriber Subscriber(IDalamudPluginInterface pi, params Action[] actions) => new(pi, Label, actions); /// Create a provider. public static EventProvider Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, t => api.ModSettingChanged += t.Invoke, t => api.ModSettingChanged -= t.Invoke); } /// public sealed class CopyModSettings(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Penumbra.{nameof(CopyModSettings)}.V5"; /// public new PenumbraApiEc Invoke(Guid? collectionId, string modDirectoryFrom, string modDirectoryTo) => (PenumbraApiEc)base.Invoke(collectionId, modDirectoryFrom, modDirectoryTo); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiModSettings api) => new(pi, Label, (a, b, c) => (int)api.CopyModSettings(a, b, c)); }