Browse Source

Added a good way to get the library path and native library path

pull/46/head
Anairkoen Schno 6 years ago
parent
commit
bc4f7db80d
6 changed files with 28 additions and 18 deletions
  1. +4
    -4
      BSIPA.sln
  2. +10
    -3
      IPA.Injector/Injector.cs
  3. +3
    -3
      IPA.Injector/LibLoader.cs
  4. +0
    -7
      IPA.Loader/Loader/PluginComponent.cs
  5. +1
    -1
      IPA.Loader/Updating/ModsaberML/Updater.cs
  6. +10
    -0
      IPA.Loader/Utilities/BeatSaber.cs

+ 4
- 4
BSIPA.sln View File

@ -154,8 +154,8 @@ Global
{2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|x86.ActiveCfg = Release|Any CPU {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|x86.ActiveCfg = Release|Any CPU
{2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|x86.Build.0 = 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|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.ActiveCfg = Debug|Win32
{88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x86.Build.0 = Debug|Win32 {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x86.Build.0 = Debug|Win32
{88609E16-731F-46C9-8139-6B1A7A83240D}.Release|Any CPU.ActiveCfg = Release|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.ActiveCfg = Verbose_Release|Win32
{88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose_Release|x86.Build.0 = 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|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.ActiveCfg = Verbose|Win32
{88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x86.Build.0 = Verbose|Win32 {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x86.Build.0 = Verbose|Win32
EndGlobalSection EndGlobalSection


+ 10
- 3
IPA.Injector/Injector.cs View File

@ -149,9 +149,16 @@ namespace IPA.Injector
if (bootstrapped) return; if (bootstrapped) return;
bootstrapped = true; 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 // need to reinit streams singe Unity seems to redirect stdout
Windows.WinConsole.InitializeStreams(); Windows.WinConsole.InitializeStreams();
var bootstrapper = new GameObject("NonDestructiveBootstrapper").AddComponent<Bootstrapper>(); var bootstrapper = new GameObject("NonDestructiveBootstrapper").AddComponent<Bootstrapper>();
bootstrapper.Destroyed += Bootstrapper_Destroyed; bootstrapper.Destroyed += Bootstrapper_Destroyed;
} }
@ -176,14 +183,14 @@ namespace IPA.Injector
loadingDone = true; loadingDone = true;
#region Add Library load locations #region Add Library load locations
AppDomain.CurrentDomain.AssemblyResolve += LibLoader.AssemblyLibLoader; AppDomain.CurrentDomain.AssemblyResolve += LibLoader.AssemblyLibLoader;
try
/*try
{ {
if (!SetDllDirectory(LibLoader.NativeDir)) if (!SetDllDirectory(LibLoader.NativeDir))
{ {
libLoader.Warn("Unable to add native library path to load path"); libLoader.Warn("Unable to add native library path to load path");
} }
} }
catch (Exception) { }
catch (Exception) { }*/
#endregion #endregion
} }


+ 3
- 3
IPA.Injector/LibLoader.cs View File

@ -12,8 +12,8 @@ namespace IPA.Injector
{ {
internal class LibLoader 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<string, string> filenameLocations = null; private static Dictionary<string, string> filenameLocations = null;
public static Assembly AssemblyLibLoader(object source, ResolveEventArgs e) public static Assembly AssemblyLibLoader(object source, ResolveEventArgs e)
@ -25,7 +25,7 @@ namespace IPA.Injector
{ {
filenameLocations = new Dictionary<string, string>(); filenameLocations = new Dictionary<string, string>();
foreach (var fn in TraverseTree(LibsDir, s => s != NativeDir))
foreach (var fn in TraverseTree(LibraryPath, s => s != NativeLibraryPath))
filenameLocations.Add(fn.Name, fn.FullName); filenameLocations.Add(fn.Name, fn.FullName);
} }


+ 0
- 7
IPA.Loader/Loader/PluginComponent.cs View File

@ -17,13 +17,6 @@ namespace IPA.Loader
internal static PluginComponent Create() 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<PluginComponent>(); return new GameObject("IPA_PluginManager").AddComponent<PluginComponent>();
} }


+ 1
- 1
IPA.Loader/Updating/ModsaberML/Updater.cs View File

@ -267,7 +267,7 @@ namespace IPA.Updating.ModsaberML
{ {
foreach(var dep in list.Value) 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) if (dep.MetaRequestFailed)
{ {


+ 10
- 0
IPA.Loader/Utilities/BeatSaber.cs View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -39,6 +40,15 @@ namespace IPA.Utilities
/// </summary> /// </summary>
public static Release ReleaseType => (_releaseCache ?? (_releaseCache = FindSteamVRAsset() ? Release.Steam : Release.Oculus)).Value; public static Release ReleaseType => (_releaseCache ?? (_releaseCache = FindSteamVRAsset() ? Release.Steam : Release.Oculus)).Value;
/// <summary>
/// The path to the `Libs` folder. Use only if necessary.
/// </summary>
public static string LibraryPath => Path.Combine(Environment.CurrentDirectory, "Libs");
/// <summary>
/// The path to the `Libs\Native` folder. Use only if necessary.
/// </summary>
public static string NativeLibraryPath => Path.Combine(LibraryPath, "Native");
private static bool FindSteamVRAsset() private static bool FindSteamVRAsset()
{ {
// these require assembly qualified names.... // these require assembly qualified names....


Loading…
Cancel
Save