Skip to content

Commit

Permalink
Merge branch 'relatedAssets' into AssetStudioMod
Browse files Browse the repository at this point in the history
  • Loading branch information
aelurum committed Aug 7, 2023
2 parents e1d883a + 4d919a2 commit 74a8555
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 12 deletions.
29 changes: 24 additions & 5 deletions AssetStudioGUI/AssetStudioGUIForm.Designer.cs

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

80 changes: 76 additions & 4 deletions AssetStudioGUI/AssetStudioGUIForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,10 @@ private void tabPageSelected(object sender, TabControlEventArgs e)
switch (e.TabPageIndex)
{
case 0:
treeSearch.Select();
sceneTreeView.Select();
break;
case 1:
listSearch.Select();
assetListView.Select();
break;
}
}
Expand Down Expand Up @@ -1812,10 +1812,11 @@ private void toolStripMenuItem15_Click(object sender, EventArgs e)
logger.ShowErrorMessage = toolStripMenuItem15.Checked;
}

private void sceneTreeView_MouseClick(object sender, MouseEventArgs e)
private void sceneTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Button == MouseButtons.Right && sceneTreeView.Nodes.Count > 0)
if (e.Button == MouseButtons.Right)
{
sceneTreeView.SelectedNode = e.Node;
contextMenuStrip2.Show(sceneTreeView, e.Location.X, e.Location.Y);
}
}
Expand Down Expand Up @@ -1924,6 +1925,77 @@ private void allLive2DModelsToolStripMenuItem_Click(object sender, EventArgs e)
}
}

private void selectRelatedAsset(object sender, EventArgs e)
{
var selectedItem = (ToolStripMenuItem)sender;
var index = int.Parse(selectedItem.Name.Split('_')[0]);

assetListView.SelectedIndices.Clear();
tabControl1.SelectedTab = tabPage2;
var assetItem = assetListView.Items[index];
assetItem.Selected = true;
assetItem.EnsureVisible();
}

private void selectAllRelatedAssets(object sender, EventArgs e)
{
var selectedNode = sceneTreeView.SelectedNode;
var relatedAssets = visibleAssets.FindAll(x => x.TreeNode == selectedNode);
if (relatedAssets.Count > 0)
{
assetListView.SelectedIndices.Clear();
tabControl1.SelectedTab = tabPage2;
foreach (var asset in relatedAssets)
{
var assetItem = assetListView.Items[assetListView.Items.IndexOf(asset)];
assetItem.Selected = true;
}
assetListView.Items[assetListView.Items.IndexOf(relatedAssets[0])].EnsureVisible();
}
}

private void showRelatedAssetsToolStripMenuItem_Click(object sender, EventArgs e)
{
var selectedNode = sceneTreeView.SelectedNode;
var relatedAssets = visibleAssets.FindAll(x => x.TreeNode == selectedNode);
if (relatedAssets.Count == 0)
{
StatusStripUpdate("No related assets were found among the visible assets.");
}
}

private void contextMenuStrip2_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
var selectedNode = sceneTreeView.SelectedNode;
var relatedAssets = visibleAssets.FindAll(x => x.TreeNode == selectedNode);
showRelatedAssetsToolStripMenuItem.DropDownItems.Clear();
if (relatedAssets.Count > 1)
{
var assetItem = new ToolStripMenuItem
{
CheckOnClick = false,
Name = "selectAllRelatedAssetsToolStripMenuItem",
Size = new Size(180, 22),
Text = "Select all"
};
assetItem.Click += selectAllRelatedAssets;
showRelatedAssetsToolStripMenuItem.DropDownItems.Add(assetItem);
}
foreach (var asset in relatedAssets)
{
var index = assetListView.Items.IndexOf(asset);
var assetItem = new ToolStripMenuItem
{
CheckOnClick = false,
Name = $"{index}_{asset.TypeString}",
Size = new Size(180, 22),
Text = $"({asset.TypeString}) {asset.Text}"
};
assetItem.Click += selectRelatedAsset;
showRelatedAssetsToolStripMenuItem.DropDownItems.Add(assetItem);
}
}

#region FMOD
private void FMODinit()
{
Expand Down
6 changes: 3 additions & 3 deletions AssetStudioGUI/AssetStudioGUIForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@
<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 @@ -141,6 +138,9 @@ 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 74a8555

Please sign in to comment.