Added: Multi-sprite drag, Sprite selection memory between frames, Frame naming

This commit is contained in:
quinnvoker
2018-12-24 13:52:39 -08:00
parent 1a21b230ad
commit f3a0ef8dc2
3 changed files with 269 additions and 131 deletions
+18 -10
View File
@@ -20,7 +20,7 @@ namespace AnimationEditor
public float ZoomLevel { get; set; } public float ZoomLevel { get; set; }
public Vector3 CameraLocation { get; set; } public Vector3 CameraLocation { get; set; }
public Sprite EditSprite { get; set; } public List<Sprite> EditSprites { get; set; }
public int PixelGridDisplayLevel { get; set; } public int PixelGridDisplayLevel { get; set; }
public int GridSpacing { get; set; } public int GridSpacing { get; set; }
@@ -142,7 +142,10 @@ namespace AnimationEditor
private void HandleDragging() private void HandleDragging()
{ {
if (EditSprite != null) if (EditSprites != null && EditSprites.Count > 0)
{
bool hoverFound = false;
foreach (Sprite spr in EditSprites)
{ {
/*create draggable rect spriteRect at 0,0 /*create draggable rect spriteRect at 0,0
*rect is scaled by Zoomlevel to match sprite's onscreen size *rect is scaled by Zoomlevel to match sprite's onscreen size
@@ -150,14 +153,16 @@ namespace AnimationEditor
*rect is then offset by the camera's location(multiplied by zoomlevel) and the onscreen centerpoint *rect is then offset by the camera's location(multiplied by zoomlevel) and the onscreen centerpoint
*this results in a rect that matches the sprite's onscreen position regardless of pan or zoom *this results in a rect that matches the sprite's onscreen position regardless of pan or zoom
*/ */
Rectangle spriteRect = new Rectangle(0, 0, (int)(EditSprite.Bounds.Width * ZoomLevel), (int)(EditSprite.Bounds.Height * ZoomLevel)); Rectangle sprRect = new Rectangle(0, 0, (int)(spr.Bounds.Width * ZoomLevel), (int)(spr.Bounds.Height * ZoomLevel));
spriteRect.Offset((EditSprite.Offset - EditSprite.Origin) * ZoomLevel + new Vector2(CameraLocation.X, CameraLocation.Y) * ZoomLevel + centerPoint); sprRect.Offset((spr.Offset - spr.Origin) * ZoomLevel + new Vector2(CameraLocation.X, CameraLocation.Y) * ZoomLevel + centerPoint);
if (sprRect.Contains(mState.Position))
{
hoverFound = true;
break;
}
}
//fix for when detecting the mouse being within Bounds made an uninteractable section appear at the top of screen and allowed interaction below bottom if (hoverFound)
Rectangle frame = new Rectangle(Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);
frame.Y = 0;
if (spriteRect.Contains(mState.Position))
{ {
if (!hovering) if (!hovering)
{ {
@@ -189,7 +194,10 @@ namespace AnimationEditor
if (distMoved != Vector2.Zero) if (distMoved != Vector2.Zero)
{ {
EditSprite.Offset += distMoved; foreach(Sprite spr in EditSprites)
{
spr.Offset += distMoved;
}
OnSpriteMoved(new EventArgs()); OnSpriteMoved(new EventArgs());
} }
} }
+124 -109
View File
@@ -63,17 +63,19 @@
this.frameEditorPanel = new System.Windows.Forms.Panel(); this.frameEditorPanel = new System.Windows.Forms.Panel();
this.frameNameBox = new System.Windows.Forms.TextBox(); this.frameNameBox = new System.Windows.Forms.TextBox();
this.frameSpritePanel = new System.Windows.Forms.Panel(); this.frameSpritePanel = new System.Windows.Forms.Panel();
this.spritePosPanel = new System.Windows.Forms.Panel();
this.frameSpritePositionLabel = new System.Windows.Forms.Label();
this.spriteYPosLabel = new System.Windows.Forms.Label();
this.spriteXPosLabel = new System.Windows.Forms.Label();
this.spriteYPosBox = new System.Windows.Forms.NumericUpDown();
this.spriteXPosBox = new System.Windows.Forms.NumericUpDown();
this.removeSpriteButton = new System.Windows.Forms.Button(); this.removeSpriteButton = new System.Windows.Forms.Button();
this.moveSpriteUpButton = new System.Windows.Forms.Button(); this.moveSpriteUpButton = new System.Windows.Forms.Button();
this.moveSpriteDownButton = new System.Windows.Forms.Button(); this.moveSpriteDownButton = new System.Windows.Forms.Button();
this.frameSpritePositionLabel = new System.Windows.Forms.Label();
this.frameSpriteListBox = new System.Windows.Forms.ListBox(); this.frameSpriteListBox = new System.Windows.Forms.ListBox();
this.spriteYPosLabel = new System.Windows.Forms.Label();
this.spriteXPosLabel = new System.Windows.Forms.Label();
this.frameSpriteListLabel = new System.Windows.Forms.Label(); this.frameSpriteListLabel = new System.Windows.Forms.Label();
this.replaceSpriteButton = new System.Windows.Forms.Button();
this.addSpriteToFrameSpritesButton = new System.Windows.Forms.Button(); this.addSpriteToFrameSpritesButton = new System.Windows.Forms.Button();
this.spriteYPosBox = new System.Windows.Forms.NumericUpDown();
this.spriteXPosBox = new System.Windows.Forms.NumericUpDown();
this.importDelayLabel = new System.Windows.Forms.Label(); this.importDelayLabel = new System.Windows.Forms.Label();
this.importValuesLabel = new System.Windows.Forms.Label(); this.importValuesLabel = new System.Windows.Forms.Label();
this.importDelayBox = new System.Windows.Forms.NumericUpDown(); this.importDelayBox = new System.Windows.Forms.NumericUpDown();
@@ -82,20 +84,20 @@
this.frameInfoLabel = new System.Windows.Forms.Label(); this.frameInfoLabel = new System.Windows.Forms.Label();
this.frameBoxLabel = new System.Windows.Forms.Label(); this.frameBoxLabel = new System.Windows.Forms.Label();
this.spriteBoxLabel = new System.Windows.Forms.Label(); this.spriteBoxLabel = new System.Windows.Forms.Label();
this.duplicateFrameButton = new System.Windows.Forms.Button();
this.addEmptyFrameButton = new System.Windows.Forms.Button(); this.addEmptyFrameButton = new System.Windows.Forms.Button();
this.animationPanel = new System.Windows.Forms.Panel(); this.animationPanel = new System.Windows.Forms.Panel();
this.animationNameLabel = new System.Windows.Forms.Label(); this.animationNameLabel = new System.Windows.Forms.Label();
this.animationLabel = new System.Windows.Forms.Label(); this.animationLabel = new System.Windows.Forms.Label();
this.loadAnimationSetDialog = new System.Windows.Forms.OpenFileDialog();
this.duplicateFrameButton = new System.Windows.Forms.Button();
this.animationPreview = new AnimationEditor.AnimationPreview(); this.animationPreview = new AnimationEditor.AnimationPreview();
this.replaceSpriteButton = new System.Windows.Forms.Button(); this.loadAnimationSetDialog = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.spritePreview)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.spritePreview)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.frameTrackBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.frameTrackBar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.delayInputBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.delayInputBox)).BeginInit();
this.mainMenuStrip.SuspendLayout(); this.mainMenuStrip.SuspendLayout();
this.frameEditorPanel.SuspendLayout(); this.frameEditorPanel.SuspendLayout();
this.frameSpritePanel.SuspendLayout(); this.frameSpritePanel.SuspendLayout();
this.spritePosPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.importDelayBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.importDelayBox)).BeginInit();
@@ -430,27 +432,105 @@
this.frameNameBox.Name = "frameNameBox"; this.frameNameBox.Name = "frameNameBox";
this.frameNameBox.Size = new System.Drawing.Size(83, 20); this.frameNameBox.Size = new System.Drawing.Size(83, 20);
this.frameNameBox.TabIndex = 25; this.frameNameBox.TabIndex = 25;
this.frameNameBox.TextChanged += new System.EventHandler(this.frameNameBox_TextChanged);
// //
// frameSpritePanel // frameSpritePanel
// //
this.frameSpritePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.frameSpritePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.frameSpritePanel.Controls.Add(this.spritePosPanel);
this.frameSpritePanel.Controls.Add(this.removeSpriteButton); this.frameSpritePanel.Controls.Add(this.removeSpriteButton);
this.frameSpritePanel.Controls.Add(this.moveSpriteUpButton); this.frameSpritePanel.Controls.Add(this.moveSpriteUpButton);
this.frameSpritePanel.Controls.Add(this.moveSpriteDownButton); this.frameSpritePanel.Controls.Add(this.moveSpriteDownButton);
this.frameSpritePanel.Controls.Add(this.frameSpritePositionLabel);
this.frameSpritePanel.Controls.Add(this.frameSpriteListBox); this.frameSpritePanel.Controls.Add(this.frameSpriteListBox);
this.frameSpritePanel.Controls.Add(this.spriteYPosLabel);
this.frameSpritePanel.Controls.Add(this.spriteXPosLabel);
this.frameSpritePanel.Controls.Add(this.frameSpriteListLabel); this.frameSpritePanel.Controls.Add(this.frameSpriteListLabel);
this.frameSpritePanel.Controls.Add(this.replaceSpriteButton); this.frameSpritePanel.Controls.Add(this.replaceSpriteButton);
this.frameSpritePanel.Controls.Add(this.addSpriteToFrameSpritesButton); this.frameSpritePanel.Controls.Add(this.addSpriteToFrameSpritesButton);
this.frameSpritePanel.Controls.Add(this.spriteYPosBox);
this.frameSpritePanel.Controls.Add(this.spriteXPosBox);
this.frameSpritePanel.Location = new System.Drawing.Point(129, 277); this.frameSpritePanel.Location = new System.Drawing.Point(129, 277);
this.frameSpritePanel.Name = "frameSpritePanel"; this.frameSpritePanel.Name = "frameSpritePanel";
this.frameSpritePanel.Size = new System.Drawing.Size(161, 126); this.frameSpritePanel.Size = new System.Drawing.Size(161, 126);
this.frameSpritePanel.TabIndex = 24; this.frameSpritePanel.TabIndex = 24;
// //
// spritePosPanel
//
this.spritePosPanel.Controls.Add(this.frameSpritePositionLabel);
this.spritePosPanel.Controls.Add(this.spriteYPosLabel);
this.spritePosPanel.Controls.Add(this.spriteXPosLabel);
this.spritePosPanel.Controls.Add(this.spriteYPosBox);
this.spritePosPanel.Controls.Add(this.spriteXPosBox);
this.spritePosPanel.Location = new System.Drawing.Point(32, 81);
this.spritePosPanel.Name = "spritePosPanel";
this.spritePosPanel.Size = new System.Drawing.Size(128, 44);
this.spritePosPanel.TabIndex = 27;
//
// frameSpritePositionLabel
//
this.frameSpritePositionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.frameSpritePositionLabel.AutoSize = true;
this.frameSpritePositionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.frameSpritePositionLabel.Location = new System.Drawing.Point(1, 1);
this.frameSpritePositionLabel.Name = "frameSpritePositionLabel";
this.frameSpritePositionLabel.Size = new System.Drawing.Size(86, 13);
this.frameSpritePositionLabel.TabIndex = 23;
this.frameSpritePositionLabel.Text = "Sprite Positon";
//
// spriteYPosLabel
//
this.spriteYPosLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.spriteYPosLabel.AutoSize = true;
this.spriteYPosLabel.Location = new System.Drawing.Point(62, 21);
this.spriteYPosLabel.Name = "spriteYPosLabel";
this.spriteYPosLabel.Size = new System.Drawing.Size(14, 13);
this.spriteYPosLabel.TabIndex = 18;
this.spriteYPosLabel.Text = "Y";
//
// spriteXPosLabel
//
this.spriteXPosLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.spriteXPosLabel.AutoSize = true;
this.spriteXPosLabel.Location = new System.Drawing.Point(1, 21);
this.spriteXPosLabel.Name = "spriteXPosLabel";
this.spriteXPosLabel.Size = new System.Drawing.Size(14, 13);
this.spriteXPosLabel.TabIndex = 18;
this.spriteXPosLabel.Text = "X";
//
// spriteYPosBox
//
this.spriteYPosBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.spriteYPosBox.Location = new System.Drawing.Point(77, 19);
this.spriteYPosBox.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.spriteYPosBox.Minimum = new decimal(new int[] {
2147483647,
0,
0,
-2147483648});
this.spriteYPosBox.Name = "spriteYPosBox";
this.spriteYPosBox.Size = new System.Drawing.Size(43, 20);
this.spriteYPosBox.TabIndex = 8;
this.spriteYPosBox.ValueChanged += new System.EventHandler(this.spriteYPosBox_ValueChanged);
//
// spriteXPosBox
//
this.spriteXPosBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.spriteXPosBox.Location = new System.Drawing.Point(16, 19);
this.spriteXPosBox.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.spriteXPosBox.Minimum = new decimal(new int[] {
2147483647,
0,
0,
-2147483648});
this.spriteXPosBox.Name = "spriteXPosBox";
this.spriteXPosBox.Size = new System.Drawing.Size(43, 20);
this.spriteXPosBox.TabIndex = 8;
this.spriteXPosBox.ValueChanged += new System.EventHandler(this.spriteXPosBox_ValueChanged);
//
// removeSpriteButton // removeSpriteButton
// //
this.removeSpriteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.removeSpriteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@@ -487,47 +567,17 @@
this.moveSpriteDownButton.UseVisualStyleBackColor = true; this.moveSpriteDownButton.UseVisualStyleBackColor = true;
this.moveSpriteDownButton.Click += new System.EventHandler(this.moveSpriteDownButton_Click); this.moveSpriteDownButton.Click += new System.EventHandler(this.moveSpriteDownButton_Click);
// //
// frameSpritePositionLabel
//
this.frameSpritePositionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.frameSpritePositionLabel.AutoSize = true;
this.frameSpritePositionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.frameSpritePositionLabel.Location = new System.Drawing.Point(33, 82);
this.frameSpritePositionLabel.Name = "frameSpritePositionLabel";
this.frameSpritePositionLabel.Size = new System.Drawing.Size(86, 13);
this.frameSpritePositionLabel.TabIndex = 23;
this.frameSpritePositionLabel.Text = "Sprite Positon";
//
// frameSpriteListBox // frameSpriteListBox
// //
this.frameSpriteListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.frameSpriteListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.frameSpriteListBox.FormattingEnabled = true; this.frameSpriteListBox.FormattingEnabled = true;
this.frameSpriteListBox.Location = new System.Drawing.Point(34, 23); this.frameSpriteListBox.Location = new System.Drawing.Point(34, 23);
this.frameSpriteListBox.Name = "frameSpriteListBox"; this.frameSpriteListBox.Name = "frameSpriteListBox";
this.frameSpriteListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
this.frameSpriteListBox.Size = new System.Drawing.Size(120, 56); this.frameSpriteListBox.Size = new System.Drawing.Size(120, 56);
this.frameSpriteListBox.TabIndex = 22; this.frameSpriteListBox.TabIndex = 22;
this.frameSpriteListBox.SelectedIndexChanged += new System.EventHandler(this.frameSpriteListBox_SelectedIndexChanged); this.frameSpriteListBox.SelectedIndexChanged += new System.EventHandler(this.frameSpriteListBox_SelectedIndexChanged);
// //
// spriteYPosLabel
//
this.spriteYPosLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.spriteYPosLabel.AutoSize = true;
this.spriteYPosLabel.Location = new System.Drawing.Point(94, 102);
this.spriteYPosLabel.Name = "spriteYPosLabel";
this.spriteYPosLabel.Size = new System.Drawing.Size(14, 13);
this.spriteYPosLabel.TabIndex = 18;
this.spriteYPosLabel.Text = "Y";
//
// spriteXPosLabel
//
this.spriteXPosLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.spriteXPosLabel.AutoSize = true;
this.spriteXPosLabel.Location = new System.Drawing.Point(33, 102);
this.spriteXPosLabel.Name = "spriteXPosLabel";
this.spriteXPosLabel.Size = new System.Drawing.Size(14, 13);
this.spriteXPosLabel.TabIndex = 18;
this.spriteXPosLabel.Text = "X";
//
// frameSpriteListLabel // frameSpriteListLabel
// //
this.frameSpriteListLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.frameSpriteListLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@@ -539,6 +589,18 @@
this.frameSpriteListLabel.TabIndex = 16; this.frameSpriteListLabel.TabIndex = 16;
this.frameSpriteListLabel.Text = "Sprites"; this.frameSpriteListLabel.Text = "Sprites";
// //
// replaceSpriteButton
//
this.replaceSpriteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.replaceSpriteButton.Location = new System.Drawing.Point(1, 56);
this.replaceSpriteButton.Name = "replaceSpriteButton";
this.replaceSpriteButton.Size = new System.Drawing.Size(27, 23);
this.replaceSpriteButton.TabIndex = 5;
this.replaceSpriteButton.Text = "@";
this.replaceSpriteButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.replaceSpriteButton.UseVisualStyleBackColor = true;
this.replaceSpriteButton.Click += new System.EventHandler(this.replaceSpriteButton_Click);
//
// addSpriteToFrameSpritesButton // addSpriteToFrameSpritesButton
// //
this.addSpriteToFrameSpritesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.addSpriteToFrameSpritesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@@ -550,44 +612,6 @@
this.addSpriteToFrameSpritesButton.UseVisualStyleBackColor = true; this.addSpriteToFrameSpritesButton.UseVisualStyleBackColor = true;
this.addSpriteToFrameSpritesButton.Click += new System.EventHandler(this.addSpriteToFrameSpritesButton_Click); this.addSpriteToFrameSpritesButton.Click += new System.EventHandler(this.addSpriteToFrameSpritesButton_Click);
// //
// spriteYPosBox
//
this.spriteYPosBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.spriteYPosBox.Location = new System.Drawing.Point(109, 100);
this.spriteYPosBox.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.spriteYPosBox.Minimum = new decimal(new int[] {
2147483647,
0,
0,
-2147483648});
this.spriteYPosBox.Name = "spriteYPosBox";
this.spriteYPosBox.Size = new System.Drawing.Size(43, 20);
this.spriteYPosBox.TabIndex = 8;
this.spriteYPosBox.ValueChanged += new System.EventHandler(this.spriteYPosBox_ValueChanged);
//
// spriteXPosBox
//
this.spriteXPosBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.spriteXPosBox.Location = new System.Drawing.Point(48, 100);
this.spriteXPosBox.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.spriteXPosBox.Minimum = new decimal(new int[] {
2147483647,
0,
0,
-2147483648});
this.spriteXPosBox.Name = "spriteXPosBox";
this.spriteXPosBox.Size = new System.Drawing.Size(43, 20);
this.spriteXPosBox.TabIndex = 8;
this.spriteXPosBox.ValueChanged += new System.EventHandler(this.spriteXPosBox_ValueChanged);
//
// importDelayLabel // importDelayLabel
// //
this.importDelayLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.importDelayLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@@ -669,6 +693,16 @@
this.spriteBoxLabel.TabIndex = 15; this.spriteBoxLabel.TabIndex = 15;
this.spriteBoxLabel.Text = "Sprite Selection"; this.spriteBoxLabel.Text = "Sprite Selection";
// //
// duplicateFrameButton
//
this.duplicateFrameButton.Location = new System.Drawing.Point(130, 18);
this.duplicateFrameButton.Name = "duplicateFrameButton";
this.duplicateFrameButton.Size = new System.Drawing.Size(27, 23);
this.duplicateFrameButton.TabIndex = 12;
this.duplicateFrameButton.Text = "++";
this.duplicateFrameButton.UseVisualStyleBackColor = true;
this.duplicateFrameButton.Click += new System.EventHandler(this.duplicateFrameButton_Click);
//
// addEmptyFrameButton // addEmptyFrameButton
// //
this.addEmptyFrameButton.Location = new System.Drawing.Point(162, 18); this.addEmptyFrameButton.Location = new System.Drawing.Point(162, 18);
@@ -719,29 +753,13 @@
this.animationLabel.TabIndex = 22; this.animationLabel.TabIndex = 22;
this.animationLabel.Text = "Animation"; this.animationLabel.Text = "Animation";
// //
// loadAnimationSetDialog
//
this.loadAnimationSetDialog.DefaultExt = "animset";
this.loadAnimationSetDialog.FileName = "openFileDialog1";
this.loadAnimationSetDialog.Filter = "QUROGames AnimationSet|*.animSet";
//
// duplicateFrameButton
//
this.duplicateFrameButton.Location = new System.Drawing.Point(130, 18);
this.duplicateFrameButton.Name = "duplicateFrameButton";
this.duplicateFrameButton.Size = new System.Drawing.Size(27, 23);
this.duplicateFrameButton.TabIndex = 12;
this.duplicateFrameButton.Text = "++";
this.duplicateFrameButton.UseVisualStyleBackColor = true;
this.duplicateFrameButton.Click += new System.EventHandler(this.duplicateFrameButton_Click);
//
// animationPreview // animationPreview
// //
this.animationPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.animationPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.animationPreview.BackColor = System.Drawing.SystemColors.ControlDarkDark; this.animationPreview.BackColor = System.Drawing.SystemColors.ControlDarkDark;
this.animationPreview.EditSprite = null; this.animationPreview.EditSprites = null;
this.animationPreview.GridSpacing = 0; this.animationPreview.GridSpacing = 0;
this.animationPreview.Location = new System.Drawing.Point(3, 26); this.animationPreview.Location = new System.Drawing.Point(3, 26);
this.animationPreview.Name = "animationPreview"; this.animationPreview.Name = "animationPreview";
@@ -755,17 +773,11 @@
this.animationPreview.ZoomLevel = 0F; this.animationPreview.ZoomLevel = 0F;
this.animationPreview.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.animationPreview_MouseWheel); this.animationPreview.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.animationPreview_MouseWheel);
// //
// replaceSpriteButton // loadAnimationSetDialog
// //
this.replaceSpriteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.loadAnimationSetDialog.DefaultExt = "animset";
this.replaceSpriteButton.Location = new System.Drawing.Point(1, 56); this.loadAnimationSetDialog.FileName = "openFileDialog1";
this.replaceSpriteButton.Name = "replaceSpriteButton"; this.loadAnimationSetDialog.Filter = "QUROGames AnimationSet|*.animSet";
this.replaceSpriteButton.Size = new System.Drawing.Size(27, 23);
this.replaceSpriteButton.TabIndex = 5;
this.replaceSpriteButton.Text = "@";
this.replaceSpriteButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.replaceSpriteButton.UseVisualStyleBackColor = true;
this.replaceSpriteButton.Click += new System.EventHandler(this.replaceSpriteButton_Click);
// //
// Form1 // Form1
// //
@@ -788,6 +800,8 @@
this.frameEditorPanel.PerformLayout(); this.frameEditorPanel.PerformLayout();
this.frameSpritePanel.ResumeLayout(false); this.frameSpritePanel.ResumeLayout(false);
this.frameSpritePanel.PerformLayout(); this.frameSpritePanel.PerformLayout();
this.spritePosPanel.ResumeLayout(false);
this.spritePosPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.importDelayBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.importDelayBox)).EndInit();
@@ -862,6 +876,7 @@
private System.Windows.Forms.Button moveSpriteDownButton; private System.Windows.Forms.Button moveSpriteDownButton;
private System.Windows.Forms.Button duplicateFrameButton; private System.Windows.Forms.Button duplicateFrameButton;
private System.Windows.Forms.Button replaceSpriteButton; private System.Windows.Forms.Button replaceSpriteButton;
private System.Windows.Forms.Panel spritePosPanel;
} }
} }
+119 -4
View File
@@ -41,6 +41,7 @@ namespace AnimationEditor
private Animation currentAnimation; private Animation currentAnimation;
private Frame currentFrame; private Frame currentFrame;
private bool tracking;
private bool reading; private bool reading;
private float importDelay = 0; private float importDelay = 0;
@@ -157,6 +158,39 @@ namespace AnimationEditor
} }
} }
private void UpdateEnabledControls()
{
bool singleFrameSelected = frameListBox.SelectedIndices.Count < 2;
bool singleSpriteSelected = frameSpriteListBox.SelectedIndices.Count < 2;
//update per-frame controls
frameSpritePanel.Enabled = singleFrameSelected;
moveFrameDownButton.Enabled = singleFrameSelected;
moveFrameUpButton.Enabled = singleFrameSelected;
removeFrameButton.Enabled = singleFrameSelected;
duplicateFrameButton.Enabled = singleFrameSelected;
//update per-sprite controls
spritePosPanel.Enabled = singleSpriteSelected;
replaceSpriteButton.Enabled = singleSpriteSelected;
moveSpriteDownButton.Enabled = singleSpriteSelected;
moveSpriteUpButton.Enabled = singleSpriteSelected;
removeSpriteButton.Enabled = singleSpriteSelected;
reading = true;
if (!singleSpriteSelected)
{
spriteXPosBox.Text = "";
spriteYPosBox.Text = "";
}
else
{
spriteXPosBox.Text = spriteXPosBox.Value.ToString();
spriteYPosBox.Text = spriteYPosBox.Value.ToString();
}
reading = false;
}
private void ReadAnimationInfo() private void ReadAnimationInfo()
{ {
reading = true; reading = true;
@@ -184,26 +218,61 @@ namespace AnimationEditor
private void frameListBox_SelectedIndexChanged(object sender, EventArgs e) private void frameListBox_SelectedIndexChanged(object sender, EventArgs e)
{ {
if(!tracking)
UpdateEnabledControls();
if (frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedItem != null) if (frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedItem != null)
{ {
//create copy of current frameSprite selection
List<int> oldFrameSpriteSelection = new List<int>();
foreach (int index in frameSpriteListBox.SelectedIndices)
{
oldFrameSpriteSelection.Add(index);
}
//update currentFrame to match selection
currentFrame = (Frame)frameListBox.SelectedItem; currentFrame = (Frame)frameListBox.SelectedItem;
//update preview and frameTrackBar frame positions
if (animationPreview.PreviewSprite != null && !animationPreview.Playing) if (animationPreview.PreviewSprite != null && !animationPreview.Playing)
{ {
animationPreview.PreviewSprite.CurrentFrameIndex = frameListBox.SelectedIndex; animationPreview.PreviewSprite.CurrentFrameIndex = frameListBox.SelectedIndex;
frameTrackBar.Value = frameListBox.SelectedIndex; frameTrackBar.Value = frameListBox.SelectedIndex;
} }
frameSpritePanel.Enabled = true;
//update frameSpriteListBox with the current frame's sprites
if (currentFrame.Sprites != null) if (currentFrame.Sprites != null)
frameSprites = new BindingList<Sprite>(currentFrame.Sprites); frameSprites = new BindingList<Sprite>(currentFrame.Sprites);
else else
frameSprites = new BindingList<Sprite>(); frameSprites = new BindingList<Sprite>();
frameSpriteListBox.DataSource = frameSprites; frameSpriteListBox.DataSource = frameSprites;
frameSpriteListBox.DisplayMember = "Name"; frameSpriteListBox.DisplayMember = "Name";
//restore old frameSprite selection
frameSpriteListBox.SelectedIndices.Clear();
foreach(int index in oldFrameSpriteSelection)
{
if(index < frameSprites.Count)
{
frameSpriteListBox.SelectedIndex = index;
}
}
//update forms fields to match selected frame's informations
UpdateFrameInformation(); UpdateFrameInformation();
} }
else if (frameListBox.SelectedIndices.Count > 1) else if (frameListBox.SelectedIndices.Count > 1)
{ {
//disable frameSpritePanel, as multi frame sprite editing is not yet possible
frameSpritePanel.Enabled = false; frameSpritePanel.Enabled = false;
//disable single frame controls
moveFrameDownButton.Enabled = false;
moveFrameUpButton.Enabled = false;
removeFrameButton.Enabled = false;
duplicateFrameButton.Enabled = false;
//disable preview sprite drag+drop functionality
if (animationPreview.EditSprites != null)
animationPreview.EditSprites.Clear();
} }
} }
@@ -224,7 +293,6 @@ namespace AnimationEditor
} }
} }
private void loadSpriteSheetToolStripMenuItem_Click(object sender, EventArgs e) private void loadSpriteSheetToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (loadSpriteSheetDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) if (loadSpriteSheetDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
@@ -315,8 +383,10 @@ namespace AnimationEditor
{ {
if (!animationPreview.Playing) if (!animationPreview.Playing)
{ {
tracking = true;
animationPreview.PreviewSprite.CurrentFrameIndex = frameTrackBar.Value; animationPreview.PreviewSprite.CurrentFrameIndex = frameTrackBar.Value;
frameListBox_SetSingleSelection(frameTrackBar.Value); frameListBox_SetSingleSelection(frameTrackBar.Value);
tracking = false;
} }
} }
@@ -542,12 +612,27 @@ namespace AnimationEditor
private void frameSpriteListBox_SelectedIndexChanged(object sender, EventArgs e) private void frameSpriteListBox_SelectedIndexChanged(object sender, EventArgs e)
{ {
if(!tracking)
UpdateEnabledControls();
if (frameSpriteListBox.SelectedIndex > -1 && frameSpriteListBox.SelectedIndex < frameSprites.Count) if (frameSpriteListBox.SelectedIndex > -1 && frameSpriteListBox.SelectedIndex < frameSprites.Count)
{ {
animationPreview.EditSprite = frameSprites[frameSpriteListBox.SelectedIndex]; //check if animationPreview has initialized EditSprites; do so if not, and if so, clear it
if (animationPreview.EditSprites == null)
animationPreview.EditSprites = new List<Sprite>();
else
animationPreview.EditSprites.Clear();
//add selected sprites to EditSprites list
foreach(int index in frameSpriteListBox.SelectedIndices)
{
if(index < frameSprites.Count)
animationPreview.EditSprites.Add(frameSprites[index]);
}
if (frameSpriteListBox.SelectedIndices.Count == 1)
{
ReadSpriteOffset(); ReadSpriteOffset();
} }
} }
}
//load selected sprite's position into the sprite position boxes //load selected sprite's position into the sprite position boxes
private void ReadSpriteOffset() private void ReadSpriteOffset()
@@ -598,7 +683,36 @@ namespace AnimationEditor
{ {
if (reading) if (reading)
return; return;
currentFrame.Name = frameNameBox.Text;
bool changed = false;
foreach(int index in frameListBox.SelectedIndices)
{
if (frames[index].Name != frameNameBox.Text)
{
frames[index].Name = frameNameBox.Text;
changed = true;
}
}
if (changed)
{
//store current frame selection data
List<int> selection = new List<int>();
foreach (int index in frameListBox.SelectedIndices)
{
selection.Add(index);
}
//refresh list so name changes are reflected in form
frames.ResetBindings();
//restore selection
reading = true;
foreach(int index in selection)
{
frameListBox.SelectedIndex = index;
}
reading = false;
}
} }
private void moveSpriteDownButton_Click(object sender, EventArgs e) private void moveSpriteDownButton_Click(object sender, EventArgs e)
@@ -642,6 +756,7 @@ namespace AnimationEditor
private void animationPreview_SpriteMoved(object sender, EventArgs e) private void animationPreview_SpriteMoved(object sender, EventArgs e)
{ {
if(frameSpriteListBox.SelectedIndices.Count == 1)
ReadSpriteOffset(); ReadSpriteOffset();
} }