mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-26 13:50:21 -04:00
Add option to export assets with PathID in filename (#25)
https://github.com/Perfare/AssetStudio/issues/1050 https://github.com/Perfare/AssetStudio/issues/975 https://github.com/Perfare/AssetStudio/issues/762
This commit is contained in:
parent
535153be6b
commit
f90c0ecc00
@ -315,18 +315,31 @@ namespace AssetStudioCLI
|
|||||||
private static bool TryExportFile(string dir, AssetItem item, string extension, out string fullPath)
|
private static bool TryExportFile(string dir, AssetItem item, string extension, out string fullPath)
|
||||||
{
|
{
|
||||||
var fileName = FixFileName(item.Text);
|
var fileName = FixFileName(item.Text);
|
||||||
|
var filenameFormat = CLIOptions.o_filenameFormat.Value;
|
||||||
|
switch (filenameFormat)
|
||||||
|
{
|
||||||
|
case FilenameFormat.AssetName_PathID:
|
||||||
|
fileName = $"{fileName} @{item.m_PathID}";
|
||||||
|
break;
|
||||||
|
case FilenameFormat.PathID:
|
||||||
|
fileName = item.m_PathID.ToString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
fullPath = Path.Combine(dir, fileName + extension);
|
fullPath = Path.Combine(dir, fileName + extension);
|
||||||
if (!File.Exists(fullPath))
|
if (!File.Exists(fullPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (filenameFormat == FilenameFormat.AssetName)
|
||||||
|
{
|
||||||
fullPath = Path.Combine(dir, fileName + item.UniqueID + extension);
|
fullPath = Path.Combine(dir, fileName + item.UniqueID + extension);
|
||||||
if (!File.Exists(fullPath))
|
if (!File.Exists(fullPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Logger.Error($"Export error. File \"{fullPath.Color(ColorConsole.BrightRed)}\" already exist");
|
Logger.Error($"Export error. File \"{fullPath.Color(ColorConsole.BrightRed)}\" already exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,13 @@ namespace AssetStudioCLI.Options
|
|||||||
SourceFileName,
|
SourceFileName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal enum FilenameFormat
|
||||||
|
{
|
||||||
|
AssetName,
|
||||||
|
AssetName_PathID,
|
||||||
|
PathID,
|
||||||
|
}
|
||||||
|
|
||||||
internal enum ExportListType
|
internal enum ExportListType
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
@ -75,6 +82,7 @@ namespace AssetStudioCLI.Options
|
|||||||
public static Option<WorkMode> o_workMode;
|
public static Option<WorkMode> o_workMode;
|
||||||
public static Option<List<ClassIDType>> o_exportAssetTypes;
|
public static Option<List<ClassIDType>> o_exportAssetTypes;
|
||||||
public static Option<AssetGroupOption> o_groupAssetsBy;
|
public static Option<AssetGroupOption> o_groupAssetsBy;
|
||||||
|
public static Option<FilenameFormat> o_filenameFormat;
|
||||||
public static Option<string> o_outputFolder;
|
public static Option<string> o_outputFolder;
|
||||||
public static Option<bool> o_displayHelp;
|
public static Option<bool> o_displayHelp;
|
||||||
//logger
|
//logger
|
||||||
@ -200,7 +208,19 @@ namespace AssetStudioCLI.Options
|
|||||||
"Container - Group exported assets by container path\n" +
|
"Container - Group exported assets by container path\n" +
|
||||||
"ContainerFull - Group exported assets by full container path (e.g. with prefab name)\n" +
|
"ContainerFull - Group exported assets by full container path (e.g. with prefab name)\n" +
|
||||||
"Filename - Group exported assets by source file name\n",
|
"Filename - Group exported assets by source file name\n",
|
||||||
optionExample: "Example: \"-g container\"\n",
|
optionExample: "Example: \"-g containerFull\"\n",
|
||||||
|
optionHelpGroup: HelpGroups.General
|
||||||
|
);
|
||||||
|
o_filenameFormat = new GroupedOption<FilenameFormat>
|
||||||
|
(
|
||||||
|
optionDefaultValue: FilenameFormat.AssetName,
|
||||||
|
optionName: "-f, --filename-format <value>",
|
||||||
|
optionDescription: "Specify the file name format for exported assets\n" +
|
||||||
|
"<Value: assetName(default) | assetName_pathID | pathID>\n" +
|
||||||
|
"AssetName - Asset file names will look like \"assetName.extension\"\n" +
|
||||||
|
"AssetName_pathID - Asset file names will look like \"assetName @pathID.extension\"\n" +
|
||||||
|
"PathID - Asset file names will look like \"pathID.extension\"\n",
|
||||||
|
optionExample: "Example: \"-f assetName_pathID\"\n",
|
||||||
optionHelpGroup: HelpGroups.General
|
optionHelpGroup: HelpGroups.General
|
||||||
);
|
);
|
||||||
o_outputFolder = new GroupedOption<string>
|
o_outputFolder = new GroupedOption<string>
|
||||||
@ -629,6 +649,25 @@ namespace AssetStudioCLI.Options
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "-f":
|
||||||
|
case "--filename-format":
|
||||||
|
switch (value.ToLower())
|
||||||
|
{
|
||||||
|
case "assetname":
|
||||||
|
o_filenameFormat.Value = FilenameFormat.AssetName;
|
||||||
|
break;
|
||||||
|
case "assetname_pathid":
|
||||||
|
o_filenameFormat.Value = FilenameFormat.AssetName_PathID;
|
||||||
|
break;
|
||||||
|
case "pathid":
|
||||||
|
o_filenameFormat.Value = FilenameFormat.PathID;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported file name format: [{value.Color(brightRed)}].\n");
|
||||||
|
ShowOptionDescription(o_filenameFormat.Description);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "-o":
|
case "-o":
|
||||||
case "--output":
|
case "--output":
|
||||||
try
|
try
|
||||||
|
28
AssetStudioGUI/ExportOptions.Designer.cs
generated
28
AssetStudioGUI/ExportOptions.Designer.cs
generated
@ -32,6 +32,8 @@
|
|||||||
this.OKbutton = new System.Windows.Forms.Button();
|
this.OKbutton = new System.Windows.Forms.Button();
|
||||||
this.Cancel = new System.Windows.Forms.Button();
|
this.Cancel = new System.Windows.Forms.Button();
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.filenameFormatLabel = new System.Windows.Forms.Label();
|
||||||
|
this.filenameFormatComboBox = new System.Windows.Forms.ComboBox();
|
||||||
this.exportSpriteWithAlphaMask = new System.Windows.Forms.CheckBox();
|
this.exportSpriteWithAlphaMask = new System.Windows.Forms.CheckBox();
|
||||||
this.openAfterExport = new System.Windows.Forms.CheckBox();
|
this.openAfterExport = new System.Windows.Forms.CheckBox();
|
||||||
this.restoreExtensionName = new System.Windows.Forms.CheckBox();
|
this.restoreExtensionName = new System.Windows.Forms.CheckBox();
|
||||||
@ -104,6 +106,8 @@
|
|||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
this.groupBox1.AutoSize = true;
|
this.groupBox1.AutoSize = true;
|
||||||
|
this.groupBox1.Controls.Add(this.filenameFormatLabel);
|
||||||
|
this.groupBox1.Controls.Add(this.filenameFormatComboBox);
|
||||||
this.groupBox1.Controls.Add(this.exportSpriteWithAlphaMask);
|
this.groupBox1.Controls.Add(this.exportSpriteWithAlphaMask);
|
||||||
this.groupBox1.Controls.Add(this.openAfterExport);
|
this.groupBox1.Controls.Add(this.openAfterExport);
|
||||||
this.groupBox1.Controls.Add(this.restoreExtensionName);
|
this.groupBox1.Controls.Add(this.restoreExtensionName);
|
||||||
@ -119,6 +123,28 @@
|
|||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Export";
|
this.groupBox1.Text = "Export";
|
||||||
//
|
//
|
||||||
|
// filenameFormatLabel
|
||||||
|
//
|
||||||
|
this.filenameFormatLabel.AutoSize = true;
|
||||||
|
this.filenameFormatLabel.Location = new System.Drawing.Point(177, 18);
|
||||||
|
this.filenameFormatLabel.Name = "filenameFormatLabel";
|
||||||
|
this.filenameFormatLabel.Size = new System.Drawing.Size(84, 13);
|
||||||
|
this.filenameFormatLabel.TabIndex = 10;
|
||||||
|
this.filenameFormatLabel.Text = "File name format";
|
||||||
|
//
|
||||||
|
// filenameFormatComboBox
|
||||||
|
//
|
||||||
|
this.filenameFormatComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.filenameFormatComboBox.FormattingEnabled = true;
|
||||||
|
this.filenameFormatComboBox.Items.AddRange(new object[] {
|
||||||
|
"assetName",
|
||||||
|
"assetName@pathID",
|
||||||
|
"pathID"});
|
||||||
|
this.filenameFormatComboBox.Location = new System.Drawing.Point(177, 35);
|
||||||
|
this.filenameFormatComboBox.Name = "filenameFormatComboBox";
|
||||||
|
this.filenameFormatComboBox.Size = new System.Drawing.Size(118, 21);
|
||||||
|
this.filenameFormatComboBox.TabIndex = 9;
|
||||||
|
//
|
||||||
// exportSpriteWithAlphaMask
|
// exportSpriteWithAlphaMask
|
||||||
//
|
//
|
||||||
this.exportSpriteWithAlphaMask.AutoSize = true;
|
this.exportSpriteWithAlphaMask.AutoSize = true;
|
||||||
@ -646,5 +672,7 @@
|
|||||||
private System.Windows.Forms.RadioButton l2dAnimationClipRadioButton;
|
private System.Windows.Forms.RadioButton l2dAnimationClipRadioButton;
|
||||||
private System.Windows.Forms.RadioButton l2dMonoBehaviourRadioButton;
|
private System.Windows.Forms.RadioButton l2dMonoBehaviourRadioButton;
|
||||||
private System.Windows.Forms.Panel l2dMotionExportMethodPanel;
|
private System.Windows.Forms.Panel l2dMotionExportMethodPanel;
|
||||||
|
private System.Windows.Forms.ComboBox filenameFormatComboBox;
|
||||||
|
private System.Windows.Forms.Label filenameFormatLabel;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,6 +33,7 @@ namespace AssetStudioGUI
|
|||||||
var defaultMotionMode = Properties.Settings.Default.l2dMotionMode.ToString();
|
var defaultMotionMode = Properties.Settings.Default.l2dMotionMode.ToString();
|
||||||
((RadioButton)l2dMotionExportMethodPanel.Controls.Cast<Control>().First(x => x.AccessibleName == defaultMotionMode)).Checked = true;
|
((RadioButton)l2dMotionExportMethodPanel.Controls.Cast<Control>().First(x => x.AccessibleName == defaultMotionMode)).Checked = true;
|
||||||
l2dForceBezierCheckBox.Checked = Properties.Settings.Default.l2dForceBezier;
|
l2dForceBezierCheckBox.Checked = Properties.Settings.Default.l2dForceBezier;
|
||||||
|
filenameFormatComboBox.SelectedIndex = Properties.Settings.Default.filenameFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OKbutton_Click(object sender, EventArgs e)
|
private void OKbutton_Click(object sender, EventArgs e)
|
||||||
@ -60,6 +61,7 @@ namespace AssetStudioGUI
|
|||||||
var checkedMotionMode = (RadioButton)l2dMotionExportMethodPanel.Controls.Cast<Control>().First(x => ((RadioButton)x).Checked);
|
var checkedMotionMode = (RadioButton)l2dMotionExportMethodPanel.Controls.Cast<Control>().First(x => ((RadioButton)x).Checked);
|
||||||
Properties.Settings.Default.l2dMotionMode = (CubismLive2DExtractor.Live2DMotionMode)Enum.Parse(typeof(CubismLive2DExtractor.Live2DMotionMode), checkedMotionMode.AccessibleName);
|
Properties.Settings.Default.l2dMotionMode = (CubismLive2DExtractor.Live2DMotionMode)Enum.Parse(typeof(CubismLive2DExtractor.Live2DMotionMode), checkedMotionMode.AccessibleName);
|
||||||
Properties.Settings.Default.l2dForceBezier = l2dForceBezierCheckBox.Checked;
|
Properties.Settings.Default.l2dForceBezier = l2dForceBezierCheckBox.Checked;
|
||||||
|
Properties.Settings.Default.filenameFormat = filenameFormatComboBox.SelectedIndex;
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
|
@ -269,18 +269,32 @@ namespace AssetStudioGUI
|
|||||||
private static bool TryExportFile(string dir, AssetItem item, string extension, out string fullPath)
|
private static bool TryExportFile(string dir, AssetItem item, string extension, out string fullPath)
|
||||||
{
|
{
|
||||||
var fileName = FixFileName(item.Text);
|
var fileName = FixFileName(item.Text);
|
||||||
|
var filenameFormatIndex = Properties.Settings.Default.filenameFormat;
|
||||||
|
switch (filenameFormatIndex)
|
||||||
|
{
|
||||||
|
case 1: //assetName@pathID
|
||||||
|
fileName = $"{fileName} @{item.m_PathID}";
|
||||||
|
break;
|
||||||
|
case 2: //pathID
|
||||||
|
fileName = item.m_PathID.ToString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
fullPath = Path.Combine(dir, fileName + extension);
|
fullPath = Path.Combine(dir, fileName + extension);
|
||||||
if (!File.Exists(fullPath))
|
if (!File.Exists(fullPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (filenameFormatIndex == 0) //assetName
|
||||||
|
{
|
||||||
fullPath = Path.Combine(dir, fileName + item.UniqueID + extension);
|
fullPath = Path.Combine(dir, fileName + item.UniqueID + extension);
|
||||||
if (!File.Exists(fullPath))
|
if (!File.Exists(fullPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Logger.Warning($"Export error. File \"{fullPath.Color(ColorConsole.BrightYellow)}\" already exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
AssetStudioGUI/Properties/Settings.Designer.cs
generated
12
AssetStudioGUI/Properties/Settings.Designer.cs
generated
@ -346,5 +346,17 @@ namespace AssetStudioGUI.Properties {
|
|||||||
this["buildTreeStructure"] = value;
|
this["buildTreeStructure"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("0")]
|
||||||
|
public int filenameFormat {
|
||||||
|
get {
|
||||||
|
return ((int)(this["filenameFormat"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["filenameFormat"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,5 +83,8 @@
|
|||||||
<Setting Name="buildTreeStructure" Type="System.Boolean" Scope="User">
|
<Setting Name="buildTreeStructure" Type="System.Boolean" Scope="User">
|
||||||
<Value Profile="(Default)">True</Value>
|
<Value Profile="(Default)">True</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="filenameFormat" Type="System.Int32" Scope="User">
|
||||||
|
<Value Profile="(Default)">0</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
Loading…
Reference in New Issue
Block a user