Add right-mouse menu export function

This commit is contained in:
Perfare 2018-04-10 04:45:09 +08:00
parent bc2469e11a
commit 8031d1a03f
5 changed files with 471 additions and 390 deletions

View File

@ -37,12 +37,6 @@
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.extractBundleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.extractFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.debugMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buildClassStructuresMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dontLoadAssetsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dontBuildHierarchyMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.exportClassStructuresMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.displayAll = new System.Windows.Forms.ToolStripMenuItem();
this.displayOriginalName = new System.Windows.Forms.ToolStripMenuItem();
@ -51,18 +45,24 @@
this.openAfterExport = new System.Windows.Forms.ToolStripMenuItem();
this.assetGroupOptions = new System.Windows.Forms.ToolStripComboBox();
this.showExpOpt = new System.Windows.Forms.ToolStripMenuItem();
this.modelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportallobjectsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportallobjectssplitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportselectedobjectsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportAllAssetsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportSelectedAssetsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportFilteredAssetsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._3DToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportAll3DMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.all3DObjectssplitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportSelected3DMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.debugMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buildClassStructuresMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dontLoadAssetsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dontBuildHierarchyMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.exportClassStructuresMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.sceneTreeView = new GOHierarchy();
this.sceneTreeView = new AssetStudio.GOHierarchy();
this.treeSearch = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.assetListView = new System.Windows.Forms.ListView();
@ -103,8 +103,9 @@
this.treeTip = new System.Windows.Forms.ToolTip(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.showOriginalFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.animatorWithAnimationClipToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportAnimatorwithAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportObjectswithAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportSelectedAssetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@ -128,10 +129,10 @@
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.debugMenuItem,
this.optionsToolStripMenuItem,
this.modelToolStripMenuItem,
this.exportToolStripMenuItem,
this._3DToolStripMenuItem});
this.debugMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1264, 25);
@ -183,53 +184,6 @@
this.extractFolderToolStripMenuItem.Text = "Extract folder";
this.extractFolderToolStripMenuItem.Click += new System.EventHandler(this.extractFolderToolStripMenuItem_Click);
//
// debugMenuItem
//
this.debugMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.buildClassStructuresMenuItem,
this.dontLoadAssetsMenuItem,
this.dontBuildHierarchyMenuItem,
this.toolStripSeparator2,
this.exportClassStructuresMenuItem});
this.debugMenuItem.Name = "debugMenuItem";
this.debugMenuItem.Size = new System.Drawing.Size(87, 21);
this.debugMenuItem.Text = "Diagnostics";
this.debugMenuItem.Visible = false;
//
// buildClassStructuresMenuItem
//
this.buildClassStructuresMenuItem.CheckOnClick = true;
this.buildClassStructuresMenuItem.Name = "buildClassStructuresMenuItem";
this.buildClassStructuresMenuItem.Size = new System.Drawing.Size(224, 22);
this.buildClassStructuresMenuItem.Text = "Build class structures";
//
// dontLoadAssetsMenuItem
//
this.dontLoadAssetsMenuItem.CheckOnClick = true;
this.dontLoadAssetsMenuItem.Name = "dontLoadAssetsMenuItem";
this.dontLoadAssetsMenuItem.Size = new System.Drawing.Size(224, 22);
this.dontLoadAssetsMenuItem.Text = "Don\'t load assets";
this.dontLoadAssetsMenuItem.CheckedChanged += new System.EventHandler(this.dontLoadAssetsMenuItem_CheckedChanged);
//
// dontBuildHierarchyMenuItem
//
this.dontBuildHierarchyMenuItem.CheckOnClick = true;
this.dontBuildHierarchyMenuItem.Name = "dontBuildHierarchyMenuItem";
this.dontBuildHierarchyMenuItem.Size = new System.Drawing.Size(224, 22);
this.dontBuildHierarchyMenuItem.Text = "Don\'t build hierarchy tree";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(221, 6);
//
// exportClassStructuresMenuItem
//
this.exportClassStructuresMenuItem.Name = "exportClassStructuresMenuItem";
this.exportClassStructuresMenuItem.Size = new System.Drawing.Size(224, 22);
this.exportClassStructuresMenuItem.Text = "Export class structures";
this.exportClassStructuresMenuItem.Click += new System.EventHandler(this.exportClassStructuresMenuItem_Click);
//
// optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -314,14 +268,43 @@
this.showExpOpt.Text = "Export options";
this.showExpOpt.Click += new System.EventHandler(this.showExpOpt_Click);
//
// modelToolStripMenuItem
//
this.modelToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exportallobjectsMenuItem,
this.exportallobjectssplitToolStripMenuItem,
this.exportselectedobjectsMenuItem});
this.modelToolStripMenuItem.Name = "modelToolStripMenuItem";
this.modelToolStripMenuItem.Size = new System.Drawing.Size(58, 21);
this.modelToolStripMenuItem.Text = "Model";
//
// exportallobjectsMenuItem
//
this.exportallobjectsMenuItem.Name = "exportallobjectsMenuItem";
this.exportallobjectsMenuItem.Size = new System.Drawing.Size(213, 22);
this.exportallobjectsMenuItem.Text = "Export all objects";
this.exportallobjectsMenuItem.Click += new System.EventHandler(this.ExportObjects_Click);
//
// exportallobjectssplitToolStripMenuItem
//
this.exportallobjectssplitToolStripMenuItem.Name = "exportallobjectssplitToolStripMenuItem";
this.exportallobjectssplitToolStripMenuItem.Size = new System.Drawing.Size(213, 22);
this.exportallobjectssplitToolStripMenuItem.Text = "Export all objects (split)";
this.exportallobjectssplitToolStripMenuItem.Click += new System.EventHandler(this.exportallobjectssplitToolStripMenuItem_Click);
//
// exportselectedobjectsMenuItem
//
this.exportselectedobjectsMenuItem.Name = "exportselectedobjectsMenuItem";
this.exportselectedobjectsMenuItem.Size = new System.Drawing.Size(213, 22);
this.exportselectedobjectsMenuItem.Text = "Export selected objects";
this.exportselectedobjectsMenuItem.Click += new System.EventHandler(this.ExportObjects_Click);
//
// exportToolStripMenuItem
//
this.exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exportAllAssetsMenuItem,
this.exportSelectedAssetsMenuItem,
this.exportFilteredAssetsMenuItem,
this.toolStripSeparator1,
this.animatorWithAnimationClipToolStripMenuItem});
this.exportFilteredAssetsMenuItem});
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
this.exportToolStripMenuItem.Size = new System.Drawing.Size(58, 21);
this.exportToolStripMenuItem.Text = "Export";
@ -348,36 +331,52 @@
this.exportFilteredAssetsMenuItem.Text = "Filtered assets";
this.exportFilteredAssetsMenuItem.Click += new System.EventHandler(this.ExportAssets_Click);
//
// _3DToolStripMenuItem
// debugMenuItem
//
this._3DToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exportAll3DMenuItem,
this.all3DObjectssplitToolStripMenuItem,
this.exportSelected3DMenuItem});
this._3DToolStripMenuItem.Name = "_3DToolStripMenuItem";
this._3DToolStripMenuItem.Size = new System.Drawing.Size(78, 21);
this._3DToolStripMenuItem.Text = "3D Model";
this.debugMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.buildClassStructuresMenuItem,
this.dontLoadAssetsMenuItem,
this.dontBuildHierarchyMenuItem,
this.toolStripSeparator2,
this.exportClassStructuresMenuItem});
this.debugMenuItem.Name = "debugMenuItem";
this.debugMenuItem.Size = new System.Drawing.Size(59, 21);
this.debugMenuItem.Text = "Debug";
this.debugMenuItem.Visible = false;
//
// exportAll3DMenuItem
// buildClassStructuresMenuItem
//
this.exportAll3DMenuItem.Name = "exportAll3DMenuItem";
this.exportAll3DMenuItem.Size = new System.Drawing.Size(234, 22);
this.exportAll3DMenuItem.Text = "Export All 3D objects";
this.exportAll3DMenuItem.Click += new System.EventHandler(this.Export3DObjects_Click);
this.buildClassStructuresMenuItem.CheckOnClick = true;
this.buildClassStructuresMenuItem.Name = "buildClassStructuresMenuItem";
this.buildClassStructuresMenuItem.Size = new System.Drawing.Size(224, 22);
this.buildClassStructuresMenuItem.Text = "Build class structures";
//
// all3DObjectssplitToolStripMenuItem
// dontLoadAssetsMenuItem
//
this.all3DObjectssplitToolStripMenuItem.Name = "all3DObjectssplitToolStripMenuItem";
this.all3DObjectssplitToolStripMenuItem.Size = new System.Drawing.Size(234, 22);
this.all3DObjectssplitToolStripMenuItem.Text = "Export All 3D objects (split)";
this.all3DObjectssplitToolStripMenuItem.Click += new System.EventHandler(this.all3DObjectssplitToolStripMenuItem_Click);
this.dontLoadAssetsMenuItem.CheckOnClick = true;
this.dontLoadAssetsMenuItem.Name = "dontLoadAssetsMenuItem";
this.dontLoadAssetsMenuItem.Size = new System.Drawing.Size(224, 22);
this.dontLoadAssetsMenuItem.Text = "Don\'t load assets";
this.dontLoadAssetsMenuItem.CheckedChanged += new System.EventHandler(this.dontLoadAssetsMenuItem_CheckedChanged);
//
// exportSelected3DMenuItem
// dontBuildHierarchyMenuItem
//
this.exportSelected3DMenuItem.Name = "exportSelected3DMenuItem";
this.exportSelected3DMenuItem.Size = new System.Drawing.Size(234, 22);
this.exportSelected3DMenuItem.Text = "Export Selected 3D objects";
this.exportSelected3DMenuItem.Click += new System.EventHandler(this.Export3DObjects_Click);
this.dontBuildHierarchyMenuItem.CheckOnClick = true;
this.dontBuildHierarchyMenuItem.Name = "dontBuildHierarchyMenuItem";
this.dontBuildHierarchyMenuItem.Size = new System.Drawing.Size(224, 22);
this.dontBuildHierarchyMenuItem.Text = "Don\'t build hierarchy tree";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(221, 6);
//
// exportClassStructuresMenuItem
//
this.exportClassStructuresMenuItem.Name = "exportClassStructuresMenuItem";
this.exportClassStructuresMenuItem.Size = new System.Drawing.Size(224, 22);
this.exportClassStructuresMenuItem.Text = "Export class structures";
this.exportClassStructuresMenuItem.Click += new System.EventHandler(this.exportClassStructuresMenuItem_Click);
//
// splitContainer1
//
@ -830,28 +829,43 @@
//
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exportSelectedAssetsToolStripMenuItem,
this.exportAnimatorwithAnimationClipMenuItem,
this.exportObjectswithAnimationClipMenuItem,
this.showOriginalFileToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(176, 26);
this.contextMenuStrip1.Size = new System.Drawing.Size(283, 114);
//
// showOriginalFileToolStripMenuItem
//
this.showOriginalFileToolStripMenuItem.Name = "showOriginalFileToolStripMenuItem";
this.showOriginalFileToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
this.showOriginalFileToolStripMenuItem.Text = "show original file";
this.showOriginalFileToolStripMenuItem.Size = new System.Drawing.Size(282, 22);
this.showOriginalFileToolStripMenuItem.Text = "Show original file";
this.showOriginalFileToolStripMenuItem.Visible = false;
this.showOriginalFileToolStripMenuItem.Click += new System.EventHandler(this.showOriginalFileToolStripMenuItem_Click);
//
// toolStripSeparator1
// exportAnimatorwithAnimationClipMenuItem
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(162, 6);
this.exportAnimatorwithAnimationClipMenuItem.Name = "exportAnimatorwithAnimationClipMenuItem";
this.exportAnimatorwithAnimationClipMenuItem.Size = new System.Drawing.Size(282, 22);
this.exportAnimatorwithAnimationClipMenuItem.Text = "Export Animator with AnimationClip";
this.exportAnimatorwithAnimationClipMenuItem.Visible = false;
this.exportAnimatorwithAnimationClipMenuItem.Click += new System.EventHandler(this.exportAnimatorwithAnimationClipMenuItem_Click);
//
// animatorWithAnimationClipToolStripMenuItem
// exportObjectswithAnimationClipMenuItem
//
this.animatorWithAnimationClipToolStripMenuItem.Name = "animatorWithAnimationClipToolStripMenuItem";
this.animatorWithAnimationClipToolStripMenuItem.Size = new System.Drawing.Size(240, 22);
this.animatorWithAnimationClipToolStripMenuItem.Text = "Export Animator with AnimationClip";
this.animatorWithAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.ExportAnimatorwithAnimationClip_Click);
this.exportObjectswithAnimationClipMenuItem.Name = "exportObjectswithAnimationClipMenuItem";
this.exportObjectswithAnimationClipMenuItem.Size = new System.Drawing.Size(282, 22);
this.exportObjectswithAnimationClipMenuItem.Text = "Export Objects with AnimationClip";
this.exportObjectswithAnimationClipMenuItem.Visible = false;
this.exportObjectswithAnimationClipMenuItem.Click += new System.EventHandler(this.exportObjectswithAnimationClipMenuItem_Click);
//
// exportSelectedAssetsToolStripMenuItem
//
this.exportSelectedAssetsToolStripMenuItem.Name = "exportSelectedAssetsToolStripMenuItem";
this.exportSelectedAssetsToolStripMenuItem.Size = new System.Drawing.Size(282, 22);
this.exportSelectedAssetsToolStripMenuItem.Text = "Export selected assets";
this.exportSelectedAssetsToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedAssetsToolStripMenuItem_Click);
//
// AssetStudioForm
//
@ -922,7 +936,7 @@
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.Panel progressbarPanel;
private System.Windows.Forms.ToolStripMenuItem exportFilteredAssetsMenuItem;
private System.Windows.Forms.ToolStripMenuItem _3DToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem modelToolStripMenuItem;
private System.Windows.Forms.Label assetInfoLabel;
private System.Windows.Forms.TextBox textPreviewBox;
private System.Windows.Forms.RichTextBox fontPreviewBox;
@ -946,8 +960,8 @@
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem extractBundleToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem extractFolderToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportAll3DMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportSelected3DMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportallobjectsMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportselectedobjectsMenuItem;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.ToolStripComboBox assetGroupOptions;
@ -968,12 +982,13 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem exportClassStructuresMenuItem;
private System.Windows.Forms.Label FMODcopyright;
private System.Windows.Forms.ToolStripMenuItem all3DObjectssplitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportallobjectssplitToolStripMenuItem;
private OpenTK.GLControl glControl1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem showOriginalFileToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem animatorWithAnimationClipToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportAnimatorwithAnimationClipMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportObjectswithAnimationClipMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportSelectedAssetsToolStripMenuItem;
}
}

View File

@ -16,7 +16,6 @@ using OpenTK.Graphics.OpenGL;
using static AssetStudio.Studio;
using static AssetStudio.FBXExporter;
using static AssetStudio.Importer;
using static AssetStudio.Exporter;
using static AssetStudio.SpriteHelper;
namespace AssetStudio
@ -75,7 +74,7 @@ namespace AssetStudio
private PrivateFontCollection pfc = new PrivateFontCollection();
private AssetPreloadData selectasset;
private List<AssetPreloadData> selectedAssets = new List<AssetPreloadData>();
[DllImport("gdi32.dll")]
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
@ -145,48 +144,31 @@ namespace AssetStudio
private void extractBundleToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openBundleDialog = new OpenFileDialog();
openBundleDialog.Filter = "Bundle files|*.*";
openBundleDialog.FilterIndex = 1;
openBundleDialog.RestoreDirectory = true;
openBundleDialog.Multiselect = true;
var openBundleDialog = new OpenFileDialog
{
Filter = "Bundle files|*.*",
FilterIndex = 1,
RestoreDirectory = true,
Multiselect = true
};
if (openBundleDialog.ShowDialog() == DialogResult.OK)
{
progressBar1.Value = 0;
progressBar1.Maximum = openBundleDialog.FileNames.Length;
int extractedCount = 0;
ThreadPool.QueueUserWorkItem(delegate
{
foreach (var fileName in openBundleDialog.FileNames)
{
extractedCount += ExtractBundleFile(fileName);
ProgressBarPerformStep();
}
StatusStripUpdate($"Finished extracting {extractedCount} files.");
});
ExtractBundle(openBundleDialog.FileNames);
}
}
private void extractFolderToolStripMenuItem_Click(object sender, EventArgs e)
{
int extractedCount = 0;
var openFolderDialog1 = new OpenFolderDialog();
if (openFolderDialog1.ShowDialog(this) == DialogResult.OK)
{
string startPath = openFolderDialog1.Folder;
var bundleFiles = Directory.GetFiles(startPath, "*.*", SearchOption.AllDirectories).ToList();
var bundleFiles = Directory.GetFiles(openFolderDialog1.Folder, "*.*", SearchOption.AllDirectories);
progressBar1.Value = 0;
progressBar1.Maximum = bundleFiles.Count;
ThreadPool.QueueUserWorkItem(delegate
{
foreach (var fileName in bundleFiles)
{
extractedCount += ExtractBundleFile(fileName);
ProgressBarPerformStep();
}
StatusStripUpdate($"Finished extracting {extractedCount} files.");
});
progressBar1.Maximum = bundleFiles.Length;
ExtractBundle(bundleFiles);
}
}
@ -484,11 +466,11 @@ namespace AssetStudio
{
case 0:
treeSearch.Select();
_3DToolStripMenuItem.Visible = true;
modelToolStripMenuItem.Visible = true;
exportToolStripMenuItem.Visible = false;
break;
case 1:
_3DToolStripMenuItem.Visible = false;
modelToolStripMenuItem.Visible = false;
exportToolStripMenuItem.Visible = true;
resizeAssetListColumns(); //required because the ListView is not visible on app launch
classPreviewPanel.Visible = false;
@ -496,7 +478,7 @@ namespace AssetStudio
listSearch.Select();
break;
case 2:
_3DToolStripMenuItem.Visible = false;
modelToolStripMenuItem.Visible = false;
exportToolStripMenuItem.Visible = false;
previewPanel.Visible = false;
classPreviewPanel.Visible = true;
@ -1322,7 +1304,7 @@ namespace AssetStudio
return false;
}
private void all3DObjectssplitToolStripMenuItem_Click(object sender, EventArgs e)
private void exportallobjectssplitToolStripMenuItem_Click(object sender, EventArgs e)
{
if (sceneTreeView.Nodes.Count > 0)
{
@ -1342,7 +1324,7 @@ namespace AssetStudio
progressBar1.Value = 0;
progressBar1.Maximum = sceneTreeView.Nodes.Count;
//防止主界面假死
ThreadPool.QueueUserWorkItem(delegate
ThreadPool.QueueUserWorkItem(state =>
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
sceneTreeView.Invoke(new Action(() =>
@ -1379,7 +1361,10 @@ namespace AssetStudio
}
//取消挂起
sceneTreeView.Invoke(new Action(() => sceneTreeView.EndUpdate()));
if (openAfterExport.Checked) { Process.Start(savePath); }
if (openAfterExport.Checked)
{
Process.Start(savePath);
}
});
break;
}
@ -1387,19 +1372,19 @@ namespace AssetStudio
}
}
else { StatusStripUpdate("No Objects available for export"); }
else
{
StatusStripUpdate("No Objects available for export");
}
}
private void Export3DObjects_Click(object sender, EventArgs e)
private void ExportObjects_Click(object sender, EventArgs e)
{
if (sceneTreeView.Nodes.Count > 0)
{
bool exportSwitch = ((ToolStripItem)sender).Name == "exportAll3DMenuItem";
var exportSwitch = ((ToolStripItem)sender).Name == "exportallobjectsMenuItem";
var timestamp = DateTime.Now;
saveFileDialog1.FileName = productName + timestamp.ToString("_yy_MM_dd__HH_mm_ss");
//extension will be added by the file save dialog
saveFileDialog1.FileName = productName + DateTime.Now.ToString("_yy_MM_dd__HH_mm_ss");
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
@ -1407,165 +1392,57 @@ namespace AssetStudio
{
case true:
ExportOptions exportOpt = new ExportOptions();
if (exportOpt.ShowDialog() == DialogResult.OK) { goto case false; }
if (exportOpt.ShowDialog() == DialogResult.OK)
{
goto case false;
}
break;
case false:
switch (saveFileDialog1.FilterIndex)
{
case 1:
WriteFBX(saveFileDialog1.FileName, exportSwitch);
break;
case 2:
break;
}
WriteFBX(saveFileDialog1.FileName, exportSwitch);
if (openAfterExport.Checked && File.Exists(saveFileDialog1.FileName)) { try { Process.Start(saveFileDialog1.FileName); } catch { } }
if (openAfterExport.Checked && File.Exists(saveFileDialog1.FileName))
{
Process.Start(Path.GetDirectoryName(saveFileDialog1.FileName));
}
break;
}
}
}
else { StatusStripUpdate("No Objects available for export"); }
else
{
StatusStripUpdate("No Objects available for export");
}
}
private void ExportAssets_Click(object sender, EventArgs e)
{
var saveFolderDialog1 = new OpenFolderDialog();
if (exportableAssets.Count > 0 && saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
if (exportableAssets.Count > 0)
{
timer.Stop();
List<AssetPreloadData> toExportAssets = null;
switch (((ToolStripItem)sender).Name)
var saveFolderDialog1 = new OpenFolderDialog();
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
{
case "exportAllAssetsMenuItem":
toExportAssets = exportableAssets;
break;
case "exportFilteredAssetsMenuItem":
toExportAssets = visibleAssets;
break;
case "exportSelectedAssetsMenuItem":
toExportAssets = new List<AssetPreloadData>(assetListView.SelectedIndices.Count);
foreach (int i in assetListView.SelectedIndices)
{
toExportAssets.Add((AssetPreloadData)assetListView.Items[i]);
}
break;
timer.Stop();
List<AssetPreloadData> toExportAssets = null;
switch (((ToolStripItem)sender).Name)
{
case "exportAllAssetsMenuItem":
toExportAssets = exportableAssets;
break;
case "exportFilteredAssetsMenuItem":
toExportAssets = visibleAssets;
break;
case "exportSelectedAssetsMenuItem":
toExportAssets = new List<AssetPreloadData>(assetListView.SelectedIndices.Count);
foreach (int i in assetListView.SelectedIndices)
{
toExportAssets.Add((AssetPreloadData)assetListView.Items[i]);
}
break;
}
ExportAssets(saveFolderDialog1.Folder, toExportAssets, assetGroupOptions.SelectedIndex, openAfterExport.Checked);
}
int assetGroupSelectedIndex = assetGroupOptions.SelectedIndex;
ThreadPool.QueueUserWorkItem(delegate
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
var savePath = saveFolderDialog1.Folder;
int toExport = toExportAssets.Count;
int exportedCount = 0;
SetProgressBarValue(0);
SetProgressBarMaximum(toExport);
//looping assetsFiles will optimize HDD access
//but will also have a small performance impact when exporting only a couple of selected assets
foreach (var asset in toExportAssets)
{
string exportpath = savePath + "\\";
if (assetGroupSelectedIndex == 1) { exportpath += Path.GetFileNameWithoutExtension(asset.sourceFile.filePath) + "_export\\"; }
else if (assetGroupSelectedIndex == 0) { exportpath = savePath + "\\" + asset.TypeString + "\\"; }
StatusStripUpdate($"Exporting {asset.TypeString}: {asset.Text}");
switch (asset.Type)
{
case ClassIDReference.Texture2D:
if (ExportTexture2D(asset, exportpath, true))
{
exportedCount++;
}
break;
case ClassIDReference.AudioClip:
if (ExportAudioClip(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Shader:
if (ExportShader(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.TextAsset:
if (ExportTextAsset(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.MonoBehaviour:
if (ExportMonoBehaviour(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Font:
if (ExportFont(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Mesh:
if (ExportMesh(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.VideoClip:
if (ExportVideoClip(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.MovieTexture:
if (ExportMovieTexture(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Sprite:
if (ExportSprite(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Animator:
if (ExportAnimator(asset, exportpath))
{
exportedCount++;
}
break;
default:
if (ExportRawFile(asset, exportpath))
{
exportedCount++;
}
break;
}
ProgressBarPerformStep();
}
string statusText;
switch (exportedCount)
{
case 0:
statusText = "Nothing exported.";
break;
default:
statusText = $"Finished exporting {exportedCount} assets.";
break;
}
if (toExport > exportedCount) { statusText += $" {toExport - exportedCount} assets skipped (not extractable or files already exist)"; }
StatusStripUpdate(statusText);
if (openAfterExport.Checked && exportedCount > 0) { Process.Start(savePath); }
});
}
else
{
@ -1800,6 +1677,14 @@ namespace AssetStudio
glControl1.SwapBuffers();
}
private void glControl1_MouseWheel(object sender, MouseEventArgs e)
{
if (glControl1.Visible)
{
viewMatrixData *= Matrix4.CreateScale(1 + e.Delta / 1000f);
glControl1.Invalidate();
}
}
private void resetForm()
{
Text = "AssetStudio";
@ -1845,46 +1730,74 @@ namespace AssetStudio
FMODreset();
}
private void assetListView_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right && assetListView.SelectedIndices.Count > 0)
{
showOriginalFileToolStripMenuItem.Visible = false;
exportAnimatorwithAnimationClipMenuItem.Visible = false;
exportObjectswithAnimationClipMenuItem.Visible = false;
if (assetListView.SelectedIndices.Count == 1)
{
selectedAssets.Clear();
selectedAssets.Add((AssetPreloadData)assetListView.Items[assetListView.SelectedIndices[0]]);
showOriginalFileToolStripMenuItem.Visible = true;
}
else if (assetListView.SelectedIndices.Count >= 1)
{
selectedAssets.Clear();
foreach (int index in assetListView.SelectedIndices)
{
selectedAssets.Add((AssetPreloadData)assetListView.Items[index]);
}
if (selectedAssets.Any(x => x.Type == ClassIDReference.Animator) && selectedAssets.Any(x => x.Type == ClassIDReference.AnimationClip))
{
exportAnimatorwithAnimationClipMenuItem.Visible = true;
}
/*else if (selectedAssets.All(x => x.Type == ClassIDReference.AnimationClip))
{
exportObjectswithAnimationClipMenuItem.Visible = true;
}*/
}
contextMenuStrip1.Show(assetListView, e.X, e.Y);
}
}
private void exportSelectedAssetsToolStripMenuItem_Click(object sender, EventArgs e)
{
var saveFolderDialog1 = new OpenFolderDialog();
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
{
timer.Stop();
ExportAssets(saveFolderDialog1.Folder, selectedAssets, assetGroupOptions.SelectedIndex, openAfterExport.Checked);
}
}
private void showOriginalFileToolStripMenuItem_Click(object sender, EventArgs e)
{
var selectasset = (AssetPreloadData)assetListView.Items[assetListView.SelectedIndices[0]];
var args = $"/select, {selectasset.sourceFile.parentPath ?? selectasset.sourceFile.filePath}";
var pfi = new ProcessStartInfo("explorer.exe", args);
Process.Start(pfi);
}
private void assetListView_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
selectasset = (AssetPreloadData)assetListView.Items[assetListView.SelectedIndices[0]];
contextMenuStrip1.Show(assetListView, e.X, e.Y);
}
}
private void glControl1_MouseWheel(object sender, MouseEventArgs e)
{
if (glControl1.Visible)
{
viewMatrixData *= Matrix4.CreateScale(1 + e.Delta / 1000f);
glControl1.Invalidate();
}
}
private void ExportAnimatorwithAnimationClip_Click(object sender, EventArgs e)
private void exportAnimatorwithAnimationClipMenuItem_Click(object sender, EventArgs e)
{
AssetPreloadData animator = null;
List<AssetPreloadData> animationList = new List<AssetPreloadData>();
for (int i = 0; i < assetListView.SelectedIndices.Count; i++)
foreach (var assetPreloadData in selectedAssets)
{
var index = assetListView.SelectedIndices[i];
var asset = (AssetPreloadData)assetListView.Items[index];
if (asset.Type2 == 95) //Animator
if (assetPreloadData.Type == ClassIDReference.Animator)
{
animator = asset;
animator = assetPreloadData;
}
else if (asset.Type2 == 74) //AnimationClip
else if (assetPreloadData.Type == ClassIDReference.AnimationClip)
{
animationList.Add(asset);
animationList.Add(assetPreloadData);
}
}
@ -1893,17 +1806,17 @@ namespace AssetStudio
var saveFolderDialog1 = new OpenFolderDialog();
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
{
var savePath = saveFolderDialog1.Folder;
string exportpath = savePath + "\\Animator\\";
SetProgressBarValue(0);
SetProgressBarMaximum(1);
ThreadPool.QueueUserWorkItem(state =>
{
StatusStripUpdate(ExportAnimator(animator, animationList, exportpath) ? "Successfully exported" : "Nothing exported.");
ProgressBarPerformStep();
});
var exportpath = saveFolderDialog1.Folder + "\\Animator\\";
progressBar1.Value = 0;
progressBar1.Maximum = 1;
ExportAnimatorWithAnimationClip(animator, animationList, exportpath);
}
}
}
private void exportObjectswithAnimationClipMenuItem_Click(object sender, EventArgs e)
{
//TODO
}
}
}

View File

@ -334,7 +334,7 @@ namespace AssetStudio
return true;
}
public static bool ExportAnimator(AssetPreloadData animator, List<AssetPreloadData> animations, string exportPath)
public static bool ExportAnimator(AssetPreloadData animator, List<AssetPreloadData> animationList, string exportPath)
{
var EulerFilter = (bool)Properties.Settings.Default["EulerFilter"];
var filterPrecision = (float)(decimal)Properties.Settings.Default["filterPrecision"];
@ -345,7 +345,7 @@ namespace AssetStudio
var flatInbetween = (bool)Properties.Settings.Default["flatInbetween"];
var compatibility = (bool)Properties.Settings.Default["compatibility"];
var m_Animator = new Animator(animator);
var convert = new ModelConverter(m_Animator, animations);
var convert = new ModelConverter(m_Animator, animationList);
exportPath = exportPath + Studio.FixFileName(animator.Text) + ".fbx";
Fbx.Exporter.Export(exportPath, convert, EulerFilter, filterPrecision, ".fbx", allFrames, allBones, skins, boneSize, flatInbetween, compatibility);
return true;

View File

@ -14,6 +14,58 @@ namespace AssetStudio
public static HashSet<string> importFilesHash = new HashSet<string>(); //to improve the loading speed
public static HashSet<string> assetsfileListHash = new HashSet<string>(); //to improve the loading speed
private enum FileType
{
AssetsFile,
BundleFile,
WebFile
}
private static FileType CheckFileType(MemoryStream stream, out EndianBinaryReader reader)
{
reader = new EndianBinaryReader(stream);
return CheckFileType(reader);
}
private static FileType CheckFileType(string fileName, out EndianBinaryReader reader)
{
reader = new EndianBinaryReader(File.OpenRead(fileName));
return CheckFileType(reader);
}
private static FileType CheckFileType(EndianBinaryReader reader)
{
var signature = reader.ReadStringToNull();
reader.Position = 0;
switch (signature)
{
case "UnityWeb":
case "UnityRaw":
case "\xFA\xFA\xFA\xFA\xFA\xFA\xFA\xFA":
case "UnityFS":
return FileType.BundleFile;
case "UnityWebData1.0":
return FileType.WebFile;
default:
{
var magic = reader.ReadBytes(2);
reader.Position = 0;
if (WebFile.gzipMagic.SequenceEqual(magic))
{
return FileType.WebFile;
}
reader.Position = 0x20;
magic = reader.ReadBytes(6);
reader.Position = 0;
if (WebFile.brotliMagic.SequenceEqual(magic))
{
return FileType.WebFile;
}
return FileType.AssetsFile;
}
}
}
public static void LoadFile(string fullName)
{
switch (CheckFileType(fullName, out var reader))

View File

@ -1,8 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Web.Script.Serialization;
using System.Windows.Forms;
using static AssetStudio.Exporter;
namespace AssetStudio
{
@ -29,22 +34,32 @@ namespace AssetStudio
public static Action<string> StatusStripUpdate;
public static Action<int> ProgressBarMaximumAdd;
public enum FileType
public static void ExtractBundle(string[] bundleFileName)
{
AssetsFile,
BundleFile,
WebFile
ThreadPool.QueueUserWorkItem(state =>
{
int extractedCount = 0;
foreach (var fileName in bundleFileName)
{
extractedCount += ExtractBundleFile(fileName);
ProgressBarPerformStep();
}
StatusStripUpdate($"Finished extracting {extractedCount} files.");
});
}
public static int ExtractBundleFile(string bundleFileName)
private static int ExtractBundleFile(string bundleFileName)
{
int extractedCount = 0;
if (CheckFileType(bundleFileName, out var reader) == FileType.BundleFile)
var extractPath = bundleFileName + "_unpacked\\";
Directory.CreateDirectory(extractPath);
var reader = new EndianBinaryReader(File.OpenRead(bundleFileName));
var bundleFile = new BundleFile(reader);
reader.Dispose();
if (bundleFile.fileList.Count > 0)
{
StatusStripUpdate($"Decompressing {Path.GetFileName(bundleFileName)} ...");
var extractPath = bundleFileName + "_unpacked\\";
Directory.CreateDirectory(extractPath);
var bundleFile = new BundleFile(reader);
foreach (var memFile in bundleFile.fileList)
{
var filePath = extractPath + memFile.fileName.Replace('/', '\\');
@ -54,17 +69,12 @@ namespace AssetStudio
}
if (!File.Exists(filePath))
{
StatusStripUpdate($"Extracting {Path.GetFileName(memFile.fileName)}");
File.WriteAllBytes(filePath, memFile.stream.ToArray());
memFile.stream.Dispose();
extractedCount += 1;
using (var file = File.Create(filePath))
{
memFile.stream.WriteTo(file);
memFile.stream.Close();
}
}
}
}
reader.Dispose();
return extractedCount;
}
@ -361,51 +371,6 @@ namespace AssetStudio
return Path.GetInvalidFileNameChars().Aggregate(str, (current, c) => current.Replace(c, '_'));
}
public static FileType CheckFileType(MemoryStream stream, out EndianBinaryReader reader)
{
reader = new EndianBinaryReader(stream);
return CheckFileType(reader);
}
public static FileType CheckFileType(string fileName, out EndianBinaryReader reader)
{
reader = new EndianBinaryReader(File.OpenRead(fileName));
return CheckFileType(reader);
}
public static FileType CheckFileType(EndianBinaryReader reader)
{
var signature = reader.ReadStringToNull();
reader.Position = 0;
switch (signature)
{
case "UnityWeb":
case "UnityRaw":
case "\xFA\xFA\xFA\xFA\xFA\xFA\xFA\xFA":
case "UnityFS":
return FileType.BundleFile;
case "UnityWebData1.0":
return FileType.WebFile;
default:
{
var magic = reader.ReadBytes(2);
reader.Position = 0;
if (WebFile.gzipMagic.SequenceEqual(magic))
{
return FileType.WebFile;
}
reader.Position = 0x20;
magic = reader.ReadBytes(6);
reader.Position = 0;
if (WebFile.brotliMagic.SequenceEqual(magic))
{
return FileType.WebFile;
}
return FileType.AssetsFile;
}
}
}
public static string[] ProcessingSplitFiles(List<string> selectFile)
{
var splitFiles = selectFile.Where(x => x.Contains(".split"))
@ -422,5 +387,141 @@ namespace AssetStudio
}
return selectFile.Distinct().ToArray();
}
public static void ExportAssets(string savePath, List<AssetPreloadData> toExportAssets, int assetGroupSelectedIndex, bool openAfterExport)
{
ThreadPool.QueueUserWorkItem(state =>
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
int toExport = toExportAssets.Count;
int exportedCount = 0;
SetProgressBarValue(0);
SetProgressBarMaximum(toExport);
foreach (var asset in toExportAssets)
{
var exportpath = savePath + "\\";
if (assetGroupSelectedIndex == 1)
{
exportpath += Path.GetFileNameWithoutExtension(asset.sourceFile.filePath) + "_export\\";
}
else if (assetGroupSelectedIndex == 0)
{
exportpath = savePath + "\\" + asset.TypeString + "\\";
}
StatusStripUpdate($"Exporting {asset.TypeString}: {asset.Text}");
switch (asset.Type)
{
case ClassIDReference.Texture2D:
if (ExportTexture2D(asset, exportpath, true))
{
exportedCount++;
}
break;
case ClassIDReference.AudioClip:
if (ExportAudioClip(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Shader:
if (ExportShader(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.TextAsset:
if (ExportTextAsset(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.MonoBehaviour:
if (ExportMonoBehaviour(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Font:
if (ExportFont(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Mesh:
if (ExportMesh(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.VideoClip:
if (ExportVideoClip(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.MovieTexture:
if (ExportMovieTexture(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Sprite:
if (ExportSprite(asset, exportpath))
{
exportedCount++;
}
break;
case ClassIDReference.Animator:
if (ExportAnimator(asset, exportpath))
{
exportedCount++;
}
break;
default:
if (ExportRawFile(asset, exportpath))
{
exportedCount++;
}
break;
}
ProgressBarPerformStep();
}
var statusText = exportedCount == 0 ? "Nothing exported." : $"Finished exporting {exportedCount} assets.";
if (toExport > exportedCount)
{
statusText += $" {toExport - exportedCount} assets skipped (not extractable or files already exist)";
}
StatusStripUpdate(statusText);
if (openAfterExport && exportedCount > 0)
{
Process.Start(savePath);
}
});
}
public static void ExportAnimatorWithAnimationClip(AssetPreloadData animator, List<AssetPreloadData> animationList, string exportPath)
{
ThreadPool.QueueUserWorkItem(state =>
{
var result = false;
try
{
result = ExportAnimator(animator, animationList, exportPath);
}
catch (Exception ex)
{
MessageBox.Show($"{ex.Message}\r\n{ex.StackTrace}");
}
StatusStripUpdate(result ? "Successfully exported" : "Nothing exported.");
ProgressBarPerformStep();
});
}
}
}