示例#1
0
 /// <summary>
 /// Return a mod's current status
 /// This can't be static because the user's installation plans are part of the object.
 /// This function is extremely performance-sensitive because it's the default sort for
 /// the main mod list, so anything in here should be O(1) and fast.
 /// </summary>
 /// <param name="manager">KSP manager containing the instances</param>
 /// <param name="registry">Registry of instance being displayed</param>
 /// <param name="identifier">The mod</param>
 /// <returns>
 /// Status of mod
 /// </returns>
 public InstallStatus GetModStatus(KSPManager manager, IRegistryQuerier registry, string identifier)
 {
     if (registry.IsInstalled(identifier, false))
     {
         if (Remove.Contains(identifier))
         {
             return(InstallStatus.Removing);
         }
         else if (registry.HasUpdate(identifier, manager.CurrentInstance.VersionCriteria()))
         {
             if (Upgrade.Contains(identifier))
             {
                 return(InstallStatus.Upgrading);
             }
             else
             {
                 return(InstallStatus.Upgradeable);
             }
         }
         else if (!IsAnyAvailable(registry, identifier))
         {
             return(InstallStatus.Unavailable);
         }
         else
         {
             return(InstallStatus.Installed);
         }
     }
     else
     {
         if (Install.Contains(identifier))
         {
             return(InstallStatus.Installing);
         }
         else
         {
             return(InstallStatus.NotInstalled);
         }
     }
 }