Exemple #1
0
        /// <summary>
        /// Reads all compatible files in the stated folder. If the folder is nullOrEmpty, the previous used folder is used.
        /// </summary>
        /// <param name="folderPath"></param>
        public void LoadFilesInFolder(string folderPath = null)
        {
            if (string.IsNullOrEmpty(folderPath))
            {
                folderPath = selectedFolder;
            }
            if (string.IsNullOrEmpty(folderPath) || !Directory.Exists(folderPath))
            {
                return;
            }

            selectedFolder = folderPath;

            string[] files = Directory.GetFiles(folderPath, "*dinoexport*.ini");
            // check if there are many files to import, then ask because that can take time
            if (Properties.Settings.Default.WarnWhenImportingMoreCreaturesThan > 0 &&
                files.Length > Properties.Settings.Default.WarnWhenImportingMoreCreaturesThan &&
                MessageBox.Show($"There are more than {Properties.Settings.Default.WarnWhenImportingMoreCreaturesThan}"
                                + $" files to import ({files.Length}) which can take some time.\n" +
                                "Do you really want to read all these files?",
                                "Many files to import", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
            {
                return;
            }

            SuspendLayout();
            ClearControls();
            hiddenSpecies.Clear();
            foreach (var i in speciesHideItems)
            {
                i.Dispose();
            }
            speciesHideItems.Clear();

            List <string> unknownSpeciesBlueprintPaths = new List <string>();
            List <string> ignoreSpeciesBlueprintPaths  = new List <string>();

            foreach (string f in files)
            {
                ExportedCreatureControl ecc = new ExportedCreatureControl(f);
                if (ecc.validValues)
                {
                    ecc.Dock = DockStyle.Top;
                    ecc.CopyValuesToExtractor += CopyValuesToExtractor;
                    ecc.CheckArkIdInLibrary   += CheckArkIdInLibrary;
                    ecc.DisposeThis           += Ecc_DisposeIt;
                    ecc.DoCheckArkIdInLibrary();
                    eccs.Add(ecc);
                    if (!string.IsNullOrEmpty(ecc.creatureValues.Species?.name) && !hiddenSpecies.Contains(ecc.creatureValues.Species.name))
                    {
                        hiddenSpecies.Add(ecc.creatureValues.Species.name);
                    }
                }
                else if (!string.IsNullOrEmpty(ecc.speciesBlueprintPath))
                {
                    if (unknownSpeciesBlueprintPaths.Contains(ecc.speciesBlueprintPath) ||
                        ignoreSpeciesBlueprintPaths.Contains(ecc.speciesBlueprintPath))
                    {
                        continue;
                    }

                    // check if species should be ignored (e.g. if it's a raft)
                    if (Values.V.IgnoreSpeciesBlueprint(ecc.speciesBlueprintPath))
                    {
                        ignoreSpeciesBlueprintPaths.Add(ecc.speciesBlueprintPath);
                        continue;
                    }

                    // species should not be ignored and is not yet in the unknown species list
                    unknownSpeciesBlueprintPaths.Add(ecc.speciesBlueprintPath);
                }
            }

            OrderList();

            hiddenSpecies.Sort();
            foreach (var s in hiddenSpecies)
            {
                var item = new ToolStripMenuItem(s)
                {
                    CheckOnClick = true,
                    Checked      = true
                };
                item.Click += ItemHideSpecies_Click;
                filterToolStripMenuItem.DropDownItems.Add(item);
                speciesHideItems.Add(item);
            }
            hiddenSpecies.Clear();

            Text = "Exported creatures in " + Utils.ShortPath(folderPath, 100);
            UpdateStatusBarLabelAndControls();
            ResumeLayout();

            // check for unsupported species
            if (unknownSpeciesBlueprintPaths.Any())
            {
                CheckForUnknownMods?.Invoke(unknownSpeciesBlueprintPaths);
            }
        }
Exemple #2
0
        /// <summary>
        /// Reads all compatible files in the stated folder. If the folder is nullOrEmpty, the previous used folder is used.
        /// </summary>
        /// <param name="folderPath"></param>
        public void loadFilesInFolder(string folderPath = null)
        {
            if (string.IsNullOrEmpty(folderPath))
            {
                folderPath = selectedFolder;
            }
            if (string.IsNullOrEmpty(folderPath) || !Directory.Exists(folderPath))
            {
                return;
            }

            selectedFolder = folderPath;

            string[] files = Directory.GetFiles(folderPath, "*dinoexport*.ini");
            // check if there are many files to import, then ask because that can take time
            if (Properties.Settings.Default.WarnWhenImportingMoreCreaturesThan > 0 &&
                files.Length > Properties.Settings.Default.WarnWhenImportingMoreCreaturesThan &&
                MessageBox.Show($"There are more than {Properties.Settings.Default.WarnWhenImportingMoreCreaturesThan}"
                                + $" files to import ({files.Length}) which can take some time.\n" +
                                "Do you really want to read all these files?",
                                "Many files to import", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
            {
                return;
            }

            SuspendLayout();
            ClearControls();
            hiddenSpecies.Clear();
            foreach (var i in speciesHideItems)
            {
                i.Dispose();
            }
            speciesHideItems.Clear();

            List <string> unknownSpeciesBlueprintPaths = new List <string>();
            var           ignoreClasses = Values.V.IgnoreSpeciesClassesOnImport;

            foreach (string f in files)
            {
                ExportedCreatureControl ecc = new ExportedCreatureControl(f);
                if (ecc.validValues)
                {
                    ecc.Dock = DockStyle.Top;
                    ecc.CopyValuesToExtractor += CopyValuesToExtractor;
                    ecc.CheckArkIdInLibrary   += CheckArkIdInLibrary;
                    ecc.DisposeThis           += Ecc_DisposeIt;
                    ecc.DoCheckArkIdInLibrary();
                    eccs.Add(ecc);
                    if (!string.IsNullOrEmpty(ecc.creatureValues.Species?.name) && !hiddenSpecies.Contains(ecc.creatureValues.Species.name))
                    {
                        hiddenSpecies.Add(ecc.creatureValues.Species.name);
                    }
                }
                else
                {
                    if (unknownSpeciesBlueprintPaths.Contains(ecc.speciesBlueprintPath))
                    {
                        continue;
                    }

                    // check if species should be ignored (e.g. if it's a raft)
                    string speciesClassString;
                    var    m = Regex.Match(ecc.creatureValues.speciesBlueprint, @"\/([^\/\.]+)\.");
                    if (m.Success)
                    {
                        speciesClassString = m.Groups[1].Value;
                        if (!speciesClassString.EndsWith("_C"))
                        {
                            speciesClassString += "_C";
                        }
                        if (ignoreClasses.Contains(speciesClassString))
                        {
                            continue;
                        }

                        // species should not be ignored and it not yet in the unknown species list
                        unknownSpeciesBlueprintPaths.Add(ecc.speciesBlueprintPath);
                    }
                }
            }

            // sort according to date and if already in library (order seems reversed here, because controls get added reversely)
            eccs = eccs.OrderByDescending(e => e.Status).ThenBy(e => e.AddedToLibrary).ToList();

            foreach (var ecc in eccs)
            {
                panel1.Controls.Add(ecc);
            }

            hiddenSpecies.Sort();
            foreach (var s in hiddenSpecies)
            {
                var item = new ToolStripMenuItem(s);
                item.CheckOnClick = true;
                item.Checked      = true;
                item.Click       += ItemHideSpecies_Click;
                filterToolStripMenuItem.DropDownItems.Add(item);
                speciesHideItems.Add(item);
            }
            hiddenSpecies.Clear();

            Text = "Exported creatures in " + Utils.shortPath(folderPath, 100);
            UpdateStatusBarLabelAndControls();
            ResumeLayout();

            // check for unsupported species
            if (unknownSpeciesBlueprintPaths.Any())
            {
                CheckForUnknownMods?.Invoke(unknownSpeciesBlueprintPaths);
            }
        }