From 90d2cd6cafc8242cfd65706c839e0ddfeb1b364a Mon Sep 17 00:00:00 2001 From: Zoryn Date: Thu, 3 Mar 2016 10:04:38 -0500 Subject: update --- StardewModdingAPI.v12.suo | Bin 0 -> 27648 bytes .../Debug/StardewModdingAPI.csproj.FileListAbsolute.txt | 1 + .../DesignTimeResolveAssemblyReferencesInput.cache | Bin 0 -> 6731 bytes 3 files changed, 1 insertion(+) create mode 100644 StardewModdingAPI.v12.suo create mode 100644 TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache diff --git a/StardewModdingAPI.v12.suo b/StardewModdingAPI.v12.suo new file mode 100644 index 00000000..b013dc49 Binary files /dev/null and b/StardewModdingAPI.v12.suo differ diff --git a/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt b/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt index c86a6fc8..3dab321b 100644 --- a/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt +++ b/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt @@ -30,3 +30,4 @@ C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\ C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.exe C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.pdb C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.csprojResolveAssemblyReference.cache +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe.config diff --git a/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 00000000..52390cdd Binary files /dev/null and b/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ -- cgit From eee4e9c0fe434e3c49d53b5b8dcca1836a08abf8 Mon Sep 17 00:00:00 2001 From: Zoryn Date: Thu, 3 Mar 2016 14:01:32 -0500 Subject: updates to change working location --- .gitignore | 7 +- Release/Mods/TrainerMod.dll | Bin 23552 -> 23552 bytes Release/StardewModdingAPI.exe | Bin 67072 -> 69120 bytes StardewModdingAPI.sln | 14 +++- StardewModdingAPI.v12.suo | Bin 27648 -> 68608 bytes StardewModdingAPI/Extensions.cs | 19 +++-- StardewModdingAPI/Mod.cs | 2 +- StardewModdingAPI/Program.cs | 78 ++++++++++++++++++++- StardewModdingAPI/StardewModdingAPI.csproj | 16 ++--- .../StardewModdingAPI.csproj.FileListAbsolute.txt | 10 +++ TrainerMod/TrainerMod.csproj | 3 +- TrainerMod/bin/Debug/Stardew Valley.exe | Bin 0 -> 2185728 bytes TrainerMod/bin/Debug/TrainerMod.dll | Bin 23552 -> 23552 bytes TrainerMod/bin/Debug/TrainerMod.pdb | Bin 0 -> 34304 bytes .../DesignTimeResolveAssemblyReferencesInput.cache | Bin 6731 -> 7012 bytes .../Debug/TrainerMod.csproj.FileListAbsolute.txt | 6 ++ ...TrainerMod.csprojResolveAssemblyReference.cache | Bin 0 -> 75042 bytes TrainerMod/obj/Debug/TrainerMod.dll | Bin 23552 -> 23552 bytes TrainerMod/obj/Debug/TrainerMod.pdb | Bin 0 -> 34304 bytes 19 files changed, 133 insertions(+), 22 deletions(-) create mode 100644 TrainerMod/bin/Debug/Stardew Valley.exe create mode 100644 TrainerMod/bin/Debug/TrainerMod.pdb create mode 100644 TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cache create mode 100644 TrainerMod/obj/Debug/TrainerMod.pdb diff --git a/.gitignore b/.gitignore index 00cc0c56..ab067b03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,11 @@ StardewModdingAPI/bin/ StardewModdingAPI/obj/ +packages/ +StardewInjector/ + *.symlink *.lnk !*.exe -!*.dll \ No newline at end of file +!*.dll + +Release/Mods/StardewInjector.dll \ No newline at end of file diff --git a/Release/Mods/TrainerMod.dll b/Release/Mods/TrainerMod.dll index d6e49439..bcf663ab 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 24cc0edd..5c6d556b 100644 Binary files a/Release/StardewModdingAPI.exe and b/Release/StardewModdingAPI.exe differ diff --git a/StardewModdingAPI.sln b/StardewModdingAPI.sln index e5ffbfd8..76616134 100644 --- a/StardewModdingAPI.sln +++ b/StardewModdingAPI.sln @@ -1,12 +1,14 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 +VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI", "StardewModdingAPI\StardewModdingAPI.csproj", "{F1A573B0-F436-472C-AE29-0B91EA6B9F8F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrainerMod", "TrainerMod\TrainerMod.csproj", "{28480467-1A48-46A7-99F8-236D95225359}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewInjector", "StardewInjector\StardewInjector.csproj", "{C9388F35-68D2-431C-88BB-E26286272256}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +41,16 @@ Global {28480467-1A48-46A7-99F8-236D95225359}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {28480467-1A48-46A7-99F8-236D95225359}.Release|Mixed Platforms.Build.0 = Release|Any CPU {28480467-1A48-46A7-99F8-236D95225359}.Release|x86.ActiveCfg = Release|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Debug|x86.ActiveCfg = Debug|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Release|Any CPU.Build.0 = Release|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {C9388F35-68D2-431C-88BB-E26286272256}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/StardewModdingAPI.v12.suo b/StardewModdingAPI.v12.suo index b013dc49..1351bd7f 100644 Binary files a/StardewModdingAPI.v12.suo and b/StardewModdingAPI.v12.suo differ diff --git a/StardewModdingAPI/Extensions.cs b/StardewModdingAPI/Extensions.cs index 8b99be1c..8fd34b6c 100644 --- a/StardewModdingAPI/Extensions.cs +++ b/StardewModdingAPI/Extensions.cs @@ -29,15 +29,26 @@ namespace StardewModdingAPI return result; } - public static bool IsInt32(this string s) + public static bool IsInt32(this object o) { int i; - return Int32.TryParse(s, out i); + return Int32.TryParse(o.ToString(), out i); } - public static Int32 AsInt32(this string s) + public static Int32 AsInt32(this object o) { - return Int32.Parse(s); + return Int32.Parse(o.ToString()); + } + + public static bool IsBool(this object o) + { + bool b; + return Boolean.TryParse(o.ToString(), out b); + } + + public static bool AsBool(this object o) + { + return Boolean.Parse(o.ToString()); } public static int GetHash(this IEnumerable enumerable) diff --git a/StardewModdingAPI/Mod.cs b/StardewModdingAPI/Mod.cs index 32021b4a..eabdc539 100644 --- a/StardewModdingAPI/Mod.cs +++ b/StardewModdingAPI/Mod.cs @@ -31,7 +31,7 @@ namespace StardewModdingAPI /// /// A basic method that is the entry-point of your mod. It will always be called once when the mod loads. /// - public virtual void Entry() + public virtual void Entry(params object[] objects) { } diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index 313fcbe5..a13f25a8 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -53,6 +53,9 @@ namespace StardewModdingAPI public const bool debug = true; public static bool disableLogging { get; private set; } + public static bool StardewInjectorLoaded { get; private set; } + public static Mod StardewInjectorMod { get; private set; } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -84,7 +87,6 @@ namespace StardewModdingAPI } catch (Exception ex) { - LogError("Could not create a missing ModPath: " + ModPath + "\n\n" + ex); } } @@ -141,9 +143,75 @@ namespace StardewModdingAPI //Load in that assembly. Also, ignore security :D StardewAssembly = Assembly.UnsafeLoadFrom(ExecutionPath + "\\Stardew Valley.exe"); + + foreach (string ModPath in ModPaths) + { + foreach (String s in Directory.GetFiles(ModPath, "StardewInjector.dll")) + { + LogColour(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) + { + LogColour(ConsoleColor.Green, "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}", m.Name, m.Authour, m.Version, m.Description); + m.Entry(false); + StardewInjectorLoaded = true; + StardewInjectorMod = m; + } + else + { + LogError("Invalid Mod DLL"); + } + } + catch (Exception ex) + { + LogError("Failed to load mod '{0}'. Exception details:\n" + ex, s); + } + } + } + StardewProgramType = StardewAssembly.GetType("StardewValley.Program", true); StardewGameInfo = StardewProgramType.GetField("gamePtr"); + /* + if (File.Exists(ExecutionPath + "\\Stardew_Injector.exe")) + { + //Stardew_Injector Mode + StardewInjectorLoaded = true; + Program.LogInfo("STARDEW_INJECTOR DETECTED, LAUNCHING USING INJECTOR CALLS"); + Assembly inj = Assembly.UnsafeLoadFrom(ExecutionPath + "\\Stardew_Injector.exe"); + Type prog = inj.GetType("Stardew_Injector.Program", true); + FieldInfo hooker = prog.GetField("hooker", BindingFlags.NonPublic | BindingFlags.Static); + + //hook.GetMethod("Initialize").Invoke(hooker.GetValue(null), null); + //customize the initialize method for SGame instead of Game + Assembly cecil = Assembly.UnsafeLoadFrom(ExecutionPath + "\\Mono.Cecil.dll"); + Type assDef = cecil.GetType("Mono.Cecil.AssemblyDefinition"); + var aDefs = assDef.GetMethods(BindingFlags.Public | BindingFlags.Static); + var aDef = aDefs.First(x => x.ToString().Contains("ReadAssembly(System.String)")); + var theAssDef = aDef.Invoke(null, new object[] { Assembly.GetExecutingAssembly().Location }); + var modDef = assDef.GetProperty("MainModule", BindingFlags.Public | BindingFlags.Instance); + var theModDef = modDef.GetValue(theAssDef); + Console.WriteLine("MODDEF: " + theModDef); + Type hook = inj.GetType("Stardew_Injector.Stardew_Hooker", true); + hook.GetField("m_vAsmDefinition", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(hooker.GetValue(null), theAssDef); + hook.GetField("m_vModDefinition", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(hooker.GetValue(null), theModDef); + + //hook.GetMethod("Initialize").Invoke(hooker.GetValue(null), null); + hook.GetMethod("ApplyHooks").Invoke(hooker.GetValue(null), null); + //hook.GetMethod("Finalize").Invoke(hooker.GetValue(null), null); + //hook.GetMethod("Run").Invoke(hooker.GetValue(null), null); + + Console.ReadKey(); + //Now go back and load Stardew through SMAPI + } + */ + //Change the game's version LogInfo("Injecting New SDV Version..."); Game1.version += "-Z_MODDED | SMAPI " + Version; @@ -259,6 +327,12 @@ namespace StardewModdingAPI ready = true; + if (StardewInjectorLoaded) + { + //StardewInjectorMod.Entry(true); + StardewAssembly.EntryPoint.Invoke(null, new object[] { new string[0] }); + } + gamePtr.Run(); } catch (Exception ex) @@ -284,6 +358,8 @@ namespace StardewModdingAPI { foreach (String s in Directory.GetFiles(ModPath, "*.dll")) { + if (s.Contains("StardewInjector")) + continue; LogColour(ConsoleColor.Green, "Found DLL: " + s); try { diff --git a/StardewModdingAPI/StardewModdingAPI.csproj b/StardewModdingAPI/StardewModdingAPI.csproj index 9ca0a64b..098bed73 100644 --- a/StardewModdingAPI/StardewModdingAPI.csproj +++ b/StardewModdingAPI/StardewModdingAPI.csproj @@ -47,18 +47,12 @@ icon.ico - - False - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Stardew Valley.exe - False - False + + Z:\Games\Stardew Valley\Stardew Valley.exe @@ -69,10 +63,8 @@ - - False - D:\#Network-Steam\SteamRepo\steamapps\common\Stardew Valley\xTile.dll - False + + Z:\Games\Stardew Valley\xTile.dll diff --git a/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt b/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt index 3dab321b..4cd75334 100644 --- a/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt +++ b/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt @@ -31,3 +31,13 @@ C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\ C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.pdb C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.csprojResolveAssemblyReference.cache C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe.config +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\bin\x86\Debug\steam_appid.txt +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.pdb +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\bin\x86\Debug\Stardew Valley.exe +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\bin\x86\Debug\xTile.dll +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\bin\x86\Debug\Lidgren.Network.dll +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\bin\x86\Debug\Steamworks.NET.dll +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.csprojResolveAssemblyReference.cache +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.exe +C:\Users\zoryn\Documents\GitHub\SMAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.pdb diff --git a/TrainerMod/TrainerMod.csproj b/TrainerMod/TrainerMod.csproj index 301ee296..d98a4228 100644 --- a/TrainerMod/TrainerMod.csproj +++ b/TrainerMod/TrainerMod.csproj @@ -37,8 +37,7 @@ False - D:\#Network-Steam\SteamRepo\steamapps\common\Stardew Valley\Stardew Valley.exe - False + Z:\Games\Stardew Valley\Stardew Valley.exe diff --git a/TrainerMod/bin/Debug/Stardew Valley.exe b/TrainerMod/bin/Debug/Stardew Valley.exe new file mode 100644 index 00000000..c0e1d4be Binary files /dev/null and b/TrainerMod/bin/Debug/Stardew Valley.exe differ diff --git a/TrainerMod/bin/Debug/TrainerMod.dll b/TrainerMod/bin/Debug/TrainerMod.dll index d6e49439..bcf663ab 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 new file mode 100644 index 00000000..21f85abf Binary files /dev/null and b/TrainerMod/bin/Debug/TrainerMod.pdb differ diff --git a/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 52390cdd..7b09d9e8 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 dfc005ea..0b85292c 100644 --- a/TrainerMod/obj/Debug/TrainerMod.csproj.FileListAbsolute.txt +++ b/TrainerMod/obj/Debug/TrainerMod.csproj.FileListAbsolute.txt @@ -3,3 +3,9 @@ C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\bin\Debug\TrainerMod. C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\obj\Debug\TrainerMod.csprojResolveAssemblyReference.cache C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\obj\Debug\TrainerMod.dll C:\TFSource\Master-Collection\StardewModdingAPI\TrainerMod\obj\Debug\TrainerMod.pdb +C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\obj\Debug\TrainerMod.csprojResolveAssemblyReference.cache +C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\obj\Debug\TrainerMod.dll +C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\bin\Debug\TrainerMod.dll +C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\bin\Debug\TrainerMod.pdb +C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\bin\Debug\Stardew Valley.exe +C:\Users\zoryn\Documents\GitHub\SMAPI\TrainerMod\obj\Debug\TrainerMod.pdb diff --git a/TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cache b/TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cache new file mode 100644 index 00000000..13cf99fc Binary files /dev/null and b/TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cache differ diff --git a/TrainerMod/obj/Debug/TrainerMod.dll b/TrainerMod/obj/Debug/TrainerMod.dll index d6e49439..bcf663ab 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 new file mode 100644 index 00000000..21f85abf Binary files /dev/null and b/TrainerMod/obj/Debug/TrainerMod.pdb differ -- cgit From 9a1b910ea32f518b605c88315f192afc6fc40f28 Mon Sep 17 00:00:00 2001 From: Zoryn Date: Thu, 3 Mar 2016 15:06:25 -0500 Subject: resync for merge conflicts --- .gitignore | 1 - Release/Mods/TrainerMod.dll | Bin 23552 -> 24064 bytes Release/StardewModdingAPI.exe | Bin 69120 -> 72704 bytes StardewInjector/App.config | 15 + StardewInjector/CecilUtils.cs | 173 + StardewInjector/Config.cs | 72 + StardewInjector/Program.cs | 30 + StardewInjector/Properties/AssemblyInfo.cs | 36 + StardewInjector/StardewHooker.cs | 190 + StardewInjector/StardewInjector.cs | 55 + StardewInjector/StardewInjector.csproj | 77 + StardewInjector/bin/Debug/Lidgren.Network.dll | Bin 0 -> 123904 bytes .../bin/Debug/Microsoft.Xna.Framework.Game.dll | Bin 0 -> 74752 bytes .../bin/Debug/Microsoft.Xna.Framework.Game.xml | 625 ++ .../bin/Debug/Microsoft.Xna.Framework.Graphics.dll | Bin 0 -> 427520 bytes .../bin/Debug/Microsoft.Xna.Framework.Graphics.xml | 3431 +++++++++ .../bin/Debug/Microsoft.Xna.Framework.Xact.dll | Bin 0 -> 75776 bytes .../bin/Debug/Microsoft.Xna.Framework.Xact.xml | 283 + .../bin/Debug/Microsoft.Xna.Framework.dll | Bin 0 -> 679424 bytes .../bin/Debug/Microsoft.Xna.Framework.xml | 7375 ++++++++++++++++++++ StardewInjector/bin/Debug/Mono.Cecil.dll | Bin 0 -> 280576 bytes StardewInjector/bin/Debug/Stardew Valley.exe | Bin 0 -> 2185728 bytes StardewInjector/bin/Debug/StardewInjector.dll | Bin 0 -> 18432 bytes .../bin/Debug/StardewInjector.dll.config | 15 + StardewInjector/bin/Debug/StardewInjector.pdb | Bin 0 -> 42496 bytes StardewInjector/bin/Debug/StardewModdingAPI.exe | Bin 0 -> 72704 bytes StardewInjector/bin/Debug/StardewModdingAPI.pdb | Bin 0 -> 138752 bytes StardewInjector/bin/Debug/Steamworks.NET.dll | Bin 0 -> 249856 bytes StardewInjector/bin/Debug/steam_appid.txt | 1 + StardewInjector/bin/Debug/xTile.dll | Bin 0 -> 157696 bytes .../DesignTimeResolveAssemblyReferencesInput.cache | Bin 0 -> 7163 bytes .../StardewInjector.csproj.FileListAbsolute.txt | 22 + ...ewInjector.csprojResolveAssemblyReference.cache | Bin 0 -> 60415 bytes StardewInjector/obj/Debug/StardewInjector.dll | Bin 0 -> 18432 bytes StardewInjector/obj/Debug/StardewInjector.pdb | Bin 0 -> 42496 bytes ...tedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs | 0 ...tedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs | 0 ...tedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs | 0 StardewInjector/packages.config | 4 + StardewModdingAPI.sln | 28 +- StardewModdingAPI.v12.suo | Bin 58880 -> 89088 bytes StardewModdingAPI/Command.cs | 2 +- StardewModdingAPI/Program.cs | 540 +- StardewModdingAPI/StardewModdingAPI.csproj | 104 - .../StardewModdingAPI.csproj.FileListAbsolute.txt | 39 - TrainerMod/TrainerMod.cs | 2 +- TrainerMod/TrainerMod.csproj | 1 - TrainerMod/bin/Debug/Lidgren.Network.dll | Bin 0 -> 123904 bytes .../bin/Debug/Microsoft.Xna.Framework.Xact.dll | Bin 0 -> 75776 bytes .../bin/Debug/Microsoft.Xna.Framework.Xact.xml | 283 + TrainerMod/bin/Debug/StardewModdingAPI.exe | Bin 0 -> 72704 bytes TrainerMod/bin/Debug/StardewModdingAPI.pdb | Bin 0 -> 138752 bytes TrainerMod/bin/Debug/Steamworks.NET.dll | Bin 0 -> 249856 bytes TrainerMod/bin/Debug/TrainerMod.dll | Bin 23552 -> 24064 bytes TrainerMod/bin/Debug/TrainerMod.pdb | Bin 34304 -> 34304 bytes TrainerMod/bin/Debug/steam_appid.txt | 1 + TrainerMod/bin/Debug/xTile.dll | Bin 0 -> 157696 bytes .../DesignTimeResolveAssemblyReferencesInput.cache | Bin 6915 -> 7012 bytes .../Debug/TrainerMod.csproj.FileListAbsolute.txt | 8 + ...TrainerMod.csprojResolveAssemblyReference.cache | Bin 75042 -> 79113 bytes TrainerMod/obj/Debug/TrainerMod.dll | Bin 23552 -> 24064 bytes TrainerMod/obj/Debug/TrainerMod.pdb | Bin 34304 -> 34304 bytes UpgradeLog.htm | Bin 0 -> 28862 bytes UpgradeLog2.htm | Bin 0 -> 28862 bytes 64 files changed, 12726 insertions(+), 687 deletions(-) create mode 100644 StardewInjector/App.config create mode 100644 StardewInjector/CecilUtils.cs create mode 100644 StardewInjector/Config.cs create mode 100644 StardewInjector/Program.cs create mode 100644 StardewInjector/Properties/AssemblyInfo.cs create mode 100644 StardewInjector/StardewHooker.cs create mode 100644 StardewInjector/StardewInjector.cs create mode 100644 StardewInjector/StardewInjector.csproj create mode 100644 StardewInjector/bin/Debug/Lidgren.Network.dll create mode 100644 StardewInjector/bin/Debug/Microsoft.Xna.Framework.Game.dll create mode 100644 StardewInjector/bin/Debug/Microsoft.Xna.Framework.Game.xml create mode 100644 StardewInjector/bin/Debug/Microsoft.Xna.Framework.Graphics.dll create mode 100644 StardewInjector/bin/Debug/Microsoft.Xna.Framework.Graphics.xml create mode 100644 StardewInjector/bin/Debug/Microsoft.Xna.Framework.Xact.dll create mode 100644 StardewInjector/bin/Debug/Microsoft.Xna.Framework.Xact.xml create mode 100644 StardewInjector/bin/Debug/Microsoft.Xna.Framework.dll create mode 100644 StardewInjector/bin/Debug/Microsoft.Xna.Framework.xml create mode 100644 StardewInjector/bin/Debug/Mono.Cecil.dll create mode 100644 StardewInjector/bin/Debug/Stardew Valley.exe create mode 100644 StardewInjector/bin/Debug/StardewInjector.dll create mode 100644 StardewInjector/bin/Debug/StardewInjector.dll.config create mode 100644 StardewInjector/bin/Debug/StardewInjector.pdb create mode 100644 StardewInjector/bin/Debug/StardewModdingAPI.exe create mode 100644 StardewInjector/bin/Debug/StardewModdingAPI.pdb create mode 100644 StardewInjector/bin/Debug/Steamworks.NET.dll create mode 100644 StardewInjector/bin/Debug/steam_appid.txt create mode 100644 StardewInjector/bin/Debug/xTile.dll create mode 100644 StardewInjector/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache create mode 100644 StardewInjector/obj/Debug/StardewInjector.csproj.FileListAbsolute.txt create mode 100644 StardewInjector/obj/Debug/StardewInjector.csprojResolveAssemblyReference.cache create mode 100644 StardewInjector/obj/Debug/StardewInjector.dll create mode 100644 StardewInjector/obj/Debug/StardewInjector.pdb create mode 100644 StardewInjector/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs create mode 100644 StardewInjector/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs create mode 100644 StardewInjector/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs create mode 100644 StardewInjector/packages.config create mode 100644 TrainerMod/bin/Debug/Lidgren.Network.dll create mode 100644 TrainerMod/bin/Debug/Microsoft.Xna.Framework.Xact.dll create mode 100644 TrainerMod/bin/Debug/Microsoft.Xna.Framework.Xact.xml create mode 100644 TrainerMod/bin/Debug/StardewModdingAPI.exe create mode 100644 TrainerMod/bin/Debug/StardewModdingAPI.pdb create mode 100644 TrainerMod/bin/Debug/Steamworks.NET.dll create mode 100644 TrainerMod/bin/Debug/steam_appid.txt create mode 100644 TrainerMod/bin/Debug/xTile.dll create mode 100644 UpgradeLog.htm create mode 100644 UpgradeLog2.htm diff --git a/.gitignore b/.gitignore index ab067b03..4737a5d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ StardewModdingAPI/bin/ StardewModdingAPI/obj/ packages/ -StardewInjector/ *.symlink *.lnk diff --git a/Release/Mods/TrainerMod.dll b/Release/Mods/TrainerMod.dll index bcf663ab..d39f4375 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 5c6d556b..c4813237 100644 Binary files a/Release/StardewModdingAPI.exe and b/Release/StardewModdingAPI.exe differ diff --git a/StardewInjector/App.config b/StardewInjector/App.config new file mode 100644 index 00000000..f1914205 --- /dev/null +++ b/StardewInjector/App.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/StardewInjector/CecilUtils.cs b/StardewInjector/CecilUtils.cs new file mode 100644 index 00000000..acdf5198 --- /dev/null +++ b/StardewInjector/CecilUtils.cs @@ -0,0 +1,173 @@ +using Mono.Cecil; +using Mono.Cecil.Cil; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace StardewInjector +{ + public struct ScannerState + { + public ILProcessor ILProcessor; + public Instruction Instruction; + + public ScannerState(ILProcessor ilProc, Instruction ins) + { + ILProcessor = ilProc; + Instruction = ins; + } + + public ScannerState Previous(Func until = null) + { + if (until != null) + { + Instruction cur = this.Instruction; + do + { + cur = cur.Previous; + } while (!until(cur)); + return new ScannerState(this.ILProcessor, cur); + } + return new ScannerState(this.ILProcessor, Instruction.Previous); + } + + public ScannerState Next(Func until = null) + { + if (until != null) + { + Instruction cur = this.Instruction; + do + { + cur = cur.Next; + } while (!until(cur)); + return new ScannerState(this.ILProcessor, cur); + } + return new ScannerState(this.ILProcessor, Instruction.Next); + } + + public ScannerState Last() + { + var instructions = this.ILProcessor.Body.Instructions; + return new ScannerState(this.ILProcessor, instructions[instructions.Count - 1]); + } + + public ScannerState First() + { + var instructions = this.ILProcessor.Body.Instructions; + return new ScannerState(this.ILProcessor, instructions[0]); + } + + public ScannerState ReplaceCreate(OpCode opcode) + { + Instruction ins = this.ILProcessor.Create(opcode); + this.ILProcessor.Replace(this.Instruction, ins); + return new ScannerState(this.ILProcessor, ins); + } + + public ScannerState ReplaceCreate(OpCode opcode, object arg) + { + Instruction ins = this.ILProcessor.Create(opcode, arg as dynamic); + this.ILProcessor.Replace(this.Instruction, ins); + return new ScannerState(this.ILProcessor, ins); + } + + public ScannerState CreateBefore(OpCode opcode) + { + Instruction ins = this.ILProcessor.Create(opcode); + this.ILProcessor.InsertBefore(this.Instruction, ins); + return new ScannerState(this.ILProcessor, ins); + } + + public ScannerState CreateBefore(OpCode opcode, object arg) + { + Instruction ins = this.ILProcessor.Create(opcode, arg as dynamic); + this.ILProcessor.InsertBefore(this.Instruction, ins); + return new ScannerState(this.ILProcessor, ins); + } + + public ScannerState CreateAfter(OpCode opcode) + { + Instruction ins = this.ILProcessor.Create(opcode); + this.ILProcessor.InsertAfter(this.Instruction, ins); + return new ScannerState(this.ILProcessor, ins); + } + + public ScannerState CreateAfter(OpCode opcode, object arg) + { + Instruction ins = this.ILProcessor.Create(opcode, arg as dynamic); + this.ILProcessor.InsertAfter(this.Instruction, ins); + return new ScannerState(this.ILProcessor, ins); + } + } + + public static class CecilUtils + { + public static ScannerState Scanner(this MethodDefinition me) + { + return new ScannerState(me.Body.GetILProcessor(), me.Body.Instructions[0]); + } + + public static ScannerState FindSetField(this MethodDefinition me, string fieldName) + { + var instruction = me.Body.Instructions + .FirstOrDefault(i => i.OpCode == OpCodes.Stsfld && (i.Operand as FieldDefinition).Name == fieldName); + return new ScannerState(me.Body.GetILProcessor(), instruction); + } + + public static ScannerState FindLoadField(this MethodDefinition me, string fieldName) + { + var instruction = me.Body.Instructions + .FirstOrDefault(i => { + if (i.OpCode != OpCodes.Ldfld && i.OpCode != OpCodes.Ldsfld) + return false; + if (i.Operand is FieldDefinition && (i.Operand as FieldDefinition).Name == fieldName) + return true; + if (i.Operand is FieldReference && (i.Operand as FieldReference).Name == fieldName) + return true; + return false; + }); + return new ScannerState(me.Body.GetILProcessor(), instruction); + } + + public static ScannerState FindLoadConstant(this MethodDefinition me, int val) + { + var instruction = me.Body.Instructions + .FirstOrDefault(i => i.OpCode == OpCodes.Ldc_I4 && (int)i.Operand == val); + return new ScannerState(me.Body.GetILProcessor(), instruction); + } + + public static ScannerState FindLoadConstant(this MethodDefinition me, float val) + { + var instruction = me.Body.Instructions + .FirstOrDefault(i => i.OpCode == OpCodes.Ldc_R4 && (float)i.Operand == val); + return new ScannerState(me.Body.GetILProcessor(), instruction); + } + + public static MethodDefinition FindMethod(this ModuleDefinition me, string name) + { + var nameSplit = name.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); + if (nameSplit.Length < 2) + throw new ArgumentException("Invalid method full name", "name"); + + var currentType = me.Types.FirstOrDefault(t => t.FullName == nameSplit[0]); + if (currentType == null) + return null; + + return currentType.Methods.FirstOrDefault(m => m.Name == nameSplit[1]); + } + + public static FieldDefinition FindField(this ModuleDefinition me, string name) + { + var nameSplit = name.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); + if (nameSplit.Length < 2) + throw new ArgumentException("Invalid field full name", "name"); + + var currentType = me.Types.FirstOrDefault(t => t.FullName == nameSplit[0]); + if (currentType == null) + return null; + + return currentType.Fields.FirstOrDefault(m => m.Name == nameSplit[1]); + } + } +} diff --git a/StardewInjector/Config.cs b/StardewInjector/Config.cs new file mode 100644 index 00000000..cea45e98 --- /dev/null +++ b/StardewInjector/Config.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; + +namespace StardewInjector +{ + public static class Config + { + public static bool EnableDebugMode + { + get + { + bool val = false; + bool.TryParse(ConfigurationManager.AppSettings["EnableDebugMode"], out val); + return val; + } + } + + public static bool EnableAlwaysSpawnFishingBubble + { + get + { + bool val = false; + bool.TryParse(ConfigurationManager.AppSettings["EnableAlwaysSpawnFishingBubble"], out val); + return val; + } + } + + public static bool EnableEasyFishing + { + get + { + bool val = false; + bool.TryParse(ConfigurationManager.AppSettings["EnableEasyFishing"], out val); + return val; + } + } + + public static int SecondsPerTenMinutes + { + get + { + int val = 7; + int.TryParse(ConfigurationManager.AppSettings["SecondsPerTenMinutes"], out val); + return val; + } + } + + public static float RunSpeed + { + get + { + float val = 1f; + float.TryParse(ConfigurationManager.AppSettings["RunSpeed"], out val); + return val; + } + } + + public static bool EnableTweakedDiagonalMovement + { + get + { + bool val = false; + bool.TryParse(ConfigurationManager.AppSettings["EnableTweakedDiagonalMovement"], out val); + return val; + } + } + + } +} diff --git a/StardewInjector/Program.cs b/StardewInjector/Program.cs new file mode 100644 index 00000000..41c72240 --- /dev/null +++ b/StardewInjector/Program.cs @@ -0,0 +1,30 @@ +/* +using Mono.Cecil; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace Stardew_Injector +{ + class Program + { + + private static Stardew_Hooker hooker = new Stardew_Hooker(); + + static void Main(string[] args) + { + hooker.Initialize(); + hooker.ApplyHooks(); + hooker.Finalize(); + + hooker.Run(); + Console.ReadLine(); + } + + } +} +*/ \ No newline at end of file diff --git a/StardewInjector/Properties/AssemblyInfo.cs b/StardewInjector/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..0ba4aafe --- /dev/null +++ b/StardewInjector/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("StardewInjector")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("StardewInjector")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("820406dc-ae78-461f-8c7f-6329f34f986c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/StardewInjector/StardewHooker.cs b/StardewInjector/StardewHooker.cs new file mode 100644 index 00000000..a92b96c1 --- /dev/null +++ b/StardewInjector/StardewHooker.cs @@ -0,0 +1,190 @@ +using Microsoft.Xna.Framework; +using Mono.Cecil; +using Mono.Cecil.Cil; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using StardewModdingAPI; + +namespace StardewInjector +{ + public class Stardew_Hooker + { + private AssemblyDefinition m_vAsmDefinition = null; + private ModuleDefinition m_vModDefinition = null; + private Assembly m_vAssembly = null; + + public bool Initialize() + { + Console.WriteLine("Initiating StarDew_Injector...."); + try + { + this.m_vAsmDefinition = AssemblyDefinition.ReadAssembly(@"Stardew Valley.exe"); + this.m_vModDefinition = this.m_vAsmDefinition.MainModule; + return true; + } + catch (Exception ex) + { + Program.LogError(ex); + return false; + } + } + + public bool Finalize() + { + Console.WriteLine("Finalizing StarDew_Injector...."); + try + { + if (this.m_vAsmDefinition == null) + return false; + + using (MemoryStream mStream = new MemoryStream()) + { + // Write the edited data to the memory stream.. + this.m_vAsmDefinition.Write(mStream); + + // Load the new assembly from the memory stream buffer.. + this.m_vAssembly = Assembly.Load(mStream.GetBuffer()); + + Program.StardewAssembly = m_vAssembly; + + return true; + } + } + catch (Exception ex) + { + Program.LogError(ex); + return false; + } + } + + public bool Run() + { + if (this.m_vAssembly == null) + return false; + + Console.WriteLine("Starting Stardew Valley..."); + + m_vAssembly.EntryPoint.Invoke(null, new object[] {new string[0]}); + + return true; + } + + public void ApplyHooks() + { + Console.WriteLine("Applying StarDew_Injector...."); + try + { + InjectMovementSpeed(); + + if (Config.SecondsPerTenMinutes != 7) + InjectClockScale(); + + if (Config.EnableEasyFishing) + InjectEasyFishing(); + + if (Config.EnableAlwaysSpawnFishingBubble) + InjectMoreBubbles(); + + /* + if (Config.EnableDebugMode) + InjectDebugMode(); + */ + } + catch (Exception ex) + { + Program.LogError(ex); + } + + } + + private void InjectDebugMode() + { + this.m_vModDefinition.FindMethod("StardewValley.Program::.cctor") + .FindSetField("releaseBuild").Previous() + .ReplaceCreate(OpCodes.Ldc_I4_0); + + Console.WriteLine("Enabled debug mode."); + } + + private void InjectMoreBubbles() + { + this.m_vModDefinition.FindMethod("StardewValley.GameLocation::performTenMinuteUpdate") + .FindLoadField("currentLocation").Next(i => i.ToString().Contains("NextDouble")).Next() + .ReplaceCreate(OpCodes.Ldc_R8, 1.1); + + Console.WriteLine("Forced each area to always spawn a fishing bubble."); + } + + private void InjectEasyFishing() + { + this.m_vModDefinition.FindMethod("StardewValley.Menus.BobberBar::update") + .FindLoadConstant(694) + .Next(i => i.OpCode == OpCodes.Ldc_R4) + .ReplaceCreate(OpCodes.Ldc_R4, 0.001f) + .Next(i => i.OpCode == OpCodes.Ldc_R4) + .ReplaceCreate(OpCodes.Ldc_R4, 0.001f); + + Console.WriteLine("Replaced fish escape constants for all bobbers & bobber id 694 with 0.001, slowing it down."); + } + + private void InjectClockScale() + { + int timeScale = Config.SecondsPerTenMinutes; + timeScale *= 1000; + + this.m_vModDefinition.FindMethod("StardewValley.Game1::UpdateGameClock") + .FindLoadConstant(7000f) + .ReplaceCreate(OpCodes.Ldc_R4, timeScale*1.0f) + .Next(i => i.OpCode == OpCodes.Ldc_R4 && (float) i.Operand == 7000f) + .ReplaceCreate(OpCodes.Ldc_R4, timeScale*1.0f) + .Next(i => i.OpCode == OpCodes.Ldc_I4 && (int) i.Operand == 7000) + .ReplaceCreate(OpCodes.Ldc_I4, timeScale); + + Console.WriteLine("Updated lighting for new timescale ({0}).", timeScale); + } + + private void InjectMovementSpeed() + { + + + if (Config.EnableTweakedDiagonalMovement) + { + this.m_vModDefinition.FindMethod("StardewValley.Farmer::getMovementSpeed") + .FindLoadField("movementDirections").Next(i => i.OpCode == OpCodes.Ldc_I4_1) + .ReplaceCreate(OpCodes.Ldc_I4_4); + + Console.WriteLine("Removed diagonal movement check."); + } + + if (Config.RunSpeed > 0) + { + this.m_vModDefinition.FindMethod("StardewValley.Farmer::getMovementSpeed") + .FindLoadField("movementDirections").Last().CreateBefore(OpCodes.Ldc_R4, (float) Config.RunSpeed).CreateAfter(OpCodes.Add); + + Console.WriteLine("Added run speed: " + Config.RunSpeed); + } + + + } + + + + private void DumpInstructionsToFile(MethodDefinition methodDefinition) + { + var fileName = string.Format("{0}.{1}.txt", methodDefinition.DeclaringType.Name, methodDefinition.Name); + + using (var stream = File.OpenWrite(Path.Combine(".", fileName))) + using (var writer = new StreamWriter(stream)) + { + var ilProcessor = methodDefinition.Body.GetILProcessor(); + for (int i = 0; i < ilProcessor.Body.Instructions.Count; i++) + writer.WriteLine((i) + ":" + ilProcessor.Body.Instructions[i]); + } + } + } +} \ No newline at end of file diff --git a/StardewInjector/StardewInjector.cs b/StardewInjector/StardewInjector.cs new file mode 100644 index 00000000..055a79f9 --- /dev/null +++ b/StardewInjector/StardewInjector.cs @@ -0,0 +1,55 @@ +using StardewModdingAPI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewInjector +{ + public class StardewInjector : Mod + { + public override string Name + { + get { return "Stardew Injector"; } + } + + public override string Authour + { + get { return "Zoryn Aaron"; } + } + + public override string Version + { + get { return "1.0"; } + } + + public override string Description + { + get { return "Pulled from https://github.com/kevinmurphy678/Stardew_Injector and converted to a mod."; } + } + + public static Stardew_Hooker hooker { get; set; } + public override void Entry(params object[] objects) + { + if (objects.Length <= 0 || (objects.Length > 0 && objects[0].AsBool() == false)) + { + hooker = new Stardew_Hooker(); + hooker.Initialize(); + hooker.ApplyHooks(); + hooker.Finalize(); + + Program.LogInfo("INJECTOR ENTERED"); + } + else if (objects.Length > 0 && objects[0].AsBool() == true) + { + Program.LogInfo("INJECTOR LAUNCHING"); + hooker.Run(); + } + else + { + Program.LogError("INVALID PARAMETERS FOR INJECTOR"); + } + } + } +} diff --git a/StardewInjector/StardewInjector.csproj b/StardewInjector/StardewInjector.csproj new file mode 100644 index 00000000..7987a7bd --- /dev/null +++ b/StardewInjector/StardewInjector.csproj @@ -0,0 +1,77 @@ + + + + + Debug + AnyCPU + {C9388F35-68D2-431C-88BB-E26286272256} + Library + Properties + StardewInjector + StardewInjector + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + Z:\Games\Stardew Valley\Mono.Cecil.dll + + + + + + + + + + + + + + + + + + + + + + + + + {f1a573b0-f436-472c-ae29-0b91ea6b9f8f} + StardewModdingAPI + + + + + mkdir "$(SolutionDir)Release\Mods\" +copy /y "$(SolutionDir)$(ProjectName)\$(OutDir)$(TargetFileName)" "$(SolutionDir)Release\Mods\" + + + \ No newline at end of file diff --git a/StardewInjector/bin/Debug/Lidgren.Network.dll b/StardewInjector/bin/Debug/Lidgren.Network.dll new file mode 100644 index 00000000..2cd9d5b3 Binary files /dev/null and b/StardewInjector/bin/Debug/Lidgren.Network.dll differ diff --git a/StardewInjector/bin/Debug/Microsoft.Xna.Framework.Game.dll b/StardewInjector/bin/Debug/Microsoft.Xna.Framework.Game.dll new file mode 100644 index 00000000..9ba4aa23 Binary files /dev/null and b/StardewInjector/bin/Debug/Microsoft.Xna.Framework.Game.dll differ diff --git a/StardewInjector/bin/Debug/Microsoft.Xna.Framework.Game.xml b/StardewInjector/bin/Debug/Microsoft.Xna.Framework.Game.xml new file mode 100644 index 00000000..d0b7a111 --- /dev/null +++ b/StardewInjector/bin/Debug/Microsoft.Xna.Framework.Game.xml @@ -0,0 +1,625 @@ + + + + + A game component that is notified when it needs to draw itself. + + + Creates a new instance of DrawableGameComponent. + The Game that the game component should be attached to. + + + Releases the unmanaged resources used by the DrawableGameComponent and optionally releases the managed resources. + true to release both managed and unmanaged resources; false to release only unmanaged resources. + + + Called when the DrawableGameComponent needs to be drawn. Override this method with component-specific drawing code. Reference page contains links to related conceptual articles. + Time passed since the last call to Draw. + + + Order in which the component should be drawn, relative to other components that are in the same GameComponentCollection. Reference page contains code sample. + + + Raised when the DrawOrder property changes. + + + + The GraphicsDevice the DrawableGameComponent is associated with. + + + Initializes the component. Override this method to load any non-graphics resources and query for any required services. + + + Called when graphics resources need to be loaded. Override this method to load any component-specific graphics resources. + + + Called when the DrawOrder property changes. Raises the DrawOrderChanged event. + The DrawableGameComponent. + Arguments to the DrawOrderChanged event. + + + Called when the Visible property changes. Raises the VisibleChanged event. + The DrawableGameComponent. + Arguments to the VisibleChanged event. + + + Called when graphics resources need to be unloaded. Override this method to unload any component-specific graphics resources. + + + Indicates whether Draw should be called. + + + Raised when the Visible property changes. + + + + Provides basic graphics device initialization, game logic, and rendering code. + + + Initializes a new instance of this class, which provides basic graphics device initialization, game logic, rendering code, and a game loop. Reference page contains code sample. + + + Raised when the game gains focus. + + + + Starts the drawing of a frame. This method is followed by calls to Draw and EndDraw. + + + Called after all components are initialized but before the first update in the game loop. + + + Gets the collection of GameComponents owned by the game. + + + Gets or sets the current ContentManager. + + + Raised when the game loses focus. + + + + Immediately releases the unmanaged resources used by this object. + + + Releases all resources used by the Game class. + true to release both managed and unmanaged resources; false to release only unmanaged resources. + + + Raised when the game is being disposed. + + + + Reference page contains code sample. + Time passed since the last call to Draw. + + + Ends the drawing of a frame. This method is preceeded by calls to Draw and BeginDraw. + + + Called after the game loop has stopped running before exiting. + + + Exits the game. + + + Raised when the game is exiting. + + + + Allows a Game to attempt to free resources and perform other cleanup operations before garbage collection reclaims the Game. + + + Gets the current GraphicsDevice. + + + Gets or sets the time to sleep when the game is inactive. + + + Called after the Game and GraphicsDevice are created, but before LoadContent. Reference page contains code sample. + + + Indicates whether the game is currently the active application. + + + Gets or sets a value indicating whether to use fixed time steps. + + + Gets or sets a value indicating whether the mouse cursor should be visible. + + + Gets the start up parameters in LaunchParameters. + + + + + + Raises the Activated event. Override this method to add code to handle when the game gains focus. + The Game. + Arguments for the Activated event. + + + Raises the Deactivated event. Override this method to add code to handle when the game loses focus. + The Game. + Arguments for the Deactivated event. + + + Raises an Exiting event. Override this method to add code to handle when the game is exiting. + The Game. + Arguments for the Exiting event. + + + Resets the elapsed time counter. + + + Call this method t