Add exclude mode to asset list filter

This commit is contained in:
VaDiM 2023-02-05 00:34:45 +03:00
parent b9cf95616b
commit 5c662d64e4
2 changed files with 51 additions and 4 deletions

View File

@ -81,6 +81,7 @@
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
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();
this.filterExcludeMode = new System.Windows.Forms.CheckBox();
this.assetListView = new System.Windows.Forms.ListView(); this.assetListView = new System.Windows.Forms.ListView();
this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderContainer = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeaderContainer = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@ -588,6 +589,7 @@
// //
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.filterExcludeMode);
this.tabPage2.Controls.Add(this.assetListView); this.tabPage2.Controls.Add(this.assetListView);
this.tabPage2.Controls.Add(this.listSearch); this.tabPage2.Controls.Add(this.listSearch);
this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Location = new System.Drawing.Point(4, 22);
@ -597,6 +599,23 @@
this.tabPage2.Text = "Asset List"; this.tabPage2.Text = "Asset List";
this.tabPage2.UseVisualStyleBackColor = true; this.tabPage2.UseVisualStyleBackColor = true;
// //
// filterExludeMode
//
this.filterExcludeMode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.filterExcludeMode.AutoSize = true;
this.filterExcludeMode.BackColor = System.Drawing.Color.WhiteSmoke;
this.filterExcludeMode.Enabled = false;
this.filterExcludeMode.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.filterExcludeMode.ForeColor = System.Drawing.SystemColors.ControlText;
this.filterExcludeMode.Location = new System.Drawing.Point(409, 2);
this.filterExcludeMode.Name = "filterExludeMode";
this.filterExcludeMode.Size = new System.Drawing.Size(61, 17);
this.filterExcludeMode.TabIndex = 2;
this.filterExcludeMode.Text = "Exclude";
this.filterExcludeMode.TextAlign = System.Drawing.ContentAlignment.BottomRight;
this.filterExcludeMode.UseVisualStyleBackColor = false;
this.filterExcludeMode.CheckedChanged += new System.EventHandler(this.filterExludeMode_CheckedChanged);
//
// assetListView // assetListView
// //
this.assetListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.assetListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
@ -1219,6 +1238,7 @@
private System.Windows.Forms.ToolStripTextBox specifyUnityVersion; private System.Windows.Forms.ToolStripTextBox specifyUnityVersion;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem15; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem15;
private System.Windows.Forms.ToolStripMenuItem dumpSelectedAssetsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem dumpSelectedAssetsToolStripMenuItem;
private System.Windows.Forms.CheckBox filterExcludeMode;
} }
} }

View File

@ -212,6 +212,7 @@ namespace AssetStudioGUI
{ {
if (assetsManager.assetsFileList.Count == 0) if (assetsManager.assetsFileList.Count == 0)
{ {
filterExcludeModeCheck(assetsManager.assetsFileList.Count);
StatusStripUpdate("No Unity file can be loaded."); StatusStripUpdate("No Unity file can be loaded.");
return; return;
} }
@ -250,6 +251,8 @@ namespace AssetStudioGUI
typeMap.Clear(); typeMap.Clear();
classesListView.EndUpdate(); classesListView.EndUpdate();
filterExcludeModeCheck(exportableAssets.Count);
var types = exportableAssets.Select(x => x.Type).Distinct().OrderBy(x => x.ToString()).ToArray(); var types = exportableAssets.Select(x => x.Type).Distinct().OrderBy(x => x.ToString()).ToArray();
foreach (var type in types) foreach (var type in types)
{ {
@ -1576,6 +1579,20 @@ namespace AssetStudioGUI
return selectedAssets; return selectedAssets;
} }
private void filterExludeMode_CheckedChanged(object sender, EventArgs e)
{
FilterAssetList();
}
private void filterExcludeModeCheck(int itemCount)
{
filterExcludeMode.Enabled = itemCount > 0;
if (!filterExcludeMode.Enabled)
{
filterExcludeMode.Checked = false;
}
}
private void FilterAssetList() private void FilterAssetList()
{ {
assetListView.BeginUpdate(); assetListView.BeginUpdate();
@ -1599,10 +1616,20 @@ namespace AssetStudioGUI
} }
if (listSearch.Text != " Filter ") if (listSearch.Text != " Filter ")
{ {
visibleAssets = visibleAssets.FindAll( if (filterExcludeMode.Checked)
x => x.Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0 || {
x.SubItems[1].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0 || visibleAssets = visibleAssets.FindAll(
x.SubItems[3].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0); x => x.Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0 &&
x.SubItems[1].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0 &&
x.SubItems[3].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0);
}
else
{
visibleAssets = visibleAssets.FindAll(
x => x.Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0 ||
x.SubItems[1].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0 ||
x.SubItems[3].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0);
}
} }
assetListView.VirtualListSize = visibleAssets.Count; assetListView.VirtualListSize = visibleAssets.Count;
assetListView.EndUpdate(); assetListView.EndUpdate();