summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--StardewModdingAPI/Mod.cs25
-rw-r--r--StardewModdingAPI/Program.cs92
-rw-r--r--TrainerMod/TrainerMod.csproj6
3 files changed, 75 insertions, 48 deletions
diff --git a/StardewModdingAPI/Mod.cs b/StardewModdingAPI/Mod.cs
index 4b923fd7..b323b6ec 100644
--- a/StardewModdingAPI/Mod.cs
+++ b/StardewModdingAPI/Mod.cs
@@ -9,6 +9,31 @@ 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>
+ 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>
+ 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>
+ 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>
+ 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 6d137a68..92c6c079 100644
--- a/StardewModdingAPI/Program.cs
+++ b/StardewModdingAPI/Program.cs
@@ -50,7 +50,6 @@ namespace StardewModdingAPI
{
ConfigureUI();
ConfigurePaths();
- ConfigureInjector();
ConfigureSDV();
GameRunInvoker();
@@ -107,51 +106,6 @@ namespace StardewModdingAPI
}
/// <summary>
- /// Load the injector.
- /// Is this deprecated? Why is there a LoadMods?
- /// </summary>
- /// <remarks>
- /// This will load the injector before anything else if it sees it
- /// It doesn't matter though
- /// I'll leave it as a feature in case anyone in the community wants to tinker with it
- /// All you need is a DLL that inherits from mod and is called StardewInjector.dll with an Entry() method
- /// </remarks>
- private static void ConfigureInjector()
- {
- foreach (string ModPath in _modPaths)
- {
- foreach (String s in Directory.GetFiles(ModPath, "StardewInjector.dll"))
- {
- StardewModdingAPI.Log.Success(ConsoleColor.Green, "Found Stardew Injector 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.Success("Loading Injector DLL...");
- TypeInfo tar = mod.DefinedTypes.First(x => x.BaseType == typeof(Mod));
- Mod m = (Mod)mod.CreateInstance(tar.ToString());
- Console.WriteLine("LOADED: {0} by {1} - Version {2} | Description: {3} (@:{4})", m.Manifest.Name, m.Manifest.Authour, m.Manifest.Version, m.Manifest.Description, s);
- m.PathOnDisk = Path.GetDirectoryName(s);
- m.Entry(false);
- StardewInjectorLoaded = true;
- StardewInjectorMod = m;
- }
- else
- {
- StardewModdingAPI.Log.Error("Invalid Mod DLL");
- }
- }
- catch (Exception ex)
- {
- StardewModdingAPI.Log.Error("Failed to load mod '{0}'. Exception details:\n" + ex, s);
- }
- }
- }
- }
-
- /// <summary>
/// Load Stardev Valley and control features
/// </summary>
private static void ConfigureSDV()
@@ -263,6 +217,8 @@ namespace StardewModdingAPI
StardewModdingAPI.Log.Verbose("Patching SDV Graphics Profile...");
Game1.graphics.GraphicsProfile = GraphicsProfile.HiDef;
LoadMods();
+ //DEPRECATED WAY
+ LoadMods_OldWay();
StardewForm = Control.FromHandle(Program.gamePtr.Window.Handle).FindForm();
StardewForm.Closing += StardewForm_Closing;
@@ -379,6 +335,50 @@ namespace StardewModdingAPI
StardewModdingAPI.Log.Success("LOADED {0} MODS", loadedMods);
}
+ /// <summary>
+ /// DEPRECATED. REMOVE
+ /// </summary>
+ public static void LoadMods_OldWay()
+ {
+ StardewModdingAPI.Log.Verbose("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.Success("LOADED {0} MODS THAT NEED TO UPDATE", loadedMods);
+ }
+
+
public static void ConsoleInputThread()
{
string input = string.Empty;
diff --git a/TrainerMod/TrainerMod.csproj b/TrainerMod/TrainerMod.csproj
index 6424ecdb..8f1a494f 100644
--- a/TrainerMod/TrainerMod.csproj
+++ b/TrainerMod/TrainerMod.csproj
@@ -54,7 +54,7 @@
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
- <Private>True</Private>
+ <Private>False</Private>
</Reference>
<Reference Include="Stardew Valley">
<HintPath>$(SteamPath)\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
@@ -85,7 +85,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <None Include="manifest.json" />
+ <None Include="manifest.json">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />