From 86ef70feece302f21041204b3baa31d757730acc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 23 Apr 2017 21:51:49 -0400 Subject: revamp startup process (#265) This revamps SMAPI's startup process to simplify mod development by ensuring that core components are ready by the time mods are loaded (which is also needed for the upcoming content API), and eliminate or reduce SEHExceptions some players experience. --- src/StardewModdingAPI/Events/GameEvents.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/StardewModdingAPI/Events') diff --git a/src/StardewModdingAPI/Events/GameEvents.cs b/src/StardewModdingAPI/Events/GameEvents.cs index 47c1275b..babf7f31 100644 --- a/src/StardewModdingAPI/Events/GameEvents.cs +++ b/src/StardewModdingAPI/Events/GameEvents.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using StardewModdingAPI.Framework; namespace StardewModdingAPI.Events @@ -16,7 +17,10 @@ namespace StardewModdingAPI.Events /********* ** Events *********/ - /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called during . + /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after . + internal static event EventHandler InitializeInternal; + + /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after . [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the " + nameof(Initialize) + " event, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")] public static event EventHandler Initialize; @@ -66,12 +70,14 @@ namespace StardewModdingAPI.Events /// Encapsulates logging and monitoring. internal static void InvokeInitialize(IMonitor monitor) { + // notify SMAPI + monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.InitializeInternal)}", GameEvents.InitializeInternal?.GetInvocationList()); + + // notify mods if (GameEvents.Initialize == null) return; - string name = $"{nameof(GameEvents)}.{nameof(GameEvents.Initialize)}"; Delegate[] handlers = GameEvents.Initialize.GetInvocationList(); - GameEvents.DeprecationManager.WarnForEvent(handlers, name, "1.10", DeprecationLevel.Info); monitor.SafelyRaisePlainEvent(name, handlers); } -- cgit