summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--StardewModdingAPI/Command.cs216
-rw-r--r--StardewModdingAPI/Config.cs37
-rw-r--r--StardewModdingAPI/Constants.cs24
-rw-r--r--StardewModdingAPI/Entities/SCharacter.cs8
-rw-r--r--StardewModdingAPI/Entities/SFarm.cs8
-rw-r--r--StardewModdingAPI/Entities/SFarmAnimal.cs8
-rw-r--r--StardewModdingAPI/Entities/SNpc.cs8
-rw-r--r--StardewModdingAPI/Entities/SPlayer.cs8
-rw-r--r--StardewModdingAPI/Events/Controls.cs8
-rw-r--r--StardewModdingAPI/Events/EventArgs.cs26
-rw-r--r--StardewModdingAPI/Events/Game.cs10
-rw-r--r--StardewModdingAPI/Events/Graphics.cs6
-rw-r--r--StardewModdingAPI/Events/Location.cs12
-rw-r--r--StardewModdingAPI/Events/Menu.cs8
-rw-r--r--StardewModdingAPI/Events/Mine.cs8
-rw-r--r--StardewModdingAPI/Events/Player.cs15
-rw-r--r--StardewModdingAPI/Events/Time.cs4
-rw-r--r--StardewModdingAPI/Extensions.cs23
-rw-r--r--StardewModdingAPI/Inheritance/ItemStackChange.cs5
-rw-r--r--StardewModdingAPI/Inheritance/Menus/SBobberBar.cs7
-rw-r--r--StardewModdingAPI/Inheritance/Menus/SGameMenu.cs15
-rw-r--r--StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs8
-rw-r--r--StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs10
-rw-r--r--StardewModdingAPI/Inheritance/SGame.cs199
-rw-r--r--StardewModdingAPI/Inheritance/SGameLocation.cs4
-rw-r--r--StardewModdingAPI/Inheritance/SObject.cs52
-rw-r--r--StardewModdingAPI/Log.cs1
-rw-r--r--StardewModdingAPI/Manifest.cs33
-rw-r--r--StardewModdingAPI/Mod.cs32
-rw-r--r--StardewModdingAPI/ModItem.cs17
-rw-r--r--StardewModdingAPI/Program.cs58
-rw-r--r--StardewModdingAPI/Properties/AssemblyInfo.cs1
-rw-r--r--TrainerMod/TrainerMod.cs3
33 files changed, 419 insertions, 463 deletions
diff --git a/StardewModdingAPI/Command.cs b/StardewModdingAPI/Command.cs
index 164263d6..7cf2b67b 100644
--- a/StardewModdingAPI/Command.cs
+++ b/StardewModdingAPI/Command.cs
@@ -1,108 +1,108 @@
-using StardewModdingAPI.Events;
-using System;
-using System.Collections.Generic;
-
-namespace StardewModdingAPI
-{
- public class Command
- {
- internal static List<Command> RegisteredCommands = new List<Command>();
-
- public String CommandName;
- public String CommandDesc;
- public String[] CommandArgs;
- public String[] CalledArgs;
- public event EventHandler<EventArgsCommand> CommandFired;
-
- /// <summary>
- /// Calls the specified command. (It runs the command)
- /// </summary>
- /// <param name="input">The command to run</param>
- public static void CallCommand(string input)
- {
- input = input.TrimEnd(new[] {' '});
- string[] args = new string[0];
- Command fnd;
- if (input.Contains(" "))
- {
- args = input.Split(new[] {" "}, 2, StringSplitOptions.RemoveEmptyEntries);
- fnd = FindCommand(args[0]);
- args = args[1].Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
- }
- else
- {
- fnd = FindCommand(input);
- }
-
- if (fnd != null)
- {
- fnd.CalledArgs = args;
- fnd.Fire();
- }
- else
- {
- Log.Error("Unknown Command");
- }
- }
-
- /// <summary>
- /// Registers a command to the list of commands properly
- /// </summary>
- /// <param name="command">Name of the command to register</param>
- /// <param name="cdesc">Description</param>
- /// <param name="args">Arguments (these are purely for viewing so that a user can see what an argument needs to be)</param>
- /// <returns></returns>
- public static Command RegisterCommand(string command, string cdesc, string[] args = null)
- {
- Command c = new Command(command, cdesc, args);
- if (RegisteredCommands.Contains(c))
- {
- Log.Error("Command already registered! [{0}]", c.CommandName);
- return RegisteredCommands.Find(x => x.Equals(c));
- }
-
- RegisteredCommands.Add(c);
- Log.Verbose("Registered command: " + command);
-
- return c;
- }
-
- /// <summary>
- /// Looks up a command in the list of registered commands. Returns null if it doesn't exist (I think)
- /// </summary>
- /// <param name="name">Name of command to find</param>
- /// <returns></returns>
- public static Command FindCommand(string name)
- {
- return RegisteredCommands.Find(x => x.CommandName.Equals(name));
- }
-
- /// <summary>
- /// Creates a Command from a Name, Description, and Arguments
- /// </summary>
- /// <param name="cname">Name</param>
- /// <param name="cdesc">Description</param>
- /// <param name="args">Arguments</param>
- public Command(String cname, String cdesc, String[] args = null)
- {
- CommandName = cname;
- CommandDesc = cdesc;
- if (args == null)
- args = new string[0];
- CommandArgs = args;
- }
-
- /// <summary>
- /// Runs a command. Fires it. Calls it. Any of those.
- /// </summary>
- public void Fire()
- {
- if (CommandFired == null)
- {
- Log.Error("Command failed to fire because it's fire event is null: " + CommandName);
- return;
- }
- CommandFired.Invoke(this, new EventArgsCommand(this));
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using StardewModdingAPI.Events;
+
+namespace StardewModdingAPI
+{
+ public class Command
+ {
+ internal static List<Command> RegisteredCommands = new List<Command>();
+
+ public String CommandName;
+ public String CommandDesc;
+ public String[] CommandArgs;
+ public String[] CalledArgs;
+ public event EventHandler<EventArgsCommand> CommandFired;
+
+ /// <summary>
+ /// Calls the specified command. (It runs the command)
+ /// </summary>
+ /// <param name="input">The command to run</param>
+ public static void CallCommand(string input)
+ {
+ input = input.TrimEnd(' ');
+ string[] args = new string[0];
+ Command fnd;
+ if (input.Contains(" "))
+ {
+ args = input.Split(new[] {" "}, 2, StringSplitOptions.RemoveEmptyEntries);
+ fnd = FindCommand(args[0]);
+ args = args[1].Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+ }
+ else
+ {
+ fnd = FindCommand(input);
+ }
+
+ if (fnd != null)
+ {
+ fnd.CalledArgs = args;
+ fnd.Fire();
+ }
+ else
+ {
+ Log.Error("Unknown Command");
+ }
+ }
+
+ /// <summary>
+ /// Registers a command to the list of commands properly
+ /// </summary>
+ /// <param name="command">Name of the command to register</param>
+ /// <param name="cdesc">Description</param>
+ /// <param name="args">Arguments (these are purely for viewing so that a user can see what an argument needs to be)</param>
+ /// <returns></returns>
+ public static Command RegisterCommand(string command, string cdesc, string[] args = null)
+ {
+ Command c = new Command(command, cdesc, args);
+ if (RegisteredCommands.Contains(c))
+ {
+ Log.Error("Command already registered! [{0}]", c.CommandName);
+ return RegisteredCommands.Find(x => x.Equals(c));
+ }
+
+ RegisteredCommands.Add(c);
+ Log.Verbose("Registered command: " + command);
+
+ return c;
+ }
+
+ /// <summary>
+ /// Looks up a command in the list of registered commands. Returns null if it doesn't exist (I think)
+ /// </summary>
+ /// <param name="name">Name of command to find</param>
+ /// <returns></returns>
+ public static Command FindCommand(string name)
+ {
+ return RegisteredCommands.Find(x => x.CommandName.Equals(name));
+ }
+
+ /// <summary>
+ /// Creates a Command from a Name, Description, and Arguments
+ /// </summary>
+ /// <param name="cname">Name</param>
+ /// <param name="cdesc">Description</param>
+ /// <param name="args">Arguments</param>
+ public Command(String cname, String cdesc, String[] args = null)
+ {
+ CommandName = cname;
+ CommandDesc = cdesc;
+ if (args == null)
+ args = new string[0];
+ CommandArgs = args;
+ }
+
+ /// <summary>
+ /// Runs a command. Fires it. Calls it. Any of those.
+ /// </summary>
+ public void Fire()
+ {
+ if (CommandFired == null)
+ {
+ Log.Error("Command failed to fire because it's fire event is null: " + CommandName);
+ return;
+ }
+ CommandFired.Invoke(this, new EventArgsCommand(this));
+ }
+ }
+}
diff --git a/StardewModdingAPI/Config.cs b/StardewModdingAPI/Config.cs
index 84119179..b95888d2 100644
--- a/StardewModdingAPI/Config.cs
+++ b/StardewModdingAPI/Config.cs
@@ -6,7 +6,6 @@ using System;
using System.IO;
using System.Linq;
using System.Reflection;
-using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -27,9 +26,15 @@ namespace StardewModdingAPI
public static Config InitializeConfig(string configLocation, Config baseConfig)
{
+ if (string.IsNullOrEmpty(configLocation))
+ {
+ Log.Verbose("The location to save the config to must not be empty.");
+ return null;
+ }
+
if (baseConfig == null)
{
- Console.WriteLine("A config must be instantiated before being passed to Initialize.\n\t" + configLocation);
+ Log.Verbose("A config must be instantiated before being passed to Initialize.\n\t" + configLocation);
return null;
}
@@ -56,7 +61,7 @@ namespace StardewModdingAPI
try
{
- var j = JObject.Parse(Encoding.UTF8.GetString(File.ReadAllBytes(baseConfig.ConfigLocation)));
+ var j = JObject.Parse(File.ReadAllText(baseConfig.ConfigLocation));
baseConfig = (Config)j.ToObject(baseConfig.GetType());
baseConfig.ConfigLocation = p;
baseConfig.JObject = j;
@@ -69,7 +74,7 @@ namespace StardewModdingAPI
}
catch
{
- Console.WriteLine("Invalid JSON Renamed: " + p);
+ Log.Verbose("Invalid JSON Renamed: " + p);
if (File.Exists(p))
File.Move(p, Path.Combine(Path.GetDirectoryName(p), Path.GetFileNameWithoutExtension(p) + "." + Guid.NewGuid() + ".json")); //Get it out of the way for a new one
var v = (Config)baseConfig.GetType().GetMethod("GenerateBaseConfig", BindingFlags.Public | BindingFlags.Instance).Invoke(baseConfig, new object[] { baseConfig });
@@ -95,14 +100,20 @@ namespace StardewModdingAPI
}
catch (Exception ex)
{
- Console.WriteLine(ex.ToString());
+ Log.Error(ex.ToString());
}
return baseConfig;
}
+ /// <summary>
+ /// NOTICE: THIS IS OBSOLETE AND WILL BE REMOVED IN THE FUTURE. 'BaseConfigPath' IS NOW A PROPERTY IN A MOD
+ /// </summary>
+ /// <param name="theMod"></param>
+ /// <returns></returns>
+ [Obsolete]
public static string GetBasePath(Mod theMod)
{
- return theMod.PathOnDisk + "\\config.json";
+ return theMod.BaseConfigPath;
}
}
@@ -110,9 +121,17 @@ namespace StardewModdingAPI
{
public static void WriteConfig(this Config baseConfig)
{
- var toWrite = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(baseConfig, baseConfig.GetType(), Formatting.Indented, new JsonSerializerSettings()));
- if (!File.Exists(baseConfig.ConfigLocation) || !File.ReadAllBytes(baseConfig.ConfigLocation).SequenceEqual(toWrite))
- File.WriteAllBytes(baseConfig.ConfigLocation, toWrite);
+ if (baseConfig == null || string.IsNullOrEmpty(baseConfig.ConfigLocation) || string.IsNullOrEmpty(Path.GetDirectoryName(baseConfig.ConfigLocation)))
+ {
+ Log.Error("A config attempted to save when it itself or it's location were null.");
+ return;
+ }
+
+ var toWrite = JsonConvert.SerializeObject(baseConfig, baseConfig.GetType(), Formatting.Indented, new JsonSerializerSettings());
+ if (!Directory.Exists(Path.GetDirectoryName(baseConfig.ConfigLocation)))
+ Directory.CreateDirectory(Path.GetDirectoryName(baseConfig.ConfigLocation));
+ if (!File.Exists(baseConfig.ConfigLocation) || !File.ReadAllText(baseConfig.ConfigLocation).SequenceEqual(toWrite))
+ File.WriteAllText(baseConfig.ConfigLocation, toWrite);
toWrite = null;
}
diff --git a/StardewModdingAPI/Constants.cs b/StardewModdingAPI/Constants.cs
index 4c10bf77..dde4193c 100644
--- a/StardewModdingAPI/Constants.cs
+++ b/StardewModdingAPI/Constants.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Reflection;
+using StardewValley;
namespace StardewModdingAPI
{
@@ -10,11 +11,23 @@ namespace StardewModdingAPI
public static class Constants
{
/// <summary>
- /// Stardew Valley's local app data location.
- /// %LocalAppData%//StardewValley
+ /// Stardew Valley's roaming app data location.
+ /// %AppData%//StardewValley
/// </summary>
public static string DataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley");
+ public static string SavesPath => Path.Combine(DataPath, "Saves");
+
+ private static string saveFolderName => PlayerNull ? string.Empty : Game1.player.name.RemoveNumerics() + "_" + Game1.uniqueIDForThisGame;
+ public static string SaveFolderName => CurrentSavePathExists ? saveFolderName : "";
+
+ private static string currentSavePath => PlayerNull ? string.Empty : Path.Combine(SavesPath, saveFolderName);
+ public static string CurrentSavePath => CurrentSavePathExists ? currentSavePath : "";
+
+ public static bool CurrentSavePathExists => Directory.Exists(currentSavePath);
+
+ public static bool PlayerNull => !Game1.hasLoadedGame || Game1.player == null || string.IsNullOrEmpty(Game1.player.name);
+
/// <summary>
/// Execution path to execute the code.
/// </summary>
@@ -23,7 +36,7 @@ namespace StardewModdingAPI
/// <summary>
/// Title for the API console
/// </summary>
- public static string ConsoleTitle => string.Format("Stardew Modding API Console - Version {0}", VersionString);
+ public static string ConsoleTitle => string.Format("Stardew Modding API Console - Version {0} - Mods Loaded: {1}", VersionString, ModsLoaded);
/// <summary>
/// Path for log files to be output to.
@@ -40,5 +53,10 @@ namespace StardewModdingAPI
public const string Build = "Alpha";
public static string VersionString => string.Format("{0}.{1}.{2} {3}", MajorVersion, MinorVersion, PatchVersion, Build);
+
+ /// <summary>
+ /// Not quite "constant", but it makes more sense for it to be here, at least for now
+ /// </summary>
+ public static int ModsLoaded = 0;
}
}
diff --git a/StardewModdingAPI/Entities/SCharacter.cs b/StardewModdingAPI/Entities/SCharacter.cs
index 740a6d7f..39e4f9c8 100644
--- a/StardewModdingAPI/Entities/SCharacter.cs
+++ b/StardewModdingAPI/Entities/SCharacter.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StardewModdingAPI.Entities
+namespace StardewModdingAPI.Entities
{
class SCharacter
{
diff --git a/StardewModdingAPI/Entities/SFarm.cs b/StardewModdingAPI/Entities/SFarm.cs
index 5d1647a8..4895df7e 100644
--- a/StardewModdingAPI/Entities/SFarm.cs
+++ b/StardewModdingAPI/Entities/SFarm.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StardewModdingAPI.Entities
+namespace StardewModdingAPI.Entities
{
class SFarm
{
diff --git a/StardewModdingAPI/Entities/SFarmAnimal.cs b/StardewModdingAPI/Entities/SFarmAnimal.cs
index 0f768f6a..8bd99e1c 100644
--- a/StardewModdingAPI/Entities/SFarmAnimal.cs
+++ b/StardewModdingAPI/Entities/SFarmAnimal.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StardewModdingAPI.Entities
+namespace StardewModdingAPI.Entities
{
class SFarmAnimal
{
diff --git a/StardewModdingAPI/Entities/SNpc.cs b/StardewModdingAPI/Entities/SNpc.cs
index 02242d20..612c9c89 100644
--- a/StardewModdingAPI/Entities/SNpc.cs
+++ b/StardewModdingAPI/Entities/SNpc.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StardewModdingAPI.Entities
+namespace StardewModdingAPI.Entities
{
class SNpc
{
diff --git a/StardewModdingAPI/Entities/SPlayer.cs b/StardewModdingAPI/Entities/SPlayer.cs
index ae4e9472..c74ba461 100644
--- a/StardewModdingAPI/Entities/SPlayer.cs
+++ b/StardewModdingAPI/Entities/SPlayer.cs
@@ -1,10 +1,6 @@
-using StardewModdingAPI.Inheritance;
+using System.Collections.Generic;
+using StardewModdingAPI.Inheritance;
using StardewValley;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace StardewModdingAPI.Entities
{
diff --git a/StardewModdingAPI/Events/Controls.cs b/StardewModdingAPI/Events/Controls.cs
index c79c28f6..5c604492 100644
--- a/StardewModdingAPI/Events/Controls.cs
+++ b/StardewModdingAPI/Events/Controls.cs
@@ -1,10 +1,6 @@
-using Microsoft.Xna.Framework;
+using System;
+using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace StardewModdingAPI.Events
{
diff --git a/StardewModdingAPI/Events/EventArgs.cs b/StardewModdingAPI/Events/EventArgs.cs
index ee30b406..a6de3597 100644
--- a/StardewModdingAPI/Events/EventArgs.cs
+++ b/StardewModdingAPI/Events/EventArgs.cs
@@ -1,13 +1,12 @@
-using Microsoft.Xna.Framework;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using StardewModdingAPI.Inheritance;
using StardewValley;
using StardewValley.Menus;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Object = StardewValley.Object;
namespace StardewModdingAPI.Events
{
@@ -112,11 +111,11 @@ namespace StardewModdingAPI.Events
public class EventArgsLocationObjectsChanged : EventArgs
{
- public EventArgsLocationObjectsChanged(SerializableDictionary<Vector2, StardewValley.Object> newObjects)
+ public EventArgsLocationObjectsChanged(SerializableDictionary<Vector2, Object> newObjects)
{
NewObjects = newObjects;
}
- public SerializableDictionary<Vector2, StardewValley.Object> NewObjects { get; private set; }
+ public SerializableDictionary<Vector2, Object> NewObjects { get; private set; }
}
public class EventArgsCurrentLocationChanged : EventArgs
@@ -198,6 +197,17 @@ namespace StardewModdingAPI.Events
public String PriorString { get; private set; }
}
+ public class EventArgsLoadedGameChanged : EventArgs
+ {
+ public EventArgsLoadedGameChanged(bool loadedGame)
+ {
+ LoadedGame = loadedGame;
+ }
+
+ public bool LoadedGame { get; private set; }
+ }
+
+
public class EventArgsCommand : EventArgs
{
public EventArgsCommand(Command command)
diff --git a/StardewModdingAPI/Events/Game.cs b/StardewModdingAPI/Events/Game.cs
index ac630ba9..85022391 100644
--- a/StardewModdingAPI/Events/Game.cs
+++ b/StardewModdingAPI/Events/Game.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace StardewModdingAPI.Events
{
@@ -54,7 +50,7 @@ namespace StardewModdingAPI.Events
}
catch (Exception ex)
{
- Log.Error("An exception occured in XNA Initialize: " + ex.ToString());
+ Log.Error("An exception occured in XNA Initialize: " + ex);
}
}
@@ -66,7 +62,7 @@ namespace StardewModdingAPI.Events
}
catch (Exception ex)
{
- Log.Error("An exception occured in XNA LoadContent: " + ex.ToString());
+ Log.Error("An exception occured in XNA LoadContent: " + ex);
}
}
@@ -78,7 +74,7 @@ namespace StardewModdingAPI.Events
}
catch (Exception ex)
{
- Log.Error("An exception occured in XNA UpdateTick: " + ex.ToString());
+ Log.Error("An exception occured in XNA UpdateTick: " + ex);
}
}
diff --git a/StardewModdingAPI/Events/Graphics.cs b/StardewModdingAPI/Events/Graphics.cs
index 60ee7a74..87ee845b 100644
--- a/StardewModdingAPI/Events/Graphics.cs
+++ b/StardewModdingAPI/Events/Graphics.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace StardewModdingAPI.Events
{
@@ -19,7 +15,7 @@ namespace StardewModdingAPI.Events
}
catch (Exception ex)
{
- Log.Error("An exception occured in XNA DrawTick: " + ex.ToString());
+ Log.Error("An exception occured in XNA DrawTick: " + ex);
}
}
diff --git a/StardewModdingAPI/Events/Location.cs b/StardewModdingAPI/Events/Location.cs
index c347659b..63b0f602 100644
--- a/StardewModdingAPI/Events/Location.cs
+++ b/StardewModdingAPI/Events/Location.cs
@@ -1,10 +1,8 @@
-using Microsoft.Xna.Framework;
-using StardewValley;
-using System;
+using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Microsoft.Xna.Framework;
+using StardewValley;
+using Object = StardewValley.Object;
namespace StardewModdingAPI.Events
{
@@ -24,7 +22,7 @@ namespace StardewModdingAPI.Events
CurrentLocationChanged.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, newLocation));
}
- internal static void InvokeOnNewLocationObject(SerializableDictionary<Vector2, StardewValley.Object> newObjects)
+ internal static void InvokeOnNewLocationObject(SerializableDictionary<Vector2, Object> newObjects)
{
LocationObjectsChanged.Invoke(null, new EventArgsLocationObjectsChanged(newObjects));
}
diff --git a/StardewModdingAPI/Events/Menu.cs b/StardewModdingAPI/Events/Menu.cs
index 0819fb20..d3f3e008 100644
--- a/StardewModdingAPI/Events/Menu.cs
+++ b/StardewModdingAPI/Events/Menu.cs
@@ -1,9 +1,5 @@
-using StardewValley.Menus;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System;
+using StardewValley.Menus;
namespace StardewModdingAPI.Events
{
diff --git a/StardewModdingAPI/Events/Mine.cs b/StardewModdingAPI/Events/Mine.cs
index 67f1e2c1..ea23a8a3 100644
--- a/StardewModdingAPI/Events/Mine.cs
+++ b/StardewModdingAPI/Events/Mine.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StardewModdingAPI.Events
+namespace StardewModdingAPI.Events
{
public static class MineEvents
{
diff --git a/StardewModdingAPI/Events/Player.cs b/StardewModdingAPI/Events/Player.cs
index f0547f87..ca05c05b 100644
--- a/StardewModdingAPI/Events/Player.cs
+++ b/StardewModdingAPI/Events/Player.cs
@@ -1,10 +1,7 @@
-using StardewModdingAPI.Inheritance;
-using StardewValley;
-using System;
+using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using StardewModdingAPI.Inheritance;
+using StardewValley;
namespace StardewModdingAPI.Events
{
@@ -13,6 +10,7 @@ namespace StardewModdingAPI.Events
public static event EventHandler<EventArgsFarmerChanged> FarmerChanged = delegate { };
public static event EventHandler<EventArgsInventoryChanged> InventoryChanged = delegate { };
public static event EventHandler<EventArgsLevelUp> LeveledUp = delegate { };
+ public static event EventHandler<EventArgsLoadedGameChanged> LoadedGame = delegate { };
public static void InvokeFarmerChanged(Farmer priorFarmer, Farmer newFarmer)
{
@@ -28,5 +26,10 @@ namespace StardewModdingAPI.Events
{
LeveledUp.Invoke(null, new EventArgsLevelUp(type, newLevel));
}
+
+ public static void InvokeLoadedGame(EventArgsLoadedGameChanged loaded)
+ {
+ LoadedGame.Invoke(null, loaded);
+ }
}
}
diff --git a/StardewModdingAPI/Events/Time.cs b/StardewModdingAPI/Events/Time.cs
index fcf0b3e5..a3fcee19 100644
--- a/StardewModdingAPI/Events/Time.cs
+++ b/StardewModdingAPI/Events/Time.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace StardewModdingAPI.Events
{
diff --git a/StardewModdingAPI/Extensions.cs b/StardewModdingAPI/Extensions.cs
index d4b582b7..a0e87f04 100644
--- a/StardewModdingAPI/Extensions.cs
+++ b/StardewModdingAPI/Extensions.cs
@@ -1,10 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using System.Linq;
using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
@@ -82,12 +79,18 @@ namespace StardewModdingAPI
return t.GetBaseFieldInfo(name).GetValue(o) as T;
}
+ public static void SetBaseFieldValue<T>(this Type t, object o, string name, object newValue) where T : class
+ {
+ t.GetBaseFieldInfo(name).SetValue(o, newValue as T);
+ }
+
/*
public static T GetBaseFieldValue<T>(this object o, string name) where T : class
{
return o.GetType().GetBaseFieldInfo(name).GetValue(o) as T;
}*/
+ /*
public static object GetBaseFieldValue(this object o, string name)
{
return o.GetType().GetBaseFieldInfo(name).GetValue(o);
@@ -97,5 +100,19 @@ namespace StardewModdingAPI
{
o.GetType().GetBaseFieldInfo(name).SetValue(o, newValue);
}
+ */
+
+ public static string RemoveNumerics(this string st)
+ {
+ string s = st;
+ foreach (char c in s)
+ {
+