mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-18 11:48:47 -05:00
Merge branch 'pr/113' into AssetStudioMod
This commit is contained in:
@@ -119,6 +119,7 @@ namespace AssetStudioCLI.Options
|
|||||||
public static Option<List<string>> o_filterByPathID;
|
public static Option<List<string>> o_filterByPathID;
|
||||||
public static Option<List<string>> o_filterByText;
|
public static Option<List<string>> o_filterByText;
|
||||||
public static Option<bool> f_filterWithRegex;
|
public static Option<bool> f_filterWithRegex;
|
||||||
|
public static Option<bool> f_filterExcludeMode;
|
||||||
//import
|
//import
|
||||||
public static Option<UnityVersion> o_unityVersion;
|
public static Option<UnityVersion> o_unityVersion;
|
||||||
public static Option<string> o_cachePath;
|
public static Option<string> o_cachePath;
|
||||||
@@ -129,6 +130,7 @@ namespace AssetStudioCLI.Options
|
|||||||
public static Option<int> o_maxParallelExportTasks;
|
public static Option<int> o_maxParallelExportTasks;
|
||||||
public static Option<ExportListType> o_exportAssetList;
|
public static Option<ExportListType> o_exportAssetList;
|
||||||
public static Option<string> o_assemblyPath;
|
public static Option<string> o_assemblyPath;
|
||||||
|
public static Option<string> o_stripPathPrefix;
|
||||||
public static Option<bool> f_notRestoreExtensionName;
|
public static Option<bool> f_notRestoreExtensionName;
|
||||||
public static Option<bool> f_avoidLoadingViaTypetree;
|
public static Option<bool> f_avoidLoadingViaTypetree;
|
||||||
public static Option<bool> f_rawByteArrayFromMono;
|
public static Option<bool> f_rawByteArrayFromMono;
|
||||||
@@ -459,7 +461,17 @@ namespace AssetStudioCLI.Options
|
|||||||
optionDefaultValue: false,
|
optionDefaultValue: false,
|
||||||
optionName: "--filter-with-regex",
|
optionName: "--filter-with-regex",
|
||||||
optionDescription: "(Flag) If specified, the filter options will handle the specified text\n" +
|
optionDescription: "(Flag) If specified, the filter options will handle the specified text\n" +
|
||||||
"as a regular expression (doesn't apply to --filter-by-pathid)",
|
"as a regular expression (doesn't apply to --filter-by-pathid)\n",
|
||||||
|
optionExample: "",
|
||||||
|
optionHelpGroup: HelpGroups.Filter,
|
||||||
|
isFlag: true
|
||||||
|
);
|
||||||
|
f_filterExcludeMode = new GroupedOption<bool>
|
||||||
|
(
|
||||||
|
optionDefaultValue: false,
|
||||||
|
optionName: "--filter-exclude-mode",
|
||||||
|
optionDescription: "(Flag) If specified, the filter options will work as an exclusion\n" +
|
||||||
|
"(i.e. assets that match the filter conditions will be excluded)",
|
||||||
optionExample: "",
|
optionExample: "",
|
||||||
optionHelpGroup: HelpGroups.Filter,
|
optionHelpGroup: HelpGroups.Filter,
|
||||||
isFlag: true
|
isFlag: true
|
||||||
@@ -551,6 +563,14 @@ namespace AssetStudioCLI.Options
|
|||||||
optionExample: "",
|
optionExample: "",
|
||||||
optionHelpGroup: HelpGroups.Advanced
|
optionHelpGroup: HelpGroups.Advanced
|
||||||
);
|
);
|
||||||
|
o_stripPathPrefix = new GroupedOption<string>
|
||||||
|
(
|
||||||
|
optionDefaultValue: "",
|
||||||
|
optionName: "--strip-path-prefix <path>",
|
||||||
|
optionDescription: "Specify a path prefix to be stripped from exported asset paths\n",
|
||||||
|
optionExample: "Example: \"--strip-path-prefix assets/models/char/\"\n",
|
||||||
|
optionHelpGroup: HelpGroups.Advanced
|
||||||
|
);
|
||||||
f_notRestoreExtensionName = new GroupedOption<bool>
|
f_notRestoreExtensionName = new GroupedOption<bool>
|
||||||
(
|
(
|
||||||
optionDefaultValue: false,
|
optionDefaultValue: false,
|
||||||
@@ -750,6 +770,10 @@ namespace AssetStudioCLI.Options
|
|||||||
f_filterWithRegex.Value = true;
|
f_filterWithRegex.Value = true;
|
||||||
flagIndexes.Add(i);
|
flagIndexes.Add(i);
|
||||||
break;
|
break;
|
||||||
|
case "--filter-exclude-mode":
|
||||||
|
f_filterExcludeMode.Value = true;
|
||||||
|
flagIndexes.Add(i);
|
||||||
|
break;
|
||||||
case "--decompress-to-disk":
|
case "--decompress-to-disk":
|
||||||
f_decompressToDisk.Value = true;
|
f_decompressToDisk.Value = true;
|
||||||
flagIndexes.Add(i);
|
flagIndexes.Add(i);
|
||||||
@@ -1241,6 +1265,13 @@ namespace AssetStudioCLI.Options
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "--strip-path-prefix":
|
||||||
|
o_stripPathPrefix.Value = Path.Combine(Path.GetDirectoryName(value), Path.GetFileName(value));
|
||||||
|
if (!o_stripPathPrefix.Value.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||||
|
{
|
||||||
|
o_stripPathPrefix.Value += Path.DirectorySeparatorChar;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "--unity-version":
|
case "--unity-version":
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1494,12 +1525,14 @@ namespace AssetStudioCLI.Options
|
|||||||
}
|
}
|
||||||
sb.AppendLine(ShowCurrentFilter());
|
sb.AppendLine(ShowCurrentFilter());
|
||||||
sb.AppendLine($"# Filter With Regex: {f_filterWithRegex}");
|
sb.AppendLine($"# Filter With Regex: {f_filterWithRegex}");
|
||||||
|
sb.AppendLine($"# Filter Exclusion Mode: {f_filterExcludeMode}");
|
||||||
sb.AppendLine($"# Assembly Path: \"{o_assemblyPath}\"");
|
sb.AppendLine($"# Assembly Path: \"{o_assemblyPath}\"");
|
||||||
break;
|
break;
|
||||||
case WorkMode.Live2D:
|
case WorkMode.Live2D:
|
||||||
sb.AppendLine($"# [{o_workMode} Options]");
|
sb.AppendLine($"# [{o_workMode} Options]");
|
||||||
sb.AppendLine($"# Filter by Text: \"{string.Join("\", \"", o_filterByText.Value)}\"");
|
sb.AppendLine($"# Filter by Text: \"{string.Join("\", \"", o_filterByText.Value)}\"");
|
||||||
sb.AppendLine($"# Filter With Regex: {f_filterWithRegex}");
|
sb.AppendLine($"# Filter With Regex: {f_filterWithRegex}");
|
||||||
|
sb.AppendLine($"# Filter Exclusion Mode: {f_filterExcludeMode}");
|
||||||
sb.AppendLine($"# Model Group Option: {o_l2dGroupOption}");
|
sb.AppendLine($"# Model Group Option: {o_l2dGroupOption}");
|
||||||
sb.AppendFormat("# Search Model-related Assets by: {0}\n", f_l2dAssetSearchByFilename.Value ? "FileName" : "Container");
|
sb.AppendFormat("# Search Model-related Assets by: {0}\n", f_l2dAssetSearchByFilename.Value ? "FileName" : "Container");
|
||||||
sb.AppendLine($"# Motion Export Method: {o_l2dMotionMode}");
|
sb.AppendLine($"# Motion Export Method: {o_l2dMotionMode}");
|
||||||
@@ -1513,6 +1546,7 @@ namespace AssetStudioCLI.Options
|
|||||||
? ShowCurrentFilter()
|
? ShowCurrentFilter()
|
||||||
: $"# Filter by Name(s): \"{string.Join("\", \"", o_filterByName.Value)}\"");
|
: $"# Filter by Name(s): \"{string.Join("\", \"", o_filterByName.Value)}\"");
|
||||||
sb.AppendLine($"# Filter With Regex: {f_filterWithRegex}");
|
sb.AppendLine($"# Filter With Regex: {f_filterWithRegex}");
|
||||||
|
sb.AppendLine($"# Filter Exclusion Mode: {f_filterExcludeMode}");
|
||||||
sb.AppendLine($"# Export Image Format: {o_imageFormat}");
|
sb.AppendLine($"# Export Image Format: {o_imageFormat}");
|
||||||
sb.AppendLine($"# FBX Scale Factor: {o_fbxScaleFactor}");
|
sb.AppendLine($"# FBX Scale Factor: {o_fbxScaleFactor}");
|
||||||
sb.AppendLine($"# FBX Bone Size: {o_fbxBoneSize}");
|
sb.AppendLine($"# FBX Bone Size: {o_fbxBoneSize}");
|
||||||
|
|||||||
@@ -152,6 +152,9 @@ Filter Options:
|
|||||||
--filter-with-regex (Flag) If specified, the filter options will handle the specified text
|
--filter-with-regex (Flag) If specified, the filter options will handle the specified text
|
||||||
as a regular expression (doesn't apply to --filter-by-pathid)
|
as a regular expression (doesn't apply to --filter-by-pathid)
|
||||||
|
|
||||||
|
--filter-exclude-mode (Flag) If specified, the filter options will work as an exclusion
|
||||||
|
(i.e. assets that match the filter conditions will be excluded)
|
||||||
|
|
||||||
Advanced Options:
|
Advanced Options:
|
||||||
--blockinfo-comp <value> Specify the compression type of bundle's blockInfo data
|
--blockinfo-comp <value> Specify the compression type of bundle's blockInfo data
|
||||||
<Value: auto(default) | zstd | oodle | lz4 | lzma>
|
<Value: auto(default) | zstd | oodle | lz4 | lzma>
|
||||||
@@ -183,6 +186,9 @@ Advanced Options:
|
|||||||
|
|
||||||
--assembly-folder <path> Specify the path to the assembly folder
|
--assembly-folder <path> Specify the path to the assembly folder
|
||||||
|
|
||||||
|
--strip-path-prefix <path> Specify a path prefix to be stripped from exported asset paths
|
||||||
|
Example: "--strip-path-prefix assets/models/char/"
|
||||||
|
|
||||||
--unity-version <text> Specify Unity version
|
--unity-version <text> Specify Unity version
|
||||||
Example: "--unity-version 2017.4.39f1"
|
Example: "--unity-version 2017.4.39f1"
|
||||||
|
|
||||||
|
|||||||
@@ -627,6 +627,14 @@ namespace AssetStudioCLI
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CLIOptions.f_filterExcludeMode.Value)
|
||||||
|
{
|
||||||
|
var excludeCount = assetsCount - filteredAssets.Count;
|
||||||
|
Logger.Info($"Excluding {excludeCount} asset(s) that match the filter.");
|
||||||
|
filteredAssets = parsedAssetsList.Except(filteredAssets).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
parsedAssetsList.Clear();
|
parsedAssetsList.Clear();
|
||||||
parsedAssetsList = filteredAssets;
|
parsedAssetsList = filteredAssets;
|
||||||
}
|
}
|
||||||
@@ -641,6 +649,31 @@ namespace AssetStudioCLI
|
|||||||
var parallelExportCount = CLIOptions.o_maxParallelExportTasks.Value;
|
var parallelExportCount = CLIOptions.o_maxParallelExportTasks.Value;
|
||||||
var toExportAssetDict = new ConcurrentDictionary<AssetItem, string>();
|
var toExportAssetDict = new ConcurrentDictionary<AssetItem, string>();
|
||||||
var toParallelExportAssetDict = new ConcurrentDictionary<AssetItem, string>();
|
var toParallelExportAssetDict = new ConcurrentDictionary<AssetItem, string>();
|
||||||
|
|
||||||
|
if (CLIOptions.o_stripPathPrefix.Value != null)
|
||||||
|
{
|
||||||
|
foreach (var asset in parsedAssetsList)
|
||||||
|
{
|
||||||
|
var containerPath = asset.Container;
|
||||||
|
if (string.IsNullOrEmpty(containerPath))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!Path.Combine(Path.GetDirectoryName(containerPath), Path.GetFileName(containerPath)).StartsWith(CLIOptions.o_stripPathPrefix.Value))
|
||||||
|
{
|
||||||
|
Logger.Warning($"Asset container path \"{asset.Container}\" does not start with the specified path prefix \"{CLIOptions.o_stripPathPrefix.Value}\"");
|
||||||
|
Logger.Warning("strip path prefix option will be ignored.");
|
||||||
|
CLIOptions.o_stripPathPrefix.Value = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CLIOptions.o_stripPathPrefix.Value != null)
|
||||||
|
{
|
||||||
|
Logger.Info($"Asset container path prefix \"{CLIOptions.o_stripPathPrefix.Value}\" will be stripped off.");
|
||||||
|
}
|
||||||
|
|
||||||
Parallel.ForEach(parsedAssetsList, asset =>
|
Parallel.ForEach(parsedAssetsList, asset =>
|
||||||
{
|
{
|
||||||
string exportPath;
|
string exportPath;
|
||||||
@@ -653,7 +686,12 @@ namespace AssetStudioCLI
|
|||||||
case AssetGroupOption.ContainerPathFull:
|
case AssetGroupOption.ContainerPathFull:
|
||||||
if (!string.IsNullOrEmpty(asset.Container))
|
if (!string.IsNullOrEmpty(asset.Container))
|
||||||
{
|
{
|
||||||
exportPath = Path.Combine(savePath, Path.GetDirectoryName(asset.Container));
|
var containerPath = Path.GetDirectoryName(asset.Container);
|
||||||
|
if (CLIOptions.o_stripPathPrefix.Value != null)
|
||||||
|
{
|
||||||
|
containerPath = containerPath.Substring(CLIOptions.o_stripPathPrefix.Value.Length);
|
||||||
|
}
|
||||||
|
exportPath = Path.Combine(savePath, containerPath);
|
||||||
if (groupOption == AssetGroupOption.ContainerPathFull)
|
if (groupOption == AssetGroupOption.ContainerPathFull)
|
||||||
{
|
{
|
||||||
exportPath = Path.Combine(exportPath, Path.GetFileNameWithoutExtension(asset.Container));
|
exportPath = Path.Combine(exportPath, Path.GetFileNameWithoutExtension(asset.Container));
|
||||||
@@ -722,7 +760,6 @@ namespace AssetStudioCLI
|
|||||||
toExportAssetDict.TryAdd(asset, exportPath);
|
toExportAssetDict.TryAdd(asset, exportPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var toExportAsset in toExportAssetDict)
|
foreach (var toExportAsset in toExportAssetDict)
|
||||||
{
|
{
|
||||||
var asset = toExportAsset.Key;
|
var asset = toExportAsset.Key;
|
||||||
|
|||||||
Reference in New Issue
Block a user