예제 #1
0
        /// <summary>
        /// Export the creature export file of the given exportedCreature control.
        /// </summary>
        /// <param name="ecc"></param>
        /// <param name="updateParentVisuals"></param>
        private void ExtractExportedFileInExtractor(importExported.ExportedCreatureControl ecc, bool updateParentVisuals = false)
        {
            if (ecc == null)
            {
                return;
            }

            SetCreatureValuesToExtractor(ecc.creatureValues, false);

            // exported stat-files have values for all stats, so activate all stats the species uses
            SetStatsActiveAccordingToUsage(ecc.creatureValues.Species);

            ExtractLevels(autoExtraction: false, statInputsHighPrecision: true);
            // gets deleted in extractLevels()
            exportedCreatureControl = ecc;

            // not for batch-extractions, only for single creatures
            if (updateParentVisuals)
            {
                UpdateParentListInput(creatureInfoInputExtractor);
            }

            SetCreatureValuesToInfoInput(exportedCreatureControl.creatureValues, creatureInfoInputExtractor);
            if (exportedCreatureList != null && exportedCreatureList.ownerSuffix != null)
            {
                creatureInfoInputExtractor.CreatureOwner += exportedCreatureList.ownerSuffix;
            }

            SetMessageLabelText("Creature of the exported file\n" + exportedCreatureControl.exportedFile);
            DisplayIfCreatureAlreadyInLibrary();
        }
        private void ExportedCreatureList_CheckGuidInLibrary(importExported.ExportedCreatureControl exportedCreatureControl)
        {
            Creature cr = _creatureCollection.creatures.SingleOrDefault(c => c.guid == exportedCreatureControl.creatureValues.guid);

            if (cr != null && !cr.flags.HasFlag(CreatureFlags.Placeholder))
            {
                exportedCreatureControl.setStatus(importExported.ExportedCreatureControl.ImportStatus.OldImported, cr.addedToLibrary);
            }
            else
            {
                exportedCreatureControl.setStatus(importExported.ExportedCreatureControl.ImportStatus.NotImported, DateTime.Now);
            }
        }
예제 #3
0
        /// <summary>
        /// Export the creature export file of the given exportedCreature control.
        /// </summary>
        /// <param name="ecc"></param>
        /// <param name="updateParentVisuals"></param>
        private void ExtractExportedFileInExtractor(importExported.ExportedCreatureControl ecc, bool updateParentVisuals = false)
        {
            if (ecc == null)
            {
                return;
            }

            ExtractValuesInExtractor(ecc.creatureValues, ecc.exportedFile, false);

            // gets deleted in extractLevels()
            exportedCreatureControl = ecc;

            if (exportedCreatureList != null && exportedCreatureList.ownerSuffix != null)
            {
                creatureInfoInputExtractor.CreatureOwner += exportedCreatureList.ownerSuffix;
            }
        }
        private void ExportedCreatureList_CopyValuesToExtractor(importExported.ExportedCreatureControl exportedCreatureControl, bool addToLibraryIfUnique, bool goToLibraryTab)
        {
            tabControlMain.SelectedTab = tabPageExtractor;
            ExtractExportedFileInExtractor(exportedCreatureControl, updateParentVisuals: !addToLibraryIfUnique);

            // add to library automatically if batch-extracting exportedImported values and uniqueLevels
            if (addToLibraryIfUnique)
            {
                if (_extractor.uniqueResults)
                {
                    AddCreatureToCollection(true, exportedCreatureControl.creatureValues.motherArkId, exportedCreatureControl.creatureValues.fatherArkId, goToLibraryTab);
                }
                else
                {
                    exportedCreatureControl.setStatus(importExported.ExportedCreatureControl.ImportStatus.NeedsLevelChosing, DateTime.Now);
                }
            }
            else
            {
                // bring main-window to front to work with the data
                BringToFront();
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        public void loadFilesInFolder(string folderPath)
        {
            if (Directory.Exists(folderPath))
            {
                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 (files.Length > 50 &&
                    MessageBox.Show($"There are many 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();

                // load game.ini and gameusersettings.ini if available and use the settings.
                if (File.Exists(folderPath + @"\game.ini") || File.Exists(folderPath + @"\gameusersettings.ini"))
                {
                    // set multipliers to default
                    // TODO
                    // set settings to values of files
                    // TODO
                }

                foreach (string f in files)
                {
                    ExportedCreatureControl ecc = new ExportedCreatureControl(f);
                    if (ecc.validValues)
                    {
                        ecc.Dock = DockStyle.Top;
                        ecc.CopyValuesToExtractor += CopyValuesToExtractor;
                        ecc.CheckArkIdInLibrary   += CheckArkIdInLibrary;
                        ecc.DoCheckArkIdInLibrary();
                        eccs.Add(ecc);
                        if (!string.IsNullOrEmpty(ecc.creatureValues.species) && !hiddenSpecies.Contains(ecc.creatureValues.species))
                        {
                            hiddenSpecies.Add(ecc.creatureValues.species);
                        }
                    }
                }

                // 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);
                UpdateStatusBarLabel();
                ResumeLayout();
            }
        }
예제 #7
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);
            }
        }