From 2bcd9662be015a870c89233f7c68a9c5bcbb9301 Mon Sep 17 00:00:00 2001 From: Perfare Date: Thu, 26 Mar 2020 01:01:02 +0800 Subject: [PATCH] improve export --- AssetStudioGUI/AssetStudioGUIForm.Designer.cs | 38 +----- AssetStudioGUI/AssetStudioGUIForm.cs | 22 ++-- AssetStudioGUI/ExportOptions.Designer.cs | 81 +++++++++++-- AssetStudioGUI/ExportOptions.cs | 6 + AssetStudioGUI/Exporter.cs | 45 ++++++- .../Properties/Settings.Designer.cs | 12 ++ AssetStudioGUI/Properties/Settings.settings | 3 + AssetStudioGUI/Studio.cs | 110 +++++------------- AssetStudioGUI/app.config | 3 + 9 files changed, 175 insertions(+), 145 deletions(-) diff --git a/AssetStudioGUI/AssetStudioGUIForm.Designer.cs b/AssetStudioGUI/AssetStudioGUIForm.Designer.cs index 2aed026..7dd5083 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.Designer.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.Designer.cs @@ -41,8 +41,6 @@ this.displayAll = new System.Windows.Forms.ToolStripMenuItem(); this.enablePreview = new System.Windows.Forms.ToolStripMenuItem(); this.displayInfo = new System.Windows.Forms.ToolStripMenuItem(); - this.openAfterExport = new System.Windows.Forms.ToolStripMenuItem(); - this.assetGroupOptions = new System.Windows.Forms.ToolStripComboBox(); this.showExpOpt = new System.Windows.Forms.ToolStripMenuItem(); this.modelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportAllObjectssplitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); @@ -206,8 +204,6 @@ this.displayAll, this.enablePreview, this.displayInfo, - this.openAfterExport, - this.assetGroupOptions, this.showExpOpt}); this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.optionsToolStripMenuItem.Size = new System.Drawing.Size(66, 21); @@ -217,11 +213,11 @@ // this.displayAll.CheckOnClick = true; this.displayAll.Name = "displayAll"; - this.displayAll.Size = new System.Drawing.Size(252, 22); + this.displayAll.Size = new System.Drawing.Size(223, 22); this.displayAll.Text = "Display all assets"; this.displayAll.ToolTipText = "Check this option will display all types assets. Not extractable assets can expor" + "t the RAW file."; - this.displayAll.CheckedChanged += new System.EventHandler(this.MenuItem_CheckedChanged); + this.displayAll.CheckedChanged += new System.EventHandler(this.displayAll_CheckedChanged); // // enablePreview // @@ -229,7 +225,7 @@ this.enablePreview.CheckOnClick = true; this.enablePreview.CheckState = System.Windows.Forms.CheckState.Checked; this.enablePreview.Name = "enablePreview"; - this.enablePreview.Size = new System.Drawing.Size(252, 22); + this.enablePreview.Size = new System.Drawing.Size(223, 22); this.enablePreview.Text = "Enable preview"; this.enablePreview.ToolTipText = "Toggle the loading and preview of readable assets, such as images, sounds, text, " + "etc.\r\nDisable preview if you have performance or compatibility issues."; @@ -241,38 +237,16 @@ this.displayInfo.CheckOnClick = true; this.displayInfo.CheckState = System.Windows.Forms.CheckState.Checked; this.displayInfo.Name = "displayInfo"; - this.displayInfo.Size = new System.Drawing.Size(252, 22); + this.displayInfo.Size = new System.Drawing.Size(223, 22); this.displayInfo.Text = "Display asset infromation"; this.displayInfo.ToolTipText = "Toggle the overlay that shows information about each asset, eg. image size, forma" + "t, audio bitrate, etc."; this.displayInfo.CheckedChanged += new System.EventHandler(this.displayAssetInfo_Check); // - // openAfterExport - // - this.openAfterExport.Checked = true; - this.openAfterExport.CheckOnClick = true; - this.openAfterExport.CheckState = System.Windows.Forms.CheckState.Checked; - this.openAfterExport.Name = "openAfterExport"; - this.openAfterExport.Size = new System.Drawing.Size(252, 22); - this.openAfterExport.Text = "Open file/folder after export"; - this.openAfterExport.CheckedChanged += new System.EventHandler(this.MenuItem_CheckedChanged); - // - // assetGroupOptions - // - this.assetGroupOptions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.assetGroupOptions.FlatStyle = System.Windows.Forms.FlatStyle.Standard; - this.assetGroupOptions.Items.AddRange(new object[] { - "Group by type", - "Group by source file", - "Do not group"}); - this.assetGroupOptions.Name = "assetGroupOptions"; - this.assetGroupOptions.Size = new System.Drawing.Size(192, 25); - this.assetGroupOptions.SelectedIndexChanged += new System.EventHandler(this.assetGroupOptions_SelectedIndexChanged); - // // showExpOpt // this.showExpOpt.Name = "showExpOpt"; - this.showExpOpt.Size = new System.Drawing.Size(252, 22); + this.showExpOpt.Size = new System.Drawing.Size(223, 22); this.showExpOpt.Text = "Export options"; this.showExpOpt.Click += new System.EventHandler(this.showExpOpt_Click); // @@ -1102,8 +1076,6 @@ private System.Windows.Forms.ToolStripMenuItem extractFolderToolStripMenuItem; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.ToolStripComboBox assetGroupOptions; - private System.Windows.Forms.ToolStripMenuItem openAfterExport; private System.Windows.Forms.ToolStripMenuItem showExpOpt; private GOHierarchy sceneTreeView; private System.Windows.Forms.ToolStripMenuItem debugMenuItem; diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs index 01e91b3..603cebd 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.cs @@ -307,7 +307,7 @@ namespace AssetStudioGUI if (dirty) { PreviewAsset(lastLoadedAsset); - if (assetInfoLabel.Text != null) + if (lastSelectedItem != null && assetInfoLabel.Text != null) { assetInfoLabel.Text = lastSelectedItem.InfoText; } @@ -356,6 +356,12 @@ namespace AssetStudioGUI } } + private void displayAll_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.displayAll = displayAll.Checked; + Properties.Settings.Default.Save(); + } + private void enablePreview_Check(object sender, EventArgs e) { if (lastLoadedAsset != null) @@ -433,18 +439,6 @@ namespace AssetStudioGUI Properties.Settings.Default.Save(); } - private void MenuItem_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default[((ToolStripMenuItem)sender).Name] = ((ToolStripMenuItem)sender).Checked; - Properties.Settings.Default.Save(); - } - - private void assetGroupOptions_SelectedIndexChanged(object sender, EventArgs e) - { - Properties.Settings.Default.assetGroupOption = ((ToolStripComboBox)sender).SelectedIndex; - Properties.Settings.Default.Save(); - } - private void showExpOpt_Click(object sender, EventArgs e) { ExportOptions exportOpt = new ExportOptions(); @@ -1480,8 +1474,6 @@ namespace AssetStudioGUI displayAll.Checked = Properties.Settings.Default.displayAll; displayInfo.Checked = Properties.Settings.Default.displayInfo; enablePreview.Checked = Properties.Settings.Default.enablePreview; - openAfterExport.Checked = Properties.Settings.Default.openAfterExport; - assetGroupOptions.SelectedIndex = Properties.Settings.Default.assetGroupOption; FMODinit(); Logger.Default = new GUILogger(StatusStripUpdate); diff --git a/AssetStudioGUI/ExportOptions.Designer.cs b/AssetStudioGUI/ExportOptions.Designer.cs index 975c205..b8e9198 100644 --- a/AssetStudioGUI/ExportOptions.Designer.cs +++ b/AssetStudioGUI/ExportOptions.Designer.cs @@ -31,6 +31,10 @@ this.OKbutton = new System.Windows.Forms.Button(); this.Cancel = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.openAfterExport = new System.Windows.Forms.CheckBox(); + this.restoreExtensionName = new System.Windows.Forms.CheckBox(); + this.assetGroupOptions = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); this.convertAudio = new System.Windows.Forms.CheckBox(); this.panel1 = new System.Windows.Forms.Panel(); this.totga = new System.Windows.Forms.RadioButton(); @@ -65,7 +69,7 @@ // // OKbutton // - this.OKbutton.Location = new System.Drawing.Point(321, 293); + this.OKbutton.Location = new System.Drawing.Point(308, 320); this.OKbutton.Name = "OKbutton"; this.OKbutton.Size = new System.Drawing.Size(75, 21); this.OKbutton.TabIndex = 6; @@ -76,7 +80,7 @@ // Cancel // this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.Cancel.Location = new System.Drawing.Point(402, 293); + this.Cancel.Location = new System.Drawing.Point(389, 320); this.Cancel.Name = "Cancel"; this.Cancel.Size = new System.Drawing.Size(75, 21); this.Cancel.TabIndex = 7; @@ -87,22 +91,73 @@ // groupBox1 // this.groupBox1.AutoSize = true; + this.groupBox1.Controls.Add(this.openAfterExport); + this.groupBox1.Controls.Add(this.restoreExtensionName); + this.groupBox1.Controls.Add(this.assetGroupOptions); + this.groupBox1.Controls.Add(this.label6); this.groupBox1.Controls.Add(this.convertAudio); this.groupBox1.Controls.Add(this.panel1); this.groupBox1.Controls.Add(this.converttexture); - this.groupBox1.Location = new System.Drawing.Point(232, 12); + this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(245, 114); + this.groupBox1.Size = new System.Drawing.Size(232, 302); this.groupBox1.TabIndex = 9; this.groupBox1.TabStop = false; - this.groupBox1.Text = "Convert"; + this.groupBox1.Text = "Export"; + // + // openAfterExport + // + this.openAfterExport.AutoSize = true; + this.openAfterExport.Checked = true; + this.openAfterExport.CheckState = System.Windows.Forms.CheckState.Checked; + this.openAfterExport.Location = new System.Drawing.Point(6, 160); + this.openAfterExport.Name = "openAfterExport"; + this.openAfterExport.Size = new System.Drawing.Size(168, 16); + this.openAfterExport.TabIndex = 10; + this.openAfterExport.Text = "Open folder after export"; + this.openAfterExport.UseVisualStyleBackColor = true; + // + // restoreExtensionName + // + this.restoreExtensionName.AutoSize = true; + this.restoreExtensionName.Checked = true; + this.restoreExtensionName.CheckState = System.Windows.Forms.CheckState.Checked; + this.restoreExtensionName.Location = new System.Drawing.Point(6, 58); + this.restoreExtensionName.Name = "restoreExtensionName"; + this.restoreExtensionName.Size = new System.Drawing.Size(216, 16); + this.restoreExtensionName.TabIndex = 9; + this.restoreExtensionName.Text = "Restore TextAsset extension name"; + this.restoreExtensionName.UseVisualStyleBackColor = true; + // + // assetGroupOptions + // + this.assetGroupOptions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.assetGroupOptions.FormattingEnabled = true; + this.assetGroupOptions.Items.AddRange(new object[] { + "type name", + "container path", + "source file name", + "do not group"}); + this.assetGroupOptions.Location = new System.Drawing.Point(6, 32); + this.assetGroupOptions.Name = "assetGroupOptions"; + this.assetGroupOptions.Size = new System.Drawing.Size(149, 20); + this.assetGroupOptions.TabIndex = 8; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 17); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(149, 12); + this.label6.TabIndex = 7; + this.label6.Text = "Group exported assets by"; // // convertAudio // this.convertAudio.AutoSize = true; this.convertAudio.Checked = true; this.convertAudio.CheckState = System.Windows.Forms.CheckState.Checked; - this.convertAudio.Location = new System.Drawing.Point(6, 78); + this.convertAudio.Location = new System.Drawing.Point(6, 138); this.convertAudio.Name = "convertAudio"; this.convertAudio.Size = new System.Drawing.Size(198, 16); this.convertAudio.TabIndex = 6; @@ -115,9 +170,9 @@ this.panel1.Controls.Add(this.tojpg); this.panel1.Controls.Add(this.topng); this.panel1.Controls.Add(this.tobmp); - this.panel1.Location = new System.Drawing.Point(30, 42); + this.panel1.Location = new System.Drawing.Point(20, 102); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(207, 30); + this.panel1.Size = new System.Drawing.Size(202, 30); this.panel1.TabIndex = 5; // // totga @@ -167,7 +222,7 @@ this.converttexture.AutoSize = true; this.converttexture.Checked = true; this.converttexture.CheckState = System.Windows.Forms.CheckState.Checked; - this.converttexture.Location = new System.Drawing.Point(6, 20); + this.converttexture.Location = new System.Drawing.Point(6, 80); this.converttexture.Name = "converttexture"; this.converttexture.Size = new System.Drawing.Size(126, 16); this.converttexture.TabIndex = 1; @@ -193,7 +248,7 @@ this.groupBox2.Controls.Add(this.castToBone); this.groupBox2.Controls.Add(this.exportAllNodes); this.groupBox2.Controls.Add(this.eulerFilter); - this.groupBox2.Location = new System.Drawing.Point(12, 12); + this.groupBox2.Location = new System.Drawing.Point(250, 12); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(214, 302); this.groupBox2.TabIndex = 11; @@ -398,7 +453,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.Cancel; - this.ClientSize = new System.Drawing.Size(490, 328); + this.ClientSize = new System.Drawing.Size(477, 351); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.Cancel); @@ -453,5 +508,9 @@ private System.Windows.Forms.Label label5; private System.Windows.Forms.CheckBox exportBlendShape; private System.Windows.Forms.CheckBox exportAnimations; + private System.Windows.Forms.ComboBox assetGroupOptions; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.CheckBox restoreExtensionName; + private System.Windows.Forms.CheckBox openAfterExport; } } \ No newline at end of file diff --git a/AssetStudioGUI/ExportOptions.cs b/AssetStudioGUI/ExportOptions.cs index bb5640b..b00744a 100644 --- a/AssetStudioGUI/ExportOptions.cs +++ b/AssetStudioGUI/ExportOptions.cs @@ -15,6 +15,8 @@ namespace AssetStudioGUI public ExportOptions() { InitializeComponent(); + assetGroupOptions.SelectedIndex = Properties.Settings.Default.assetGroupOption; + restoreExtensionName.Checked = Properties.Settings.Default.restoreExtensionName; converttexture.Checked = Properties.Settings.Default.convertTexture; convertAudio.Checked = Properties.Settings.Default.convertAudio; var str = Properties.Settings.Default.convertType; @@ -26,6 +28,7 @@ namespace AssetStudioGUI break; } } + openAfterExport.Checked = Properties.Settings.Default.openAfterExport; eulerFilter.Checked = Properties.Settings.Default.eulerFilter; filterPrecision.Value = Properties.Settings.Default.filterPrecision; exportAllNodes.Checked = Properties.Settings.Default.exportAllNodes; @@ -41,6 +44,8 @@ namespace AssetStudioGUI private void OKbutton_Click(object sender, EventArgs e) { + Properties.Settings.Default.assetGroupOption = assetGroupOptions.SelectedIndex; + Properties.Settings.Default.restoreExtensionName = restoreExtensionName.Checked; Properties.Settings.Default.convertTexture = converttexture.Checked; Properties.Settings.Default.convertAudio = convertAudio.Checked; foreach (Control c in panel1.Controls) @@ -51,6 +56,7 @@ namespace AssetStudioGUI break; } } + Properties.Settings.Default.openAfterExport = openAfterExport.Checked; Properties.Settings.Default.eulerFilter = eulerFilter.Checked; Properties.Settings.Default.filterPrecision = filterPrecision.Value; Properties.Settings.Default.exportAllNodes = exportAllNodes.Checked; diff --git a/AssetStudioGUI/Exporter.cs b/AssetStudioGUI/Exporter.cs index 970e69e..8a9df4a 100644 --- a/AssetStudioGUI/Exporter.cs +++ b/AssetStudioGUI/Exporter.cs @@ -112,7 +112,15 @@ namespace AssetStudioGUI public static bool ExportTextAsset(AssetItem item, string exportPath) { var m_TextAsset = (TextAsset)(item.Asset); - var exportFullName = exportPath + item.Text + ".txt"; + var extension = ".txt"; + if (Properties.Settings.Default.restoreExtensionName) + { + if (!string.IsNullOrEmpty(item.Container)) + { + extension = Path.GetExtension(item.Container); + } + } + var exportFullName = exportPath + item.Text + extension; if (ExportFileExists(exportFullName)) return false; File.WriteAllBytes(exportFullName, m_TextAsset.m_Script); @@ -284,7 +292,7 @@ namespace AssetStudioGUI { if (tga) { - TGASharpLib.TGA file = new TGASharpLib.TGA(bitmap); + var file = new TGA(bitmap); file.Save(exportFullName); } else @@ -367,5 +375,38 @@ namespace AssetStudioGUI } return false; } + + public static bool ExportConvertFile(AssetItem item, string exportPath) + { + switch (item.Type) + { + case ClassIDType.Texture2D: + return ExportTexture2D(item, exportPath); + case ClassIDType.AudioClip: + return ExportAudioClip(item, exportPath); + case ClassIDType.Shader: + return ExportShader(item, exportPath); + case ClassIDType.TextAsset: + return ExportTextAsset(item, exportPath); + case ClassIDType.MonoBehaviour: + return ExportMonoBehaviour(item, exportPath); + case ClassIDType.Font: + return ExportFont(item, exportPath); + case ClassIDType.Mesh: + return ExportMesh(item, exportPath); + case ClassIDType.VideoClip: + return ExportVideoClip(item, exportPath); + case ClassIDType.MovieTexture: + return ExportMovieTexture(item, exportPath); + case ClassIDType.Sprite: + return ExportSprite(item, exportPath); + case ClassIDType.Animator: + return ExportAnimator(item, exportPath); + case ClassIDType.AnimationClip: + return false; + default: + return ExportRawFile(item, exportPath); + } + } } } diff --git a/AssetStudioGUI/Properties/Settings.Designer.cs b/AssetStudioGUI/Properties/Settings.Designer.cs index 6d9a39f..4074970 100644 --- a/AssetStudioGUI/Properties/Settings.Designer.cs +++ b/AssetStudioGUI/Properties/Settings.Designer.cs @@ -250,5 +250,17 @@ namespace AssetStudioGUI.Properties { this["castToBone"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool restoreExtensionName { + get { + return ((bool)(this["restoreExtensionName"])); + } + set { + this["restoreExtensionName"] = value; + } + } } } diff --git a/AssetStudioGUI/Properties/Settings.settings b/AssetStudioGUI/Properties/Settings.settings index 291bee2..3700b01 100644 --- a/AssetStudioGUI/Properties/Settings.settings +++ b/AssetStudioGUI/Properties/Settings.settings @@ -59,5 +59,8 @@ False + + True + \ No newline at end of file diff --git a/AssetStudioGUI/Studio.cs b/AssetStudioGUI/Studio.cs index e060720..1d09059 100644 --- a/AssetStudioGUI/Studio.cs +++ b/AssetStudioGUI/Studio.cs @@ -349,109 +349,51 @@ namespace AssetStudioGUI Progress.Reset(); foreach (var asset in toExportAssets) { - var exportpath = savePath + "\\"; - if (Properties.Settings.Default.assetGroupOption == 1) + string exportPath; + switch (Properties.Settings.Default.assetGroupOption) { - exportpath += Path.GetFileNameWithoutExtension(asset.SourceFile.fullName) + "_export\\"; - } - else if (Properties.Settings.Default.assetGroupOption == 0) - { - exportpath = savePath + "\\" + asset.TypeString + "\\"; + case 0: //type name + exportPath = Path.Combine(savePath, asset.TypeString); + break; + case 1: //container path + if (!string.IsNullOrEmpty(asset.Container)) + { + exportPath = Path.Combine(savePath, Path.GetDirectoryName(asset.Container)); + } + else + { + exportPath = savePath; + } + break; + case 2: //source file + exportPath = Path.Combine(savePath, asset.SourceFile.fullName + "_export"); + break; + default: + exportPath = savePath; + break; } + exportPath += Path.DirectorySeparatorChar; StatusStripUpdate($"Exporting {asset.TypeString}: {asset.Text}"); try { switch (exportType) { case ExportType.Raw: - if (ExportRawFile(asset, exportpath)) + if (ExportRawFile(asset, exportPath)) { exportedCount++; } break; case ExportType.Dump: - if (ExportDumpFile(asset, exportpath)) + if (ExportDumpFile(asset, exportPath)) { exportedCount++; } break; case ExportType.Convert: - switch (asset.Type) + if (ExportConvertFile(asset, exportPath)) { - case ClassIDType.Texture2D: - if (ExportTexture2D(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.AudioClip: - if (ExportAudioClip(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.Shader: - if (ExportShader(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.TextAsset: - if (ExportTextAsset(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.MonoBehaviour: - if (ExportMonoBehaviour(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.Font: - if (ExportFont(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.Mesh: - if (ExportMesh(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.VideoClip: - if (ExportVideoClip(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.MovieTexture: - if (ExportMovieTexture(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.Sprite: - if (ExportSprite(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.Animator: - if (ExportAnimator(asset, exportpath)) - { - exportedCount++; - } - break; - case ClassIDType.AnimationClip: - break; - default: - if (ExportRawFile(asset, exportpath)) - { - exportedCount++; - } - break; + exportedCount++; } break; } diff --git a/AssetStudioGUI/app.config b/AssetStudioGUI/app.config index 4cbad19..82a8c4c 100644 --- a/AssetStudioGUI/app.config +++ b/AssetStudioGUI/app.config @@ -64,6 +64,9 @@ False + + True + \ No newline at end of file