示例#1
0
        public static CommandContext Create(CommandContextStack stack, TagCache cache, FileInfo fileInfo, StringIdCache stringIds)
        {
            var context = new CommandContext(null, fileInfo.Name);

            context.AddCommand(new HelpCommand(stack));
            context.AddCommand(new DependencyCommand(cache, fileInfo));
            context.AddCommand(new FixupCommand(cache, fileInfo));
            context.AddCommand(new ExtractCommand(cache, fileInfo));
            context.AddCommand(new ImportCommand(cache, fileInfo));
            context.AddCommand(new InfoCommand(cache));
            context.AddCommand(new InsertCommand(cache, fileInfo));
            context.AddCommand(new ListCommand(cache));
            context.AddCommand(new MapCommand());
            context.AddCommand(new EditCommand(stack, cache, fileInfo, stringIds));
            context.AddCommand(new DuplicateTagCommand(cache, fileInfo));
            context.AddCommand(new AddressCommand());
            context.AddCommand(new ExtractBitmapsCommand(cache, fileInfo));
            context.AddCommand(new ResourceDataCommand());
            if (stringIds != null)
            {
                context.AddCommand(new StringIdCommand(stringIds));
                context.AddCommand(new ListStringsCommand(cache, fileInfo, stringIds));
                context.AddCommand(new GenerateLayoutsCommand(cache, fileInfo, stringIds));
            }
            return(context);
        }
 public static CommandContext Create(CommandContext parent, FileInfo fileInfo, TagCache cache, StringIdCache stringIds, HaloTag tag, Model model)
 {
     var context = new CommandContext(parent, string.Format("{0:X8}.hlmt", tag.Index));
     context.AddCommand(new HlmtListVariantsCommand(model, stringIds));
     context.AddCommand(new HlmtExtractModeCommand(cache, fileInfo, model, stringIds));
     return context;
 }
        public void Setup()
        {
            TagHelper.AddTag("Test");

            agent     = new GameObject();
            behaviour = agent.AddComponent <DotToTag>();
            agent.AddComponent <TagCache>();
            agent.transform.position = new Vector3(0, 0, 0);

            planarParameters.ContextMapRotationAxis = RotationAxis.YAxis;
            planarParameters.ContextMapResolution   = 4;
            behaviour.BehaviourName = "Test behaviour";

            behaviour.InstantiateContextMap(planarParameters);

            targetOne = new GameObject();
            targetOne.transform.position = new Vector3(0, 0, 5);
            targetOne.tag = "Test";
            TagCache.Register(targetOne);

            targetTwo = new GameObject();
            targetTwo.transform.position = new Vector3(5, 0, 0);
            targetTwo.tag = "Test";
            TagCache.Register(targetTwo);

            targetThree = new GameObject();
            targetThree.transform.position = new Vector3(0, 0, 0);
            targetThree.tag = "Test";
            TagCache.Register(targetThree);



            behaviour.Tags = new string[] { "Test" };
        }
 /// <summary>
 /// Creates a tag serialization context which serializes data into a tag.
 /// </summary>
 /// <param name="stream">The stream to write to.</param>
 /// <param name="cache">The cache file to write to.</param>
 /// <param name="stringIds">The stringID source to use.</param>
 /// <param name="tag">The tag to overwrite.</param>
 public TagSerializationContext(Stream stream, TagCache cache, StringIDCache stringIds, TagInstance tag)
 {
     _stream    = stream;
     _cache     = cache;
     _stringIds = stringIds;
     Tag        = tag;
 }
示例#5
0
        public void ClearAllTest()
        {
            Vector3[] ga  = TagCache.GetVector3sByTag("Test");
            Vector3   toA = testObjectA.transform.position;
            Vector3   toB = testObjectB.transform.position;
            Vector3   toC = testObjectC.transform.position;

            Assert.AreEqual(2, ga.Length);
            Assert.AreEqual(true, ga.Contains(toA));
            Assert.AreEqual(true, ga.Contains(toB));
            Assert.AreEqual(false, ga.Contains(toC));
            Assert.AreEqual(testObjectC.transform.position, TagCache.GetVector3sByTag("Dummy")[0]);

            testObjectA.transform.position = new Vector3(10, 123, 5);
            testObjectB.transform.position = new Vector3(13, 13, 1);
            testObjectC.transform.position = new Vector3(-10, 3, 0);

            TagCache.ClearAll();

            Vector3[] gaAfter = TagCache.GetVector3sByTag("Test");
            Assert.AreEqual(0, gaAfter.Length);
            Assert.AreEqual(false, gaAfter.Contains(toA));
            Assert.AreEqual(false, gaAfter.Contains(toB));
            Assert.AreEqual(false, gaAfter.Contains(testObjectA.transform.position));
            Assert.AreEqual(false, gaAfter.Contains(testObjectB.transform.position));
            Assert.AreEqual(false, gaAfter.Contains(testObjectC.transform.position));
        }
示例#6
0
 /// <summary>
 /// 获取指定标签
 /// 不存在或已删除时返回null
 /// </summary>
 /// <param name="tagId">标签Id</param>
 /// <returns></returns>
 public virtual Database.GenericTag GetTag(long tagId)
 {
     return(TagCache.GetOrCreate(tagId, () =>
                                 UnitOfWork.ReadData <Database.GenericTag, Database.GenericTag>(r => {
         return r.GetByIdWhereNotDeleted(tagId);
     }), TagCacheTime));
 }
        public void TearDown()
        {
            TagHelper.RemoveTag("Test");
            behaviour.OnDisable();

            TagCache.ClearAll();
        }
		public static CommandContext Create(CommandContextStack stack, TagCache cache, FileInfo fileInfo, StringIdCache stringIds)
		{
			var context = new CommandContext(null, fileInfo.Name);
			context.AddCommand(new HelpCommand(stack));
			context.AddCommand(new DependencyCommand(cache, fileInfo));
			context.AddCommand(new FixupCommand(cache, fileInfo));
			context.AddCommand(new ExtractCommand(cache, fileInfo));
			context.AddCommand(new ImportCommand(cache, fileInfo));
			context.AddCommand(new InfoCommand(cache));
			context.AddCommand(new InsertCommand(cache, fileInfo));
			context.AddCommand(new ListCommand(cache));
			context.AddCommand(new MapCommand());
			context.AddCommand(new EditCommand(stack, cache, fileInfo, stringIds));
			context.AddCommand(new DuplicateTagCommand(cache, fileInfo));
			context.AddCommand(new AddressCommand());
			context.AddCommand(new ExtractBitmapsCommand(cache, fileInfo));
			context.AddCommand(new ResourceDataCommand());
            context.AddCommand(new CompareCommand(cache, fileInfo));
			if (stringIds != null)
			{
				context.AddCommand(new StringIdCommand(stringIds));
				context.AddCommand(new ListStringsCommand(cache, fileInfo, stringIds));
				context.AddCommand(new GenerateLayoutsCommand(cache, fileInfo, stringIds));
			}
			return context;
		}
 public static Tag ParseTagClass(TagCache cache, string className)
 {
     if (className.Length == 4)
         return new Tag(className);
     Console.WriteLine("Invalid tag class: {0}", className);
     return new Tag(-1);
 }
示例#10
0
        public static Vector3[] GetVectors(string[] Tags)
        {
            if (Tags != null)
            {
                int       oldLen  = 0;
                Vector3[] targets = null;
                foreach (string tag in Tags)
                {
                    Vector3[] tempTargets = TagCache.GetVector3sByTag(tag);

                    if (targets == null)
                    {
                        targets = new Vector3[tempTargets.Length];
                    }
                    else
                    {
                        oldLen = targets.Length;
                        Array.Resize(ref targets, targets.Length + tempTargets.Length);
                    }

                    // Copy new elements into the start of the space added by Array.Resize, or the start of the array if its empty
                    Array.Copy(tempTargets, 0, targets, oldLen, tempTargets.Length);
                }

                return(targets);
            }
            return(new Vector3[0]);
        }
示例#11
0
        /// <summary>
        ///  Update interface when label changes
        /// </summary>
        /// <param name="file"></param>
        /// <param name="op"></param>
        void _TagCache_CacheUpdated(CacheUpdatedArgs e)
        {
            // 删除结点
            TreeNode root = tvClassView.Nodes[e.ProjectIndex];

            /*
             * ClassViewIndex index = root.Tag as ClassViewIndex;
             * if (index.FileName2TreeNode_Index.ContainsKey(e.File))
             * {
             *  List<TreeNode> nodeList = index.FileName2TreeNode_Index[e.File];
             *  nodeList.Reverse();
             *  foreach (TreeNode node in nodeList)
             *  {
             *      ITag tag = node.Tag as ITag;
             *      index.TagFullName2TreeNode_Index.Remove(tag.FullName);
             *  }
             *  index.FileName2TreeNode_Index.Remove(e.File);
             *  foreach (TreeNode node in nodeList)
             *  {
             *      if (node.Nodes.Count == 0)  // 没有子结点的情况下才删除。像命名空间往往有很多子结点
             *          node.Remove();  // throw new exception?
             *  }
             * }*/
            // 如果是Update操作,添加结点
            if (e.Operator == Operator.Update)
            {
                _InsertTags(root, TagCache.GetTags(e.File));
            }
        }
 /// <summary>
 /// Creates a tag serialization context which serializes data into a tag.
 /// </summary>
 /// <param name="stream">The stream to write to.</param>
 /// <param name="cache">The cache file to write to.</param>
 /// <param name="stringIds">The stringID source to use.</param>
 /// <param name="tag">The tag to overwrite.</param>
 public TagSerializationContext(Stream stream, TagCache cache, StringIdCache stringIds, TagInstance tag)
 {
     _stream = stream;
     _cache = cache;
     _stringIds = stringIds;
     Tag = tag;
 }
示例#13
0
        public void TestTagCacheAPIs()
        {
            TagCache tagCache = new TagCache();

            tagCache.Set("key", 1);
            tagCache.Set("key", 1, TagCache.LOWEST_PRIORITY);
            tagCache.Set("key", 1, DateTime.UtcNow.AddSeconds(10));
            tagCache.Set("key", 1, DateTime.UtcNow.AddSeconds(10), TagCache.LOWEST_PRIORITY);
            tagCache.Set("key", 1, TimeSpan.FromSeconds(10));
            tagCache.Set("key", 1, TimeSpan.FromSeconds(10), TagCache.LOWEST_PRIORITY);
            tagCache.Set("key", 1, new List<string> { "tag1", "tag2" });
            tagCache.Set("key", 1, new List<string> { "tag1", "tag2" }, TagCache.LOWEST_PRIORITY);
            tagCache.Set("key", 1, new List<string> { "tag1", "tag2" }, DateTime.UtcNow.AddSeconds(10));
            tagCache.Set("key", 1, new List<string> { "tag1", "tag2" }, DateTime.UtcNow.AddSeconds(10), TagCache.LOWEST_PRIORITY);
            tagCache.Set("key", 1, new List<string> { "tag1", "tag2" }, TimeSpan.FromSeconds(10));
            tagCache.Set("key", 1, new List<string> { "tag1", "tag2" }, TimeSpan.FromSeconds(10), TagCache.LOWEST_PRIORITY);

            Assert.AreEqual(tagCache.Get("key"), 1);
            tagCache.Remove("key");
            Assert.AreEqual(tagCache.Get("key"), null);

            tagCache.Set("key", 1, new List<string> { "tag1", "tag2" });
            Assert.AreEqual(tagCache.Get("key"), 1);
            tagCache.Invalidate(new List<List<string>> { new List<string> { "tag1" } });
            Assert.AreEqual(tagCache.Get("key"), null);
        }
示例#14
0
 public TagAnalyzer(TagCache cache)
 {
     _cache = cache;
     foreach (var group in cache.Index.NonNull().Select(t => t.Group.Tag).Distinct())
     {
         _tagGroups.Add(group);
     }
 }
示例#15
0
 public TagAnalyzer(TagCache cache, HaloTag tag)
 {
     _cache = cache;
     _tag = tag;
     _tagMap = BuildTagMap(tag);
     _dataFixupsByWriteOffset = _tag.DataFixups.ToDictionary(f => f.WriteOffset);
     _resourceFixupsByWriteOffset = _tag.ResourceFixups.ToDictionary(f => f.WriteOffset);
 }
 public TagAnalyzer(TagCache cache, HaloTag tag)
 {
     _cache  = cache;
     _tag    = tag;
     _tagMap = BuildTagMap(tag);
     _dataFixupsByWriteOffset     = _tag.DataFixups.ToDictionary(f => f.WriteOffset);
     _resourceFixupsByWriteOffset = _tag.ResourceFixups.ToDictionary(f => f.WriteOffset);
 }
示例#17
0
 public static MagicNumber ParseTagClass(TagCache cache, string className)
 {
     if (className.Length == 4)
     {
         return(new MagicNumber(className));
     }
     Console.Error.WriteLine("Invalid tag class: {0}", className);
     return(new MagicNumber(-1));
 }
示例#18
0
 public static Tag ParseTagClass(TagCache cache, string className)
 {
     if (className.Length == 4)
     {
         return(new Tag(className));
     }
     Console.WriteLine("Invalid tag class: {0}", className);
     return(new Tag(-1));
 }
 public TagAnalyzer(TagCache cache, TagInstance tag)
 {
     _cache = cache;
     _tag = tag;
     _tagMap = BuildTagMap(tag);
     _dataFixupsByWriteOffset = _tag.DataFixups.ToDictionary(f => f.WriteOffset);
     _resourceFixupsByWriteOffset = _tag.ResourceFixups.ToDictionary(f => f.WriteOffset);
     foreach (var group in cache.Tags.NonNull().Select(t => t.GroupTag).Distinct())
         _tagGroups.Add(group);
 }
 public static CommandContext Create(CommandContext parent, FileInfo fileInfo, TagCache cache, HaloTag tag, VFilesList vfsl)
 {
     var context = new CommandContext(parent, string.Format("{0:X8}.vfsl", tag.Index));
     context.AddCommand(new VfslListCommand(vfsl));
     context.AddCommand(new VfslExtractCommand(vfsl));
     context.AddCommand(new VfslExtractAllCommand(vfsl));
     context.AddCommand(new VfslImportCommand(fileInfo, cache, tag, vfsl));
     context.AddCommand(new VfslImportAllCommand(fileInfo, cache, tag, vfsl));
     return context;
 }
示例#21
0
 /// <summary>
 /// 加载标签视图
 /// </summary>
 void _LoadClassView()
 {
     foreach (Project project in ProjectManager.Projects)
     {
         List <ITag> tags = TagCache.GetTags(project.Root.SubFiles2.ToArray());
         TreeNode    node = new TreeNode(project.Root.Name, Resource.ClassViewIcon_Project, Resource.ClassViewIcon_Project);
         tvClassView.Nodes.Add(node);
         _Bind(node, tags);
     }
 }
示例#22
0
        void _UpdateView(String File)
        {
            m_CurrFile = File;
            if (tvClassView.Nodes.Count == 0)
            {
                return;
            }
            TreeNode root = tvClassView.Nodes[0]; //TODO

            _InsertTags(root, TagCache.GetTags(File));
        }
        public static CommandContext Create(CommandContext parent, FileInfo fileInfo, TagCache cache, HaloTag tag,
			MultilingualUnicodeStringList unic, StringIdCache stringIds)
        {
            var context = new CommandContext(parent, string.Format("{0:X8}.unic", tag.Index));
            if (stringIds != null)
            {
                context.AddCommand(new UnicListCommand(unic, stringIds));
                context.AddCommand(new UnicSetCommand(fileInfo, cache, tag, unic, stringIds));
            }
            return context;
        }
示例#24
0
        public void GetGameObjectsTest()
        {
            Assert.AreEqual(2, TagCache.GetGameObjectsByTag("Test").Length);

            GameObject[] ga = TagCache.GetGameObjectsByTag("Test");
            Assert.AreEqual(true, ga.Contains(testObjectA));
            Assert.AreEqual(true, ga.Contains(testObjectB));
            Assert.AreEqual(false, ga.Contains(testObjectC));

            Assert.AreSame(testObjectC, TagCache.GetGameObjectsByTag("Dummy")[0]);
        }
示例#25
0
        public void GetVector3sTest()
        {
            Assert.AreEqual(2, TagCache.GetVector3sByTag("Test").Length);

            Vector3[] ga = TagCache.GetVector3sByTag("Test");
            Assert.AreEqual(true, ga.Contains(testObjectA.transform.position));
            Assert.AreEqual(true, ga.Contains(testObjectB.transform.position));
            Assert.AreEqual(false, ga.Contains(testObjectC.transform.position));

            Assert.AreEqual(testObjectC.transform.position, TagCache.GetVector3sByTag("Dummy")[0]);
        }
示例#26
0
        public TagEntryViewModel(TagCache tag, TagPropertyEditorViewModel parent, bool isChecked)
        {
            if (parent == null) throw new ArgumentNullException("parent");
            if (tag == null) throw new ArgumentNullException("tag");

            _parent = parent;
            _isChecked = isChecked;
            _text = tag.Name;

            this.Tag = tag;
            this.CurrentlyAdded = tag.ObjectState == DataObjectState.New;
        }
示例#27
0
 public static TagInstance ParseTagIndex(TagCache cache, string arg)
 {
     int tagIndex;
     if (!int.TryParse(arg, NumberStyles.HexNumber, null, out tagIndex))
         return null;
     if (!cache.Tags.Contains(tagIndex))
     {
         Console.WriteLine("Unable to find tag {0:X8}.", tagIndex);
         return null;
     }
     return cache.Tags[tagIndex];
 }
示例#28
0
        public InfoCommand(TagCache cache) : base(
                CommandFlags.Inherit,

                "info",
                "Get information about a tag",

                "info <tag index>",

                "Displays detailed information about a tag.")
        {
            _cache = cache;
        }
示例#29
0
        public InfoCommand(OpenTagCache info) : base(
            CommandFlags.Inherit,

            "info",
            "Get information about a tag",

            "info <tag index>",

            "Displays detailed information about a tag.")
        {
            _cache = info.Cache;
        }
示例#30
0
        internal static void GotoDefinition()
        {
            if (FrmMain == null)
            {
                ShowNppPIALexer2View();
            }

            string      tagName = NPP.GetCurrentWord2();
            List <ITag> lst     = TagCache.SearchTag(tagName, TagParser.GetDefaultLang(NPP.GetCurrentFile()));

            if (lst.Count == 0)
            {
                return;
            }

            if (lst.Count == 1)
            {
                Jump.Add(tagName, lst[0].SourceFile, lst[0].LineNo - 1);
                //NPP.GoToDefinition(lst[0].SourceFile, lst[0].LineNo - 1, lst[0].TagName);
                Jump.Cursor.Go();
            }
            else
            {
                if (_ctntGoToDefinition == null)
                {
                    _ctntGoToDefinition = new ContextMenuStrip();
                }

                Point pos = NPP.GetCurrentPoint();
                _ctntGoToDefinition.Items.Clear();
                foreach (ITag tag in lst)
                {
                    string            txt  = string.Format("{0}    [{1}] {2}", tag.FullName, tag.LineNo, tag.SourceFile);
                    ToolStripMenuItem item = new ToolStripMenuItem(txt);
                    item.Tag         = tag;
                    item.ToolTipText = tag.Signature;
                    _ctntGoToDefinition.Items.Add(item);
                    item.Click += new EventHandler(delegate(object src, EventArgs ex)
                    {
                        ToolStripMenuItem i = src as ToolStripMenuItem;
                        if (i != null)
                        {
                            var t = item.Tag as ITag;
                            Jump.Add(t.TagName, t.SourceFile, t.LineNo - 1);
                            Jump.Cursor.Go();
                            //NPP.GoToDefinition(t.SourceFile, t.LineNo - 1, t.TagName);
                        }
                    });
                }
                _ctntGoToDefinition.Show(pos);
            }
        }
示例#31
0
        public void DeregisterTest()
        {
            Assert.AreEqual(true, TagCache.GetGameObjectsByTag("Test").Contains(testObjectA));
            Assert.AreEqual(true, TagCache.GetGameObjectsByTag("Test").Contains(testObjectB));
            Assert.AreEqual(2, TagCache.GetGameObjectsByTag("Test").Length);

            TagCache.DeRegister(testObjectA);
            TagCache.DeRegister(testObjectB);

            Assert.AreEqual(new GameObject[] { }, TagCache.GetGameObjectsByTag("Test"));
            Assert.AreEqual(true, TagCache.GetGameObjectsByTag("Dummy").Contains(testObjectC));
            Assert.AreEqual(1, TagCache.GetGameObjectsByTag("Dummy").Length);
        }
示例#32
0
        public ExtractCommand(OpenTagCache info) : base(
                CommandFlags.Inherit,

                "extract",
                "Extract a tag to a file",

                "extract <tag index> <filename>",

                "Use the \"import\" command to re-import an extracted tag.")
        {
            _cache    = info.Cache;
            _fileInfo = info.CacheFile;
        }
示例#33
0
        public ExtractCommand(OpenTagCache info) : base(
            CommandFlags.Inherit,

            "extract",
            "Extract a tag to a file",
            
            "extract <tag index> <filename>",
            
            "Use the \"import\" command to re-import an extracted tag.")
        {
            _cache = info.Cache;
            _fileInfo = info.CacheFile;
        }
        public JiraIssueActionsSmartTagger(ITextView view, IClassifier classifier)
        {
            this.view       = view;
            this.classifier = classifier;

            tagCache = new TagCache(view.TextBuffer, classifier, "PlvsJiraIssueActionsSmartTaggerTagCache");

            this.view.LayoutChanged    += layoutChanged;
            view.Caret.PositionChanged += caretPositionChanged;
            AtlassianPanel.Instance.Jira.SelectedServerChanged += jiraSelectedServerChanged;
            GlobalSettings.SettingsChanged += globalSettingsChanged;
            view.TextBuffer.Changed        += textBufferChanged;
        }
示例#35
0
        public DuplicateTagCommand(TagCache cache, FileInfo fileInfo) : base(
                CommandFlags.None,

                "duplicate",
                "Create a copy of a tag",

                "duplicate <tag index>",

                "All of the tag's data, including tag blocks, will be copied into a new tag.\n" +
                "The new tag can then be edited independently of the old tag.")
        {
            _cache    = cache;
            _fileInfo = fileInfo;
        }
        public ExtractBitmapsCommand(TagCache cache, FileInfo fileInfo) : base(
                CommandFlags.Inherit,

                "extractbitmaps",
                "Extract all bitmaps to a folder",

                "extractbitmaps <folder>",

                "Extract all bitmap tags and any subimages to the given folder.\n" +
                "If the folder does not exist, it will be created.")
        {
            _cache    = cache;
            _fileInfo = fileInfo;
        }
示例#37
0
        public ImportCommand(OpenTagCache info) : base(
                CommandFlags.None,

                "import",
                "Import a tag from a file",

                "import <tag index> <filename>",

                "The data must have been previously extracted with the \"extract\" command.\n" +
                "If the data is too large, the tag will be expanded as necessary.\n")
        {
            _cache    = info.Cache;
            _fileInfo = info.CacheFile;
        }
        public DuplicateTagCommand(TagCache cache, FileInfo fileInfo)
            : base(CommandFlags.None,

			"duplicate",
			"Create a copy of a tag",

			"duplicate <tag index>",

			"All of the tag's data, including tag blocks, will be copied into a new tag.\n" +
			"The new tag can then be edited independently of the old tag.")
        {
            _cache = cache;
            _fileInfo = fileInfo;
        }
示例#39
0
        public void GetTags_BackgroundAndTracking()
        {
            Create("cat", "dog", "bear", "pig");
            var backgroundData = CreateBackgroundCacheData(_textBuffer.GetLine(0).Extent, _textBuffer.GetLineSpan(0, 1));
            var trackingData   = CreateTrackingCacheData(_textBuffer.GetLine(1).Extent, _textBuffer.GetLineSpan(1, 1));

            _asyncTagger.TagCache = TagCache <TextMarkerTag> .NewTrackingAndBackgroundCache(
                trackingData,
                backgroundData);

            var tags = _asyncTagger.GetTags(_textBuffer.GetLineRange(0, 2).ExtentIncludingLineBreak);

            Assert.AreEqual(2, tags.Count());
        }
示例#40
0
        public ImportCommand(OpenTagCache info) : base(
            CommandFlags.None,

            "import",
            "Import a tag from a file",
            
            "import <tag index> <filename>",
            
            "The data must have been previously extracted with the \"extract\" command.\n" +
            "If the data is too large, the tag will be expanded as necessary.\n")
        {
            _cache = info.Cache;
            _fileInfo = info.CacheFile;
        }
        public ExtractBitmapsCommand(TagCache cache, FileInfo fileInfo)
            : base(CommandFlags.Inherit,

			"extractbitmaps",
			"Extract all bitmaps to a folder",

			"extractbitmaps <folder>",

			"Extract all bitmap tags and any subimages to the given folder.\n" +
			"If the folder does not exist, it will be created.")
        {
            _cache = cache;
            _fileInfo = fileInfo;
        }
示例#42
0
        public VfslImportCommand(FileInfo fileInfo, TagCache cache, HaloTag tag, VFilesList list)
            : base(CommandFlags.None,
			
			"import",
			"Replace a file stored in the tag",

			"import <virtual path> [filename]",
			
			"Replaces a file stored in the tag. The tag will be resized as necessary.")
        {
            _fileInfo = fileInfo;
            _cache = cache;
            _tag = tag;
            _list = list;
        }
        public ListCommand(OpenTagCache info)
            : base(CommandFlags.Inherit,

            "list",
            "List tags",
            
            "list [class...]",
            
            "class is a 4-character string identifying the tag class, e.g. \"proj\".\n" +
            "Multiple classes to list tags from can be specified.\n" +
            "Tags which inherit from the given classes will also be printed.\n" +
            "If no class is specified, all tags in the file will be listed.")
        {
            _cache = info.Cache;
        }
示例#44
0
        public ListCommand(OpenTagCache info) : base(
                CommandFlags.Inherit,

                "list",
                "List tags",

                "list [class...]",

                "class is a 4-character string identifying the tag class, e.g. \"proj\".\n" +
                "Multiple classes to list tags from can be specified.\n" +
                "Tags which inherit from the given classes will also be printed.\n" +
                "If no class is specified, all tags in the file will be listed.")
        {
            _cache = info.Cache;
        }
示例#45
0
        public ImportResourceCommand(OpenTagCache info) : base(
                CommandFlags.Inherit,

                "importresource",
                "Import as a new resource for a specified tag.",

                "importresource <cache file> <tag> <input file>\n",

                "For bitm, it only works with permutations. The path must end with a folder, and not a file.\n")
        {
            _info      = info;
            _cache     = info.Cache;
            _fileInfo  = info.CacheFile;
            _stringIds = info.StringIDs;
        }
示例#46
0
        public static TagInstance ParseTagIndex(TagCache cache, string arg)
        {
            int tagIndex;

            if (!int.TryParse(arg, NumberStyles.HexNumber, null, out tagIndex))
            {
                return(null);
            }
            if (!cache.Tags.Contains(tagIndex))
            {
                Console.WriteLine("Unable to find tag {0:X8}.", tagIndex);
                return(null);
            }
            return(cache.Tags[tagIndex]);
        }
示例#47
0
        public VfslImportCommand(FileInfo fileInfo, TagCache cache, HaloTag tag, VFilesList list) : base(
                CommandFlags.None,

                "import",
                "Replace a file stored in the tag",

                "import <virtual path> [filename]",

                "Replaces a file stored in the tag. The tag will be resized as necessary.")
        {
            _fileInfo = fileInfo;
            _cache    = cache;
            _tag      = tag;
            _list     = list;
        }
示例#48
0
        /// <summary>
        /// Called when the IAsyncTaggerSource raises a Changed event.  Clear out the
        /// cache, pass on the event to the ITagger and wait for the next request
        /// </summary>
        private void OnAsyncTaggerSourceChanged(object sender, EventArgs e)
        {
            // Clear out the cache.  It's no longer valid.
            _tagCache = TagCache.Empty;
            CancelAsyncBackgroundRequest();

            // Now if we've previously had a SnapshotSpan requested via GetTags go ahead
            // and tell the consumers that it's changed.  Use the entire cached request
            // span here.  We're pessimistic when we have a Changed call because we have
            // no information on what could've changed
            if (_cachedOverarchingRequestSpan.HasValue)
            {
                RaiseTagsChanged(_cachedOverarchingRequestSpan.Value);
            }
        }
示例#49
0
        public ExtractCommand(TagCache cache, FileInfo fileInfo)
            : base(CommandFlags.Inherit,

			"extract",
			"Extract a tag to a file",
			
			"extract <tag index> <filename> [full]",
			
			"Use the \"import\" command to re-import the tag's data.\n" +
			"\n" +
			"If the \"full\" option is specified, the tag's header will be included.\n" +
			"To import a full tag, you must pass \"full\" when you re-import the tag.")
        {
            _cache = cache;
            _fileInfo = fileInfo;
        }
        public GenerateLayoutsCommand(OpenTagCache info)
            : base(CommandFlags.Inherit,

			"genlayouts",
			"Generate tag layouts",

			"genlayouts <type> <output dir>",

			"Scans all tags in the file to guess tag layouts.\n" +
			"Layouts will be written to the output directory in the chosen format.\n" +
			"\n" +
			"Supported types: csharp, cpp")
        {
            _cache = info.Cache;
            _info = info;
        }
        public ConvertPluginsCommand(OpenTagCache info)
            : base(CommandFlags.Inherit,

            "convertplugins",
            "Convert Assembly plugins to tag layout structures",

            "convertplugins <input dir> <output type> <output dir>",

            "Only plugins for groups that are actually used in the tag cache will be converted.\n" +
            "Layouts will be written to the output directory in the chosen format.\n" +
            "\n" +
            "Supported output types: csharp, cpp")
        {
            _cache = info.Cache;
            _info = info;
        }
        public ModelTestCommand(OpenTagCache info)
            : base(CommandFlags.Inherit,

            "modeltest",
            "Model injection test",

            "modeltest <model file>",

            "Injects the model over the traffic cone.\n" +
            "The model must only have a single material and no nodes.")
        {
            _info = info;
            _cache = info.Cache;
            _fileInfo = info.CacheFile;
            _stringIds = info.StringIds;
        }
示例#53
0
        public ImportCommand(TagCache cache, FileInfo fileInfo)
            : base(CommandFlags.None,

			"import",
			"Import a tag from a file",
			
			"import <tag index> <filename> [full]",
			
			"The data must have been previously extracted with the \"extract\" command.\n" +
			"If the data is too large, the tag will be expanded as necessary.\n" +
			"\n" +
			"If the tag was extracted using the \"full\" option, you must supply it here too.")
        {
            _cache = cache;
            _fileInfo = fileInfo;
        }
        public VfslImportAllCommand(FileInfo fileInfo, TagCache cache, HaloTag tag, VFilesList list)
            : base(CommandFlags.None,
			
			"importall",
			"Replace all files stored in the tag",

			"importall [directory]",
			
			"Replaces all file stored in the tag. The tag will be resized as necessary.\n" +
			"If no directory is specified, files will be loaded from the current directory.")
        {
            _fileInfo = fileInfo;
            _cache = cache;
            _tag = tag;
            _list = list;
        }
示例#55
0
        public BitmImportCommand(FileInfo fileInfo, TagCache cache, HaloTag tag, Bitmap bitmap)
            : base(CommandFlags.None,

			"import",
			"Import an image from a DDS file",

			"import <image index> <path>",

			"The image index must be in hexadecimal.\n" +
			"No conversion will be done on the data in the DDS file.\n" +
			"The pixel format must be supported by the game.")
        {
            _fileInfo = fileInfo;
            _cache = cache;
            _tag = tag;
            _bitmap = bitmap;
        }
        public GenerateLayoutsCommand(TagCache cache, FileInfo fileInfo, StringIdCache stringIds)
            : base(CommandFlags.Inherit,

			"genlayouts",
			"Generate tag layouts",

			"genlayouts <type> <output dir>",

			"Scans all tags in the file to guess tag layouts.\n" +
			"Layouts will be written to the output directory in the chosen format.\n" +
			"\n" +
			"Supported types: csharp, cpp")
        {
            _cache = cache;
            _fileInfo = fileInfo;
            _stringIds = stringIds;
        }
示例#57
0
        public UnicSetCommand(FileInfo fileInfo, TagCache cache, HaloTag tag, MultilingualUnicodeStringList unic, StringIdCache stringIds)
            : base(CommandFlags.None,

			"set",
			"Set the value of a string",

			"set <language> <stringid> <value>",

			"Sets the string associated with a stringID in a language.\n" +
			"Remember to put the string value in quotes if it contains spaces.\n" +
			"If the string does not exist, it will be added.")
        {
            _fileInfo = fileInfo;
            _cache = cache;
            _tag = tag;
            _unic = unic;
            _stringIds = stringIds;
        }
示例#58
0
        public EditCommand(CommandContextStack stack, OpenTagCache info)
            : base(CommandFlags.None,

			"edit",
			"Edit tag-specific data",

			"edit <tag index>",

			"If the tag contains data which is supported by this program,\n" +
			"this command will make special tag-specific commands available\n" +
			"which can be used to edit or view the data in the tag.\n" +
			"\n" +
			"Currently-supported tag types: bitm, hlmt, unic, vfsl")
        {
            _stack = stack;
            _cache = info.Cache;
            _info = info;
        }
        public HlmtExtractModeCommand(TagCache cache, FileInfo fileInfo, Model model, StringIdCache stringIds)
            : base(CommandFlags.Inherit,

			"extractmode",
			"Extract the render model",

			"extractmode <variant> <filetype> <filename>",

			"Extracts a variant of the render model to a file.\n" +
			"Use the \"listvariants\" command to list available variants.\n" +
			"If the model does not have any variants, just use \"default\"." +
			"\n" +
			"Supported file types: obj")
        {
            _cache = cache;
            _fileInfo = fileInfo;
            _model = model;
            _stringIds = stringIds;
        }
示例#60
0
        /// <summary>
        /// Returns a combination of the hash codes of all the unique tag elements in this tag.
        /// </summary>
        /// <returns>The hash code combination, can be used to identify the tag.</returns>
        public ulong GetHash(TagCache cache, System.IO.FileInfo fileInfo)
        {
            ulong returnVal = 0;

            var properties = this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            foreach (var property in properties)
            {
                // Get the property's TagValueAttribute
                var valueInfo = property.GetCustomAttributes(typeof(TagElementAttribute), false).FirstOrDefault() as TagElementAttribute;
                if (valueInfo == null || (valueInfo.Flags & TagElementFlags.Unique) != TagElementFlags.Unique)
                    continue; // Ignore the property

                ulong valueHash = 0;
                var value = property.GetValue(this);
                if (value is HaloTag) // if the HaloTag reference is marked as unique we'll add the hash of the ref'd tag too
                {
                    var tag = (value as HaloTag).Deserialize(cache, fileInfo);
                    valueHash = tag.GetHash(cache, fileInfo);
                }
                else
                    valueHash = (ulong)value.GetHashCode();

                returnVal += valueHash;
            }

            // add class ID to the hash
            if(returnVal != 0)
            {
                var structType = this.GetType();
                var structAttrib = structType.GetCustomAttributes(typeof(TagStructureAttribute), false).FirstOrDefault() as TagStructureAttribute;
                if (structAttrib == null)
                    throw new InvalidOperationException("Structure type must have TagStructureAttribute");
                var classVals = structAttrib.Class.ToCharArray();
                for(int i = 0; i < 4; i++)
                {
                    if(i >= classVals.Length)
                        break;
                    returnVal += (ulong)(classVals[i] << (i * 8));
                }
            }

            return returnVal;
        }