From bc4f7db80d06cfa640fece82767a3550eb814a9c Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Thu, 4 Oct 2018 22:38:16 -0500 Subject: [PATCH] Added a good way to get the library path and native library path --- BSIPA.sln | 8 ++++---- IPA.Injector/Injector.cs | 13 ++++++++++--- IPA.Injector/LibLoader.cs | 6 +++--- IPA.Loader/Loader/PluginComponent.cs | 7 ------- IPA.Loader/Updating/ModsaberML/Updater.cs | 2 +- IPA.Loader/Utilities/BeatSaber.cs | 10 ++++++++++ 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/BSIPA.sln b/BSIPA.sln index cb99673e..411979ba 100644 --- a/BSIPA.sln +++ b/BSIPA.sln @@ -154,8 +154,8 @@ Global {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|x86.ActiveCfg = Release|Any CPU {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|x86.Build.0 = Release|Any CPU {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x64.ActiveCfg = Debug|x64 - {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x64.Build.0 = Debug|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x64.ActiveCfg = Release|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x64.Build.0 = Release|x64 {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x86.ActiveCfg = Debug|Win32 {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x86.Build.0 = Debug|Win32 {88609E16-731F-46C9-8139-6B1A7A83240D}.Release|Any CPU.ActiveCfg = Release|Win32 @@ -169,8 +169,8 @@ Global {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose_Release|x86.ActiveCfg = Verbose_Release|Win32 {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose_Release|x86.Build.0 = Verbose_Release|Win32 {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|Any CPU.ActiveCfg = Verbose|Win32 - {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x64.ActiveCfg = Verbose|x64 - {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x64.Build.0 = Verbose|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x64.ActiveCfg = Verbose_Release|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x64.Build.0 = Verbose_Release|x64 {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x86.ActiveCfg = Verbose|Win32 {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x86.Build.0 = Verbose|Win32 EndGlobalSection diff --git a/IPA.Injector/Injector.cs b/IPA.Injector/Injector.cs index 09f91444..a0feae57 100644 --- a/IPA.Injector/Injector.cs +++ b/IPA.Injector/Injector.cs @@ -149,9 +149,16 @@ namespace IPA.Injector if (bootstrapped) return; bootstrapped = true; + Application.logMessageReceived += delegate (string condition, string stackTrace, LogType type) + { + var level = UnityLogInterceptor.LogTypeToLevel(type); + UnityLogInterceptor.UnityLogger.Log(level, $"{condition.Trim()}"); + UnityLogInterceptor.UnityLogger.Log(level, $"{stackTrace.Trim()}"); + }; + // need to reinit streams singe Unity seems to redirect stdout Windows.WinConsole.InitializeStreams(); - + var bootstrapper = new GameObject("NonDestructiveBootstrapper").AddComponent(); bootstrapper.Destroyed += Bootstrapper_Destroyed; } @@ -176,14 +183,14 @@ namespace IPA.Injector loadingDone = true; #region Add Library load locations AppDomain.CurrentDomain.AssemblyResolve += LibLoader.AssemblyLibLoader; - try + /*try { if (!SetDllDirectory(LibLoader.NativeDir)) { libLoader.Warn("Unable to add native library path to load path"); } } - catch (Exception) { } + catch (Exception) { }*/ #endregion } diff --git a/IPA.Injector/LibLoader.cs b/IPA.Injector/LibLoader.cs index 61343826..50dd12be 100644 --- a/IPA.Injector/LibLoader.cs +++ b/IPA.Injector/LibLoader.cs @@ -12,8 +12,8 @@ namespace IPA.Injector { internal class LibLoader { - public static string LibsDir { get; set; } = Path.Combine(Environment.CurrentDirectory, "Libs"); - public static string NativeDir { get; set; } = Path.Combine(LibsDir, "Native"); + public static string LibraryPath => Path.Combine(Environment.CurrentDirectory, "Libs"); + public static string NativeLibraryPath => Path.Combine(LibraryPath, "Native"); private static Dictionary filenameLocations = null; public static Assembly AssemblyLibLoader(object source, ResolveEventArgs e) @@ -25,7 +25,7 @@ namespace IPA.Injector { filenameLocations = new Dictionary(); - foreach (var fn in TraverseTree(LibsDir, s => s != NativeDir)) + foreach (var fn in TraverseTree(LibraryPath, s => s != NativeLibraryPath)) filenameLocations.Add(fn.Name, fn.FullName); } diff --git a/IPA.Loader/Loader/PluginComponent.cs b/IPA.Loader/Loader/PluginComponent.cs index a6d4a3ee..9deee95a 100644 --- a/IPA.Loader/Loader/PluginComponent.cs +++ b/IPA.Loader/Loader/PluginComponent.cs @@ -17,13 +17,6 @@ namespace IPA.Loader internal static PluginComponent Create() { - Application.logMessageReceived += delegate (string condition, string stackTrace, LogType type) - { - var level = UnityLogInterceptor.LogTypeToLevel(type); - UnityLogInterceptor.UnityLogger.Log(level, $"{condition.Trim()}"); - UnityLogInterceptor.UnityLogger.Log(level, $"{stackTrace.Trim()}"); - }; - return new GameObject("IPA_PluginManager").AddComponent(); } diff --git a/IPA.Loader/Updating/ModsaberML/Updater.cs b/IPA.Loader/Updating/ModsaberML/Updater.cs index 4b5f4e30..53a2760b 100644 --- a/IPA.Loader/Updating/ModsaberML/Updater.cs +++ b/IPA.Loader/Updating/ModsaberML/Updater.cs @@ -267,7 +267,7 @@ namespace IPA.Updating.ModsaberML { foreach(var dep in list.Value) { - dep.Has = dep.Version != null;// dep.Version is only not null if its already installed + dep.Has = dep.Version != null; // dep.Version is only not null if its already installed if (dep.MetaRequestFailed) { diff --git a/IPA.Loader/Utilities/BeatSaber.cs b/IPA.Loader/Utilities/BeatSaber.cs index bb6c9427..f93ce0e6 100644 --- a/IPA.Loader/Utilities/BeatSaber.cs +++ b/IPA.Loader/Utilities/BeatSaber.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -39,6 +40,15 @@ namespace IPA.Utilities /// public static Release ReleaseType => (_releaseCache ?? (_releaseCache = FindSteamVRAsset() ? Release.Steam : Release.Oculus)).Value; + /// + /// The path to the `Libs` folder. Use only if necessary. + /// + public static string LibraryPath => Path.Combine(Environment.CurrentDirectory, "Libs"); + /// + /// The path to the `Libs\Native` folder. Use only if necessary. + /// + public static string NativeLibraryPath => Path.Combine(LibraryPath, "Native"); + private static bool FindSteamVRAsset() { // these require assembly qualified names....