summaryrefslogtreecommitdiff
path: root/StardewModdingAPI/Program.cs
diff options
context:
space:
mode:
authorZoryn <Zoryn4163@users.noreply.github.com>2016-03-20 18:51:04 -0400
committerZoryn <Zoryn4163@users.noreply.github.com>2016-03-20 18:51:04 -0400
commit280d77c9750d33a7557792625fa3ad35c2c923fd (patch)
tree173d14dfc578d5f8b7f225b729742b977e910246 /StardewModdingAPI/Program.cs
parent14c781345315c97aed958d71dbd5e896cedc25f3 (diff)
parent17021ae35162cfa4a6dad2c0457d4981f38878bc (diff)
downloadSMAPI-280d77c9750d33a7557792625fa3ad35c2c923fd.tar.gz
SMAPI-280d77c9750d33a7557792625fa3ad35c2c923fd.tar.bz2
SMAPI-280d77c9750d33a7557792625fa3ad35c2c923fd.zip
Merge pull request #36 from Zoryn4163/master
forgot to merge for 38.1
Diffstat (limited to 'StardewModdingAPI/Program.cs')
-rw-r--r--StardewModdingAPI/Program.cs104
1 files changed, 53 insertions, 51 deletions
diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs
index 6d137a68..cde2dfbc 100644
--- a/StardewModdingAPI/Program.cs
+++ b/StardewModdingAPI/Program.cs
@@ -20,7 +20,7 @@ namespace StardewModdingAPI
public class Program
{
private static List<string> _modPaths;
- private static List<string> _modContentPaths;
+ //private static List<string> _modContentPaths;
public static Texture2D DebugPixel { get; private set; }
@@ -50,7 +50,6 @@ namespace StardewModdingAPI
{
ConfigureUI();
ConfigurePaths();
- ConfigureInjector();
ConfigureSDV();
GameRunInvoker();
@@ -85,17 +84,19 @@ namespace StardewModdingAPI
StardewModdingAPI.Log.Info("Validating api paths...");
_modPaths = new List<string>();
- _modContentPaths = new List<string>();
+ //_modContentPaths = new List<string>();
//TODO: Have an app.config and put the paths inside it so users can define locations to load mods from
_modPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods"));
_modPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods"));
- _modContentPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods", "Content"));
- _modContentPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods", "Content"));
+
+ //Mods need to make their own content paths, since we're doing a different, manifest-driven, approach.
+ //_modContentPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods", "Content"));
+ //_modContentPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods", "Content"));
//Checks that all defined modpaths exist as directories
_modPaths.ForEach(path => VerifyPath(path));
- _modContentPaths.ForEach(path => VerifyPath(path));
+ //_modContentPaths.ForEach(path => VerifyPath(path));
VerifyPath(Constants.LogPath);
StardewModdingAPI.Log.Initialize(Constants.LogPath);
@@ -107,51 +108,6 @@ namespace StardewModdingAPI
}
/// <summary>
- /// Load the injector.
- /// Is this deprecated? Why is there a LoadMods?
- /// </summary>
- /// <remarks>
- /// 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
- /// </remarks>
- private static void ConfigureInjector()
- {
- foreach (string ModPath in _modPaths)
- {
- foreach (String s in Directory.GetFiles(ModPath, "StardewInjector.dll"))
- {
- StardewModdingAPI.Log.Success(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)
- {
- StardewModdingAPI.Log.Success("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} (@:{4})", m.Manifest.Name, m.Manifest.Authour, m.Manifest.Version, m.Manifest.Description, s);
- m.PathOnDisk = Path.GetDirectoryName(s);
- m.Entry(false);
- StardewInjectorLoaded = true;
- StardewInjectorMod = m;
- }
- else
- {
- StardewModdingAPI.Log.Error("Invalid Mod DLL");
- }
- }
- catch (Exception ex)
- {
- StardewModdingAPI.Log.Error("Failed to load mod '{0}'. Exception details:\n" + ex, s);
- }
- }
- }
- }
-
- /// <summary>
/// Load Stardev Valley and control features
/// </summary>
private static void ConfigureSDV()
@@ -263,6 +219,8 @@ namespace StardewModdingAPI
StardewModdingAPI.Log.Verbose("Patching SDV Graphics Profile...");
Game1.graphics.GraphicsProfile = GraphicsProfile.HiDef;
LoadMods();
+ //DEPRECATED WAY
+ LoadMods_OldWay();
StardewForm = Control.FromHandle(Program.gamePtr.Window.Handle).FindForm();
StardewForm.Closing += StardewForm_Closing;
@@ -379,6 +337,50 @@ namespace StardewModdingAPI
StardewModdingAPI.Log.Success("LOADED {0} MODS", loadedMods);
}
+ /// <summary>
+ /// DEPRECATED. REMOVE
+ /// </summary>
+ public static void LoadMods_OldWay()
+ {
+ StardewModdingAPI.Log.Verbose("LOADING MODS (OLD WAY - DEPRECATED. ANY MODS LOADED THIS WAY NEED TO UPDATE)");
+ int loadedMods = 0;
+ foreach (string ModPath in _modPaths)
+ {
+ foreach (String s in Directory.GetFiles(ModPath, "*.dll"))
+ {
+ if (s.Contains("StardewInjector"))
+ continue;
+ StardewModdingAPI.Log.Success("Found DLL: " + s);
+ try
+ {
+ Assembly mod = Assembly.UnsafeLoadFrom(s); //to combat internet-downloaded DLLs
+
+ if (mod.DefinedTypes.Count(x => x.BaseType == typeof(Mod)) > 0)
+ {
+ StardewModdingAPI.Log.Verbose("Loading Mod DLL...");
+ TypeInfo tar = mod.DefinedTypes.First(x => x.BaseType == typeof(Mod));
+ Mod m = (Mod)mod.CreateInstance(tar.ToString());
+ m.Manifest = null;
+ m.PathOnDisk = Path.GetDirectoryName(s);
+ Console.WriteLine("LOADED MOD: {0} by {1} - Version {2} | Description: {3}", m.Name, m.Authour, m.Version, m.Description);
+ loadedMods += 1;
+ m.Entry();
+ }
+ else
+ {
+ StardewModdingAPI.Log.Error("Invalid Mod DLL");
+ }
+ }
+ catch (Exception ex)
+ {
+ StardewModdingAPI.Log.Error("Failed to load mod '{0}'. Exception details:\n" + ex, s);
+ }
+ }
+ }
+ StardewModdingAPI.Log.Success("LOADED {0} MODS THAT NEED TO UPDATE", loadedMods);
+ }
+
+
public static void ConsoleInputThread()
{
string input = string.Empty;