/// <summary> /// Initialize a GUIMod based on just an identifier /// </summary> /// <param name="identifier">The id of the module to represent</param> /// <param name="registry">CKAN registry object for current game instance</param> /// <param name="current_ksp_version">Current game version</param> /// <param name="incompatible">If true, mark this module as incompatible</param> public GUIMod(string identifier, IRegistryQuerier registry, KspVersionCriteria current_ksp_version, bool?incompatible = null) { Identifier = identifier; IsAutodetected = registry.IsAutodetected(identifier); DownloadCount = registry.DownloadCount(identifier); if (IsAutodetected) { IsInstalled = true; } ModuleVersion latest_version = null; try { LatestCompatibleMod = registry.LatestAvailable(identifier, current_ksp_version); latest_version = LatestCompatibleMod?.version; } catch (ModuleNotFoundKraken) { } IsIncompatible = incompatible ?? LatestCompatibleMod == null; // Let's try to find the compatibility for this mod. If it's not in the registry at // all (because it's a DarkKAN mod) then this might fail. CkanModule latest_available_for_any_ksp = null; try { latest_available_for_any_ksp = registry.LatestAvailable(identifier, null); } catch { } // If there's known information for this mod in any form, calculate the highest compatible // KSP. if (latest_available_for_any_ksp != null) { KSPCompatibilityVersion = registry.LatestCompatibleKSP(identifier); KSPCompatibility = KSPCompatibilityVersion?.ToYalovString() ?? Properties.Resources.GUIModUnknown; KSPCompatibilityLong = string.Format(Properties.Resources.GUIModKSPCompatibilityLong, KSPCompatibility, latest_available_for_any_ksp.version); } if (latest_version != null) { LatestVersion = latest_version.ToString(); } else if (latest_available_for_any_ksp != null) { LatestVersion = latest_available_for_any_ksp.version.ToString(); } else { LatestVersion = "-"; } SearchableIdentifier = CkanModule.nonAlphaNums.Replace(Identifier, ""); }
/// <summary> /// Initialize a GUIMod based on just an identifier /// </summary> /// <param name="identifier">The id of the module to represent</param> /// <param name="registry">CKAN registry object for current game instance</param> /// <param name="current_ksp_version">Current game version</param> /// <param name="incompatible">If true, mark this module as incompatible</param> public GUIMod(string identifier, IRegistryQuerier registry, KspVersionCriteria current_ksp_version, bool incompatible = false) { Identifier = identifier; IsIncompatible = incompatible; IsAutodetected = registry.IsAutodetected(identifier); DownloadCount = registry.DownloadCount(identifier); ModuleVersion latest_version = null; try { latest_version = registry.LatestAvailable(identifier, current_ksp_version)?.version; } catch (ModuleNotFoundKraken) { } // Let's try to find the compatibility for this mod. If it's not in the registry at // all (because it's a DarkKAN mod) then this might fail. CkanModule latest_available_for_any_ksp = null; try { latest_available_for_any_ksp = registry.LatestAvailable(identifier, null); } catch { } // If there's known information for this mod in any form, calculate the highest compatible // KSP. if (latest_available_for_any_ksp != null) { KSPCompatibility = registry.LatestCompatibleKSP(identifier)?.ToYalovString() ?? "Unknown"; KSPCompatibilityLong = $"{KSPCompatibility} (using mod version {latest_available_for_any_ksp.version})"; } else { // No idea what this mod is, sorry! KSPCompatibility = KSPCompatibilityLong = "unknown"; } if (latest_version != null) { LatestVersion = latest_version.ToString(); } else if (latest_available_for_any_ksp != null) { LatestVersion = latest_available_for_any_ksp.version.ToString(); } else { LatestVersion = "-"; } // If we have a homepage provided, use that; otherwise use the spacedock page, curse page or the github repo so that users have somewhere to get more info than just the abstract. Homepage = "N/A"; }
/// <summary> /// Initialize a GUIMod based on just an identifier /// </summary> /// <param name="identifier">The id of the module to represent</param> /// <param name="registry">CKAN registry object for current game instance</param> /// <param name="current_ksp_version">Current game version</param> /// <param name="incompatible">If true, mark this module as incompatible</param> public GUIMod(string identifier, IRegistryQuerier registry, KspVersionCriteria current_ksp_version, bool incompatible = false) { Identifier = identifier; IsIncompatible = incompatible; IsAutodetected = registry.IsAutodetected(identifier); DownloadCount = registry.DownloadCount(identifier); if (registry.IsAutodetected(identifier)) { IsInstalled = true; } ModuleVersion latest_version = null; try { LatestCompatibleMod = registry.LatestAvailable(identifier, current_ksp_version); latest_version = LatestCompatibleMod?.version; } catch (ModuleNotFoundKraken) { } // Let's try to find the compatibility for this mod. If it's not in the registry at // all (because it's a DarkKAN mod) then this might fail. CkanModule latest_available_for_any_ksp = null; try { latest_available_for_any_ksp = registry.LatestAvailable(identifier, null); } catch { } // If there's known information for this mod in any form, calculate the highest compatible // KSP. if (latest_available_for_any_ksp != null) { KSPCompatibility = registry.LatestCompatibleKSP(identifier)?.ToYalovString() ?? Properties.Resources.GUIModUnknown; KSPCompatibilityLong = string.Format(Properties.Resources.GUIModKSPCompatibilityLong, KSPCompatibility, latest_available_for_any_ksp.version); } else { // No idea what this mod is, sorry! KSPCompatibility = KSPCompatibilityLong = Properties.Resources.GUIModUnknown; } if (latest_version != null) { LatestVersion = latest_version.ToString(); } else if (latest_available_for_any_ksp != null) { LatestVersion = latest_available_for_any_ksp.version.ToString(); } else { LatestVersion = "-"; } // If we have a homepage provided, use that; otherwise use the spacedock page, curse page or the github repo so that users have somewhere to get more info than just the abstract. Homepage = Properties.Resources.GUIModNSlashA; SearchableIdentifier = CkanModule.nonAlphaNums.Replace(Identifier, ""); }