diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj index bacdc995..c2bd030a 100644 --- a/IPA.Loader/IPA.Loader.csproj +++ b/IPA.Loader/IPA.Loader.csproj @@ -1,196 +1,198 @@ - - - - - Debug - Net4 - true - {5AD344F0-01A0-4CA8-92E5-9D095737744D} - Library - Properties - IPA - IPA.Loader - 512 - true - $(SolutionDir)=C:\ - portable - false - true - net461;net35 - 8.0 - true - - - true - false - bin\$(Platform)\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - true - bin\$(Platform)\Release\ - TRACE - prompt - 4 - false - - - v4.6.1 - $(DefineConstants);NET4 - - - v3.5 - $(DefineConstants);NET3 - - - $(DefineConstants);BeatSaber - - - $(OutputPath)IPA.Loader.xml - - - - - - - - - - - - - - ..\Refs\UnityEngine.CoreModule.Net4.dll - False - - - ..\Refs\UnityEngine.UnityWebRequestModule.Net4.dll - False - - - - - ..\Refs\UnityEngine.CoreModule.Net3.dll - False - - - ..\Refs\UnityEngine.UnityWebRequestModule.Net3.dll - False - - - - - {642F52DA-90F9-40E3-8784-6964F36752FB} - Net3-Proxy - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.9.1.8 - - - 1.2.0.1 - - - 0.10.4 - - - 12.0.3 - - - 1.0.1 - - - 1.2.2 - - - 0.3.1 - - - - - - - - - - - - + + + + + Debug + Net4 + true + {5AD344F0-01A0-4CA8-92E5-9D095737744D} + Library + Properties + IPA + IPA.Loader + 512 + true + $(SolutionDir)=C:\ + portable + false + true + net461;net35 + 8.0 + true + + + true + false + bin\$(Platform)\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + true + bin\$(Platform)\Release\ + TRACE + prompt + 4 + false + + + v4.6.1 + $(DefineConstants);NET4 + + + v3.5 + $(DefineConstants);NET3 + + + $(DefineConstants);BeatSaber + + + $(OutputPath)IPA.Loader.xml + + + + + + + + + + + + + + ..\Refs\UnityEngine.CoreModule.Net4.dll + False + + + ..\Refs\UnityEngine.UnityWebRequestModule.Net4.dll + False + + + + + ..\Refs\UnityEngine.CoreModule.Net3.dll + False + + + ..\Refs\UnityEngine.UnityWebRequestModule.Net3.dll + False + + + + + {642F52DA-90F9-40E3-8784-6964F36752FB} + Net3-Proxy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.9.1.8 + + + 1.2.0.1 + + + 0.10.4 + + + 12.0.3 + + + 1.0.1 + + + 1.2.2 + + + 0.3.1 + + + + + + + + + + + + \ No newline at end of file diff --git a/IPA.Loader/PluginInterfaces/Attributes/LifecycleAttributes.cs b/IPA.Loader/PluginInterfaces/Attributes/LifecycleAttributes.cs new file mode 100644 index 00000000..cb577c36 --- /dev/null +++ b/IPA.Loader/PluginInterfaces/Attributes/LifecycleAttributes.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IPA +{ + internal enum EdgeLifecycleType + { + Enable, Disable + } + + internal interface IEdgeLifecycleAttribute + { + EdgeLifecycleType Type { get; } + } + + // TODO: is there a better way to manage this mess? + + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public sealed class OnEnableAttribute : Attribute, IEdgeLifecycleAttribute + { + EdgeLifecycleType IEdgeLifecycleAttribute.Type => EdgeLifecycleType.Enable; + } + + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public sealed class OnStartAttribute : Attribute, IEdgeLifecycleAttribute + { + EdgeLifecycleType IEdgeLifecycleAttribute.Type => EdgeLifecycleType.Enable; + } + + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public sealed class OnDisableAttribute : Attribute, IEdgeLifecycleAttribute + { + EdgeLifecycleType IEdgeLifecycleAttribute.Type => EdgeLifecycleType.Disable; + } + + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public sealed class OnExitAttribute : Attribute, IEdgeLifecycleAttribute + { + EdgeLifecycleType IEdgeLifecycleAttribute.Type => EdgeLifecycleType.Disable; + } +} diff --git a/IPA.Loader/PluginInterfaces/Attributes/PluginAttribute.cs b/IPA.Loader/PluginInterfaces/Attributes/PluginAttribute.cs new file mode 100644 index 00000000..0cb8385f --- /dev/null +++ b/IPA.Loader/PluginInterfaces/Attributes/PluginAttribute.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IPA +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + public sealed class PluginAttribute : Attribute + { + public RuntimeOptions RuntimeOptions { get; } + public PluginAttribute(RuntimeOptions runtimeOptions) + { + RuntimeOptions = runtimeOptions; + } + } + + public enum RuntimeOptions + { + SingleStartInit, + DynamicInit, + + // TODO: do I want this? + SingleDynamicInit + } + + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] + public sealed class InitAttribute : Attribute { } +} diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs index f3be9e5a..7d5abd42 100644 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs @@ -1,19 +1,22 @@ -namespace IPA -{ - /// - /// Provides methods to allow runtime disabling of a plugin. - /// - public interface IDisablablePlugin : IPlugin - { - - /// - /// Called when a plugin is disabled at runtime. This should disable things like Harmony patches and unsubscribe - /// from events. After this is called there should be no lingering effects of the mod. - /// - /// - /// This will get called at shutdown, after , as well as when the - /// plugin is disabled at runtime. - /// - void OnDisable(); - } -} +using System; + +namespace IPA +{ + /// + /// Provides methods to allow runtime disabling of a plugin. + /// + [Obsolete("Use the attribute-based system instead.")] + public interface IDisablablePlugin : IPlugin + { + + /// + /// Called when a plugin is disabled at runtime. This should disable things like Harmony patches and unsubscribe + /// from events. After this is called there should be no lingering effects of the mod. + /// + /// + /// This will get called at shutdown, after , as well as when the + /// plugin is disabled at runtime. + /// + void OnDisable(); + } +} diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedPlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedPlugin.cs index 960c1688..583e67e2 100644 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedPlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedPlugin.cs @@ -1,31 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IPA -{ - /// - /// - /// An enhanced version of a standard BeatSaber plugin. - /// - public interface IEnhancedPlugin : IPlugin - { - - /// - /// Gets invoked on every graphic update. - /// - void OnUpdate(); - - /// - /// Gets invoked on ever physics update. - /// - void OnFixedUpdate(); - - /// - /// Called after Update. - /// - void OnLateUpdate(); - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IPA +{ + /// + /// + /// An enhanced version of a standard BeatSaber plugin. + /// + [Obsolete("Use the attribute-based system instead.")] + public interface IEnhancedPlugin : IPlugin + { + + /// + /// Gets invoked on every graphic update. + /// + void OnUpdate(); + + /// + /// Gets invoked on ever physics update. + /// + void OnFixedUpdate(); + + /// + /// Called after Update. + /// + void OnLateUpdate(); + } +} diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs index c298d87a..afcd50fa 100644 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs @@ -1,51 +1,53 @@ -using UnityEngine.SceneManagement; - -namespace IPA -{ - /// - /// Interface for BSIPA plugins. Every class that implements this will be loaded if the DLL is placed at - /// <install dir>/Plugins. - /// - /// - /// Mods implemented with this interface should handle being enabled at runtime properly, unless marked - /// with the "no-runtime-enable" feature. - /// - public interface IPlugin - { - /// - /// Called when a plugin is enabled. This is where you should set up Harmony patches and the like. - /// - /// - /// This will be called after Init, and will be called when the plugin loads normally too. - /// When a plugin is disabled at startup, neither this nor Init will be called until it is enabled. - /// - /// Init will only ever be called once. - /// - void OnEnable(); - - /// - /// Gets invoked when the application is closed. - /// - void OnApplicationQuit(); - - /// - /// Gets invoked whenever a scene is loaded. - /// - /// The scene currently loaded - /// The type of loading - void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode); - - /// - /// Gets invoked whenever a scene is unloaded - /// - /// The unloaded scene - void OnSceneUnloaded(Scene scene); - - /// - /// Gets invoked whenever a scene is changed - /// - /// The Scene that was previously loaded - /// The Scene being loaded - void OnActiveSceneChanged(Scene prevScene, Scene nextScene); - } -} +using System; +using UnityEngine.SceneManagement; + +namespace IPA +{ + /// + /// Interface for BSIPA plugins. Every class that implements this will be loaded if the DLL is placed at + /// <install dir>/Plugins. + /// + /// + /// Mods implemented with this interface should handle being enabled at runtime properly, unless marked + /// with the "no-runtime-enable" feature. + /// + [Obsolete("Use the attribute-based system instead.")] + public interface IPlugin + { + /// + /// Called when a plugin is enabled. This is where you should set up Harmony patches and the like. + /// + /// + /// This will be called after Init, and will be called when the plugin loads normally too. + /// When a plugin is disabled at startup, neither this nor Init will be called until it is enabled. + /// + /// Init will only ever be called once. + /// + void OnEnable(); + + /// + /// Gets invoked when the application is closed. + /// + void OnApplicationQuit(); + + /// + /// Gets invoked whenever a scene is loaded. + /// + /// The scene currently loaded + /// The type of loading + void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode); + + /// + /// Gets invoked whenever a scene is unloaded + /// + /// The unloaded scene + void OnSceneUnloaded(Scene scene); + + /// + /// Gets invoked whenever a scene is changed + /// + /// The Scene that was previously loaded + /// The Scene being loaded + void OnActiveSceneChanged(Scene prevScene, Scene nextScene); + } +}