- [GUI] Option to dump Scene Hierarchy

This commit is contained in:
Razmoth
2023-09-17 01:39:59 +04:00
parent 0a0cf2a7d2
commit e5cbb8bdae
3 changed files with 65 additions and 20 deletions

View File

@@ -171,6 +171,7 @@ namespace AssetStudioGUI
exportAnimatorwithselectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem();
goToSceneHierarchyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
showOriginalFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
sceneHierarchy = new System.Windows.Forms.ToolStripMenuItem();
menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
@@ -477,7 +478,7 @@ namespace AssetStudioGUI
//
// exportToolStripMenuItem
//
exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { exportAllAssetsMenuItem, exportSelectedAssetsMenuItem, exportFilteredAssetsMenuItem, toolStripSeparator3, exportAnimatorWithSelectedAnimationClipToolStripMenuItem, toolStripSeparator4, toolStripMenuItem2, toolStripMenuItem3, toolStripMenuItem16, toolStripSeparator2, toolStripMenuItem10 });
exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { exportAllAssetsMenuItem, exportSelectedAssetsMenuItem, exportFilteredAssetsMenuItem, toolStripSeparator3, exportAnimatorWithSelectedAnimationClipToolStripMenuItem, toolStripSeparator4, toolStripMenuItem2, toolStripMenuItem3, toolStripMenuItem16, toolStripSeparator2, toolStripMenuItem10, sceneHierarchy });
exportToolStripMenuItem.Name = "exportToolStripMenuItem";
exportToolStripMenuItem.Size = new System.Drawing.Size(53, 20);
exportToolStripMenuItem.Text = "Export";
@@ -586,21 +587,21 @@ namespace AssetStudioGUI
// toolStripMenuItem17
//
toolStripMenuItem17.Name = "toolStripMenuItem17";
toolStripMenuItem17.Size = new System.Drawing.Size(152, 22);
toolStripMenuItem17.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem17.Text = "All assets";
toolStripMenuItem17.Click += toolStripMenuItem17_Click;
//
// toolStripMenuItem24
//
toolStripMenuItem24.Name = "toolStripMenuItem24";
toolStripMenuItem24.Size = new System.Drawing.Size(152, 22);
toolStripMenuItem24.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem24.Text = "Selected assets";
toolStripMenuItem24.Click += toolStripMenuItem24_Click;
//
// toolStripMenuItem25
//
toolStripMenuItem25.Name = "toolStripMenuItem25";
toolStripMenuItem25.Size = new System.Drawing.Size(152, 22);
toolStripMenuItem25.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem25.Text = "Filtered assets";
toolStripMenuItem25.Click += toolStripMenuItem25_Click;
//
@@ -619,21 +620,21 @@ namespace AssetStudioGUI
// toolStripMenuItem11
//
toolStripMenuItem11.Name = "toolStripMenuItem11";
toolStripMenuItem11.Size = new System.Drawing.Size(152, 22);
toolStripMenuItem11.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem11.Text = "All assets";
toolStripMenuItem11.Click += toolStripMenuItem11_Click;
//
// toolStripMenuItem12
//
toolStripMenuItem12.Name = "toolStripMenuItem12";
toolStripMenuItem12.Size = new System.Drawing.Size(152, 22);
toolStripMenuItem12.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem12.Text = "Selected assets";
toolStripMenuItem12.Click += toolStripMenuItem12_Click;
//
// toolStripMenuItem13
//
toolStripMenuItem13.Name = "toolStripMenuItem13";
toolStripMenuItem13.Size = new System.Drawing.Size(152, 22);
toolStripMenuItem13.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem13.Text = "Filtered assets";
toolStripMenuItem13.Click += toolStripMenuItem13_Click;
//
@@ -878,9 +879,9 @@ namespace AssetStudioGUI
treeSearch.ForeColor = System.Drawing.SystemColors.WindowText;
treeSearch.Location = new System.Drawing.Point(0, 0);
treeSearch.Name = "treeSearch";
treeSearch.PlaceholderText = "Search (with Ctrl to check result, with Shift for all)";
treeSearch.Size = new System.Drawing.Size(472, 23);
treeSearch.TabIndex = 0;
treeSearch.PlaceholderText = "Search (with Ctrl to check result, with Shift for all)";
treeSearch.TextChanged += treeSearch_TextChanged;
treeSearch.KeyDown += treeSearch_KeyDown;
//
@@ -943,9 +944,9 @@ namespace AssetStudioGUI
listSearch.ForeColor = System.Drawing.SystemColors.WindowText;
listSearch.Location = new System.Drawing.Point(0, 0);
listSearch.Name = "listSearch";
listSearch.PlaceholderText = "Search";
listSearch.Size = new System.Drawing.Size(472, 23);
listSearch.TabIndex = 0;
listSearch.PlaceholderText = "Search";
listSearch.KeyPress += listSearch_KeyPress;
//
// tabPage3
@@ -1336,6 +1337,13 @@ namespace AssetStudioGUI
showOriginalFileToolStripMenuItem.Visible = false;
showOriginalFileToolStripMenuItem.Click += showOriginalFileToolStripMenuItem_Click;
//
// sceneHierarchy
//
sceneHierarchy.Name = "sceneHierarchy";
sceneHierarchy.Size = new System.Drawing.Size(266, 22);
sceneHierarchy.Text = "Scene hierarchy";
sceneHierarchy.Click += sceneHierarchy_Click;
//
// AssetStudioGUIForm
//
AllowDrop = true;
@@ -1524,6 +1532,7 @@ namespace AssetStudioGUI
private System.Windows.Forms.ToolStripSeparator toolStripSeparator13;
private System.Windows.Forms.ToolStripMenuItem enableFileLogging;
private System.Windows.Forms.ToolStripMenuItem enableVerbose;
private System.Windows.Forms.ToolStripMenuItem sceneHierarchy;
}
}

View File

@@ -158,8 +158,8 @@ namespace AssetStudioGUI
if (Studio.Game.Type.IsUnityCN())
{
UnityCNManager.SetKey(Properties.Settings.Default.selectedUnityCNKey);
}
UnityCNManager.SetKey(Properties.Settings.Default.selectedUnityCNKey);
}
MapNameComboBox.SelectedIndexChanged += new EventHandler(specifyNameComboBox_SelectedIndexChanged);
if (!string.IsNullOrEmpty(Properties.Settings.Default.selectedCABMapName))
@@ -587,7 +587,7 @@ namespace AssetStudioGUI
while (tempNode.Parent != null)
{
tempNode = tempNode.Parent;
}
}
tempNode.EnsureVisible();
tempNode.Checked = e.Control;
}
@@ -595,10 +595,10 @@ namespace AssetStudioGUI
}
else
{
if (nextGObject >= treeSrcResults.Count)
{
nextGObject = 0;
}
if (nextGObject >= treeSrcResults.Count)
{
nextGObject = 0;
}
var node = treeSrcResults[nextGObject];
while (node.Parent != null)
{
@@ -606,12 +606,12 @@ namespace AssetStudioGUI
}
node.EnsureVisible();
node.Checked = e.Control;
sceneTreeView.SelectedNode = treeSrcResults[nextGObject];
nextGObject++;
sceneTreeView.SelectedNode = treeSrcResults[nextGObject];
nextGObject++;
}
}
}
}
}
private void TreeNodeSearch(Regex regex, TreeNode treeNode)
{
@@ -634,6 +634,42 @@ namespace AssetStudioGUI
}
}
private void sceneHierarchy_Click(object sender, EventArgs e)
{
var saveFileDialog = new SaveFileDialog() { FileName = "scene.json", Filter = "Scene Hierarchy dump | *.json" };
if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
{
var path = saveFileDialog.FileName;
var nodes = new Dictionary<string, dynamic>();
foreach (TreeNode node in sceneTreeView.Nodes)
{
var value = GetNode(node);
nodes.Add(node.Text, value);
}
var json = JsonConvert.SerializeObject(nodes, Formatting.Indented);
File.WriteAllText(path, json);
Logger.Info("Scene Hierarchy dumped sucessfully !!");
}
}
private dynamic GetNode(TreeNode treeNode)
{
if (treeNode.GetNodeCount(true) == 0)
{
return string.Empty;
}
else
{
var nodes = new Dictionary<string, dynamic>();
var exportableNodes = treeNode.Nodes.Cast<GameObjectTreeNode>().Where(x => x.gameObject.m_Animator != null || (bool)x.gameObject.m_Transform?.m_Father.IsNull).ToList();
foreach (TreeNode node in exportableNodes)
{
nodes.TryAdd(node.Text, GetNode(node));
}
return nodes;
}
}
private void listSearch_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)

View File

@@ -18,7 +18,7 @@
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>