public WeatherDefinition(TagDefinition TagDef, EndianReader br) : base(TagDef) { // Add New Stream base.AddStream("WeatherRaw"); // Weather for (int i = 0; i < ((TagBlock)base.Owner[0]).BlockCount; i++) { // Get Values int Offset = (int)((TagBlock)base.Owner[0])[i][15].GetValue(); int Size = (int)((TagBlock)base.Owner[0])[i][16].GetValue(); // Double Check if ((Offset & 0xC0000000) == 0 && (Offset & 0x3FFFFFFF) > 0 && Size > 0) { // Write new Offset Offset &= 0x3FFFFFFF; ((TagBlock)base.Owner[0])[i][15].SetValue((int)base["WeatherRaw"].Length); // Write Raw br.BaseStream.Position = Offset; byte[] Buffer = br.ReadBytes(Size); base["WeatherRaw"].Write(Buffer, 0, Buffer.Length); // Write Padding int Padding = 512 - ((int)base["WeatherRaw"].Length % 512); if (Padding != 512) { base["WeatherRaw"].Write(new byte[Padding], 0, Padding); } } } }
/// <summary> /// Unsubscribes from a tag. /// </summary> /// <param name="tag">The tag.</param> private void UnsubscribeTag(TagDefinition tag) { _subscribedTags.TryRemove(tag.Id, out var _); if (_subscriptions.TryRemove(tag.Id, out var subscription)) { subscription.Dispose(); } }
protected override Task <TagDefinition> UpdateTag(ClaimsPrincipal identity, TagDefinition tag, TagSettings update, string description, CancellationToken cancellationToken) { if (!_tags.ContainsKey(tag.Id)) { throw new ArgumentException("Tag is not registered.", nameof(tag)); } return(base.UpdateTag(identity, tag, update, description, cancellationToken)); }
/// <summary> /// Updates a tag. /// </summary> /// <param name="identity">The identity of the caller.</param> /// <param name="tag">The tag to update.</param> /// <param name="update">The updated tag definition.</param> /// <param name="description">A description of the change.</param> /// <param name="cancellationToken">The cancellation token for the request.</param> /// <returns> /// The updated tag definition. /// </returns> async Task <TagDefinition> IHistorian.UpdateTag(ClaimsPrincipal identity, TagDefinition tag, TagSettings update, string description, CancellationToken cancellationToken) { ThrowIfDisposed(); if (tag.Historian != this) { throw new ArgumentException(Resources.Error_CannotOperateOnTagsOwnedByAnotherHistorian, nameof(tag)); } return(await UpdateTag(identity, tag, update, description, cancellationToken).ConfigureAwait(false)); }
/// <summary> /// Saves updated tag definitions to Redis. /// </summary> /// <param name="updated">The updated tag definition.</param> private static void TagUpdated(TagDefinition updated) { var redisTag = updated as RedisTagDefinition; if (redisTag == null) { return; } redisTag._historian.RunBackgroundTask(ct => redisTag.Save(ct)); }
private void DisplayTag(TagDefinition tag, string prefix = "", int width = 0) { string strippedTagKind = tag.Kind.ToString().Replace("TYPE_", ""); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(prefix); Console.Write("{0,1}", tag.Name, -width); Console.ResetColor(); Console.Write(": " + tag.Description + " (kind: " + strippedTagKind); Console.WriteLine(" | unit: " + tag.Unit + ")"); }
public bool Contains(TagDefinition def) { int num = TagDefinitions.Length; for (int i = 0; i < num; i++) { if (TagDefinitions[i].Tag == def.Tag) { return(true); } } return(false); }
private CachedTagInstance ConvertCachedTagInstance(ModPackageExtended modPack, CachedTagInstance modTag) { // Determine if tag requires conversion if (modPack.Tags.Index[modTag.Index] == null) { return(CacheContext.TagCache.Index[modTag.Index]); // references an HO tag } else { // tag has already been converted if (TagMapping.ContainsKey(modTag.Index)) { return(CacheContext.TagCache.Index[TagMapping[modTag.Index]]); // get the matching tag in the destination package } else { CachedTagInstance newTag; if (modTag.Index <= MagicNumber) { newTag = CacheContext.GetTag(modTag.Index); } else if (!CacheContext.TryGetTag($"{modTag.Name}.{modTag.Group}", out newTag)) { newTag = CacheContext.TagCache.AllocateTag(modTag.Group); newTag.Name = modTag.Name; } TagMapping.Add(modTag.Index, newTag.Index); var definitionType = TagDefinition.Find(modTag.Group.Tag); var tagDefinition = CacheContext.Deserialize(new ModPackageTagSerializationContext(modPack.TagsStream, CacheContext, modPack, modTag), definitionType); tagDefinition = ConvertData(modPack, tagDefinition); if (definitionType == typeof(ForgeGlobalsDefinition)) { tagDefinition = ConvertForgeGlobals((ForgeGlobalsDefinition)tagDefinition); } else if (definitionType == typeof(Scenario)) { tagDefinition = ConvertScenario(modPack, (Scenario)tagDefinition); } CacheContext.Serialize(CacheStream, newTag, tagDefinition); foreach (var resourcePointer in modTag.ResourcePointerOffsets) { newTag.AddResourceOffset(resourcePointer); } return(newTag); } } }
private TagDefinition[] BuildTagDefinitions() { List <TagDefinition> tags = new List <TagDefinition>(); foreach (TagBuilder builder in _tagBuilders) { TagDefinition td = new TagDefinition { Id = builder.Id, DisplayName = builder.DisplayName, Handler = BuildTagHandler(builder.TagHandler) }; tags.Add(td); } return(tags.ToArray()); }
public ITageService GetTagService(TagDefinition tagDefinition) { switch (tagDefinition.Handler.StepHandlerType) { case StepHandlerTypeEnum.IoC: return(new IocTagService(tagDefinition, _iocTagServiceProvider)); case StepHandlerTypeEnum.Script: return(new ScriptTagService(tagDefinition)); case StepHandlerTypeEnum.Service: case StepHandlerTypeEnum.None: return(new EmptyTagService(tagDefinition.Id, tagDefinition.DisplayName)); default: throw new ArgumentException($"Invalid or unsupported Step Handler type:{tagDefinition.Handler.StepHandlerType}"); } }
/// <summary> /// Updates a tag. /// </summary> /// <param name="identity">The identity of the caller.</param> /// <param name="tag">The tag to update.</param> /// <param name="update">The updated tag definition.</param> /// <param name="description">The change description</param> /// <param name="cancellationToken">The cancellation token for the request.</param> /// <returns> /// The updated tag definition. /// </returns> protected override Task <TagDefinition> UpdateTag(ClaimsPrincipal identity, TagDefinition tag, TagSettings update, string description, CancellationToken cancellationToken) { if (tag == null) { throw new ArgumentNullException(nameof(tag)); } if (update == null) { throw new ArgumentNullException(nameof(update)); } if (!_tags.ContainsKey(tag.Id)) { throw new ArgumentException(Resources.Error_InvalidTagId, nameof(tag)); } return(base.UpdateTag(identity, tag, update, description, cancellationToken)); }
private void ConvertMutationPlugins(object sender, DoWorkEventArgs e) { // Cast the sender object to a background worker. BackgroundWorker worker = sender as BackgroundWorker; // Update the status label. worker.ReportProgress(0, "Initializing..."); // Initialize the mutation plugin repository. HaloPlugins.Halo2Xbox h2xPlugins = new HaloPlugins.Halo2Xbox(); // Loop through all of the plugins and process each one. for (int i = 0; i < h2xPlugins.TagExtensions.Length; i++) { // Create an instance of the current plugin definition. TagDefinition definition = h2xPlugins.CreateInstance(h2xPlugins.TagExtensions[i]); } }
private void buttonX1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Halo 2 Tags (*.*)|*.*"; if (Global.Application.Instance.IsProjectOpen != false) { ofd.InitialDirectory = Global.Application.Instance.Project.TagFolder; } if (ofd.ShowDialog() == DialogResult.OK) { // Open tag EndianReader br = new EndianReader(IO.Endianness.Little, new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)); // Get Ext string ext = ofd.FileName.Substring(ofd.FileName.LastIndexOf(".") + 1); TagDefinition tagdef = EngineManager.Engines[Global.Application.Instance.Project.Engine].CreateInstance(ext); // Read tagdef.Read(br); // Close br.Close(); // See if tag belongs to this project if (!Global.Application.Instance.Project.Tags.Contains(tagdef.AbsolutePath)) { // Ask to add if (MessageBox.Show("Mutation has detected this tag does not belong to the opened project.\r\nWould you like to add it to the project?", "Add tag to project", MessageBoxButtons.YesNo) == DialogResult.Yes) { // Add MessageBox.Show("This feature has not yet been enabled in Mutation.\r\nPlease wait for a new build.", "Future feature"); return; } } else { Reference = tagdef.AbsolutePath; this.textEdit1.Text = Reference; textEdit1.ForeColor = Color.RoyalBlue; } } }
/// <summary> /// Creates a new <see cref="TagDefinitionDto"/> object from the specified <see cref="TagDefinition"/>. /// </summary> /// <param name="tagDefinition">The tag definition to copy from.</param> /// <exception cref="ArgumentNullException"><paramref name="tagDefinition"/> is <see langword="null"/>.</exception> internal static TagDefinitionDto ToTagDefinitionDto(this TagDefinition tagDefinition) { if (tagDefinition == null) { throw new ArgumentNullException(nameof(tagDefinition)); } return(new TagDefinitionDto() { Id = tagDefinition.Id, Name = tagDefinition.Name, Description = tagDefinition.Description, Units = tagDefinition.Units, DataType = tagDefinition.DataType.ToString(), StateSet = tagDefinition.DataType == TagDataType.State ? tagDefinition.StateSet : null }); }
private bool GetShader( Mutex mutex, Stream stream, CachedTagInstance instance, IEnumerable <int> shader_rmdfs_ids, out RenderMethod rm_shader_definition, out Type rm_shader_type, out TagSerializationContext rm_shader_context, out string rmdf_name ) { // get shader rm_shader_definition = null; rm_shader_type = null; rm_shader_context = null; rmdf_name = null; { stream.Position = 0; rm_shader_context = new TagSerializationContext(stream, CacheContext, instance); // if there is no dependency on the rmsh, early exit if (shader_rmdfs_ids != null && !rm_shader_context.Tag.Dependencies.Intersect(shader_rmdfs_ids).Any()) { mutex.ReleaseMutex(); return(true); } rm_shader_type = TagDefinition.Find(rm_shader_context.Tag.Group.Tag); rm_shader_definition = CacheContext.Deserializer.Deserialize(rm_shader_context, rm_shader_type) as RenderMethod; // double check to make sure this is the correct render method definition if (shader_rmdfs_ids != null && !shader_rmdfs_ids.Contains(rm_shader_definition.BaseRenderMethod.Index)) { mutex.ReleaseMutex(); return(true); } var rmdf_index = rm_shader_definition.BaseRenderMethod.Index; rmdf_name = CacheContext.GetTag(rmdf_index)?.Name ?? rmdf_index.ToString("X"); } return(false); }
public override object Execute(List <string> args) { if (args.Count != 1) { return(false); } var destDir = new DirectoryInfo(args[0]); if (!destDir.Exists) { destDir.Create(); } foreach (var entry in TagGroup.Instances) { if (entry.Key.Value == -1) { continue; } var tagGroupName = CacheContext.GetString(entry.Value.Name).ToSnakeCase(); var tagStructureInfo = TagStructure.GetTagStructureInfo(TagDefinition.Find(entry.Key), CacheContext.Version); foreach (var type in tagStructureInfo.Types.Reverse <Type>()) { var info = type.GetCustomAttributes <TagStructureAttribute>(false).Where(attr => CacheVersionDetection.IsBetween(CacheContext.Version, attr.MinVersion, attr.MaxVersion)).First(); if (info.Name == null) { Console.WriteLine($"WARNING: {type.FullName} has no tag structure name defined!"); continue; } ExportType(type, new FileInfo(Path.Combine(destDir.FullName, $"{info.Name}.hpp"))); } } return(true); }
public static bool TryParseGroupTag(GameCache cache, string name, out Tag result) { if (TagDefinition.TryFind(name, out var type)) { var attribute = TagStructure.GetTagStructureAttribute(type); result = new Tag(attribute.Tag); return(true); } foreach (var pair in TagGroup.Instances) { if (name == cache.StringTable.GetString(pair.Value.Name)) { result = pair.Value.Tag; return(true); } } result = Tag.Null; return(name == "none" || name == "null"); }
private void CopyTagNames(Stream cacheStream, CachedTagInstance edTag, CacheFile.IndexItem blamTag) { if (CopiedTags.ContainsKey(blamTag.GroupTag)) { foreach (var name in CopiedTags[blamTag.GroupTag]) { if (name == blamTag.Name) { return; } } } else { CopiedTags[blamTag.GroupTag] = new List <string>(); } CopiedTags[blamTag.GroupTag].Add(blamTag.Name); var edDef = CacheContext.Deserialize(cacheStream, edTag); var blamDef = BlamCache.Deserializer.Deserialize( new CacheSerializationContext(ref BlamCache, blamTag), TagDefinition.Find(blamTag.GroupTag)); var edInfo = TagStructure.GetTagStructureInfo(edDef.GetType(), CacheContext.Version); var blamInfo = TagStructure.GetTagStructureInfo(blamDef.GetType(), BlamCache.Version); var oldName = edTag.Name; edTag.Name = blamTag.Name; if (edTag.Name != oldName) { NewNameCount++; } CopyTagNames(cacheStream, edDef, edInfo, blamDef, blamInfo); }
//public TagEditorPage(string Class) //{ // //Suspend Layout // this.SuspendLayout(); // // Set Fields // saved = false; // // Load tagdef // plugin = EngineManager.Engines[Global.Application.Instance.Project.Engine].CreateInstance(Class); // // Create Panel // Panel panel = new Panel(); // panel.SuspendLayout(); // panel.Dock = DockStyle.Fill; // panel.AutoScroll = true; // panel.AutoSize = true; // panel.BackColor = Color.FromKnownColor(KnownColor.Control); // // Load into panel // LoadIntoPanel(); // // Update Tab // this.Text = "New_Tag." + plugin.CompiledClass + "*"; // panel.ResumeLayout(); // this.Controls.Add(panel); // //Resume // this.ResumeLayout(); //} public void Open(string Location) { // Open the tag this.path = Location; EndianReader br = new EndianReader(Endianness.Little, new FileStream(Location, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)); // Create tag def string Ext = Location.Substring(Location.LastIndexOf(".") + 1); plugin = EngineManager.Engines[Global.Application.Instance.Project.Engine].CreateInstance(Ext); // Read plugin.Read(br); // Close br.Close(); // Load into panel LoadIntoPanel(); // Set the tab name. this.Text = Location.Substring(Location.LastIndexOf("\\") + 1); }
public BitmapDefinition(TagDefinition TagDef, EndianReader br) : base(TagDef) { // Create a new stream base.AddStream("BitmapRaw"); // Bitmaps for (int i = 0; i < ((TagBlock)base.Owner[20]).BlockCount; i++) { // 3 LODS for (int x = 0; x < 3; x++) { // Get Values int Offset = (int)((TagBlock)base.Owner[20])[i][12 + x].GetValue(); int Size = (int)((TagBlock)base.Owner[20])[i][18 + x].GetValue(); // Double Check if ((Offset & 0xC0000000) == 0 && (Offset & 0x3FFFFFFF) > 0 && Size > 0) { // Write new Offset Offset &= 0x3FFFFFFF; ((TagBlock)base.Owner[20])[i][12 + x].SetValue((int)base["BitmapRaw"].Length); // Write Raw br.BaseStream.Position = Offset; byte[] Buffer = br.ReadBytes(Size); base["BitmapRaw"].Write(Buffer, 0, Buffer.Length); // Write Padding int Padding = 512 - ((int)base["BitmapRaw"].Length % 512); if (Padding != 512) { base["BitmapRaw"].Write(new byte[Padding], 0, Padding); } } } } }
public void GetRMDF_IDs(string template_name, out IEnumerable <int> shader_rmdfs_ids, out Type template_type) { template_type = null; shader_rmdfs_ids = null; IEnumerable <CachedTagInstance> shader_rmdfs = null; switch (template_name) { case "shader_templates": case "shader_template": template_type = typeof(Shader); //shader_rmdfs = CacheContext.TagNames.Where(item => item.Value == @"shaders\shader").Select(item => CacheContext.GetTag(item.Key)).ToList(); break; case "cortana_templates": case "cortana_template": template_type = typeof(ShaderCortana); //shader_rmdfs = CacheContext.TagNames.Where(item => item.Value == @"shaders\cortana").Select(item => CacheContext.GetTag(item.Key)).ToList(); break; case null: case "*": break; default: Console.WriteLine("Invalid template_type"); break; } if (shader_rmdfs != null) { shader_rmdfs = shader_rmdfs.Where(rmdf => TagDefinition.Find(rmdf.Group.Tag) == typeof(RenderMethodDefinition)); shader_rmdfs_ids = shader_rmdfs.Select(rmdf => rmdf.Index); shader_rmdfs_ids = new int[] { shader_rmdfs_ids.FirstOrDefault() }; } }
public object Deserialize(Stream stream, CachedTagGen2 instance) => Deserialize(new Gen2SerializationContext(stream, this, instance), TagDefinition.Find(instance.Group.Tag));
public override object Deserialize(Stream stream, CachedTag instance) => Deserialize(new Gen1SerializationContext(stream, this, (CachedTagGen1)instance), TagDefinition.Find(instance.Group.Tag));
public override object Execute(List <string> args) { if (args.Count < 1 || args.Count > 2) { return(false); } begin: var groupTagString = args[0]; if (groupTagString.Length > 4) { Console.WriteLine($"ERROR: Invalid group tag: {groupTagString}"); return(true); } if (!Cache.TryParseGroupTag(groupTagString, out var groupTag)) { var chars = new char[] { ' ', ' ', ' ', ' ' }; for (var i = 0; i < chars.Length; i++) { chars[i] = groupTagString[i]; } groupTag = new Tag(new string(chars)); } if (!TagGroup.Instances.ContainsKey(groupTag)) { Console.WriteLine($"ERROR: No tag group definition for group tag '{groupTag}'!"); Console.Write($"(BE CAREFUL WITH THIS!!!) Define '{groupTag}' tag group? [y/n]: "); var answer = Console.ReadLine().ToLower(); if (answer != "y" && answer != "yes") { return(true); } Console.WriteLine("Enter the tag group specification in the following format"); Console.WriteLine("<group tag> [parent group tag] [grandparent group tag] <group name>:"); Console.WriteLine(); Console.Write($"{groupTag} specification> "); answer = Console.ReadLine(); var groupArgs = ArgumentParser.ParseCommand(answer, out string redirect); switch (groupArgs.Count) { case 2: new TagGroup(new Tag(groupArgs[0]), Tag.Null, Tag.Null, Cache.StringTable.GetStringId(groupArgs[1])); break; case 3: new TagGroup(new Tag(groupArgs[0]), new Tag(groupArgs[1]), Tag.Null, Cache.StringTable.GetStringId(groupArgs[2])); break; case 4: new TagGroup(new Tag(groupArgs[0]), new Tag(groupArgs[1]), new Tag(groupArgs[2]), Cache.StringTable.GetStringId(groupArgs[3])); break; default: return(false); } goto begin; } CachedTag instance = null; TagGroup.Instances.TryGetValue(groupTag, out var tagGroup); using (var stream = Cache.OpenCacheReadWrite()) { if (args.Count == 2) { var tagIndex = -1; if (!Cache.TryGetCachedTag(args[1], out instance)) { if (args[1].StartsWith("0x")) { tagIndex = Convert.ToInt32(args[1], 16); } else { return(false); } } else { tagIndex = instance.Index; } while (tagIndex >= Cache.TagCache.Count) { Cache.TagCache.AllocateTag(TagGroup.None); } if (tagIndex < Cache.TagCache.Count) { if (Cache.TagCacheGenHO.Tags[tagIndex] != null) { var oldInstance = Cache.TagCacheGenHO.Tags[tagIndex]; Cache.TagCacheGenHO.Tags[tagIndex] = null; Cache.TagCacheGenHO.SetTagDataRaw(stream, oldInstance, new byte[] { }); } instance = Cache.TagCache.CreateCachedTag(tagIndex, TagGroup.Instances[groupTag]); Cache.TagCacheGenHO.Tags[tagIndex] = (CachedTagHaloOnline)instance; } } if (instance == null) { instance = Cache.TagCache.AllocateTag(TagGroup.Instances[groupTag]); } Cache.Serialize(stream, instance, Activator.CreateInstance(TagDefinition.Find(groupTag))); } var tagName = instance.Name ?? $"0x{instance.Index:X4}"; Console.WriteLine($"[Index: 0x{instance.Index:X4}] {tagName}.{Cache.StringTable.GetString(instance.Group.Name)}"); return(true); }
/// <summary> /// Gets whether the given tag's generator should be used for a secondary (or substitute) text block. /// </summary> /// <param name="definition">The tag to inspect.</param> /// <returns>True if the tag's generator should be used as a secondary generator.</returns> public override bool ShouldCreateSecondaryGroup(TagDefinition definition) { return(new string[] { "elif", "else" }.Contains(definition.Name)); }
/// <summary> /// Updates a tag. /// </summary> /// <param name="identity">The identity of the caller.</param> /// <param name="tag">The tag to update.</param> /// <param name="update">The updated tag definition.</param> /// <param name="description">A description of the change.</param> /// <param name="cancellationToken">The cancellation token for the request.</param> /// <returns> /// The updated tag definition. /// </returns> protected virtual Task <TagDefinition> UpdateTag(ClaimsPrincipal identity, TagDefinition tag, TagSettings update, string description, CancellationToken cancellationToken) { tag.Update(update, identity, description); return(Task.FromResult(tag)); }
/// <summary> /// IoC Service constructor /// </summary> public IocTagService(TagDefinition tagDef, Func <string, ITageService> iocTagServiceProvider) { _service = iocTagServiceProvider(tagDef.Handler.IocName); Name = _service.Name; DisplayName = _service.DisplayName; }
/// <summary> /// Constructor /// </summary> /// <param name="tagDefinition"></param> public ScriptTagService(TagDefinition tagDefinition) { Name = tagDefinition.Id; DisplayName = tagDefinition.DisplayName; _sc = new CsScriptRuntimeGeneric <string[]>(tagDefinition.Handler.Script); }
public override object Execute(List <string> args) { if (args.Count < 2) { return(false); } var outputPath = args[0]; // Load each file and do version detection var infos = new List <HaloOnlineCacheContext>(); foreach (var path in args.Skip(1)) { Console.WriteLine("Loading {0}...", path); // Load the cache file var cacheContext = new HaloOnlineCacheContext(new FileInfo(path).Directory); infos.Add(cacheContext); } var result = new TagVersionMap(); using (var baseStream = CacheContext.OpenTagCacheRead()) { // Get the scenario tags for this cache Console.WriteLine("Finding base scenario tags..."); var baseScenarios = FindScenarios(CacheContext, baseStream); var baseVersion = CacheContext.Version; var baseTagData = new Dictionary <int, object>(); foreach (var scenario in baseScenarios) { baseTagData[scenario.Tag.Index] = scenario.Data; } // Now compare with each of the other caches foreach (var info in infos) { using (var stream = info.OpenTagCacheRead()) { Console.WriteLine("Finding scenario tags in {0}...", info.TagCacheFile.FullName); // Get the scenario tags and connect them to the base tags var scenarios = FindScenarios(info, stream); var tagsToCompare = new Queue <QueuedTag>(); for (var i = 0; i < scenarios.Count; i++) { tagsToCompare.Enqueue(scenarios[i]); if (i < baseScenarios.Count) { result.Add(baseVersion, baseScenarios[i].Tag.Index, info.Version, scenarios[i].Tag.Index); } } // Process each tag in the queue, enqueuing all of its dependencies as well while (tagsToCompare.Count > 0) { // Get the tag and its data var tag = tagsToCompare.Dequeue(); TagPrinter.PrintTagShort(tag.Tag); var data = tag.Data; if (data == null) { // No data yet - deserialize it var context = new TagSerializationContext(stream, info, tag.Tag); var type = TagDefinition.Find(tag.Tag.Group.Tag); data = info.Deserializer.Deserialize(context, type); } // Now get the data for the base tag var baseTag = result.Translate(info.Version, tag.Tag.Index, baseVersion); if (baseTag == -1 || CacheContext.TagCache.Index[baseTag].Group.Tag != tag.Tag.Group.Tag) { continue; } if (!baseTagData.TryGetValue(baseTag, out object baseData)) { // No data yet - deserialize it var context = new TagSerializationContext(baseStream, CacheContext, CacheContext.TagCache.Index[baseTag]); var type = TagDefinition.Find(tag.Tag.Group.Tag); baseData = CacheContext.Deserializer.Deserialize(context, type); baseTagData[baseTag] = baseData; } // Compare the two blocks CompareBlocks(baseData, baseVersion, data, info.Version, result, tagsToCompare); } } } } // Write out the CSV Console.WriteLine("Writing results..."); using (var writer = new StreamWriter(File.Open(outputPath, FileMode.Create, FileAccess.Write))) result.WriteCsv(writer); Console.WriteLine("Done!"); return(true); }
public override object Execute(List <string> args) { if (args.Count != 2) { return(false); } var groupTagInput = args[0]; var blamTagName = args[1]; var groupTag = Tag.Null; if (TagDefinition.Exists(groupTagInput)) { groupTag = new Tag(groupTagInput); } else { foreach (var tagGroup in BlamCache.IndexItems.ClassList) { if (groupTagInput == BlamCache.Strings.GetItemByID(tagGroup.StringID)) { var chars = new char[4] { ' ', ' ', ' ', ' ' }; for (var i = 0; i < 4; i++) { chars[i] = tagGroup.ClassCode[i]; } groupTag = new Tag(new string(chars)); break; } } } CacheFile.IndexItem tag = null; foreach (var blamTag in BlamCache.IndexItems) { if ((blamTag.GroupTag == groupTag.ToString()) && (blamTagName == "*" || blamTag.Name == blamTagName)) { tag = blamTag; break; } } if (tag == null) { throw new Exception(); } var tagName = $"(0x{tag.ID:X8}) {tag.Name.Substring(tag.Name.LastIndexOf('\\') + 1)}"; var tagType = TagDefinition.Find(groupTag); var definition = (TagStructure)BlamCache.Deserializer.Deserialize(new CacheSerializationContext(ref BlamCache, tag), tagType); var structure = definition.GetTagStructureInfo(BlamCache.Version); var oldContext = ContextStack.Context; var commandContext = new CommandContext(ContextStack.Context, string.Format("{0}.{1}", tagName, groupTagInput)); commandContext.AddCommand(new ListFieldsCommand(BlamCache, structure, definition)); commandContext.AddCommand(new EditBlockCommand(ContextStack, BlamCache, tag, definition)); commandContext.AddCommand(new CopyBlockElementsCommand(ContextStack, BlamCache, tag, structure, definition)); commandContext.AddCommand(new Editing.ExitToCommand(ContextStack)); ContextStack.Push(commandContext); Console.WriteLine($"Tag {tagName}.{groupTagInput} has been opened for editing."); Console.WriteLine("New commands are now available. Enter \"help\" to view them."); Console.WriteLine("Use \"exit\" to return to {0}.", oldContext.Name); return(true); }