mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Set GameRootPath to outside the game.app folder on OSX
Rebase of f963d6c
This commit is contained in:
4 files changed
+29
-2
No files matched your search
@@ -39,6 +39,10 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>C:\Users\Richard\.nuget\packages\harmonyx\2.1.0-beta.8\lib\net35\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -86,6 +90,9 @@
|
||||
<Compile Include="Utility.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HarmonyX">
|
||||
<Version>2.1.0-beta.8</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Mono.Cecil">
|
||||
<Version>0.10.4</Version>
|
||||
</PackageReference>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using MonoMod.Utils;
|
||||
|
||||
namespace BepInEx
|
||||
{
|
||||
@@ -12,7 +13,11 @@ namespace BepInEx
|
||||
{
|
||||
ExecutablePath = executablePath;
|
||||
ProcessName = Path.GetFileNameWithoutExtension(executablePath);
|
||||
GameRootPath = Path.GetDirectoryName(executablePath);
|
||||
|
||||
GameRootPath = Utility.CurrentPlatform == Platform.MacOS
|
||||
? Utility.ParentDirectory(executablePath, 4)
|
||||
: Path.GetDirectoryName(executablePath);
|
||||
|
||||
BepInExRootPath = bepinRootPath ?? Path.Combine(GameRootPath, "BepInEx");
|
||||
ConfigPath = Path.Combine(BepInExRootPath, "config");
|
||||
BepInExConfigPath = Path.Combine(ConfigPath, "BepInEx.cfg");
|
||||
@@ -50,6 +55,7 @@ namespace BepInEx
|
||||
|
||||
/// <summary>
|
||||
/// The directory that the currently executing process resides in.
|
||||
/// <para>On OSX however, this is the parent directory of the game.app folder.</para>
|
||||
/// </summary>
|
||||
public static string GameRootPath { get; private set; }
|
||||
|
||||
|
||||
@@ -66,6 +66,20 @@ namespace BepInEx
|
||||
/// <returns>A combined path.</returns>
|
||||
public static string CombinePaths(params string[] parts) => parts.Aggregate(Path.Combine);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the parent directory of a path, optionally specifying the amount of levels.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to get the parent directory of.</param>
|
||||
/// <param name="levels">The amount of levels to traverse. Defaults to 1</param>
|
||||
/// <returns>The parent directory.</returns>
|
||||
public static string ParentDirectory(string path, int levels = 1)
|
||||
{
|
||||
for (int i = 0; i < levels; i++)
|
||||
path = Path.GetDirectoryName(path);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to parse a bool, with a default value if unable to parse.
|
||||
/// </summary>
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace BepInEx.Preloader.Unity
|
||||
{
|
||||
public static void PreloaderPreMain(string[] args)
|
||||
{
|
||||
string bepinPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH)));
|
||||
string bepinPath = Utility.ParentDirectory(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH), 2);
|
||||
|
||||
Paths.SetExecutablePath(args[0], bepinPath);
|
||||
AppDomain.CurrentDomain.AssemblyResolve += LocalResolve;
|
||||
|
||||
Reference in new issue
Block a user