mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
[GUI] Improve file and folder loading (drag&drop)
- Added support for drag&drop of multiple folders - Open/Export dialog can now also use a path taken from drag&drop items
This commit is contained in:
parent
b7d5d73f23
commit
2f8f57c1a6
@ -53,19 +53,53 @@ namespace AssetStudio
|
|||||||
SetAssetFilter(classIDType);
|
SetAssetFilter(classIDType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFiles(params string[] files)
|
public void LoadFilesAndFolders(params string[] path)
|
||||||
{
|
{
|
||||||
var path = Path.GetDirectoryName(Path.GetFullPath(files[0]));
|
List<string> pathList = new List<string>();
|
||||||
MergeSplitAssets(path);
|
pathList.AddRange(path);
|
||||||
var toReadFile = ProcessingSplitFiles(files.ToList());
|
LoadFilesAndFolders(out _, pathList);
|
||||||
Load(toReadFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFolder(string path)
|
public void LoadFilesAndFolders(out string parentPath, params string[] path)
|
||||||
{
|
{
|
||||||
MergeSplitAssets(path, true);
|
List<string> pathList = new List<string>();
|
||||||
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).ToList();
|
pathList.AddRange(path);
|
||||||
var toReadFile = ProcessingSplitFiles(files);
|
LoadFilesAndFolders(out parentPath, pathList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFilesAndFolders(out string parentPath, List<string> pathList)
|
||||||
|
{
|
||||||
|
List<string> fileList = new List<string>();
|
||||||
|
bool filesInPath = false;
|
||||||
|
parentPath = "";
|
||||||
|
foreach (var path in pathList)
|
||||||
|
{
|
||||||
|
var fullPath = Path.GetFullPath(path);
|
||||||
|
if (Directory.Exists(fullPath))
|
||||||
|
{
|
||||||
|
var parent = Directory.GetParent(fullPath).FullName;
|
||||||
|
if (!filesInPath && (parentPath == "" || parentPath.Length > parent.Length))
|
||||||
|
{
|
||||||
|
parentPath = parent;
|
||||||
|
}
|
||||||
|
MergeSplitAssets(fullPath, true);
|
||||||
|
fileList.AddRange(Directory.GetFiles(fullPath, "*.*", SearchOption.AllDirectories));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parentPath = Path.GetDirectoryName(fullPath);
|
||||||
|
fileList.Add(fullPath);
|
||||||
|
filesInPath = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (filesInPath)
|
||||||
|
{
|
||||||
|
MergeSplitAssets(parentPath);
|
||||||
|
}
|
||||||
|
var toReadFile = ProcessingSplitFiles(fileList);
|
||||||
|
fileList.Clear();
|
||||||
|
pathList.Clear();
|
||||||
|
|
||||||
Load(toReadFile);
|
Load(toReadFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,14 +33,7 @@ namespace AssetStudioCLI
|
|||||||
assetsManager.SpecifyUnityVersion = options.o_unityVersion.Value;
|
assetsManager.SpecifyUnityVersion = options.o_unityVersion.Value;
|
||||||
assetsManager.SetAssetFilter(options.o_exportAssetTypes.Value);
|
assetsManager.SetAssetFilter(options.o_exportAssetTypes.Value);
|
||||||
|
|
||||||
if (Directory.Exists(options.inputPath))
|
assetsManager.LoadFilesAndFolders(options.inputPath);
|
||||||
{
|
|
||||||
assetsManager.LoadFolder(options.inputPath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assetsManager.LoadFiles(options.inputPath);
|
|
||||||
}
|
|
||||||
if (assetsManager.assetsFileList.Count == 0)
|
if (assetsManager.assetsFileList.Count == 0)
|
||||||
{
|
{
|
||||||
Logger.Warning("No Unity file can be loaded.");
|
Logger.Warning("No Unity file can be loaded.");
|
||||||
|
@ -143,14 +143,8 @@ namespace AssetStudioGUI
|
|||||||
{
|
{
|
||||||
ResetForm();
|
ResetForm();
|
||||||
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
||||||
if (paths.Length == 1 && Directory.Exists(paths[0]))
|
await Task.Run(() => assetsManager.LoadFilesAndFolders(out openDirectoryBackup, paths));
|
||||||
{
|
saveDirectoryBackup = openDirectoryBackup;
|
||||||
await Task.Run(() => assetsManager.LoadFolder(paths[0]));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await Task.Run(() => assetsManager.LoadFiles(paths));
|
|
||||||
}
|
|
||||||
BuildAssetStructures();
|
BuildAssetStructures();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,9 +155,8 @@ namespace AssetStudioGUI
|
|||||||
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
|
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
|
||||||
{
|
{
|
||||||
ResetForm();
|
ResetForm();
|
||||||
openDirectoryBackup = Path.GetDirectoryName(openFileDialog1.FileNames[0]);
|
|
||||||
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
||||||
await Task.Run(() => assetsManager.LoadFiles(openFileDialog1.FileNames));
|
await Task.Run(() => assetsManager.LoadFilesAndFolders(out openDirectoryBackup, openFileDialog1.FileNames));
|
||||||
BuildAssetStructures();
|
BuildAssetStructures();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,9 +168,8 @@ namespace AssetStudioGUI
|
|||||||
if (openFolderDialog.ShowDialog(this) == DialogResult.OK)
|
if (openFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||||
{
|
{
|
||||||
ResetForm();
|
ResetForm();
|
||||||
openDirectoryBackup = openFolderDialog.Folder;
|
|
||||||
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
||||||
await Task.Run(() => assetsManager.LoadFolder(openFolderDialog.Folder));
|
await Task.Run(() => assetsManager.LoadFilesAndFolders(out openDirectoryBackup, openFolderDialog.Folder));
|
||||||
BuildAssetStructures();
|
BuildAssetStructures();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user