summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--Release/Mods/TrainerMod.dllbin23552 -> 23552 bytes
-rw-r--r--Release/StardewModdingAPI.exebin67072 -> 69120 bytes
-rw-r--r--StardewModdingAPI.sln14
-rw-r--r--StardewModdingAPI.v12.suobin27648 -> 68608 bytes
-rw-r--r--StardewModdingAPI/Extensions.cs19
-rw-r--r--StardewModdingAPI/Mod.cs2
-rw-r--r--StardewModdingAPI/Program.cs78
-rw-r--r--StardewModdingAPI/StardewModdingAPI.csproj16
-rw-r--r--StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt10
-rw-r--r--TrainerMod/TrainerMod.csproj3
-rw-r--r--TrainerMod/bin/Debug/Stardew Valley.exebin0 -> 2185728 bytes
-rw-r--r--TrainerMod/bin/Debug/TrainerMod.dllbin23552 -> 23552 bytes
-rw-r--r--TrainerMod/bin/Debug/TrainerMod.pdbbin0 -> 34304 bytes
-rw-r--r--TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cachebin6731 -> 7012 bytes
-rw-r--r--TrainerMod/obj/Debug/TrainerMod.csproj.FileListAbsolute.txt6
-rw-r--r--TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cachebin0 -> 75042 bytes
-rw-r--r--TrainerMod/obj/Debug/TrainerMod.dllbin23552 -> 23552 bytes
-rw-r--r--TrainerMod/obj/Debug/TrainerMod.pdbbin0 -> 34304 bytes
19 files changed, 133 insertions, 22 deletions
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
--- a/Release/Mods/TrainerMod.dll
+++ b/Release/Mods/TrainerMod.dll
Binary files differ
diff --git a/Release/StardewModdingAPI.exe b/Release/StardewModdingAPI.exe
index 24cc0edd..5c6d556b 100644
--- a/Release/StardewModdingAPI.exe
+++ b/Release/StardewModdingAPI.exe
Binary files 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
--- a/StardewModdingAPI.v12.suo
+++ b/StardewModdingAPI.v12.suo
Binary files 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
/// <summary>
/// A basic method that is the entry-point of your mod. It will always be called once when the mod loads.
/// </summary>
- 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 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <Private>False</Private>
- </Reference>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
- <Reference Include="Stardew Valley, Version=1.0.5900.38427, Culture=neutral, processorArchitecture=x86">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
- <EmbedInteropTypes>False</EmbedInteropTypes>
- <Private>False</Private>
+ <Reference Include="Stardew Valley">
+ <HintPath>Z:\Games\Stardew Valley\Stardew Valley.exe</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -69,10 +63,8 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
- <Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>D:\#Network-Steam\SteamRepo\steamapps\common\Stardew Valley\xTile.dll</HintPath>
- <Private>False</Private>
+ <Reference Include="xTile">
+ <HintPath>Z:\Games\Stardew Valley\xTile.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
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 @@
<Private>False</Private>
</Reference>
<Reference Include="Stardew Valley">
- <HintPath>D:\#Network-Steam\SteamRepo\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
- <Private>False</Private>
+ <HintPath>Z:\Games\Stardew Valley\Stardew Valley.exe</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
diff --git a/TrainerMod/bin/Debug/Stardew Valley.exe b/TrainerMod/bin/Debug/Stardew Valley.exe
new file mode 100644
index 00000000..c0e1d4be
--- /dev/null
+++ b/TrainerMod/bin/Debug/Stardew Valley.exe
Binary files differ
diff --git a/TrainerMod/bin/Debug/TrainerMod.dll b/TrainerMod/bin/Debug/TrainerMod.dll
index d6e49439..bcf663ab 100644
--- a/TrainerMod/bin/Debug/TrainerMod.dll
+++ b/TrainerMod/bin/Debug/TrainerMod.dll
Binary files differ
diff --git a/TrainerMod/bin/Debug/TrainerMod.pdb b/TrainerMod/bin/Debug/TrainerMod.pdb
new file mode 100644
index 00000000..21f85abf
--- /dev/null
+++ b/TrainerMod/bin/Debug/TrainerMod.pdb
Binary files differ
diff --git a/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index 52390cdd..7b09d9e8 100644
--- a/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
+++ b/TrainerMod/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary files 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
--- /dev/null
+++ b/TrainerMod/obj/Debug/TrainerMod.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/TrainerMod/obj/Debug/TrainerMod.dll b/TrainerMod/obj/Debug/TrainerMod.dll
index d6e49439..bcf663ab 100644
--- a/TrainerMod/obj/Debug/TrainerMod.dll
+++ b/TrainerMod/obj/Debug/TrainerMod.dll
Binary files differ
diff --git a/TrainerMod/obj/Debug/TrainerMod.pdb b/TrainerMod/obj/Debug/TrainerMod.pdb
new file mode 100644
index 00000000..21f85abf
--- /dev/null
+++ b/TrainerMod/obj/Debug/TrainerMod.pdb
Binary files differ