From 28ffedb8018413c6fe9d18a0dc9bb14c1cbe7c77 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sun, 12 May 2024 19:42:38 +0200 Subject: [PATCH] CustomSkinEditor - Add simple unselection when clicking away from an item or pressing escape --- .../Forms/Editor/CustomSkinEditor.Designer.cs | 15 +++++------ PCK-Studio/Forms/Editor/CustomSkinEditor.cs | 25 +++++++++++++++++-- PCK-Studio/Forms/Editor/CustomSkinEditor.resx | 6 ++--- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs b/PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs index 3bf04aad..a1a38c03 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs @@ -67,9 +67,9 @@ this.offsetListBox = new System.Windows.Forms.ListBox(); this.offsetTabContextMenu = new MetroFramework.Controls.MetroContextMenu(this.components); this.addOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.renderer3D1 = new PckStudio.Rendering.SkinRenderer(); this.uvPictureBox = new PckStudio.ToolboxItems.InterpolationPictureBox(); - this.removeOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); label5 = new System.Windows.Forms.Label(); label3 = new System.Windows.Forms.Label(); label7 = new System.Windows.Forms.Label(); @@ -321,6 +321,7 @@ this.skinPartListBox.FormattingEnabled = true; this.skinPartListBox.Name = "skinPartListBox"; this.skinPartListBox.Tag = ""; + this.skinPartListBox.MouseClick += new System.Windows.Forms.MouseEventHandler(this.skinPartListBox_MouseClick); this.skinPartListBox.SelectedIndexChanged += new System.EventHandler(this.skinPartListBox_SelectedIndexChanged); this.skinPartListBox.DoubleClick += new System.EventHandler(this.skinPartListBox_DoubleClick); this.skinPartListBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.skinPartListBox_KeyUp); @@ -401,6 +402,12 @@ resources.ApplyResources(this.addOffsetToolStripMenuItem, "addOffsetToolStripMenuItem"); this.addOffsetToolStripMenuItem.Click += new System.EventHandler(this.addOffsetToolStripMenuItem_Click); // + // removeOffsetToolStripMenuItem + // + this.removeOffsetToolStripMenuItem.Name = "removeOffsetToolStripMenuItem"; + resources.ApplyResources(this.removeOffsetToolStripMenuItem, "removeOffsetToolStripMenuItem"); + this.removeOffsetToolStripMenuItem.Click += new System.EventHandler(this.removeOffsetToolStripMenuItem_Click); + // // renderer3D1 // resources.ApplyResources(this.renderer3D1, "renderer3D1"); @@ -426,12 +433,6 @@ this.uvPictureBox.Name = "uvPictureBox"; this.uvPictureBox.TabStop = false; // - // removeOffsetToolStripMenuItem - // - this.removeOffsetToolStripMenuItem.Name = "removeOffsetToolStripMenuItem"; - resources.ApplyResources(this.removeOffsetToolStripMenuItem, "removeOffsetToolStripMenuItem"); - this.removeOffsetToolStripMenuItem.Click += new System.EventHandler(this.removeOffsetToolStripMenuItem_Click); - // // CustomSkinEditor // resources.ApplyResources(this, "$this"); diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs index 7914eb09..d91a06c2 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs @@ -304,8 +304,17 @@ namespace PckStudio.Forms.Editor private void skinPartListBox_KeyUp(object sender, KeyEventArgs e) { - if (e.KeyCode == Keys.Delete) - deleteToolStripMenuItem_Click(sender, e); + switch (e.KeyCode) + { + case Keys.Delete: + deleteToolStripMenuItem_Click(sender, e); + break; + case Keys.Escape: + ClearSelection(); + break; + default: + break; + } } private void ReloadOffsetList() @@ -353,5 +362,17 @@ namespace PckStudio.Forms.Editor ReloadOffsetList(); } } + + private void skinPartListBox_MouseClick(object sender, MouseEventArgs e) + { + if (skinPartListBox.IndexFromPoint(e.X, e.Y) == -1) + ClearSelection(); + } + + private void ClearSelection() + { + skinPartListBox.ClearSelected(); + renderer3D1.SelectedIndex = skinPartListBox.SelectedIndex; + } } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.resx b/PCK-Studio/Forms/Editor/CustomSkinEditor.resx index ab7d0016..e32e90bd 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.resx +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.resx @@ -1015,19 +1015,19 @@ 204, 17 - 180, 22 + 152, 22 Add Offset - 180, 22 + 152, 22 Remove Offset - 181, 70 + 153, 48 offsetTabContextMenu