Prepared for MultiSelect Implementation

This commit is contained in:
quinnvoker
2018-11-30 20:34:26 -08:00
parent 8edc345953
commit 4a09f48266
2 changed files with 103 additions and 96 deletions
+57 -43
View File
@@ -36,6 +36,7 @@
this.moveUpButton = new System.Windows.Forms.Button(); this.moveUpButton = new System.Windows.Forms.Button();
this.spritesLabel = new System.Windows.Forms.Label(); this.spritesLabel = new System.Windows.Forms.Label();
this.spritePanel = new System.Windows.Forms.Panel(); this.spritePanel = new System.Windows.Forms.Panel();
this.editingOriginCheckBox = new System.Windows.Forms.CheckBox();
this.originYPosBox = new System.Windows.Forms.NumericUpDown(); this.originYPosBox = new System.Windows.Forms.NumericUpDown();
this.originXPosBox = new System.Windows.Forms.NumericUpDown(); this.originXPosBox = new System.Windows.Forms.NumericUpDown();
this.originYPosLabel = new System.Windows.Forms.Label(); this.originYPosLabel = new System.Windows.Forms.Label();
@@ -54,8 +55,8 @@
this.loadSpriteSheetDialog = new System.Windows.Forms.OpenFileDialog(); this.loadSpriteSheetDialog = new System.Windows.Forms.OpenFileDialog();
this.loadMapDialog = new System.Windows.Forms.OpenFileDialog(); this.loadMapDialog = new System.Windows.Forms.OpenFileDialog();
this.saveMapDialog = new System.Windows.Forms.SaveFileDialog(); this.saveMapDialog = new System.Windows.Forms.SaveFileDialog();
this.fillButton = new System.Windows.Forms.Button();
this.spriteViewerPanel = new System.Windows.Forms.Panel(); this.spriteViewerPanel = new System.Windows.Forms.Panel();
this.spriteSheetViewer = new SpriteMapEditor.PictureBoxWithInterpolationMode();
this.zoomInButton = new System.Windows.Forms.Button(); this.zoomInButton = new System.Windows.Forms.Button();
this.zoomOutButton = new System.Windows.Forms.Button(); this.zoomOutButton = new System.Windows.Forms.Button();
this.zoomLabel = new System.Windows.Forms.Label(); this.zoomLabel = new System.Windows.Forms.Label();
@@ -66,8 +67,7 @@
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.saveSpriteMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveSpriteMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveSpriteMapAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveSpriteMapAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editingOriginCheckBox = new System.Windows.Forms.CheckBox(); this.highlightCheckBox = new System.Windows.Forms.CheckBox();
this.spriteSheetViewer = new SpriteMapEditor.PictureBoxWithInterpolationMode();
this.spriteListPanel.SuspendLayout(); this.spriteListPanel.SuspendLayout();
this.spritePanel.SuspendLayout(); this.spritePanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.originYPosBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.originYPosBox)).BeginInit();
@@ -77,8 +77,8 @@
((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).BeginInit();
this.spriteViewerPanel.SuspendLayout(); this.spriteViewerPanel.SuspendLayout();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.spriteSheetViewer)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.spriteSheetViewer)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// spriteList // spriteList
@@ -87,6 +87,7 @@
this.spriteList.FormattingEnabled = true; this.spriteList.FormattingEnabled = true;
this.spriteList.Location = new System.Drawing.Point(3, 32); this.spriteList.Location = new System.Drawing.Point(3, 32);
this.spriteList.Name = "spriteList"; this.spriteList.Name = "spriteList";
this.spriteList.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
this.spriteList.Size = new System.Drawing.Size(183, 199); this.spriteList.Size = new System.Drawing.Size(183, 199);
this.spriteList.TabIndex = 0; this.spriteList.TabIndex = 0;
this.spriteList.SelectedValueChanged += new System.EventHandler(this.spriteList_SelectedValueChanged); this.spriteList.SelectedValueChanged += new System.EventHandler(this.spriteList_SelectedValueChanged);
@@ -182,6 +183,17 @@
this.spritePanel.Size = new System.Drawing.Size(190, 172); this.spritePanel.Size = new System.Drawing.Size(190, 172);
this.spritePanel.TabIndex = 9; this.spritePanel.TabIndex = 9;
// //
// editingOriginCheckBox
//
this.editingOriginCheckBox.AutoSize = true;
this.editingOriginCheckBox.Location = new System.Drawing.Point(9, 108);
this.editingOriginCheckBox.Name = "editingOriginCheckBox";
this.editingOriginCheckBox.Size = new System.Drawing.Size(107, 17);
this.editingOriginCheckBox.TabIndex = 23;
this.editingOriginCheckBox.Text = "Edit Origin Point?";
this.editingOriginCheckBox.UseVisualStyleBackColor = true;
this.editingOriginCheckBox.CheckedChanged += new System.EventHandler(this.editingOriginCheckBox_CheckedChanged);
//
// originYPosBox // originYPosBox
// //
this.originYPosBox.Enabled = false; this.originYPosBox.Enabled = false;
@@ -191,6 +203,11 @@
0, 0,
0, 0,
0}); 0});
this.originYPosBox.Minimum = new decimal(new int[] {
2147483647,
0,
0,
-2147483648});
this.originYPosBox.Name = "originYPosBox"; this.originYPosBox.Name = "originYPosBox";
this.originYPosBox.Size = new System.Drawing.Size(45, 20); this.originYPosBox.Size = new System.Drawing.Size(45, 20);
this.originYPosBox.TabIndex = 22; this.originYPosBox.TabIndex = 22;
@@ -205,6 +222,11 @@
0, 0,
0, 0,
0}); 0});
this.originXPosBox.Minimum = new decimal(new int[] {
2147483647,
0,
0,
-2147483648});
this.originXPosBox.Name = "originXPosBox"; this.originXPosBox.Name = "originXPosBox";
this.originXPosBox.Size = new System.Drawing.Size(45, 20); this.originXPosBox.Size = new System.Drawing.Size(45, 20);
this.originXPosBox.TabIndex = 21; this.originXPosBox.TabIndex = 21;
@@ -361,16 +383,6 @@
this.saveMapDialog.DefaultExt = "smap"; this.saveMapDialog.DefaultExt = "smap";
this.saveMapDialog.Filter = "QUROGame SpriteMap|*.smap"; this.saveMapDialog.Filter = "QUROGame SpriteMap|*.smap";
// //
// fillButton
//
this.fillButton.Location = new System.Drawing.Point(461, 30);
this.fillButton.Name = "fillButton";
this.fillButton.Size = new System.Drawing.Size(86, 23);
this.fillButton.TabIndex = 12;
this.fillButton.Text = "Highight";
this.fillButton.UseVisualStyleBackColor = true;
this.fillButton.Click += new System.EventHandler(this.highlightButton_Click);
//
// spriteViewerPanel // spriteViewerPanel
// //
this.spriteViewerPanel.AutoScroll = true; this.spriteViewerPanel.AutoScroll = true;
@@ -383,6 +395,23 @@
this.spriteViewerPanel.TabIndex = 14; this.spriteViewerPanel.TabIndex = 14;
this.spriteViewerPanel.Scroll += new System.Windows.Forms.ScrollEventHandler(this.spriteViewerPanel_Scroll); this.spriteViewerPanel.Scroll += new System.Windows.Forms.ScrollEventHandler(this.spriteViewerPanel_Scroll);
// //
// spriteSheetViewer
//
this.spriteSheetViewer.BackgroundImage = global::SpriteMapEditor.Properties.Resources.transparentUI;
this.spriteSheetViewer.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
this.spriteSheetViewer.Location = new System.Drawing.Point(0, 0);
this.spriteSheetViewer.Margin = new System.Windows.Forms.Padding(0);
this.spriteSheetViewer.Name = "spriteSheetViewer";
this.spriteSheetViewer.Size = new System.Drawing.Size(147, 143);
this.spriteSheetViewer.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.spriteSheetViewer.TabIndex = 13;
this.spriteSheetViewer.TabStop = false;
this.spriteSheetViewer.Paint += new System.Windows.Forms.PaintEventHandler(this.spriteSheetViewer_Paint);
this.spriteSheetViewer.MouseDown += new System.Windows.Forms.MouseEventHandler(this.spriteSheetViewer_MouseDown);
this.spriteSheetViewer.MouseLeave += new System.EventHandler(this.spriteSheetViewer_MouseLeave);
this.spriteSheetViewer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.spriteSheetViewer_MouseMove);
this.spriteSheetViewer.MouseUp += new System.Windows.Forms.MouseEventHandler(this.spriteSheetViewer_MouseUp);
//
// zoomInButton // zoomInButton
// //
this.zoomInButton.Location = new System.Drawing.Point(659, 30); this.zoomInButton.Location = new System.Drawing.Point(659, 30);
@@ -467,33 +496,18 @@
this.saveSpriteMapAsToolStripMenuItem.Text = "Save Sprite Map As..."; this.saveSpriteMapAsToolStripMenuItem.Text = "Save Sprite Map As...";
this.saveSpriteMapAsToolStripMenuItem.Click += new System.EventHandler(this.saveMapAsToolStripMenuItem_Click); this.saveSpriteMapAsToolStripMenuItem.Click += new System.EventHandler(this.saveMapAsToolStripMenuItem_Click);
// //
// editingOriginCheckBox // highlightCheckBox
// //
this.editingOriginCheckBox.AutoSize = true; this.highlightCheckBox.AutoSize = true;
this.editingOriginCheckBox.Location = new System.Drawing.Point(9, 108); this.highlightCheckBox.Checked = true;
this.editingOriginCheckBox.Name = "editingOriginCheckBox"; this.highlightCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.editingOriginCheckBox.Size = new System.Drawing.Size(107, 17); this.highlightCheckBox.Location = new System.Drawing.Point(446, 34);
this.editingOriginCheckBox.TabIndex = 23; this.highlightCheckBox.Name = "highlightCheckBox";
this.editingOriginCheckBox.Text = "Edit Origin Point?"; this.highlightCheckBox.Size = new System.Drawing.Size(114, 17);
this.editingOriginCheckBox.UseVisualStyleBackColor = true; this.highlightCheckBox.TabIndex = 17;
this.editingOriginCheckBox.CheckedChanged += new System.EventHandler(this.editingOriginCheckBox_CheckedChanged); this.highlightCheckBox.Text = "Highlight Selection";
// this.highlightCheckBox.UseVisualStyleBackColor = true;
// spriteSheetViewer this.highlightCheckBox.CheckedChanged += new System.EventHandler(this.highlightCheckBox_CheckedChanged);
//
this.spriteSheetViewer.BackgroundImage = global::SpriteMapEditor.Properties.Resources.transparentUI;
this.spriteSheetViewer.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
this.spriteSheetViewer.Location = new System.Drawing.Point(0, 0);
this.spriteSheetViewer.Margin = new System.Windows.Forms.Padding(0);
this.spriteSheetViewer.Name = "spriteSheetViewer";
this.spriteSheetViewer.Size = new System.Drawing.Size(147, 143);
this.spriteSheetViewer.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.spriteSheetViewer.TabIndex = 13;
this.spriteSheetViewer.TabStop = false;
this.spriteSheetViewer.Paint += new System.Windows.Forms.PaintEventHandler(this.spriteSheetViewer_Paint);
this.spriteSheetViewer.MouseDown += new System.Windows.Forms.MouseEventHandler(this.spriteSheetViewer_MouseDown);
this.spriteSheetViewer.MouseLeave += new System.EventHandler(this.spriteSheetViewer_MouseLeave);
this.spriteSheetViewer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.spriteSheetViewer_MouseMove);
this.spriteSheetViewer.MouseUp += new System.Windows.Forms.MouseEventHandler(this.spriteSheetViewer_MouseUp);
// //
// Form1 // Form1
// //
@@ -501,11 +515,11 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control; this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(691, 465); this.ClientSize = new System.Drawing.Size(691, 465);
this.Controls.Add(this.highlightCheckBox);
this.Controls.Add(this.zoomLabel); this.Controls.Add(this.zoomLabel);
this.Controls.Add(this.zoomInButton); this.Controls.Add(this.zoomInButton);
this.Controls.Add(this.spriteViewerPanel); this.Controls.Add(this.spriteViewerPanel);
this.Controls.Add(this.zoomOutButton); this.Controls.Add(this.zoomOutButton);
this.Controls.Add(this.fillButton);
this.Controls.Add(this.spritePanel); this.Controls.Add(this.spritePanel);
this.Controls.Add(this.spriteListPanel); this.Controls.Add(this.spriteListPanel);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
@@ -522,9 +536,9 @@
((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.spriteYPosBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.spriteXPosBox)).EndInit();
this.spriteViewerPanel.ResumeLayout(false); this.spriteViewerPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.spriteSheetViewer)).EndInit();
this.menuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout(); this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.spriteSheetViewer)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -548,7 +562,6 @@
private System.Windows.Forms.OpenFileDialog loadSpriteSheetDialog; private System.Windows.Forms.OpenFileDialog loadSpriteSheetDialog;
private System.Windows.Forms.OpenFileDialog loadMapDialog; private System.Windows.Forms.OpenFileDialog loadMapDialog;
private System.Windows.Forms.SaveFileDialog saveMapDialog; private System.Windows.Forms.SaveFileDialog saveMapDialog;
private System.Windows.Forms.Button fillButton;
private PictureBoxWithInterpolationMode spriteSheetViewer; private PictureBoxWithInterpolationMode spriteSheetViewer;
private System.Windows.Forms.Panel spriteViewerPanel; private System.Windows.Forms.Panel spriteViewerPanel;
private System.Windows.Forms.Button zoomInButton; private System.Windows.Forms.Button zoomInButton;
@@ -572,6 +585,7 @@
private System.Windows.Forms.ToolStripMenuItem saveSpriteMapToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveSpriteMapToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveSpriteMapAsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveSpriteMapAsToolStripMenuItem;
private System.Windows.Forms.CheckBox editingOriginCheckBox; private System.Windows.Forms.CheckBox editingOriginCheckBox;
private System.Windows.Forms.CheckBox highlightCheckBox;
} }
} }
+46 -53
View File
@@ -22,7 +22,7 @@ namespace SpriteMapEditor
private BindingList<SpriteMapRegion> sprites; private BindingList<SpriteMapRegion> sprites;
private bool highlight = false; private bool highlight = false;
private SpriteMapRegion currentSprite; private SpriteMapRegion currentSprite { get { return sprites[spriteList.SelectedIndices[0]]; } }
private int zoomLevel = 3; private int zoomLevel = 3;
private bool loadingSprite = false; private bool loadingSprite = false;
@@ -71,8 +71,6 @@ namespace SpriteMapEditor
sprites = new BindingList<SpriteMapRegion> { new SpriteMapRegion() }; sprites = new BindingList<SpriteMapRegion> { new SpriteMapRegion() };
currentSprite = sprites[0];
spriteList.DataSource = sprites; spriteList.DataSource = sprites;
spriteList.DisplayMember = "Name"; spriteList.DisplayMember = "Name";
spriteList.ValueMember = "Bounds"; spriteList.ValueMember = "Bounds";
@@ -80,6 +78,8 @@ namespace SpriteMapEditor
originPointer_black = Properties.Resources.originPointer_black; originPointer_black = Properties.Resources.originPointer_black;
originPointer_white = Properties.Resources.originPointer_white; originPointer_white = Properties.Resources.originPointer_white;
highlight = highlightCheckBox.Checked;
LoadSpriteEditorValues(); LoadSpriteEditorValues();
} }
@@ -104,7 +104,7 @@ namespace SpriteMapEditor
{ {
//SurroundWithTranslucentRects(GetDrawingRect(currentSprite.Bounds, false), Color.Gray, e.Graphics); //SurroundWithTranslucentRects(GetDrawingRect(currentSprite.Bounds, false), Color.Gray, e.Graphics);
//e.Graphics.DrawImage(highlightMask.Bitmap, Point.Empty); //e.Graphics.DrawImage(highlightMask.Bitmap, Point.Empty);
Rectangle highlightBounds = new Rectangle(0,0, spriteSheetViewer.Bounds.Width + 1, spriteSheetViewer.Bounds.Height + 1); Rectangle highlightBounds = new Rectangle(0,0, highlightMask.Width * zoomLevel, highlightMask.Height * zoomLevel);
e.Graphics.DrawImage(highlightMask.Bitmap, highlightBounds); e.Graphics.DrawImage(highlightMask.Bitmap, highlightBounds);
} }
@@ -166,13 +166,8 @@ namespace SpriteMapEditor
drawingRect.Width *= zoomLevel; drawingRect.Width *= zoomLevel;
drawingRect.Height *= zoomLevel; drawingRect.Height *= zoomLevel;
if (outline) drawingRect.Width--;
{ drawingRect.Height--;
drawingRect.X--;
drawingRect.Y--;
drawingRect.Width++;
drawingRect.Height++;
}
return drawingRect; return drawingRect;
} }
@@ -208,12 +203,14 @@ namespace SpriteMapEditor
{ {
if (baseMask == null) if (baseMask == null)
{ {
Color maskColor = Color.FromArgb(128, 32, 32, 32);
highlightMask = new DirectBitmap(spriteSheetViewer.Image.Width, spriteSheetViewer.Image.Height); highlightMask = new DirectBitmap(spriteSheetViewer.Image.Width, spriteSheetViewer.Image.Height);
for (int currentY = 0; currentY < highlightMask.Height; currentY++) for (int currentY = 0; currentY < highlightMask.Height; currentY++)
{ {
for (int currentX = 0; currentX < highlightMask.Width; currentX++) for (int currentX = 0; currentX < highlightMask.Width; currentX++)
{ {
highlightMask.SetPixel(currentX, currentY, Color.Gray); highlightMask.SetPixel(currentX, currentY, maskColor);
} }
} }
baseMask = new DirectBitmap(highlightMask); baseMask = new DirectBitmap(highlightMask);
@@ -224,31 +221,6 @@ namespace SpriteMapEditor
} }
} }
private void SurroundWithTranslucentRects(Rectangle rect, Color color, Graphics graphics)
{
Rectangle topBorder = new Rectangle(0, 0, spriteSheetViewer.Width, rect.Y);
Rectangle leftBorder = new Rectangle(0, rect.Y, rect.X, rect.Height);
Rectangle rightBorder = new Rectangle(rect.X + rect.Width, rect.Y, spriteSheetViewer.Width - rect.X + rect.Width, rect.Height);
Rectangle bottomBorder = new Rectangle(0, rect.Y + rect.Height, spriteSheetViewer.Width, spriteSheetViewer.Height - rect.Y + rect.Height);
FillTranslucentRects(new Rectangle[] { topBorder, leftBorder, rightBorder, bottomBorder }, color, graphics);
}
private void FillTranslucentRect(Rectangle rect, Color color, Graphics graphics)
{
using (Brush whiteBrush = new SolidBrush(Color.FromArgb(128, color)))
{
graphics.FillRectangle(whiteBrush, rect);
}
}
private void FillTranslucentRects(Rectangle[] rects, Color color, Graphics graphics)
{
using (Brush whiteBrush = new SolidBrush(Color.FromArgb(128, color)))
{
graphics.FillRectangles(whiteBrush, rects);
}
}
private void DrawHighContrastOutline(Rectangle rect, Graphics graphics) private void DrawHighContrastOutline(Rectangle rect, Graphics graphics)
{ {
using (Pen blackPen = new Pen(Color.Black)) using (Pen blackPen = new Pen(Color.Black))
@@ -262,19 +234,6 @@ namespace SpriteMapEditor
} }
} }
private void highlightButton_Click(object sender, EventArgs e)
{
highlight = !highlight;
if (highlight)
{
fillButton.Text = "No Highlight";
UpdateHighlightMask();
}
else
fillButton.Text = "Highlight";
spriteSheetViewer.Refresh();
}
private void zoomInButton_Click(object sender, EventArgs e) private void zoomInButton_Click(object sender, EventArgs e)
{ {
zoomLevel++; zoomLevel++;
@@ -356,7 +315,7 @@ namespace SpriteMapEditor
{ {
if (spriteList.SelectedIndex > -1 && spriteList.SelectedIndex < sprites.Count) if (spriteList.SelectedIndex > -1 && spriteList.SelectedIndex < sprites.Count)
{ {
currentSprite = sprites[spriteList.SelectedIndex]; //currentSprite = sprites[spriteList.SelectedIndex];
LoadSpriteEditorValues(); LoadSpriteEditorValues();
UpdateHighlightMask(); UpdateHighlightMask();
spriteSheetViewer.Refresh(); spriteSheetViewer.Refresh();
@@ -462,6 +421,8 @@ namespace SpriteMapEditor
newBounds.X += differenceX; newBounds.X += differenceX;
newBounds.Y += differenceY; newBounds.Y += differenceY;
newBounds = ClampRectangleToSheet(newBounds);
currentSprite.Bounds = newBounds; currentSprite.Bounds = newBounds;
oldPosition = newPosition; oldPosition = newPosition;
UpdateHighlightMask(); UpdateHighlightMask();
@@ -473,6 +434,24 @@ namespace SpriteMapEditor
Cursor = Cursors.Default; Cursor = Cursors.Default;
} }
private Microsoft.Xna.Framework.Rectangle ClampRectangleToSheet(Microsoft.Xna.Framework.Rectangle rect)
{
var clampedRect = rect;
//clamp X value
if (clampedRect.X < 0)
clampedRect.X = 0;
else if (clampedRect.X + clampedRect.Width > spriteSheetViewer.Image.Width)
clampedRect.X = spriteSheetViewer.Image.Width - clampedRect.Width;
//clamp Y value
if (clampedRect.Y < 0)
clampedRect.Y = 0;
else if (clampedRect.Y + clampedRect.Height > spriteSheetViewer.Image.Height)
clampedRect.Y = spriteSheetViewer.Image.Height - clampedRect.Height;
return clampedRect;
}
private void spriteSheetViewer_MouseDown(object sender, MouseEventArgs e) private void spriteSheetViewer_MouseDown(object sender, MouseEventArgs e)
{ {
if (spriteSheetViewer.Image == null) if (spriteSheetViewer.Image == null)
@@ -524,7 +503,9 @@ namespace SpriteMapEditor
var spriteBelow = sprites[spriteList.SelectedIndex + 1]; var spriteBelow = sprites[spriteList.SelectedIndex + 1];
sprites[spriteList.SelectedIndex + 1] = currentSprite; sprites[spriteList.SelectedIndex + 1] = currentSprite;
sprites[spriteList.SelectedIndex] = spriteBelow; sprites[spriteList.SelectedIndex] = spriteBelow;
spriteList.SelectedIndex++; int newPosition = spriteList.SelectedIndex + 1;
spriteList.SelectedIndices.Clear();
spriteList.SelectedIndex = newPosition;
} }
} }
@@ -535,7 +516,9 @@ namespace SpriteMapEditor
var spriteAbove = sprites[spriteList.SelectedIndex - 1]; var spriteAbove = sprites[spriteList.SelectedIndex - 1];
sprites[spriteList.SelectedIndex - 1] = currentSprite; sprites[spriteList.SelectedIndex - 1] = currentSprite;
sprites[spriteList.SelectedIndex] = spriteAbove; sprites[spriteList.SelectedIndex] = spriteAbove;
spriteList.SelectedIndex--; int newPosition = spriteList.SelectedIndex - 1;
spriteList.SelectedIndices.Clear();
spriteList.SelectedIndex = newPosition;
} }
} }
@@ -560,5 +543,15 @@ namespace SpriteMapEditor
spriteViewerPanel.Refresh(); spriteViewerPanel.Refresh();
} }
private void highlightCheckBox_CheckedChanged(object sender, EventArgs e)
{
highlight = highlightCheckBox.Checked;
if (highlight)
{
UpdateHighlightMask();
}
spriteSheetViewer.Refresh();
}
} }
} }