summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoryn <Zoryn4163@users.noreply.github.com>2016-03-23 13:43:41 -0400
committerZoryn <Zoryn4163@users.noreply.github.com>2016-03-23 13:43:41 -0400
commitd3912b43052a79068d72b5689b8c6d901fbb72ea (patch)
tree1a67172990e15c8ba57ea6add2dd6d1810222ac2
parent4c4d3e66fe2e18c424c08a295d628432fca767cd (diff)
parent49e035dd2289d58cc2cb6585027f3f038344404f (diff)
downloadSMAPI-d3912b43052a79068d72b5689b8c6d901fbb72ea.tar.gz
SMAPI-d3912b43052a79068d72b5689b8c6d901fbb72ea.tar.bz2
SMAPI-d3912b43052a79068d72b5689b8c6d901fbb72ea.zip
Merge pull request #57 from Zoryn4163/master
0.39.1 inbound!
-rw-r--r--StardewModdingAPI/Config.cs141
-rw-r--r--StardewModdingAPI/Constants.cs12
-rw-r--r--StardewModdingAPI/Inheritance/SGameLocation.cs71
-rw-r--r--StardewModdingAPI/Manifest.cs6
-rw-r--r--StardewModdingAPI/Mod.cs28
-rw-r--r--StardewModdingAPI/Program.cs213
-rw-r--r--StardewModdingAPI/StardewModdingAPI.csproj2
-rw-r--r--StardewModdingAPI/Version.cs28
-rw-r--r--TrainerMod/manifest.json1
9 files changed, 85 insertions, 417 deletions
diff --git a/StardewModdingAPI/Config.cs b/StardewModdingAPI/Config.cs
index 6fb13f6e..8e6a590c 100644
--- a/StardewModdingAPI/Config.cs
+++ b/StardewModdingAPI/Config.cs
@@ -11,7 +11,7 @@ using Newtonsoft.Json.Linq;
namespace StardewModdingAPI
{
- public partial class Config
+ public class Config
{
[JsonIgnore]
public virtual string ConfigLocation { get; protected internal set; }
@@ -47,7 +47,7 @@ namespace StardewModdingAPI
if (!File.Exists(ConfigLocation))
{
//no config exists, generate default values
- var c = this.GenerateBaseConfig<T>();
+ var c = this.GenerateDefaultConfig<T>();
c.ConfigLocation = ConfigLocation;
ret = c;
}
@@ -67,8 +67,8 @@ namespace StardewModdingAPI
}
catch (Exception ex)
{
- Log.Error("Invalid JSON Config: {0} \n{1}", ConfigLocation, ex);
- return GenerateBaseConfig<T>();
+ Log.Error("Invalid JSON ({0}): {1} \n{2}", GetType().Name, ConfigLocation, ex);
+ return GenerateDefaultConfig<T>();
}
}
@@ -85,15 +85,6 @@ namespace StardewModdingAPI
}
/// <summary>
- /// Use the public GenerateDefaultConfig insteaad
- /// </summary>
- [Obsolete]
- protected virtual T GenerateBaseConfig<T>() where T : Config
- {
- return GenerateDefaultConfig<T>();
- }
-
- /// <summary>
/// Merges a default-value config with the user-config on disk.
/// </summary>
/// <typeparam name="T"></typeparam>
@@ -103,7 +94,7 @@ namespace StardewModdingAPI
try
{
//default config
- var b = JObject.FromObject(Instance<T>().GenerateBaseConfig<T>());
+ var b = JObject.FromObject(Instance<T>().GenerateDefaultConfig<T>());
//user config
var u = JObject.FromObject(this);
@@ -133,7 +124,12 @@ namespace StardewModdingAPI
/// Initializes an instance of any class that inherits from Config.
/// This method performs the loading, saving, and merging of the config on the disk and in memory at a default state.
/// This method should not be used to re-load or to re-save a config.
+ /// NOTE: You MUST set your config EQUAL to the return of this method!
/// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="baseConfig"></param>
+ /// <param name="configLocation"></param>
+ /// <returns></returns>
public static T InitializeConfig<T>(this T baseConfig, string configLocation) where T : Config
{
if (baseConfig == null)
@@ -184,122 +180,5 @@ namespace StardewModdingAPI
{
return baseConfig.UpdateConfig<T>();
}
-
- [Obsolete]
- public static void WriteConfig(this Config baseConfig)
- {
- Log.Error("A config has been written through an obsolete way.\n\tThis method of writing configs will not be supported in future versions.");
- WriteConfig<Config>(baseConfig);
- }
-
- [Obsolete]
- public static Config ReloadConfig(this Config baseConfig)
- {
- Log.Error("A config has been reloaded through an obsolete way.\n\tThis method of loading configs will not be supported in future versions.");
- return baseConfig.ReloadConfig<Config>();
- }
- }
-
- public partial class Config
- {
- [Obsolete] public static int invalids = 0;
-
- [JsonIgnore]
- [Obsolete]
- public virtual JObject JObject { get; protected set; }
-
- [Obsolete]
- public static Config InitializeConfig(string configLocation, Config baseConfig)
- {
- invalids++;
-
- if (string.IsNullOrEmpty(configLocation))
- {
- Log.Verbose("The location to save the config to must not be empty.");
- return null;
- }
-
- if (baseConfig == null)
- {
- Log.Verbose("A config must be instantiated before being passed to Initialize.\n\t" + configLocation);
- return null;
- }
-
- baseConfig.ConfigLocation = configLocation;
- return baseConfig.LoadConfig(baseConfig);
- }
-
- [Obsolete]
- public virtual Config GenerateBaseConfig(Config baseConfig)
- {
- //Must be implemented in sub-class
- return null;
- }
-
- [Obsolete]
- public virtual Config LoadConfig(Config baseConfig)
- {
- if (!File.Exists(baseConfig.ConfigLocation))
- {
- var v = (Config) baseConfig.GetType().GetMethod("GenerateBaseConfig", BindingFlags.Public | BindingFlags.Instance).Invoke(baseConfig, new object[] {baseConfig});
- v.WriteConfig();
- }
- else
- {
- var p = baseConfig.ConfigLocation;
-
- try
- {
- var j = JObject.Parse(File.ReadAllText(baseConfig.ConfigLocation));
- baseConfig = (Config) j.ToObject(baseConfig.GetType());
- baseConfig.ConfigLocation = p;
- baseConfig.JObject = j;
-
- baseConfig = UpdateConfig(baseConfig);
- baseConfig.ConfigLocation = p;
- baseConfig.JObject = j;
-
- baseConfig.WriteConfig();
- }
- catch
- {
- Log.Verbose("Invalid JSON: " + p);
- }
- }
-
- return baseConfig;
- }
-
- [Obsolete]
- public virtual Config UpdateConfig(Config baseConfig)
- {
- try
- {
- //default config with all standard values
- var b = JObject.FromObject(baseConfig.GetType().GetMethod("GenerateBaseConfig", BindingFlags.Public | BindingFlags.Instance).Invoke(baseConfig, new object[] {baseConfig}));
- //user config with their values
- var u = baseConfig.JObject;
-
- b.Merge(u, new JsonMergeSettings {MergeArrayHandling = MergeArrayHandling.Replace});
-
- return (Config) b.ToObject(baseConfig.GetType());
- }
- catch (Exception ex)
- {
- 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.BaseConfigPath;
- }
}
} \ No newline at end of file
diff --git a/StardewModdingAPI/Constants.cs b/StardewModdingAPI/Constants.cs
index 19425dda..cffb711e 100644
--- a/StardewModdingAPI/Constants.cs
+++ b/StardewModdingAPI/Constants.cs
@@ -36,7 +36,7 @@ namespace StardewModdingAPI
/// <summary>
/// Title for the API console
/// </summary>
- public static string ConsoleTitle => string.Format("Stardew Modding API Console - Version {0} - Mods Loaded: {1}", VersionString, ModsLoaded);
+ public static string ConsoleTitle => $"Stardew Modding API Console - Version {Version.VersionString} - Mods Loaded: {ModsLoaded}";
/// <summary>
/// Path for log files to be output to.
@@ -44,15 +44,7 @@ namespace StardewModdingAPI
/// </summary>
public static string LogPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "ErrorLogs");
- public const int MajorVersion = 0;
-
- public const int MinorVersion = 38;
-
- public const int PatchVersion = 8;
-
- public const string Build = "Alpha";
-
- public static string VersionString => string.Format("{0}.{1}.{2} {3}", MajorVersion, MinorVersion, PatchVersion, Build);
+ public static readonly Version Version = new Version(0, 39, 1, "Alpha");
/// <summary>
/// Not quite "constant", but it makes more sense for it to be here, at least for now
diff --git a/StardewModdingAPI/Inheritance/SGameLocation.cs b/StardewModdingAPI/Inheritance/SGameLocation.cs
deleted file mode 100644
index 2d9a17ec..00000000
--- a/StardewModdingAPI/Inheritance/SGameLocation.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using StardewValley;
-
-namespace StardewModdingAPI.Inheritance
-{
- [Obsolete]
- public class SGameLocation : GameLocation
- {
- public GameLocation BaseGameLocation { get; private set; }
-
- public SerializableDictionary<Vector2, SObject> ModObjects { get; set; }
-
- public static SGameLocation ConstructFromBaseClass(GameLocation baseClass, bool copyAllData = false)
- {
- SGameLocation s = new SGameLocation();
- s.BaseGameLocation = baseClass;
- s.name = baseClass.name;
-
- Log.Debug("CONSTRUCTED: " + s.name);
-
- if (copyAllData)
- {
- foreach (var v in baseClass.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
- {
- try
- {
- var fi = s.GetType().GetField(v.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
- if (fi != null && !fi.IsStatic)
- {
- fi.SetValue(s, v.GetValue(baseClass));
- //Console.WriteLine("SET {0} ON {1} TO {2}", fi.Name, s.name, v.GetValue(baseClass));
- }
- }
- catch (Exception ex)
- {
- Log.Error(ex);
- }
- }
- }
-
- return s;
- }
-
- public static List<SGameLocation> ConstructFromBaseClasses(List<GameLocation> baseGameLocations, bool copyAllData = false)
- {
- return baseGameLocations.Select(gl => ConstructFromBaseClass(gl, copyAllData)).ToList();
- }
-
- public virtual void update(GameTime gameTime)
- {
- }
-
- public override void draw(SpriteBatch b)
- {
- foreach (var v in ModObjects)
- {
- v.Value.draw(b, (int)v.Key.X, (int)v.Key.Y, 0.999f, 1);
- }
- }
-
- public SGameLocation()
- {
- ModObjects = new SerializableDictionary<Vector2, SObject>();
- }
- }
-}
diff --git a/StardewModdingAPI/Manifest.cs b/StardewModdingAPI/Manifest.cs
index 91a28b8b..a1a9b6fb 100644
--- a/StardewModdingAPI/Manifest.cs
+++ b/StardewModdingAPI/Manifest.cs
@@ -17,7 +17,7 @@ namespace StardewModdingAPI
/// <summary>
/// The version of the mod.
/// </summary>
- public virtual string Version { get; set; }
+ public virtual Version Version { get; set; }
/// <summary>
/// A description of the mod.
@@ -39,11 +39,11 @@ namespace StardewModdingAPI
/// </summary>
public virtual string EntryDll { get; set; }
- protected override T GenerateBaseConfig<T>()
+ public override T GenerateDefaultConfig<T>()
{
Name = "";
Authour = "";
- Version = "";
+ Version = new Version(0, 0, 0, "");
Description = "";
UniqueID = Guid.NewGuid().ToString();
PerSaveConfigs = false;
diff --git a/StardewModdingAPI/Mod.cs b/StardewModdingAPI/Mod.cs
index 694499f7..8d08f8de 100644
--- a/StardewModdingAPI/Mod.cs
+++ b/StardewModdingAPI/Mod.cs
@@ -6,34 +6,6 @@ namespace StardewModdingAPI
public class Mod
{
/// <summary>
- /// The name of your mod.
- /// NOTE: THIS IS DEPRECATED AND WILL BE REMOVED IN THE NEXT VERSION OF SMAPI
- /// </summary>
- [Obsolete]
- public virtual string Name { get; set; }
-
- /// <summary>
- /// The name of the mod's authour.
- /// NOTE: THIS IS DEPRECATED AND WILL BE REMOVED IN THE NEXT VERSION OF SMAPI
- /// </summary>
- [Obsolete]
- public virtual string Authour { get; set; }
-
- /// <summary>
- /// The version of the mod.
- /// NOTE: THIS IS DEPRECATED AND WILL BE REMOVED IN THE NEXT VERSION OF SMAPI
- /// </summary>
- [Obsolete]
- public virtual string Version { get; set; }
-
- /// <summary>
- /// A description of the mod.
- /// NOTE: THIS IS DEPRECATED AND WILL BE REMOVED IN THE NEXT VERSION OF SMAPI
- /// </summary>
- [Obsolete]
- public virtual string Description { get; set; }
-
- /// <summary>
/// The mod's manifest
/// </summary>
public Manifest Manifest { get; internal set; }
diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs
index 5a226b1d..41d137d4 100644
--- a/StardewModdingAPI/Program.cs
+++ b/StardewModdingAPI/Program.cs
@@ -9,7 +9,6 @@ using System.Threading;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
-using Newtonsoft.Json;
using StardewModdingAPI.Events;
using StardewModdingAPI.Inheritance;
using StardewModdingAPI.Inheritance.Menus;
@@ -60,10 +59,10 @@ namespace StardewModdingAPI
catch (Exception e)
{
// Catch and display all exceptions.
- StardewModdingAPI.Log.Error("Critical error: " + e);
+ Log.Error("Critical error: " + e);
}
- StardewModdingAPI.Log.Comment("The API will now terminate. Press any key to continue...");
+ Log.Comment("The API will now terminate. Press any key to continue...");
Console.ReadKey();
}
@@ -84,7 +83,7 @@ namespace StardewModdingAPI
/// </summary>
private static void ConfigurePaths()
{
- StardewModdingAPI.Log.Info("Validating api paths...");
+ Log.Info("Validating api paths...");
_modPaths = new List<string>();
//_modContentPaths = new List<string>();
@@ -102,7 +101,7 @@ namespace StardewModdingAPI
//_modContentPaths.ForEach(path => VerifyPath(path));
VerifyPath(Constants.LogPath);
- StardewModdingAPI.Log.Initialize(Constants.LogPath);
+ Log.Initialize(Constants.LogPath);
if (!File.Exists(Constants.ExecutionPath + "\\Stardew Valley.exe"))
{
@@ -115,7 +114,7 @@ namespace StardewModdingAPI
/// </summary>
private static void ConfigureSDV()
{
- StardewModdingAPI.Log.Info("Initializing SDV Assembly...");
+ Log.Info("Initializing SDV Assembly...");
// Load in the assembly - ignores security
StardewAssembly = Assembly.UnsafeLoadFrom(Constants.ExecutionPath + "\\Stardew Valley.exe");
@@ -123,22 +122,22 @@ namespace StardewModdingAPI
StardewGameInfo = StardewProgramType.GetField("gamePtr");
// Change the game's version
- StardewModdingAPI.Log.Verbose("Injecting New SDV Version...");
- Game1.version += string.Format("-Z_MODDED | SMAPI {0}", Constants.VersionString);
+ Log.Verbose("Injecting New SDV Version...");
+ Game1.version += string.Format("-Z_MODDED | SMAPI {0}", Constants.Version.VersionString);
// Create the thread for the game to run in.
gameThread = new Thread(RunGame);
- StardewModdingAPI.Log.Info("Starting SDV...");
+ Log.Info("Starting SDV...");
gameThread.Start();
// Wait for the game to load up
while (!ready) ;
//SDV is running
- StardewModdingAPI.Log.Comment("SDV Loaded Into Memory");
+ Log.Comment("SDV Loaded Into Memory");
//Create definition to listen for input
- StardewModdingAPI.Log.Verbose("Initializing Console Input Thread...");
+ Log.Verbose("Initializing Console Input Thread...");
consoleInputThread = new Thread(ConsoleInputThread);
// The only command in the API (at least it should be, for now)
@@ -150,7 +149,7 @@ namespace StardewModdingAPI
GameEvents.LoadContent += Events_LoadContent;
//Events.MenuChanged += Events_MenuChanged; //Idk right now
- StardewModdingAPI.Log.Verbose("Applying Final SDV Tweaks...");
+ Log.Verbose("Applying Final SDV Tweaks...");
StardewInvoke(() =>
{
gamePtr.IsMouseVisible = false;
@@ -165,10 +164,10 @@ namespace StardewModdingAPI
private static void GameRunInvoker()
{
//Game's in memory now, send the event
- StardewModdingAPI.Log.Verbose("Game Loaded");
+ Log.Verbose("Game Loaded");
GameEvents.InvokeGameLoaded();
- StardewModdingAPI.Log.Comment("Type 'help' for help, or 'help <cmd>' for a command's usage");
+ Log.Comment("Type 'help' for help, or 'help <cmd>' for a command's usage");
//Begin listening to input
consoleInputThread.Start();
@@ -183,8 +182,8 @@ namespace StardewModdingAPI
if (consoleInputThread != null && consoleInputThread.ThreadState == ThreadState.Running)
consoleInputThread.Abort();
- StardewModdingAPI.Log.Verbose("Game Execution Finished");
- StardewModdingAPI.Log.Verbose("Shutting Down...");
+ Log.Verbose("Game Execution Finished");
+ Log.Verbose("Shutting Down...");
Thread.Sleep(100);
Environment.Exit(0);
}
@@ -204,7 +203,7 @@ namespace StardewModdingAPI
}
catch (Exception ex)
{
- StardewModdingAPI.Log.Error("Could not create a path: " + path + "\n\n" + ex);
+ Log.Error("Could not create a path: " + path + "\n\n" + ex);
}
}
@@ -212,18 +211,16 @@ namespace StardewModdingAPI
public static void RunGame()
{
- Application.ThreadException += StardewModdingAPI.Log.Application_ThreadException;
+ Application.ThreadException += Log.Application_ThreadException;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
- AppDomain.CurrentDomain.UnhandledException += StardewModdingAPI.Log.CurrentDomain_UnhandledException;
+ AppDomain.CurrentDomain.UnhandledException += Log.CurrentDomain_UnhandledException;
try
{
gamePtr = new SGame();
- StardewModdingAPI.Log.Verbose("Patching SDV Graphics Profile...");
+ Log.Verbose("Patching SDV Graphics Profile...");
Game1.graphics.GraphicsProfile = GraphicsProfile.HiDef;
LoadMods();
- //DEPRECATED WAY
- LoadMods_OldWay();
StardewForm = Control.FromHandle(gamePtr.Window.Handle).FindForm();
StardewForm.Closing += StardewForm_Closing;
@@ -232,26 +229,10 @@ namespace StardewModdingAPI
StardewGameInfo.SetValue(StardewProgramType, gamePtr);
gamePtr.Run();
-
- #region deprecated
- if (false)
- {
- //Nope, I can't get it to work. I depend on Game1 being an SGame, and can't cast a parent to a child
- //I'm leaving this here in case the community is interested
- //StardewInjectorMod.Entry(true);
- Type gt = StardewAssembly.GetType("StardewValley.Game1", true);
- gamePtr = (SGame)Activator.CreateInstance(gt);
-
- ready = true;
-
- StardewGameInfo.SetValue(StardewProgramType, gamePtr);
- gamePtr.Run();
- }
- #endregion
}
catch (Exception ex)
{
- StardewModdingAPI.Log.Error("Game failed to start: " + ex);
+ Log.Error("Game failed to start: " + ex);
}
}
@@ -270,38 +251,37 @@ namespace StardewModdingAPI
public static void LoadMods()
{
- StardewModdingAPI.Log.Verbose("LOADING MODS");
+ Log.Verbose("LOADING MODS");
foreach (string ModPath in _modPaths)
{
- foreach (String d in Directory.GetDirectories(ModPath))
+ foreach (string d in Directory.GetDirectories(ModPath))
{
- foreach (String s in Directory.GetFiles(d, "manifest.json"))
+ foreach (string s in Directory.GetFiles(d, "manifest.json"))
{
if (s.Contains("StardewInjector"))
continue;
- StardewModdingAPI.Log.Success("Found Manifest: " + s);
+ Log.Success("Found Manifest: " + s);
Manifest manifest = new Manifest();
try
{
string t = File.ReadAllText(s);
if (string.IsNullOrEmpty(t))
{
- StardewModdingAPI.Log.Error("Failed to read mod manifest '{0}'. Manifest is empty!", s);
+ Log.Error("Failed to read mod manifest '{0}'. Manifest is empty!", s);
continue;
}
- //manifest = (Manifest)Config.InitializeConfig(s, manifest);
manifest = manifest.InitializeConfig(s);
if (string.IsNullOrEmpty(manifest.EntryDll))
{
- StardewModdingAPI.Log.Error("Failed to read mod manifest '{0}'. EntryDll is empty!", s);
+ Log.Error("Failed to read mod manifest '{0}'. EntryDll is empty!", s);
continue;
}
}
catch (Exception ex)
{
- StardewModdingAPI.Log.Error("Failed to read mod manifest '{0}'. Exception details:\n" + ex, s);
+ Log.Error("Failed to read mod manifest '{0}'. Exception details:\n" + ex, s);
continue;
}
try
@@ -313,14 +293,14 @@ namespace StardewModdingAPI
if (!Directory.Exists(Path.GetDirectoryName(s)))
{
- StardewModdingAPI.Log.Error("Failed to create psconfigs directory '{0}'. No exception occured.", Path.GetDirectoryName(s));
+ Log.Error("Failed to create psconfigs directory '{0}'. No exception occured.", Path.GetDirectoryName(s));
continue;
}
}
}
catch (Exception ex)
{
- StardewModdingAPI.Log.Error("Failed to create psconfigs directory '{0}'. Exception details:\n" + ex, Path.GetDirectoryName(s));
+ Log.Error("Failed to create psconfigs directory '{0}'. Exception details:\n" + ex, Path.GetDirectoryName(s));
continue;
}
try
@@ -328,7 +308,7 @@ namespace StardewModdingAPI
string targDll = Path.Combine(Path.GetDirectoryName(s), manifest.EntryDll);
if (!File.Exists(targDll))
{
- StardewModdingAPI.Log.Error("Failed to load mod '{0}'. File {1} does not exist!", s, targDll);
+ Log.Error("Failed to load mod '{0}'. File {1} does not exist!", s, targDll);
continue;
}
@@ -336,80 +316,31 @@ namespace StardewModdingAPI
if (mod.DefinedTypes.Count(x => x.BaseType == typeof (Mod)) > 0)
{
- StardewModdingAPI.Log.Verbose("Loading Mod DLL...");
+ Log.Verbose("Loading Mod DLL...");
TypeInfo tar = mod.DefinedTypes.First(x => x.BaseType == typeof (Mod));
Mod m = (Mod) mod.CreateInstance(tar.ToString());
m.PathOnDisk = Path.GetDirectoryName(s);
m.Manifest = manifest;
- StardewModdingAPI.Log.Success("LOADED MOD: {0} by {1} - Version {2} | Description: {3} (@ {4})", m.Manifest.Name, m.Manifest.Authour, m.Manifest.Version, m.Manifest.Description, targDll);
+ Log.Success("LOADED MOD: {0} by {1} - Version {2} | Description: {3} (@ {4})", m.Manifest.Name, m.Manifest.Authour, m.Manifest.Version, m.Manifest.Description, targDll);
Constants.ModsLoaded += 1;
m.Entry();
}
else
{
- StardewModdingAPI.Log.Error("Invalid Mod DLL");
+ Log.Error("Invalid Mod DLL");
}
}
catch (Exception ex)
{
- StardewModdingAPI.Log.Error("Failed to load mod '{0}'. Exception details:\n" + ex, s);
+ Log.Error("Failed to load mod '{0}'. Exception details:\n" + ex, s);
}
}
}
}
- StardewModdingAPI.Log.Success("LOADED {0} MODS", Constants.ModsLoaded);
- if (Config.invalids > 0)
- {
- StardewModdingAPI.Log.Error("LOADED {0} MODS THAT HAVE INVALID CONFIG INIT CALLS\n\tTHESE MODS NEED TO UPDATE", Config.invalids);
- }
+ Log.Success("LOADED {0} MODS", Constants.ModsLoaded);
Console.Title = Constants.ConsoleTitle;
}
- /// <summary>
- /// DEPRECATED. REMOVE
- /// </summary>
- [Obsolete]
- public static void LoadMods_OldWay()
- {
- StardewModdingAPI.Log.Error("LOADING MODS (OLD WAY - DEPRECATED. ANY MODS LOADED THIS WAY NEED TO UPDATE)");
- int loadedMods = 0;
- foreach (string ModPath in _modPaths)
- {
- foreach (String s in Directory.GetFiles(ModPath, "*.dll"))
- {
- if (s.Contains("StardewInjector"))
- continue;
- StardewModdingAPI.Log.Success("Found DLL: " + s);
- try
- {
- Assembly mod = Assembly.UnsafeLoadFrom(s); //to combat internet-downloaded DLLs
-
- if (mod.DefinedTypes.Count(x => x.BaseType == typeof(Mod)) > 0)
- {
- StardewModdingAPI.Log.Verbose("Loading Mod DLL...");
- TypeInfo tar = mod.DefinedTypes.First(x => x.BaseType == typeof(Mod));
- Mod m = (Mod)mod.CreateInstance(tar.ToString());
- m.Manifest = null;
- m.PathOnDisk = Path.GetDirectoryName(s);
- Console.WriteLine("LOADED MOD: {0} by {1} - Version {2} | Description: {3}", m.Name, m.Authour, m.Version, m.Description);
- loadedMods += 1;
- m.Entry();
- }
- else
- {
- StardewModdingAPI.Log.Error("Invalid Mod DLL");
- }
- }
- catch (Exception ex)
- {
- StardewModdingAPI.Log.Error("Failed to load mod '{0}'. Exception details:\n" + ex, s);
- }
- }
- }
- StardewModdingAPI.Log.Error("LOADED {0} MODS THAT NEED TO UPDATE", loadedMods);
- }
-
-
public static void ConsoleInputThread()
{
string input = string.Empty;
@@ -422,7 +353,7 @@ namespace StardewModdingAPI
static void Events_LoadContent(object o, EventArgs e)
{
- StardewModdingAPI.Log.Info("Initializing Debug Assets...");
+ Log.Info("Initializing Debug Assets...");
DebugPixel = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
DebugPixel.SetData(new[] { Color.White });
@@ -458,7 +389,7 @@ namespace StardewModdingAPI
static void Events_MenuChanged(IClickableMenu newMenu)
{
- StardewModdingAPI.Log.Verbose("NEW MENU: " + newMenu.GetType());
+ Log.Verbose("NEW MENU: " + newMenu.GetType());
if (newMenu is GameMenu)
{
Game1.activeClickableMenu = SGameMenu.ConstructFromBaseClass(Game1.activeClickableMenu as GameMenu);
@@ -496,79 +427,17 @@ namespace StardewModdingAPI
{
Command fnd = Command.FindCommand(e.Command.CalledArgs[0]);
if (fnd == null)
- StardewModdingAPI.Log.Error("The command specified could not be found");
+ Log.Error("The command specified could not be found");
else
{
if (fnd.CommandArgs.Length > 0)
- StardewModdingAPI.Log.Info("{0}: {1} - {2}", fnd.CommandName, fnd.CommandDesc, fnd.CommandArgs.ToSingular());
+ Log.Info("{0}: {1} - {2}", fnd.CommandName, fnd.CommandDesc, fnd.CommandArgs.ToSingular());
else
- StardewModdingAPI.Log.Info("{0}: {1}", fnd.CommandName, fnd.CommandDesc);
+ Log.Info("{0}: {1}", fnd.CommandName, fnd.CommandDesc);
}
}
else
- StardewModdingAPI.Log.Info("Commands: " + Command.RegisteredCommands.Select(x => x.CommandName).ToSingular());
- }
-
- #region Logging
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void Log(object o, params object[] format)
- {
- StardewModdingAPI.Log.Info(o, format);
- }
-
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void LogColour(ConsoleColor c, object o, params object[] format)
- {
- StardewModdingAPI.Log.Info(o, format);
- }
-
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void LogInfo(object o, params object[] format)
- {
- StardewModdingAPI.Log.Info(o, format);
- }
-
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void LogError(object o, params object[] format)
- {
- StardewModdingAPI.Log.Error(o, format);
- }
-
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void LogDebug(object o, params object[] format)
- {
- StardewModdingAPI.Log.Debug(o, format);
- }
-
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void LogValueNotSpecified()
- {
- StardewModdingAPI.Log.Error("<value> must be specified");
- }
-
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void LogObjectValueNotSpecified()
- {
- StardewModdingAPI.Log.Error("<object> and <value> must be specified");
- }
-
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void LogValueInvalid()
- {
- StardewModdingAPI.Log.Error("<value> is invalid");
- }
-
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void LogObjectInvalid()
- {
- StardewModdingAPI.Log.Error("<object> is invalid");
- }
-
- [Obsolete("This method is obsolete and will be removed in v0.39, please use the appropriate methods in the Log class")]
- public static void LogValueNotInt32()
- {
- StardewModdingAPI.Log.Error("<value> must be a whole number (Int32)");
+ Log.Info("Commands: " + Command.RegisteredCommands.Select(x => x.CommandName).ToSingular());
}
- #endregion
}
} \ No newline at end of file
diff --git a/StardewModdingAPI/StardewModdingAPI.csproj b/StardewModdingAPI/StardewModdingAPI.csproj
index 2f217795..a2dd442a 100644
--- a/StardewModdingAPI/StardewModdingAPI.csproj
+++ b/StardewModdingAPI/StardewModdingAPI.csproj
@@ -149,7 +149,6 @@
<Compile Include="Inheritance\Menus\SGameMenu.cs" />
<Compile Include="Inheritance\Menus\SInventoryPage.cs" />
<Compile Include="Inheritance\Minigames\SMinigameBase.cs" />
- <Compile Include="Inheritance\SGameLocation.cs" />
<Compile Include="Inheritance\SObject.cs" />
<Compile Include="Log.cs" />
<Compile Include="Manifest.cs" />
@@ -158,6 +157,7 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Inheritance\SGame.cs" />
+ <Compile Include="Version.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
diff --git a/StardewModdingAPI/Version.cs b/StardewModdingAPI/Version.cs
new file mode 100644
index 00000000..824790d6
--- /dev/null
+++ b/StardewModdingAPI/Version.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+
+namespace StardewModdingAPI
+{
+ public struct Version
+ {
+ public int MajorVersion { get; set; }
+ public int MinorVersion { get; set; }
+ public int PatchVersion { get; set; }
+ public string Build { get; set; }
+
+ [JsonIgnore]
+ public string VersionString => $"{MajorVersion}.{MinorVersion}.{PatchVersion} {Build}";
+
+ public Version(int major, int minor, int patch, string build)
+ {
+ MajorVersion = major;
+ MinorVersion = minor;
+ PatchVersion = patch;
+ Build = build;
+ }
+ }
+}
diff --git a/TrainerMod/manifest.json b/TrainerMod/manifest.json
index a85f8dc3..0fb9fa65 100644
--- a/TrainerMod/manifest.json
+++ b/TrainerMod/manifest.json
@@ -1,7 +1,6 @@
{
"Name": "Trainer Mod",
"Authour": "Zoryn",
- "Version": "1.0",
"Description": "Registers several commands to use. Most commands are trainer-like in that they offer forms of cheating.",
"EntryDll": "TrainerMod.dll"
} \ No newline at end of file