示例#1
0
        // --------------------------------------------------------------------------------------------------------------------------------

        public static AddonPackageSet Load(out string pErrorText, string pFilename = null)
        {
            pErrorText = null;
            pFilename  = GetFileName(pFilename);

            if (!File.Exists(pFilename))
            {
                return(null);
            }

            AddonPackageSet addonCatalogue = new AddonPackageSet();

            try
            {
                XmlSerializer serializer = new XmlSerializer(addonCatalogue.GetType());
                using (StreamReader reader = new StreamReader(pFilename))
                {
                    addonCatalogue = (AddonPackageSet)serializer.Deserialize(reader);
                    reader.Close();
                }
                CheckAndUpdateVersion(addonCatalogue, pFilename);
            }
            catch (Exception exception)
            {
                pErrorText     = Utils.GetExceptionExtendedMessage(exception);
                addonCatalogue = null;
            }
            return(addonCatalogue);
        }
示例#2
0
        // ----------------------------------------------------------------------------------------------------------------------------------------------------


        public object Clone()
        {
            MoviestormPaths clonedMoviestormPaths = (MoviestormPaths)MoviestormPaths.Clone();
            List <string>   clonedAddonSources    = null;

            if (AddonSources != null)
            {
                clonedAddonSources = new List <string>();
                foreach (string source in AddonSources)
                {
                    clonedAddonSources.Add(source);
                }
            }

            AddonPackageSet newAddonPackageSet = new AddonPackageSet(clonedMoviestormPaths, clonedAddonSources, Description);

            List <AddonPackage> clonedAddons = null;

            if (Addons != null)
            {
                clonedAddons = new List <AddonPackage>();
                foreach (AddonPackage item in Addons)
                {
                    clonedAddons.Add(item);
                }
            }

            newAddonPackageSet.CatalogueVersion = CatalogueVersion;
            newAddonPackageSet.Addons           = clonedAddons;
            newAddonPackageSet.LastUpdate       = LastUpdate;

            return(newAddonPackageSet);
        }
示例#3
0
        private static void CheckAndUpdateVersion(AddonPackageSet pAddonPackageSet, string pFilename)
        {
            string catalogueVersion = pAddonPackageSet.CatalogueVersion?.Trim();

            bool needsRecreatingAddonSummaries = false;
            bool needsUpdatingCatalogueVersion = false;

            uint catalogueVersionNumber        = VersionNumber(catalogueVersion);
            uint currentCatalogueVersionNumber = VersionNumber(CurrentCatalogueVersion);

            if (catalogueVersionNumber < currentCatalogueVersionNumber)
            {
                needsUpdatingCatalogueVersion = true;
            }
            if (catalogueVersionNumber < 0x010500)
            {
                needsRecreatingAddonSummaries = true;
            }

            if (needsRecreatingAddonSummaries)
            {
                RecreateAddonSummaries(pAddonPackageSet);
            }

            if (needsUpdatingCatalogueVersion)
            {
                pAddonPackageSet.CatalogueVersion = CurrentCatalogueVersion;
                string errorText;
                pAddonPackageSet.Save(out errorText, pFilename);
            }
        }
示例#4
0
        // Required because of the introduction of AddonPackage.AssetSummary in 1.5.3
        private static void RecreateAddonSummaries(AddonPackageSet pAddonPackageSet)
        {
            if ((pAddonPackageSet.Addons == null) || (pAddonPackageSet.Addons.Count == 0))
            {
                return;
            }

            foreach (AddonPackage addon in pAddonPackageSet.Addons)
            {
                addon.UpdateAssetSummary();
            }
            pAddonPackageSet.LastUpdate = DateTime.Now;
        }