/// <summary> /// Tries to load a mod file. /// If the mod-values will be used, setModFileName should be true. /// If the file cannot be found or the format is wrong, the file is ignored and no exception is thrown if throwExceptionOnFail is false. /// </summary> /// <param name="filePath"></param> /// <param name="setModFileName"></param> /// <param name="throwExceptionOnFail"></param> /// <param name="values"></param> /// <param name="errorMessage"></param> /// <returns></returns> public static bool TryLoadValuesFile(string filePath, bool setModFileName, bool throwExceptionOnFail, out Values values, out string errorMessage) { values = null; errorMessage = null; try { values = LoadValuesFile(filePath); if (setModFileName) { values.mod.FileName = Path.GetFileName(filePath); } return(true); } catch (FileNotFoundException ex) { errorMessage = "Values-File '" + filePath + "' not found. " + "This collection seems to have modified stat values that are saved in a separate file, " + "which couldn't be found at the saved location."; if (throwExceptionOnFail) { throw new FileNotFoundException(errorMessage, ex); } } catch (FormatException ex) { errorMessage = "Values-File '" + filePath + $"' has an invalid version.\n{ex.Message}\nTry updating ARK Smart Breeding."; if (throwExceptionOnFail) { throw new FormatException(errorMessage); } } return(false); }
/// <summary> /// Loads the values from the default file. /// </summary> /// <returns></returns> public Values LoadValues() { _V = LoadValuesFile(FileService.GetJsonPath(FileService.ValuesFolder, FileService.ValuesJson)); InitializeStatValues(); return(_V); }