From 7fe85119219c17d459fd5a373916dafff7b4e2a2 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 31 Oct 2016 14:48:23 -0400 Subject: document & format event code --- src/StardewModdingAPI.sln.DotSettings | 7 + src/StardewModdingAPI/Events/ControlEvents.cs | 73 +++++-- .../Events/EventArgsClickableMenuChanged.cs | 26 ++- .../Events/EventArgsClickableMenuClosed.cs | 19 +- src/StardewModdingAPI/Events/EventArgsCommand.cs | 19 +- .../Events/EventArgsControllerButtonPressed.cs | 28 ++- .../Events/EventArgsControllerButtonReleased.cs | 28 ++- .../Events/EventArgsControllerTriggerPressed.cs | 33 ++- .../Events/EventArgsControllerTriggerReleased.cs | 33 ++- .../Events/EventArgsCurrentLocationChanged.cs | 26 ++- .../Events/EventArgsFarmerChanged.cs | 26 ++- .../Events/EventArgsGameLocationsChanged.cs | 19 +- .../Events/EventArgsIntChanged.cs | 26 ++- .../Events/EventArgsInventoryChanged.cs | 36 +++- .../Events/EventArgsKeyPressed.cs | 21 +- .../Events/EventArgsKeyboardStateChanged.cs | 26 ++- src/StardewModdingAPI/Events/EventArgsLevelUp.cs | 38 +++- .../Events/EventArgsLoadedGameChanged.cs | 21 +- .../Events/EventArgsLocationObjectsChanged.cs | 19 +- .../Events/EventArgsMineLevelChanged.cs | 26 ++- .../Events/EventArgsMouseStateChanged.cs | 26 ++- src/StardewModdingAPI/Events/EventArgsNewDay.cs | 33 ++- .../Events/EventArgsStringChanged.cs | 25 ++- src/StardewModdingAPI/Events/GameEvents.cs | 80 ++++--- src/StardewModdingAPI/Events/GraphicsEvents.cs | 234 ++++++++++++--------- src/StardewModdingAPI/Events/LocationEvents.cs | 34 ++- src/StardewModdingAPI/Events/MenuEvents.cs | 22 +- src/StardewModdingAPI/Events/MineEvents.cs | 18 +- src/StardewModdingAPI/Events/PlayerEvents.cs | 46 +++- src/StardewModdingAPI/Events/TimeEvents.cs | 57 +++-- 30 files changed, 816 insertions(+), 309 deletions(-) create mode 100644 src/StardewModdingAPI.sln.DotSettings (limited to 'src') diff --git a/src/StardewModdingAPI.sln.DotSettings b/src/StardewModdingAPI.sln.DotSettings new file mode 100644 index 00000000..734205d2 --- /dev/null +++ b/src/StardewModdingAPI.sln.DotSettings @@ -0,0 +1,7 @@ + + Field, Property, Event, Method + Field, Property, Event, Method + True + False + UseVarWhenEvident + UseExplicitType \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/ControlEvents.cs b/src/StardewModdingAPI/Events/ControlEvents.cs index cb597cf1..8fb9061d 100644 --- a/src/StardewModdingAPI/Events/ControlEvents.cs +++ b/src/StardewModdingAPI/Events/ControlEvents.cs @@ -4,55 +4,102 @@ using Microsoft.Xna.Framework.Input; namespace StardewModdingAPI.Events { + /// Events raised when the player uses a controller, keyboard, or mouse. public static class ControlEvents { + /********* + ** Events + *********/ + /// Raised when the changes. That happens when the player presses or releases a key. public static event EventHandler KeyboardChanged = delegate { }; + + /// Raised when the player presses a keyboard key. public static event EventHandler KeyPressed = delegate { }; + + /// Raised when the player releases a keyboard key. public static event EventHandler KeyReleased = delegate { }; + + /// Raised when the changes. That happens when the player moves the mouse, scrolls the mouse wheel, or presses/releases a button. public static event EventHandler MouseChanged = delegate { }; + + /// The player pressed a controller button. This event isn't raised for trigger buttons. public static event EventHandler ControllerButtonPressed = delegate { }; + + /// The player released a controller button. This event isn't raised for trigger buttons. public static event EventHandler ControllerButtonReleased = delegate { }; + + /// The player pressed a controller trigger button. public static event EventHandler ControllerTriggerPressed = delegate { }; + + /// The player released a controller trigger button. public static event EventHandler ControllerTriggerReleased = delegate { }; + + /********* + ** Internal methods + *********/ + /// Raise a event. + /// The previous keyboard state. + /// The current keyboard state. internal static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState) { - KeyboardChanged.Invoke(null, new EventArgsKeyboardStateChanged(priorState, newState)); + ControlEvents.KeyboardChanged.Invoke(null, new EventArgsKeyboardStateChanged(priorState, newState)); } + /// Raise a event. + /// The previous mouse state. + /// The current mouse state. internal static void InvokeMouseChanged(MouseState priorState, MouseState newState) { - MouseChanged.Invoke(null, new EventArgsMouseStateChanged(priorState, newState)); + ControlEvents.MouseChanged.Invoke(null, new EventArgsMouseStateChanged(priorState, newState)); } + /// Raise a event. + /// The keyboard button that was pressed. internal static void InvokeKeyPressed(Keys key) { - KeyPressed.Invoke(null, new EventArgsKeyPressed(key)); + ControlEvents.KeyPressed.Invoke(null, new EventArgsKeyPressed(key)); } + /// Raise a event. + /// The keyboard button that was released. internal static void InvokeKeyReleased(Keys key) { - KeyReleased.Invoke(null, new EventArgsKeyPressed(key)); + ControlEvents.KeyReleased.Invoke(null, new EventArgsKeyPressed(key)); } - internal static void InvokeButtonPressed(PlayerIndex playerIndex, Buttons buttons) + /// Raise a event. + /// The player who pressed the button. + /// The controller button that was pressed. + internal static void InvokeButtonPressed(PlayerIndex playerIndex, Buttons button) { - ControllerButtonPressed.Invoke(null, new EventArgsControllerButtonPressed(playerIndex, buttons)); + ControlEvents.ControllerButtonPressed.Invoke(null, new EventArgsControllerButtonPressed(playerIndex, button)); } - internal static void InvokeButtonReleased(PlayerIndex playerIndex, Buttons buttons) + /// Raise a event. + /// The player who released the button. + /// The controller button that was released. + internal static void InvokeButtonReleased(PlayerIndex playerIndex, Buttons button) { - ControllerButtonReleased.Invoke(null, new EventArgsControllerButtonReleased(playerIndex, buttons)); + ControlEvents.ControllerButtonReleased.Invoke(null, new EventArgsControllerButtonReleased(playerIndex, button)); } - internal static void InvokeTriggerPressed(PlayerIndex playerIndex, Buttons buttons, float value) + /// Raise a event. + /// The player who pressed the trigger button. + /// The trigger button that was pressed. + /// The current trigger value. + internal static void InvokeTriggerPressed(PlayerIndex playerIndex, Buttons button, float value) { - ControllerTriggerPressed.Invoke(null, new EventArgsControllerTriggerPressed(playerIndex, buttons, value)); + ControlEvents.ControllerTriggerPressed.Invoke(null, new EventArgsControllerTriggerPressed(playerIndex, button, value)); } - internal static void InvokeTriggerReleased(PlayerIndex playerIndex, Buttons buttons, float value) + /// Raise a event. + /// The player who pressed the trigger button. + /// The trigger button that was pressed. + /// The current trigger value. + internal static void InvokeTriggerReleased(PlayerIndex playerIndex, Buttons button, float value) { - ControllerTriggerReleased.Invoke(null, new EventArgsControllerTriggerReleased(playerIndex, buttons, value)); + ControlEvents.ControllerTriggerReleased.Invoke(null, new EventArgsControllerTriggerReleased(playerIndex, button, value)); } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs b/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs index 6765c8da..708c02e0 100644 --- a/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs @@ -3,15 +3,29 @@ using StardewValley.Menus; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsClickableMenuChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The previous menu. + public IClickableMenu NewMenu { get; private set; } + + /// The current menu. + public IClickableMenu PriorMenu { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous menu. + /// The current menu. public EventArgsClickableMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu) { - NewMenu = newMenu; - PriorMenu = priorMenu; + this.NewMenu = newMenu; + this.PriorMenu = priorMenu; } - - public IClickableMenu NewMenu { get; private set; } - public IClickableMenu PriorMenu { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs b/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs index bdf44285..1a62432f 100644 --- a/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs +++ b/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs @@ -3,13 +3,24 @@ using StardewValley.Menus; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsClickableMenuClosed : EventArgs { + /********* + ** Accessors + *********/ + /// The menu that was closed. + public IClickableMenu PriorMenu { get; private set; } + + + /********* + ** Accessors + *********/ + /// Construct an instance. + /// The menu that was closed. public EventArgsClickableMenuClosed(IClickableMenu priorMenu) { - PriorMenu = priorMenu; + this.PriorMenu = priorMenu; } - - public IClickableMenu PriorMenu { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsCommand.cs b/src/StardewModdingAPI/Events/EventArgsCommand.cs index fd2d4a51..ddf644fb 100644 --- a/src/StardewModdingAPI/Events/EventArgsCommand.cs +++ b/src/StardewModdingAPI/Events/EventArgsCommand.cs @@ -2,13 +2,24 @@ namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsCommand : EventArgs { + /********* + ** Accessors + *********/ + /// The triggered command. + public Command Command { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The triggered command. public EventArgsCommand(Command command) { - Command = command; + this.Command = command; } - - public Command Command { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs b/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs index b51a8a5b..87c96678 100644 --- a/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs +++ b/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs @@ -4,15 +4,29 @@ using Microsoft.Xna.Framework.Input; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsControllerButtonPressed : EventArgs { - public EventArgsControllerButtonPressed(PlayerIndex playerIndex, Buttons buttonPressed) - { - PlayerIndex = playerIndex; - ButtonPressed = buttonPressed; - } - + /********* + ** Accessors + *********/ + /// The player who pressed the button. public PlayerIndex PlayerIndex { get; private set; } + + /// The controller button that was pressed. public Buttons ButtonPressed { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The player who pressed the button. + /// The controller button that was pressed. + public EventArgsControllerButtonPressed(PlayerIndex playerIndex, Buttons button) + { + this.PlayerIndex = playerIndex; + this.ButtonPressed = button; + } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs b/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs index 0164b8d6..cb53b545 100644 --- a/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs +++ b/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs @@ -4,15 +4,29 @@ using Microsoft.Xna.Framework.Input; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsControllerButtonReleased : EventArgs { - public EventArgsControllerButtonReleased(PlayerIndex playerIndex, Buttons buttonReleased) - { - PlayerIndex = playerIndex; - ButtonReleased = buttonReleased; - } - + /********* + ** Accessors + *********/ + /// The player who pressed the button. public PlayerIndex PlayerIndex { get; private set; } + + /// The controller button that was pressed. public Buttons ButtonReleased { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The player who pressed the button. + /// The controller button that was released. + public EventArgsControllerButtonReleased(PlayerIndex playerIndex, Buttons button) + { + this.PlayerIndex = playerIndex; + this.ButtonReleased = button; + } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs b/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs index 1bf4fa46..72b73040 100644 --- a/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs +++ b/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs @@ -4,17 +4,34 @@ using Microsoft.Xna.Framework.Input; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsControllerTriggerPressed : EventArgs { - public EventArgsControllerTriggerPressed(PlayerIndex playerIndex, Buttons buttonPressed, float value) - { - PlayerIndex = playerIndex; - ButtonPressed = buttonPressed; - Value = value; - } - + /********* + ** Accessors + *********/ + /// The player who pressed the button. public PlayerIndex PlayerIndex { get; private set; } + + /// The controller button that was pressed. public Buttons ButtonPressed { get; private set; } + + /// The current trigger value. public float Value { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The player who pressed the trigger button. + /// The trigger button that was pressed. + /// The current trigger value. + public EventArgsControllerTriggerPressed(PlayerIndex playerIndex, Buttons button, float value) + { + this.PlayerIndex = playerIndex; + this.ButtonPressed = button; + this.Value = value; + } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs b/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs index 07a4bcb1..de28a159 100644 --- a/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs +++ b/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs @@ -4,17 +4,34 @@ using Microsoft.Xna.Framework.Input; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsControllerTriggerReleased : EventArgs { - public EventArgsControllerTriggerReleased(PlayerIndex playerIndex, Buttons buttonReleased, float value) - { - PlayerIndex = playerIndex; - ButtonReleased = buttonReleased; - Value = value; - } - + /********* + ** Accessors + *********/ + /// The player who pressed the button. public PlayerIndex PlayerIndex { get; private set; } + + /// The controller button that was released. public Buttons ButtonReleased { get; private set; } + + /// The current trigger value. public float Value { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The player who pressed the trigger button. + /// The trigger button that was released. + /// The current trigger value. + public EventArgsControllerTriggerReleased(PlayerIndex playerIndex, Buttons button, float value) + { + this.PlayerIndex = playerIndex; + this.ButtonReleased = button; + this.Value = value; + } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs b/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs index 53ed1551..443429aa 100644 --- a/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs @@ -3,15 +3,29 @@ using StardewValley; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsCurrentLocationChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The player's previous location. + public GameLocation NewLocation { get; private set; } + + /// The player's current location. + public GameLocation PriorLocation { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The player's previous location. + /// The player's current location. public EventArgsCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) { - NewLocation = newLocation; - PriorLocation = priorLocation; + this.NewLocation = newLocation; + this.PriorLocation = priorLocation; } - - public GameLocation NewLocation { get; private set; } - public GameLocation PriorLocation { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs b/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs index 468d18ee..ba8794b7 100644 --- a/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs @@ -3,15 +3,29 @@ using StardewValley; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsFarmerChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The previous player character. + public Farmer NewFarmer { get; } + + /// The new player character. + public Farmer PriorFarmer { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous player character. + /// The new player character. public EventArgsFarmerChanged(Farmer priorFarmer, Farmer newFarmer) { - NewFarmer = NewFarmer; - PriorFarmer = PriorFarmer; + this.NewFarmer = NewFarmer; + this.PriorFarmer = PriorFarmer; } - - public Farmer NewFarmer { get; } - public Farmer PriorFarmer { get; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs b/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs index 6a55c87a..c68951ce 100644 --- a/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs @@ -4,13 +4,24 @@ using StardewValley; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsGameLocationsChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The current list of game locations. + public List NewLocations { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The current list of game locations. public EventArgsGameLocationsChanged(List newLocations) { - NewLocations = newLocations; + this.NewLocations = newLocations; } - - public List NewLocations { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsIntChanged.cs b/src/StardewModdingAPI/Events/EventArgsIntChanged.cs index c8a6e86d..0ccb9b87 100644 --- a/src/StardewModdingAPI/Events/EventArgsIntChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsIntChanged.cs @@ -2,15 +2,29 @@ namespace StardewModdingAPI.Events { + /// Event arguments for an integer field that changed value. public class EventArgsIntChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The previous value. + public int NewInt { get; } + + /// The current value. + public int PriorInt { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous value. + /// The current value. public EventArgsIntChanged(int priorInt, int newInt) { - NewInt = NewInt; - PriorInt = PriorInt; + this.NewInt = NewInt; + this.PriorInt = PriorInt; } - - public int NewInt { get; } - public int PriorInt { get; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs b/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs index fa929ab5..40c77419 100644 --- a/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs @@ -6,19 +6,37 @@ using StardewValley; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsInventoryChanged : EventArgs { - public EventArgsInventoryChanged(List inventory, List changedItems) - { - Inventory = inventory; - Added = changedItems.Where(n => n.ChangeType == ChangeType.Added).ToList(); - Removed = changedItems.Where(n => n.ChangeType == ChangeType.Removed).ToList(); - QuantityChanged = changedItems.Where(n => n.ChangeType == ChangeType.StackChange).ToList(); - } - + /********* + ** Accessors + *********/ + /// The player's inventory. public List Inventory { get; private set; } + + /// The added items. public List Added { get; private set; } + + /// The removed items. public List Removed { get; private set; } + + /// The items whose stack sizes changed. public List QuantityChanged { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The player's inventory. + /// The inventory changes. + public EventArgsInventoryChanged(List inventory, List changedItems) + { + this.Inventory = inventory; + this.Added = changedItems.Where(n => n.ChangeType == ChangeType.Added).ToList(); + this.Removed = changedItems.Where(n => n.ChangeType == ChangeType.Removed).ToList(); + this.QuantityChanged = changedItems.Where(n => n.ChangeType == ChangeType.StackChange).ToList(); + } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsKeyPressed.cs b/src/StardewModdingAPI/Events/EventArgsKeyPressed.cs index df45e111..82a593be 100644 --- a/src/StardewModdingAPI/Events/EventArgsKeyPressed.cs +++ b/src/StardewModdingAPI/Events/EventArgsKeyPressed.cs @@ -3,13 +3,24 @@ using Microsoft.Xna.Framework.Input; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsKeyPressed : EventArgs { - public EventArgsKeyPressed(Keys keyPressed) + /********* + ** Accessors + *********/ + /// The keyboard button that was pressed. + public Keys KeyPressed { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The keyboard button that was pressed. + public EventArgsKeyPressed(Keys key) { - KeyPressed = keyPressed; + this.KeyPressed = key; } - - public Keys KeyPressed { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsKeyboardStateChanged.cs b/src/StardewModdingAPI/Events/EventArgsKeyboardStateChanged.cs index 784cd197..42daa4db 100644 --- a/src/StardewModdingAPI/Events/EventArgsKeyboardStateChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsKeyboardStateChanged.cs @@ -3,15 +3,29 @@ using Microsoft.Xna.Framework.Input; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsKeyboardStateChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The previous keyboard state. + public KeyboardState NewState { get; private set; } + + /// The current keyboard state. + public KeyboardState PriorState { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous keyboard state. + /// The current keyboard state. public EventArgsKeyboardStateChanged(KeyboardState priorState, KeyboardState newState) { - NewState = newState; - NewState = newState; + this.NewState = newState; + this.NewState = newState; } - - public KeyboardState NewState { get; private set; } - public KeyboardState PriorState { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsLevelUp.cs b/src/StardewModdingAPI/Events/EventArgsLevelUp.cs index 762422c2..826914da 100644 --- a/src/StardewModdingAPI/Events/EventArgsLevelUp.cs +++ b/src/StardewModdingAPI/Events/EventArgsLevelUp.cs @@ -2,25 +2,51 @@ using System; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsLevelUp : EventArgs { + /********* + ** Accessors + *********/ + /// The player skill that leveled up. + public LevelType Type { get; private set; } + + /// The new skill level. + public int NewLevel { get; private set; } + + /// The player skill types. public enum LevelType { + /// The combat skill. Combat, + + /// The farming skill. Farming, + + /// The fishing skill. Fishing, + + /// The foraging skill. Foraging, + + /// The mining skill. Mining, + + /// The luck skill. Luck } + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The player skill that leveled up. + /// The new skill level. public EventArgsLevelUp(LevelType type, int newLevel) { - Type = type; - NewLevel = newLevel; + this.Type = type; + this.NewLevel = newLevel; } - - public LevelType Type { get; private set; } - public int NewLevel { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs b/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs index 1b6e21e2..cd7a366f 100644 --- a/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs @@ -2,13 +2,24 @@ namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsLoadedGameChanged : EventArgs { - public EventArgsLoadedGameChanged(bool loadedGame) + /********* + ** Accessors + *********/ + /// Whether the save has been loaded. This is always true. + public bool LoadedGame { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// Whether the save has been loaded. This is always true. + public EventArgsLoadedGameChanged(bool loaded) { - LoadedGame = loadedGame; + this.LoadedGame = loaded; } - - public bool LoadedGame { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsLocationObjectsChanged.cs b/src/StardewModdingAPI/Events/EventArgsLocationObjectsChanged.cs index 70309192..f708ab6b 100644 --- a/src/StardewModdingAPI/Events/EventArgsLocationObjectsChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsLocationObjectsChanged.cs @@ -5,13 +5,24 @@ using Object = StardewValley.Object; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsLocationObjectsChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The current list of objects in the current location. + public SerializableDictionary NewObjects { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The current list of objects in the current location. public EventArgsLocationObjectsChanged(SerializableDictionary newObjects) { - NewObjects = newObjects; + this.NewObjects = newObjects; } - - public SerializableDictionary NewObjects { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsMineLevelChanged.cs b/src/StardewModdingAPI/Events/EventArgsMineLevelChanged.cs index f95e0ac2..a02921d2 100644 --- a/src/StardewModdingAPI/Events/EventArgsMineLevelChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsMineLevelChanged.cs @@ -2,15 +2,29 @@ namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsMineLevelChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The previous mine level. + public int PreviousMineLevel { get; private set; } + + /// The current mine level. + public int CurrentMineLevel { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous mine level. + /// The current mine level. public EventArgsMineLevelChanged(int previousMineLevel, int currentMineLevel) { - PreviousMineLevel = previousMineLevel; - CurrentMineLevel = currentMineLevel; + this.PreviousMineLevel = previousMineLevel; + this.CurrentMineLevel = currentMineLevel; } - - public int PreviousMineLevel { get; private set; } - public int CurrentMineLevel { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsMouseStateChanged.cs b/src/StardewModdingAPI/Events/EventArgsMouseStateChanged.cs index 145a4445..9117a0c2 100644 --- a/src/StardewModdingAPI/Events/EventArgsMouseStateChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsMouseStateChanged.cs @@ -3,15 +3,29 @@ using Microsoft.Xna.Framework.Input; namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsMouseStateChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The previous mouse state. + public MouseState NewState { get; private set; } + + /// The current mouse state. + public MouseState PriorState { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous mouse state. + /// The current mouse state. public EventArgsMouseStateChanged(MouseState priorState, MouseState newState) { - PriorState = priorState; - NewState = newState; + this.PriorState = priorState; + this.NewState = newState; } - - public MouseState NewState { get; private set; } - public MouseState PriorState { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsNewDay.cs b/src/StardewModdingAPI/Events/EventArgsNewDay.cs index 04d0e389..5088cb5c 100644 --- a/src/StardewModdingAPI/Events/EventArgsNewDay.cs +++ b/src/StardewModdingAPI/Events/EventArgsNewDay.cs @@ -2,17 +2,34 @@ namespace StardewModdingAPI.Events { + /// Event arguments for a event. public class EventArgsNewDay : EventArgs { - public EventArgsNewDay(int prevDay, int curDay, bool newDay) - { - PreviousDay = prevDay; - CurrentDay = curDay; - IsNewDay = newDay; - } - + /********* + ** Accessors + *********/ + /// The previous day value. public int PreviousDay { get; private set; } + + /// The current day value. public int CurrentDay { get; private set; } + + /// Whether the game just started the transition (true) or finished it (false). public bool IsNewDay { get; private set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous day value. + /// The current day value. + /// Whether the game just started the transition (true) or finished it (false). + public EventArgsNewDay(int priorDay, int newDay, bool isTransitioning) + { + this.PreviousDay = priorDay; + this.CurrentDay = newDay; + this.IsNewDay = isTransitioning; + } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/EventArgsStringChanged.cs b/src/StardewModdingAPI/Events/EventArgsStringChanged.cs index 626d77b7..f91951ae 100644 --- a/src/StardewModdingAPI/Events/EventArgsStringChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsStringChanged.cs @@ -2,15 +2,28 @@ namespace StardewModdingAPI.Events { + /// Event arguments for a string field that changed value. public class EventArgsStringChanged : EventArgs { + /********* + ** Accessors + *********/ + /// The previous value. + public string NewString { get; private set; } + + /// The current value. + public string PriorString { get; private set; } + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous value. + /// The current value. public EventArgsStringChanged(string priorString, string newString) { - NewString = newString; - PriorString = priorString; + this.NewString = newString; + this.PriorString = priorString; } - - public string NewString { get; private set; } - public string PriorString { get; private set; } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/GameEvents.cs b/src/StardewModdingAPI/Events/GameEvents.cs index 1a366011..e4a0e08d 100644 --- a/src/StardewModdingAPI/Events/GameEvents.cs +++ b/src/StardewModdingAPI/Events/GameEvents.cs @@ -2,58 +2,61 @@ namespace StardewModdingAPI.Events { + /// Events raised when the game changes state. public static class GameEvents { - public static event EventHandler GameLoaded = delegate { }; + /********* + ** Events + *********/ + /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called during . public static event EventHandler Initialize = delegate { }; + + /// Raised during launch after configuring Stardew Valley, loading it into memory, and opening the game window. The window is still blank by this point. + public static event EventHandler GameLoaded = delegate { }; + + /// Raised before XNA loads or reloads graphics resources. Called during . public static event EventHandler LoadContent = delegate { }; + + /// Raised during the first game update tick. public static event EventHandler FirstUpdateTick = delegate { }; - /// - /// Fires every update (1/60 of a second) - /// + /// Raised when the game updates its state (≈60 times per second). public static event EventHandler UpdateTick = delegate { }; - /// - /// Fires every other update (1/30 of a second) - /// + /// Raised every other tick (≈30 times per second). public static event EventHandler SecondUpdateTick = delegate { }; - /// - /// Fires every fourth update (1/15 of a second) - /// + /// Raised every fourth tick (≈15 times per second). public static event EventHandler FourthUpdateTick = delegate { }; - /// - /// Fires every eighth update (roughly 1/8 of a second) - /// + /// Raised every eighth tick (≈8 times per second). public static event EventHandler EighthUpdateTick = delegate { }; - /// - /// Fires every fifthteenth update (1/4 of a second) - /// + /// Raised every 15th tick (≈4 times per second). public static event EventHandler QuarterSecondTick = delegate { }; - /// - /// Fires every thirtieth update (1/2 of a second) - /// + /// Raised every 30th tick (≈twice per second). public static event EventHandler HalfSecondTick = delegate { }; - /// - /// Fires every sixtieth update (a second) - /// + /// Raised every 60th tick (≈once per second). public static event EventHandler OneSecondTick = delegate { }; + + /********* + ** Internal methods + *********/ + /// Raise a event. internal static void InvokeGameLoaded() { - GameLoaded.Invoke(null, EventArgs.Empty); + GameEvents.GameLoaded.Invoke(null, EventArgs.Empty); } + /// Raise an event. internal static void InvokeInitialize() { try { - Initialize.Invoke(null, EventArgs.Empty); + GameEvents.Initialize.Invoke(null, EventArgs.Empty); } catch (Exception ex) { @@ -61,11 +64,12 @@ namespace StardewModdingAPI.Events } } + /// Raise a event. internal static void InvokeLoadContent() { try { - LoadContent.Invoke(null, EventArgs.Empty); + GameEvents.LoadContent.Invoke(null, EventArgs.Empty); } catch (Exception ex) { @@ -73,11 +77,12 @@ namespace StardewModdingAPI.Events } } + /// Raise an event. internal static void InvokeUpdateTick() { try { - UpdateTick.Invoke(null, EventArgs.Empty); + GameEvents.UpdateTick.Invoke(null, EventArgs.Empty); } catch (Exception ex) { @@ -85,39 +90,46 @@ namespace StardewModdingAPI.Events } } + /// Raise a event. internal static void InvokeSecondUpdateTick() { - SecondUpdateTick.Invoke(null, EventArgs.Empty); + GameEvents.SecondUpdateTick.Invoke(null, EventArgs.Empty); } + /// Raise a event. internal static void InvokeFourthUpdateTick() { - FourthUpdateTick.Invoke(null, EventArgs.Empty); + GameEvents.FourthUpdateTick.Invoke(null, EventArgs.Empty); } + /// Raise a event. internal static void InvokeEighthUpdateTick() { - EighthUpdateTick.Invoke(null, EventArgs.Empty); + GameEvents.EighthUpdateTick.Invoke(null, EventArgs.Empty); } + /// Raise a event. internal static void InvokeQuarterSecondTick() { - QuarterSecondTick.Invoke(null, EventArgs.Empty); + GameEvents.QuarterSecondTick.Invoke(null, EventArgs.Empty); } + /// Raise a event. internal static void InvokeHalfSecondTick() { - HalfSecondTick.Invoke(null, EventArgs.Empty); + GameEvents.HalfSecondTick.Invoke(null, EventArgs.Empty); } + /// Raise a event. internal static void InvokeOneSecondTick() { - OneSecondTick.Invoke(null, EventArgs.Empty); + GameEvents.OneSecondTick.Invoke(null, EventArgs.Empty); } + /// Raise a event. internal static void InvokeFirstUpdateTick() { - FirstUpdateTick.Invoke(null, EventArgs.Empty); + GameEvents.FirstUpdateTick.Invoke(null, EventArgs.Empty); } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/GraphicsEvents.cs b/src/StardewModdingAPI/Events/GraphicsEvents.cs index 1435bc37..fe38c1bb 100644 --- a/src/StardewModdingAPI/Events/GraphicsEvents.cs +++ b/src/StardewModdingAPI/Events/GraphicsEvents.cs @@ -2,161 +2,199 @@ namespace StardewModdingAPI.Events { - /// - /// - /// + /// Events raised during the game's draw loop, when the game is rendering content to the window. public static class GraphicsEvents { - /// - /// Occurs when the form (game) is resized. - /// + /********* + ** Events + *********/ + /**** + ** Generic events + ****/ + /// Raised after the game window is resized. public static event EventHandler Resize = delegate { }; - /// - /// Occurs before anything is drawn. - /// - public static event EventHandler OnPreRenderEvent = delegate { }; + /// Raised when drawing debug information to the screen (when is true). This is called after the sprite batch is begun. If you just want to add debug info, use in your update loop. + public static event EventHandler DrawDebug = delegate { }; - /// - /// Occurs before the GUI is drawn. - /// - public static event EventHandler OnPreRenderGuiEvent = delegate { }; + /// Obsolete. + [Obsolete("Use the other Pre/Post render events instead.")] + public static event EventHandler DrawTick = delegate { }; - /// - /// Occurs after the GUI is drawn. - /// - public static event EventHandler OnPostRenderGuiEvent = delegate { }; + /// Obsolete. + [Obsolete("Use the other Pre/Post render events instead. All of them will automatically be drawn into the render target if needed.")] + public static event EventHandler DrawInRenderTargetTick = delegate { }; + + /**** + ** Main render events + ****/ + /// Raised before drawing everything to the screen during a draw loop. + public static event EventHandler OnPreRenderEvent = delegate { }; - /// - /// Occurs before the HUD is drawn. - /// + /// Raised after drawing everything to the screen during a draw loop. + public static event EventHandler OnPostRenderEvent = delegate { }; + + /**** + ** HUD events + ****/ + /// Raised before drawing the HUD (item toolbar, clock, etc) to the screen. The HUD is available at this point, but not necessarily visible. (For example, the event is raised even if a menu is open.) public static event EventHandler OnPreRenderHudEvent = delegate { }; - /// - /// Occurs after the HUD is drawn. - /// + /// Equivalent to , but invoked even if the HUD isn't available. + public static event EventHandler OnPreRenderHudEventNoCheck = delegate { }; + + /// Raised after drawing the HUD (item toolbar, clock, etc) to the screen. The HUD is available at this point, but not necessarily visible. (For example, the event is raised even if a menu is open.) public static event EventHandler OnPostRenderHudEvent = delegate { }; - /// - /// Occurs after everything is drawn. - /// - public static event EventHandler OnPostRenderEvent = delegate { }; + /// Equivalent to , but invoked even if the HUD isn't available. + public static event EventHandler OnPostRenderHudEventNoCheck = delegate { }; - /// - /// Occurs before the GUI is drawn. Does not check for conditional statements. - /// - public static event EventHandler OnPreRenderGuiEventNoCheck = delegate { }; + /**** + ** GUI events + ****/ + /// Raised before drawing a menu to the screen during a draw loop. This includes the game's internal menus like the title screen. + public static event EventHandler OnPreRenderGuiEvent = delegate { }; - /// - /// Occurs after the GUI is drawn. Does not check for conditional statements. - /// - public static event EventHandler OnPostRenderGuiEventNoCheck = delegate { }; + /// Equivalent to , but invoked even if there's no menu being drawn. + public static event EventHandler OnPreRenderGuiEventNoCheck = delegate { }; - /// - /// Occurs before the HUD is drawn. Does not check for conditional statements. - /// - public static event EventHandler OnPreRenderHudEventNoCheck = delegate { }; + /// Raised after drawing a menu to the screen during a draw loop. This includes the game's internal menus like the title screen. + public static event EventHandler OnPostRenderGuiEvent = delegate { }; - /// - /// Occurs after the HUD is drawn. Does not check for conditional statements. - /// - public static event EventHandler OnPostRenderHudEventNoCheck = delegate { }; + /// Equivalent to , but invoked even if there's no menu being drawn. + public static event EventHandler OnPostRenderGuiEventNoCheck = delegate { }; - /// - /// Draws when SGame.Debug is true. F3 toggles this. - /// Game1.spriteBatch.Begin() is pre-called. - /// Do not make end or begin calls to the spritebatch. - /// If you are only trying to add debug information, use SGame.DebugMessageQueue in your Update loop. - /// - public static event EventHandler DrawDebug = delegate { }; - internal static void InvokeDrawDebug(object sender, EventArgs e) + /********* + ** Internal methods + *********/ + /**** + ** Generic events + ****/ + /// Raise a event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeResize(object sender, EventArgs e) { - DrawDebug.Invoke(sender, e); + GraphicsEvents.Resize.Invoke(sender, e); } - internal static void InvokeOnPreRenderEvent(object sender, EventArgs e) + /// Raise a event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeDrawDebug(object sender, EventArgs e) { - OnPreRenderEvent.Invoke(sender, e); + GraphicsEvents.DrawDebug.Invoke(sender, e); } - internal static void InvokeOnPreRenderGuiEvent(object sender, EventArgs e) + /// Raise a event. + [Obsolete("Should not be used.")] + public static void InvokeDrawTick() { - OnPreRenderGuiEvent.Invoke(sender, e); + try + { + GraphicsEvents.DrawTick.Invoke(null, EventArgs.Empty); + } + catch (Exception ex) + { + Log.AsyncR("An exception occured in a Mod's DrawTick: " + ex); + } } - internal static void InvokeOnPostRenderGuiEvent(object sender, EventArgs e) + /// Raise a event. + [Obsolete("Should not be used.")] + public static void InvokeDrawInRenderTargetTick() { - OnPostRenderGuiEvent.Invoke(sender, e); + GraphicsEvents.DrawInRenderTargetTick.Invoke(null, EventArgs.Empty); } - internal static void InvokeOnPreRenderHudEvent(object sender, EventArgs e) + /**** + ** Main render events + ****/ + /// Raise an event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeOnPreRenderEvent(object sender, EventArgs e) { - OnPreRenderHudEvent.Invoke(sender, e); + GraphicsEvents.OnPreRenderEvent.Invoke(sender, e); } - internal static void InvokeOnPostRenderHudEvent(object sender, EventArgs e) + /// Raise an event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeOnPostRenderEvent(object sender, EventArgs e) { - OnPostRenderHudEvent.Invoke(sender, e); + GraphicsEvents.OnPostRenderEvent.Invoke(sender, e); } - internal static void InvokeOnPostRenderEvent(object sender, EventArgs e) + /**** + ** HUD events + ****/ + /// Raise an event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeOnPreRenderGuiEvent(object sender, EventArgs e) { - OnPostRenderEvent.Invoke(sender, e); + GraphicsEvents.OnPreRenderGuiEvent.Invoke(sender, e); } + /// Raise an event. + /// The object which raised the event. + /// The event arguments. internal static void InvokeOnPreRenderGuiEventNoCheck(object sender, EventArgs e) { - OnPreRenderGuiEventNoCheck.Invoke(sender, e); + GraphicsEvents.OnPreRenderGuiEventNoCheck.Invoke(sender, e); } - internal static void InvokeOnPostRenderGuiEventNoCheck(object sender, EventArgs e) + /// Raise an event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeOnPostRenderGuiEvent(object sender, EventArgs e) { - OnPostRenderGuiEventNoCheck.Invoke(sender, e); + GraphicsEvents.OnPostRenderGuiEvent.Invoke(sender, e); } - internal static void InvokeOnPreRenderHudEventNoCheck(object sender, EventArgs e) + /// Raise an event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeOnPostRenderGuiEventNoCheck(object sender, EventArgs e) { - OnPreRenderHudEventNoCheck.Invoke(sender, e); + GraphicsEvents.OnPostRenderGuiEventNoCheck.Invoke(sender, e); } - internal static void InvokeOnPostRenderHudEventNoCheck(object sender, EventArgs e) + /**** + ** GUI events + ****/ + /// Raise an event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeOnPreRenderHudEvent(object sender, EventArgs e) { - OnPostRenderHudEventNoCheck.Invoke(sender, e); + GraphicsEvents.OnPreRenderHudEvent.Invoke(sender, e); } - internal static void InvokeResize(object sender, EventArgs e) + /// Raise an event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeOnPreRenderHudEventNoCheck(object sender, EventArgs e) { - Resize.Invoke(sender, e); + GraphicsEvents.OnPreRenderHudEventNoCheck.Invoke(sender, e); } - #region To Remove - - [Obsolete("Use the other Pre/Post render events instead.")] - public static event EventHandler DrawTick = delegate { }; - - [Obsolete("Use the other Pre/Post render events instead. All of them will automatically be drawn into the render target if needed.")] - public static event EventHandler DrawInRenderTargetTick = delegate { }; - - [Obsolete("Should not be used.")] - public static void InvokeDrawTick() + /// Raise an event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeOnPostRenderHudEvent(object sender, EventArgs e) { - try - { - DrawTick.Invoke(null, EventArgs.Empty); - } - catch (Exception ex) - { - Log.AsyncR("An exception occured in a Mod's DrawTick: " + ex); - } + GraphicsEvents.OnPostRenderHudEvent.Invoke(sender, e); } - [Obsolete("Should not be used.")] - public static void InvokeDrawInRenderTargetTick() + /// Raise an event. + /// The object which raised the event. + /// The event arguments. + internal static void InvokeOnPostRenderHudEventNoCheck(object sender, EventArgs e) { - DrawInRenderTargetTick.Invoke(null, EventArgs.Empty); + GraphicsEvents.OnPostRenderHudEventNoCheck.Invoke(sender, e); } - - #endregion } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/LocationEvents.cs b/src/StardewModdingAPI/Events/LocationEvents.cs index b4b4ac33..af2eb400 100644 --- a/src/StardewModdingAPI/Events/LocationEvents.cs +++ b/src/StardewModdingAPI/Events/LocationEvents.cs @@ -6,25 +6,45 @@ using Object = StardewValley.Object; namespace StardewModdingAPI.Events { + /// Events raised when the player transitions between game locations, a location is added or removed, or the objects in the current location change. public static class LocationEvents { + /********* + ** Events + *********/ + /// Raised after the player warps to a new location. + public static event EventHandler CurrentLocationChanged = delegate { }; + + /// Raised after a game location is added or removed. public static event EventHandler LocationsChanged = delegate { }; + + /// Raised after the list of objects in the current location changes (e.g. an object is added or removed). public static event EventHandler LocationObjectsChanged = delegate { }; - public static event EventHandler CurrentLocationChanged = delegate { }; - internal static void InvokeLocationsChanged(List newLocations) + + /********* + ** Internal methods + *********/ + /// Raise a event. + /// The player's previous location. + /// The player's current location. + internal static void InvokeCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) { - LocationsChanged.Invoke(null, new EventArgsGameLocationsChanged(newLocations)); + LocationEvents.CurrentLocationChanged.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, newLocation)); } - internal static void InvokeCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) + /// Raise a event. + /// The current list of game locations. + internal static void InvokeLocationsChanged(List newLocations) { - CurrentLocationChanged.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, newLocation)); + LocationEvents.LocationsChanged.Invoke(null, new EventArgsGameLocationsChanged(newLocations)); } + /// Raise a event. + /// The current list of objects in the current location. internal static void InvokeOnNewLocationObject(SerializableDictionary newObjects) { - LocationObjectsChanged.Invoke(null, new EventArgsLocationObjectsChanged(newObjects)); + LocationEvents.LocationObjectsChanged.Invoke(null, new EventArgsLocationObjectsChanged(newObjects)); } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/MenuEvents.cs b/src/StardewModdingAPI/Events/MenuEvents.cs index fdd96f00..59f03449 100644 --- a/src/StardewModdingAPI/Events/MenuEvents.cs +++ b/src/StardewModdingAPI/Events/MenuEvents.cs @@ -3,19 +3,35 @@ using StardewValley.Menus; namespace StardewModdingAPI.Events { + /// Events raised when a game menu is opened or closed (including internal menus like the title screen). public static class MenuEvents { + /********* + ** Events + *********/ + /// Raised after a game menu is opened or replaced with another menu. This event is not invoked when a menu is closed. public static event EventHandler MenuChanged = delegate { }; + + /// Raised after a game menu is closed. public static event EventHandler MenuClosed = delegate { }; + + /********* + ** Internal methods + *********/ + /// Raise a event. + /// The previous menu. + /// The current menu. internal static void InvokeMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu) { - MenuChanged.Invoke(null, new EventArgsClickableMenuChanged(priorMenu, newMenu)); + MenuEvents.MenuChanged.Invoke(null, new EventArgsClickableMenuChanged(priorMenu, newMenu)); } + /// Raise a event. + /// The menu that was closed. internal static void InvokeMenuClosed(IClickableMenu priorMenu) { - MenuClosed.Invoke(null, new EventArgsClickableMenuClosed(priorMenu)); + MenuEvents.MenuClosed.Invoke(null, new EventArgsClickableMenuClosed(priorMenu)); } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/MineEvents.cs b/src/StardewModdingAPI/Events/MineEvents.cs index b9c3070c..6121abf4 100644 --- a/src/StardewModdingAPI/Events/MineEvents.cs +++ b/src/StardewModdingAPI/Events/MineEvents.cs @@ -2,13 +2,25 @@ namespace StardewModdingAPI.Events { + /// Events raised when something happens in the mines. public static class MineEvents { + /********* + ** Events + *********/ + /// Raised after the player warps to a new level of the mine. public static event EventHandler MineLevelChanged = delegate { }; - internal static void InvokeMineLevelChanged(int previousMinelevel, int currentMineLevel) + + /********* + ** Internal methods + *********/ + /// Raise a event. + /// The previous mine level. + /// The current mine level. + internal static void InvokeMineLevelChanged(int previousMineLevel, int currentMineLevel) { - MineLevelChanged.Invoke(null, new EventArgsMineLevelChanged(previousMinelevel, currentMineLevel)); + MineEvents.MineLevelChanged.Invoke(null, new EventArgsMineLevelChanged(previousMineLevel, currentMineLevel)); } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/PlayerEvents.cs b/src/StardewModdingAPI/Events/PlayerEvents.cs index 910f3c96..71b43e71 100644 --- a/src/StardewModdingAPI/Events/PlayerEvents.cs +++ b/src/StardewModdingAPI/Events/PlayerEvents.cs @@ -5,31 +5,57 @@ using StardewValley; namespace StardewModdingAPI.Events { + /// Events raised when the player data changes. public static class PlayerEvents { + /********* + ** Events + *********/ + /// Raised after the player loads a saved game. + public static event EventHandler LoadedGame = delegate { }; + + /// Raised after the game assigns a new player character. This happens just before ; it's unclear how this would happen any other time. public static event EventHandler FarmerChanged = delegate { }; + + /// Raised after the player's inventory changes in any way (added or removed item, sorted, etc). public static event EventHandler InventoryChanged = delegate { }; + + /// Raised after the player levels up a skill. This happens as soon as they level up, not when the game notifies the player after their character goes to bed. public static event EventHandler LeveledUp = delegate { }; - public static event EventHandler LoadedGame = delegate { }; - internal static void InvokeFarmerChanged(Farmer priorFarmer, Farmer newFarmer) + + /********* + ** Internal methods + *********/ + /// Raise a event. + /// Whether the save has been loaded. This is always true. + internal static void InvokeLoadedGame(EventArgsLoadedGameChanged loaded) { - FarmerChanged.Invoke(null, new EventArgsFarmerChanged(priorFarmer, newFarmer)); + PlayerEvents.LoadedGame.Invoke(null, loaded); } - internal static void InvokeInventoryChanged(List inventory, List changedItems) + /// Raise a event. + /// The previous player character. + /// The new player character. + internal static void InvokeFarmerChanged(Farmer priorFarmer, Farmer newFarmer) { - InventoryChanged.Invoke(null, new EventArgsInventoryChanged(inventory, changedItems)); + PlayerEvents.FarmerChanged.Invoke(null, new EventArgsFarmerChanged(priorFarmer, newFarmer)); } - internal static void InvokeLeveledUp(EventArgsLevelUp.LevelType type, int newLevel) + /// Raise an event. + /// The player's inventory. + /// The inventory changes. + internal static void InvokeInventoryChanged(List inventory, List changedItems) { - LeveledUp.Invoke(null, new EventArgsLevelUp(type, newLevel)); + PlayerEvents.InventoryChanged.Invoke(null, new EventArgsInventoryChanged(inventory, changedItems)); } - internal static void InvokeLoadedGame(EventArgsLoadedGameChanged loaded) + /// Rase a event. + /// The player skill that leveled up. + /// The new skill level. + internal static void InvokeLeveledUp(EventArgsLevelUp.LevelType type, int newLevel) { - LoadedGame.Invoke(null, loaded); + PlayerEvents.LeveledUp.Invoke(null, new EventArgsLevelUp(type, newLevel)); } } -} \ No newline at end of file +} diff --git a/src/StardewModdingAPI/Events/TimeEvents.cs b/src/StardewModdingAPI/Events/TimeEvents.cs index 42fa6ce2..ee83a267 100644 --- a/src/StardewModdingAPI/Events/TimeEvents.cs +++ b/src/StardewModdingAPI/Events/TimeEvents.cs @@ -2,41 +2,70 @@ namespace StardewModdingAPI.Events { + /// Events raised when the in-game date or time changes. public static class TimeEvents { + /********* + ** Events + *********/ + /// Raised after the in-game clock changes. public static event EventHandler TimeOfDayChanged = delegate { }; + + /// Raised after the day-of-month value changes, including when loading a save (unlike ). public static event EventHandler DayOfMonthChanged = delegate { }; + + /// Raised after the year value changes. public static event EventHandler YearOfGameChanged = delegate { }; + + /// Raised after the season value changes. public static event EventHandler SeasonOfYearChanged = delegate { }; - /// - /// Occurs when Game1.newDay changes. True directly before saving, and False directly after. - /// + /// Raised when the player is transitioning to a new day and the game is performing its day update logic. This event is triggered twice: once after the game starts transitioning, and again after it finishes. public static event EventHandler OnNewDay = delegate { }; - internal static void InvokeTimeOfDayChanged(int priorInt, int newInt) + + /********* + ** Internal methods + *********/ + /// Raise a event. + /// The previous time in military time format (e.g. 6:00pm is 1800). + /// The current time in military time format (e.g. 6:10pm is 1810). + internal static void InvokeTimeOfDayChanged(int priorTime, int newTime) { - TimeOfDayChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); + TimeEvents.TimeOfDayChanged.Invoke(null, new EventArgsIntChanged(priorTime, newTime)); } - internal static void InvokeDayOfMonthChanged(int priorInt, int newInt) + /// Raise a event. + /// The previous day value. + /// The current day value. + internal static void InvokeDayOfMonthChanged(int priorDay, int newDay) { - DayOfMonthChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); + TimeEvents.DayOfMonthChanged.Invoke(null, new EventArgsIntChanged(priorDay, newDay)); } - internal static void InvokeYearOfGameChanged(int priorInt, int newInt) + /// Raise a event. + /// The previous year value. + /// The current year value. + internal static void InvokeYearOfGameChanged(int priorYear, int newYear) { - YearOfGameChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); + TimeEvents.YearOfGameChanged.Invoke(null, new EventArgsIntChanged(priorYear, newYear)); } - internal static void InvokeSeasonOfYearChanged(string priorString, string newString) + /// Raise a event. + /// The previous season name. + /// The current season name. + internal static void InvokeSeasonOfYearChanged(string priorSeason, string newSeason) { - SeasonOfYearChanged.Invoke(null, new EventArgsStringChanged(priorString, newString)); + TimeEvents.SeasonOfYearChanged.Invoke(null, new EventArgsStringChanged(priorSeason, newSeason)); } - internal static void InvokeOnNewDay(int priorInt, int newInt, bool newDay) + /// Raise a event. + /// The previous day value. + /// The current day value. + /// Whether the game just started the transition (true) or finished it (false). + internal static void InvokeOnNewDay(int priorDay, int newDay, bool isTransitioning) { - OnNewDay.Invoke(null, new EventArgsNewDay(priorInt, newInt, newDay)); + TimeEvents.OnNewDay.Invoke(null, new EventArgsNewDay(priorDay, newDay, isTransitioning)); } } -} \ No newline at end of file +} -- cgit