/// <summary> /// The load meta. /// </summary> /// <param name="tag">The tag.</param> /// <remarks></remarks> public void LoadMeta(int tag) { Meta meta = Map.GetMetaFromTagIndex(tag, map, scanbspwithifp.Checked, parsedCheckBox.Checked); map.SelectedMeta = meta; buttonInternalize.Visible = false; if (meta.type == "bitm") { // ;&&Map.HaloVersion!= Map.HaloVersionEnum.Halo1 ) ParsedBitmap pm = new ParsedBitmap(ref meta, map); Bitmap b = pm.FindChunkAndDecode(0, 0, 0, ref meta, map, 0, 0); // Raw.ParsedBitmap.BitmapInfo bmInfo = new Entity.Raw.ParsedBitmap.BitmapInfo(pm.Properties[0].formatname, pm.Properties[0].swizzle); // b = DDS_Convert.DecodeDDS( DDS_Convert.EncodeDDS(b, ref bmInfo), bmInfo ); pictureBox1.Image = b; pictureBox1.Tag = 0; statusbar.Text = pm.Properties[0].width.ToString().PadLeft(4) + " X " + pm.Properties[0].height.ToString().PadRight(4) + " " + ("(" + pm.Properties[0].typename.ToString().Remove(0, 10) + ") ").PadRight(10) + pm.Properties[0].formatname.ToString().Remove(0, 12).PadRight(10) + " - Swizzle:" + pm.Properties[0].swizzle + "- Location: " + meta.raw.rawChunks[0].rawLocation; if (meta.raw.rawChunks[0].rawLocation != MapTypes.Internal) { buttonInternalize.Visible = true; } timer1.Start(); } else { statusbar.Text = string.Empty; } // Main Form Offsets/Idents/etc metaOffsetBox.Text = "0x" + meta.offset.ToString("X8") + "\n" + meta.offset.ToString("N0") + " bytes"; metaSizeBox.Text = "0x" + meta.size.ToString("X4") + "\n" + meta.size.ToString("N0") + " bytes"; metaIdentBox.Text = meta.ident.ToString("X"); metaTypeBox.Text = meta.type; if (meta.raw != null) { int tempRawSize = 0; for (int i = 0; i < meta.raw.rawChunks.Count; i++) { tempRawSize += meta.raw.rawChunks[i].size; } metaRawBox.Text = "0x" + tempRawSize.ToString("X4") + "\n" + tempRawSize.ToString("N0") + " bytes"; } else metaRawBox.Text = "n/a"; switch (meta.type) { case "PRTM": rawDataDropDown.DropDown = prtmcontext; rawDataDropDown.Enabled = true; break; case "mode": case "mod2": rawDataDropDown.DropDown = ModelContextStrip; rawDataDropDown.Enabled = true; break; case "bitm": rawDataDropDown.DropDown = BitmapContextStrip; rawDataDropDown.Enabled = true; if (ltmpTools.Visible) { bitmapEditorToolStripMenuItem_Click(bitmapEditorToolStripMenuItem, null); } break; case "sbsp": rawDataDropDown.DropDown = BSPcontextMenu; rawDataDropDown.Enabled = true; break; case "coll": rawDataDropDown.DropDown = collContextMenu; rawDataDropDown.Enabled = true; break; default: rawDataDropDown.Enabled = false; break; } switch (getEditorMode()) { case EditorModes.HexViewer: hexView1.Reload(meta, map); hexView1.Setup(map.filePath); break; case EditorModes.MetaEditor1: if (map.SelectedMeta != null) { if (this.metaEditor1.selectedTagType == map.SelectedMeta.type) { this.metaEditor1.ReloadMetaForSameTagType(true); } else { this.metaEditor1.loadControls(map); } } break; case EditorModes.MetaEditor2: if (map.SelectedMeta != null) { if (wME == null || wME.IsDisposed) { wME = new entity.MetaEditor2.WinMetaEditor(this, map); wME.BackgroundColor = this.LibraryPanel.BackColor; wME.ForegroundColor = this.LibraryPanel.ForeColor; wME.TopLevel = false; this.MetaEditor2Panel.Controls.Add(wME); MetaEditor2Panel.BringToFront(); wME.FormBorderStyle = FormBorderStyle.None; wME.FormClosed += new FormClosedEventHandler(wME_FormClosed); } // If we are not switching from a different editor mode (on MetaEditor2) and // we already have the current tag loaded in the editor, then we can load a duplicate wME.addNewTab(map.SelectedMeta, getEditorMode() == EditorModes.MetaEditor2 && wME.tabs.Tabs.Count > 0 && wME.tabs.SelectedTab.Text == ("[" + map.SelectedMeta.type + "] " + map.SelectedMeta.name.Substring(map.SelectedMeta.name.LastIndexOf('\\') + 1))); wME.Dock = DockStyle.Fill; } break; case EditorModes.ReferenceEditor: formFuncs.AddReferencesToListView(meta, references, map.DisplayType); break; } if (selectedplugin != -1 && LibraryPanel.Visible) { if (plugins.Plugin[selectedplugin].tagtype == meta.type || plugins.Plugin[selectedplugin].tagtype == "!*.*") { plugins.Plugin[selectedplugin].Run(map, ref progressbar); } } UpdatePluginsMenu(); Prefs.Save(); AddToHistory(tag); }
/// <summary> /// Opens a form displaying header information and allows it to be edited /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void editHeaderButton_Click(object sender, EventArgs e) { // Create a dummy meta with the header info in it. Meta headerMeta = new Meta(map); #region Dummy meta info headerMeta.ident = 0; headerMeta.name = "Header"; headerMeta.offset = 0; headerMeta.size = 2048; headerMeta.TagIndex = 99999; headerMeta.type = "HEAD"; map.OpenMap(MapTypes.Internal); map.BR.BaseStream.Position = headerMeta.offset; headerMeta.MS = new MemoryStream(headerMeta.size); headerMeta.MS.Write(map.BR.ReadBytes(headerMeta.size), 0, headerMeta.size); map.CloseMap(); #endregion IFPHashMap.RemoveIfp("HEAD", map); IFPIO ifp = IFPHashMap.GetIfp("HEAD", map.HaloVersion); // New selected meta points to header Meta backupMeta = map.SelectedMeta; map.SelectedMeta = headerMeta; // Create a Meta Editor 2 form if it doesn't exist if (wME == null || wME.IsDisposed) { wME = new entity.MetaEditor2.WinMetaEditor(this, map); wME.BackgroundColor = this.LibraryPanel.BackColor; wME.ForegroundColor = this.LibraryPanel.ForeColor; wME.TopLevel = false; this.MetaEditor2Panel.Controls.Add(wME); MetaEditor2Panel.BringToFront(); wME.FormBorderStyle = FormBorderStyle.None; wME.FormClosed += new FormClosedEventHandler(wME_FormClosed); } // Create a new tab for the header meta wME.addNewTab(map.SelectedMeta, false); MetaEditor2Panel.Tag = null; wME.Dock = DockStyle.Fill; wME.BringToFront(); map.SelectedMeta = backupMeta; }