Example #1
0
 public void SetInstallByPath(string path)
 {
     try
     {
         path = Path.GetFullPath(path);
     }
     catch { }
     if (!string.IsNullOrEmpty(path))
     {
         var matchingInstall = BeatSaberLocations.Where(i => string.Equals(Path.GetFullPath(i.InstallPath), path, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
         if (matchingInstall != null)
         {
             ChosenInstall = matchingInstall;
         }
         else
         {
             var newInstall = new BeatSaberInstall(path, InstallType.Manual);
             BeatSaberLocations.Add(newInstall);
             ChosenInstall = newInstall;
         }
     }
     else
     {
         ChosenInstall = BeatSaberLocations.FirstOrDefault();
     }
 }
Example #2
0
 public bool CanAddLocation(string pathStr)
 {
     if (string.IsNullOrEmpty(pathStr))
     {
         return(false);
     }
     try
     {
         pathStr = pathStr.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
         var fullInstallPath = Path.GetFullPath(pathStr).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
         if (Directory.Exists(fullInstallPath) && Path.IsPathRooted(pathStr) && !pathStr.EndsWith(":"))
         {
             bool locationExists = BeatSaberLocations.Any(i =>
             {
                 var comp = Path.GetFullPath(i.InstallPath).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                 return(string.Equals(fullInstallPath, comp, StringComparison.CurrentCultureIgnoreCase));
             });
             if (!locationExists)
             {
                 return(true);
             }
         }
     }
     catch { return(false); }
     return(false);
 }
Example #3
0
        private bool RemoveLocation(BeatSaberInstall install)
        {
            bool result = BeatSaberLocations.Remove(install);

            if (ChosenInstall == install)
            {
                ChosenInstall = null;
            }
            NewLocationIsValid = CanAddLocation(NewLocationInput);
            return(result);
        }
Example #4
0
        private bool AddLocation(BeatSaberInstall beatSaberInstall)
        {
            bool hadEmptyList = BeatSaberLocations.Count == 0;

            BeatSaberLocations.Add(beatSaberInstall);
            if (BeatSaberLocations.Any(i => i.InstallPath == NewLocationInput.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)))
            {
                NewLocationIsValid = false;
            }
            if (hadEmptyList)
            {
                ChosenInstall = beatSaberInstall;
            }
            return(true);
        }