SMAPI/StardewModdingAPI/Events.cs

167 lines
5.0 KiB
C#
Raw Normal View History

2016-02-28 19:55:35 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2016-02-29 09:26:36 +08:00
using Microsoft.Xna.Framework.Input;
using StardewValley;
using StardewValley.Menus;
2016-02-28 19:55:35 +08:00
namespace StardewModdingAPI
{
public static class Events
{
public delegate void BlankEventHandler();
2016-02-29 05:01:24 +08:00
public static event BlankEventHandler GameLoaded = delegate { };
2016-02-29 09:26:36 +08:00
public static event BlankEventHandler Initialize = delegate { };
public static event BlankEventHandler LoadContent = delegate { };
2016-02-29 05:01:24 +08:00
public static event BlankEventHandler UpdateTick = delegate { };
2016-02-29 09:26:36 +08:00
public static event BlankEventHandler DrawTick = delegate { };
public delegate void KStateChanged(KeyboardState newState);
public static event KStateChanged KeyboardChanged = delegate { };
2016-02-29 09:26:36 +08:00
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<GameLocation> newLocations);
public static event GameLocationsChanged LocationsChanged = delegate { };
public delegate void CurrentLocationsChanged(GameLocation newLocation);
public static event CurrentLocationsChanged CurrentLocationChanged = delegate { };
2016-02-28 19:55:35 +08:00
public static event EventHandler Resize = delegate { };
2016-03-03 01:24:15 +08:00
public delegate void FarmerChangedD(Farmer newFarmer);
public static event FarmerChangedD FarmerChanged = delegate { };
2016-03-03 11:54:37 +08:00
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 { };
2016-02-28 19:55:35 +08:00
public static void InvokeGameLoaded()
{
GameLoaded.Invoke();
}
2016-02-29 05:01:24 +08:00
2016-02-29 09:26:36 +08:00
public static void InvokeInitialize()
{
2016-03-01 04:01:41 +08:00
try
{
Initialize.Invoke();
}
catch (Exception ex)
{
Program.LogError("An exception occured in XNA Initialize: " + ex.ToString());
}
2016-02-29 09:26:36 +08:00
}
public static void InvokeLoadContent()
2016-02-29 05:01:24 +08:00
{
2016-03-01 04:01:41 +08:00
try
{
LoadContent.Invoke();
}
catch (Exception ex)
{
Program.LogError("An exception occured in XNA LoadContent: " + ex.ToString());
}
2016-02-29 05:01:24 +08:00
}
public static void InvokeUpdateTick()
{
2016-03-01 04:01:41 +08:00
try
{
UpdateTick.Invoke();
}
catch (Exception ex)
{
Program.LogError("An exception occured in XNA UpdateTick: " + ex.ToString());
}
2016-02-29 05:01:24 +08:00
}
2016-02-29 09:26:36 +08:00
public static void InvokeDrawTick()
{
2016-03-01 04:01:41 +08:00
try
{
DrawTick.Invoke();
}
catch (Exception ex)
{
Program.LogError("An exception occured in XNA DrawTick: " + ex.ToString());
}
2016-02-29 09:26:36 +08:00
}
public static void InvokeKeyboardChanged(KeyboardState newState)
{
KeyboardChanged.Invoke(newState);
}
public static void InvokeMouseChanged(MouseState newState)
{
MouseChanged.Invoke(newState);
}
2016-02-29 09:26:36 +08:00
public static void InvokeKeyPressed(Keys key)
{
KeyPressed.Invoke(key);
}
public static void InvokeMenuChanged(IClickableMenu newMenu)
{
MenuChanged.Invoke(newMenu);
}
public static void InvokeLocationsChanged(List<GameLocation> 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);
}
2016-03-03 01:24:15 +08:00
public static void InvokeFarmerChanged(Farmer newFarmer)
{
FarmerChanged.Invoke(newFarmer);
}
2016-03-03 11:54:37 +08:00
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);
}
2016-02-28 19:55:35 +08:00
}
}