Exemple #1
0
        // 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;
        }