private static void LoadIcons(string arcItemsFile) { Logger.Info($"Loading item icons from {arcItemsFile}."); var isArcFileLocked = IOHelper.IsFileLocked(new FileInfo(arcItemsFile)); var arcTempFile = new TemporaryCopy(arcItemsFile, isArcFileLocked); var arcItemFileName = arcTempFile.Filename; if (isArcFileLocked) { Logger.Info($"The file {arcItemsFile} is currently locked for reading. Perhaps Grim Dawn is running?"); Logger.Info($"A copy of {arcItemsFile} has been created at {arcItemFileName}"); } if (!File.Exists(arcItemFileName)) { Logger.Warn($"Item icon file \"{arcItemFileName}\" could not be located."); } try { DDSImageReader.ExtractItemIcons(arcItemFileName, GlobalPaths.StorageFolder); } catch (ArgumentException ex) { // Ideally we'd like to catch the specific exception, but the available log files don't contain the exception name.. Logger.Error(ex.Message, ex); MessageBox.Show( "Unable to parse icons, ARZ file is corrupted.\nIf you are using steam, please verify the install integrity.", "Corrupted GD installation", MessageBoxButtons.OK); } }
// LocalizationFile private Dictionary <string, string> LoadTags(string arcTagfile, string localizationFile, bool expansionOnlyMod) { // Process and load the _tags Load the _tags Dictionary <string, string> mappedTags; bool isTagfileLocked = IOHelper.IsFileLocked(new FileInfo(arcTagfile)); TemporaryCopy arcTagTemp = isTagfileLocked ? new TemporaryCopy(arcTagfile) : null; // Load from user localization var localizationLoader = new LocalizationLoader(); if (!string.IsNullOrEmpty(localizationFile) && localizationLoader.Load(localizationFile)) { _tags = localizationLoader.GetItemTags(); } // Load from GD else { List <IItemTag> _tags = Parser.Arz.ArzParser.ParseArcFile(isTagfileLocked ? arcTagTemp.Filename : arcTagfile); this._tags = new HashSet <ItemTag>(_tags.Select(m => new ItemTag { Name = m.Name, Tag = m.Tag }).ToArray() ); } bool saveOrUpdate = expansionOnlyMod; if (saveOrUpdate) { _databaseItemDao.SaveOrUpdate(_tags); } else { _databaseItemDao.Save(_tags); } // Fallback: Just use whatever names we got stored in db if (_tags == null || _tags.Count == 0) { Logger.Info( "Using cached tag dictionary instead, this may or may not be compatible with the supplied mod."); Logger.Info("If this is causing any issues, switch to vanilla then back to the mod."); mappedTags = _databaseItemDao.GetTagDictionary(); } else { mappedTags = _tags.ToDictionary(item => item.Tag, item => item.Name); var dbTags = _databaseItemDao.GetTagDictionary(); foreach (var key in dbTags.Keys.Where(key => !mappedTags.ContainsKey(key))) { mappedTags[key] = dbTags[key]; } } return(mappedTags); }
private void LoadTags(string file) { bool isTagfileLocked = IOHelper.IsFileLocked(new FileInfo(file)); TemporaryCopy tempfile = isTagfileLocked ? new TemporaryCopy(file) : null; Logger.Debug($"Loading tags from {file}"); List<IItemTag> tags = Parser.Arz.ArzParser.ParseArcFile(isTagfileLocked ? tempfile.Filename : file); tags.ForEach(m => _tagAccumulator.Add(m.Tag, m.Name)); Logger.Debug($"Loaded {tags.Count} tags from {file}"); }
private static void LoadIcons(string arcItemsFile) { Logger.Info($"Loading item icons from {arcItemsFile}.."); bool arcfileLocked = IOHelper.IsFileLocked(new FileInfo(arcItemsFile)); TemporaryCopy arcTempFile = new TemporaryCopy(arcItemsFile, arcfileLocked); string arcItemfile = arcTempFile.Filename; if (arcfileLocked) { Logger.Info($"The file {arcItemsFile} is currently locked for reading. Perhaps Grim Dawn is running?"); Logger.Info($"A copy of {arcItemsFile} has been created at {arcItemfile}"); } if (!File.Exists(arcItemfile)) { Logger.Warn($"Item icon file \"{arcItemfile}\" could not be located.."); } DDSImageReader.ExtractItemIcons(arcItemfile, GlobalPaths.StorageFolder); }