can choose the directory to save the extracted files
This commit is contained in:
parent
8ce5b947f6
commit
ec0a2a47f1
|
@ -109,7 +109,6 @@
|
|||
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.timer = new System.Windows.Forms.Timer(this.components);
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
|
||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exportSelectedAssetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -901,11 +900,6 @@
|
|||
this.openFileDialog1.Multiselect = true;
|
||||
this.openFileDialog1.RestoreDirectory = true;
|
||||
//
|
||||
// saveFileDialog1
|
||||
//
|
||||
this.saveFileDialog1.Filter = "FBX file|*.fbx";
|
||||
this.saveFileDialog1.RestoreDirectory = true;
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
|
@ -1052,7 +1046,6 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem extractFileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem extractFolderToolStripMenuItem;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
|
||||
private System.Windows.Forms.ToolStripMenuItem showExpOpt;
|
||||
private GOHierarchy sceneTreeView;
|
||||
private System.Windows.Forms.ToolStripMenuItem debugMenuItem;
|
||||
|
|
|
@ -150,21 +150,36 @@ namespace AssetStudioGUI
|
|||
}
|
||||
}
|
||||
|
||||
private void extractFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private async void extractFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ExtractFile(openFileDialog1.FileNames);
|
||||
var saveFolderDialog = new OpenFolderDialog();
|
||||
saveFolderDialog.Title = "Select the save folder";
|
||||
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
var fileNames = openFileDialog1.FileNames;
|
||||
var savePath = saveFolderDialog.Folder;
|
||||
var extractedCount = await Task.Run(() => ExtractFile(fileNames, savePath));
|
||||
StatusStripUpdate($"Finished extracting {extractedCount} files.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void extractFolderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private async void extractFolderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var openFolderDialog1 = new OpenFolderDialog();
|
||||
if (openFolderDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
var openFolderDialog = new OpenFolderDialog();
|
||||
if (openFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
var files = Directory.GetFiles(openFolderDialog1.Folder, "*.*", SearchOption.AllDirectories);
|
||||
ExtractFile(files);
|
||||
var saveFolderDialog = new OpenFolderDialog();
|
||||
saveFolderDialog.Title = "Select the save folder";
|
||||
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
var path = openFolderDialog.Folder;
|
||||
var savePath = saveFolderDialog.Folder;
|
||||
var extractedCount = await Task.Run(() => ExtractFolder(path, savePath));
|
||||
StatusStripUpdate($"Finished extracting {extractedCount} files.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1278,10 +1293,10 @@ namespace AssetStudioGUI
|
|||
|
||||
if (animator != null)
|
||||
{
|
||||
var saveFolderDialog1 = new OpenFolderDialog();
|
||||
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
var saveFolderDialog = new OpenFolderDialog();
|
||||
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
var exportPath = saveFolderDialog1.Folder + "\\Animator\\";
|
||||
var exportPath = saveFolderDialog.Folder + "\\Animator\\";
|
||||
ExportAnimatorWithAnimationClip(animator, animationList, exportPath);
|
||||
}
|
||||
}
|
||||
|
@ -1301,10 +1316,10 @@ namespace AssetStudioGUI
|
|||
{
|
||||
if (sceneTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var saveFolderDialog1 = new OpenFolderDialog();
|
||||
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
var saveFolderDialog = new OpenFolderDialog();
|
||||
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
var exportPath = saveFolderDialog1.Folder + "\\GameObject\\";
|
||||
var exportPath = saveFolderDialog.Folder + "\\GameObject\\";
|
||||
List<AssetItem> animationList = null;
|
||||
if (animation)
|
||||
{
|
||||
|
@ -1419,10 +1434,10 @@ namespace AssetStudioGUI
|
|||
{
|
||||
if (sceneTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var saveFolderDialog1 = new OpenFolderDialog();
|
||||
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
var saveFolderDialog = new OpenFolderDialog();
|
||||
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
var savePath = saveFolderDialog1.Folder + Path.DirectorySeparatorChar;
|
||||
var savePath = saveFolderDialog.Folder + Path.DirectorySeparatorChar;
|
||||
ExportSplitObjects(savePath, sceneTreeView.Nodes);
|
||||
}
|
||||
}
|
||||
|
@ -1479,8 +1494,8 @@ namespace AssetStudioGUI
|
|||
{
|
||||
if (exportableAssets.Count > 0)
|
||||
{
|
||||
var saveFolderDialog1 = new OpenFolderDialog();
|
||||
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
var saveFolderDialog = new OpenFolderDialog();
|
||||
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
timer.Stop();
|
||||
|
||||
|
@ -1497,7 +1512,7 @@ namespace AssetStudioGUI
|
|||
toExportAssets = visibleAssets;
|
||||
break;
|
||||
}
|
||||
Studio.ExportAssets(saveFolderDialog1.Folder, toExportAssets, exportType);
|
||||
Studio.ExportAssets(saveFolderDialog.Folder, toExportAssets, exportType);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -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.:,;'\"(!?)+-*/=
|
||||
|
@ -141,15 +138,15 @@ 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="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>553, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>636, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>784, 17</value>
|
||||
</metadata>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>147, 17</value>
|
||||
</metadata>
|
||||
|
|
|
@ -27,50 +27,52 @@ namespace AssetStudioGUI
|
|||
public static List<AssetItem> visibleAssets = new List<AssetItem>();
|
||||
internal static Action<string> StatusStripUpdate = x => { };
|
||||
|
||||
public static void ExtractFile(string[] fileNames)
|
||||
public static int ExtractFolder(string path, string savePath)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
int extractedCount = 0;
|
||||
Progress.Reset();
|
||||
for (var i = 0; i < fileNames.Length; i++)
|
||||
{
|
||||
var fileName = fileNames[i];
|
||||
var type = ImportHelper.CheckFileType(fileName, out var reader);
|
||||
if (type == FileType.BundleFile)
|
||||
extractedCount += ExtractBundleFile(fileName, reader);
|
||||
else if (type == FileType.WebFile)
|
||||
extractedCount += ExtractWebDataFile(fileName, reader);
|
||||
else
|
||||
reader.Dispose();
|
||||
Progress.Report(i + 1, fileNames.Length);
|
||||
}
|
||||
|
||||
StatusStripUpdate($"Finished extracting {extractedCount} files.");
|
||||
});
|
||||
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
|
||||
return ExtractFile(files, savePath);
|
||||
}
|
||||
|
||||
private static int ExtractBundleFile(string bundleFileName, EndianBinaryReader reader)
|
||||
public static int ExtractFile(string[] fileNames, string savePath)
|
||||
{
|
||||
StatusStripUpdate($"Decompressing {Path.GetFileName(bundleFileName)} ...");
|
||||
var bundleFile = new BundleFile(reader, bundleFileName);
|
||||
int extractedCount = 0;
|
||||
Progress.Reset();
|
||||
for (var i = 0; i < fileNames.Length; i++)
|
||||
{
|
||||
var fileName = fileNames[i];
|
||||
var type = ImportHelper.CheckFileType(fileName, out var reader);
|
||||
if (type == FileType.BundleFile)
|
||||
extractedCount += ExtractBundleFile(fileName, reader, savePath);
|
||||
else if (type == FileType.WebFile)
|
||||
extractedCount += ExtractWebDataFile(fileName, reader, savePath);
|
||||
else
|
||||
reader.Dispose();
|
||||
Progress.Report(i + 1, fileNames.Length);
|
||||
}
|
||||
return extractedCount;
|
||||
}
|
||||
|
||||
private static int ExtractBundleFile(string bundleFilePath, EndianBinaryReader reader, string savePath)
|
||||
{
|
||||
StatusStripUpdate($"Decompressing {Path.GetFileName(bundleFilePath)} ...");
|
||||
var bundleFile = new BundleFile(reader, bundleFilePath);
|
||||
reader.Dispose();
|
||||
if (bundleFile.fileList.Length > 0)
|
||||
{
|
||||
var extractPath = bundleFileName + "_unpacked\\";
|
||||
var extractPath = Path.Combine(savePath, Path.GetFileName(bundleFilePath) + "_unpacked");
|
||||
return ExtractStreamFile(extractPath, bundleFile.fileList);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int ExtractWebDataFile(string webFileName, EndianBinaryReader reader)
|
||||
private static int ExtractWebDataFile(string webFilePath, EndianBinaryReader reader, string savePath)
|
||||
{
|
||||
StatusStripUpdate($"Decompressing {Path.GetFileName(webFileName)} ...");
|
||||
StatusStripUpdate($"Decompressing {Path.GetFileName(webFilePath)} ...");
|
||||
var webFile = new WebFile(reader);
|
||||
reader.Dispose();
|
||||
if (webFile.fileList.Length > 0)
|
||||
{
|
||||
var extractPath = webFileName + "_unpacked\\";
|
||||
var extractPath = Path.Combine(savePath, Path.GetFileName(webFilePath) + "_unpacked");
|
||||
return ExtractStreamFile(extractPath, webFile.fileList);
|
||||
}
|
||||
return 0;
|
||||
|
@ -81,14 +83,17 @@ namespace AssetStudioGUI
|
|||
int extractedCount = 0;
|
||||
foreach (var file in fileList)
|
||||
{
|
||||
var filePath = extractPath + file.fileName;
|
||||
var filePath = Path.Combine(extractPath, file.fileName);
|
||||
if (!Directory.Exists(extractPath))
|
||||
{
|
||||
Directory.CreateDirectory(extractPath);
|
||||
}
|
||||
if (!File.Exists(filePath) && file.stream is MemoryStream stream)
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
File.WriteAllBytes(filePath, stream.ToArray());
|
||||
using (var fileStream = File.Create(filePath))
|
||||
{
|
||||
file.stream.CopyTo(fileStream);
|
||||
}
|
||||
extractedCount += 1;
|
||||
}
|
||||
file.stream.Dispose();
|
||||
|
|
Loading…
Reference in New Issue