diff --git a/trunk/LipSync/LipSync/Common/CurveEditor.cs b/trunk/LipSync/LipSync/Common/CurveEditor.cs
index 8ebfbd8..0903f72 100644
--- a/trunk/LipSync/LipSync/Common/CurveEditor.cs
+++ b/trunk/LipSync/LipSync/Common/CurveEditor.cs
@@ -1802,7 +1802,7 @@ namespace CurveEditor {
}
}
- private Command Execute( Command run ) {
+ public Command Execute( Command run ) {
#if DEBUG
Common.DebugWriteLine( "CurveEditor.Execute" );
/*Common.DebugWriteLine( " before" );
@@ -1863,6 +1863,14 @@ namespace CurveEditor {
ret = Command.GCommandEdit( run.ID, run.PointID, m_list[run.ID][run.PointID] );
m_list[run.ID][run.PointID] = run.BezierPoint.Clone();
break;
+ case CommandType.Replace:
+ ret = Command.GCommandReplace( run.ID, m_list[run.ID] );
+ BezierChain work = m_list[run.ID];
+ work.List.Clear();
+ for ( int i = 0; i < run.chain.List.Count; i++ ) {
+ work.List.Add( run.chain.List[i].Clone() );
+ }
+ break;
default:
return null;
}
@@ -1933,7 +1941,7 @@ namespace CurveEditor {
/// コマンドバッファに指定されたコマンドを登録します
///
///
- void Register( Command command ) {
+ public void Register( Command command ) {
if ( m_command_position == m_commands.Count - 1 ) {
// 新しいコマンドバッファを追加する場合
m_commands.Add( command.Clone() );
@@ -2039,16 +2047,15 @@ namespace CurveEditor {
}
- internal class Command /*: ICloneable*/ {
+ public class Command /*: ICloneable*/ {
string m_id;
- //int m_picked_index;
PickedSide m_picked_side;
PointF m_new_position;
CommandType m_command_type;
ControlType m_control_type;
BezierPoint m_bp;
- //float m_x;
int m_pid;
+ public BezierChain chain;
public override string ToString() {
return "{ID=" + ID + ", PointID=" + PointID + ", Side=" + Side + ", CommandType=" + Type + ", Position=" + Position + "}";
@@ -2066,6 +2073,9 @@ namespace CurveEditor {
}
result.m_pid = this.m_pid;
result.m_picked_side = this.m_picked_side;
+ if ( this.chain != null ) {
+ result.chain = (BezierChain)this.chain.Clone();
+ }
return result;
}
@@ -2073,6 +2083,14 @@ namespace CurveEditor {
m_bp = null;
}
+ public static Command GCommandReplace( string ID, BezierChain item ) {
+ Command ret = new Command();
+ ret.m_id = ID;
+ ret.m_command_type = CommandType.Replace;
+ ret.chain = (BezierChain)item.Clone();
+ return ret;
+ }
+
public static Command GCommandEditPosition( string ID, int picked_id, PickedSide picked_side, PointF new_position ) {
Command ret = new Command();
ret.m_id = ID;
@@ -2181,13 +2199,14 @@ namespace CurveEditor {
}
}
- internal enum CommandType {
+ public enum CommandType {
Position,//単に位置を変更する
Type,//制御点のタイプを変更する
Add,
Delete,
None,
Edit,
+ Replace,
}
diff --git a/trunk/LipSync/LipSync/Editor/DisplacementControl.cs b/trunk/LipSync/LipSync/Editor/DisplacementControl.cs
index 73113ea..eed8a4b 100644
--- a/trunk/LipSync/LipSync/Editor/DisplacementControl.cs
+++ b/trunk/LipSync/LipSync/Editor/DisplacementControl.cs
@@ -14,8 +14,11 @@
using System;
using System.Drawing;
using System.Windows.Forms;
+using System.IO;
+using System.Text;
using Boare.Lib.AppUtil;
+using CurveEditor;
namespace LipSync {
@@ -26,6 +29,7 @@ namespace LipSync {
private PointF m_scaleandoffset_scale = new PointF( 40f, 0.5f );
private PointF m_scaleandoffset_rotate = new PointF( 1f, 0f );
private bool m_first_scaleandoffset = true;
+ private FormCurveExport m_dialog = null;
public DisplacementControl() {
InitializeComponent();
@@ -88,10 +92,11 @@ namespace LipSync {
this.Text = _( "Edit Motion Curve" );
menuClose.Text = _( "Close" ) + "(&C)";
menuFile.Text = _( "File" ) + "(&F)";
+ menuFileImport.Text = _( "Import" ) + "(&I)";
+ menuFileExport.Text = _( "Export" ) + "(&E)";
menuRedo.Text = _( "Redo" );
menuUndo.Text = _( "Undo" );
menuEdit.Text = _( "Edit" ) + "(&E)";
-
}
public void ApplyFont( Font font ) {
@@ -170,28 +175,28 @@ namespace LipSync {
curveEditor.Add( "Y", AppManager.SaveData.m_group_another[id].mc_y );
curveEditor.Add( "Alpha", AppManager.SaveData.m_group_another[id].mc_alpha );
curveEditor.Add( "Scale", AppManager.SaveData.m_group_another[id].mc_scale );
- curveEditor.Add( "Roate", AppManager.SaveData.m_group_another[id].mc_rotate );
+ curveEditor.Add( "Rotate", AppManager.SaveData.m_group_another[id].mc_rotate );
break;
case ZorderItemType.character:
curveEditor.Add( "X", AppManager.SaveData.m_groups_character[id].mc_x );
curveEditor.Add( "Y", AppManager.SaveData.m_groups_character[id].mc_y );
curveEditor.Add( "Alpha", AppManager.SaveData.m_groups_character[id].mc_alpha );
curveEditor.Add( "Scale", AppManager.SaveData.m_groups_character[id].mc_scale );
- curveEditor.Add( "Roate", AppManager.SaveData.m_groups_character[id].mc_rotate );
+ curveEditor.Add( "Rotate", AppManager.SaveData.m_groups_character[id].mc_rotate );
break;
case ZorderItemType.plugin:
curveEditor.Add( "X", AppManager.SaveData.m_group_plugin[id].mc_x );
curveEditor.Add( "Y", AppManager.SaveData.m_group_plugin[id].mc_y );
curveEditor.Add( "Alpha", AppManager.SaveData.m_group_plugin[id].mc_alpha );
curveEditor.Add( "Scale", AppManager.SaveData.m_group_plugin[id].mc_scale );
- curveEditor.Add( "Roate", AppManager.SaveData.m_group_plugin[id].mc_rotate );
+ curveEditor.Add( "Rotate", AppManager.SaveData.m_group_plugin[id].mc_rotate );
break;
case ZorderItemType.telop:
curveEditor.Add( "X", AppManager.SaveData[id].mc_x );
curveEditor.Add( "Y", AppManager.SaveData[id].mc_y );
curveEditor.Add( "Alpha", AppManager.SaveData[id].mc_alpha );
curveEditor.Add( "Scale", AppManager.SaveData[id].mc_scale );
- curveEditor.Add( "Roate", AppManager.SaveData[id].mc_rotate );
+ curveEditor.Add( "Rotate", AppManager.SaveData[id].mc_rotate );
break;
}
curveEditor.SetYScaleAndYOffset( "X", m_scaleandoffset_x.X, m_scaleandoffset_x.Y );
@@ -230,6 +235,153 @@ namespace LipSync {
private void menuClose_Click( object sender, EventArgs e ) {
this.Close();
}
+
+ private void menuFileExport_Click( object sender, EventArgs e ) {
+#if DEBUG
+ Console.WriteLine( "DisplacementControl#menuFileExport_Click" );
+#endif
+ if ( m_dialog == null ) {
+ m_dialog = new FormCurveExport();
+ }
+ m_dialog.setMode( FormCurveExport.Mode.EXPORT );
+ if ( m_dialog.ShowDialog() != DialogResult.OK ) {
+ return;
+ }
+ int index = comboObjects.SelectedIndex;
+ if ( index < 0 ) {
+ return;
+ }
+ TagForTreeNode node = (TagForTreeNode)comboObjects.Items[index];
+ int id = node.id_or_index;
+ BezierChain x = null;
+ BezierChain y = null;
+ BezierChain alpha = null;
+ BezierChain scale = null;
+ BezierChain rotate = null;
+ switch ( node.type ) {
+ case ZorderItemType.another:
+ x = AppManager.SaveData.m_group_another[id].mc_x;
+ y = AppManager.SaveData.m_group_another[id].mc_y;
+ alpha = AppManager.SaveData.m_group_another[id].mc_alpha;
+ scale = AppManager.SaveData.m_group_another[id].mc_scale;
+ rotate = AppManager.SaveData.m_group_another[id].mc_rotate;
+ break;
+ case ZorderItemType.character:
+ x = AppManager.SaveData.m_groups_character[id].mc_x;
+ y = AppManager.SaveData.m_groups_character[id].mc_y;
+ alpha = AppManager.SaveData.m_groups_character[id].mc_alpha;
+ scale = AppManager.SaveData.m_groups_character[id].mc_scale;
+ rotate = AppManager.SaveData.m_groups_character[id].mc_rotate;
+ break;
+ case ZorderItemType.plugin:
+ x = AppManager.SaveData.m_group_plugin[id].mc_x;
+ y = AppManager.SaveData.m_group_plugin[id].mc_y;
+ alpha = AppManager.SaveData.m_group_plugin[id].mc_alpha;
+ scale = AppManager.SaveData.m_group_plugin[id].mc_scale;
+ rotate = AppManager.SaveData.m_group_plugin[id].mc_rotate;
+ break;
+ case ZorderItemType.telop:
+ x = AppManager.SaveData[id].mc_x;
+ y = AppManager.SaveData[id].mc_y;
+ alpha = AppManager.SaveData[id].mc_alpha;
+ scale = AppManager.SaveData[id].mc_scale;
+ rotate = AppManager.SaveData[id].mc_rotate;
+ break;
+ }
+ String name = comboObjects.Items[index].ToString();
+ String dir = m_dialog.getPath();
+ if ( m_dialog.isX() ) {
+ exportBezierChain( x, Path.Combine( dir, name + "_X.txt" ) );
+ }
+ if ( m_dialog.isY() ) {
+ exportBezierChain( y, Path.Combine( dir, name + "_Y.txt" ) );
+ }
+ if ( m_dialog.isAlpha() ) {
+ exportBezierChain( alpha, Path.Combine( dir, name + "_ALPHA.txt" ) );
+ }
+ if ( m_dialog.isScale() ) {
+ exportBezierChain( scale, Path.Combine( dir, name + "_SCALE.txt" ) );
+ }
+ if ( m_dialog.isRotation() ) {
+ exportBezierChain( rotate, Path.Combine( dir, name + "_ROTATE.txt" ) );
+ }
+ }
+
+ private void menuFileImport_Click( object sender, EventArgs e ) {
+#if DEBUG
+ Console.WriteLine( "menuFileImport_Click" );
+#endif
+ if ( m_dialog == null ) m_dialog = new FormCurveExport();
+ m_dialog.setMode( FormCurveExport.Mode.IMPORT );
+ if ( m_dialog.ShowDialog() != DialogResult.OK ) return;
+
+ BezierChain chain = new BezierChain( Color.Black );
+ if ( m_dialog.isX() ) chain.Color = Common.CURVE_X;
+ if ( m_dialog.isY() ) chain.Color = Common.CURVE_Y;
+ if ( m_dialog.isAlpha() ) chain.Color = Common.CURVE_ALPHA;
+ if ( m_dialog.isScale() ) chain.Color = Common.CURVE_SCALE;
+ if ( m_dialog.isRotation() ) chain.Color = Common.CURVE_ROTATE;
+ String file = m_dialog.getPath();
+ if ( !File.Exists( file ) ) return;
+ if ( comboObjects.SelectedIndex < 0 ) return;
+ using ( StreamReader sr = new StreamReader( file, Encoding.GetEncoding( 0 ) ) ) {
+ String line = "";
+ int point_id = 0;
+ while ( (line = sr.ReadLine()) != null ) {
+ string[] spl = line.Split( new char[] { '\t', ' ', ' ' }, StringSplitOptions.RemoveEmptyEntries );
+ if ( spl.Length < 2 ) continue;
+ ControlType tleft = ControlType.None;
+ ControlType tright = ControlType.None;
+ PointF pbase = new PointF();
+ PointF pleft = new PointF();
+ PointF pright = new PointF();
+ float v = 0.0f;
+ if ( float.TryParse( spl[0], out v ) ) pbase.X = v;
+ if ( float.TryParse( spl[1], out v ) ) pbase.Y = v;
+ if ( spl.Length >= 8 ) {
+ if ( float.TryParse( spl[2], out v ) ) pleft.X = v;
+ if ( float.TryParse( spl[3], out v ) ) pleft.Y = v;
+ String s = spl[4].Trim().ToLower();
+ if ( s.Equals( "master" ) ) tleft = ControlType.Master;
+ if ( s.Equals( "normal" ) ) tleft = ControlType.Normal;
+ if ( float.TryParse( spl[5], out v ) ) pright.X = v;
+ if ( float.TryParse( spl[6], out v ) ) pright.Y = v;
+ s = spl[7].Trim().ToLower();
+ if ( s.Equals( "master" ) ) tright = ControlType.Master;
+ if ( s.Equals( "normal" ) ) tright = ControlType.Normal;
+ }
+ point_id++;
+ BezierPoint bp = new BezierPoint( pbase, new PointF(), new PointF() );
+ bp.ID = point_id;
+ bp.m_control_left = pleft;
+ bp.m_control_right = pright;
+ bp.ControlLeftType = tleft;
+ bp.ControlRightType = tright;
+#if DEBUG
+ Console.WriteLine( " bp=" + bp.ToString() );
+#endif
+ chain.List.Add( bp );
+ }
+ }
+ String id = "X";
+ if ( m_dialog.isX() ) id = "X";
+ if ( m_dialog.isY() ) id = "Y";
+ if ( m_dialog.isAlpha() ) id = "Alpha";
+ if ( m_dialog.isScale() ) id = "Scale";
+ if ( m_dialog.isRotation() ) id = "Rotate";
+ CurveEditor.Command run = CurveEditor.Command.GCommandReplace( id, chain );
+ curveEditor.Register( curveEditor.Execute( run ) );
+ }
+
+ private void exportBezierChain( BezierChain chain, String file ) {
+ int count = chain.List.Count;
+ using ( StreamWriter sw = new StreamWriter( file, false, Encoding.GetEncoding( 0 ) ) ) {
+ for ( int i = 0; i < count; i++ ) {
+ BezierPoint point = chain.List[i];
+ sw.WriteLine( point.Base.X + "\t" + point.Base.Y + "\t" + point.m_control_left.X + "\t" + point.m_control_left.Y + "\t" + point.ControlLeftType + "\t" + point.m_control_right.X + "\t" + point.m_control_right.Y + "\t" + point.ControlRightType );
+ }
+ }
+ }
}
}
diff --git a/trunk/LipSync/LipSync/Editor/DisplacementControl.designer.cs b/trunk/LipSync/LipSync/Editor/DisplacementControl.designer.cs
index 2bfc5d7..5f57289 100644
--- a/trunk/LipSync/LipSync/Editor/DisplacementControl.designer.cs
+++ b/trunk/LipSync/LipSync/Editor/DisplacementControl.designer.cs
@@ -44,6 +44,8 @@ namespace LipSync {
this.menuUndo = new System.Windows.Forms.ToolStripMenuItem();
this.menuRedo = new System.Windows.Forms.ToolStripMenuItem();
this.comboObjects = new System.Windows.Forms.ComboBox();
+ this.menuFileImport = new System.Windows.Forms.ToolStripMenuItem();
+ this.menuFileExport = new System.Windows.Forms.ToolStripMenuItem();
this.curveEditor = new CurveEditor.CurveEditor();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
@@ -55,16 +57,18 @@ namespace LipSync {
this.menuEdit} );
this.menuStrip1.Location = new System.Drawing.Point( 0, 0 );
this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size( 557, 24 );
+ this.menuStrip1.Size = new System.Drawing.Size( 557, 26 );
this.menuStrip1.TabIndex = 7;
this.menuStrip1.Text = "menuStrip1";
//
// menuFile
//
this.menuFile.DropDownItems.AddRange( new System.Windows.Forms.ToolStripItem[] {
+ this.menuFileImport,
+ this.menuFileExport,
this.menuClose} );
this.menuFile.Name = "menuFile";
- this.menuFile.Size = new System.Drawing.Size( 66, 20 );
+ this.menuFile.Size = new System.Drawing.Size( 85, 22 );
this.menuFile.Text = "ファイル(&F)";
//
// menuClose
@@ -81,7 +85,7 @@ namespace LipSync {
this.menuUndo,
this.menuRedo} );
this.menuEdit.Name = "menuEdit";
- this.menuEdit.Size = new System.Drawing.Size( 56, 20 );
+ this.menuEdit.Size = new System.Drawing.Size( 61, 22 );
this.menuEdit.Text = "編集(&E)";
this.menuEdit.DropDownOpening += new System.EventHandler( this.menuEdit_DropDownOpening );
//
@@ -89,7 +93,7 @@ namespace LipSync {
//
this.menuUndo.Name = "menuUndo";
this.menuUndo.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));
- this.menuUndo.Size = new System.Drawing.Size( 192, 22 );
+ this.menuUndo.Size = new System.Drawing.Size( 226, 22 );
this.menuUndo.Text = "元に戻す(&U)";
this.menuUndo.Click += new System.EventHandler( this.menuUndo_Click );
//
@@ -98,7 +102,7 @@ namespace LipSync {
this.menuRedo.Name = "menuRedo";
this.menuRedo.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.Z)));
- this.menuRedo.Size = new System.Drawing.Size( 192, 22 );
+ this.menuRedo.Size = new System.Drawing.Size( 226, 22 );
this.menuRedo.Text = "やり直し(&R)";
this.menuRedo.Click += new System.EventHandler( this.menuRedo_Click );
//
@@ -114,7 +118,21 @@ namespace LipSync {
this.comboObjects.TabIndex = 8;
this.comboObjects.SelectedIndexChanged += new System.EventHandler( this.comboObjects_SelectedIndexChanged );
//
- // curveEditor1
+ // menuFileImport
+ //
+ this.menuFileImport.Name = "menuFileImport";
+ this.menuFileImport.Size = new System.Drawing.Size( 152, 22 );
+ this.menuFileImport.Text = "Import(&I)";
+ this.menuFileImport.Click += new System.EventHandler( this.menuFileImport_Click );
+ //
+ // menuFileExport
+ //
+ this.menuFileExport.Name = "menuFileExport";
+ this.menuFileExport.Size = new System.Drawing.Size( 152, 22 );
+ this.menuFileExport.Text = "Export(&E)";
+ this.menuFileExport.Click += new System.EventHandler( this.menuFileExport_Click );
+ //
+ // curveEditor
//
this.curveEditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
@@ -142,7 +160,7 @@ namespace LipSync {
this.curveEditor.MinimumSize = new System.Drawing.Size( 100, 100 );
this.curveEditor.MinXScale = 1F;
this.curveEditor.MinYScale = 0.2F;
- this.curveEditor.Name = "curveEditor1";
+ this.curveEditor.Name = "curveEditor";
this.curveEditor.RescaleYEnabled = true;
this.curveEditor.ScaleLine = System.Drawing.Color.FromArgb( ((int)(((byte)(94)))), ((int)(((byte)(94)))), ((int)(((byte)(94)))) );
this.curveEditor.ScrollEnabled = true;
@@ -190,5 +208,7 @@ namespace LipSync {
public System.Windows.Forms.ToolStripMenuItem menuRedo;
public System.Windows.Forms.ComboBox comboObjects;
private System.Windows.Forms.ToolStripMenuItem menuClose;
+ private System.Windows.Forms.ToolStripMenuItem menuFileImport;
+ private System.Windows.Forms.ToolStripMenuItem menuFileExport;
}
}
diff --git a/trunk/LipSync/LipSync/LipSync.csproj b/trunk/LipSync/LipSync/LipSync.csproj
index 8a205d5..730ccbb 100644
--- a/trunk/LipSync/LipSync/LipSync.csproj
+++ b/trunk/LipSync/LipSync/LipSync.csproj
@@ -2,7 +2,7 @@
Debug
AnyCPU
- 9.0.30729
+ 9.0.21022
2.0
{15B51EEA-0D7F-4B59-AC7B-879A7BDB4A56}
WinExe
@@ -239,7 +239,19 @@
FormVocalomark.cs
+
+ Form
+
+
+ FormCurveExport.cs
+
+
+ DisplacementControl.cs
+
+
+ FormCurveExport.cs
+
PublicResXFileCodeGenerator
Resources.Designer.cs