diff --git a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs index 9a9968a1..304c5ab0 100644 --- a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs +++ b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs @@ -173,11 +173,24 @@ namespace FirstPlugin public ToolStripItem[] GetContextMenuItems() { List Items = new List(); + Items.Add(new ToolStripMenuItem("Save", null, SaveAction, Keys.Control | Keys.S)); Items.Add(new ToolStripMenuItem("Export Model", null, ExportAction, Keys.Control | Keys.E)); Items.Add(new ToolStripMenuItem("Replace Model", null, ReplaceAction, Keys.Control | Keys.R)); return Items.ToArray(); } + private void SaveAction(object sender, EventArgs args) + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.Filter = Utils.GetAllFilters(this); + sfd.FileName = FileName; + + if (sfd.ShowDialog() == DialogResult.OK) + { + STFileSaver.SaveFileFormat(this, sfd.FileName); + } + } + private void ExportAction(object sender, EventArgs args) { SaveFileDialog sfd = new SaveFileDialog(); @@ -377,9 +390,8 @@ namespace FirstPlugin } } - Dictionary NodeIndices = new Dictionary(); - //Go through each bone and remove the original mesh node + List bonesToRemove = new List(); for (int i = 0; i < Model.Skeleton.bones.Count; i++) { //Reset bone as rigid @@ -398,13 +410,9 @@ namespace FirstPlugin } } - if (Model.GenericMeshes.Any(x => x.Text == node.Text)) - { - if (!NodeIndices.ContainsKey(node.Text)) - NodeIndices.Add(node.Text, i); - + if (Model.GenericMeshes.Any(x => x.Text == node.Text)) { + bonesToRemove.Add(node); Model.Model.Bones.Remove(node.Bone); - Model.Skeleton.bones.Remove(node); } /* if (Model.Model.CollisionGroups?.Count != 0) @@ -420,6 +428,11 @@ namespace FirstPlugin }*/ } + foreach (var bone in bonesToRemove) + Model.Skeleton.bones.Remove(bone); + + bonesToRemove.Clear(); + Model.Model.CollisionGroups = new List(); List skinningIndices = Model.GenerateSkinningIndices();