Beispiel #1
0
        /// <summary>
        /// Returns true if files were downloaded.
        /// </summary>
        /// <param name="modValueFileNames"></param>
        /// <returns></returns>
        private static bool CheckAvailabilityAndUpdateModFiles(List <string> modValueFileNames, Values values)
        {
            var(missingModValueFilesOnlineAvailable, missingModValueFilesOnlineNotAvailable, modValueFilesWithAvailableUpdate) = values.CheckAvailabilityAndUpdateModFiles(modValueFileNames);

            bool filesDownloaded = false;

            if (modValueFilesWithAvailableUpdate.Any() &&
                MessageBox.Show("For " + modValueFilesWithAvailableUpdate.Count.ToString() + " value files there is an update available. It is strongly recommended to use the updated versions.\n"
                                + "The updated files can be downloaded automatically if you want.\n"
                                + "The following files can be downloaded\n\n"
                                + string.Join("\n", modValueFilesWithAvailableUpdate)
                                + "\n\nDo you want to download these files?",
                                "Updates for value files available", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
                == DialogResult.Yes)
            {
                filesDownloaded |= values.modsManifest.DownloadModFiles(modValueFilesWithAvailableUpdate);
            }

            if (missingModValueFilesOnlineAvailable.Any() &&
                MessageBox.Show(missingModValueFilesOnlineAvailable.Count.ToString() + " mod-value files are not available locally. Without these files the library will not display all creatures.\n"
                                + "The missing files can be downloaded automatically if you want.\n"
                                + "The following files can be downloaded\n\n"
                                + string.Join("\n", missingModValueFilesOnlineAvailable)
                                + "\n\nDo you want to download these files?",
                                "Missing value files", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
                == DialogResult.Yes)
            {
                filesDownloaded |= values.modsManifest.DownloadModFiles(missingModValueFilesOnlineAvailable);
            }

            if (missingModValueFilesOnlineNotAvailable.Any())
            {
                MessageBoxes.ShowMessageBox(missingModValueFilesOnlineNotAvailable.Count + " mod-value files are neither available locally nor online. The creatures of the missing mod will not be displayed.\n"
                                            + "The following files are missing\n\n"
                                            + string.Join("\n", missingModValueFilesOnlineNotAvailable), "Missing value files");
            }

            return(filesDownloaded);
        }
Beispiel #2
0
        public bool loadValues()
        {
            bool loadedSuccessful = true;

            string filename = "values.json";

            // check if file exists
            if (!File.Exists(filename))
            {
                if (MessageBox.Show("Values-File '" + filename + "' not found. This tool will not work properly without that file.\n\nDo you want to visit the homepage of the tool to redownload it?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                    System.Diagnostics.Process.Start("https://github.com/cadon/ARKStatsExtractor/releases/latest");
                return false;
            }

            _V.version = 0;

            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Values));
            System.IO.FileStream file = System.IO.File.OpenRead(filename);

            try
            {
                _V = (Values)ser.ReadObject(file);
                _V.speciesNames = new List<string>();
                foreach (Species sp in _V.species)
                {
                    sp.initialize();
                    _V.speciesNames.Add(sp.name);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("File Couldn't be opened.\nErrormessage:\n\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                loadedSuccessful = false;
            }
            file.Close();

            //saveJSON();
            return loadedSuccessful;
        }
Beispiel #3
0
        public bool loadAdditionalValues(string filename, bool showResults)
        {
            // load extra values-file that can add values or modify existing ones
            bool loadedSuccessful = true;

            // check if file exists
            if (!File.Exists(filename))
            {
                MessageBox.Show("Additional Values-File '" + filename + "' not found.\nThis collection seems to have modified or added values that are saved in a separate file, which couldn't be found at the saved location. You can load it manually via the menu File - Load additional values...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Values));

            System.IO.FileStream file = System.IO.File.OpenRead(filename);

            Values modifiedValues = new Values();

            try
            {
                modifiedValues = (Values)ser.ReadObject(file);
            }
            catch (Exception e)
            {
                MessageBox.Show("File Couldn't be opened or read.\nErrormessage:\n\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                loadedSuccessful = false;
            }
            file.Close();
            if (!loadedSuccessful)
            {
                return(false);
            }

            int speciesUpdated = 0;
            int speciesAdded   = 0;

            // update data if existing
            // version
            if (modifiedValues.version > 0)
            {
                _V.version = modifiedValues.version;
            }
            // species
            if (modifiedValues.species != null)
            {
                foreach (Species sp in modifiedValues.species)
                {
                    if (!_V.speciesNames.Contains(sp.name))
                    {
                        _V.species.Add(sp);
                        sp.initialize();
                        _V.speciesNames.Add(sp.name);
                        speciesAdded++;
                    }
                    else
                    {
                        int  i       = _V.speciesNames.IndexOf(sp.name);
                        bool updated = false;
                        if (sp.TamedBaseHealthMultiplier != null)
                        {
                            _V.species[i].TamedBaseHealthMultiplier = sp.TamedBaseHealthMultiplier;
                            updated = true;
                        }
                        if (sp.NoImprintingForSpeed != null)
                        {
                            _V.species[i].NoImprintingForSpeed = sp.NoImprintingForSpeed;
                            updated = true;
                        }
                        if (sp.statsRaw != null && sp.statsRaw.Length > 0)
                        {
                            for (int s = 0; s < 8 && s < sp.statsRaw.Length; s++)
                            {
                                if (sp.statsRaw[s] != null)
                                {
                                    for (int si = 0; si < 5 && si < sp.statsRaw[s].Length; si++)
                                    {
                                        if (sp.statsRaw[s][si] != null)
                                        {
                                            _V.species[i].statsRaw[s][si] = sp.statsRaw[s][si];
                                            updated = true;
                                        }
                                    }
                                }
                            }
                            if (updated)
                            {
                                speciesUpdated++;
                            }
                        }
                    }
                }
            }
            // fooddata TODO
            // default-multiplier TODO

            if (showResults)
            {
                MessageBox.Show("Species with changed stats: " + speciesUpdated + "\nSpecies added: " + speciesAdded, "Additional Values succesfully added", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return(true);
        }