// Add a level animation private void ImportLevelAnimation() { importFileDialog.InitialDirectory = modFolder; if (importFileDialog.ShowDialog() != DialogResult.OK) { return; } string animpath = Path.ChangeExtension(importFileDialog.FileName, ".saanim"); // Load saanim file if it isn't found if (!File.Exists(animpath)) { using (OpenFileDialog ofd = new OpenFileDialog { Title = "Import Level Animation", DefaultExt = "saanim", Filter = "Animation Files|*.saanim", Multiselect = false }) { if (ofd.ShowDialog() != DialogResult.OK) { return; } animpath = ofd.FileName; } } // Update level animations LevelAnim newanim = LevelData.ImportLevelAnimation(new ModelFile(importFileDialog.FileName).Model, NJS_MOTION.Load(animpath), selectedItems); if (LevelData.LevelAnims == null) { LevelData.ClearLevelGeoAnims(); } LevelData.geo.Anim.Add(newanim.GeoAnimationData); LevelData.AddLevelAnim(newanim); unsaved = true; selectedItems.Clear(); selectedItems.Add(newanim); LevelData.InvalidateRenderState(); playAnimButton.Enabled = prevFrameButton.Enabled = nextFrameButton.Enabled = resetAnimButton.Enabled = LevelData.LevelAnimCount > 0; }
private void Selection_SelectionChanged(EditorItemSelection sender) { if (suppressSelectionEvents) { return; } // match our tree to our editor selection List <TreeNode> selectedNodes = new List <TreeNode>(); foreach (Item item in sender.Items) { if (item is LevelItem) { LevelItem levelItem = (LevelItem)item; // find the index of the level item int index = LevelData.GetIndexOfItem(levelItem); selectedNodes.Add(levelItemNode.Nodes[index]); } else if (item is LevelAnim) { LevelAnim levelAnim = (LevelAnim)item; // find the index of the level animation int index = LevelData.GetIndexOfItem(levelAnim); selectedNodes.Add(levelAnimNode.Nodes[index]); } else if (item is DeathZoneItem) { DeathZoneItem deathZoneItem = (DeathZoneItem)item; int index = LevelData.DeathZones.IndexOf(deathZoneItem); selectedNodes.Add(deathZoneNode.Nodes[index]); } else if (item is MissionSETItem) { MissionSETItem miSetItem = (MissionSETItem)item; int index = LevelData.MissionSETItems[LevelData.Character].IndexOf(miSetItem); selectedNodes.Add(missionSETNode.Nodes[index]); } else if (item is SETItem) { SETItem setItem = (SETItem)item; int index = LevelData.GetIndexOfSETItem(LevelData.Character, setItem); //LevelData.SETItems[LevelData.Character].IndexOf(setItem); selectedNodes.Add(setNode.Nodes[index]); } else if (item is CAMItem) { CAMItem camItem = (CAMItem)item; int index = LevelData.CAMItems[LevelData.Character].IndexOf(camItem); selectedNodes.Add(camNode.Nodes[index]); } else if (item is SplineData) { SplineData spline = (SplineData)item; int index = LevelData.LevelSplines.IndexOf(spline); selectedNodes.Add(splineNode.Nodes[index]); } } sceneTreeView.SelectedNodes = selectedNodes; }
// Export C structs private void exportStructs(string filename, bool selectedOnly) { LandTableFormat fmt = LevelData.geo.Format; switch (fmt) { case LandTableFormat.SA1: case LandTableFormat.SADX: if (usetBasicDXFormatToolStripMenuItem.Checked) { fmt = LandTableFormat.SADX; } else { fmt = LandTableFormat.SA1; } break; } List <string> labels = new List <string>() { LevelData.geo.Name }; string[] texnames = null; if (LevelData.leveltexs != null && exportTextureNamesToolStripMenuItem.Checked) { texnames = new string[LevelData.TextureBitmaps[LevelData.leveltexs].Length]; for (int i = 0; i < LevelData.TextureBitmaps[LevelData.leveltexs].Length; i++) { texnames[i] = string.Format("{0}TexName_{1}", LevelData.leveltexs, LevelData.TextureBitmaps[LevelData.leveltexs][i].Name); } } if (!selectedOnly) { using (StreamWriter sw = File.CreateText(filename)) { WriteStructMetadata(sw, true, fmt, texnames); LevelData.geo.ToStructVariables(sw, fmt, labels, texnames); return; } } else { foreach (Item selectedItem in selectedItems.Items) { if (selectedItem is LevelItem) { LevelItem levelItem = selectedItem as LevelItem; string path = Path.Combine(filename, levelItem.CollisionData.Model.Name + ".c"); using (StreamWriter sw = File.CreateText(path)) { WriteStructMetadata(sw, false, fmt, texnames); levelItem.CollisionData.Model.ToStructVariables(sw, usetBasicDXFormatToolStripMenuItem.Checked, labels, texnames); } } else if (selectedItem is LevelAnim) { LevelAnim levelAnim = selectedItem as LevelAnim; string path = Path.Combine(filename, levelAnim.GeoAnimationData.Animation.ActionName + ".c"); using (StreamWriter sw = File.CreateText(path)) { WriteStructMetadata(sw, false, fmt, texnames); levelAnim.GeoAnimationData.ToStructVariables(sw, usetBasicDXFormatToolStripMenuItem.Checked, labels, texnames); } } } return; } }