예제 #1
0
        // 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);
        }
예제 #2
0
 public Dictionary <string, string> GetTagDictionary()
 {
     return(ThreadExecuter.Execute(
                () => _repo.GetTagDictionary()
                ));
 }