mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-11-12 23:32:42 -05:00
Update asset export logic
- Disabled saving files with a unique id if they already exist. A unique id will only be added to files with identical names during export. - Added an option to overwrite exisisting files. - Fixed support of multiple model export using "Export selected objects (split)" option. (#43)
This commit is contained in:
@ -9,7 +9,7 @@ namespace AssetStudioGUI
|
||||
{
|
||||
internal static class ParallelExporter
|
||||
{
|
||||
private static ConcurrentDictionary<string, bool> savePathHash = new ConcurrentDictionary<string, bool>();
|
||||
private static readonly ConcurrentDictionary<string, bool> ExportPathDict = new ConcurrentDictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static bool ExportTexture2D(AssetItem item, string exportPath, out string debugLog)
|
||||
{
|
||||
@ -183,6 +183,7 @@ namespace AssetStudioGUI
|
||||
{
|
||||
var fileName = FixFileName(item.Text);
|
||||
var filenameFormatIndex = Properties.Settings.Default.filenameFormat;
|
||||
var canOverwrite = Properties.Settings.Default.overwriteExistingFiles;
|
||||
switch (filenameFormatIndex)
|
||||
{
|
||||
case 1: //assetName@pathID
|
||||
@ -193,17 +194,18 @@ namespace AssetStudioGUI
|
||||
break;
|
||||
}
|
||||
fullPath = Path.Combine(dir, fileName + extension);
|
||||
if (savePathHash.TryAdd(fullPath.ToLower(), true) && !File.Exists(fullPath))
|
||||
if (ExportPathDict.TryAdd(fullPath, true))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
return true;
|
||||
if (CanWrite(fullPath, dir, canOverwrite))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (filenameFormatIndex == 0) //assetName
|
||||
else if (filenameFormatIndex == 0) //assetName
|
||||
{
|
||||
fullPath = Path.Combine(dir, fileName + item.UniqueID + extension);
|
||||
if (!File.Exists(fullPath))
|
||||
if (CanWrite(fullPath, dir, canOverwrite))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -211,6 +213,14 @@ namespace AssetStudioGUI
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool CanWrite(string fullPath, string dir, bool canOverwrite)
|
||||
{
|
||||
if (!canOverwrite && File.Exists(fullPath))
|
||||
return false;
|
||||
Directory.CreateDirectory(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool ParallelExportConvertFile(AssetItem item, string exportPath, out string debugLog)
|
||||
{
|
||||
switch (item.Type)
|
||||
@ -236,7 +246,7 @@ namespace AssetStudioGUI
|
||||
|
||||
public static void ClearHash()
|
||||
{
|
||||
savePathHash.Clear();
|
||||
ExportPathDict.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user