public static CommandContext Create(CommandContext parent, OpenTagCache info, HaloTag tag, Model model)
 {
     var context = new CommandContext(parent, string.Format("{0:X8}.hlmt", tag.Index));
     context.AddCommand(new HlmtListVariantsCommand(info, model));
     context.AddCommand(new HlmtExtractModeCommand(info, model));
     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 static void Populate(CommandContext context, OpenTagCache info, TagInstance tag)
        {
            RenderMethod renderMethod = null;

            using (var cacheStream = info.OpenCacheReadWrite())
            {
                var tagContext = new TagSerializationContext(cacheStream, info.Cache, info.StringIds, tag);

                switch (tag.Group.Tag.ToString())
                {
                    case "rm  ": // render_method
                        renderMethod = info.Deserializer.Deserialize<RenderMethod>(tagContext);
                        break;

                    case "rmsh": // shader
                        renderMethod = info.Deserializer.Deserialize<Shader>(tagContext);
                        break;

                    case "rmd ": // shader_decal
                        renderMethod = info.Deserializer.Deserialize<ShaderDecal>(tagContext);
                        break;

                    case "rmfl": // shader_foliage
                        renderMethod = info.Deserializer.Deserialize<ShaderFoliage>(tagContext);
                        break;

                    case "rmhg": // shader_halogram
                        renderMethod = info.Deserializer.Deserialize<ShaderHalogram>(tagContext);
                        break;

                    case "rmss": // shader_screen
                        renderMethod = info.Deserializer.Deserialize<ShaderScreen>(tagContext);
                        break;

                    case "rmtr": // shader_terrain
                        renderMethod = info.Deserializer.Deserialize<ShaderTerrain>(tagContext);
                        break;

                    case "rmw ": // shader_water
                        renderMethod = info.Deserializer.Deserialize<ShaderWater>(tagContext);
                        break;

                    case "rmzo": // shader_zonly
                        renderMethod = info.Deserializer.Deserialize<ShaderZonly>(tagContext);
                        break;

                    case "rmcs": // shader_custom
                        renderMethod = info.Deserializer.Deserialize<ShaderCustom>(tagContext);
                        break;

                    default:
                        throw new NotImplementedException();
                }
            }
            
            context.AddCommand(new ListArgumentsCommand(info, tag, renderMethod));
            context.AddCommand(new ListBitmapsCommand(info, tag, renderMethod));
            context.AddCommand(new SpecifyBitmapsCommand(info, tag, renderMethod));
        }
        public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, MultilingualUnicodeStringList unic)
        {
            if (info.StringIds == null)
                return;

            context.AddCommand(new ListCommand(info, unic));
            context.AddCommand(new SetCommand(info, tag, unic));
        }
 public static CommandContext Create(CommandContext parent, OpenTagCache info, CacheBase blamCache)
 {
     var context = new CommandContext(parent, blamCache.Build);
     context.AddCommand(new PortShaderCommand(info, blamCache));
     context.AddCommand(new PortModelCommand(info, blamCache));
     context.AddCommand(new ListBitmapsCommand(info, blamCache));
     return context;
 }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, VFilesList vfsl)
 {
     context.AddCommand(new ListCommand(vfsl));
     context.AddCommand(new ExtractCommand(vfsl));
     context.AddCommand(new ExtractAllCommand(vfsl));
     context.AddCommand(new ImportCommand(info, tag, vfsl));
     context.AddCommand(new ImportAllCommand(info, tag, vfsl));
 }
 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;
 }
 public static CommandContext Create(CommandContext parent, OpenTagCache info, HaloTag tag, MultilingualUnicodeStringList unic)
 {
     var context = new CommandContext(parent, string.Format("{0:X8}.unic", tag.Index));
     if (info.StringIds != null)
     {
         context.AddCommand(new UnicListCommand(info, unic));
         context.AddCommand(new UnicSetCommand(info, tag, unic));
     }
     return context;
 }
        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;
        }
 public static void Populate(CommandContext commandContext, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ScenarioLightmapBspData Lbsp)
 {
     commandContext.AddCommand(new DumpRenderGeometryCommand(cacheContext, Lbsp.Geometry, "Lightmap"));
 }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, Scenario scenario)
 {
     context.AddCommand(new CopyForgePaletteCommand(info, scenario));
 }
Example #12
0
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, ScenarioStructureBsp bsp)
 {
     context.AddCommand(new LoadResourcesCommand(info, tag, bsp));
 }
Example #13
0
 public static void Populate(CommandContext commandContext, GameCache cache, CachedTag tag, Bink bink)
 {
     commandContext.AddCommand(new ExtractBinkFileCommand(cache, tag, bink));
 }
Example #14
0
 public static void Populate(CommandContext context, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Scenario scenario)
 {
     context.AddCommand(new CopyForgePaletteCommand(cacheContext, scenario));
     context.AddCommand(new ExtractScriptsCommand(cacheContext, tag, scenario));
     context.AddCommand(new DumpScriptsCommand(cacheContext, scenario));
 }
Example #15
0
 public static void Populate(CommandContext commandContext, GameCache cache, CachedTag tag, T shader)
 {
     commandContext.AddCommand(new GenerateShader <T>(cache, tag, shader));
     commandContext.AddCommand(new CompileCommand <T>(cache, tag, shader));
     commandContext.AddCommand(new DisassembleCommand <T>(cache, tag, shader));
 }
        public static CommandContext Create(CommandContextStack stack, OpenTagCache info, TagInstance tag)
        {
            var groupName = info.StringIds.GetString(tag.Group.Name);

            var context = new CommandContext(stack.Context,
                string.Format("0x{0:X4}.{1}", tag.Index, groupName));

            switch (tag.Group.Tag.ToString())
            {
                case "vfsl": // vfiles_list
                    EditVFilesList(context, info, tag);
                    break;

                case "unic": // multilingual_unicode_string_list
                    EditMultilingualUnicodeStringList(context, info, tag);
                    break;

                case "bitm": // bitmap
                    EditBitmap(context, info, tag);
                    break;

                case "hlmt": // model
                    EditModel(context, info, tag);
                    break;

                case "mode": // render_model
                    EditRenderModel(context, info, tag);
                    break;

                case "rm  ": // render_method
                case "rmsh": // shader
                case "rmd ": // shader_decal
                case "rmfl": // shader_foliage
                case "rmhg": // shader_halogram
                case "rmss": // shader_screen
                case "rmtr": // shader_terrain
                case "rmw ": // shader_water
                case "rmzo": // shader_zonly
                case "rmcs": // shader_custom
                    EditRenderMethod(context, info, tag);
                    break;

                case "scnr":
                    EditScenario(context, info, tag);
                    break;
            }

            object value = null;

            using (var stream = info.OpenCacheRead())
                value = info.Deserializer.Deserialize(
                    new TagSerializationContext(stream, info.Cache, info.StringIds, tag),
                    TagStructureTypes.FindByGroupTag(tag.Group.Tag));

            var structure = new TagStructureInfo(
                TagStructureTypes.FindByGroupTag(tag.Group.Tag));

            context.AddCommand(new ListFieldsCommand(info, structure, value));
            context.AddCommand(new SetFieldCommand(stack, info, tag, structure, value));
            context.AddCommand(new EditBlockCommand(stack, info, tag, value));
            context.AddCommand(new AddToBlockCommand(stack, info, tag, structure, value));
            context.AddCommand(new RemoveFromBlockCommand(stack, info, tag, structure, value));
            context.AddCommand(new SaveChangesCommand(info, tag, value));
            context.AddCommand(new ExitToCommand(stack));

            return context;
        }
        public static void Populate(CommandContextStack contextStack, CommandContext context, GameCache cache)
        {
            context.AddCommand(new TestCommand(cache));

            context.AddCommand(new DumpLogCommand());
            context.AddCommand(new RunCommands(contextStack));
            context.AddCommand(new ClearCommand());
            context.AddCommand(new EchoCommand());
            context.AddCommand(new HelpCommand(contextStack));
            context.AddCommand(new SetLocaleCommand());
            context.AddCommand(new StopwatchCommand());
            context.AddCommand(new ConvertPluginsCommand(cache));
            context.AddCommand(new ListTagsCommand(cache));
            context.AddCommand(new EditTagCommand(contextStack, cache));
            context.AddCommand(new GenerateCampaignFileCommand(cache));
            context.AddCommand(new NameTagCommand(cache));
            context.AddCommand(new ForEachCommand(contextStack, cache));
            context.AddCommand(new ListAllStringsCommand(cache));
            context.AddCommand(new StringIdCommand(cache));
            context.AddCommand(new GenerateAssemblyPluginsCommand());
            context.AddCommand(new DuplicateTagCommand(cache));
            context.AddCommand(new DeleteTagCommand(cache));
            context.AddCommand(new ListNullTagsCommand(cache));
            context.AddCommand(new ListUnnamedTagsCommand(cache));
            context.AddCommand(new ExtractBitmapsCommand(cache));

            // Halo Online Specific Commands
            if (cache is GameCacheHaloOnlineBase)
            {
                var hoCache = cache as GameCacheHaloOnlineBase;
                context.AddCommand(new SaveTagNamesCommand(hoCache));
                context.AddCommand(new SaveModdedTagsCommand(hoCache));
                context.AddCommand(new CreateTagCommand(hoCache));
                context.AddCommand(new ImportTagCommand(hoCache));
                context.AddCommand(new TagDependencyCommand(hoCache));
                context.AddCommand(new TagResourceCommand(hoCache));
                context.AddCommand(new ListUnusedTagsCommand(hoCache));
                context.AddCommand(new GetTagInfoCommand(hoCache));
                context.AddCommand(new GetTagAddressCommand());
                context.AddCommand(new ExtractTagCommand(hoCache));
                context.AddCommand(new ExtractAllTagsCommand(hoCache));
                context.AddCommand(new ExportTagModCommand(hoCache));

                // modding commands
                context.AddCommand(new ApplyModPackageCommand(hoCache));
                context.AddCommand(new CreateCharacterType(cache));
                context.AddCommand(new ExportModPackageCommand(hoCache));

                context.AddCommand(new UpdateMapFilesCommand(cache));

                context.AddCommand(new PhysicsModelTestCommand(cache));
                context.AddCommand(new CollisionModelTestCommand(hoCache));
            }

            // porting related
            context.AddCommand(new UseXSDCommand());
            context.AddCommand(new UseAudioCacheCommand());
            context.AddCommand(new OpenCacheFileCommand(contextStack, cache));
        }
Example #18
0
 public static void Populate(CommandContext context, HaloOnlineCacheContext cacheContext, CachedTagInstance instance, ForgeGlobalsDefinition definition)
 {
     context.AddCommand(new ParseItemsXmlCommand(cacheContext, instance, definition));
 }
Example #19
0
        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()) && (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 oldContext = ContextStack.Context;

            var commandContext = new CommandContext(ContextStack.Context, string.Format("{0}.{1}", tagName, groupTagInput));

            commandContext.AddCommand(new ListFieldsCommand(BlamCache, definition.GetTagStructureInfo(BlamCache.Version), definition));
            commandContext.AddCommand(new EditBlockCommand(ContextStack, BlamCache, tag, 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);
        }
Example #20
0
 public static void Populate(CommandContext context, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Model model)
 {
     context.AddCommand(new ListVariantsCommand(cacheContext, model));
     context.AddCommand(new ExtractModelCommand(cacheContext, model));
     context.AddCommand(new ExtractBitmapsCommand(cacheContext, tag, model));
 }
 public static void Populate(CommandContext commandContext, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, CollisionModel definition)
 {
     commandContext.AddCommand(new ExtractModelCommand(cacheContext, definition));
 }
 public static void Populate(CommandContext context, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ModelAnimationGraph animation)
 {
     context.AddCommand(new GetResourceInfoCommand(cacheContext, tag, animation));
     context.AddCommand(new ResourceDataCommand(cacheContext, tag, animation));
     context.AddCommand(new SortModesCommand(cacheContext, animation));
 }
Example #23
0
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, Model model)
 {
     context.AddCommand(new ListVariantsCommand(info, model));
     context.AddCommand(new ExtractModelCommand(info, model));
 }
Example #24
0
 public static void Populate(CommandContext commandContext, GameCache cache, CachedTag tag, Bitmap bitmap)
 {
     commandContext.AddCommand(new ExtractBitmapCommand(cache, tag, bitmap));
     commandContext.AddCommand(new ImportBitmapCommand(cache, tag, bitmap));
 }
 public static void Populate(CommandContext context, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ParticleModel particleModel)
 {
     context.AddCommand(new DumpRenderGeometryCommand(cacheContext, particleModel.Geometry, "particle"));
 }
Example #26
0
        public override bool Execute(List<string> args)
        {
            if (args.Count < 1 || args.Count > 2)
                return false;

            var blockName = args[0];
            var ownerType = Owner.GetType();

            var enumerator = new TagFieldEnumerator(Structure);

            var deferredNames = new List<string>();
            var deferredArgs = new List<string>();

            if (blockName.Contains("."))
            {
                deferredNames.AddRange(blockName.Split('.'));
                blockName = deferredNames[0];
                deferredNames = deferredNames.Skip(1).ToList();
                deferredArgs.AddRange(args.Skip(1));
                args = new List<string> { blockName };
            }

            if (blockName.Contains("]"))
            {
                var openBracketIndex = blockName.IndexOf('[');
                var closeBracketIndex = blockName.IndexOf(']');
                var name = blockName.Substring(0, openBracketIndex);
                var index = blockName.Substring(openBracketIndex + 1, (closeBracketIndex - openBracketIndex) - 1);

                blockName = name;
                args = new List<string> { name, index };
            }

            var blockNameLow = blockName.ToLower();
            var field = enumerator.Find(f => f.Name == blockName || f.Name.ToLower() == blockNameLow);

            if (field == null)
            {
                Console.WriteLine("{0} does not contain a block named \"{1}\"", ownerType.Name, blockName);
                return false;
            }

            var contextName = "";
            object blockValue = null;

            var structureAttribute = field.FieldType.CustomAttributes.ToList().Find(a => a.AttributeType == typeof(TagStructureAttribute));

            if (structureAttribute != null)
            {
                if (args.Count != 1)
                    return false;

                blockValue = field.GetValue(Owner);
                contextName = $"{blockName}";
            }
            else
            {
                if (args.Count != 2)
                    return false;

                IList fieldValue = null;

                if (field.FieldType.GetInterface("IList") == null || (fieldValue = (IList)field.GetValue(Owner)) == null)
                {
                    Console.WriteLine("{0} does not contain a block named \"{1}\"", ownerType.Name, blockName);
                    return false;
                }

                int blockIndex = 0;

                if (args[1] == "*")
                    blockIndex = fieldValue.Count - 1;
                else if (!int.TryParse(args[1], out blockIndex))
                {
                    Console.WriteLine("Invalid index requested from block {0}: {1}", blockName, blockIndex);
                    return false;
                }

                if (blockIndex >= fieldValue.Count || blockIndex < 0)
                {
                    Console.WriteLine("Invalid index requested from block {0}: {1}", blockName, blockIndex);
                    return false;
                }

                blockValue = fieldValue[blockIndex];
                contextName = $"{blockName}[{blockIndex}]";
            }

            var blockStructure = new TagStructureInfo(blockValue.GetType());

            var blockContext = new CommandContext(Stack.Context, contextName);
            blockContext.AddCommand(new ListFieldsCommand(Info, blockStructure, blockValue));
            blockContext.AddCommand(new SetFieldCommand(Stack, Info, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new EditBlockCommand(Stack, Info, Tag, blockValue));
            blockContext.AddCommand(new AddToCommand(Stack, Info, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new RemoveFromCommand(Stack, Info, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new CopyElementsCommand(Stack, Info, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new PasteElementsCommand(Stack, Info, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new ExitToCommand(Stack));
            Stack.Push(blockContext);

            if (deferredNames.Count != 0)
            {
                var name = deferredNames[0];
                deferredNames = deferredNames.Skip(1).ToList();

                foreach (var deferredName in deferredNames)
                    name += '.' + deferredName;

                args = new List<string> { name };
                args.AddRange(deferredArgs);

                var command = new EditBlockCommand(Stack, Info, Tag, blockValue);
                return command.Execute(args);
            }

            return true;
        }
Example #27
0
 public static void Populate(CommandContext commandContext, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ScenarioStructureBsp bsp)
 {
     commandContext.AddCommand(new CollisionTestCommand(cacheContext, tag, bsp));
     commandContext.AddCommand(new ResourceDataCommand(cacheContext, tag, bsp));
     commandContext.AddCommand(new ExtractCollisionGeometryCommand(cacheContext, bsp));
     commandContext.AddCommand(new ExtractPathfindingGeometryCommand(cacheContext, bsp));
     commandContext.AddCommand(new GenerateJumpHintsCommand(cacheContext, bsp));
     commandContext.AddCommand(new ExtractRenderGeometryCommand(cacheContext, bsp));
     commandContext.AddCommand(new DumpRenderGeometryCommand(cacheContext, bsp.Geometry, "Decorator"));
     commandContext.AddCommand(new DumpRenderGeometryCommand(cacheContext, bsp.Geometry2, "Bsp"));
     commandContext.AddCommand(new DumpMoppCommand(cacheContext, bsp));
     commandContext.AddCommand(new MoppDataCommand(cacheContext, bsp));
     commandContext.AddCommand(new LocalizeTagResourcesCommand(cacheContext, bsp, tag));
 }
		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 void Populate(CommandContext context, OpenTagCache info, TagInstance tag, ModelAnimationGraph animation)
 {
     context.AddCommand(new GetResourcesCommand(info, tag, animation));
 }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, RenderModel renderModel)
 {
     context.AddCommand(new SpecifyShadersCommand(info, tag, renderModel));
     context.AddCommand(new GetResourceCommand(info, tag, renderModel));
     context.AddCommand(new ReplaceCommand(info, tag, renderModel));
 }
 public static void Populate(CommandContext context, GameCache cache, CachedTag tag, ParticleModel particleModel)
 {
     context.AddCommand(new DumpRenderGeometryCommand(cache, particleModel.Geometry, "particle"));
 }
Example #32
0
        public override object Execute(List <string> args)
        {
            if (args.Count < 1 || args.Count > 2)
            {
                return(false);
            }

            var blockName = args[0];
            var ownerType = Owner.GetType();

            var deferredNames = new List <string>();
            var deferredArgs  = new List <string>();

            if (blockName.Contains("."))
            {
                deferredNames.AddRange(blockName.Split('.'));
                blockName     = deferredNames[0];
                deferredNames = deferredNames.Skip(1).ToList();
                deferredArgs.AddRange(args.Skip(1));
                args = new List <string> {
                    blockName
                };
            }

            if (blockName.Contains("]"))
            {
                var openBracketIndex  = blockName.IndexOf('[');
                var closeBracketIndex = blockName.IndexOf(']');
                var name  = blockName.Substring(0, openBracketIndex);
                var index = blockName.Substring(openBracketIndex + 1, (closeBracketIndex - openBracketIndex) - 1);

                blockName = name;
                args      = new List <string> {
                    name, index
                };
            }

            var blockNameLow   = blockName.ToLower();
            var blockNameSnake = blockName.ToSnakeCase();

            var field = TagStructure.GetTagFieldEnumerable(Structure)
                        .Find(f =>
                              f.Name == blockName ||
                              f.Name.ToLower() == blockNameLow ||
                              f.Name.ToSnakeCase() == blockNameSnake);

            if (field == null)
            {
                Console.WriteLine("{0} does not contain a block named \"{1}\"", ownerType.Name, blockName);
                return(false);
            }

            var    contextName = "";
            object blockValue  = null;

            var structureAttribute = field.FieldType.CustomAttributes.ToList().Find(a => a.AttributeType == typeof(TagStructureAttribute));

            if (structureAttribute != null)
            {
                if (args.Count != 1)
                {
                    return(false);
                }

                blockValue  = field.GetValue(Owner);
                contextName = $"{blockName}";
            }
            else
            {
                if (args.Count != 2)
                {
                    return(false);
                }

                IList fieldValue = null;

                if (field.FieldType.GetInterface("IList") == null || (fieldValue = (IList)field.GetValue(Owner)) == null)
                {
                    Console.WriteLine("{0} does not contain a block named \"{1}\"", ownerType.Name, blockName);
                    return(false);
                }

                int blockIndex = 0;

                if (args[1] == "*")
                {
                    blockIndex = fieldValue.Count - 1;
                }
                else if (!int.TryParse(args[1], out blockIndex))
                {
                    Console.WriteLine("Invalid index requested from block {0}: {1}", blockName, blockIndex);
                    return(false);
                }

                if (blockIndex >= fieldValue.Count || blockIndex < 0)
                {
                    Console.WriteLine("Invalid index requested from block {0}: {1}", blockName, blockIndex);
                    return(false);
                }

                blockValue  = fieldValue[blockIndex];
                contextName = $"{blockName}[{blockIndex}]";
            }

            var blockStructure = TagStructure.GetTagStructureInfo(blockValue.GetType(), Cache.Version);

            var blockContext = new CommandContext(ContextStack.Context, contextName);

            blockContext.AddCommand(new ListFieldsCommand(Cache, blockStructure, blockValue));
            blockContext.AddCommand(new SetFieldCommand(ContextStack, Cache, Tag, blockStructure, blockValue));
            //blockContext.AddCommand(new ExtractResourceCommand(ContextStack, CacheContext, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new EditBlockCommand(ContextStack, Cache, Tag, blockValue));
            blockContext.AddCommand(new AddBlockElementsCommand(ContextStack, Cache, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new RemoveBlockElementsCommand(ContextStack, Cache, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new CopyBlockElementsCommand(ContextStack, Cache, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new PasteBlockElementsCommand(ContextStack, Cache, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new ForEachCommand(ContextStack, Cache, Tag, blockStructure, blockValue));
            blockContext.AddCommand(new ExitToCommand(ContextStack));
            ContextStack.Push(blockContext);

            if (deferredNames.Count != 0)
            {
                var name = deferredNames[0];
                deferredNames = deferredNames.Skip(1).ToList();

                foreach (var deferredName in deferredNames)
                {
                    name += '.' + deferredName;
                }

                args = new List <string> {
                    name
                };
                args.AddRange(deferredArgs);

                var command = new EditBlockCommand(ContextStack, Cache, Tag, blockValue);
                return(command.Execute(args));
            }

            return(true);
        }
        public static CommandContext Create(CommandContextStack contextStack, HaloOnlineCacheContext cacheContext)
        {
            var context = new CommandContext(contextStack.Context, "tags");

            context.AddCommand(new HelpCommand(contextStack));
            context.AddCommand(new ClearCommand());
            context.AddCommand(new DumpLogCommand());
            context.AddCommand(new EchoCommand());
            context.AddCommand(new SetLocaleCommand());
            context.AddCommand(new StopwatchCommand());
            context.AddCommand(new CleanCsvFileCommand(cacheContext));
            context.AddCommand(new TagDependencyCommand(cacheContext));
            context.AddCommand(new ExtractTagCommand(cacheContext));
            context.AddCommand(new ImportTagCommand(cacheContext));
            context.AddCommand(new GetTagInfoCommand(cacheContext));
            context.AddCommand(new ListTagsCommand(cacheContext));
            context.AddCommand(new GetMapInfoCommand());
            context.AddCommand(new DuplicateTagCommand(cacheContext));
            context.AddCommand(new GetTagAddressCommand());
            context.AddCommand(new TagResourceCommand(cacheContext));
            context.AddCommand(new DeleteTagCommand(cacheContext));
            context.AddCommand(new CleanCacheFilesCommand(cacheContext));
            context.AddCommand(new RebuildCacheFilesCommand(cacheContext));
            context.AddCommand(new ListUnusedTagsCommand(cacheContext));
            context.AddCommand(new ListNullTagsCommand(cacheContext));
            context.AddCommand(new CreateTagCommand(cacheContext));
            context.AddCommand(new ExtractAllTagsCommand(cacheContext));
            context.AddCommand(new Editing.EditTagCommand(contextStack, cacheContext));
            context.AddCommand(new CollisionModelTestCommand(cacheContext));
            context.AddCommand(new PhysicsModelTestCommand(cacheContext));
            context.AddCommand(new StringIdCommand(cacheContext));
            context.AddCommand(new ListAllStringsCommand(cacheContext));
            context.AddCommand(new GenerateTagStructuresCommand(cacheContext));
            context.AddCommand(new RenderModelTestCommand(cacheContext));
            context.AddCommand(new ConvertPluginsCommand(cacheContext));
            context.AddCommand(new GenerateTagNamesCommand(cacheContext));
            context.AddCommand(new NameTagCommand(cacheContext));
            context.AddCommand(new SaveTagNamesCommand(cacheContext));
            context.AddCommand(new MatchTagsCommand(cacheContext));
            context.AddCommand(new ConvertTagCommand(cacheContext));
            context.AddCommand(new UpdateMapFilesCommand(cacheContext));
            context.AddCommand(new Bitmaps.ExtractBitmapsCommand(cacheContext));
            context.AddCommand(new GenerateAssemblyPluginsCommand());
            context.AddCommand(new RelocateResourcesCommand(cacheContext));
            context.AddCommand(new RebuildStringIdsCommand(cacheContext));
            context.AddCommand(new OpenCacheFileCommand(contextStack, cacheContext));
            context.AddCommand(new ExportTagModCommand(cacheContext));
            context.AddCommand(new Shaders.RegenerateShaders(cacheContext));
            context.AddCommand(new UseAudioCacheCommand());
            context.AddCommand(new ForEachCommand(contextStack, cacheContext));

            return(context);
        }
Example #34
0
        public static CommandContext Create(CommandContextStack contextStack, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, object definition)
        {
            var documentationPath = $"{new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName}\\TagTool.xml";

            if (Documentation.ChildNodes.Count == 0 && File.Exists(documentationPath))
            {
                Documentation.Load(documentationPath);
            }

            var groupName = cacheContext.GetString(tag.Group.Name);
            var tagName   = tag?.Name ?? $"0x{tag.Index:X4}";

            var commandContext = new CommandContext(contextStack.Context, string.Format("{0}.{1}", tagName, groupName));

            switch (tag.Group.Tag.ToString())
            {
            case "bink":
                VideoContextFactory.Populate(commandContext, cacheContext, tag, (Bink)definition);
                break;

            case "bitm":     // bitmap
                BitmapContextFactory.Populate(commandContext, cacheContext, tag, (Bitmap)definition);
                break;

            case "coll":
                CollisionModelContextFactory.Populate(commandContext, cacheContext, tag, (CollisionModel)definition);
                break;

            case "hlmt":     // model
                ModelContextFactory.Populate(commandContext, cacheContext, tag, (Model)definition);
                break;

            case "jmad":
                AnimationContextFactory.Populate(commandContext, cacheContext, tag, (ModelAnimationGraph)definition);
                break;

            case "Lbsp":
                LightmapContextFactory.Populate(commandContext, cacheContext, tag, (ScenarioLightmapBspData)definition);
                break;

            case "mode":     // render_model
                RenderModelContextFactory.Populate(commandContext, cacheContext, tag, (RenderModel)definition);
                break;

            case "pmdf":
                ParticleModelContextFactory.Populate(commandContext, cacheContext, tag, (ParticleModel)definition);
                break;

            case "rm  ":     // render_method
            case "rmsh":     // shader
            case "rmd ":     // shader_decal
            case "rmfl":     // shader_foliage
            case "rmhg":     // shader_halogram
            case "rmss":     // shader_screen
            case "rmtr":     // shader_terrain
            case "rmw ":     // shader_water
            case "rmzo":     // shader_zonly
            case "rmcs":     // shader_custom
                RenderMethodContextFactory.Populate(commandContext, cacheContext, tag, (RenderMethod)definition);
                break;

            case "sbsp":
                BSPContextFactory.Populate(commandContext, cacheContext, tag, (ScenarioStructureBsp)definition);
                break;

            case "scnr":
                ScnrContextFactory.Populate(commandContext, cacheContext, tag, (Scenario)definition);
                break;

            case "snd!":
                SoundContextFactory.Populate(commandContext, cacheContext, tag, (Sound)definition);
                break;

            case "unic":     // multilingual_unicode_string_list
                UnicodeContextFactory.Populate(commandContext, cacheContext, tag, (MultilingualUnicodeStringList)definition);
                break;

            case "vfsl":     // vfiles_list
                VFilesContextFactory.Populate(commandContext, cacheContext, tag, (VFilesList)definition);
                break;

            case "pixl":
                Shaders.ShaderContextFactory <PixelShader> .Populate(commandContext, cacheContext, tag, (PixelShader)definition);

                break;

            case "vtsh":
                Shaders.ShaderContextFactory <VertexShader> .Populate(commandContext, cacheContext, tag, (VertexShader)definition);

                break;

            case "glps":
                Shaders.ShaderContextFactory <GlobalPixelShader> .Populate(commandContext, cacheContext, tag, (GlobalPixelShader)definition);

                break;

            case "glvs":
                Shaders.ShaderContextFactory <GlobalVertexShader> .Populate(commandContext, cacheContext, tag, (GlobalVertexShader)definition);

                break;

            case "rmt2":
                Shaders.RenderMethodTemplateContextFactory.Populate(commandContext, cacheContext, tag, (RenderMethodTemplate)definition);
                break;
            }

            var structure = TagStructure.GetTagStructureInfo(TagDefinition.Find(tag.Group.Tag), cacheContext.Version);

            commandContext.AddCommand(new ListFieldsCommand(cacheContext, structure, definition));
            commandContext.AddCommand(new SetFieldCommand(contextStack, cacheContext, tag, structure, definition));
            commandContext.AddCommand(new EditBlockCommand(contextStack, cacheContext, tag, definition));
            commandContext.AddCommand(new AddBlockElementsCommand(contextStack, cacheContext, tag, structure, definition));
            commandContext.AddCommand(new RemoveBlockElementsCommand(contextStack, cacheContext, tag, structure, definition));
            commandContext.AddCommand(new CopyBlockElementsCommand(contextStack, cacheContext, tag, structure, definition));
            commandContext.AddCommand(new PasteBlockElementsCommand(contextStack, cacheContext, tag, structure, definition));
            commandContext.AddCommand(new ForEachCommand(contextStack, cacheContext, tag, structure, definition));
            commandContext.AddCommand(new SaveTagChangesCommand(cacheContext, tag, definition));
            commandContext.AddCommand(new PokeTagChangesCommand(cacheContext, tag, definition));
            commandContext.AddCommand(new ExitToCommand(contextStack));

            return(commandContext);
        }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, Bitmap bitmap)
 {
     context.AddCommand(new ImportCommand(info, tag, bitmap));
 }
 public static CommandContext Create(CommandContext parent, OpenTagCache info, HaloTag tag, Bitmap bitmap)
 {
     var context = new CommandContext(parent, string.Format("{0:X8}.bitm", tag.Index));
     context.AddCommand(new BitmImportCommand(info, tag, bitmap));
     return context;
 }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, ModelAnimationGraph animation)
 {
     context.AddCommand(new GetResourcesCommand(info, tag, animation));
 }
Example #38
0
        public static CommandContext Create(CommandContextStack stack, OpenTagCache info)
        {
            var context = new CommandContext(null, info.CacheFile.Name);

            context.AddCommand(new HelpCommand(stack));
            context.AddCommand(new ClearCommand());
            context.AddCommand(new DumpLogCommand());
            context.AddCommand(new EchoCommand());
            context.AddCommand(new DependencyCommand(info));
            context.AddCommand(new ExtractCommand(info));
            context.AddCommand(new ImportCommand(info));
            context.AddCommand(new InfoCommand(info));
            context.AddCommand(new ListCommand(info));
            context.AddCommand(new MapCommand());
            context.AddCommand(new DuplicateTagCommand(info));
            context.AddCommand(new AddressCommand());
            context.AddCommand(new ResourceDataCommand());
            if (info.StringIds != null)
            {
                context.AddCommand(new EditCommand(stack, info));
                context.AddCommand(new ExtractBitmapsCommand(info));
                context.AddCommand(new ImportBitmapCommand(info));
                context.AddCommand(new CollisionGeometryTestCommand(info));
                context.AddCommand(new PhysicsModelTestCommand(info));
                context.AddCommand(new StringIdCommand(info));
                context.AddCommand(new ListStringsCommand(info));
                context.AddCommand(new GenerateLayoutsCommand(info));
                context.AddCommand(new ModelTestCommand(info));
                context.AddCommand(new ConvertPluginsCommand(info));
                context.AddCommand(new GenerateTagNamesCommand(info));
                context.AddCommand(new MatchTagsCommand(info));
                context.AddCommand(new ConvertCommand(info));
            }
            return(context);
        }
Example #39
0
 public static void Populate(CommandContext context, GameCache cache, CachedTag instance, ForgeGlobalsDefinition definition)
 {
     context.AddCommand(new ParseItemsXmlCommand(cache, instance, definition));
 }
 public static void Populate(CommandContext commandContext, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Sound sound)
 {
     commandContext.AddCommand(new ImportSoundCommand(cacheContext, tag, sound));
     commandContext.AddCommand(new ResourceDataCommand(cacheContext, tag, sound));
     commandContext.AddCommand(new ExportSoundCommand(cacheContext, tag, sound));
 }
 public static void Populate(CommandContext commandContext, GameCacheContext cacheContext, CachedTagInstance tag, RenderMethodTemplate render_method_template)
 {
     commandContext.AddCommand(new GenerateRenderMethodTemplate(cacheContext, tag, render_method_template));
 }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, RenderModel renderModel)
 {
     context.AddCommand(new SpecifyShadersCommand(info, tag, renderModel));
 }
        public static CommandContext Create(CommandContextStack contextStack, HaloOnlineCacheContext cacheContext)
        {
            var context = new CommandContext(contextStack.Context, "tags");

            context.AddCommand(new HelpCommand(contextStack));
            context.AddCommand(new ClearCommand());
            context.AddCommand(new DumpLogCommand());
            context.AddCommand(new EchoCommand());
            context.AddCommand(new SetLocaleCommand());
            context.AddCommand(new StopwatchCommand());
            context.AddCommand(new CleanCsvFileCommand(cacheContext));
            context.AddCommand(new TagDependencyCommand(cacheContext));
            context.AddCommand(new ExtractTagCommand(cacheContext));
            context.AddCommand(new ImportTagCommand(cacheContext));
            context.AddCommand(new GetTagInfoCommand(cacheContext));
            context.AddCommand(new ListTagsCommand(cacheContext));
            context.AddCommand(new ListUnnamedTagsCommand(cacheContext));
            context.AddCommand(new GetMapInfoCommand());
            context.AddCommand(new DuplicateTagCommand(cacheContext));
            context.AddCommand(new GetTagAddressCommand());
            context.AddCommand(new TagResourceCommand(cacheContext));
            context.AddCommand(new DeleteTagCommand(cacheContext));
            context.AddCommand(new CleanCacheFilesCommand(cacheContext));
            context.AddCommand(new RebuildCacheFilesCommand(cacheContext));
            context.AddCommand(new ListUnusedTagsCommand(cacheContext));
            context.AddCommand(new ListNullTagsCommand(cacheContext));
            context.AddCommand(new CreateTagCommand(cacheContext));
            context.AddCommand(new ExtractAllTagsCommand(cacheContext));
            context.AddCommand(new Editing.EditTagCommand(contextStack, cacheContext));
            context.AddCommand(new CollisionModelTestCommand(cacheContext));
            context.AddCommand(new PhysicsModelTestCommand(cacheContext));
            context.AddCommand(new StringIdCommand(cacheContext));
            context.AddCommand(new ListAllStringsCommand(cacheContext));
            context.AddCommand(new GenerateTagStructuresCommand(cacheContext));
            context.AddCommand(new RenderModelTestCommand(cacheContext));
            context.AddCommand(new ConvertPluginsCommand(cacheContext));
            context.AddCommand(new GenerateTagNamesCommand(cacheContext));
            context.AddCommand(new NameTagCommand(cacheContext));
            context.AddCommand(new SaveTagNamesCommand(cacheContext));
            context.AddCommand(new MatchTagsCommand(cacheContext));
            context.AddCommand(new ConvertTagCommand(cacheContext));
            context.AddCommand(new UpdateMapFilesCommand(cacheContext));
            context.AddCommand(new UpdateMapFilesNewCommand(cacheContext));
            context.AddCommand(new Bitmaps.ExtractBitmapsCommand(cacheContext));
            context.AddCommand(new GenerateAssemblyPluginsCommand());
            context.AddCommand(new RelocateResourcesCommand(cacheContext));
            context.AddCommand(new RebuildStringIdsCommand(cacheContext));
            context.AddCommand(new OpenCacheFileCommand(contextStack, cacheContext));
            context.AddCommand(new ExportTagModCommand(cacheContext));
            context.AddCommand(new Shaders.RegenerateShaders(cacheContext));
            context.AddCommand(new UseAudioCacheCommand());
            context.AddCommand(new ForEachCommand(contextStack, cacheContext));
            context.AddCommand(new ClearMultiplayerCustomizationCommand(cacheContext));
            context.AddCommand(new ModelAnimationGraphs.AnimationTestCommand(cacheContext));
            context.AddCommand(new ExportTagDefinitionsCommand(cacheContext));
            context.AddCommand(new ModelAnimationGraphs.ApplySprintFixupsCommand(cacheContext));
            context.AddCommand(new ListMultiMeshModelsCommand(cacheContext));
            context.AddCommand(new OpenMapFileCommand(cacheContext));

            //
            // Modding commands
            //

            context.AddCommand(new ExportModPackageCommand(cacheContext));
            context.AddCommand(new CreateCharacterType(cacheContext));
            context.AddCommand(new UpgradeModPackage(cacheContext));
            //context.AddCommand(new MergeModPackagesCommand(cacheContext));
            context.AddCommand(new ApplyModPackageCommand(cacheContext));
            context.AddCommand(new SaveModdedTagsCommand(cacheContext));
            return(context);
        }
 public static CommandContext Create(CommandContextStack stack, OpenTagCache info)
 {
     var context = new CommandContext(null, info.CacheFile.Name);
     context.AddCommand(new HelpCommand(stack));
     context.AddCommand(new ClearCommand());
     context.AddCommand(new DumpLogCommand());
     context.AddCommand(new EchoCommand());
     context.AddCommand(new DependencyCommand(info));
     context.AddCommand(new ExtractCommand(info));
     context.AddCommand(new ImportCommand(info));
     context.AddCommand(new InfoCommand(info));
     context.AddCommand(new ListCommand(info));
     context.AddCommand(new MapCommand());
     context.AddCommand(new DuplicateTagCommand(info));
     context.AddCommand(new AddressCommand());
     context.AddCommand(new ResourceDataCommand());
     if (info.StringIds != null)
     {
         context.AddCommand(new EditCommand(stack, info));
         context.AddCommand(new ExtractBitmapsCommand(info));
         context.AddCommand(new ImportBitmapCommand(info));
         context.AddCommand(new CollisionGeometryTestCommand(info));
         context.AddCommand(new PhysicsModelTestCommand(info));
         context.AddCommand(new StringIdCommand(info));
         context.AddCommand(new ListStringsCommand(info));
         context.AddCommand(new GenerateLayoutsCommand(info));
         context.AddCommand(new ModelTestCommand(info));
         context.AddCommand(new ConvertPluginsCommand(info));
         context.AddCommand(new GenerateTagNamesCommand(info));
         context.AddCommand(new MatchTagsCommand(info));
         context.AddCommand(new ConvertCommand(info));
     }
     return context;
 }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, Model model)
 {
     context.AddCommand(new ListVariantsCommand(info, model));
     context.AddCommand(new ExtractModelCommand(info, model));
 }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, RenderMethod renderMethod)
 {
     context.AddCommand(new ListArgumentsCommand(info, tag, renderMethod));
     context.AddCommand(new ListBitmapsCommand(info, tag, renderMethod));
     context.AddCommand(new SpecifyBitmapsCommand(info, tag, renderMethod));
 }
 public static CommandContext Create(CommandContextStack stack, OpenTagCache info)
 {
     var context = new CommandContext(null, info.CacheFile.Name);
     context.AddCommand(new HelpCommand(stack));
     context.AddCommand(new DependencyCommand(info));
     context.AddCommand(new FixupCommand(info));
     context.AddCommand(new ExtractCommand(info));
     context.AddCommand(new ImportCommand(info));
     context.AddCommand(new InfoCommand(info));
     context.AddCommand(new InsertCommand(info));
     context.AddCommand(new ListCommand(info));
     context.AddCommand(new MapCommand());
     context.AddCommand(new EditCommand(stack, info));
     context.AddCommand(new DuplicateTagCommand(info));
     context.AddCommand(new AddressCommand());
     context.AddCommand(new ExtractBitmapsCommand(info));
     context.AddCommand(new ResourceDataCommand());
     context.AddCommand(new TagBlockCommand(info));
     if (info.StringIds != null)
     {
         context.AddCommand(new StringIdCommand(info));
         context.AddCommand(new ListStringsCommand(info));
         context.AddCommand(new GenerateLayoutsCommand(info));
         context.AddCommand(new ModelTestCommand(info));
     }
     return context;
 }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, Bitmap bitmap)
 {
     context.AddCommand(new ImportCommand(info, tag, bitmap));
 }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, Scenario scenario)
 {
     context.AddCommand(new CopyForgePaletteCommand(info, scenario));
 }
 public static void Populate(CommandContext commandContext, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Bitmap bitmap)
 {
     commandContext.AddCommand(new ExtractBitmapCommand(cacheContext, tag, bitmap));
     commandContext.AddCommand(new ImportBitmapCommand(cacheContext, tag, bitmap));
 }
Example #51
0
        public static void Populate(CommandContextStack contextStack, CommandContext context, HaloOnlineCacheContext cacheContext, CacheFile blamCache)
        {
            var portTagCommand = new PortTagCommand(cacheContext, blamCache);

            context.AddCommand(portTagCommand);
            context.AddCommand(new ExtractXMACommand(cacheContext, blamCache));
            context.AddCommand(new ExtractSoundCommand(cacheContext, blamCache));
            context.AddCommand(new ExtractBitmapCommand(blamCache));
            context.AddCommand(new EditTagCommand(contextStack, blamCache));
            context.AddCommand(new ListBlamTagsCommand(cacheContext, blamCache));
            context.AddCommand(new PortArmorVariantCommand(cacheContext, blamCache));
            context.AddCommand(new PortMultiplayerEventsCommand(cacheContext, blamCache));
            context.AddCommand(new NameBlamTagCommand(cacheContext, blamCache));
            context.AddCommand(new MergeAnimationGraphsCommand(cacheContext, blamCache, portTagCommand));
            context.AddCommand(new PortMultiplayerScenarioCommand(cacheContext, blamCache, portTagCommand));
            context.AddCommand(new CopyTagNamesCommand(cacheContext, blamCache));
        }
        public static CommandContext Create(CommandContextStack stack, OpenTagCache info, TagInstance tag)
        {
            var groupName = info.StringIds.GetString(tag.Group.Name);

            var context = new CommandContext(stack.Context,
                                             string.Format("0x{0:X4}.{1}", tag.Index, groupName));

            switch (tag.Group.Tag.ToString())
            {
            case "vfsl":     // vfiles_list
                EditVFilesList(context, info, tag);
                break;

            case "unic":     // multilingual_unicode_string_list
                EditMultilingualUnicodeStringList(context, info, tag);
                break;

            case "bitm":     // bitmap
                EditBitmap(context, info, tag);
                break;

            case "hlmt":     // model
                EditModel(context, info, tag);
                break;

            case "mode":     // render_model
                EditRenderModel(context, info, tag);
                break;

            case "rm  ":     // render_method
            case "rmsh":     // shader
            case "rmd ":     // shader_decal
            case "rmfl":     // shader_foliage
            case "rmhg":     // shader_halogram
            case "rmss":     // shader_screen
            case "rmtr":     // shader_terrain
            case "rmw ":     // shader_water
            case "rmzo":     // shader_zonly
            case "rmcs":     // shader_custom
                EditRenderMethod(context, info, tag);
                break;

            case "scnr":
                EditScenario(context, info, tag);
                break;
            }

            object value = null;

            using (var stream = info.OpenCacheRead())
                value = info.Deserializer.Deserialize(
                    new TagSerializationContext(stream, info.Cache, info.StringIds, tag),
                    TagStructureTypes.FindByGroupTag(tag.Group.Tag));

            var structure = new TagStructureInfo(
                TagStructureTypes.FindByGroupTag(tag.Group.Tag));

            context.AddCommand(new ListFieldsCommand(info, structure, value));
            context.AddCommand(new SetFieldCommand(stack, info, tag, structure, value));
            context.AddCommand(new EditBlockCommand(stack, info, tag, value));
            context.AddCommand(new AddToBlockCommand(stack, info, tag, structure, value));
            context.AddCommand(new RemoveFromBlockCommand(stack, info, tag, structure, value));
            context.AddCommand(new SaveChangesCommand(info, tag, value));
            context.AddCommand(new ExitToCommand(stack));

            return(context);
        }
        public static CommandContext Create(CommandContextStack stack, OpenTagCache info, TagInstance tag)
        {
            var groupName = info.StringIDs.GetString(tag.Group.Name);

            var tagName = $"0x{tag.Index:X4}";

            if (info.TagNames.ContainsKey(tag.Index))
            {
                tagName = info.TagNames[tag.Index];
                tagName = $"(0x{tag.Index:X4}) {tagName.Substring(tagName.LastIndexOf('\\') + 1)}";
            }

            var context = new CommandContext(stack.Context,
                string.Format("{0}.{1}", tagName, groupName));

            object value = null;

            using (var stream = info.OpenCacheRead())
                value = info.Deserializer.Deserialize(
                    new TagSerializationContext(stream, info.Cache, info.StringIDs, tag),
                    TagStructureTypes.FindByGroupTag(tag.Group.Tag));

            switch (tag.Group.Tag.ToString())
            {
                case "vfsl": // vfiles_list
                    VFilesContextFactory.Populate(context, info, tag, (VFilesList)value);
                    break;

                case "unic": // multilingual_unicode_string_list
                    UnicodeContextFactory.Populate(context, info, tag, (MultilingualUnicodeStringList)value);
                    break;

                case "bitm": // bitmap
                    BitmapContextFactory.Populate(context, info, tag, (Bitmap)value);
                    break;

                case "hlmt": // model
                    ModelContextFactory.Populate(context, info, tag, (Model)value);
                    break;

                case "mode": // render_model
                    RenderModelContextFactory.Populate(context, info, tag, (RenderModel)value);
                    break;

                case "jmad":
                    AnimationContextFactory.Populate(context, info, tag, (ModelAnimationGraph)value);
                    break;

                case "rm  ": // render_method
                case "rmsh": // shader
                case "rmd ": // shader_decal
                case "rmfl": // shader_foliage
                case "rmhg": // shader_halogram
                case "rmss": // shader_screen
                case "rmtr": // shader_terrain
                case "rmw ": // shader_water
                case "rmzo": // shader_zonly
                case "rmcs": // shader_custom
                    RenderMethodContextFactory.Populate(context, info, tag, (RenderMethod)value);
                    break;

                case "scnr":
                    ScnrContextFactory.Populate(context, info, tag, (Scenario)value);
                    break;

                case "sbsp":
                    BSPContextFactory.Populate(context, info, tag, (ScenarioStructureBsp)value);
                    break;
            }

            var structure = new TagStructureInfo(
                TagStructureTypes.FindByGroupTag(tag.Group.Tag));

            context.AddCommand(new ListFieldsCommand(info, structure, value));
            context.AddCommand(new SetFieldCommand(stack, info, tag, structure, value));
            context.AddCommand(new EditBlockCommand(stack, info, tag, value));
            context.AddCommand(new AddToCommand(stack, info, tag, structure, value));
            context.AddCommand(new RemoveFromCommand(stack, info, tag, structure, value));
            context.AddCommand(new CopyElementsCommand(stack, info, tag, structure, value));
            context.AddCommand(new PasteElementsCommand(stack, info, tag, structure, value));
            context.AddCommand(new SaveChangesCommand(info, tag, value));
            context.AddCommand(new ExitToCommand(stack));

            return context;
        }