summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Program.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-02-07 20:50:41 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-02-07 20:50:41 -0500
commit95a93a05b39d2b27b538ecdb0e6a18f28096c5c2 (patch)
treed225096d50f0b952c8ca80bac80a34209ee85ea4 /src/StardewModdingAPI/Program.cs
parent99d0450b2cb291d565cb836de9f132ca657472c1 (diff)
downloadSMAPI-95a93a05b39d2b27b538ecdb0e6a18f28096c5c2.tar.gz
SMAPI-95a93a05b39d2b27b538ecdb0e6a18f28096c5c2.tar.bz2
SMAPI-95a93a05b39d2b27b538ecdb0e6a18f28096c5c2.zip
remove oldest deprecated code (#231)
Since Stardew Valley 1.2 breaks most mods anyway, this commits removes the oldest deprecations and fixes the issues that are easiest for mods to update. See documentation for details.
Diffstat (limited to 'src/StardewModdingAPI/Program.cs')
-rw-r--r--src/StardewModdingAPI/Program.cs46
1 files changed, 17 insertions, 29 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index 45bf1238..c0a05e2d 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -14,14 +14,13 @@ using StardewModdingAPI.AssemblyRewriters;
using StardewModdingAPI.Events;
using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Models;
-using StardewModdingAPI.Inheritance;
using StardewValley;
using Monitor = StardewModdingAPI.Framework.Monitor;
namespace StardewModdingAPI
{
/// <summary>The main entry point for SMAPI, responsible for hooking into and launching the game.</summary>
- public class Program
+ internal class Program
{
/*********
** Properties
@@ -52,31 +51,27 @@ namespace StardewModdingAPI
/// <summary>Tracks whether the game should exit immediately and any pending initialisation should be cancelled.</summary>
private static readonly CancellationTokenSource CancellationTokenSource = new CancellationTokenSource();
-
- /*********
- ** Accessors
- *********/
- /// <summary>The number of mods currently loaded by SMAPI.</summary>
- public static int ModsLoaded;
-
- /// <summary>The underlying game instance.</summary>
- public static SGame gamePtr;
-
/// <summary>Whether the game is currently running.</summary>
- public static bool ready;
+ private static bool ready;
/// <summary>The underlying game assembly.</summary>
- public static Assembly StardewAssembly;
+ private static Assembly StardewAssembly;
/// <summary>The underlying <see cref="StardewValley.Program"/> type.</summary>
- public static Type StardewProgramType;
+ private static Type StardewProgramType;
/// <summary>The field containing game's main instance.</summary>
- public static FieldInfo StardewGameInfo;
+ private static FieldInfo StardewGameInfo;
- // ReSharper disable once PossibleNullReferenceException
- /// <summary>The game's build type (i.e. GOG vs Steam).</summary>
- public static int BuildType => (int)Program.StardewProgramType.GetField("buildType", BindingFlags.Public | BindingFlags.Static).GetValue(null);
+
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The underlying game instance.</summary>
+ internal static SGame gamePtr;
+
+ /// <summary>The number of mods currently loaded by SMAPI.</summary>
+ internal static int ModsLoaded;
/// <summary>Tracks the installed mods.</summary>
internal static readonly ModRegistry ModRegistry = new ModRegistry();
@@ -358,7 +353,7 @@ namespace StardewModdingAPI
string errorPrefix = $"Couldn't load mod for manifest '{manifestPath}'";
// read manifest
- ManifestImpl manifest;
+ Manifest manifest;
try
{
// read manifest text
@@ -370,7 +365,7 @@ namespace StardewModdingAPI
}
// deserialise manifest
- manifest = helper.ReadJsonFile<ManifestImpl>("manifest.json");
+ manifest = helper.ReadJsonFile<Manifest>("manifest.json");
if (manifest == null)
{
Program.Monitor.Log($"{errorPrefix}: the manifest file does not exist.", LogLevel.Error);
@@ -381,10 +376,6 @@ namespace StardewModdingAPI
Program.Monitor.Log($"{errorPrefix}: manifest doesn't specify an entry DLL.", LogLevel.Error);
continue;
}
-
- // log deprecated fields
- if (manifest.UsedAuthourField)
- deprecationWarnings.Add(() => Program.DeprecationManager.Warn(manifest.Name, $"{nameof(Manifest)}.{nameof(Manifest.Authour)}", "1.0", DeprecationLevel.Notice));
}
catch (Exception ex)
{
@@ -424,7 +415,7 @@ namespace StardewModdingAPI
}
catch (FormatException ex) when (ex.Message.Contains("not a valid semantic version"))
{
- Program.Monitor.Log($"{errorPrefix}: the mod specified an invalid minimum SMAPI version '{manifest.MinimumApiVersion}'. This should be a semantic version number like {Constants.Version}.", LogLevel.Error);
+ Program.Monitor.Log($"{errorPrefix}: the mod specified an invalid minimum SMAPI version '{manifest.MinimumApiVersion}'. This should be a semantic version number like {Constants.ApiVersion}.", LogLevel.Error);
continue;
}
}
@@ -528,14 +519,11 @@ namespace StardewModdingAPI
{
// call entry methods
mod.Entry(); // deprecated since 1.0
- mod.Entry((ModHelper)mod.Helper); // deprecated since 1.1
mod.Entry(mod.Helper);
// raise deprecation warning for old Entry() methods
if (Program.DeprecationManager.IsVirtualMethodImplemented(mod.GetType(), typeof(Mod), nameof(Mod.Entry), new[] { typeof(object[]) }))
Program.DeprecationManager.Warn(mod.ModManifest.Name, $"{nameof(Mod)}.{nameof(Mod.Entry)}(object[]) instead of {nameof(Mod)}.{nameof(Mod.Entry)}({nameof(IModHelper)})", "1.0", DeprecationLevel.Notice);
- if (Program.DeprecationManager.IsVirtualMethodImplemented(mod.GetType(), typeof(Mod), nameof(Mod.Entry), new[] { typeof(ModHelper) }))
- Program.DeprecationManager.Warn(mod.ModManifest.Name, $"{nameof(Mod)}.{nameof(Mod.Entry)}({nameof(ModHelper)}) instead of {nameof(Mod)}.{nameof(Mod.Entry)}({nameof(IModHelper)})", "1.1", DeprecationLevel.PendingRemoval);
}
catch (Exception ex)
{