public ThirdGenPluginVisitor(TagHierarchy tags, bool showInvisibles)
        {
            _tags = tags;

            Values = new ObservableCollection<MetaField>();
            Reflexives = new ObservableCollection<ReflexiveData>();
            _showInvisibles = showInvisibles;
        }
Example #2
0
        public ThirdGenPluginVisitor(TagHierarchy tags, Trie stringIDTrie, FileSegmentGroup metaArea, bool showInvisibles)
        {
            _tags = tags;
            _stringIDTrie = stringIDTrie;
            _metaArea = metaArea;

            Values = new ObservableCollection<MetaField>();
            Reflexives = new ObservableCollection<ReflexiveData>();
            _showInvisibles = showInvisibles;
        }
Example #3
0
        private TagHierarchy BuildTagHierarchy(Func<TagClass, bool> classFilter, Func<TagEntry, bool> tagFilter)
        {
            // Build a dictionary of tag classes
            var classWrappers = new Dictionary<ITagClass, TagClass>();
            foreach (ITagClass tagClass in _cacheFile.TagClasses)
            {
                string name = CharConstant.ToString(tagClass.Magic);
                string description = _cacheFile.StringIDs.GetString(tagClass.Description) ?? "unknown";
                var wrapper = new TagClass(tagClass, name, description);
                classWrappers[tagClass] = wrapper;
            }

            // Now add tags which match the filter to their respective classes
            var result = new TagHierarchy
            {
                Entries = _tagEntries
            };

            foreach (TagEntry tag in _tagEntries.Where(t => t != null))
            {
                TagClass parentClass = classWrappers[tag.RawTag.Class];
                if (tagFilter(tag))
                    parentClass.Children.Add(tag);
            }

            // Build a sorted list of classes, and then sort each tag in them
            List<TagClass> classList = classWrappers.Values.Where(classFilter).ToList();
            classList.Sort((a, b) => String.Compare(a.TagClassMagic, b.TagClassMagic, StringComparison.OrdinalIgnoreCase));
            foreach (TagClass tagClass in classList)
                tagClass.Children.Sort((a, b) => String.Compare(a.TagFileName, b.TagFileName, StringComparison.OrdinalIgnoreCase));

            // Done!
            Dispatcher.Invoke(new Action(delegate
            {
                // Give the dispatcher ownership of the ObservableCollection
                result.Classes = new ObservableCollection<TagClass>(classList);
            }));

            return result;
        }
Example #4
0
        private void UpdateTagFilter()
        {
            if (_cacheFile == null)
                return;

            string filter = "";
            Dispatcher.Invoke(new Action(delegate { filter = txtTagSearch.Text.ToLower(); }));

            _visibleTags = BuildTagHierarchy(
                c => FilterClass(c, filter),
                t => FilterTag(t, filter));

            Dispatcher.Invoke(new Action(delegate { tvTagList.DataContext = _visibleTags.Classes; }));
        }
Example #5
0
        private void LoadTags()
        {
            if (_cacheFile.TagClasses == null || _cacheFile.Tags == null)
                return;

            // Only allow tag importing if resource data is available
            if (_cacheFile.Resources == null)
                Dispatcher.Invoke(new Action(() => btnImport.IsEnabled = false));

            _tagEntries = _cacheFile.Tags.Select(WrapTag).ToList();
            _allTags = BuildTagHierarchy(
                c => c.Children.Count > 0,
                t => true);

            UpdateTagFilter();
        }
Example #6
0
        private void LoadTags()
        {
            if (_cacheFile.TagClasses.Count == 0)
            {
                // Cache file does not support tags
                Dispatcher.Invoke(new Action(() => tabTags.Visibility = Visibility.Collapsed));
                return;
            }

            // Only allow tag importing if resource data is available
            if (_cacheFile.Resources == null)
                Dispatcher.Invoke(new Action(() => btnImport.IsEnabled = false));

            // Hide import/save name buttons if the cache file isn't thirdgen
            if (_cacheFile.Engine != EngineType.ThirdGeneration)
                Dispatcher.Invoke(new Action(() => panelTagButtons.Visibility = Visibility.Collapsed));

            _tagEntries = _cacheFile.Tags.Select(WrapTag).ToList();
            _allTags = BuildTagHierarchy(
                c => c.Children.Count > 0,
                t => true);

            UpdateTagFilter();
        }
Example #7
0
        private void LoadTags()
        {
            if (_cacheFile.TagClasses == null || _cacheFile.Tags == null)
                return;

            // Load all the tag classes into data
            var classes = new List<TagClass>();
            var classWrappers = new Dictionary<ITagClass, TagClass>();
            Dispatcher.Invoke(new Action(() =>
                                  {
                                      foreach (var tagClass in _cacheFile.TagClasses)
                                      {
                                          var wrapper = new TagClass(tagClass, CharConstant.ToString(tagClass.Magic), _cacheFile.StringIDs.GetString(tagClass.Description));
                                          classes.Add(wrapper);
                                          classWrappers[tagClass] = wrapper;
                                      }
                                  }));

            Dispatcher.Invoke(new Action(() => StatusUpdater.Update("Loaded Tag Classes")));

            // Load all the tags into the treeview (into their class categoies)
            _hierarchy.Entries = new List<TagEntry>();
            foreach (var tag in _cacheFile.Tags)
            {
                if (tag.MetaLocation != null)
                {
                    var fileName = _cacheFile.FileNames.GetTagName(tag);
                    if (fileName == null || fileName.Trim() == "")
                        fileName = tag.Index.ToString();

                    var parentClass = classWrappers[tag.Class];
                    var entry = new TagEntry(tag, parentClass, fileName);
                    parentClass.Children.Add(entry);
                    _hierarchy.Entries.Add(entry);
                }
                else
                    _hierarchy.Entries.Add(null);
            }

            foreach (var tagClass in classes)
                tagClass.Children.Sort((x, y) => String.Compare(x.TagFileName, y.TagFileName, StringComparison.OrdinalIgnoreCase));

            //// Taglist Generation
            /*string taglistPath = @"C:\" + _cacheFile.Info.InternalName.ToLower() + ".taglist";
            List<string> taglist = new List<string>();
            taglist.Add("<scenario=\"" + _cacheFile.Info.ScenarioName + "\">");
            for (int i = 0; i < _cacheFile.Tags.Count; i++)
            {
                ITag tag = _cacheFile.Tags[i];
                if (tag.Index.IsValid)
                    taglist.Add(string.Format("\t<tag id=\"{0}\" class=\"{1}\">{2}</tag>", tag.Index.ToString(), ExtryzeDLL.Util.CharConstant.ToString(tag.Class.Magic) ,_cacheFile.FileNames.FindTagName(tag.Index)));
            }
            taglist.Add("</scenario>");
            File.WriteAllLines(taglistPath, taglist.ToArray<string>());*/

            Dispatcher.Invoke(new Action(() => StatusUpdater.Update("Loaded Tags")));

            classes.Sort((x, y) => String.Compare(x.TagClassMagic, y.TagClassMagic, StringComparison.OrdinalIgnoreCase));
            Dispatcher.Invoke(new Action(delegate
                                  {
                                      _tagsComplete = new ObservableCollection<TagClass>(classes);

                                      // Load un-populated tags
                                      foreach (var tagClass in _tagsComplete.Where(tagClass => tagClass.Children.Count > 0))
                                          _tagsPopulated.Add(tagClass);
                                      _hierarchy.Classes = _tagsPopulated;
                                      _tmpHierarchy = _hierarchy;
                                  }));

            // Add to the treeview
            Dispatcher.Invoke(new Action(() => UpdateEmptyTags(cbShowEmptyTags.IsChecked != null && (bool) cbShowEmptyTags.IsChecked)));
        }