}; // Default viewport #endregion #region ToolStripMenu private void openNUDToolStripMenuItem_Click(object sender, EventArgs e) { PARAMEditor currentParam = null; ACMDEditor currentACMD = null; SwagEditor currentSwagEditor = null; foreach (PARAMEditor p in paramEditors) { if (p.ContainsFocus) { currentParam = p; } } foreach (ACMDEditor a in ACMDEditors) { if (a.ContainsFocus) { currentACMD = a; } } foreach (SwagEditor s in SwagEditors) { if (s.ContainsFocus) { currentSwagEditor = s; } } if (currentParam != null) { currentParam.saveAs(); } else if (currentACMD != null) { currentACMD.save(); } else if (currentSwagEditor != null) { currentSwagEditor.save(); } else { string filename = ""; SaveFileDialog save = new SaveFileDialog(); save.Filter = "Supported Filetypes (VBN,LVD)|*.vbn;*.lvd;*.dae|Smash 4 Boneset|*.vbn|All files(*.*)|*.*"; DialogResult result = save.ShowDialog(); if (result == DialogResult.OK) { filename = save.FileName; if (filename.EndsWith(".vbn")) { Runtime.TargetVBN.Endian = Endianness.Big; if (!checkBox1.Checked) { Runtime.TargetVBN.Endian = Endianness.Little; } Runtime.TargetVBN.Save(filename); } if (filename.EndsWith(".lvd") && Runtime.TargetLVD != null) { File.WriteAllBytes(filename, Runtime.TargetLVD.Rebuild()); } else if (filename.EndsWith(".lvd")) { DAT d = null; foreach (ModelContainer c in Runtime.ModelContainers) { if (c.dat_melee != null) { d = c.dat_melee; } } if (d != null) { DialogResult r = MessageBox.Show("Would you like to save in safe mode?\n(This is not suggested, only use when needed)", "DAT -> LVD safe mode", MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { File.WriteAllBytes(filename, d.toLVD(true).Rebuild()); } else if (r == DialogResult.No) { File.WriteAllBytes(filename, d.toLVD(false).Rebuild()); } } } if (filename.EndsWith(".dae")) { if (Runtime.ModelContainers.Count > 0) { Collada.Save(filename, Runtime.ModelContainers[0]); } } //OMO.createOMO (anim, vbn, "C:\\Users\\ploaj_000\\Desktop\\WebGL\\test_outut.omo", -1, -1); } } }
///<summary> ///Open a file based on the filename ///</summary> /// <param name="filename"> Filename of file to open</param> public void openFile(string filename) { if (!filename.EndsWith(".mta") && !filename.EndsWith(".dat") && !filename.EndsWith(".smd")) { openAnimation(filename); } if (filename.EndsWith(".vbn")) { Runtime.TargetVBN = new VBN(filename); if (Directory.Exists("Skapon\\")) { NUD nud = Skapon.Create(Runtime.TargetVBN); ModelContainer con = new ModelContainer(); con.vbn = Runtime.TargetVBN; con.nud = nud; nud.PreRender(); Runtime.ModelContainers.Add(con); } } if (filename.EndsWith(".sb")) { SB sb = new SB(); sb.Read(filename); SwagEditor swagEditor = new SwagEditor(sb) { ShowHint = DockState.DockRight }; AddDockedControl(swagEditor); SwagEditors.Add(swagEditor); } if (filename.EndsWith(".dat")) { if (filename.EndsWith("AJ.dat")) { MessageBox.Show("This is animation; load with Animation -> Import"); return; } DAT dat = new DAT(); dat.Read(new FileData(filename)); ModelContainer c = new ModelContainer(); Runtime.ModelContainers.Add(c); c.dat_melee = dat; dat.PreRender(); HashMatch(); Runtime.TargetVBN = dat.bones; DAT_TreeView p = new DAT_TreeView() { ShowHint = DockState.DockLeft }; p.setDAT(dat); AddDockedControl(p); //Runtime.TargetVBN = dat.bones; meshList.refresh(); } if (filename.EndsWith(".nut")) { Runtime.TextureContainers.Add(new NUT(filename)); NUTEditor ev = new NUTEditor(); ev.Show(); } if (filename.EndsWith(".lvd")) { Runtime.TargetLVD = new LVD(filename); LVD test = Runtime.TargetLVD; lvdList.fillList(); } if (filename.EndsWith(".mta")) { Runtime.TargetMTA = new MTA(); Runtime.TargetMTA.Read(filename); viewports[0].loadMTA(Runtime.TargetMTA); MTAEditor temp = new MTAEditor(Runtime.TargetMTA) { ShowHint = DockState.DockLeft }; temp.Text = Path.GetFileName(filename); AddDockedControl(temp); mtaEditors.Add(temp); } if (filename.EndsWith(".mtable")) { //project.openACMD(filename); Runtime.Moveset = new MovesetManager(filename); } if (filename.EndsWith("path.bin")) { Runtime.TargetPath = new PathBin(filename); } else if (filename.EndsWith(".bin")) { //Note to whoever is readin this: //Eventually we need to look at the magic here (and also make all .bins look at magic) //Runtime.TargetCMR0 = new CMR0(); //Runtime.TargetCMR0.read(new FileData(filename)); PARAMEditor p = new PARAMEditor(filename) { ShowHint = DockState.Document }; p.Text = Path.GetFileName(filename); AddDockedControl(p); paramEditors.Add(p); } if (filename.EndsWith(".mdl0")) { MDL0Bones mdl0 = new MDL0Bones(); Runtime.TargetVBN = mdl0.GetVBN(new FileData(filename)); } if (filename.EndsWith(".smd")) { Runtime.TargetVBN = new VBN(); SMD.read(filename, new SkelAnimation(), Runtime.TargetVBN); } if (filename.ToLower().EndsWith(".dae")) { DAEImportSettings m = new DAEImportSettings(); m.ShowDialog(); if (m.exitStatus == DAEImportSettings.Opened) { if (Runtime.ModelContainers.Count < 1) { Runtime.ModelContainers.Add(new ModelContainer()); } Collada.DAEtoNUD(filename, Runtime.ModelContainers[0]); // apply settings m.Apply(Runtime.ModelContainers[0].nud); Runtime.ModelContainers[0].nud.MergePoly(); meshList.refresh(); } } if (filename.EndsWith(".mbn")) { MBN m = new MBN(); m.Read(filename); ModelContainer con = new ModelContainer(); BCH b = new BCH(); con.bch = b; b.mbn = m; b.Read("C:\\s\\Smash\\extract\\data\\fighter\\lucas\\Ness3DS - h00\\normal.bch"); Runtime.ModelContainers.Add(con); } /*if (filename.EndsWith(".bch")) * { * ModelContainer con = new ModelContainer(); * BCH b = new BCH(); * b.Read(filename); * con.bch = b; * Runtime.ModelContainers.Add(con); * }*/ if (filename.EndsWith(".nud")) { openNud(filename); } if (filename.EndsWith(".moi")) { MOI moi = new MOI(filename); AddDockedControl(new MOIEditor(moi) { ShowHint = DockState.DockRight }); } if (filename.EndsWith(".wrkspc")) { Workspace = new WorkspaceManager(project); Workspace.OpenWorkspace(filename); } if (Runtime.TargetVBN != null) { ModelContainer m = new ModelContainer(); m.vbn = Runtime.TargetVBN; Runtime.ModelContainers.Add(m); if (filename.EndsWith(".smd")) { m.nud = SMD.toNUD(filename); meshList.refresh(); } leftPanel.treeRefresh(); } else { foreach (ModelContainer m in Runtime.ModelContainers) { if (m.vbn != null) { Runtime.TargetVBN = Runtime.ModelContainers[0].vbn; break; } } } // Don't want to mess up the project tree if we // just set it up already if (!filename.EndsWith(".wrkspc")) { project.fillTree(); } }