-
Notifications
You must be signed in to change notification settings - Fork 29
/
ME3Directory.cs
79 lines (71 loc) · 2.93 KB
/
ME3Directory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using UsefulThings;
namespace ME3Explorer
{
public static class ME3Directory
{
private static string _gamePath;
public static string gamePath
{
get
{
if (_gamePath == null)
return null;
return Path.GetFullPath(_gamePath); //normalize
}
set
{
if (value != null)
{
if (value.Contains("BIOGame"))
value = value.Substring(0, value.LastIndexOf("BIOGame"));
}
_gamePath = value;
}
}
public static string BIOGamePath => gamePath != null ? gamePath.Contains("biogame", StringComparison.OrdinalIgnoreCase) ? gamePath : Path.Combine(gamePath, @"BIOGame\") : null;
public static string tocFile => gamePath != null ? Path.Combine(gamePath, @"BIOGame\PCConsoleTOC.bin") : null;
public static string cookedPath => gamePath != null ? Path.Combine(gamePath, @"BIOGame\CookedPCConsole\") : "Not Found";
public static string DLCPath => gamePath != null ? Path.Combine(gamePath , @"BIOGame\DLC\") : "Not Found";
// "C:\...\MyDocuments\BioWare\Mass Effect 3\" folder
public static string BioWareDocPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"\BioWare\Mass Effect 3\");
public static string GamerSettingsIniFile => Path.Combine(BioWareDocPath, @"BIOGame\Config\GamerSettings.ini");
public static string DLCFilePath(string DLCName)
{
string fullPath = Path.Combine(DLCPath, DLCName, @"\CookedPCConsole\Default.sfar");
if (!File.Exists(fullPath))
throw new FileNotFoundException($"Invalid DLC path {fullPath}");
return fullPath;
}
static ME3Directory()
{
if (!string.IsNullOrEmpty(Properties.Settings.Default.ME3Directory))
{
gamePath = Properties.Settings.Default.ME3Directory;
}
else
{
string hkey32 = @"HKEY_LOCAL_MACHINE\SOFTWARE\";
string hkey64 = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\";
string subkey = @"BioWare\Mass Effect 3";
string keyName = hkey32 + subkey;
string test = (string)Microsoft.Win32.Registry.GetValue(keyName, "Install Dir", null);
if (test != null)
{
gamePath = test;
return;
}
/*if (gamePath != null)
return;*/
keyName = hkey64 + subkey;
gamePath = (string)Microsoft.Win32.Registry.GetValue(keyName, "Install Dir", null);
}
}
}
}