From 2d8100755633b43f52f2af88dc593b7945b6b860 Mon Sep 17 00:00:00 2001 From: VaDiM Date: Wed, 26 Apr 2023 09:54:06 +0300 Subject: [PATCH] [GUI] Improve de-selection in Scene Hierarchy tab - improved de-selection perfomance - selected objects count is now displayed in the status bar - "Select none" renamed to "Clear selection" --- AssetStudioGUI/AssetStudioGUIForm.Designer.cs | 32 ++++++------- AssetStudioGUI/AssetStudioGUIForm.cs | 47 ++++++++++++++++--- AssetStudioGUI/AssetStudioGUIForm.resx | 6 +-- 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/AssetStudioGUI/AssetStudioGUIForm.Designer.cs b/AssetStudioGUI/AssetStudioGUIForm.Designer.cs index 306014d4..fd9cb75b 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.Designer.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.Designer.cs @@ -121,10 +121,10 @@ private void InitializeComponent() this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components); this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.selectNoneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.clearSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); - this.collapseAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.expandAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.collapseAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.timer = new System.Windows.Forms.Timer(this.components); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); @@ -1046,7 +1046,7 @@ private void InitializeComponent() // this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.selectAllToolStripMenuItem, - this.selectNoneToolStripMenuItem, + this.clearSelectionToolStripMenuItem, this.toolStripSeparator5, this.expandAllToolStripMenuItem, this.collapseAllToolStripMenuItem}); @@ -1060,25 +1060,18 @@ private void InitializeComponent() this.selectAllToolStripMenuItem.Text = "Select all"; this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click); // - // selectNoneToolStripMenuItem + // clearSelectionToolStripMenuItem // - this.selectNoneToolStripMenuItem.Name = "selectNoneToolStripMenuItem"; - this.selectNoneToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.selectNoneToolStripMenuItem.Text = "Select none"; - this.selectNoneToolStripMenuItem.Click += new System.EventHandler(this.selectNoneToolStripMenuItem_Click); + this.clearSelectionToolStripMenuItem.Name = "clearSelectionToolStripMenuItem"; + this.clearSelectionToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.clearSelectionToolStripMenuItem.Text = "Clear selection"; + this.clearSelectionToolStripMenuItem.Click += new System.EventHandler(this.clearSelectionToolStripMenuItem_Click); // // toolStripSeparator5 // this.toolStripSeparator5.Name = "toolStripSeparator5"; this.toolStripSeparator5.Size = new System.Drawing.Size(177, 6); // - // collapseAllToolStripMenuItem - // - this.collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem"; - this.collapseAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.collapseAllToolStripMenuItem.Text = "Collapse all"; - this.collapseAllToolStripMenuItem.Click += new System.EventHandler(this.collapseAllToolStripMenuItem_Click); - // // expandAllToolStripMenuItem // this.expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem"; @@ -1086,6 +1079,13 @@ private void InitializeComponent() this.expandAllToolStripMenuItem.Text = "Expand all"; this.expandAllToolStripMenuItem.Click += new System.EventHandler(this.expandAllToolStripMenuItem_Click); // + // collapseAllToolStripMenuItem + // + this.collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem"; + this.collapseAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.collapseAllToolStripMenuItem.Text = "Collapse all"; + this.collapseAllToolStripMenuItem.Click += new System.EventHandler(this.collapseAllToolStripMenuItem_Click); + // // timer // this.timer.Interval = 10; @@ -1307,7 +1307,7 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox filterExcludeMode; private System.Windows.Forms.ContextMenuStrip contextMenuStrip2; private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem selectNoneToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem clearSelectionToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; private System.Windows.Forms.ToolStripMenuItem collapseAllToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem expandAllToolStripMenuItem; diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs index 5d135b27..823ace20 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.cs @@ -95,6 +95,11 @@ partial class AssetStudioGUIForm : Form private int nextGObject; private List treeSrcResults = new List(); + //tree selection + private List treeNodeSelectedList = new List(); + private bool treeRecursionEnabled = true; + private bool isRecursionEvent = false; + private string openDirectoryBackup = string.Empty; private string saveDirectoryBackup = string.Empty; @@ -571,10 +576,38 @@ private void TreeNodeSearch(TreeNode treeNode) private void sceneTreeView_AfterCheck(object sender, TreeViewEventArgs e) { + if (!treeRecursionEnabled) + return; + + if (!isRecursionEvent) + { + if (e.Node.Checked) + { + treeNodeSelectedList.Add(e.Node); + } + else + { + treeNodeSelectedList.Remove(e.Node); + } + } + foreach (TreeNode childNode in e.Node.Nodes) { + isRecursionEvent = true; + bool wasChecked = childNode.Checked; childNode.Checked = e.Node.Checked; + if (!wasChecked && childNode.Checked) + { + treeNodeSelectedList.Add(childNode); + } + else if (!childNode.Checked) + { + treeNodeSelectedList.Remove(childNode); + } } + isRecursionEvent = false; + + StatusStripUpdate($"Selected {treeNodeSelectedList.Count} object(s)."); } private void listSearch_Enter(object sender, EventArgs e) @@ -1738,22 +1771,22 @@ private void sceneTreeView_MouseClick(object sender, MouseEventArgs e) private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) { - sceneTreeView.BeginUpdate(); foreach (TreeNode node in sceneTreeView.Nodes) { node.Checked = true; } - sceneTreeView.EndUpdate(); } - private void selectNoneToolStripMenuItem_Click(object sender, EventArgs e) + private void clearSelectionToolStripMenuItem_Click(object sender, EventArgs e) { - sceneTreeView.BeginUpdate(); - foreach (TreeNode node in sceneTreeView.Nodes) + treeRecursionEnabled = false; + for(var i = 0; i < treeNodeSelectedList.Count; i++) { - node.Checked = false; + treeNodeSelectedList[i].Checked = false; } - sceneTreeView.EndUpdate(); + treeRecursionEnabled = true; + treeNodeSelectedList.Clear(); + StatusStripUpdate($"Selected {treeNodeSelectedList.Count} object(s)."); } private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/AssetStudioGUI/AssetStudioGUIForm.resx b/AssetStudioGUI/AssetStudioGUIForm.resx index 095950b2..dcce5cff 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.resx +++ b/AssetStudioGUI/AssetStudioGUIForm.resx @@ -120,6 +120,9 @@ 312, 17 + + 432, 17 + abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWYZ 1234567890.:,;'\"(!?)+-*/= @@ -138,9 +141,6 @@ The quick brown fox jumps over the lazy dog. 1234567890 The quick brown fox jumps over the lazy dog. 1234567890 - - 432, 17 - 775, 21