[GUI] Add exact search option for Scene Hierarchy. Close #49

This commit is contained in:
VaDiM 2025-05-10 01:09:54 +03:00
parent 97fa42742b
commit b0a051fc47
2 changed files with 37 additions and 9 deletions

View File

@ -103,6 +103,7 @@
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
this.sceneExactSearchCheckBox = new System.Windows.Forms.CheckBox();
this.sceneTreeView = new AssetStudioGUI.GOHierarchy(); this.sceneTreeView = new AssetStudioGUI.GOHierarchy();
this.treeSearch = new System.Windows.Forms.TextBox(); this.treeSearch = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
@ -841,6 +842,7 @@
// //
// tabPage1 // tabPage1
// //
this.tabPage1.Controls.Add(this.sceneExactSearchCheckBox);
this.tabPage1.Controls.Add(this.sceneTreeView); this.tabPage1.Controls.Add(this.sceneTreeView);
this.tabPage1.Controls.Add(this.treeSearch); this.tabPage1.Controls.Add(this.treeSearch);
this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Location = new System.Drawing.Point(4, 22);
@ -850,6 +852,21 @@
this.tabPage1.Text = "Scene Hierarchy"; this.tabPage1.Text = "Scene Hierarchy";
this.tabPage1.UseVisualStyleBackColor = true; this.tabPage1.UseVisualStyleBackColor = true;
// //
// sceneExactSearchCheckBox
//
this.sceneExactSearchCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.sceneExactSearchCheckBox.AutoSize = true;
this.sceneExactSearchCheckBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.sceneExactSearchCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.sceneExactSearchCheckBox.Location = new System.Drawing.Point(384, 2);
this.sceneExactSearchCheckBox.Name = "sceneExactSearchCheckBox";
this.sceneExactSearchCheckBox.Size = new System.Drawing.Size(85, 17);
this.sceneExactSearchCheckBox.TabIndex = 2;
this.sceneExactSearchCheckBox.Text = "Exact search";
this.sceneExactSearchCheckBox.UseVisualStyleBackColor = true;
this.sceneExactSearchCheckBox.CheckedChanged += new System.EventHandler(this.sceneExactSearchCheckBox_CheckedChanged);
//
// sceneTreeView // sceneTreeView
// //
this.sceneTreeView.BackColor = System.Drawing.SystemColors.Window; this.sceneTreeView.BackColor = System.Drawing.SystemColors.Window;
@ -860,7 +877,7 @@
this.sceneTreeView.Location = new System.Drawing.Point(0, 20); this.sceneTreeView.Location = new System.Drawing.Point(0, 20);
this.sceneTreeView.Name = "sceneTreeView"; this.sceneTreeView.Name = "sceneTreeView";
this.sceneTreeView.Size = new System.Drawing.Size(472, 587); this.sceneTreeView.Size = new System.Drawing.Size(472, 587);
this.sceneTreeView.TabIndex = 1; this.sceneTreeView.TabIndex = 0;
this.sceneTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.sceneTreeView_AfterCheck); this.sceneTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.sceneTreeView_AfterCheck);
this.sceneTreeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.sceneTreeView_NodeMouseClick); this.sceneTreeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.sceneTreeView_NodeMouseClick);
// //
@ -871,7 +888,7 @@
this.treeSearch.Location = new System.Drawing.Point(0, 0); this.treeSearch.Location = new System.Drawing.Point(0, 0);
this.treeSearch.Name = "treeSearch"; this.treeSearch.Name = "treeSearch";
this.treeSearch.Size = new System.Drawing.Size(472, 20); this.treeSearch.Size = new System.Drawing.Size(472, 20);
this.treeSearch.TabIndex = 2; this.treeSearch.TabIndex = 1;
this.treeSearch.Text = " Search "; this.treeSearch.Text = " Search ";
this.treeSearch.TextChanged += new System.EventHandler(this.treeSearch_TextChanged); this.treeSearch.TextChanged += new System.EventHandler(this.treeSearch_TextChanged);
this.treeSearch.Enter += new System.EventHandler(this.treeSearch_Enter); this.treeSearch.Enter += new System.EventHandler(this.treeSearch_Enter);
@ -905,7 +922,7 @@
this.assetListView.Location = new System.Drawing.Point(0, 23); this.assetListView.Location = new System.Drawing.Point(0, 23);
this.assetListView.Name = "assetListView"; this.assetListView.Name = "assetListView";
this.assetListView.Size = new System.Drawing.Size(472, 584); this.assetListView.Size = new System.Drawing.Size(472, 584);
this.assetListView.TabIndex = 1; this.assetListView.TabIndex = 0;
this.assetListView.UseCompatibleStateImageBehavior = false; this.assetListView.UseCompatibleStateImageBehavior = false;
this.assetListView.View = System.Windows.Forms.View.Details; this.assetListView.View = System.Windows.Forms.View.Details;
this.assetListView.VirtualMode = true; this.assetListView.VirtualMode = true;
@ -965,7 +982,7 @@
this.listSearch.Name = "listSearch"; this.listSearch.Name = "listSearch";
this.listSearch.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; this.listSearch.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
this.listSearch.Size = new System.Drawing.Size(331, 16); this.listSearch.Size = new System.Drawing.Size(331, 16);
this.listSearch.TabIndex = 3; this.listSearch.TabIndex = 1;
this.listSearch.Text = " Filter "; this.listSearch.Text = " Filter ";
this.listSearch.WordWrap = false; this.listSearch.WordWrap = false;
this.listSearch.TextChanged += new System.EventHandler(this.ListSearchTextChanged); this.listSearch.TextChanged += new System.EventHandler(this.ListSearchTextChanged);
@ -999,7 +1016,7 @@
this.listSearchFilterMode.Location = new System.Drawing.Point(351, 0); this.listSearchFilterMode.Location = new System.Drawing.Point(351, 0);
this.listSearchFilterMode.Name = "listSearchFilterMode"; this.listSearchFilterMode.Name = "listSearchFilterMode";
this.listSearchFilterMode.Size = new System.Drawing.Size(121, 21); this.listSearchFilterMode.Size = new System.Drawing.Size(121, 21);
this.listSearchFilterMode.TabIndex = 3; this.listSearchFilterMode.TabIndex = 2;
this.listSearchFilterMode.SelectedIndexChanged += new System.EventHandler(this.listSearchFilterMode_SelectedIndexChanged); this.listSearchFilterMode.SelectedIndexChanged += new System.EventHandler(this.listSearchFilterMode_SelectedIndexChanged);
// //
// tabPage3 // tabPage3
@ -1793,6 +1810,7 @@
private System.Windows.Forms.ToolStripMenuItem blockCompressionToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem blockCompressionToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem blockInfoCompressionToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem blockInfoCompressionToolStripMenuItem;
private System.Windows.Forms.ToolStripComboBox customBlockInfoCompressionComboBoxToolStripMenuItem; private System.Windows.Forms.ToolStripComboBox customBlockInfoCompressionComboBoxToolStripMenuItem;
private System.Windows.Forms.CheckBox sceneExactSearchCheckBox;
} }
} }

View File

@ -616,9 +616,10 @@ namespace AssetStudioGUI
{ {
if (treeSrcResults.Count == 0) if (treeSrcResults.Count == 0)
{ {
var isExactSearch = sceneExactSearchCheckBox.Checked;
foreach (TreeNode node in sceneTreeView.Nodes) foreach (TreeNode node in sceneTreeView.Nodes)
{ {
TreeNodeSearch(node); TreeNodeSearch(node, isExactSearch);
} }
} }
if (treeSrcResults.Count > 0) if (treeSrcResults.Count > 0)
@ -634,19 +635,28 @@ namespace AssetStudioGUI
} }
} }
private void TreeNodeSearch(TreeNode treeNode) private void TreeNodeSearch(TreeNode treeNode, bool isExactSearch)
{ {
if (treeNode.Text.IndexOf(treeSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0) if (isExactSearch && string.Equals(treeNode.Text, treeSearch.Text, StringComparison.InvariantCultureIgnoreCase))
{
treeSrcResults.Add(treeNode);
}
else if (!isExactSearch && treeNode.Text.IndexOf(treeSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0)
{ {
treeSrcResults.Add(treeNode); treeSrcResults.Add(treeNode);
} }
foreach (TreeNode node in treeNode.Nodes) foreach (TreeNode node in treeNode.Nodes)
{ {
TreeNodeSearch(node); TreeNodeSearch(node, isExactSearch);
} }
} }
private void sceneExactSearchCheckBox_CheckedChanged(object sender, EventArgs e)
{
treeSearch_TextChanged(sender, e);
}
private void sceneTreeView_AfterCheck(object sender, TreeViewEventArgs e) private void sceneTreeView_AfterCheck(object sender, TreeViewEventArgs e)
{ {
if (!treeRecursionEnabled) if (!treeRecursionEnabled)