public uiIdentSwapper(uiIdent ident, int ID, string Text) { texT = Text; InitializeComponent(); IDENTIFIER = ID; Ident_UI = ident; tagNameList = new TagNameList(string.Format("{0}\\Tag Lists\\{1}.taglist", (object)Application.StartupPath, (object)ident.HMap.Map_Header.internalName)); ident.HMap.tagNameList = tagNameList; ident.HMap.LoadTagsIntoTreeview(treeView1, false); int tagIndexByIdent = ident.HMap.GetTagIndexByIdent(IDENTIFIER); if (tagIndexByIdent == -1) { return; } HaloMap.TagItem indexItem = ident.HMap.Index_Items[tagIndexByIdent]; for (int index1 = 0; index1 < treeView1.Nodes.Count; ++index1) { if (treeView1.Nodes[index1].Tag.ToString() == indexItem.Class) { for (int index2 = 0; index2 < treeView1.Nodes[index1].Nodes.Count; ++index2) { if (treeView1.Nodes[index1].Nodes[index2].Text.Contains(texT)) { treeView1.SelectedNode = treeView1.Nodes[index1].Nodes[index2]; break; } } break; } } }
/// <summary> /// This function loads the UI and sets the meta instance. /// </summary> /// <param name="meta">The meta instance to set and swap.</param> public SwapTagHeader(HaloMap.TagItem meta) { //Initialize our component. InitializeComponent(); //Set our meta instance Meta = meta; //Loop through our tag hierarchy classes foreach (TagHierarchy.TagHClass TClass in Meta.Map.TagHierarchy.TagClasses) { //If this is our tagclass we're looking for. if (TClass.TagClass == Meta.Class) { //Loop for each meta foreach (TagHierarchy.TagHName TName in TClass.Tags) { //Add our tagname to the combobox. comboBoxEx1.Items.Add(TName.TagName); } } } //Sort our combobox comboBoxEx1.Sorted = true; //Select our first item comboBoxEx1.SelectedIndex = 0; }
/// <summary> /// This form of initializing loads the RawPools. /// </summary> /// <param name="Map">The map to load the raw pools for</param> public RawPoolsList(HaloMap Map) { //Create our variable to hold the play index int playIndex = -1; for (int i = 0; i < Map.IndexItems.Count; i++) { if (Map.IndexItems[i].Class == "play") { playIndex = i; break; } } //If we found the play tag.. if (playIndex != -1) { //Obtain the tag instance of the play tag HaloMap.TagItem play_tag = Map.IndexItems[playIndex]; //Go to the tag offset + 24 Map.IO.In.BaseStream.Position = play_tag.Offset + 24; int poolCount = Map.IO.In.ReadInt32(); int poolPointer = Map.IO.In.ReadInt32() - Map.MapHeader.mapMagic; //Loop for each chunk for (int i = 0; i < poolCount; i++) { //Initialize our chunk RawPool rawPool = new RawPool(); //Set our offset of our raw pool. rawPool.ChunkOffset = poolPointer + (i * 88); //Go to the chunk location. Map.IO.In.BaseStream.Position = poolPointer + (i * 88); Map.IO.In.BaseStream.Position += 4; //Read our external map index. rawPool.ExternalMapIndex = Map.IO.In.ReadInt16(); //Go to our raw offset value's offset Map.IO.In.BaseStream.Position += 2; rawPool.RawOffset = Map.IO.In.ReadUInt32(); rawPool.CompressedSize = Map.IO.In.ReadUInt32(); rawPool.DecompressedSize = Map.IO.In.ReadUInt32(); //Go to our raw chunk count offset Map.IO.In.BaseStream.Position = poolPointer + (i * 88) + 84; rawPool.RawChunkCount = Map.IO.In.ReadInt16(); //Add it to our list this.Add(rawPool); } } }
public MetaHeader_DataBlock(HaloMap.TagItem tag) { base.Reflexive_Data_Blocks = new List <PluginLayoutCreator.Reflexive_DataBlock>(); base.Tag_Idents = new List <PluginLayoutCreator.Tag_Ident>(); base.Tag_Voids = new List <PluginLayoutCreator.Tag_Void>(); base.Data_Block_Type = PluginLayoutCreator.PluginDataBlock.DataBlockType.Meta_Header; base.Count = 1; base.Pointer = tag.Offset; Tag_Class = tag.Class; }
private void documentContainer1_ActiveDocumentChanged(object sender, ActiveDocumentEventArgs e) { //Try to parse the tag as an integer. try { int.Parse(documentContainer1.ActiveDocument.Tag.ToString()); } //Return if we catch an error catch { return; } //Set our changing status ChangingTab = true; //Get our index item HaloMap.TagItem tabbedTag = Map.IndexItems[int.Parse(documentContainer1.ActiveDocument.Tag.ToString())]; //Loop through all treenodes for (int i = 0; i < tvMetaTree.Nodes.Count; i++) { //If it's class is that of this tag if (tvMetaTree.Nodes[i].Tag.ToString() == tabbedTag.Class) { //Loop through all child nodes for (int z = 0; z < tvMetaTree.Nodes[i].Nodes.Count; z++) { //If it's name is that of this tag if (tvMetaTree.Nodes[i].Nodes[z].Text == tabbedTag.Name) { //Select that tag tvMetaTree.SelectedNode = tvMetaTree.Nodes[i].Nodes[z]; //Break out of this loop of code break; } } //Break out of this block of code break; } } //Set our changing status ChangingTab = false; }
private void buttonX1_Click(object sender, EventArgs e) { string fileName = AppSettings.Settings.PluginPath + Meta.Class.Replace(" ", "").Replace("<", "_").Replace(">", "_") + ".asc"; XmlParser parser = new XmlParser(); parser.ParsePlugin(fileName); int headerSize = parser.HeaderSize; HaloMap.TagItem item = Meta.Map.Index_Items[Meta.Map.GetTagIndexByClassAndName(Meta.Class, comboBox1.Text)]; Meta.Map.OpenIO(); Meta.Map.IO.In.BaseStream.Position = item.Offset; byte[] buffer = Meta.Map.IO.In.ReadBytes(headerSize); Meta.Map.IO.Out.BaseStream.Position = Meta.Offset; Meta.Map.IO.Out.Write(buffer); Meta.Map.CloseIO(); base.Close(); OutputMessenger.OutputMessage("Tag header successfully swapped to: \"" + Meta.Name + "." + Meta.Class + "\"", (Control)form); }
public SwapTagHeader(HaloMap.TagItem meta, MapForm mf) { InitializeComponent(); Meta = meta; form = mf; foreach (TagHierarchy.TagHClass class2 in Meta.Map.Tag_Hierarchy.TagClasses) { if (class2.TagClass == Meta.Class) { foreach (TagHierarchy.TagHName name in class2.Tags) { comboBox1.Items.Add(name.TagName); } } } comboBox1.Sorted = true; comboBox1.SelectedIndex = 0; }
public MetaHeader_DataBlock(HaloMap.TagItem tag) { //Initialize our list Reflexive_Data_Blocks = new List <Reflexive_DataBlock>(); Tag_Idents = new List <Tag_Ident>(); //Set the type Data_Block_Type = DataBlockType.Meta_Header; //Set our count as 1 Count = 1; //Set our pointer Pointer = tag.Offset; //Set our class Tag_Class = tag.Class; }
/// <summary> /// This form of initializing loads the raw locations. /// </summary> /// <param name="Map">The map file to load from.</param> public RawLocationsList(HaloMap Map) { //Create our variable to hold the play index int playIndex = -1; for (int i = 0; i < Map.IndexItems.Count; i++) { if (Map.IndexItems[i].Class == "play") { playIndex = i; break; } } //If we found the play tag.. if (playIndex != -1) { //Obtain the tag instance of the play tag HaloMap.TagItem play_tag = Map.IndexItems[playIndex]; //Go to the tag offset + 48 Map.IO.In.BaseStream.Position = play_tag.Offset + 48; int locationsCount = Map.IO.In.ReadInt32(); int locationsPointer = Map.IO.In.ReadInt32() - Map.MapHeader.mapMagic; //Loop for each chunk for (int i = 0; i < locationsCount; i++) { //Initialize our chunk RawLocation rawLoc = new RawLocation(); //Go to the chunk location. Map.IO.In.BaseStream.Position = locationsPointer + (i * 16); //Read our raw pool indexes rawLoc.RawPoolIndexMultiple = Map.IO.In.ReadInt16(); rawLoc.RawPoolIndexSingle = Map.IO.In.ReadInt16(); rawLoc.OffsetOfRawInPool = Map.IO.In.ReadUInt32(); //Add it to our list this.Add(rawLoc); } } }
private void buttonX1_Click(object sender, EventArgs e) { //Get our plugin path. string pluginPath = Application.StartupPath + "\\plugins\\" + Meta.Class.Replace(" ", "").Replace("<", "_").Replace(">", "_") + ".alt"; //Get our header size XmlParser xmlparser = new XmlParser(); //Parse our plugin xmlparser.ParsePlugin(pluginPath); //Get our headersize int HeaderSize = xmlparser.HeaderSize; //Get our meta for our tag to swap to HaloMap.TagItem Meta_To_Swap_To = Meta.Map.IndexItems[Meta.Map.GetTagIndexByClassAndName(Meta.Class, comboBoxEx1.Text)]; //Open our map IO Meta.Map.OpenIO(); //Go to our meta to swap to Meta.Map.IO.In.BaseStream.Position = Meta_To_Swap_To.Offset; //Read our bytes byte[] meta_header = Meta.Map.IO.In.ReadBytes(HeaderSize); //Go to our meta header for our tag to overwrite Meta.Map.IO.Out.BaseStream.Position = Meta.Offset; //Write our meta_header. Meta.Map.IO.Out.Write(meta_header); //Close our map IO Meta.Map.CloseIO(); //Close our dialog. this.Close(); //Show our messagebox MessageBox.Show("Done."); }
/// <summary> /// This form of initialization loads the external maps. /// </summary> /// <param name="Map">The map instance to read external map paths from.</param> public ExternalMapsList(HaloMap Map) { map = Map; //Create our variable to hold the play index int playIndex = -1; for (int i = 0; i < Map.IndexItems.Count; i++) { if (Map.IndexItems[i].Class == "play") { playIndex = i; break; } } //If we found the play tag.. if (playIndex != -1) { //Obtain the tag instance of the play tag HaloMap.TagItem play_tag = Map.IndexItems[playIndex]; //Go to the tag offset + 12 Map.IO.In.BaseStream.Position = play_tag.Offset + 12; int externCount = Map.IO.In.ReadInt32(); int externPointer = Map.IO.In.ReadInt32() - Map.MapHeader.mapMagic; //Loop for each chunk for (int i = 0; i < externCount; i++) { //Initialize our external chunk ExternalMap externMap = new ExternalMap(); //Go to the map string reference location Map.IO.In.BaseStream.Position = externPointer + (i * 264); externMap.MapReference = Map.IO.In.ReadAsciiString(32); //Add it to our list this.Add(externMap); } } }
public Unknown3s(HaloMap Map) { //Create our variable to hold the play index int playIndex = -1; for (int i = 0; i < Map.IndexItems.Count; i++) { if (Map.IndexItems[i].Class == "play") { playIndex = i; break; } } //If we found the play tag.. if (playIndex != -1) { //Obtain the tag instance of the play tag HaloMap.TagItem play_tag = Map.IndexItems[playIndex]; //Go to the tag offset + 48 Map.IO.In.BaseStream.Position = play_tag.Offset + 36; int locationsCount = Map.IO.In.ReadInt32(); int locationsPointer = Map.IO.In.ReadInt32() - Map.MapHeader.mapMagic; //Loop for each chunk for (int i = 0; i < locationsCount; i++) { //Initialize our chunk Unknown3 unkn = new Unknown3(); //Go to the chunk location. Map.IO.In.BaseStream.Position = locationsPointer + (i * 16); unkn.unknownInt = Map.IO.In.ReadInt32(); //Add it to our list this.Add(unkn); } } }
/// <summary> /// This function renames a tag. /// </summary> /// <param name="tagIndex">The index of the tag to rename.</param> /// <param name="newName">The new name of the tag to rename as.</param> public void RenameTag(int tagIndex, string newName) { //Get our tag instance HaloMap.TagItem tagItem = map.IndexItems[tagIndex]; //Compare our string lengths.. if (tagItem.Name.Length == newName.Length) { //They are the same length. Let's write our new string. //Open our IO map.OpenIO(); //Go to our tag_name_index_entry map.IO.In.BaseStream.Position = map.MapHeader.fileTableIndexOffset + (tagIndex * 4); //Read our tagnameoffset int tagNameOffset = map.IO.In.ReadInt32() + map.MapHeader.fileTableOffset; //Go to this position map.IO.In.BaseStream.Position = tagNameOffset; //Write our tagname map.IO.Out.WriteAsciiString(newName, tagItem.Name.Length); //Close our IO map.CloseIO(); //Set our tagname. map.IndexItems[tagIndex].Name = newName; } else { //Calculate our table difference. int differenceInStringLength = (tagItem.Name.Length - newName.Length); int newTableSizeUnpadded = map.MapHeader.fileTableSize - differenceInStringLength; int newTableSize = newTableSizeUnpadded + ExtraFunctions.CalculatePadding(newTableSizeUnpadded, 0x1000); int oldTableSize = map.MapHeader.fileTableSize + ExtraFunctions.CalculatePadding(map.MapHeader.fileTableSize, 0x1000); int differenceInSize = oldTableSize - newTableSize; //Open our IO map.OpenIO(); //Go to our tag_name_index_entry map.IO.In.BaseStream.Position = map.MapHeader.fileTableIndexOffset + (tagIndex * 4); //Read our tagnameoffset int tagNameOffset = map.IO.In.ReadInt32() + map.MapHeader.fileTableOffset; //Loop for each tag_name_index after it. for (int i = tagIndex + 1; i < map.IndexHeader.tagCount; i++) { //Go to our tag_name_index_entry map.IO.In.BaseStream.Position = map.MapHeader.fileTableIndexOffset + (i * 4); //Read our tagindex int tagOff = map.IO.In.ReadInt32(); //Recalculate it. tagOff -= differenceInStringLength; //Go to our tag_name_index_entry map.IO.Out.BaseStream.Position = map.MapHeader.fileTableIndexOffset + (i * 4); //Write it map.IO.Out.Write(tagOff); } //Close our IO map.CloseIO(); //If it's any different. if (differenceInSize > 0) { ExtraFunctions.DeleteBytes(map.FileName, map.MapHeader.fileTableOffset + newTableSize, oldTableSize - newTableSize); } else { ExtraFunctions.InsertBytes(map.FileName, map.MapHeader.fileTableOffset + oldTableSize, newTableSize - oldTableSize); } //Open our IO map.OpenIO(); //Go to this position map.IO.Out.BaseStream.Position = tagNameOffset; //Write our tagname map.IO.Out.WriteAsciiString(newName, newName.Length); map.IO.Out.Write((byte)0); for (int i = tagIndex + 1; i < map.IndexHeader.tagCount; i++) { //Write the tagname map.IO.Out.WriteAsciiString(map.IndexItems[i].Name, map.IndexItems[i].Name.Length); map.IO.Out.Write((byte)0); } //For the rest of our table, write the padding. byte[] padding = new byte[newTableSize - newTableSizeUnpadded]; //Write our padding map.IO.Out.Write(padding); //Recalculate some header values. map.IO.Out.BaseStream.Position = 20; map.IO.Out.Write(((map.MapHeader.virtSegmentStart - differenceInSize) + map.MapHeader.headerMagic)); map.IO.Out.BaseStream.Position = 700; map.IO.Out.Write(newTableSizeUnpadded); map.IO.Out.BaseStream.Position = 704; map.IO.Out.Write(((map.MapHeader.fileTableIndexOffset - differenceInSize) + map.MapHeader.headerMagic)); map.IO.Out.BaseStream.Position = 1136; map.IO.Out.Write((map.MapHeader.RawTableOffset - differenceInSize)); map.IO.Out.BaseStream.Position = 1144; map.IO.Out.Write((map.MapHeader.localeTableAddressModifier - differenceInSize)); //Close our IO map.CloseIO(); //Reload our map map.Reload(); } }
private void LoadSelectedPallete() { //If we have an item selected if (tvTagReferences.SelectedNode != null) { //If the item has a tag if (tvTagReferences.SelectedNode.Tag != null) { //If its not a tagclass parent node if (tvTagReferences.SelectedNode.Tag.ToString() != "ParentClassNode") { //Get the index for the tag int palleteIndex = (int)tvTagReferences.SelectedNode.Tag; #region Tag Ident //Get our tag index int tagIndex = Map.GetTagIndexByIdent(Usermap.Pallette_Blocks[palleteIndex].Tag_Ident); //If our tagIndex isnt -1 if (tagIndex != -1) { //Get our tag item instance HaloMap.TagItem tagItem = Map.IndexItems[tagIndex]; //Select our class SelectItem(cmbxTagClass, tagItem.Class); //Select our tagName SelectItem(cmbxTagName, tagItem.Name); } //Otherwise.. else { //Select our first item. cmbxTagClass.SelectedIndex = 0; } #endregion #region Pallete Values //Set our runtimes text. txtRuntimeMinimum.Text = Usermap.Pallette_Blocks[palleteIndex].Run_Time_Minimum.ToString(); txtRuntimeMaximum.Text = Usermap.Pallette_Blocks[palleteIndex].Run_Time_Maximum.ToString(); //Set our total cost txtTotalCost.Text = Usermap.Pallette_Blocks[palleteIndex].Total_Cost.ToString(); #endregion #region Load Our Placements Into the Combobox //Clear our combobox items cmbxPlacementChunk.Items.Clear(); cmbxPlacementChunk.Text = ""; //Disable our gpnl for placements gpnlPlacements.Enabled = false; //If our tagIndex isnt -1 if (palleteIndex != -1) { //Get our currently selected pallete block Selected_Block = Usermap.Pallette_Blocks[palleteIndex]; //Loop for each placement for (int i = 0; i < Selected_Block.Placement_Blocks.Count; i++) { //Add our chunk item. cmbxPlacementChunk.Items.Add(i + " : Chunk"); } //If we have any items if (cmbxPlacementChunk.Items.Count > 0) { //Select the first item. cmbxPlacementChunk.SelectedIndex = 0; //Enable our gpnl for placements gpnlPlacements.Enabled = true; } } #endregion } } } }