public void SaveAs(object sender, EventArgs args) { if (Runtime.TargetVbn == null) { MessageBox.Show("You must have a bone-set (VBN) selected to save animations."); return; } using (var sfd = new SaveFileDialog()) { sfd.Filter = "Supported Files (.omo, .anim, .smd)|*.omo;*.anim;*.smd|" + "Maya Anim (.anim)|*.anim|" + "Object Motion (.omo)|*.omo|" + "Source Animation (.smd)|*.smd|" + "All Files (*.*)|*.*"; sfd.DefaultExt = "smd"; //Set a default extension to prevent crashing if not specified by user if (sfd.ShowDialog() == DialogResult.OK) { sfd.FileName = sfd.FileName; if (sfd.FileName.EndsWith(".anim")) { if (Tag is AnimTrack) { ((AnimTrack)Tag).CreateAnim(sfd.FileName, Runtime.TargetVbn); } else { ANIM.CreateANIM(sfd.FileName, this, Runtime.TargetVbn); } } if (sfd.FileName.EndsWith(".omo")) { if (Tag is FileData) { FileOutput o = new FileOutput(); o.WriteBytes(((FileData)Tag).GetSection(0, ((FileData)Tag).Size())); o.Save(sfd.FileName); } else { File.WriteAllBytes(sfd.FileName, OMOOld.CreateOMOFromAnimation(this, Runtime.TargetVbn)); } } if (sfd.FileName.EndsWith(".smd")) { Smd.Save(this, Runtime.TargetVbn, sfd.FileName); } } } }
public void Save(object sender, EventArgs args) { //BackgroundWorker worker = sender as BackgroundWorker; float f = 1; if (fileName.ToLower().EndsWith(".bch")) { List <Animation> anims = new List <Animation>(); foreach (Animation a in ((TreeNode)node).Nodes) { //worker.ReportProgress((int)((f / Node.Nodes.Count) * 100f)); f++; anims.Add(a); } BCH_Animation.Rebuild(fileName, anims); } if (fileName.ToLower().EndsWith(".pac")) { var pac = new PAC(); foreach (Animation anim in node.Nodes) { //worker.ReportProgress((int)((f / Node.Nodes.Count) * 100f)); f++; //Console.WriteLine("Working on " + anim.Text + " " + (anim.Tag is FileData)); var bytes = new byte[1]; if (anim.Tag != null && anim.Tag is FileData) { bytes = ((FileData)anim.Tag).GetSection(0, ((FileData)anim.Tag).Size()); } else { bytes = OMOOld.CreateOMOFromAnimation(anim, Runtime.TargetVbn); } pac.Files.Add((useGroupName ? Text : "") + (anim.Text.EndsWith(".omo") ? anim.Text : anim.Text + ".omo"), bytes); } pac.Save(fileName); } }