diff --git a/Release/Mods/TrainerMod.dll b/Release/Mods/TrainerMod.dll index d39f4375..f508923b 100644 Binary files a/Release/Mods/TrainerMod.dll and b/Release/Mods/TrainerMod.dll differ diff --git a/Release/StardewModdingAPI.exe b/Release/StardewModdingAPI.exe index 001ada22..934e9570 100644 Binary files a/Release/StardewModdingAPI.exe and b/Release/StardewModdingAPI.exe differ diff --git a/StardewInjector/bin/Debug/StardewInjector.dll b/StardewInjector/bin/Debug/StardewInjector.dll index ec198674..edc2b8bc 100644 Binary files a/StardewInjector/bin/Debug/StardewInjector.dll and b/StardewInjector/bin/Debug/StardewInjector.dll differ diff --git a/StardewInjector/bin/Debug/StardewInjector.pdb b/StardewInjector/bin/Debug/StardewInjector.pdb index ea65643b..3d35d4d8 100644 Binary files a/StardewInjector/bin/Debug/StardewInjector.pdb and b/StardewInjector/bin/Debug/StardewInjector.pdb differ diff --git a/StardewInjector/bin/Debug/StardewModdingAPI.exe b/StardewInjector/bin/Debug/StardewModdingAPI.exe index c1090547..7389ad0c 100644 Binary files a/StardewInjector/bin/Debug/StardewModdingAPI.exe and b/StardewInjector/bin/Debug/StardewModdingAPI.exe differ diff --git a/StardewInjector/bin/Debug/StardewModdingAPI.pdb b/StardewInjector/bin/Debug/StardewModdingAPI.pdb index 07545045..a3d7d1b0 100644 Binary files a/StardewInjector/bin/Debug/StardewModdingAPI.pdb and b/StardewInjector/bin/Debug/StardewModdingAPI.pdb differ diff --git a/StardewInjector/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/StardewInjector/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 836ea946..69432333 100644 Binary files a/StardewInjector/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/StardewInjector/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/StardewInjector/obj/Debug/StardewInjector.csproj.FileListAbsolute.txt b/StardewInjector/obj/Debug/StardewInjector.csproj.FileListAbsolute.txt index 95f28c1a..7c17c873 100644 --- a/StardewInjector/obj/Debug/StardewInjector.csproj.FileListAbsolute.txt +++ b/StardewInjector/obj/Debug/StardewInjector.csproj.FileListAbsolute.txt @@ -20,3 +20,23 @@ C:\Users\zoryn\Documents\GitHub\SMAPI\StardewInjector\bin\Debug\Microsoft.Xna.Fr C:\Users\zoryn\Documents\GitHub\SMAPI\StardewInjector\bin\Debug\Microsoft.Xna.Framework.Xact.xml C:\Users\zoryn\Documents\GitHub\SMAPI\StardewInjector\obj\Debug\StardewInjector.dll C:\Users\zoryn\Documents\GitHub\SMAPI\StardewInjector\obj\Debug\StardewInjector.pdb +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\StardewInjector.dll.config +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\StardewInjector.dll +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\StardewInjector.pdb +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Microsoft.Xna.Framework.dll +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Microsoft.Xna.Framework.Game.dll +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\StardewModdingAPI.exe +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Stardew Valley.exe +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Microsoft.Xna.Framework.Graphics.dll +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\xTile.dll +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Lidgren.Network.dll +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Microsoft.Xna.Framework.Xact.dll +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Steamworks.NET.dll +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\StardewModdingAPI.pdb +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Microsoft.Xna.Framework.xml +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Microsoft.Xna.Framework.Game.xml +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Microsoft.Xna.Framework.Graphics.xml +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\bin\Debug\Microsoft.Xna.Framework.Xact.xml +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\obj\Debug\StardewInjector.csprojResolveAssemblyReference.cache +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\obj\Debug\StardewInjector.dll +C:\TFSource\Master-Collection\StardewModdingAPI\StardewInjector\obj\Debug\StardewInjector.pdb diff --git a/StardewInjector/obj/Debug/StardewInjector.csprojResolveAssemblyReference.cache b/StardewInjector/obj/Debug/StardewInjector.csprojResolveAssemblyReference.cache index e17ed343..3cc9e142 100644 Binary files a/StardewInjector/obj/Debug/StardewInjector.csprojResolveAssemblyReference.cache and b/StardewInjector/obj/Debug/StardewInjector.csprojResolveAssemblyReference.cache differ diff --git a/StardewInjector/obj/Debug/StardewInjector.dll b/StardewInjector/obj/Debug/StardewInjector.dll index ec198674..edc2b8bc 100644 Binary files a/StardewInjector/obj/Debug/StardewInjector.dll and b/StardewInjector/obj/Debug/StardewInjector.dll differ diff --git a/StardewInjector/obj/Debug/StardewInjector.pdb b/StardewInjector/obj/Debug/StardewInjector.pdb index ea65643b..3d35d4d8 100644 Binary files a/StardewInjector/obj/Debug/StardewInjector.pdb and b/StardewInjector/obj/Debug/StardewInjector.pdb differ diff --git a/StardewModdingAPI.v12.suo b/StardewModdingAPI.v12.suo index 0f5c0fce..6a286e20 100644 Binary files a/StardewModdingAPI.v12.suo and b/StardewModdingAPI.v12.suo differ diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index a7065c69..e7169bde 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -144,6 +144,10 @@ namespace StardewModdingAPI //Load in that assembly. Also, ignore security :D StardewAssembly = Assembly.UnsafeLoadFrom(ExecutionPath + "\\Stardew Valley.exe"); + //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 foreach (string ModPath in ModPaths) { foreach (String s in Directory.GetFiles(ModPath, "StardewInjector.dll")) @@ -153,11 +157,11 @@ namespace StardewModdingAPI { Assembly mod = Assembly.UnsafeLoadFrom(s); //to combat internet-downloaded DLLs - if (mod.DefinedTypes.Count(x => x.BaseType == typeof(Mod)) > 0) + if (mod.DefinedTypes.Count(x => x.BaseType == typeof (Mod)) > 0) { LogColour(ConsoleColor.Green, "Loading Injector DLL..."); - TypeInfo tar = mod.DefinedTypes.First(x => x.BaseType == typeof(Mod)); - Mod m = (Mod)mod.CreateInstance(tar.ToString()); + 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}", m.Name, m.Authour, m.Version, m.Description); m.Entry(false); StardewInjectorLoaded = true; @@ -178,7 +182,9 @@ namespace StardewModdingAPI StardewProgramType = StardewAssembly.GetType("StardewValley.Program", true); StardewGameInfo = StardewProgramType.GetField("gamePtr"); + #region deprecated /* + * Lol no. I tried though. if (File.Exists(ExecutionPath + "\\Stardew_Injector.exe")) { //Stardew_Injector Mode @@ -211,6 +217,7 @@ namespace StardewModdingAPI //Now go back and load Stardew through SMAPI } */ + #endregion //Change the game's version LogInfo("Injecting New SDV Version..."); @@ -327,17 +334,24 @@ namespace StardewModdingAPI ready = true; - if (StardewInjectorLoaded) + 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); - StardewAssembly.EntryPoint.Invoke(null, new object[] {new string[0]}); - StardewGameInfo.SetValue(StardewProgramType, gamePtr); - } - else - { + Type gt = StardewAssembly.GetType("StardewValley.Game1", true); + gamePtr = (SGame)Activator.CreateInstance(gt); + + ready = true; + StardewGameInfo.SetValue(StardewProgramType, gamePtr); gamePtr.Run(); } + #endregion } catch (Exception ex) { @@ -348,10 +362,14 @@ namespace StardewModdingAPI static void StardewForm_Closing(object sender, CancelEventArgs e) { e.Cancel = true; - gamePtr.Exit(); - gamePtr.Dispose(); - StardewForm.Hide(); - ready = false; + + if (true || MessageBox.Show("Are you sure you would like to quit Stardew Valley?\nUnsaved progress will be lost!", "Confirm Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) + { + gamePtr.Exit(); + gamePtr.Dispose(); + StardewForm.Hide(); + ready = false; + } } public static void LoadMods() diff --git a/StardewModdingAPI/StardewModdingAPI.csproj b/StardewModdingAPI/StardewModdingAPI.csproj index 3e39ce98..b642598d 100644 --- a/StardewModdingAPI/StardewModdingAPI.csproj +++ b/StardewModdingAPI/StardewModdingAPI.csproj @@ -94,9 +94,7 @@ - - PreserveNewest - + diff --git a/TrainerMod/bin/Debug/StardewModdingAPI.exe b/TrainerMod/bin/Debug/StardewModdingAPI.exe index c1090547..7389ad0c 100644 Binary files a/TrainerMod/bin/Debug/StardewModdingAPI.exe and b/TrainerMod/bin/Debug/StardewModdingAPI.exe differ diff --git a/TrainerMod/bin/Debug/StardewModdingAPI.pdb b/TrainerMod/bin/Debug/StardewModdingAPI.pdb index 07545045..a3d7d1b0 100644 Binary files a/TrainerMod/bin/Debug/StardewModdingAPI.pdb and b/TrainerMod/bin/Debug/StardewModdingAPI.pdb differ diff --git a/TrainerMod/bin/Debug/TrainerMod.dll b/TrainerMod/bin/Debug/TrainerMod.dll index d39f4375..f508923b 100644 Binary files a/TrainerMod/bin/Debug/TrainerMod.dll and b/TrainerMod/bin/Debug/TrainerMod.dll differ diff --git a/TrainerMod/bin/Debug/TrainerMod.pdb b/TrainerMod/bin/Debug/TrainerMod.pdb index e20c53af..06152379 100644 Binary files a/TrainerMod/bin/Debug/TrainerMod.pdb and b/TrainerMod/bin/Debug/TrainerMod.pdb differ diff --git a/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 7b09d9e8..171a61ae 100644 Binary files a/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/TrainerMod/obj/Debug/TrainerMod.csproj.FileListAbsolute.txt b/TrainerMod/obj/Debug/TrainerMod.csproj.FileListAbsolute.txt index 9a9d9045..4ec02324 100644 --- a/TrainerMod/obj/Debug/TrainerMod.csproj.FileListAbsolute.txt +++ b/TrainerMod/obj/Debug/TrainerMod.csproj.FileListAbsolute.txt @@ -17,3 +17,10 @@ C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\bin\Debug\Microsoft.Xna.Framewo C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\bin\Debug\Steamworks.NET.dll C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\bin\Debug\StardewModdingAPI.pdb C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\bin\Debug\Microsoft.Xna.Framework.Xact.xml +C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\bin\Debug\StardewModdingAPI.exe +C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\bin\Debug\xTile.dll +C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\bin\Debug\Lidgren.Network.dll +C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\bin\Debug\Microsoft.Xna.Framework.Xact.dll +C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\bin\Debug\Steamworks.NET.dll +C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\bin\Debug\StardewModdingAPI.pdb +C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\bin\Debug\Microsoft.Xna.Framework.Xact.xml diff --git a/TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cache b/TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cache index cc53004f..62384c20 100644 Binary files a/TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cache and b/TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cache differ diff --git a/TrainerMod/obj/Debug/TrainerMod.dll b/TrainerMod/obj/Debug/TrainerMod.dll index d39f4375..f508923b 100644 Binary files a/TrainerMod/obj/Debug/TrainerMod.dll and b/TrainerMod/obj/Debug/TrainerMod.dll differ diff --git a/TrainerMod/obj/Debug/TrainerMod.pdb b/TrainerMod/obj/Debug/TrainerMod.pdb index e20c53af..06152379 100644 Binary files a/TrainerMod/obj/Debug/TrainerMod.pdb and b/TrainerMod/obj/Debug/TrainerMod.pdb differ