private string NotFoundHandler() { bool found = false; while (found == false) { using (var folderDialog = new FolderBrowserDialog()) { if (folderDialog.ShowDialog() == DialogResult.OK) { string path = folderDialog.SelectedPath; if (File.Exists(Path.Combine(path, AppFileName))) { FormPlatformSelect selector = new FormPlatformSelect(this); selector.ShowDialog(); found = true; return(path); } else { MessageBox.Show("The directory you selected doesn't contain Beat Saber.exe! please try again!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { return(null); } } } return(string.Empty); }
public string GetInstallationPath() { // Check if install path is already saved if (Properties.Settings.Default.InstallPath.Length != 0 && Properties.Settings.Default.Platform != (int)Platform.Default) { if (File.Exists(Path.Combine(Properties.Settings.Default.InstallPath, AppFileName))) { installPath = Properties.Settings.Default.InstallPath; if ((Platform)Properties.Settings.Default.Platform == Platform.Steam) { platform = Platform.Steam; } else if ((Platform)Properties.Settings.Default.Platform == Platform.Oculus) { platform = Platform.Oculus; } else { // If the platform isn't saved, prompt user to select FormPlatformSelect selector = new FormPlatformSelect(this); selector.ShowDialog(); Properties.Settings.Default.Platform = (int)platform; Properties.Settings.Default.Save(); } return(installPath); } } string steam = GetSteamLocation(); if (steam != null) { if (Directory.Exists(steam)) { if (File.Exists(Path.Combine(steam, AppFileName))) { platform = Platform.Steam; installPath = steam; return(steam); } } } string oculus = GetValidOculusLocation(); if (oculus != null) { if (Directory.Exists(oculus)) { if (File.Exists(Path.Combine(oculus, AppFileName))) { platform = Platform.Oculus; installPath = oculus; return(oculus); } } } string fallback = GetFallbackDirectory(); installPath = fallback; return(fallback); }