2019-09-28 23:27:48 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2020-05-10 17:44:52 +02:00
|
|
|
|
using System.Windows.Forms;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
|
|
|
|
namespace Toolbox.Library.Animations
|
|
|
|
|
{
|
2020-05-10 17:44:52 +02:00
|
|
|
|
public class STSkeletonAnimation : STAnimation, IContextMenuNode
|
2019-09-28 23:27:48 +02:00
|
|
|
|
{
|
|
|
|
|
public virtual STSkeleton GetActiveSkeleton()
|
|
|
|
|
{
|
|
|
|
|
Viewport viewport = LibraryGUI.GetActiveViewport();
|
|
|
|
|
if (viewport == null) return null;
|
|
|
|
|
|
|
|
|
|
foreach (var drawable in viewport.scene.objects) {
|
|
|
|
|
if (drawable is STSkeleton)
|
|
|
|
|
return (STSkeleton)drawable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2020-05-10 17:44:52 +02:00
|
|
|
|
|
|
|
|
|
public ToolStripItem[] GetContextMenuItems()
|
|
|
|
|
{
|
|
|
|
|
bool hasBones = GetActiveSkeleton() != null;
|
|
|
|
|
|
|
|
|
|
List<ToolStripItem> Items = new List<ToolStripItem>();
|
|
|
|
|
Items.Add(new ToolStripMenuItem("Export Animation", null, ExportAction, Keys.Control | Keys.E)
|
|
|
|
|
{ Enabled = hasBones });
|
|
|
|
|
|
|
|
|
|
return Items.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ExportAction(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveFileDialog sfd = new SaveFileDialog();
|
2020-05-26 22:05:03 +02:00
|
|
|
|
sfd.Filter = "Supported Formats|*.smd; *.seanim;|" +
|
|
|
|
|
"SMD |*.smd|" +
|
|
|
|
|
"SEANIM |*.seanim|" +
|
|
|
|
|
"All files(*.*)|*.*";
|
|
|
|
|
|
|
|
|
|
sfd.DefaultExt = "seanim";
|
2020-05-10 17:44:52 +02:00
|
|
|
|
sfd.FileName = Name;
|
|
|
|
|
if (sfd.ShowDialog() == DialogResult.OK) {
|
2020-05-26 22:05:03 +02:00
|
|
|
|
string ext = Utils.GetExtension(sfd.FileName);
|
|
|
|
|
if (ext == ".smd")
|
|
|
|
|
SMD.Save(this, sfd.FileName);
|
|
|
|
|
if (ext == ".seanim")
|
|
|
|
|
SEANIM.Save(this, sfd.FileName);
|
2020-05-10 17:44:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-28 23:27:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|