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);
|
||||
}
|
||||
|
||||
public void LoadFiles(params string[] files)
|
||||
public void LoadFilesAndFolders(params string[] path)
|
||||
{
|
||||
var path = Path.GetDirectoryName(Path.GetFullPath(files[0]));
|
||||
MergeSplitAssets(path);
|
||||
var toReadFile = ProcessingSplitFiles(files.ToList());
|
||||
Load(toReadFile);
|
||||
List<string> pathList = new List<string>();
|
||||
pathList.AddRange(path);
|
||||
LoadFilesAndFolders(out _, pathList);
|
||||
}
|
||||
|
||||
public void LoadFolder(string path)
|
||||
public void LoadFilesAndFolders(out string parentPath, params string[] path)
|
||||
{
|
||||
MergeSplitAssets(path, true);
|
||||
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).ToList();
|
||||
var toReadFile = ProcessingSplitFiles(files);
|
||||
List<string> pathList = new List<string>();
|
||||
pathList.AddRange(path);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,7 @@ namespace AssetStudioCLI
|
||||
assetsManager.SpecifyUnityVersion = options.o_unityVersion.Value;
|
||||
assetsManager.SetAssetFilter(options.o_exportAssetTypes.Value);
|
||||
|
||||
if (Directory.Exists(options.inputPath))
|
||||
{
|
||||
assetsManager.LoadFolder(options.inputPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
assetsManager.LoadFiles(options.inputPath);
|
||||
}
|
||||
assetsManager.LoadFilesAndFolders(options.inputPath);
|
||||
if (assetsManager.assetsFileList.Count == 0)
|
||||
{
|
||||
Logger.Warning("No Unity file can be loaded.");
|
||||
|
@ -143,14 +143,8 @@ namespace AssetStudioGUI
|
||||
{
|
||||
ResetForm();
|
||||
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
||||
if (paths.Length == 1 && Directory.Exists(paths[0]))
|
||||
{
|
||||
await Task.Run(() => assetsManager.LoadFolder(paths[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Run(() => assetsManager.LoadFiles(paths));
|
||||
}
|
||||
await Task.Run(() => assetsManager.LoadFilesAndFolders(out openDirectoryBackup, paths));
|
||||
saveDirectoryBackup = openDirectoryBackup;
|
||||
BuildAssetStructures();
|
||||
}
|
||||
}
|
||||
@ -161,9 +155,8 @@ namespace AssetStudioGUI
|
||||
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
ResetForm();
|
||||
openDirectoryBackup = Path.GetDirectoryName(openFileDialog1.FileNames[0]);
|
||||
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
||||
await Task.Run(() => assetsManager.LoadFiles(openFileDialog1.FileNames));
|
||||
await Task.Run(() => assetsManager.LoadFilesAndFolders(out openDirectoryBackup, openFileDialog1.FileNames));
|
||||
BuildAssetStructures();
|
||||
}
|
||||
}
|
||||
@ -175,9 +168,8 @@ namespace AssetStudioGUI
|
||||
if (openFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
ResetForm();
|
||||
openDirectoryBackup = openFolderDialog.Folder;
|
||||
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
||||
await Task.Run(() => assetsManager.LoadFolder(openFolderDialog.Folder));
|
||||
await Task.Run(() => assetsManager.LoadFilesAndFolders(out openDirectoryBackup, openFolderDialog.Folder));
|
||||
BuildAssetStructures();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user