mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
performance improvement
This commit is contained in:
parent
a0bf4f9acd
commit
06fbe69a97
12
AssetStudioGUI/AssetStudioGUIForm.Designer.cs
generated
12
AssetStudioGUI/AssetStudioGUIForm.Designer.cs
generated
@ -83,8 +83,8 @@
|
||||
this.listSearch = new System.Windows.Forms.TextBox();
|
||||
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||
this.classesListView = new System.Windows.Forms.ListView();
|
||||
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.progressbarPanel = new System.Windows.Forms.Panel();
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.previewPanel = new System.Windows.Forms.Panel();
|
||||
@ -622,16 +622,16 @@
|
||||
this.classesListView.View = System.Windows.Forms.View.Details;
|
||||
this.classesListView.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.classesListView_ItemSelectionChanged);
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Name";
|
||||
this.columnHeader2.Width = 300;
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "ID";
|
||||
this.columnHeader1.Width = 70;
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Name";
|
||||
this.columnHeader2.Width = 300;
|
||||
//
|
||||
// progressbarPanel
|
||||
//
|
||||
this.progressbarPanel.Controls.Add(this.progressBar1);
|
||||
|
@ -13,6 +13,7 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows.Forms;
|
||||
using static AssetStudioGUI.Studio;
|
||||
@ -82,47 +83,49 @@ namespace AssetStudioGUI
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
|
||||
|
||||
public AssetStudioGUIForm()
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
|
||||
InitializeComponent();
|
||||
Text = $"AssetStudioGUI v{Application.ProductVersion}";
|
||||
delayTimer = new System.Timers.Timer(800);
|
||||
delayTimer.Elapsed += new ElapsedEventHandler(delayTimer_Elapsed);
|
||||
displayAll.Checked = Properties.Settings.Default.displayAll;
|
||||
displayInfo.Checked = Properties.Settings.Default.displayInfo;
|
||||
enablePreview.Checked = Properties.Settings.Default.enablePreview;
|
||||
FMODinit();
|
||||
|
||||
private void loadFile_Click(object sender, EventArgs e)
|
||||
Logger.Default = new GUILogger(StatusStripUpdate);
|
||||
Progress.Default = new GUIProgress(SetProgressBarValue);
|
||||
Studio.StatusStripUpdate = StatusStripUpdate;
|
||||
}
|
||||
|
||||
private async void loadFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ResetForm();
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
assetsManager.LoadFiles(openFileDialog1.FileNames);
|
||||
await Task.Run(() => assetsManager.LoadFiles(openFileDialog1.FileNames));
|
||||
BuildAssetStructures();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFolder_Click(object sender, EventArgs e)
|
||||
private async void loadFolder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var openFolderDialog = new OpenFolderDialog();
|
||||
if (openFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
ResetForm();
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
assetsManager.LoadFolder(openFolderDialog.Folder);
|
||||
await Task.Run(() => assetsManager.LoadFolder(openFolderDialog.Folder));
|
||||
BuildAssetStructures();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void extractFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var openBundleDialog = new OpenFileDialog
|
||||
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Filter = "All types|*.*",
|
||||
FilterIndex = 1,
|
||||
RestoreDirectory = true,
|
||||
Multiselect = true
|
||||
};
|
||||
|
||||
if (openBundleDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ExtractFile(openBundleDialog.FileNames);
|
||||
ExtractFile(openFileDialog1.FileNames);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +139,7 @@ namespace AssetStudioGUI
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildAssetStructures()
|
||||
private async void BuildAssetStructures()
|
||||
{
|
||||
if (assetsManager.assetsFileList.Count == 0)
|
||||
{
|
||||
@ -144,27 +147,23 @@ namespace AssetStudioGUI
|
||||
return;
|
||||
}
|
||||
|
||||
var data = BuildAssetData();
|
||||
var productName = data.Item1;
|
||||
var treeNodeCollection = data.Item2;
|
||||
var typeMap = BuildClassStructure();
|
||||
(var productName, var treeNodeCollection) = await Task.Run(() => BuildAssetData());
|
||||
var typeMap = await Task.Run(() => BuildClassStructure());
|
||||
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(productName))
|
||||
{
|
||||
Text = $"AssetStudioGUI - {productName} - {assetsManager.assetsFileList[0].unityVersion} - {assetsManager.assetsFileList[0].m_TargetPlatform}";
|
||||
Text = $"AssetStudioGUI v{Application.ProductVersion} - {productName} - {assetsManager.assetsFileList[0].unityVersion} - {assetsManager.assetsFileList[0].m_TargetPlatform}";
|
||||
}
|
||||
else
|
||||
{
|
||||
Text = $"AssetStudioGUI - no productName - {assetsManager.assetsFileList[0].unityVersion} - {assetsManager.assetsFileList[0].m_TargetPlatform}";
|
||||
Text = $"AssetStudioGUI v{Application.ProductVersion} - no productName - {assetsManager.assetsFileList[0].unityVersion} - {assetsManager.assetsFileList[0].m_TargetPlatform}";
|
||||
}
|
||||
|
||||
assetListView.VirtualListSize = visibleAssets.Count;
|
||||
|
||||
sceneTreeView.BeginUpdate();
|
||||
sceneTreeView.Nodes.AddRange(treeNodeCollection.ToArray());
|
||||
foreach (TreeNode node in sceneTreeView.Nodes)
|
||||
foreach (var node in treeNodeCollection)
|
||||
{
|
||||
node.HideCheckBox();
|
||||
}
|
||||
@ -208,8 +207,6 @@ namespace AssetStudioGUI
|
||||
log += $" and {m_ObjectsCount - objectsCount} assets failed to read";
|
||||
}
|
||||
StatusStripUpdate(log);
|
||||
treeSearch.Select();
|
||||
}));
|
||||
}
|
||||
|
||||
private void typeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@ -1138,26 +1135,9 @@ namespace AssetStudioGUI
|
||||
}
|
||||
}
|
||||
|
||||
public AssetStudioGUIForm()
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
|
||||
InitializeComponent();
|
||||
delayTimer = new System.Timers.Timer(800);
|
||||
delayTimer.Elapsed += new ElapsedEventHandler(delayTimer_Elapsed);
|
||||
displayAll.Checked = Properties.Settings.Default.displayAll;
|
||||
displayInfo.Checked = Properties.Settings.Default.displayInfo;
|
||||
enablePreview.Checked = Properties.Settings.Default.enablePreview;
|
||||
FMODinit();
|
||||
|
||||
Logger.Default = new GUILogger(StatusStripUpdate);
|
||||
Progress.Default = new GUIProgress(SetProgressBarValue);
|
||||
Studio.StatusStripUpdate = StatusStripUpdate;
|
||||
}
|
||||
|
||||
|
||||
private void ResetForm()
|
||||
{
|
||||
Text = "AssetStudioGUI";
|
||||
Text = $"AssetStudioGUI v{Application.ProductVersion}";
|
||||
assetsManager.Clear();
|
||||
exportableAssets.Clear();
|
||||
visibleAssets.Clear();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using AssetStudio;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
@ -6,7 +7,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using AssetStudio;
|
||||
using static AssetStudioGUI.Exporter;
|
||||
using Object = AssetStudio.Object;
|
||||
|
||||
@ -96,7 +96,7 @@ namespace AssetStudioGUI
|
||||
return extractedCount;
|
||||
}
|
||||
|
||||
public static Tuple<string, List<TreeNode>> BuildAssetData()
|
||||
public static (string, List<TreeNode>) BuildAssetData()
|
||||
{
|
||||
StatusStripUpdate("Building asset list...");
|
||||
|
||||
@ -109,7 +109,7 @@ namespace AssetStudioGUI
|
||||
foreach (var assetsFile in assetsManager.assetsFileList)
|
||||
{
|
||||
var tempExportableAssets = new List<AssetItem>();
|
||||
AssetBundle ab = null;
|
||||
Dictionary<long, string> containers = null;
|
||||
foreach (var asset in assetsFile.Objects.Values)
|
||||
{
|
||||
var assetItem = new AssetItem(asset);
|
||||
@ -174,8 +174,8 @@ namespace AssetStudioGUI
|
||||
productName = m_PlayerSettings.productName;
|
||||
break;
|
||||
case AssetBundle m_AssetBundle:
|
||||
ab = m_AssetBundle;
|
||||
assetItem.Text = ab.m_Name;
|
||||
containers = m_AssetBundle.m_Container.ToDictionary(x => x.Value.asset.m_PathID, x => x.Key);
|
||||
assetItem.Text = m_AssetBundle.m_Name;
|
||||
break;
|
||||
case NamedObject m_NamedObject:
|
||||
assetItem.Text = m_NamedObject.m_Name;
|
||||
@ -200,18 +200,21 @@ namespace AssetStudioGUI
|
||||
}
|
||||
foreach (var item in tempExportableAssets)
|
||||
{
|
||||
if (ab != null)
|
||||
if (containers != null)
|
||||
{
|
||||
if (containers.TryGetValue(item.Asset.m_PathID, out var container))
|
||||
{
|
||||
var container = ab.m_Container.FirstOrDefault(y => y.Value.asset.m_PathID == item.Asset.m_PathID).Key;
|
||||
if (!string.IsNullOrEmpty(container))
|
||||
{
|
||||
item.Container = container;
|
||||
}
|
||||
}
|
||||
}
|
||||
item.SetSubItems();
|
||||
}
|
||||
exportableAssets.AddRange(tempExportableAssets);
|
||||
tempExportableAssets.Clear();
|
||||
containers?.Clear();
|
||||
}
|
||||
visibleAssets = exportableAssets;
|
||||
assetsNameHash.Clear();
|
||||
@ -291,7 +294,7 @@ namespace AssetStudioGUI
|
||||
|
||||
objectAssetItemDic.Clear();
|
||||
|
||||
return new Tuple<string, List<TreeNode>>(productName, treeNodeCollection);
|
||||
return (productName, treeNodeCollection);
|
||||
}
|
||||
|
||||
public static Dictionary<string, SortedDictionary<int, TypeTreeItem>> BuildClassStructure()
|
||||
|
Loading…
Reference in New Issue
Block a user