From 4e26cb7abc6fb699f0df9ddf1d50bc3ef2fe01c6 Mon Sep 17 00:00:00 2001 From: ClxS Date: Thu, 3 Mar 2016 18:50:22 +0000 Subject: Resolved static analysis issues Standardised event handlers so there's less hassle with future changes --- StardewModdingAPI/Events.cs | 314 +++++++++++++++++++++----------------------- 1 file changed, 148 insertions(+), 166 deletions(-) (limited to 'StardewModdingAPI/Events.cs') diff --git a/StardewModdingAPI/Events.cs b/StardewModdingAPI/Events.cs index 97e55d8d..e8e9727c 100644 --- a/StardewModdingAPI/Events.cs +++ b/StardewModdingAPI/Events.cs @@ -1,166 +1,148 @@ -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; - -namespace StardewModdingAPI -{ - public static class Events - { - public delegate void BlankEventHandler(); - - public static event BlankEventHandler GameLoaded = delegate { }; - public static event BlankEventHandler Initialize = delegate { }; - public static event BlankEventHandler LoadContent = delegate { }; - public static event BlankEventHandler UpdateTick = delegate { }; - public static event BlankEventHandler DrawTick = delegate { }; - - public delegate void KStateChanged(KeyboardState newState); - public static event KStateChanged KeyboardChanged = delegate { }; - - public delegate void KeyStateChanged(Keys key); - public static event KeyStateChanged KeyPressed = delegate { }; - - public delegate void MStateChanged(MouseState newState); - public static event MStateChanged MouseChanged = delegate { }; - - public delegate void ClickableMenuChanged(IClickableMenu newMenu); - public static event ClickableMenuChanged MenuChanged = delegate { }; - - public delegate void GameLocationsChanged(List newLocations); - public static event GameLocationsChanged LocationsChanged = delegate { }; - - public delegate void CurrentLocationsChanged(GameLocation newLocation); - public static event CurrentLocationsChanged CurrentLocationChanged = delegate { }; - - public static event EventHandler Resize = delegate { }; - - public delegate void FarmerChangedD(Farmer newFarmer); - public static event FarmerChangedD FarmerChanged = delegate { }; - - public delegate void IntChanged(Int32 newInt); - public static event IntChanged TimeOfDayChanged = delegate { }; - public static event IntChanged DayOfMonthChanged = delegate { }; - public static event IntChanged YearOfGameChanged = delegate { }; - - public delegate void StringChanged(String newString); - public static event StringChanged SeasonOfYearChanged = delegate { }; - - public static void InvokeGameLoaded() - { - GameLoaded.Invoke(); - } - - public static void InvokeInitialize() - { - try - { - Initialize.Invoke(); - } - catch (Exception ex) - { - Program.LogError("An exception occured in XNA Initialize: " + ex.ToString()); - } - } - - public static void InvokeLoadContent() - { - try - { - LoadContent.Invoke(); - } - catch (Exception ex) - { - Program.LogError("An exception occured in XNA LoadContent: " + ex.ToString()); - } - } - - public static void InvokeUpdateTick() - { - try - { - UpdateTick.Invoke(); - } - catch (Exception ex) - { - Program.LogError("An exception occured in XNA UpdateTick: " + ex.ToString()); - } - } - - public static void InvokeDrawTick() - { - try - { - DrawTick.Invoke(); - } - catch (Exception ex) - { - Program.LogError("An exception occured in XNA DrawTick: " + ex.ToString()); - } - } - - public static void InvokeKeyboardChanged(KeyboardState newState) - { - KeyboardChanged.Invoke(newState); - } - - public static void InvokeMouseChanged(MouseState newState) - { - MouseChanged.Invoke(newState); - } - - public static void InvokeKeyPressed(Keys key) - { - KeyPressed.Invoke(key); - } - - public static void InvokeMenuChanged(IClickableMenu newMenu) - { - MenuChanged.Invoke(newMenu); - } - - public static void InvokeLocationsChanged(List newLocations) - { - LocationsChanged.Invoke(newLocations); - } - - public static void InvokeCurrentLocationChanged(GameLocation newLocation) - { - CurrentLocationChanged.Invoke(newLocation); - } - - public static void InvokeResize(object sender, EventArgs e) - { - Resize.Invoke(sender, e); - } - - public static void InvokeFarmerChanged(Farmer newFarmer) - { - FarmerChanged.Invoke(newFarmer); - } - - public static void InvokeTimeOfDayChanged(Int32 newInt) - { - TimeOfDayChanged.Invoke(newInt); - } - - public static void InvokeDayOfMonthChanged(Int32 newInt) - { - DayOfMonthChanged.Invoke(newInt); - } - - public static void InvokeYearOfGameChanged(Int32 newInt) - { - YearOfGameChanged.Invoke(newInt); - } - - public static void InvokeSeasonOfYearChanged(String newString) - { - SeasonOfYearChanged.Invoke(newString); - } - } -} +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; + +namespace StardewModdingAPI +{ + public static class Events + { + public delegate void BlankEventHandler(object sender, EventArgs e); + + public static event BlankEventHandler GameLoaded = delegate { }; + public static event BlankEventHandler Initialize = delegate { }; + public static event BlankEventHandler LoadContent = delegate { }; + public static event BlankEventHandler UpdateTick = delegate { }; + public static event BlankEventHandler 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 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)); + } + } +} -- cgit From de0cd2ac5095fb3db924317eb1628ec33fb4ffb7 Mon Sep 17 00:00:00 2001 From: ClxS Date: Thu, 3 Mar 2016 18:55:36 +0000 Subject: Forgot to remove unneeded BlankEventHandler --- Release/StardewModdingAPI.exe | Bin 71168 -> 70656 bytes StardewModdingAPI/Events.cs | 12 +++++------- .../StardewModdingAPI.csproj.FileListAbsolute.txt | 4 ++++ TrainerMod/obj/Debug/TrainerMod.dll | Bin 23552 -> 24064 bytes 4 files changed, 9 insertions(+), 7 deletions(-) (limited to 'StardewModdingAPI/Events.cs') diff --git a/Release/StardewModdingAPI.exe b/Release/StardewModdingAPI.exe index 06f57e1f..3897c71f 100644 Binary files a/Release/StardewModdingAPI.exe and b/Release/StardewModdingAPI.exe differ diff --git a/StardewModdingAPI/Events.cs b/StardewModdingAPI/Events.cs index e8e9727c..3ae861d9 100644 --- a/StardewModdingAPI/Events.cs +++ b/StardewModdingAPI/Events.cs @@ -11,13 +11,11 @@ namespace StardewModdingAPI { public static class Events { - public delegate void BlankEventHandler(object sender, EventArgs e); - - public static event BlankEventHandler GameLoaded = delegate { }; - public static event BlankEventHandler Initialize = delegate { }; - public static event BlankEventHandler LoadContent = delegate { }; - public static event BlankEventHandler UpdateTick = delegate { }; - public static event BlankEventHandler DrawTick = delegate { }; + 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 { }; diff --git a/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt b/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt index 0d8f693b..241cf998 100644 --- a/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt +++ b/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt @@ -32,3 +32,7 @@ C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\ C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.csprojResolveAssemblyReference.cache Z:\Projects\C#\SMAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.exe Z:\Projects\C#\SMAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.pdb +Z:\Projects\C#\SMAPI\StardewModdingAPI\bin\x86\Debug\steam_appid.txt +Z:\Projects\C#\SMAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe.config +Z:\Projects\C#\SMAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe +Z:\Projects\C#\SMAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.pdb diff --git a/TrainerMod/obj/Debug/TrainerMod.dll b/TrainerMod/obj/Debug/TrainerMod.dll index d6e49439..eda3dfa9 100644 Binary files a/TrainerMod/obj/Debug/TrainerMod.dll and b/TrainerMod/obj/Debug/TrainerMod.dll differ -- cgit