Skip to content

Commit

Permalink
[GUI] Improve de-selection in Scene Hierarchy tab
Browse files Browse the repository at this point in the history
- improved de-selection perfomance
- selected objects count is now displayed in the status bar
- "Select none" renamed to "Clear selection"
  • Loading branch information
aelurum committed Apr 26, 2023
1 parent 4bae988 commit 2d81007
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 26 deletions.
32 changes: 16 additions & 16 deletions AssetStudioGUI/AssetStudioGUIForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 40 additions & 7 deletions AssetStudioGUI/AssetStudioGUIForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ partial class AssetStudioGUIForm : Form
private int nextGObject;
private List<TreeNode> treeSrcResults = new List<TreeNode>();

//tree selection
private List<TreeNode> treeNodeSelectedList = new List<TreeNode>();
private bool treeRecursionEnabled = true;
private bool isRecursionEvent = false;

private string openDirectoryBackup = string.Empty;
private string saveDirectoryBackup = string.Empty;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions AssetStudioGUI/AssetStudioGUIForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>312, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>432, 17</value>
</metadata>
<data name="fontPreviewBox.Text" xml:space="preserve">
<value>abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWYZ
1234567890.:,;'\"(!?)+-*/=
Expand All @@ -138,9 +141,6 @@ The quick brown fox jumps over the lazy dog. 1234567890

The quick brown fox jumps over the lazy dog. 1234567890</value>
</data>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>432, 17</value>
</metadata>
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>775, 21</value>
</metadata>
Expand Down

0 comments on commit 2d81007

Please sign in to comment.