Added: Multi-sprite drag, Sprite selection memory between frames, Frame naming
This commit is contained in:
@@ -20,7 +20,7 @@ namespace AnimationEditor
|
||||
public float ZoomLevel { 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 GridSpacing { get; set; }
|
||||
@@ -142,7 +142,10 @@ namespace AnimationEditor
|
||||
|
||||
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
|
||||
*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
|
||||
*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));
|
||||
spriteRect.Offset((EditSprite.Offset - EditSprite.Origin) * ZoomLevel + new Vector2(CameraLocation.X, CameraLocation.Y) * ZoomLevel + centerPoint);
|
||||
Rectangle sprRect = new Rectangle(0, 0, (int)(spr.Bounds.Width * ZoomLevel), (int)(spr.Bounds.Height * ZoomLevel));
|
||||
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
|
||||
Rectangle frame = new Rectangle(Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);
|
||||
frame.Y = 0;
|
||||
|
||||
if (spriteRect.Contains(mState.Position))
|
||||
if (hoverFound)
|
||||
{
|
||||
if (!hovering)
|
||||
{
|
||||
@@ -189,7 +194,10 @@ namespace AnimationEditor
|
||||
|
||||
if (distMoved != Vector2.Zero)
|
||||
{
|
||||
EditSprite.Offset += distMoved;
|
||||
foreach(Sprite spr in EditSprites)
|
||||
{
|
||||
spr.Offset += distMoved;
|
||||
}
|
||||
OnSpriteMoved(new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+124
-109
@@ -63,17 +63,19 @@
|
||||
this.frameEditorPanel = new System.Windows.Forms.Panel();
|
||||
this.frameNameBox = new System.Windows.Forms.TextBox();
|
||||
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.moveSpriteUpButton = 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.spriteYPosLabel = new System.Windows.Forms.Label();
|
||||
this.spriteXPosLabel = 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.spriteYPosBox = new System.Windows.Forms.NumericUpDown();
|
||||
this.spriteXPosBox = new System.Windows.Forms.NumericUpDown();
|
||||
this.importDelayLabel = new System.Windows.Forms.Label();
|
||||
this.importValuesLabel = new System.Windows.Forms.Label();
|
||||
this.importDelayBox = new System.Windows.Forms.NumericUpDown();
|
||||
@@ -82,20 +84,20 @@
|
||||
this.frameInfoLabel = new System.Windows.Forms.Label();
|
||||
this.frameBoxLabel = 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.animationPanel = new System.Windows.Forms.Panel();
|
||||
this.animationNameLabel = 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.replaceSpriteButton = new System.Windows.Forms.Button();
|
||||
this.loadAnimationSetDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.spritePreview)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.frameTrackBar)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.delayInputBox)).BeginInit();
|
||||
this.mainMenuStrip.SuspendLayout();
|
||||
this.frameEditorPanel.SuspendLayout();
|
||||
this.frameSpritePanel.SuspendLayout();
|
||||
this.spritePosPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.importDelayBox)).BeginInit();
|
||||
@@ -430,27 +432,105 @@
|
||||
this.frameNameBox.Name = "frameNameBox";
|
||||
this.frameNameBox.Size = new System.Drawing.Size(83, 20);
|
||||
this.frameNameBox.TabIndex = 25;
|
||||
this.frameNameBox.TextChanged += new System.EventHandler(this.frameNameBox_TextChanged);
|
||||
//
|
||||
// frameSpritePanel
|
||||
//
|
||||
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.moveSpriteUpButton);
|
||||
this.frameSpritePanel.Controls.Add(this.moveSpriteDownButton);
|
||||
this.frameSpritePanel.Controls.Add(this.frameSpritePositionLabel);
|
||||
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.replaceSpriteButton);
|
||||
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.Name = "frameSpritePanel";
|
||||
this.frameSpritePanel.Size = new System.Drawing.Size(161, 126);
|
||||
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
|
||||
//
|
||||
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.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
|
||||
//
|
||||
this.frameSpriteListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.frameSpriteListBox.FormattingEnabled = true;
|
||||
this.frameSpriteListBox.Location = new System.Drawing.Point(34, 23);
|
||||
this.frameSpriteListBox.Name = "frameSpriteListBox";
|
||||
this.frameSpriteListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
|
||||
this.frameSpriteListBox.Size = new System.Drawing.Size(120, 56);
|
||||
this.frameSpriteListBox.TabIndex = 22;
|
||||
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
|
||||
//
|
||||
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.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
|
||||
//
|
||||
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.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
|
||||
//
|
||||
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.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
|
||||
//
|
||||
this.addEmptyFrameButton.Location = new System.Drawing.Point(162, 18);
|
||||
@@ -719,29 +753,13 @@
|
||||
this.animationLabel.TabIndex = 22;
|
||||
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
|
||||
//
|
||||
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.Right)));
|
||||
this.animationPreview.BackColor = System.Drawing.SystemColors.ControlDarkDark;
|
||||
this.animationPreview.EditSprite = null;
|
||||
this.animationPreview.EditSprites = null;
|
||||
this.animationPreview.GridSpacing = 0;
|
||||
this.animationPreview.Location = new System.Drawing.Point(3, 26);
|
||||
this.animationPreview.Name = "animationPreview";
|
||||
@@ -755,17 +773,11 @@
|
||||
this.animationPreview.ZoomLevel = 0F;
|
||||
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.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);
|
||||
this.loadAnimationSetDialog.DefaultExt = "animset";
|
||||
this.loadAnimationSetDialog.FileName = "openFileDialog1";
|
||||
this.loadAnimationSetDialog.Filter = "QUROGames AnimationSet|*.animSet";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
@@ -788,6 +800,8 @@
|
||||
this.frameEditorPanel.PerformLayout();
|
||||
this.frameSpritePanel.ResumeLayout(false);
|
||||
this.frameSpritePanel.PerformLayout();
|
||||
this.spritePosPanel.ResumeLayout(false);
|
||||
this.spritePosPanel.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.importDelayBox)).EndInit();
|
||||
@@ -862,6 +876,7 @@
|
||||
private System.Windows.Forms.Button moveSpriteDownButton;
|
||||
private System.Windows.Forms.Button duplicateFrameButton;
|
||||
private System.Windows.Forms.Button replaceSpriteButton;
|
||||
private System.Windows.Forms.Panel spritePosPanel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+119
-4
@@ -41,6 +41,7 @@ namespace AnimationEditor
|
||||
private Animation currentAnimation;
|
||||
private Frame currentFrame;
|
||||
|
||||
private bool tracking;
|
||||
private bool reading;
|
||||
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()
|
||||
{
|
||||
reading = true;
|
||||
@@ -184,26 +218,61 @@ namespace AnimationEditor
|
||||
|
||||
private void frameListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(!tracking)
|
||||
UpdateEnabledControls();
|
||||
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;
|
||||
//update preview and frameTrackBar frame positions
|
||||
if (animationPreview.PreviewSprite != null && !animationPreview.Playing)
|
||||
{
|
||||
animationPreview.PreviewSprite.CurrentFrameIndex = frameListBox.SelectedIndex;
|
||||
frameTrackBar.Value = frameListBox.SelectedIndex;
|
||||
}
|
||||
frameSpritePanel.Enabled = true;
|
||||
|
||||
//update frameSpriteListBox with the current frame's sprites
|
||||
if (currentFrame.Sprites != null)
|
||||
frameSprites = new BindingList<Sprite>(currentFrame.Sprites);
|
||||
else
|
||||
frameSprites = new BindingList<Sprite>();
|
||||
frameSpriteListBox.DataSource = frameSprites;
|
||||
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();
|
||||
}
|
||||
else if (frameListBox.SelectedIndices.Count > 1)
|
||||
{
|
||||
//disable frameSpritePanel, as multi frame sprite editing is not yet possible
|
||||
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)
|
||||
{
|
||||
if (loadSpriteSheetDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
@@ -315,8 +383,10 @@ namespace AnimationEditor
|
||||
{
|
||||
if (!animationPreview.Playing)
|
||||
{
|
||||
tracking = true;
|
||||
animationPreview.PreviewSprite.CurrentFrameIndex = frameTrackBar.Value;
|
||||
frameListBox_SetSingleSelection(frameTrackBar.Value);
|
||||
tracking = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,12 +612,27 @@ namespace AnimationEditor
|
||||
|
||||
private void frameSpriteListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(!tracking)
|
||||
UpdateEnabledControls();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//load selected sprite's position into the sprite position boxes
|
||||
private void ReadSpriteOffset()
|
||||
@@ -598,7 +683,36 @@ namespace AnimationEditor
|
||||
{
|
||||
if (reading)
|
||||
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)
|
||||
@@ -642,6 +756,7 @@ namespace AnimationEditor
|
||||
|
||||
private void animationPreview_SpriteMoved(object sender, EventArgs e)
|
||||
{
|
||||
if(frameSpriteListBox.SelectedIndices.Count == 1)
|
||||
ReadSpriteOffset();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user