예제 #1
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);
        }
예제 #2
0
        private static CataloguesIndex InitializeNoCatalogues(MoviestormPaths pMoviestormPaths, out string pErrorText)
        {
            CataloguesIndex cataloguesIndex = new CataloguesIndex();

            cataloguesIndex.Catalogues = new List <CatalogueInfo>();

            AddonPackageSet packageSet = new AddonPackageSet(pMoviestormPaths, null)
            {
                Description = "Default catalogue"
            };

            packageSet.Save(out pErrorText, cataloguesIndex.DefaultAddonDatabaseFilename);
            CatalogueInfo catalogue = new CatalogueInfo()
            {
                Name               = cataloguesIndex.DefaultAddonDatabase,
                Description        = "Default catalogue",
                AddonCount         = 0,
                LastUpdateDateTime = packageSet.LastUpdate,
                Version            = packageSet.CatalogueVersion
            };

            cataloguesIndex.Catalogues.Add(catalogue);
            cataloguesIndex.Save(CataloguesIndexFilePath, out pErrorText);

            return(cataloguesIndex);
        }
예제 #3
0
        // -----------------------------------------------------------------------------------------------


        public CatalogueIndexOpsForm(CataloguesIndexOperation pOperation, MoviestormPaths pMoviestormPaths, CataloguesIndex pCataloguesIndex, string pSelectedCatalogueName)
        {
            _operation             = pOperation;
            _moviestormPaths       = pMoviestormPaths;
            CataloguesIndex        = pCataloguesIndex;
            _selectedCatalogueName = pSelectedCatalogueName;

            InitializeComponent();
        }
예제 #4
0
        // -------------------------------------------------------------------------------------------------


        public static CataloguesIndex Initialize(MoviestormPaths pMoviestormPaths, out string pErrorText)
        {
            pErrorText = null;

            List <string> catalogueFiles = Directory.EnumerateFiles(Utils.GetExecutableDirectory(), "*.scat").ToList();

            if ((catalogueFiles == null) || (catalogueFiles.Count == 0))
            {
                return(InitializeNoCatalogues(pMoviestormPaths, out pErrorText));
            }

            int defaultIndex = -1;
            int index        = 0;

            List <CatalogueInfo> catalogues = new List <CatalogueInfo>();

            foreach (string file in catalogueFiles)
            {
                CatalogueInfo catalogue = new CatalogueInfo()
                {
                    Name = Path.GetFileNameWithoutExtension(file)
                };
                string          errorText;
                AddonPackageSet packageSet = AddonPackageSet.Load(out errorText, file);
                catalogue.Description = packageSet?.Description;

                if ((catalogue.FilePath.ToLower() == AddonPackageSet.DefaultAddonPackageSetFileName.ToLower()) ||
                    (catalogueFiles.Count == 1))
                {
                    if (catalogue.Description == null)
                    {
                        catalogue.Description = "Default catalogue";
                    }
                    defaultIndex = index;
                }

                catalogue.LastUpdateDateTime = packageSet.LastUpdate;
                catalogue.AddonCount         = packageSet?.Addons.Count ?? 0;
                catalogue.Version            = packageSet.CatalogueVersion;

                catalogues.Add(catalogue);
                index++;
            }

            CataloguesIndex cataloguesIndex = new CataloguesIndex();

            cataloguesIndex.Catalogues = catalogues.OrderBy(o => o.FilePath).ToList();

            cataloguesIndex.DefaultAddonDatabase =
                (defaultIndex < 0)
                    ? cataloguesIndex.Catalogues[0].Name
                    : cataloguesIndex.Catalogues[defaultIndex].Name;

            cataloguesIndex.Save(CataloguesIndexFilePath, out pErrorText);
            return(cataloguesIndex);
        }
예제 #5
0
        private void Initialize(MoviestormPaths pMoviestormPaths, List <string> pSources, string pDescription)
        {
            string errorText;

            MoviestormPaths  = pMoviestormPaths ?? AddonPersistenceUtils.GetMoviestormPaths(out errorText);
            AddonSources     = pSources;
            Description      = pDescription;
            CatalogueVersion = CurrentCatalogueVersion;
            LastUpdate       = DateTime.Now;
        }
예제 #6
0
        // ---------------------------------------------------------------------------------------------------

        private void pbPathsDefaults_Click(object sender, EventArgs e)
        {
            string          errorText;
            MoviestormPaths defaultMoviestormPaths = AddonPersistenceUtils.GetMoviestormPaths(out errorText);

            if (defaultMoviestormPaths == null)
            {
                MessageBox.Show(errorText, "Error determining Moviestorm folders", MessageBoxButtons.OK);
                return;
            }

            tbMoviestormInstallPath.Text  = defaultMoviestormPaths.InstallationPath;
            tbMoviestormUserDataPath.Text = defaultMoviestormPaths.UserDataPath;
        }
예제 #7
0
        private static bool InitializationChores(string[] pArgs, out string pErrorText)
        {
            pErrorText = null;
            if (!CheckArguments(pArgs))
            {
                return(false);
            }

            _tempPath = Utils.GetTempDirectory();

            string errorText;

            Utils.ResetTempFolder(out errorText);

            _moviestormPaths = AddonPersistenceUtils.GetMoviestormPaths(out errorText);
            if (_moviestormPaths == null)
            {
                pErrorText = errorText;
                return(false);
            }

            return(true);
        }
예제 #8
0
 public AddonPackageSet(MoviestormPaths pMoviestormPaths, List <string> pSources, string pDescription = null)
 {
     Initialize(pMoviestormPaths, pSources, pDescription);
 }