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;
|
2016-03-01 14:35:52 +08:00
|
|
|
|
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 { };
|
|
|
|
|
|
2016-03-02 06:22:19 +08:00
|
|
|
|
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 { };
|
|
|
|
|
|
2016-03-02 06:22:19 +08:00
|
|
|
|
public delegate void MStateChanged(MouseState newState);
|
|
|
|
|
public static event MStateChanged MouseChanged = delegate { };
|
|
|
|
|
|
2016-03-01 14:35:52 +08:00
|
|
|
|
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
|
|
|
|
|
2016-03-02 06:22:19 +08:00
|
|
|
|
public static event EventHandler Resize = 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);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-02 06:22:19 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
2016-03-01 14:35:52 +08:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2016-03-02 06:22:19 +08:00
|
|
|
|
|
|
|
|
|
public static void InvokeResize(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Resize.Invoke(sender, e);
|
|
|
|
|
}
|
2016-02-28 19:55:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|