diff options
Diffstat (limited to 'src/StardewModdingAPI')
25 files changed, 96 insertions, 76 deletions
diff --git a/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs b/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs index 708c02e0..2a2aa163 100644 --- a/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs @@ -10,10 +10,10 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The previous menu.</summary> - public IClickableMenu NewMenu { get; private set; } + public IClickableMenu NewMenu { get; } /// <summary>The current menu.</summary> - public IClickableMenu PriorMenu { get; private set; } + public IClickableMenu PriorMenu { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs b/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs index 1a62432f..5e6585f0 100644 --- a/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs +++ b/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The menu that was closed.</summary> - public IClickableMenu PriorMenu { get; private set; } + public IClickableMenu PriorMenu { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsCommand.cs b/src/StardewModdingAPI/Events/EventArgsCommand.cs index bae13694..88a9e5a3 100644 --- a/src/StardewModdingAPI/Events/EventArgsCommand.cs +++ b/src/StardewModdingAPI/Events/EventArgsCommand.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The triggered command.</summary> - public Command Command { get; private set; } + public Command Command { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs b/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs index 87c96678..3243b80b 100644 --- a/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs +++ b/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs @@ -11,10 +11,10 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The player who pressed the button.</summary> - public PlayerIndex PlayerIndex { get; private set; } + public PlayerIndex PlayerIndex { get; } /// <summary>The controller button that was pressed.</summary> - public Buttons ButtonPressed { get; private set; } + public Buttons ButtonPressed { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs b/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs index cb53b545..e05a080b 100644 --- a/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs +++ b/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs @@ -11,10 +11,10 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The player who pressed the button.</summary> - public PlayerIndex PlayerIndex { get; private set; } + public PlayerIndex PlayerIndex { get; } /// <summary>The controller button that was pressed.</summary> - public Buttons ButtonReleased { get; private set; } + public Buttons ButtonReleased { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs b/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs index 72b73040..a2087733 100644 --- a/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs +++ b/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs @@ -11,13 +11,13 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The player who pressed the button.</summary> - public PlayerIndex PlayerIndex { get; private set; } + public PlayerIndex PlayerIndex { get; } /// <summary>The controller button that was pressed.</summary> - public Buttons ButtonPressed { get; private set; } + public Buttons ButtonPressed { get; } /// <summary>The current trigger value.</summary> - public float Value { get; private set; } + public float Value { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs b/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs index de28a159..d2eecbec 100644 --- a/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs +++ b/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs @@ -11,13 +11,13 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The player who pressed the button.</summary> - public PlayerIndex PlayerIndex { get; private set; } + public PlayerIndex PlayerIndex { get; } /// <summary>The controller button that was released.</summary> - public Buttons ButtonReleased { get; private set; } + public Buttons ButtonReleased { get; } /// <summary>The current trigger value.</summary> - public float Value { get; private set; } + public float Value { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs b/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs index aa0bb377..25d3ebf3 100644 --- a/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs @@ -10,10 +10,10 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The player's current location.</summary> - public GameLocation NewLocation { get; private set; } + public GameLocation NewLocation { get; } /// <summary>The player's previous location.</summary> - public GameLocation PriorLocation { get; private set; } + public GameLocation PriorLocation { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs b/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs index c68951ce..fb8c821e 100644 --- a/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs @@ -11,7 +11,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The current list of game locations.</summary> - public List<GameLocation> NewLocations { get; private set; } + public List<GameLocation> NewLocations { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs b/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs index 11cbcedf..1ee02842 100644 --- a/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs @@ -12,16 +12,16 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The player's inventory.</summary> - public List<Item> Inventory { get; private set; } + public List<Item> Inventory { get; } /// <summary>The added items.</summary> - public List<ItemStackChange> Added { get; private set; } + public List<ItemStackChange> Added { get; } /// <summary>The removed items.</summary> - public List<ItemStackChange> Removed { get; private set; } + public List<ItemStackChange> Removed { get; } /// <summary>The items whose stack sizes changed.</summary> - public List<ItemStackChange> QuantityChanged { get; private set; } + public List<ItemStackChange> QuantityChanged { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsKeyPressed.cs b/src/StardewModdingAPI/Events/EventArgsKeyPressed.cs index 82a593be..d9d81e10 100644 --- a/src/StardewModdingAPI/Events/EventArgsKeyPressed.cs +++ b/src/StardewModdingAPI/Events/EventArgsKeyPressed.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The keyboard button that was pressed.</summary> - public Keys KeyPressed { get; private set; } + public Keys KeyPressed { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsKeyboardStateChanged.cs b/src/StardewModdingAPI/Events/EventArgsKeyboardStateChanged.cs index 2e314731..14e397ce 100644 --- a/src/StardewModdingAPI/Events/EventArgsKeyboardStateChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsKeyboardStateChanged.cs @@ -10,10 +10,10 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The previous keyboard state.</summary> - public KeyboardState NewState { get; private set; } + public KeyboardState NewState { get; } /// <summary>The current keyboard state.</summary> - public KeyboardState PriorState { get; private set; } + public KeyboardState PriorState { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsLevelUp.cs b/src/StardewModdingAPI/Events/EventArgsLevelUp.cs index 826914da..fe6696d4 100644 --- a/src/StardewModdingAPI/Events/EventArgsLevelUp.cs +++ b/src/StardewModdingAPI/Events/EventArgsLevelUp.cs @@ -9,10 +9,10 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The player skill that leveled up.</summary> - public LevelType Type { get; private set; } + public LevelType Type { get; } /// <summary>The new skill level.</summary> - public int NewLevel { get; private set; } + public int NewLevel { get; } /// <summary>The player skill types.</summary> public enum LevelType diff --git a/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs b/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs index cd7a366f..51d64016 100644 --- a/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs @@ -9,7 +9,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>Whether the save has been loaded. This is always true.</summary> - public bool LoadedGame { get; private set; } + public bool LoadedGame { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsLocationObjectsChanged.cs b/src/StardewModdingAPI/Events/EventArgsLocationObjectsChanged.cs index f708ab6b..058999e9 100644 --- a/src/StardewModdingAPI/Events/EventArgsLocationObjectsChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsLocationObjectsChanged.cs @@ -12,7 +12,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The current list of objects in the current location.</summary> - public SerializableDictionary<Vector2, Object> NewObjects { get; private set; } + public SerializableDictionary<Vector2, Object> NewObjects { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsMineLevelChanged.cs b/src/StardewModdingAPI/Events/EventArgsMineLevelChanged.cs index a02921d2..c82fed35 100644 --- a/src/StardewModdingAPI/Events/EventArgsMineLevelChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsMineLevelChanged.cs @@ -9,10 +9,10 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The previous mine level.</summary> - public int PreviousMineLevel { get; private set; } + public int PreviousMineLevel { get; } /// <summary>The current mine level.</summary> - public int CurrentMineLevel { get; private set; } + public int CurrentMineLevel { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsMouseStateChanged.cs b/src/StardewModdingAPI/Events/EventArgsMouseStateChanged.cs index a589e29d..57298164 100644 --- a/src/StardewModdingAPI/Events/EventArgsMouseStateChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsMouseStateChanged.cs @@ -11,16 +11,16 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The previous mouse state.</summary> - public MouseState PriorState { get; private set; } + public MouseState PriorState { get; } /// <summary>The current mouse state.</summary> - public MouseState NewState { get; private set; } + public MouseState NewState { get; } /// <summary>The previous mouse position on the screen adjusted for the zoom level.</summary> - public Point PriorPosition { get; private set; } + public Point PriorPosition { get; } /// <summary>The current mouse position on the screen adjusted for the zoom level.</summary> - public Point NewPosition { get; private set; } + public Point NewPosition { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsNewDay.cs b/src/StardewModdingAPI/Events/EventArgsNewDay.cs index 5088cb5c..aba837e4 100644 --- a/src/StardewModdingAPI/Events/EventArgsNewDay.cs +++ b/src/StardewModdingAPI/Events/EventArgsNewDay.cs @@ -9,13 +9,13 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The previous day value.</summary> - public int PreviousDay { get; private set; } + public int PreviousDay { get; } /// <summary>The current day value.</summary> - public int CurrentDay { get; private set; } + public int CurrentDay { get; } /// <summary>Whether the game just started the transition (<c>true</c>) or finished it (<c>false</c>).</summary> - public bool IsNewDay { get; private set; } + public bool IsNewDay { get; } /********* diff --git a/src/StardewModdingAPI/Events/EventArgsStringChanged.cs b/src/StardewModdingAPI/Events/EventArgsStringChanged.cs index f91951ae..85b6fab5 100644 --- a/src/StardewModdingAPI/Events/EventArgsStringChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsStringChanged.cs @@ -9,10 +9,10 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The previous value.</summary> - public string NewString { get; private set; } + public string NewString { get; } /// <summary>The current value.</summary> - public string PriorString { get; private set; } + public string PriorString { get; } /********* ** Public methods diff --git a/src/StardewModdingAPI/Events/GameEvents.cs b/src/StardewModdingAPI/Events/GameEvents.cs index 715083b9..47c1275b 100644 --- a/src/StardewModdingAPI/Events/GameEvents.cs +++ b/src/StardewModdingAPI/Events/GameEvents.cs @@ -7,17 +7,26 @@ namespace StardewModdingAPI.Events public static class GameEvents { /********* + ** Properties + *********/ + /// <summary>Manages deprecation warnings.</summary> + private static DeprecationManager DeprecationManager; + + + /********* ** 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> + [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; - /// <summary>Raised during launch after configuring Stardew Valley, loading it into memory, and opening the game window. The window is still blank by this point.</summary> - public static event EventHandler GameLoaded; - /// <summary>Raised before XNA loads or reloads graphics resources. Called during <see cref="Microsoft.Xna.Framework.Game.LoadContent"/>.</summary> + [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the " + nameof(LoadContent) + " event, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")] public static event EventHandler LoadContent; + /// <summary>Raised during launch after configuring Stardew Valley, loading it into memory, and opening the game window. The window is still blank by this point.</summary> + public static event EventHandler GameLoaded; + /// <summary>Raised during the first game update tick.</summary> public static event EventHandler FirstUpdateTick; @@ -46,25 +55,46 @@ namespace StardewModdingAPI.Events /********* ** Internal methods *********/ - /// <summary>Raise a <see cref="GameLoaded"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - internal static void InvokeGameLoaded(IMonitor monitor) + /// <summary>Injects types required for backwards compatibility.</summary> + /// <param name="deprecationManager">Manages deprecation warnings.</param> + internal static void Shim(DeprecationManager deprecationManager) { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}", GameEvents.GameLoaded?.GetInvocationList()); + GameEvents.DeprecationManager = deprecationManager; } /// <summary>Raise an <see cref="Initialize"/> event.</summary> /// <param name="monitor">Encapsulates logging and monitoring.</param> internal static void InvokeInitialize(IMonitor monitor) { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.Initialize)}", GameEvents.Initialize?.GetInvocationList()); + 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); } /// <summary>Raise a <see cref="LoadContent"/> event.</summary> /// <param name="monitor">Encapsulates logging and monitoring.</param> internal static void InvokeLoadContent(IMonitor monitor) { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.LoadContent)}", GameEvents.LoadContent?.GetInvocationList()); + if (GameEvents.LoadContent == null) + return; + + string name = $"{nameof(GameEvents)}.{nameof(GameEvents.LoadContent)}"; + Delegate[] handlers = GameEvents.LoadContent.GetInvocationList(); + + GameEvents.DeprecationManager.WarnForEvent(handlers, name, "1.10", DeprecationLevel.Info); + monitor.SafelyRaisePlainEvent(name, handlers); + } + + /// <summary>Raise a <see cref="GameLoaded"/> event.</summary> + /// <param name="monitor">Encapsulates monitoring and logging.</param> + internal static void InvokeGameLoaded(IMonitor monitor) + { + monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}", GameEvents.GameLoaded?.GetInvocationList()); } /// <summary>Raise an <see cref="UpdateTick"/> event.</summary> diff --git a/src/StardewModdingAPI/Framework/AssemblyLoader.cs b/src/StardewModdingAPI/Framework/AssemblyLoader.cs index f6fe89f5..2c9973c1 100644 --- a/src/StardewModdingAPI/Framework/AssemblyLoader.cs +++ b/src/StardewModdingAPI/Framework/AssemblyLoader.cs @@ -284,7 +284,7 @@ namespace StardewModdingAPI.Framework { if (!hash.Contains(message)) { - this.Monitor.Log(message, level); + monitor.Log(message, level); hash.Add(message); } } diff --git a/src/StardewModdingAPI/Framework/InternalExtensions.cs b/src/StardewModdingAPI/Framework/InternalExtensions.cs index 4ca79518..a2d589ff 100644 --- a/src/StardewModdingAPI/Framework/InternalExtensions.cs +++ b/src/StardewModdingAPI/Framework/InternalExtensions.cs @@ -39,7 +39,7 @@ namespace StardewModdingAPI.Framework if (handlers == null) return; - foreach (EventHandler handler in Enumerable.Cast<EventHandler>(handlers)) + foreach (EventHandler handler in handlers.Cast<EventHandler>()) { try { @@ -64,7 +64,7 @@ namespace StardewModdingAPI.Framework if (handlers == null) return; - foreach (EventHandler<TEventArgs> handler in Enumerable.Cast<EventHandler<TEventArgs>>(handlers)) + foreach (EventHandler<TEventArgs> handler in handlers.Cast<EventHandler<TEventArgs>>()) { try { @@ -85,14 +85,14 @@ namespace StardewModdingAPI.Framework public static string GetLogSummary(this Exception exception) { // type load exception - if (exception is TypeLoadException) - return $"Failed loading type: {((TypeLoadException)exception).TypeName}: {exception}"; + if (exception is TypeLoadException typeLoadEx) + return $"Failed loading type: {typeLoadEx.TypeName}: {exception}"; // reflection type load exception - if (exception is ReflectionTypeLoadException) + if (exception is ReflectionTypeLoadException reflectionTypeLoadEx) { string summary = exception.ToString(); - foreach (Exception childEx in ((ReflectionTypeLoadException)exception).LoaderExceptions) + foreach (Exception childEx in reflectionTypeLoadEx.LoaderExceptions) summary += $"\n\n{childEx.GetLogSummary()}"; return summary; } diff --git a/src/StardewModdingAPI/Framework/Monitor.cs b/src/StardewModdingAPI/Framework/Monitor.cs index 64075f2f..76793bbf 100644 --- a/src/StardewModdingAPI/Framework/Monitor.cs +++ b/src/StardewModdingAPI/Framework/Monitor.cs @@ -21,7 +21,7 @@ namespace StardewModdingAPI.Framework private readonly LogFileManager LogFile; /// <summary>The maximum length of the <see cref="LogLevel"/> values.</summary> - private static readonly int MaxLevelLength = (from level in Enumerable.Cast<LogLevel>(Enum.GetValues(typeof(LogLevel))) select level.ToString().Length).Max(); + private static readonly int MaxLevelLength = (from level in Enum.GetValues(typeof(LogLevel)).Cast<LogLevel>() select level.ToString().Length).Max(); /// <summary>The console text color for each log level.</summary> private static readonly Dictionary<LogLevel, ConsoleColor> Colors = new Dictionary<LogLevel, ConsoleColor> @@ -71,6 +71,7 @@ namespace StardewModdingAPI.Framework this.Source = source; this.LogFile = logFile; this.ConsoleManager = consoleManager; + this.RequestExit = requestExitDelegate; } /// <summary>Log a message for the player or developer.</summary> @@ -129,6 +130,8 @@ namespace StardewModdingAPI.Framework { if (this.ConsoleManager.SupportsColor) { + if (background.HasValue) + Console.BackgroundColor = background.Value; Console.ForegroundColor = color; Console.WriteLine(message); Console.ResetColor(); diff --git a/src/StardewModdingAPI/Framework/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs index c16bf1cf..b262d4dd 100644 --- a/src/StardewModdingAPI/Framework/SGame.cs +++ b/src/StardewModdingAPI/Framework/SGame.cs @@ -50,7 +50,7 @@ namespace StardewModdingAPI.Framework ** Game state ****/ /// <summary>Arrays of pressed controller buttons indexed by <see cref="PlayerIndex"/>.</summary> - private Buttons[][] PreviouslyPressedButtons; + private readonly Buttons[][] PreviouslyPressedButtons = { new Buttons[0], new Buttons[0], new Buttons[0], new Buttons[0] }; /// <summary>A record of the keyboard state (i.e. the up/down state for each button) as of the latest tick.</summary> private KeyboardState KStateNow; @@ -186,17 +186,6 @@ namespace StardewModdingAPI.Framework /**** ** Intercepted methods & events ****/ - /// <summary>The method called during game launch after configuring XNA or MonoGame. The game window hasn't been opened by this point.</summary> - protected override void Initialize() - { - this.PreviouslyPressedButtons = new Buttons[4][]; - for (var i = 0; i < 4; ++i) - this.PreviouslyPressedButtons[i] = new Buttons[0]; - - base.Initialize(); - GameEvents.InvokeInitialize(this.Monitor); - } - /// <summary>Constructor a content manager to read XNB files.</summary> /// <param name="serviceProvider">The service provider to use to locate services.</param> /// <param name="rootDirectory">The root directory to search for content.</param> @@ -205,13 +194,6 @@ namespace StardewModdingAPI.Framework return new SContentManager(this.Content.ServiceProvider, this.Content.RootDirectory, this.Monitor); } - /// <summary>The method called before XNA or MonoGame loads or reloads graphics resources.</summary> - protected override void LoadContent() - { - base.LoadContent(); - GameEvents.InvokeLoadContent(this.Monitor); - } - /// <summary>The method called when the game is updating its state. This happens roughly 60 times per second.</summary> /// <param name="gameTime">A snapshot of the game timing state.</param> protected override void Update(GameTime gameTime) @@ -234,7 +216,11 @@ namespace StardewModdingAPI.Framework // raise game loaded if (this.FirstUpdate) + { + GameEvents.InvokeInitialize(this.Monitor); + GameEvents.InvokeLoadContent(this.Monitor); GameEvents.InvokeGameLoaded(this.Monitor); + } // update SMAPI events this.UpdateEventCalls(); @@ -1159,7 +1145,7 @@ namespace StardewModdingAPI.Framework { ControlEvents.InvokeMouseChanged(this.Monitor, this.MStatePrior, this.MStateNow, this.MPositionPrior, this.MPositionNow); this.MStatePrior = this.MStateNow; - this.MPositionPrior = this.MPositionPrior; + this.MPositionPrior = this.MPositionNow; } } diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 019ac0e3..62961021 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -120,6 +120,7 @@ namespace StardewModdingAPI Log.Shim(this.DeprecationManager, this.GetSecondaryMonitor("legacy mod"), this.ModRegistry); Mod.Shim(this.DeprecationManager); ContentEvents.Shim(this.ModRegistry, this.Monitor); + GameEvents.Shim(this.DeprecationManager); PlayerEvents.Shim(this.DeprecationManager); TimeEvents.Shim(this.DeprecationManager); #pragma warning restore 618 |