From afef5648ca512d0c151a87becbb85cd14494717b Mon Sep 17 00:00:00 2001 From: ClxS Date: Fri, 4 Mar 2016 14:05:36 +0000 Subject: Refactored all of the events into their own categories --- StardewModdingAPI/Command.cs | 3 +- StardewModdingAPI/EventArgs.cs | 126 ------------------------ StardewModdingAPI/Events.cs | 153 ----------------------------- StardewModdingAPI/Events/Controls.cs | 31 ++++++ StardewModdingAPI/Events/EventArgs.cs | 126 ++++++++++++++++++++++++ StardewModdingAPI/Events/Game.cs | 57 +++++++++++ StardewModdingAPI/Events/Graphics.cs | 31 ++++++ StardewModdingAPI/Events/Location.cs | 32 ++++++ StardewModdingAPI/Events/Menu.cs | 19 ++++ StardewModdingAPI/Events/Mine.cs | 12 +++ StardewModdingAPI/Events/Player.cs | 19 ++++ StardewModdingAPI/Events/Time.cs | 36 +++++++ StardewModdingAPI/Inheritance/SGame.cs | 32 +++--- StardewModdingAPI/Program.cs | 11 ++- StardewModdingAPI/StardewModdingAPI.csproj | 14 ++- 15 files changed, 398 insertions(+), 304 deletions(-) delete mode 100644 StardewModdingAPI/EventArgs.cs delete mode 100644 StardewModdingAPI/Events.cs create mode 100644 StardewModdingAPI/Events/Controls.cs create mode 100644 StardewModdingAPI/Events/EventArgs.cs create mode 100644 StardewModdingAPI/Events/Game.cs create mode 100644 StardewModdingAPI/Events/Graphics.cs create mode 100644 StardewModdingAPI/Events/Location.cs create mode 100644 StardewModdingAPI/Events/Menu.cs create mode 100644 StardewModdingAPI/Events/Mine.cs create mode 100644 StardewModdingAPI/Events/Player.cs create mode 100644 StardewModdingAPI/Events/Time.cs (limited to 'StardewModdingAPI') diff --git a/StardewModdingAPI/Command.cs b/StardewModdingAPI/Command.cs index bb18a9a6..4bfc7564 100644 --- a/StardewModdingAPI/Command.cs +++ b/StardewModdingAPI/Command.cs @@ -1,4 +1,5 @@ -using System; +using StardewModdingAPI.Events; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/StardewModdingAPI/EventArgs.cs b/StardewModdingAPI/EventArgs.cs deleted file mode 100644 index cb7324c9..00000000 --- a/StardewModdingAPI/EventArgs.cs +++ /dev/null @@ -1,126 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; -using StardewValley; -using StardewValley.Menus; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardewModdingAPI -{ - public class EventArgsKeyboardStateChanged : EventArgs - { - public EventArgsKeyboardStateChanged(KeyboardState priorState, KeyboardState newState) - { - NewState = newState; - NewState = newState; - } - public KeyboardState NewState { get; private set; } - public KeyboardState PriorState { get; private set; } - } - - public class EventArgsKeyPressed : EventArgs - { - public EventArgsKeyPressed(Keys keyPressed) - { - KeyPressed = keyPressed; - } - public Keys KeyPressed { get; private set; } - } - - public class EventArgsMouseStateChanged : EventArgs - { - public EventArgsMouseStateChanged(MouseState priorState, MouseState newState) - { - NewState = newState; - NewState = newState; - } - public MouseState NewState { get; private set; } - public MouseState PriorState { get; private set; } - } - - public class EventArgsClickableMenuChanged : EventArgs - { - public EventArgsClickableMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu) - { - NewMenu = newMenu; - PriorMenu = priorMenu; - } - public IClickableMenu NewMenu { get; private set; } - public IClickableMenu PriorMenu { get; private set; } - } - - public class EventArgsGameLocationsChanged : EventArgs - { - public EventArgsGameLocationsChanged(List newLocations) - { - NewLocations = newLocations; - } - public List NewLocations { get; private set; } - } - - public class EventArgsLocationObjectsChanged : EventArgs - { - public EventArgsLocationObjectsChanged(SerializableDictionary newObjects) - { - NewObjects = newObjects; - } - public SerializableDictionary NewObjects { get; private set; } - } - - public class EventArgsCurrentLocationChanged : EventArgs - { - public EventArgsCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) - { - NewLocation = newLocation; - PriorLocation = priorLocation; - } - public GameLocation NewLocation { get; private set; } - public GameLocation PriorLocation { get; private set; } - } - - public class EventArgsFarmerChanged : EventArgs - { - public EventArgsFarmerChanged(Farmer priorFarmer, Farmer newFarmer) - { - NewFarmer = NewFarmer; - PriorFarmer = PriorFarmer; - } - public Farmer NewFarmer { get; private set; } - public Farmer PriorFarmer { get; private set; } - } - - public class EventArgsIntChanged : EventArgs - { - public EventArgsIntChanged(Int32 priorInt, Int32 newInt) - { - NewInt = NewInt; - PriorInt = PriorInt; - } - public Int32 NewInt { get; private set; } - public Int32 PriorInt { get; private set; } - } - - public class EventArgsStringChanged : EventArgs - { - public EventArgsStringChanged(String priorString, String newString) - { - NewString = newString; - PriorString = priorString; - } - public String NewString { get; private set; } - public String PriorString { get; private set; } - } - - public class EventArgsCommand : EventArgs - { - public EventArgsCommand(Command command) - { - Command = command; - } - public Command Command { get; private set; } - } -} - diff --git a/StardewModdingAPI/Events.cs b/StardewModdingAPI/Events.cs deleted file mode 100644 index de1c24bc..00000000 --- a/StardewModdingAPI/Events.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework.Input; -using StardewValley; -using StardewValley.Menus; -using Microsoft.Xna.Framework; - -namespace StardewModdingAPI -{ - public static class Events - { - public static event EventHandler GameLoaded = delegate { }; - public static event EventHandler Initialize = delegate { }; - public static event EventHandler LoadContent = delegate { }; - public static event EventHandler UpdateTick = delegate { }; - public static event EventHandler DrawTick = delegate { }; - - public static event EventHandler KeyboardChanged = delegate { }; - public static event EventHandler KeyPressed = delegate { }; - public static event EventHandler MouseChanged = delegate { }; - public static event EventHandler MenuChanged = delegate { }; - public static event EventHandler LocationsChanged = delegate { }; - public static event EventHandler LocationObjectsChanged = delegate { }; - public static event EventHandler CurrentLocationChanged = delegate { }; - public static event EventHandler Resize = delegate { }; - public static event EventHandler FarmerChanged = delegate { }; - public static event EventHandler TimeOfDayChanged = delegate { }; - public static event EventHandler DayOfMonthChanged = delegate { }; - public static event EventHandler YearOfGameChanged = delegate { }; - public static event EventHandler SeasonOfYearChanged = delegate { }; - - public static void InvokeGameLoaded() - { - GameLoaded.Invoke(null, EventArgs.Empty); - } - - public static void InvokeInitialize() - { - try - { - Initialize.Invoke(null, EventArgs.Empty); - } - catch (Exception ex) - { - Program.LogError("An exception occured in XNA Initialize: " + ex.ToString()); - } - } - - public static void InvokeLoadContent() - { - try - { - LoadContent.Invoke(null, EventArgs.Empty); - } - catch (Exception ex) - { - Program.LogError("An exception occured in XNA LoadContent: " + ex.ToString()); - } - } - - public static void InvokeUpdateTick() - { - try - { - UpdateTick.Invoke(null, EventArgs.Empty); - } - catch (Exception ex) - { - Program.LogError("An exception occured in XNA UpdateTick: " + ex.ToString()); - } - } - - public static void InvokeDrawTick() - { - try - { - DrawTick.Invoke(null, EventArgs.Empty); - } - catch (Exception ex) - { - Program.LogError("An exception occured in XNA DrawTick: " + ex.ToString()); - } - } - - public static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState) - { - KeyboardChanged.Invoke(null, new EventArgsKeyboardStateChanged(priorState, newState)); - } - - public static void InvokeMouseChanged(MouseState priorState, MouseState newState) - { - MouseChanged.Invoke(null, new EventArgsMouseStateChanged(priorState, newState)); - } - - public static void InvokeKeyPressed(Keys key) - { - KeyPressed.Invoke(null, new EventArgsKeyPressed(key)); - } - - public static void InvokeMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu) - { - MenuChanged.Invoke(null, new EventArgsClickableMenuChanged(priorMenu, newMenu)); - } - - public static void InvokeLocationsChanged(List newLocations) - { - LocationsChanged.Invoke(null, new EventArgsGameLocationsChanged(newLocations)); - } - - public static void InvokeCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) - { - CurrentLocationChanged.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, newLocation)); - } - - public static void InvokeResize(object sender, EventArgs e) - { - Resize.Invoke(sender, e); - } - - public static void InvokeFarmerChanged(Farmer priorFarmer, Farmer newFarmer) - { - FarmerChanged.Invoke(null, new EventArgsFarmerChanged(priorFarmer, newFarmer)); - } - - public static void InvokeTimeOfDayChanged(Int32 priorInt, Int32 newInt) - { - TimeOfDayChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); - } - - public static void InvokeDayOfMonthChanged(Int32 priorInt, Int32 newInt) - { - DayOfMonthChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); - } - - public static void InvokeYearOfGameChanged(Int32 priorInt, Int32 newInt) - { - YearOfGameChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); - } - - public static void InvokeSeasonOfYearChanged(String priorString, String newString) - { - SeasonOfYearChanged.Invoke(null, new EventArgsStringChanged(priorString, newString)); - } - - internal static void InvokeOnNewLocationObject(SerializableDictionary newObjects) - { - LocationObjectsChanged.Invoke(null, new EventArgsLocationObjectsChanged(newObjects)); - } - } -} diff --git a/StardewModdingAPI/Events/Controls.cs b/StardewModdingAPI/Events/Controls.cs new file mode 100644 index 00000000..ace890ca --- /dev/null +++ b/StardewModdingAPI/Events/Controls.cs @@ -0,0 +1,31 @@ +using Microsoft.Xna.Framework.Input; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + public static class ControlEvents + { + public static event EventHandler KeyboardChanged = delegate { }; + public static event EventHandler KeyPressed = delegate { }; + public static event EventHandler MouseChanged = delegate { }; + + public static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState) + { + KeyboardChanged.Invoke(null, new EventArgsKeyboardStateChanged(priorState, newState)); + } + + public static void InvokeMouseChanged(MouseState priorState, MouseState newState) + { + MouseChanged.Invoke(null, new EventArgsMouseStateChanged(priorState, newState)); + } + + public static void InvokeKeyPressed(Keys key) + { + KeyPressed.Invoke(null, new EventArgsKeyPressed(key)); + } + } +} diff --git a/StardewModdingAPI/Events/EventArgs.cs b/StardewModdingAPI/Events/EventArgs.cs new file mode 100644 index 00000000..c9055f84 --- /dev/null +++ b/StardewModdingAPI/Events/EventArgs.cs @@ -0,0 +1,126 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input; +using StardewValley; +using StardewValley.Menus; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + public class EventArgsKeyboardStateChanged : EventArgs + { + public EventArgsKeyboardStateChanged(KeyboardState priorState, KeyboardState newState) + { + NewState = newState; + NewState = newState; + } + public KeyboardState NewState { get; private set; } + public KeyboardState PriorState { get; private set; } + } + + public class EventArgsKeyPressed : EventArgs + { + public EventArgsKeyPressed(Keys keyPressed) + { + KeyPressed = keyPressed; + } + public Keys KeyPressed { get; private set; } + } + + public class EventArgsMouseStateChanged : EventArgs + { + public EventArgsMouseStateChanged(MouseState priorState, MouseState newState) + { + NewState = newState; + NewState = newState; + } + public MouseState NewState { get; private set; } + public MouseState PriorState { get; private set; } + } + + public class EventArgsClickableMenuChanged : EventArgs + { + public EventArgsClickableMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu) + { + NewMenu = newMenu; + PriorMenu = priorMenu; + } + public IClickableMenu NewMenu { get; private set; } + public IClickableMenu PriorMenu { get; private set; } + } + + public class EventArgsGameLocationsChanged : EventArgs + { + public EventArgsGameLocationsChanged(List newLocations) + { + NewLocations = newLocations; + } + public List NewLocations { get; private set; } + } + + public class EventArgsLocationObjectsChanged : EventArgs + { + public EventArgsLocationObjectsChanged(SerializableDictionary newObjects) + { + NewObjects = newObjects; + } + public SerializableDictionary NewObjects { get; private set; } + } + + public class EventArgsCurrentLocationChanged : EventArgs + { + public EventArgsCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) + { + NewLocation = newLocation; + PriorLocation = priorLocation; + } + public GameLocation NewLocation { get; private set; } + public GameLocation PriorLocation { get; private set; } + } + + public class EventArgsFarmerChanged : EventArgs + { + public EventArgsFarmerChanged(Farmer priorFarmer, Farmer newFarmer) + { + NewFarmer = NewFarmer; + PriorFarmer = PriorFarmer; + } + public Farmer NewFarmer { get; private set; } + public Farmer PriorFarmer { get; private set; } + } + + public class EventArgsIntChanged : EventArgs + { + public EventArgsIntChanged(Int32 priorInt, Int32 newInt) + { + NewInt = NewInt; + PriorInt = PriorInt; + } + public Int32 NewInt { get; private set; } + public Int32 PriorInt { get; private set; } + } + + public class EventArgsStringChanged : EventArgs + { + public EventArgsStringChanged(String priorString, String newString) + { + NewString = newString; + PriorString = priorString; + } + public String NewString { get; private set; } + public String PriorString { get; private set; } + } + + public class EventArgsCommand : EventArgs + { + public EventArgsCommand(Command command) + { + Command = command; + } + public Command Command { get; private set; } + } +} + diff --git a/StardewModdingAPI/Events/Game.cs b/StardewModdingAPI/Events/Game.cs new file mode 100644 index 00000000..d155ba2e --- /dev/null +++ b/StardewModdingAPI/Events/Game.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + public static class GameEvents + { + public static event EventHandler GameLoaded = delegate { }; + public static event EventHandler Initialize = delegate { }; + public static event EventHandler LoadContent = delegate { }; + public static event EventHandler UpdateTick = delegate { }; + + public static void InvokeGameLoaded() + { + GameLoaded.Invoke(null, EventArgs.Empty); + } + + public static void InvokeInitialize() + { + try + { + Initialize.Invoke(null, EventArgs.Empty); + } + catch (Exception ex) + { + Program.LogError("An exception occured in XNA Initialize: " + ex.ToString()); + } + } + + public static void InvokeLoadContent() + { + try + { + LoadContent.Invoke(null, EventArgs.Empty); + } + catch (Exception ex) + { + Program.LogError("An exception occured in XNA LoadContent: " + ex.ToString()); + } + } + + public static void InvokeUpdateTick() + { + try + { + UpdateTick.Invoke(null, EventArgs.Empty); + } + catch (Exception ex) + { + Program.LogError("An exception occured in XNA UpdateTick: " + ex.ToString()); + } + } + } +} diff --git a/StardewModdingAPI/Events/Graphics.cs b/StardewModdingAPI/Events/Graphics.cs new file mode 100644 index 00000000..62bffe82 --- /dev/null +++ b/StardewModdingAPI/Events/Graphics.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + public static class GraphicsEvents + { + public static event EventHandler Resize = delegate { }; + public static event EventHandler DrawTick = delegate { }; + + public static void InvokeDrawTick() + { + try + { + DrawTick.Invoke(null, EventArgs.Empty); + } + catch (Exception ex) + { + Program.LogError("An exception occured in XNA DrawTick: " + ex.ToString()); + } + } + + public static void InvokeResize(object sender, EventArgs e) + { + Resize.Invoke(sender, e); + } + } +} diff --git a/StardewModdingAPI/Events/Location.cs b/StardewModdingAPI/Events/Location.cs new file mode 100644 index 00000000..c347659b --- /dev/null +++ b/StardewModdingAPI/Events/Location.cs @@ -0,0 +1,32 @@ +using Microsoft.Xna.Framework; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + public static class LocationEvents + { + public static event EventHandler LocationsChanged = delegate { }; + public static event EventHandler LocationObjectsChanged = delegate { }; + public static event EventHandler CurrentLocationChanged = delegate { }; + + public static void InvokeLocationsChanged(List newLocations) + { + LocationsChanged.Invoke(null, new EventArgsGameLocationsChanged(newLocations)); + } + + public static void InvokeCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) + { + CurrentLocationChanged.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, newLocation)); + } + + internal static void InvokeOnNewLocationObject(SerializableDictionary newObjects) + { + LocationObjectsChanged.Invoke(null, new EventArgsLocationObjectsChanged(newObjects)); + } + } +} diff --git a/StardewModdingAPI/Events/Menu.cs b/StardewModdingAPI/Events/Menu.cs new file mode 100644 index 00000000..0819fb20 --- /dev/null +++ b/StardewModdingAPI/Events/Menu.cs @@ -0,0 +1,19 @@ +using StardewValley.Menus; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + public static class MenuEvents + { + public static event EventHandler MenuChanged = delegate { }; + + public static void InvokeMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu) + { + MenuChanged.Invoke(null, new EventArgsClickableMenuChanged(priorMenu, newMenu)); + } + } +} diff --git a/StardewModdingAPI/Events/Mine.cs b/StardewModdingAPI/Events/Mine.cs new file mode 100644 index 00000000..67f1e2c1 --- /dev/null +++ b/StardewModdingAPI/Events/Mine.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + public static class MineEvents + { + } +} diff --git a/StardewModdingAPI/Events/Player.cs b/StardewModdingAPI/Events/Player.cs new file mode 100644 index 00000000..3fa5c806 --- /dev/null +++ b/StardewModdingAPI/Events/Player.cs @@ -0,0 +1,19 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + public static class PlayerEvents + { + public static event EventHandler FarmerChanged = delegate { }; + + public static void InvokeFarmerChanged(Farmer priorFarmer, Farmer newFarmer) + { + FarmerChanged.Invoke(null, new EventArgsFarmerChanged(priorFarmer, newFarmer)); + } + } +} diff --git a/StardewModdingAPI/Events/Time.cs b/StardewModdingAPI/Events/Time.cs new file mode 100644 index 00000000..fcf0b3e5 --- /dev/null +++ b/StardewModdingAPI/Events/Time.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + public static class TimeEvents + { + public static event EventHandler TimeOfDayChanged = delegate { }; + public static event EventHandler DayOfMonthChanged = delegate { }; + public static event EventHandler YearOfGameChanged = delegate { }; + public static event EventHandler SeasonOfYearChanged = delegate { }; + + public static void InvokeTimeOfDayChanged(Int32 priorInt, Int32 newInt) + { + TimeOfDayChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); + } + + public static void InvokeDayOfMonthChanged(Int32 priorInt, Int32 newInt) + { + DayOfMonthChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); + } + + public static void InvokeYearOfGameChanged(Int32 priorInt, Int32 newInt) + { + YearOfGameChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); + } + + public static void InvokeSeasonOfYearChanged(String priorString, String newString) + { + SeasonOfYearChanged.Invoke(null, new EventArgsStringChanged(priorString, newString)); + } + } +} diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs index 83f8e335..f9b2f60c 100644 --- a/StardewModdingAPI/Inheritance/SGame.cs +++ b/StardewModdingAPI/Inheritance/SGame.cs @@ -100,14 +100,14 @@ namespace StardewModdingAPI.Inheritance ModItems = new Dictionary(); PreviouslyPressedKeys = new Keys[0]; base.Initialize(); - Events.InvokeInitialize(); + Events.GameEvents.InvokeInitialize(); } protected override void LoadContent() { Program.Log("XNA LoadContent"); base.LoadContent(); - Events.InvokeLoadContent(); + Events.GameEvents.InvokeLoadContent(); } protected override void Update(GameTime gameTime) @@ -124,7 +124,7 @@ namespace StardewModdingAPI.Inheritance Console.ReadKey(); } - Events.InvokeUpdateTick(); + Events.GameEvents.InvokeUpdateTick(); PreviouslyPressedKeys = CurrentlyPressedKeys; } @@ -132,7 +132,7 @@ namespace StardewModdingAPI.Inheritance protected override void Draw(GameTime gameTime) { base.Draw(gameTime); - Events.InvokeDrawTick(); + Events.GraphicsEvents.InvokeDrawTick(); if (false) { @@ -225,71 +225,71 @@ namespace StardewModdingAPI.Inheritance MStateNow = Mouse.GetState(); foreach (Keys k in FramePressedKeys) - Events.InvokeKeyPressed(k); + Events.ControlEvents.InvokeKeyPressed(k); if (KStateNow != KStatePrior) { - Events.InvokeKeyboardChanged(KStatePrior, KStateNow); + Events.ControlEvents.InvokeKeyboardChanged(KStatePrior, KStateNow); KStatePrior = KStateNow; } if (MStateNow != MStatePrior) { - Events.InvokeMouseChanged(MStatePrior, MStateNow); + Events.ControlEvents.InvokeMouseChanged(MStatePrior, MStateNow); MStatePrior = MStateNow; } if (activeClickableMenu != null && activeClickableMenu != PreviousActiveMenu) { - Events.InvokeMenuChanged(PreviousActiveMenu, activeClickableMenu); + Events.MenuEvents.InvokeMenuChanged(PreviousActiveMenu, activeClickableMenu); PreviousActiveMenu = activeClickableMenu; } if (locations.GetHash() != PreviousGameLocations) { - Events.InvokeLocationsChanged(locations); + Events.LocationEvents.InvokeLocationsChanged(locations); PreviousGameLocations = locations.GetHash(); } if (currentLocation != PreviousGameLocation) { - Events.InvokeCurrentLocationChanged(PreviousGameLocation, currentLocation); + Events.LocationEvents.InvokeCurrentLocationChanged(PreviousGameLocation, currentLocation); PreviousGameLocation = currentLocation; } if (player != null && player != PreviousFarmer) { - Events.InvokeFarmerChanged(PreviousFarmer, player); + Events.PlayerEvents.InvokeFarmerChanged(PreviousFarmer, player); PreviousFarmer = player; } if(currentLocation != null && PreviousLocationObjects != currentLocation.objects.GetHash()) { - Events.InvokeOnNewLocationObject(currentLocation.objects); + Events.LocationEvents.InvokeOnNewLocationObject(currentLocation.objects); PreviousLocationObjects = currentLocation.objects.GetHash(); } if (timeOfDay != PreviousTimeOfDay) { - Events.InvokeTimeOfDayChanged(PreviousTimeOfDay, timeOfDay); + Events.TimeEvents.InvokeTimeOfDayChanged(PreviousTimeOfDay, timeOfDay); PreviousTimeOfDay = timeOfDay; } if (dayOfMonth != PreviousDayOfMonth) { - Events.InvokeDayOfMonthChanged(PreviousDayOfMonth, dayOfMonth); + Events.TimeEvents.InvokeDayOfMonthChanged(PreviousDayOfMonth, dayOfMonth); PreviousDayOfMonth = dayOfMonth; } if (currentSeason != PreviousSeasonOfYear) { - Events.InvokeSeasonOfYearChanged(PreviousSeasonOfYear, currentSeason); + Events.TimeEvents.InvokeSeasonOfYearChanged(PreviousSeasonOfYear, currentSeason); PreviousSeasonOfYear = currentSeason; } if (year != PreviousYearOfGame) { - Events.InvokeYearOfGameChanged(PreviousYearOfGame, year); + Events.TimeEvents.InvokeYearOfGameChanged(PreviousYearOfGame, year); PreviousYearOfGame = year; } } diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index e7169bde..f7cb7c87 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -23,7 +23,8 @@ using StardewValley.Network; using StardewValley.Tools; using Keys = Microsoft.Xna.Framework.Input.Keys; using Object = StardewValley.Object; - +using StardewModdingAPI.Events; + namespace StardewModdingAPI { public class Program @@ -249,8 +250,8 @@ namespace StardewModdingAPI //Command.RegisterCommand("crash", "crashes sdv").CommandFired += delegate { Game1.player.draw(null); }; //Subscribe to events - Events.KeyPressed += Events_KeyPressed; - Events.LoadContent += Events_LoadContent; + Events.ControlEvents.KeyPressed += Events_KeyPressed; + Events.GameEvents.LoadContent += Events_LoadContent; //Events.MenuChanged += Events_MenuChanged; //Idk right now if (debug) { @@ -265,12 +266,12 @@ namespace StardewModdingAPI { gamePtr.IsMouseVisible = false; gamePtr.Window.Title = "Stardew Valley - Version " + Game1.version; - StardewForm.Resize += Events.InvokeResize; + StardewForm.Resize += Events.GraphicsEvents.InvokeResize; }); //Game's in memory now, send the event LogInfo("Game Loaded"); - Events.InvokeGameLoaded(); + Events.GameEvents.InvokeGameLoaded(); LogColour(ConsoleColor.Cyan, "Type 'help' for help, or 'help ' for a command's usage"); //Begin listening to input diff --git a/StardewModdingAPI/StardewModdingAPI.csproj b/StardewModdingAPI/StardewModdingAPI.csproj index 35a17272..64f5a718 100644 --- a/StardewModdingAPI/StardewModdingAPI.csproj +++ b/StardewModdingAPI/StardewModdingAPI.csproj @@ -78,8 +78,15 @@ - - + + + + + + + + + @@ -102,7 +109,8 @@ - copy /y "$(SolutionDir)$(ProjectName)\$(OutDir)StardewModdingAPI.exe" "$(SolutionDir)Release\" + +