summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Events
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-04-23 21:51:49 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-04-23 21:51:49 -0400
commit86ef70feece302f21041204b3baa31d757730acc (patch)
tree2607f445d592667f2894cc79765b980905b450f6 /src/StardewModdingAPI/Events
parent5f595d8a464174bf8ec6940476cf6e05014e17b4 (diff)
downloadSMAPI-86ef70feece302f21041204b3baa31d757730acc.tar.gz
SMAPI-86ef70feece302f21041204b3baa31d757730acc.tar.bz2
SMAPI-86ef70feece302f21041204b3baa31d757730acc.zip
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.
Diffstat (limited to 'src/StardewModdingAPI/Events')
-rw-r--r--src/StardewModdingAPI/Events/GameEvents.cs12
1 files changed, 9 insertions, 3 deletions
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
*********/
- /// <summary>Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called during <see cref="Microsoft.Xna.Framework.Game.Initialize"/>.</summary>
+ /// <summary>Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after <see cref="Microsoft.Xna.Framework.Game.Initialize"/>.</summary>
+ internal static event EventHandler InitializeInternal;
+
+ /// <summary>Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after <see cref="Microsoft.Xna.Framework.Game.Initialize"/>.</summary>
[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
/// <param name="monitor">Encapsulates logging and monitoring.</param>
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);
}