updates to change working location

This commit is contained in:
Zoryn 2016-03-03 14:01:32 -05:00
parent 90d2cd6caf
commit eee4e9c0fe
19 changed files with 133 additions and 22 deletions

7
.gitignore vendored
View File

@ -1,6 +1,11 @@
StardewModdingAPI/bin/
StardewModdingAPI/obj/
packages/
StardewInjector/
*.symlink
*.lnk
!*.exe
!*.dll
!*.dll
Release/Mods/StardewInjector.dll

Binary file not shown.

Binary file not shown.

View File

@ -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

Binary file not shown.

View File

@ -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)

View File

@ -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)
{
}

View File

@ -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
{

View File

@ -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>

View File

@ -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

View File

@ -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" />

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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

Binary file not shown.

Binary file not shown.