diff options
-rw-r--r-- | Release/Mods/TrainerMod.dll | bin | 22528 -> 23040 bytes | |||
-rw-r--r-- | Release/SMAPI_0.31A.zip | bin | 0 -> 29642 bytes | |||
-rw-r--r-- | Release/SMAPI_0.3A.zip | bin | 29822 -> 0 bytes | |||
-rw-r--r-- | Release/StardewModdingAPI.exe | bin | 57344 -> 58368 bytes | |||
-rw-r--r-- | StardewModdingAPI/Program.cs | 72 | ||||
-rw-r--r-- | TrainerMod/TrainerMod.cs | 47 | ||||
-rw-r--r-- | TrainerMod/bin/Debug/TrainerMod.dll | bin | 22528 -> 23040 bytes | |||
-rw-r--r-- | TrainerMod/obj/Debug/TrainerMod.dll | bin | 22528 -> 23040 bytes |
8 files changed, 98 insertions, 21 deletions
diff --git a/Release/Mods/TrainerMod.dll b/Release/Mods/TrainerMod.dll Binary files differindex 8c80a376..d30355e9 100644 --- a/Release/Mods/TrainerMod.dll +++ b/Release/Mods/TrainerMod.dll diff --git a/Release/SMAPI_0.31A.zip b/Release/SMAPI_0.31A.zip Binary files differnew file mode 100644 index 00000000..70c538f2 --- /dev/null +++ b/Release/SMAPI_0.31A.zip diff --git a/Release/SMAPI_0.3A.zip b/Release/SMAPI_0.3A.zip Binary files differdeleted file mode 100644 index a20c66e7..00000000 --- a/Release/SMAPI_0.3A.zip +++ /dev/null diff --git a/Release/StardewModdingAPI.exe b/Release/StardewModdingAPI.exe Binary files differindex fc4e475c..6761f582 100644 --- a/Release/StardewModdingAPI.exe +++ b/Release/StardewModdingAPI.exe diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index c2bb1836..af765f97 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -49,7 +49,7 @@ namespace StardewModdingAPI public static Thread gameThread; public static Thread consoleInputThread; - public const string Version = "0.31 Alpha"; + public const string Version = "0.3x Alpha"; public const bool debug = false; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -60,7 +60,7 @@ namespace StardewModdingAPI Console.Title += " - Version " + Version; if (debug) - Console.Title += " - DEBUG IS NOT FALSE, AUTHOUR FORGET TO INCREMENT VERSION VARS"; + Console.Title += " - DEBUG IS NOT FALSE, AUTHOUR FORGOT TO INCREMENT VERSION VARS"; Application.ThreadException += Application_ThreadException; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); @@ -69,19 +69,44 @@ namespace StardewModdingAPI ExecutionPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ModPaths.Add(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods")); ModPaths.Add(Path.Combine(ExecutionPath, "Mods")); + ModPaths.Add(Path.Combine(Path.Combine(ExecutionPath, "Mods"), "Content")); ModContentPaths.Add(Path.Combine(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods"), "Content")); foreach (string ModPath in ModPaths) { - if (File.Exists(ModPath)) - File.Delete(ModPath); - if (!Directory.Exists(ModPath)) - Directory.CreateDirectory(ModPath); + try + { + if (File.Exists(ModPath)) + File.Delete(ModPath); + if (!Directory.Exists(ModPath)) + Directory.CreateDirectory(ModPath); + } + catch (Exception ex) + { + LogError("Could not create a missing ModPath: " + ModPath + "\n\n" + ex); + } } foreach (string ModContentPath in ModContentPaths) { - if (!Directory.Exists(ModContentPath)) - Directory.CreateDirectory(ModContentPath); + try + { + if (!Directory.Exists(ModContentPath)) + Directory.CreateDirectory(ModContentPath); + } + catch (Exception ex) + { + LogError("Could not create a missing ModContentPath: " + ModContentPath + "\n\n" + ex); + } + } + + try + { + if (Directory.Exists(LogPath)) + Directory.CreateDirectory(LogPath); + } + catch (Exception ex) + { + LogError("Could not create the missing ErrorLogs path: " + LogPath + "\n\n" + ex); } CurrentLog = LogPath + "\\MODDED_ProgramLog_" + System.DateTime.Now.Ticks + ".txt"; @@ -106,7 +131,7 @@ namespace StardewModdingAPI LogInfo("Injecting New SDV Version..."); - Game1.version += "-Z_MODDED"; + Game1.version += "-Z_MODDED | SMAPI " + Version; gameThread = new Thread(RunGame); LogInfo("Starting SDV..."); @@ -221,20 +246,27 @@ namespace StardewModdingAPI foreach (String s in Directory.GetFiles(ModPath, "*.dll")) { LogColour(ConsoleColor.Green, "Found DLL: " + s); - Assembly mod = Assembly.LoadFile(s); - - if (mod.DefinedTypes.Count(x => x.BaseType == typeof (Mod)) > 0) + try { - LogColour(ConsoleColor.Green, "Loading Mod DLL..."); - TypeInfo tar = mod.DefinedTypes.First(x => x.BaseType == typeof (Mod)); - Mod m = (Mod) mod.CreateInstance(tar.ToString()); - Console.WriteLine("LOADED MOD: {0} by {1} - Version {2} | Description: {3}", m.Name, m.Authour, m.Version, m.Description); - loadedMods += 1; - m.Entry(); + Assembly mod = Assembly.UnsafeLoadFrom(s); //to combat internet-downloaded DLLs + + if (mod.DefinedTypes.Count(x => x.BaseType == typeof (Mod)) > 0) + { + LogColour(ConsoleColor.Green, "Loading Mod DLL..."); + TypeInfo tar = mod.DefinedTypes.First(x => x.BaseType == typeof (Mod)); + Mod m = (Mod) mod.CreateInstance(tar.ToString()); + Console.WriteLine("LOADED MOD: {0} by {1} - Version {2} | Description: {3}", m.Name, m.Authour, m.Version, m.Description); + loadedMods += 1; + m.Entry(); + } + else + { + LogError("Invalid Mod DLL"); + } } - else + catch (Exception ex) { - LogError("Invalid Mod DLL"); + LogError("Failed to load mod '{0}'. Exception details:\n" + ex, s); } } } diff --git a/TrainerMod/TrainerMod.cs b/TrainerMod/TrainerMod.cs index d0a36fed..6e1b4b17 100644 --- a/TrainerMod/TrainerMod.cs +++ b/TrainerMod/TrainerMod.cs @@ -9,6 +9,7 @@ using StardewModdingAPI.Inheritance; using StardewValley; using StardewValley.Tools; using Microsoft.Xna.Framework; +using StardewValley.Objects; namespace TrainerMod { @@ -91,9 +92,11 @@ namespace TrainerMod Command.RegisterCommand("player_additem", "Gives the player an item | player_additem <item> <count>", new[] { "?<item> (Int32)<count>" }).CommandFired += player_addItem; Command.RegisterCommand("player_addmelee", "Gives the player a melee item | player_addmelee <item>", new[] { "?<item>" }).CommandFired += player_addMelee; + Command.RegisterCommand("player_addring", "Gives the player a ring | player_addring <item>", new[] { "?<item>" }).CommandFired += player_addRing; Command.RegisterCommand("out_items", "Outputs a list of items | out_items", new[] { "" }).CommandFired += out_items; Command.RegisterCommand("out_melee", "Outputs a list of melee weapons | out_melee", new[] { "" }).CommandFired += out_melee; + Command.RegisterCommand("out_rings", "Outputs a list of rings | out_rings", new[] { "" }).CommandFired += out_rings; Command.RegisterCommand("newitem", "Outputs a list of melee weapons | out_melee", new[] { "" }).CommandFired += RegisterNewItem; Command.RegisterCommand("world_settime", "Sets the time to the specified value | world_settime <value>", new[] { "(Int32)<value> The target time [06:00 AM is 600]" }).CommandFired += world_setTime; @@ -605,7 +608,9 @@ namespace TrainerMod return; } } - Game1.player.addItemByMenuIfNecessary((Item)new StardewValley.Object(cmd.CalledArgs[0].AsInt32(), count)); + Item i = (Item) new StardewValley.Object(cmd.CalledArgs[0].AsInt32(), count); + + Game1.player.addItemByMenuIfNecessary(i); } else { @@ -624,6 +629,7 @@ namespace TrainerMod { if (cmd.CalledArgs[0].IsInt32()) { + MeleeWeapon toAdd = new MeleeWeapon(cmd.CalledArgs[0].AsInt32()); Game1.player.addItemByMenuIfNecessary(toAdd); Program.LogInfo("Given {0} to {1}", toAdd.Name, Game1.player.Name); @@ -639,6 +645,28 @@ namespace TrainerMod } } + static void player_addRing(Command cmd) + { + if (cmd.CalledArgs.Length > 0) + { + if (cmd.CalledArgs[0].IsInt32()) + { + + Ring toAdd = new Ring(cmd.CalledArgs[0].AsInt32()); + Game1.player.addItemByMenuIfNecessary(toAdd); + Program.LogInfo("Given {0} to {1}", toAdd.Name, Game1.player.Name); + } + else + { + Program.LogError("<item> is invalid"); + } + } + else + { + Program.LogObjectValueNotSpecified(); + } + } + static void out_items(Command cmd) { for (int i = 0; i < 1000; i++) @@ -666,6 +694,23 @@ namespace TrainerMod } } + static void out_rings(Command cmd) + { + for (int i = 0; i < 100; i++) + { + try + { + Item it = new Ring(i); + if (it.Name != "Error Item") + Console.WriteLine(i + "| " + it.Name); + } + catch + { + + } + } + } + static void world_downMineLevel(Command cmd) { Game1.nextMineLevel(); diff --git a/TrainerMod/bin/Debug/TrainerMod.dll b/TrainerMod/bin/Debug/TrainerMod.dll Binary files differindex 8c80a376..d30355e9 100644 --- a/TrainerMod/bin/Debug/TrainerMod.dll +++ b/TrainerMod/bin/Debug/TrainerMod.dll diff --git a/TrainerMod/obj/Debug/TrainerMod.dll b/TrainerMod/obj/Debug/TrainerMod.dll Binary files differindex 8c80a376..d30355e9 100644 --- a/TrainerMod/obj/Debug/TrainerMod.dll +++ b/TrainerMod/obj/Debug/TrainerMod.dll |