Esempio n. 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">Game instance 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(GameInstanceManager 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 (registry.IsAutodetected(identifier))
         {
             return(InstallStatus.AutoDetected);
         }
         else if (Replace.Contains(identifier))
         {
             return(InstallStatus.Replacing);
         }
         else if (registry.GetReplacement(identifier, manager.CurrentInstance.VersionCriteria()) != null)
         {
             return(InstallStatus.Replaceable);
         }
         else if (!IsAnyAvailable(registry, identifier))
         {
             return(InstallStatus.Unavailable);
         }
         else if (registry.InstalledModule(identifier)?.AutoInstalled ?? false)
         {
             return(InstallStatus.AutoInstalled);
         }
         else
         {
             return(InstallStatus.Installed);
         }
     }
     else
     {
         foreach (CkanModule m in Install)
         {
             if (m.identifier == identifier)
             {
                 return(InstallStatus.Installing);
             }
         }
         return(InstallStatus.NotInstalled);
     }
 }
Esempio n. 2
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);
         }
     }
 }