Ejemplo n.º 1
0
        /// <summary>
        /// Initialize a GUIMod based on a CkanModule
        /// </summary>
        /// <param name="mod">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(CkanModule mod, IRegistryQuerier registry, KspVersionCriteria current_ksp_version, bool?incompatible = null)
            : this(mod.identifier, registry, current_ksp_version, incompatible)
        {
            Mod    = mod;
            IsCKAN = mod is CkanModule;

            Name        = mod.name.Trim();
            Abstract    = [email protected]();
            Description = mod.description?.Trim() ?? string.Empty;
            Abbrevation = new string(Name.Split(' ').Where(s => s.Length > 0).Select(s => s[0]).ToArray());
            Authors     = mod.author == null ? Properties.Resources.GUIModNSlashA : String.Join(",", mod.author);

            HasUpdate      = registry.HasUpdate(mod.identifier, current_ksp_version);
            HasReplacement = registry.GetReplacement(mod, current_ksp_version) != null;
            DownloadSize   = mod.download_size == 0 ? Properties.Resources.GUIModNSlashA : CkanModule.FmtSize(mod.download_size);

            // Get the Searchables.
            SearchableName        = mod.SearchableName;
            SearchableAbstract    = mod.SearchableAbstract;
            SearchableDescription = mod.SearchableDescription;
            SearchableAuthors     = mod.SearchableAuthors;

            // If not set in GUIMod(identifier, ...) (because the mod is not known to the registry),
            // set based on the the data we have from the CkanModule.
            if (KSPCompatibilityVersion == null)
            {
                KSPCompatibilityVersion = mod.LatestCompatibleKSP();
                KSPCompatibility        = KSPCompatibilityVersion?.ToYalovString() ?? Properties.Resources.GUIModUnknown;
                KSPCompatibilityLong    = string.Format(
                    Properties.Resources.GUIModKSPCompatibilityLong,
                    KSPCompatibility,
                    mod.version
                    );
            }

            UpdateIsCached();
        }