mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 04:23:09 +00:00
Add channel component option for batch export textures. Fix exporting texture alts from model.
This commit is contained in:
parent
32be289855
commit
ab066f1706
4 changed files with 100 additions and 67 deletions
|
@ -561,21 +561,32 @@ namespace Bfres.Structs
|
|||
|
||||
private List<STGenericTexture> GetTextures()
|
||||
{
|
||||
List<string> textureRefs = new List<string>();
|
||||
foreach (var mat in materials) {
|
||||
foreach (var texref in mat.Value.TextureMaps) {
|
||||
if (!textureRefs.Contains(texref.Name)) {
|
||||
textureRefs.Add(texref.Name);
|
||||
if (texref.Name.EndsWith(".0"))
|
||||
{
|
||||
for (int i = 1; i < 100; i++)
|
||||
textureRefs.Add(texref.Name.Replace(".0", $".{i}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<STGenericTexture> textures = new List<STGenericTexture>();
|
||||
foreach (var mat in materials)
|
||||
foreach (var texref in textureRefs)
|
||||
{
|
||||
foreach (var texref in mat.Value.TextureMaps)
|
||||
foreach (var bntx in PluginRuntime.bntxContainers)
|
||||
{
|
||||
foreach (var bntx in PluginRuntime.bntxContainers)
|
||||
{
|
||||
if (bntx.Textures.ContainsKey(texref.Name))
|
||||
textures.Add(bntx.Textures[texref.Name]);
|
||||
}
|
||||
foreach (var ftexCont in PluginRuntime.ftexContainers)
|
||||
{
|
||||
if (ftexCont.ResourceNodes.ContainsKey(texref.Name))
|
||||
textures.Add((FTEX)ftexCont.ResourceNodes[texref.Name]);
|
||||
}
|
||||
if (bntx.Textures.ContainsKey(texref))
|
||||
textures.Add(bntx.Textures[texref]);
|
||||
}
|
||||
foreach (var ftexCont in PluginRuntime.ftexContainers)
|
||||
{
|
||||
if (ftexCont.ResourceNodes.ContainsKey(texref))
|
||||
textures.Add((FTEX)ftexCont.ResourceNodes[texref]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,13 +28,73 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.comboBox1 = new Toolbox.Library.Forms.STComboBox();
|
||||
this.button1 = new Toolbox.Library.Forms.STButton();
|
||||
this.OkButton = new Toolbox.Library.Forms.STButton();
|
||||
this.chkSeperateTextureContainers = new Toolbox.Library.Forms.STCheckBox();
|
||||
this.chkChannelComponents = new Toolbox.Library.Forms.STCheckBox();
|
||||
this.chkSeperateArchives = new Toolbox.Library.Forms.STCheckBox();
|
||||
this.chkSeperateTextureContainers = new Toolbox.Library.Forms.STCheckBox();
|
||||
this.OkButton = new Toolbox.Library.Forms.STButton();
|
||||
this.button1 = new Toolbox.Library.Forms.STButton();
|
||||
this.comboBox1 = new Toolbox.Library.Forms.STComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// chkChannelComponents
|
||||
//
|
||||
this.chkChannelComponents.AutoSize = true;
|
||||
this.chkChannelComponents.Checked = true;
|
||||
this.chkChannelComponents.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkChannelComponents.Location = new System.Drawing.Point(12, 85);
|
||||
this.chkChannelComponents.Name = "chkChannelComponents";
|
||||
this.chkChannelComponents.Size = new System.Drawing.Size(161, 17);
|
||||
this.chkChannelComponents.TabIndex = 5;
|
||||
this.chkChannelComponents.Text = "Use Texture Channel Swaps";
|
||||
this.chkChannelComponents.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// chkSeperateArchives
|
||||
//
|
||||
this.chkSeperateArchives.AutoSize = true;
|
||||
this.chkSeperateArchives.Checked = true;
|
||||
this.chkSeperateArchives.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkSeperateArchives.Location = new System.Drawing.Point(12, 62);
|
||||
this.chkSeperateArchives.Name = "chkSeperateArchives";
|
||||
this.chkSeperateArchives.Size = new System.Drawing.Size(160, 17);
|
||||
this.chkSeperateArchives.TabIndex = 4;
|
||||
this.chkSeperateArchives.Text = "Use Folders for Archive Files";
|
||||
this.chkSeperateArchives.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// chkSeperateTextureContainers
|
||||
//
|
||||
this.chkSeperateTextureContainers.AutoSize = true;
|
||||
this.chkSeperateTextureContainers.Checked = true;
|
||||
this.chkSeperateTextureContainers.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkSeperateTextureContainers.Location = new System.Drawing.Point(12, 39);
|
||||
this.chkSeperateTextureContainers.Name = "chkSeperateTextureContainers";
|
||||
this.chkSeperateTextureContainers.Size = new System.Drawing.Size(219, 17);
|
||||
this.chkSeperateTextureContainers.TabIndex = 3;
|
||||
this.chkSeperateTextureContainers.Text = "Use Folders for Models/Texture Archives";
|
||||
this.chkSeperateTextureContainers.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// OkButton
|
||||
//
|
||||
this.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.OkButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.OkButton.Location = new System.Drawing.Point(82, 121);
|
||||
this.OkButton.Name = "OkButton";
|
||||
this.OkButton.Size = new System.Drawing.Size(63, 23);
|
||||
this.OkButton.TabIndex = 2;
|
||||
this.OkButton.Text = "Ok";
|
||||
this.OkButton.UseVisualStyleBackColor = true;
|
||||
this.OkButton.Click += new System.EventHandler(this.OkButton_Click);
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.button1.Location = new System.Drawing.Point(167, 121);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(63, 23);
|
||||
this.button1.TabIndex = 1;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// comboBox1
|
||||
//
|
||||
this.comboBox1.BorderColor = System.Drawing.Color.Empty;
|
||||
|
@ -48,58 +108,12 @@
|
|||
this.comboBox1.TabIndex = 0;
|
||||
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.button1.Location = new System.Drawing.Point(171, 96);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(63, 23);
|
||||
this.button1.TabIndex = 1;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// OkButton
|
||||
//
|
||||
this.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.OkButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.OkButton.Location = new System.Drawing.Point(86, 96);
|
||||
this.OkButton.Name = "OkButton";
|
||||
this.OkButton.Size = new System.Drawing.Size(63, 23);
|
||||
this.OkButton.TabIndex = 2;
|
||||
this.OkButton.Text = "Ok";
|
||||
this.OkButton.UseVisualStyleBackColor = true;
|
||||
this.OkButton.Click += new System.EventHandler(this.OkButton_Click);
|
||||
//
|
||||
// chkSeperateTextureContainers
|
||||
//
|
||||
this.chkSeperateTextureContainers.AutoSize = true;
|
||||
this.chkSeperateTextureContainers.Checked = true;
|
||||
this.chkSeperateTextureContainers.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkSeperateTextureContainers.Location = new System.Drawing.Point(12, 39);
|
||||
this.chkSeperateTextureContainers.Name = "chkSeperateTextureContainers";
|
||||
this.chkSeperateTextureContainers.Size = new System.Drawing.Size(219, 17);
|
||||
this.chkSeperateTextureContainers.TabIndex = 3;
|
||||
this.chkSeperateTextureContainers.Text = "Use Folders for Models/Texture Archives";
|
||||
this.chkSeperateTextureContainers.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// chkSeperateArchives
|
||||
//
|
||||
this.chkSeperateArchives.AutoSize = true;
|
||||
this.chkSeperateArchives.Checked = true;
|
||||
this.chkSeperateArchives.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkSeperateArchives.Location = new System.Drawing.Point(12, 62);
|
||||
this.chkSeperateArchives.Name = "chkSeperateArchives";
|
||||
this.chkSeperateArchives.Size = new System.Drawing.Size(160, 17);
|
||||
this.chkSeperateArchives.TabIndex = 4;
|
||||
this.chkSeperateArchives.Text = "Use Folders for Archive Files";
|
||||
this.chkSeperateArchives.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// BatchFormatExport
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(246, 131);
|
||||
this.ClientSize = new System.Drawing.Size(246, 156);
|
||||
this.Controls.Add(this.chkChannelComponents);
|
||||
this.Controls.Add(this.chkSeperateArchives);
|
||||
this.Controls.Add(this.chkSeperateTextureContainers);
|
||||
this.Controls.Add(this.OkButton);
|
||||
|
@ -119,5 +133,6 @@
|
|||
private Toolbox.Library.Forms.STButton OkButton;
|
||||
private Forms.STCheckBox chkSeperateTextureContainers;
|
||||
private Forms.STCheckBox chkSeperateArchives;
|
||||
private Forms.STCheckBox chkChannelComponents;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ namespace Toolbox.Library
|
|||
{
|
||||
public bool SeperateTextureContainers;
|
||||
public bool SeperateArchiveFiles;
|
||||
public bool UseTextureChannelComponents;
|
||||
}
|
||||
|
||||
public BatchFormatExport(List<string> Formats)
|
||||
|
@ -61,6 +62,7 @@ namespace Toolbox.Library
|
|||
{
|
||||
BatchSettings.SeperateTextureContainers = chkSeperateTextureContainers.Checked;
|
||||
BatchSettings.SeperateArchiveFiles = chkSeperateArchives.Checked;
|
||||
BatchSettings.UseTextureChannelComponents = chkChannelComponents.Checked;
|
||||
|
||||
this.Close();
|
||||
}
|
||||
|
|
|
@ -1475,7 +1475,7 @@ namespace Toolbox
|
|||
|
||||
if (fileFormat is STGenericTexture && exportMode == ExportMode.Textures) {
|
||||
string name = ((STGenericTexture)fileFormat).Text;
|
||||
ExportTexture(((STGenericTexture)fileFormat), $"{outputFolder}/{name}", extension);
|
||||
ExportTexture(((STGenericTexture)fileFormat), settings, $"{outputFolder}/{name}", extension);
|
||||
}
|
||||
else if (fileFormat is IArchiveFile)
|
||||
SearchArchive(settings, (IArchiveFile)fileFormat, extension, outputFolder, exportMode);
|
||||
|
@ -1492,7 +1492,7 @@ namespace Toolbox
|
|||
}
|
||||
|
||||
foreach (STGenericTexture tex in ((ITextureContainer)fileFormat).TextureList) {
|
||||
ExportTexture(tex, $"{outputFolder}/{tex.Text}", extension);
|
||||
ExportTexture(tex, settings, $"{outputFolder}/{tex.Text}", extension);
|
||||
}
|
||||
}
|
||||
else if (fileFormat is IExportableModel && exportMode == ExportMode.Models)
|
||||
|
@ -1529,11 +1529,16 @@ namespace Toolbox
|
|||
Textures,
|
||||
}
|
||||
|
||||
private void ExportTexture(STGenericTexture tex, string filePath, string ext) {
|
||||
private void ExportTexture(STGenericTexture tex, BatchFormatExport.Settings settings, string filePath, string ext) {
|
||||
filePath = Utils.RenameDuplicateString(batchExportFileList, filePath, 0, 3);
|
||||
batchExportFileList.Add(filePath);
|
||||
|
||||
//Switch the runtime comp setting to the batch settings then switch back later
|
||||
bool compSetting = Runtime.ImageEditor.UseComponetSelector;
|
||||
|
||||
Runtime.ImageEditor.UseComponetSelector = settings.UseTextureChannelComponents;
|
||||
tex.Export($"{filePath}.{ext}");
|
||||
Runtime.ImageEditor.UseComponetSelector = compSetting;
|
||||
}
|
||||
|
||||
private void SearchArchive(BatchFormatExport.Settings settings, IArchiveFile archiveFile,
|
||||
|
|
Loading…
Reference in a new issue