Пример #1
0
        public DialogResult RenameTag(CachedTagInstance tag)
        {
            var result = DialogResult.OK;

            using (var rd = new RenameDialog(CacheContext, tag))
            {
                if ((result = rd.ShowDialog()) != DialogResult.OK)
                {
                    return(result);
                }

                if (rd.Value == "" && tag.Name != null)
                {
                    tag.Name = null;
                }
                else if (rd.Value != "")
                {
                    tag.Name = rd.Value;
                }
            }

            LoadTagTree();

            return(result);
        }
Пример #2
0
        private void SetModelName(Stream stream, CachedTagInstance tag, ref Dictionary <int, string> tagNames)
        {
            if (tag == null || tagNames.ContainsKey(tag.Index))
            {
                return;
            }

            var definition = GetTagDefinition <Model>(stream, tag);

            if (definition.RenderModel == null)
            {
                return;
            }

            SetRenderModelName(stream, definition.RenderModel, ref tagNames);

            var tagName = tagNames[definition.RenderModel.Index];

            if (tagName.StartsWith("0x"))
            {
                tagName = $"0x{tag.Index:X4}";
            }

            tagNames[tag.Index] = tagName;

            if (definition.CollisionModel != null && !tagName.StartsWith("0x"))
            {
                tagNames[definition.CollisionModel.Index] = $"{tagName}";
            }

            if (definition.Animation != null && !tagName.StartsWith("0x"))
            {
                tagNames[definition.Animation.Index] = $"{tagName}";
            }
        }
Пример #3
0
 private string GetTagTreeNodeImageKey(CachedTagInstance tag)
 {
     if (tag.IsInGroup("cfgt") || tag.IsInGroup("matg") || tag.IsInGroup("mulg") ||
         tag.IsInGroup("aigl") || tag.IsInGroup("smdt") ||
         tag.IsInGroup("inpg") || tag.IsInGroup("rasg") ||
         tag.IsInGroup("wezr") || tag.IsInGroup("wgtz") || tag.IsInGroup("wigl"))
     {
         return("file_settings");
     }
     if (tag.IsInGroup("jmad"))
     {
         return("file_animation");
     }
     else if (tag.IsInGroup("bitm"))
     {
         return("file_bitmap");
     }
     else if (tag.IsInGroup("snd!") || tag.IsInGroup("lsnd"))
     {
         return("file_sound");
     }
     else
     {
         return("file");
     }
 }
Пример #4
0
 private void Add(CachedTagInstance tag)
 {
     if (tag != null)
     {
         Tags.Add(BlamCache.GetIndexItemFromID(tag.Index));
     }
 }
Пример #5
0
 private void closeAllTagsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     currentTagsComboBox.Items.Clear();
     tagEditorPanel.Controls.Clear();
     CurrentTags.Clear();
     CurrentTag = null;
 }
Пример #6
0
 public SoundControl(HaloOnlineCacheContext cacheContext, CachedTagInstance tagInstance, Sound sound) :
     this()
 {
     CacheContext = cacheContext;
     TagInstance  = tagInstance;
     Sound        = sound;
     SoundFile    = new FileInfo(Path.Combine(Application.StartupPath, "temp", $"{TagInstance.Index:X4}.mp3"));
 }
Пример #7
0
 public StructMultiControl(CacheForm form, HaloOnlineCacheContext cacheContext, CachedTagInstance tagInstance, object definition) :
     this()
 {
     Form         = form;
     CacheContext = cacheContext;
     TagInstance  = tagInstance;
     Definition   = definition;
 }
Пример #8
0
        private void SetRenderModelName(Stream stream, CachedTagInstance tag, ref Dictionary <int, string> tagNames)
        {
            if (tagNames.ContainsKey(tag.Index))
            {
                return;
            }

            tagNames[tag.Index] = $"{CacheContext.GetString(GetTagDefinition<RenderModel>(stream, tag).Name)}";
        }
Пример #9
0
        private Dialogue ConvertDialogue(Stream cacheStream, Dialogue dialogue)
        {
            if (BlamSoundGestalt == null)
            {
                BlamSoundGestalt = PortingContextFactory.LoadSoundGestalt(CacheContext, ref BlamCache);
            }

            CachedTagInstance edAdlg = null;
            AiDialogueGlobals adlg   = null;

            foreach (var tag in CacheContext.TagCache.Index.FindAllInGroup("adlg"))
            {
                edAdlg = tag;
                break;
            }

            adlg = CacheContext.Deserialize <AiDialogueGlobals>(cacheStream, edAdlg);

            //Create empty udlg vocalization block and fill it with empty blocks matching adlg

            List <Dialogue.Vocalization> newVocalization = new List <Dialogue.Vocalization>();

            foreach (var vocalization in adlg.Vocalizations)
            {
                Dialogue.Vocalization block = new Dialogue.Vocalization
                {
                    Sound   = null,
                    Flags   = 0,
                    Unknown = 0,
                    Name    = vocalization.Name,
                };
                newVocalization.Add(block);
            }

            //Match the tags with the proper stringId

            for (int i = 0; i < 304; i++)
            {
                var vocalization = newVocalization[i];
                for (int j = 0; j < dialogue.Vocalizations.Count; j++)
                {
                    var vocalizationH3 = dialogue.Vocalizations[j];
                    if (CacheContext.StringIdCache.GetString(vocalization.Name).Equals(CacheContext.StringIdCache.GetString(vocalizationH3.Name)))
                    {
                        vocalization.Flags   = vocalizationH3.Flags;
                        vocalization.Unknown = vocalizationH3.Unknown;
                        vocalization.Sound   = vocalizationH3.Sound;
                        break;
                    }
                }
            }

            dialogue.Vocalizations = newVocalization;

            return(dialogue);
        }
Пример #10
0
        private static int CompareTags(CachedTagInstance lhs, CachedTagInstance rhs)
        {
            var classCompare = lhs.Group.Tag.CompareTo(rhs.Group.Tag);

            if (classCompare != 0)
            {
                return(classCompare);
            }
            return(lhs.Index.CompareTo(rhs.Index));
        }
Пример #11
0
        private MapFile GenerateMapFile(CachedTagInstance scenarioTag, Blf mapInfo = null)
        {
            MapFile  map    = new MapFile();
            var      header = new MapFileHeader();
            Scenario scnr;

            using (var stream = CacheContext.OpenTagCacheRead())
            {
                var deserializer = new TagDeserializer(CacheContext.Version);
                scnr = (Scenario)CacheContext.Deserialize(stream, scenarioTag);
            }

            map.Version      = CacheContext.Version;
            map.EndianFormat = EndianFormat.LittleEndian;
            map.MapVersion   = MapFileVersion.HaloOnline;

            header.HeadTag = new Tag("head");
            header.FootTag = new Tag("foot");
            header.Version = (int)map.MapVersion;
            header.Build   = CacheVersionDetection.GetBuildName(CacheContext.Version);

            switch (scnr.MapType)
            {
            case ScenarioMapType.MainMenu:
                header.CacheType = CacheFileType.MainMenu;
                break;

            case ScenarioMapType.SinglePlayer:
                header.CacheType = CacheFileType.Campaign;
                break;

            case ScenarioMapType.Multiplayer:
                header.CacheType = CacheFileType.Multiplayer;
                break;
            }
            header.SharedType = CacheFileSharedType.None;

            header.MapId            = scnr.MapId;
            header.ScenarioTagIndex = scenarioTag.Index;
            header.Name             = scenarioTag.Name.Split('\\').Last();
            header.ScenarioPath     = scenarioTag.Name;

            map.Header = header;

            header.FileLength = 0x3390;

            if (mapInfo != null)
            {
                if (mapInfo.ContentFlags.HasFlag(BlfFileContentFlags.StartOfFile) && mapInfo.ContentFlags.HasFlag(BlfFileContentFlags.EndOfFile) && mapInfo.ContentFlags.HasFlag(BlfFileContentFlags.Scenario))
                {
                    map.MapFileBlf = mapInfo;
                }
            }
            return(map);
        }
        public GenerateRenderMethodTemplate(GameCacheContext cacheContext, CachedTagInstance tag, RenderMethodTemplate definition) :
            base(true,

                 "Generate",
                 "Compiles HLSL source file from scratch :D",
                 "Generate <shader_type> <parameters...>",
                 "Compiles HLSL source file from scratch :D")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #13
0
        public GenerateShader(GameCacheContext cacheContext, CachedTagInstance tag, T definition) :
            base(true,

                 "Generate",
                 "Compiles HLSL source file from scratch :D",
                 "Generate <index> <shader_type> <drawmode> <parameters...>",
                 "Compiles HLSL source file from scratch :D")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
        private ScenarioLightmap ConvertScenarioLightmap(Stream cacheStream, Dictionary <ResourceLocation, Stream> resourceStreams, string blamTagName, ScenarioLightmap scenarioLightmap)
        {
            if (BlamCache.Version > CacheVersion.Halo3Retail)
            {
                return(scenarioLightmap);
            }

            scenarioLightmap.LightmapDataReferences = new List <ScenarioLightmap.LightmapDataReference>();

            foreach (var entry in scenarioLightmap.Lightmaps)
            {
                var wasReplacing = FlagIsSet(PortingFlags.Replace);

                RemoveFlags(PortingFlags.Replace);
                var Lbsp = ConvertStructure(cacheStream, resourceStreams, entry, scenarioLightmap, blamTagName);
                if (wasReplacing)
                {
                    SetFlags(PortingFlags.Replace);
                }

                Lbsp.Airprobes = new List <ScenarioLightmap.Airprobe>();
                Lbsp.Airprobes.AddRange(scenarioLightmap.Airprobes);

                CachedTagInstance edTag   = null;
                TagGroup          edGroup = null;

                var groupTag = new Tag("Lbsp");

                if (TagGroup.Instances.ContainsKey(groupTag))
                {
                    edGroup = TagGroup.Instances[groupTag];
                }
                else
                {
                    edGroup = new TagGroup(groupTag, Tag.Null, Tag.Null, CacheContext.GetStringId("scenario_lightmap_bsp_data"));
                }

                edTag      = CacheContext.TagCache.AllocateTag(edGroup);
                edTag.Name = blamTagName + "_data";

                CacheContext.Serialize(cacheStream, edTag, Lbsp);

                scenarioLightmap.LightmapDataReferences.Add(new ScenarioLightmap.LightmapDataReference
                {
                    LightmapData = edTag
                });
            }

            scenarioLightmap.Airprobes.Clear();

            return(scenarioLightmap);
        }
Пример #15
0
        private bool ExecuteAddRemove(CachedTagInstance tag, List <string> args)
        {
            if (args.Count < 3)
            {
                return(false);
            }

            var dependencies = args.Skip(2).Select(name => CacheContext.GetTag(name)).ToList();

            if (dependencies.Count == 0 || dependencies.Any(d => d == null))
            {
                return(false);
            }

            using (var stream = CacheContext.OpenTagCacheReadWrite())
            {
                var data = CacheContext.TagCache.ExtractTag(stream, tag);

                if (args[0].ToLower() == "add")
                {
                    foreach (var dependency in dependencies)
                    {
                        if (data.Dependencies.Add(dependency.Index))
                        {
                            Console.WriteLine("Added dependency on tag {0:X8}.", dependency.Index);
                        }
                        else
                        {
                            Console.Error.WriteLine("Tag {0:X8} already depends on tag {1:X8}.", tag.Index, dependency.Index);
                        }
                    }
                }
                else
                {
                    foreach (var dependency in dependencies)
                    {
                        if (data.Dependencies.Remove(dependency.Index))
                        {
                            Console.WriteLine("Removed dependency on tag {0:X8}.", dependency.Index);
                        }
                        else
                        {
                            Console.Error.WriteLine("Tag {0:X8} does not depend on tag {1:X8}.", tag.Index, dependency.Index);
                        }
                    }
                }

                CacheContext.TagCache.SetTagData(stream, tag, data);
            }

            return(true);
        }
Пример #16
0
        public ExportSoundCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Sound definition) :
            base(true,

                 "ExportSound",
                 "Export snd! data to a file",

                 "ExportSound <Path>",
                 "")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #17
0
        public ImportSoundCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Sound definition) :
            base(true,

                 "ImportSound",
                 "Import a MP3 file into the current snd! tag. See documentation for formatting and options.",

                 "ImportSound <Sound File>",
                 "")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #18
0
        public ReplaceAllFilesCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, VFilesList definition)
            : base(false,

                   "ReplaceAllFiles",
                   "Replace all files stored in the tag.",

                   "ReplaceAllFiles <directory>",
                   "Replaces all file stored in the tag. The tag will be resized as necessary.")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #19
0
 public MultiplayerScenarioFixup(
     Stream cacheStream, HaloOnlineCacheContext cacheContext, string scenarioTagName, int desiredZoneSetIndex,
     BspFlags desiredBsps, MultiplayerScenarioConversionFlags conversionFlags)
 {
     this.CacheContext        = cacheContext;
     this.CacheStream         = cacheStream;
     this.ScnrTag             = cacheContext.GetTag <Scenario>(scenarioTagName);
     this.Scnr                = cacheContext.Deserialize <Scenario>(new TagSerializationContext(cacheStream, cacheContext, this.ScnrTag));
     this.DesiredZoneSetIndex = desiredZoneSetIndex;
     this.DesiredBsps         = desiredBsps;
     this.ConversionFlags     = conversionFlags;
     this.BspIndexRemapping   = new Dictionary <int, int>();
 }
Пример #20
0
        public ImportSoundCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Sound definition) :
            base(true,

                 "ImportSound",
                 "Import one (or many) sound files into the current snd! tag. Overwrites existing sound data. See documentation for formatting and options.",

                 "ImportSound",
                 "")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #21
0
        private bool ExecuteListDependsOn(CachedTagInstance tag)
        {
            var dependsOn = CacheContext.TagCache.Index.NonNull().Where(t => t.Dependencies.Contains(tag.Index));

            foreach (var dependency in dependsOn)
            {
                var tagName = dependency?.Name ?? $"0x{dependency.Index:X4}";

                Console.WriteLine($"[Index: 0x{dependency.Index:X4}, Offset: 0x{dependency.HeaderOffset:X8}, Size: 0x{dependency.TotalSize:X4}] {tagName}.{CacheContext.GetString(dependency.Group.Name)}");
            }

            return(true);
        }
Пример #22
0
        string TagName(CachedTagInstance tag)
        {
            if (tag == null)
            {
                return("null");
            }
            if (tag.Name == null || tag.Name.Length < 1)
            {
                return(tag.ToString());
            }

            return($"{tag.Name}.{tag.Group}");
        }
Пример #23
0
        public ExtractScriptsCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Scenario definition)
            : base(true,

                   "ExtractScripts",
                   "Extracts all scripts in the current scenario tag to a file.",

                   "ExtractScripts <Output File>",

                   "Extracts all scripts in the current scenario tag to a file.")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #24
0
        public GetResourceInfoCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, RenderModel definition)
            : base(false,

                   "GetResourceInfo",
                   "Gets information about the render_model's resource.",

                   "GetResourceInfo",

                   "Gets information about the render_model's resource.")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #25
0
        public ParseItemsXmlCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance instance, ForgeGlobalsDefinition definition) :
            base(true,

                 "ParseItemsXml",
                 "",

                 "ParseItemsXml <File>",

                 "")
        {
            CacheContext = cacheContext;
            Instance     = instance;
            Definition   = definition;
        }
Пример #26
0
        public RemoveStringCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, MultilingualUnicodeStringList definition) :
            base(false,

                 "RemoveString",
                 "Removes a string entry from the multilingual_unicode_string_list definition.",

                 "RemoveString <StringID>",

                 "Removes a string entry from the multilingual_unicode_string_list definition.")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #27
0
        public GetStringCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, MultilingualUnicodeStringList unic)
            : base(true,

                   "GetString",
                   "Gets the value of a string.",

                   "GetString <language> <string_id>",

                   "Gets the value of a string.")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = unic;
        }
Пример #28
0
        public AddFileCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, VFilesList definition) :
            base(true,

                 "AddFile",
                 "Adds a new file to the virtual files list.",

                 "AddFile <folder> <path>",

                 "Adds a new file to the virtual files list.")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #29
0
        public ReplaceFileCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, VFilesList definition)
            : base(false,

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

                   "ReplaceFile <virtual path> [filename]",

                   "Replaces a file stored in the tag. The tag will be resized as necessary.")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Definition   = definition;
        }
Пример #30
0
        public SaveTagChangesCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, object value)
            : base(true,

                   "SaveTagChanges",
                   $"Saves changes made to the current {cacheContext.GetString(tag.Group.Name)} definition.",

                   "SaveTagChanges",

                   $"Saves changes made to the current {cacheContext.GetString(tag.Group.Name)} definition.")
        {
            CacheContext = cacheContext;
            Tag          = tag;
            Value        = value;
        }