public static List <string> GetAllGameInstallPathsFromRegistry(GameDlc dlc) { string regPath = GetRegistryPath(dlc); if (regPath == null) { return(new List <string>()); } List <string> allPaths = new List <string>(); foreach (string s in RegistryValueNames) { var regVal = Registry.GetValue(regPath, s, null); if ((regVal != null) && (regVal is string regValue)) { bool add = true; foreach (string t in allPaths) { if (t.ToLowerInvariant() == regValue.ToLowerInvariant()) { add = false; break; } } if (add) { allPaths.Add(regValue); } } } return(allPaths); }
/*static string[] _installDirSubfolders = * { * "dataep1", * "data", * "sporebinep1", * "sporebin", * "support" * };*/ public static bool CorrectGameInstallPath(string subPath, GameDlc dlc, out string fixedPath) { string output = StripTrailingCharacters(subPath); bool isSporePath = true; while (!IsPathGameInstallRoot(output, dlc)) { if (output.Contains(@"\")) { //MessageDisplay.DebugShowMessageBox("EnsureGameInstallPathIsInstallRoot output: " + output); if (IsPathGameInstallRoot(output, dlc)) { break; } else { output = output.Substring(0, output.LastIndexOf(@"\")); } } else { isSporePath = false; break; } } fixedPath = output; return(isSporePath); }
public static string GetRegistryPath(GameDlc dlc) { if (dlc != GameDlc.None) { string output = null; RegistryKey key = Registry.LocalMachine.OpenSubKey(_registryPath64bit, false); if (key == null) { key = Registry.LocalMachine.OpenSubKey(_registryPath32bit, false); } if (key != null) { output = key.Name; string slash = @"\"; if (!output.EndsWith(slash)) { output += slash; } output += RegistrySuffixes[dlc]; } //MessageDisplay.DebugShowMessageBox("REGISTRY PATH: " + output); return(output); } else { throw new InvalidOperationException("Cannot retrieve registry path for GameDlc.None"); } }
static bool IsPathGameInstallRoot(string path, GameDlc dlc) { if (Directory.Exists(Path.Combine(path, _dCr))) { return(true); } else if ((dlc == GameDlc.GalacticAdventures) && Directory.Exists(Path.Combine(path, _dEp1))) { return(true); } else { return(false); } }
static string EnsureGameInstallPathIsInstallRoot(string subPath, GameDlc dlc) { bool isSporePath = CorrectGameInstallPath(subPath, dlc, out string output); //MessageDisplay.DebugShowMessageBox("isSporePath: " + isSporePath + ", " + output); if (isSporePath) { //MessageDisplay.DebugShowMessageBox("INSTALL ROOT: " + output); return(output); } else { if (!BadGameInstallPaths.Any(x => (x.BasePath == subPath) && (x.BadPath == output) && (x.DlcLevel == dlc) && (!x.IsSporebin))) { BadGameInstallPaths.Add(new BadPathEventArgs(subPath, output, dlc)); } return(string.Empty); } }
public static List <DetectionFailureGuessFolder> GetFailureGuessFolders(GameDlc dlc, bool isSporebin) { List <DetectionFailureGuessFolder> guesses = new List <DetectionFailureGuessFolder>(); string diskBase = string.Empty; string originBase = string.Empty; string steamBase = string.Empty; string gogBase = string.Empty; if (Environment.Is64BitOperatingSystem) { string x86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86); diskBase = x86; originBase = x86; steamBase = x86; gogBase = x86; } else { string x64 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); diskBase = x64; originBase = x64; steamBase = x64; gogBase = x64; } diskBase = Path.Combine(diskBase, "Electronic Arts", "SPORE"); originBase = Path.Combine(originBase, "Origin Games"); steamBase = Path.Combine(steamBase, @"Steam\SteamApps\Common\Spore"); if (dlc == GameDlc.CoreSpore) { originBase = Path.Combine(originBase, "Spore"); if (isSporebin) { diskBase = Path.Combine(diskBase, "SporeBin"); originBase = Path.Combine(originBase, "SporeBin"); steamBase = Path.Combine(steamBase, "SporeBin"); } else { diskBase = Path.Combine(diskBase, "Data"); originBase = Path.Combine(originBase, "Data"); steamBase = Path.Combine(steamBase, "Data"); } } else { diskBase += "_EP1"; originBase = Path.Combine(originBase, "SPORE Galactic Adventures"); if (isSporebin) { diskBase = Path.Combine(diskBase, "SporebinEP1"); originBase = Path.Combine(originBase, "SporebinEP1"); steamBase = Path.Combine(steamBase, "SporebinEP1"); } else { diskBase = Path.Combine(diskBase, "Data"); originBase = Path.Combine(originBase, "Data"); steamBase = Path.Combine(steamBase, "DataEP1"); } } if (Directory.Exists(diskBase)) { guesses.Add(new DetectionFailureGuessFolder(diskBase, GameExecutableType.Disk__1_5_1)); } if (Directory.Exists(originBase)) { guesses.Add(new DetectionFailureGuessFolder(originBase, GameExecutableType.Origin__March2017)); } if (Directory.Exists(steamBase)) { guesses.Add(new DetectionFailureGuessFolder(steamBase, GameExecutableType.GogOrSteam__March2017)); } if (false && Directory.Exists(gogBase)) { guesses.Add(new DetectionFailureGuessFolder(gogBase, GameExecutableType.GogOrSteam__March2017)); } return(guesses); }
public static string GetGameInstallPathFromRegistry(GameDlc dlc) { List <string> paths = GetAllGameInstallPathsFromRegistry(dlc); if (paths.Count == 1) { return(paths.ToArray()[0]); //return null; } else { if (paths.Count > 1) { bool areSame = true; string comparison = string.Empty; foreach (string p in paths) { if (comparison == string.Empty) { comparison = p; } else { if (Directory.Exists(p)) { string newVal = EnsureGameInstallPathIsInstallRoot(p, dlc); areSame = EnsureGameInstallPathIsInstallRoot(comparison, dlc).ToLowerInvariant() == newVal.ToLowerInvariant(); if (areSame) { comparison = newVal; } else { break; } } } } if (areSame) { //MessageDisplay.DebugShowMessageBox("areSame, comparison: " + comparison); return(comparison); } } if (dlc == GameDlc.CoreSpore) { GameMultiplePaths[0] = paths; string output = ""; foreach (string s in GameMultiplePaths[0]) { output += s + ", "; } //MessageDisplay.DebugShowMessageBox("GameMultiplePaths fail: " + output); } else if (dlc == GameDlc.CreepyAndCute) { GameMultiplePaths[1] = paths; string output = ""; foreach (string s in GameMultiplePaths[1]) { output += s + ", "; } //MessageDisplay.DebugShowMessageBox("GameMultiplePaths fail: " + output); } else if (dlc == GameDlc.GalacticAdventures) { GameMultiplePaths[2] = paths; string output = ""; foreach (string s in GameMultiplePaths[2]) { output += s + ", "; } //MessageDisplay.DebugShowMessageBox("GameMultiplePaths fail: " + output); } return(null); //return paths; } }