public NSFBox(NSF nsf,GameVersion gameversion) { this.nsf = nsf; this.controller = new NSFController(nsf,gameversion); this.searchresults = new List<TreeNode>(); controller.Node.Expand(); trvMain = new TreeView(); trvMain.Dock = DockStyle.Fill; trvMain.ImageList = imglist; trvMain.HideSelection = false; trvMain.Nodes.Add(controller.Node); trvMain.SelectedNode = controller.Node; trvMain.AllowDrop = true; trvMain.AfterSelect += new TreeViewEventHandler(trvMain_AfterSelect); trvMain.ItemDrag += new ItemDragEventHandler(trvMain_ItemDrag); trvMain.DragOver += new DragEventHandler(trvMain_DragOver); trvMain.DragDrop += new DragEventHandler(trvMain_DragDrop); pnSplit = new SplitContainer(); pnSplit.Dock = DockStyle.Fill; pnSplit.Panel1.Controls.Add(trvMain); this.Controls.Add(pnSplit); }
public NSFController(NSF nsf,GameVersion gameversion) { this.nsf = nsf; this.gameversion = gameversion; Node.Text = "NSF File"; Node.ImageKey = "nsf"; Node.SelectedImageKey = "nsf"; foreach (Chunk chunk in nsf.Chunks) { if (chunk is NormalChunk) { AddNode(new NormalChunkController(this,(NormalChunk)chunk)); } else if (chunk is TextureChunk) { AddNode(new TextureChunkController(this,(TextureChunk)chunk)); } else if (chunk is OldSoundChunk) { AddNode(new OldSoundChunkController(this,(OldSoundChunk)chunk)); } else if (chunk is SoundChunk) { AddNode(new SoundChunkController(this,(SoundChunk)chunk)); } else if (chunk is WavebankChunk) { AddNode(new WavebankChunkController(this,(WavebankChunk)chunk)); } else if (chunk is SpeechChunk) { AddNode(new SpeechChunkController(this,(SpeechChunk)chunk)); } else if (chunk is UnprocessedChunk) { AddNode(new UnprocessedChunkController(this,(UnprocessedChunk)chunk)); } else { throw new NotImplementedException(); } } AddMenu("Add Chunk - Normal",Menu_Add_NormalChunk); AddMenu("Add Chunk - Sound",Menu_Add_SoundChunk); AddMenu("Add Chunk - Wavebank",Menu_Add_WavebankChunk); AddMenu("Add Chunk - Speech",Menu_Add_SpeechChunk); AddMenuSeparator(); AddMenu("Fix Nitro Detonators",Menu_Fix_Detonator); AddMenu("Fix Box Count",Menu_Fix_BoxCount); }
public void SaveNSF(string filename,NSF nsf) { try { byte[] nsfdata = nsf.Save(); if (MessageBox.Show("Are you sure you want to overwrite this file?","Save Confirmation Prompt",MessageBoxButtons.YesNo) == DialogResult.Yes) { File.WriteAllBytes(filename,nsfdata); } } catch (PackingException) { MessageBox.Show("A packing error occurred. One of the entry-containing chunks contains over 64 KB of data.","Save",MessageBoxButtons.OK,MessageBoxIcon.Error); } catch (IOException ex) { MessageBox.Show("An IO error occurred.\n\n" + ex.Message,"Save",MessageBoxButtons.OK,MessageBoxIcon.Error); } catch (UnauthorizedAccessException ex) { MessageBox.Show("An unauthorized access error occurred.\n\n" + ex.Message,"Save",MessageBoxButtons.OK,MessageBoxIcon.Error); } }
public void PatchNSD(string filename,NSF nsf) { try { byte[] data = File.ReadAllBytes(filename); NSD nsd = NSD.Load(data); nsd.ChunkCount = nsf.Chunks.Count; Dictionary<int,int> newindex = new Dictionary<int,int>(); for (int i = 0;i < nsf.Chunks.Count;i++) { if (nsf.Chunks[i] is IEntry) { IEntry entry = (IEntry)nsf.Chunks[i]; newindex.Add(entry.EID,i * 2 + 1); } if (nsf.Chunks[i] is EntryChunk) { foreach (Entry entry in ((EntryChunk)nsf.Chunks[i]).Entries) { newindex.Add(entry.EID,i * 2 + 1); } } } foreach (NSDLink link in nsd.Index) { if (newindex.ContainsKey(link.EntryID)) { link.ChunkID = newindex[link.EntryID]; newindex.Remove(link.EntryID); } else { // ??? } } foreach (KeyValuePair<int,int> link in newindex) { // ??? } if (MessageBox.Show("Are you sure you want to overwrite the NSD file?","Save Confirmation Prompt",MessageBoxButtons.YesNo) == DialogResult.Yes) { File.WriteAllBytes(filename,nsd.Save()); } } catch (LoadAbortedException) { } }
public void OpenNSF(string filename,NSF nsf,GameVersion gameversion) { NSFBox nsfbox = new NSFBox(nsf,gameversion); nsfbox.Dock = DockStyle.Fill; TabPage nsftab = new TabPage(filename); nsftab.Tag = nsfbox; nsftab.Controls.Add(nsfbox); tbcTabs.TabPages.Add(nsftab); tbcTabs.SelectedTab = nsftab; }