Move all animation and game event hooks to own classes.

This commit is contained in:
Ottermandias 2023-12-31 15:10:30 +01:00
parent 81cdcad72e
commit da019e729d
62 changed files with 1402 additions and 1143 deletions

View file

@ -11,7 +11,7 @@ namespace Penumbra.Communication;
/// <item>Parameter is the clicked object data if any. </item>
/// </list>
/// </summary>
public sealed class ChangedItemClick : EventWrapper<Action<MouseButton, object?>, ChangedItemClick.Priority>
public sealed class ChangedItemClick() : EventWrapper<MouseButton, object?, ChangedItemClick.Priority>(nameof(ChangedItemClick))
{
public enum Priority
{
@ -21,11 +21,4 @@ public sealed class ChangedItemClick : EventWrapper<Action<MouseButton, object?>
/// <seealso cref="Penumbra.SetupApi"/>
Link = 1,
}
public ChangedItemClick()
: base(nameof(ChangedItemClick))
{ }
public void Invoke(MouseButton button, object? data)
=> Invoke(this, button, data);
}

View file

@ -8,7 +8,7 @@ namespace Penumbra.Communication;
/// <item>Parameter is the hovered object data if any. </item>
/// </list>
/// </summary>
public sealed class ChangedItemHover : EventWrapper<Action<object?>, ChangedItemHover.Priority>
public sealed class ChangedItemHover() : EventWrapper<object?, ChangedItemHover.Priority>(nameof(ChangedItemHover))
{
public enum Priority
{
@ -19,13 +19,6 @@ public sealed class ChangedItemHover : EventWrapper<Action<object?>, ChangedItem
Link = 1,
}
public ChangedItemHover()
: base(nameof(ChangedItemHover))
{ }
public void Invoke(object? data)
=> Invoke(this, data);
public bool HasTooltip
=> HasSubscribers;
}

View file

@ -12,7 +12,8 @@ namespace Penumbra.Communication;
/// <item>Parameter is the new collection, or null on deletions.</item>
/// <item>Parameter is the display name for Individual collections or an empty string otherwise.</item>
/// </list> </summary>
public sealed class CollectionChange : EventWrapper<Action<CollectionType, ModCollection?, ModCollection?, string>, CollectionChange.Priority>
public sealed class CollectionChange()
: EventWrapper<CollectionType, ModCollection?, ModCollection?, string, CollectionChange.Priority>(nameof(CollectionChange))
{
public enum Priority
{
@ -46,11 +47,4 @@ public sealed class CollectionChange : EventWrapper<Action<CollectionType, ModCo
/// <seealso cref="UI.ModsTab.ModFileSystemSelector.OnCollectionChange"/>
ModFileSystemSelector = 0,
}
public CollectionChange()
: base(nameof(CollectionChange))
{ }
public void Invoke(CollectionType collectionType, ModCollection? oldCollection, ModCollection? newCollection, string displayName)
=> Invoke(this, collectionType, oldCollection, newCollection, displayName);
}

View file

@ -10,7 +10,8 @@ namespace Penumbra.Communication;
/// <item>Parameter is whether the change was itself inherited, i.e. if it happened in a direct parent (false) or a more removed ancestor (true). </item>
/// </list>
/// </summary>
public sealed class CollectionInheritanceChanged : EventWrapper<Action<ModCollection, bool>, CollectionInheritanceChanged.Priority>
public sealed class CollectionInheritanceChanged()
: EventWrapper<ModCollection, bool, CollectionInheritanceChanged.Priority>(nameof(CollectionInheritanceChanged))
{
public enum Priority
{
@ -23,11 +24,4 @@ public sealed class CollectionInheritanceChanged : EventWrapper<Action<ModCollec
/// <seealso cref="UI.ModsTab.ModFileSystemSelector.OnInheritanceChange"/>
ModFileSystemSelector = 0,
}
public CollectionInheritanceChanged()
: base(nameof(CollectionInheritanceChanged))
{ }
public void Invoke(ModCollection collection, bool inherited)
=> Invoke(this, collection, inherited);
}

View file

@ -9,18 +9,12 @@ namespace Penumbra.Communication;
/// <item>Parameter is the applied collection. </item>
/// <item>Parameter is the created draw object. </item>
/// </list> </summary>
public sealed class CreatedCharacterBase : EventWrapper<Action<nint, ModCollection, nint>, CreatedCharacterBase.Priority>
public sealed class CreatedCharacterBase()
: EventWrapper<nint, ModCollection, nint, CreatedCharacterBase.Priority>(nameof(CreatedCharacterBase))
{
public enum Priority
{
/// <seealso cref="PenumbraApi.CreatedCharacterBase"/>
Api = int.MinValue,
}
public CreatedCharacterBase()
: base(nameof(CreatedCharacterBase))
{ }
public void Invoke(nint gameObject, ModCollection appliedCollection, nint drawObject)
=> Invoke(this, gameObject, appliedCollection, drawObject);
}

View file

@ -12,18 +12,12 @@ namespace Penumbra.Communication;
/// <item>Parameter is a pointer to the customize array. </item>
/// <item>Parameter is a pointer to the equip data array. </item>
/// </list> </summary>
public sealed class CreatingCharacterBase : EventWrapper<Action<nint, string, nint, nint, nint>, CreatingCharacterBase.Priority>
public sealed class CreatingCharacterBase()
: EventWrapper<nint, string, nint, nint, nint, CreatingCharacterBase.Priority>(nameof(CreatingCharacterBase))
{
public enum Priority
{
/// <seealso cref="PenumbraApi.CreatingCharacterBase"/>
Api = 0,
}
public CreatingCharacterBase()
: base(nameof(CreatingCharacterBase))
{ }
public void Invoke(nint gameObject, string appliedCollectionName, nint modelIdAddress, nint customizeArrayAddress, nint equipDataAddress)
=> Invoke(this, gameObject, appliedCollectionName, modelIdAddress, customizeArrayAddress, equipDataAddress);
}

View file

@ -9,7 +9,7 @@ namespace Penumbra.Communication;
/// <item>Parameter is whether Penumbra is now Enabled (true) or Disabled (false). </item>
/// </list>
/// </summary>
public sealed class EnabledChanged : EventWrapper<Action<bool>, EnabledChanged.Priority>
public sealed class EnabledChanged() : EventWrapper<bool, EnabledChanged.Priority>(nameof(EnabledChanged))
{
public enum Priority
{
@ -19,11 +19,4 @@ public sealed class EnabledChanged : EventWrapper<Action<bool>, EnabledChanged.P
/// <seealso cref="Api.DalamudSubstitutionProvider.OnEnabledChange"/>
DalamudSubstitutionProvider = 0,
}
public EnabledChanged()
: base(nameof(EnabledChanged))
{ }
public void Invoke(bool enabled)
=> Invoke(this, enabled);
}

View file

@ -11,7 +11,7 @@ namespace Penumbra.Communication;
/// <item>Parameter is the changed mod. </item>
/// <item>Parameter is the old name of the mod in case of a name change, and null otherwise. </item>
/// </list> </summary>
public sealed class ModDataChanged : EventWrapper<Action<ModDataChangeType, Mod, string?>, ModDataChanged.Priority>
public sealed class ModDataChanged() : EventWrapper<ModDataChangeType, Mod, string?, ModDataChanged.Priority>(nameof(ModDataChanged))
{
public enum Priority
{
@ -27,11 +27,4 @@ public sealed class ModDataChanged : EventWrapper<Action<ModDataChangeType, Mod,
/// <seealso cref="UI.ModsTab.ModPanelHeader.OnModDataChange"/>
ModPanelHeader = 0,
}
public ModDataChanged()
: base(nameof(ModDataChanged))
{ }
public void Invoke(ModDataChangeType changeType, Mod mod, string? oldName)
=> Invoke(this, changeType, mod, oldName);
}

View file

@ -10,7 +10,7 @@ namespace Penumbra.Communication;
/// <item>Parameter is whether the new directory is valid. </item>
/// </list>
/// </summary>
public sealed class ModDirectoryChanged : EventWrapper<Action<string, bool>, ModDirectoryChanged.Priority>
public sealed class ModDirectoryChanged() : EventWrapper<string, bool, ModDirectoryChanged.Priority>(nameof(ModDirectoryChanged))
{
public enum Priority
{
@ -20,11 +20,4 @@ public sealed class ModDirectoryChanged : EventWrapper<Action<string, bool>, Mod
/// <seealso cref="UI.FileDialogService.OnModDirectoryChange"/>
FileDialogService = 0,
}
public ModDirectoryChanged()
: base(nameof(ModDirectoryChanged))
{ }
public void Invoke(string newModDirectory, bool newDirectoryValid)
=> Invoke(this, newModDirectory, newDirectoryValid);
}

View file

@ -1,10 +1,9 @@
using OtterGui.Classes;
using Penumbra.Mods.Manager;
namespace Penumbra.Communication;
/// <summary> Triggered whenever a new mod discovery has finished. </summary>
public sealed class ModDiscoveryFinished : EventWrapper<Action, ModDiscoveryFinished.Priority>
public sealed class ModDiscoveryFinished() : EventWrapper<ModDiscoveryFinished.Priority>(nameof(ModDiscoveryFinished))
{
public enum Priority
{
@ -23,11 +22,4 @@ public sealed class ModDiscoveryFinished : EventWrapper<Action, ModDiscoveryFini
/// <seealso cref="Mods.Manager.ModFileSystem.Reload"/>
ModFileSystem = 0,
}
public ModDiscoveryFinished()
: base(nameof(ModDiscoveryFinished))
{ }
public void Invoke()
=> Invoke(this);
}

View file

@ -3,7 +3,7 @@ using OtterGui.Classes;
namespace Penumbra.Communication;
/// <summary> Triggered whenever mods are prepared to be rediscovered. </summary>
public sealed class ModDiscoveryStarted : EventWrapper<Action, ModDiscoveryStarted.Priority>
public sealed class ModDiscoveryStarted() : EventWrapper<ModDiscoveryStarted.Priority>(nameof(ModDiscoveryStarted))
{
public enum Priority
{
@ -16,11 +16,4 @@ public sealed class ModDiscoveryStarted : EventWrapper<Action, ModDiscoveryStart
/// <seealso cref="UI.ModsTab.ModFileSystemSelector.StoreCurrentSelection"/>
ModFileSystemSelector = 200,
}
public ModDiscoveryStarted()
: base(nameof(ModDiscoveryStarted))
{ }
public void Invoke()
=> Invoke(this);
}

View file

@ -13,7 +13,8 @@ namespace Penumbra.Communication;
/// <item>Parameter is the index of the changed option inside the group or -1 if it does not concern a specific option. </item>
/// <item>Parameter is the index of the group an option was moved to. </item>
/// </list> </summary>
public sealed class ModOptionChanged : EventWrapper<Action<ModOptionChangeType, Mod, int, int, int>, ModOptionChanged.Priority>
public sealed class ModOptionChanged()
: EventWrapper<ModOptionChangeType, Mod, int, int, int, ModOptionChanged.Priority>(nameof(ModOptionChanged))
{
public enum Priority
{
@ -29,11 +30,4 @@ public sealed class ModOptionChanged : EventWrapper<Action<ModOptionChangeType,
/// <seealso cref="Collections.Manager.CollectionStorage.OnModOptionChange"/>
CollectionStorage = 100,
}
public ModOptionChanged()
: base(nameof(ModOptionChanged))
{ }
public void Invoke(ModOptionChangeType changeType, Mod mod, int groupIndex, int optionIndex, int moveToIndex)
=> Invoke(this, changeType, mod, groupIndex, optionIndex, moveToIndex);
}

View file

@ -14,7 +14,8 @@ namespace Penumbra.Communication;
/// <item>Parameter is the new directory on addition, move or reload and null on deletion. </item>
/// </list>
/// </summary>
public sealed class ModPathChanged : EventWrapper<Action<ModPathChangeType, Mod, DirectoryInfo?, DirectoryInfo?>, ModPathChanged.Priority>
public sealed class ModPathChanged()
: EventWrapper<ModPathChangeType, Mod, DirectoryInfo?, DirectoryInfo?, ModPathChanged.Priority>(nameof(ModPathChanged))
{
public enum Priority
{
@ -48,11 +49,4 @@ public sealed class ModPathChanged : EventWrapper<Action<ModPathChangeType, Mod,
/// <seealso cref="Collections.Cache.CollectionCacheManager.OnModChangeRemoval"/>
CollectionCacheManagerRemoval = 100,
}
public ModPathChanged()
: base(nameof(ModPathChanged))
{ }
public void Invoke(ModPathChangeType changeType, Mod mod, DirectoryInfo? oldModDirectory, DirectoryInfo? newModDirectory)
=> Invoke(this, changeType, mod, oldModDirectory, newModDirectory);
}

View file

@ -17,7 +17,8 @@ namespace Penumbra.Communication;
/// <item>Parameter is whether the change was inherited from another collection. </item>
/// </list>
/// </summary>
public sealed class ModSettingChanged : EventWrapper<Action<ModCollection, ModSettingChange, Mod?, int, int, bool>, ModSettingChanged.Priority>
public sealed class ModSettingChanged()
: EventWrapper<ModCollection, ModSettingChange, Mod?, int, int, bool, ModSettingChanged.Priority>(nameof(ModSettingChanged))
{
public enum Priority
{
@ -33,11 +34,4 @@ public sealed class ModSettingChanged : EventWrapper<Action<ModCollection, ModSe
/// <seealso cref="UI.ModsTab.ModFileSystemSelector.OnSettingChange"/>
ModFileSystemSelector = 0,
}
public ModSettingChanged()
: base(nameof(ModSettingChanged))
{ }
public void Invoke(ModCollection collection, ModSettingChange type, Mod? mod, int oldValue, int groupIdx, bool inherited)
=> Invoke(this, collection, type, mod, oldValue, groupIdx, inherited);
}

View file

@ -6,18 +6,11 @@ namespace Penumbra.Communication;
/// <item>Parameter is the material resource handle for which the shader package has been loaded. </item>
/// <item>Parameter is the associated game object. </item>
/// </list> </summary>
public sealed class MtrlShpkLoaded : EventWrapper<Action<nint, nint>, MtrlShpkLoaded.Priority>
public sealed class MtrlShpkLoaded() : EventWrapper<nint, nint, MtrlShpkLoaded.Priority>(nameof(MtrlShpkLoaded))
{
public enum Priority
{
/// <seealso cref="Interop.Services.SkinFixer.OnMtrlShpkLoaded"/>
SkinFixer = 0,
}
public MtrlShpkLoaded()
: base(nameof(MtrlShpkLoaded))
{ }
public void Invoke(nint mtrlResourceHandle, nint gameObject)
=> Invoke(this, mtrlResourceHandle, gameObject);
}

View file

@ -8,18 +8,11 @@ namespace Penumbra.Communication;
/// <item>Parameter is the identifier (directory name) of the currently selected mod. </item>
/// </list>
/// </summary>
public sealed class PostSettingsPanelDraw : EventWrapper<Action<string>, PostSettingsPanelDraw.Priority>
public sealed class PostSettingsPanelDraw() : EventWrapper<string, PostSettingsPanelDraw.Priority>(nameof(PostSettingsPanelDraw))
{
public enum Priority
{
/// <seealso cref="Api.PenumbraApi.PostSettingsPanelDraw"/>
Default = 0,
}
public PostSettingsPanelDraw()
: base(nameof(PostSettingsPanelDraw))
{ }
public void Invoke(string modDirectory)
=> Invoke(this, modDirectory);
}

View file

@ -8,18 +8,11 @@ namespace Penumbra.Communication;
/// <item>Parameter is the identifier (directory name) of the currently selected mod. </item>
/// </list>
/// </summary>
public sealed class PreSettingsPanelDraw : EventWrapper<Action<string>, PreSettingsPanelDraw.Priority>
public sealed class PreSettingsPanelDraw() : EventWrapper<string, PreSettingsPanelDraw.Priority>(nameof(PreSettingsPanelDraw))
{
public enum Priority
{
/// <seealso cref="Api.PenumbraApi.PreSettingsPanelDraw"/>
Default = 0,
}
public PreSettingsPanelDraw()
: base(nameof(PreSettingsPanelDraw))
{ }
public void Invoke(string modDirectory)
=> Invoke(this, modDirectory);
}

View file

@ -15,8 +15,9 @@ namespace Penumbra.Communication;
/// <item>Parameter is the old redirection path for Replaced, or empty. </item>
/// <item>Parameter is the mod responsible for the new redirection if any. </item>
/// </list> </summary>
public sealed class ResolvedFileChanged : EventWrapper<Action<ModCollection, ResolvedFileChanged.Type, Utf8GamePath, FullPath, FullPath, IMod?>,
ResolvedFileChanged.Priority>
public sealed class ResolvedFileChanged()
: EventWrapper<ModCollection, ResolvedFileChanged.Type, Utf8GamePath, FullPath, FullPath, IMod?, ResolvedFileChanged.Priority>(
nameof(ResolvedFileChanged))
{
public enum Type
{
@ -29,14 +30,7 @@ public sealed class ResolvedFileChanged : EventWrapper<Action<ModCollection, Res
public enum Priority
{
/// <seealso cref="Api.DalamudSubstitutionProvider.OnResolvedFileChanged"/>
/// <seealso cref="Api.DalamudSubstitutionProvider.OnResolvedFileChange"/>
DalamudSubstitutionProvider = 0,
}
public ResolvedFileChanged()
: base(nameof(ResolvedFileChanged))
{ }
public void Invoke(ModCollection collection, Type type, Utf8GamePath key, FullPath value, FullPath old, IMod? mod)
=> Invoke(this, collection, type, key, value, old, mod);
}

View file

@ -11,18 +11,11 @@ namespace Penumbra.Communication;
/// <item>Parameter is the selected mod, if any. </item>
/// </list>
/// </summary>
public sealed class SelectTab : EventWrapper<Action<TabType, Mod?>, SelectTab.Priority>
public sealed class SelectTab() : EventWrapper<TabType, Mod?, SelectTab.Priority>(nameof(SelectTab))
{
public enum Priority
{
/// <seealso cref="UI.Tabs.ConfigTabBar.OnSelectTab"/>
ConfigTabBar = 0,
}
public SelectTab()
: base(nameof(SelectTab))
{ }
public void Invoke(TabType tab = TabType.None, Mod? mod = null)
=> Invoke(this, tab, mod);
}

View file

@ -10,7 +10,8 @@ namespace Penumbra.Communication;
/// <item>Parameter is whether the mod was newly created.</item>
/// <item>Parameter is whether the mod was deleted.</item>
/// </list> </summary>
public sealed class TemporaryGlobalModChange : EventWrapper<Action<TemporaryMod, bool, bool>, TemporaryGlobalModChange.Priority>
public sealed class TemporaryGlobalModChange()
: EventWrapper<TemporaryMod, bool, bool, TemporaryGlobalModChange.Priority>(nameof(TemporaryGlobalModChange))
{
public enum Priority
{
@ -20,11 +21,4 @@ public sealed class TemporaryGlobalModChange : EventWrapper<Action<TemporaryMod,
/// <seealso cref="Collections.Manager.TempCollectionManager.OnGlobalModChange"/>
TempCollectionManager = 0,
}
public TemporaryGlobalModChange()
: base(nameof(TemporaryGlobalModChange))
{ }
public void Invoke(TemporaryMod temporaryMod, bool newlyCreated, bool deleted)
=> Invoke(this, temporaryMod, newlyCreated, deleted);
}