1
0
mirror of synced 2024-11-27 17:00:50 +01:00
This commit is contained in:
KillzXGaming 2023-10-18 19:47:28 -04:00
commit 7e5b80e575
9 changed files with 532 additions and 227 deletions

View File

@ -160,17 +160,17 @@ namespace Bfres.Structs
}
}
public override void ReplaceAll()
public override void ReplaceAll(string ReplacePath = "")
{
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
if (ReplacePath != "" || sfd.ShowDialog() == DialogResult.OK)
{
if (Type == BRESGroupType.Textures)
{
GTXTextureImporter importer = new GTXTextureImporter();
List<GTXImporterSettings> settings = new List<GTXImporterSettings>();
foreach (string file in System.IO.Directory.GetFiles(sfd.SelectedPath))
foreach (string file in System.IO.Directory.GetFiles(ReplacePath != "" ? ReplacePath : sfd.SelectedPath))
{
string FileName = System.IO.Path.GetFileNameWithoutExtension(file);
@ -260,7 +260,7 @@ namespace Bfres.Structs
}
else
{
foreach (string file in System.IO.Directory.GetFiles(sfd.SelectedPath))
foreach (string file in System.IO.Directory.GetFiles(ReplacePath != "" ? ReplacePath : sfd.SelectedPath))
{
string FileName = System.IO.Path.GetFileNameWithoutExtension(file);

View File

@ -100,7 +100,7 @@ namespace Toolbox.Library.NodeWrappers
ReplaceAll();
}
public virtual void ReplaceAll()
public virtual void ReplaceAll(string ReplacePath = "")
{
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)

View File

@ -845,7 +845,7 @@ namespace Toolbox.Library
{
if (IsAtscFormat(Format))
{
return "Supported Formats|*.astc; *.png;*.tga;*.jpg;*.tiff|" +
return "Supported Formats|*.dds; *.astc; *.png;*.tga;*.jpg;*.tiff|" +
"ASTC |*.astc|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +

View File

@ -23,6 +23,7 @@ namespace Toolbox.Library
public static bool UseDirectXTexDecoder = true;
public static bool DEVELOPER_DEBUG_MODE = false;
public static bool AlwaysCompressOnSave = false;
public static bool AlwaysSaveAll = true;
public static class ResourceTables
{

File diff suppressed because it is too large Load Diff

View File

@ -88,6 +88,7 @@ namespace Toolbox
chkBotwFileTable.Checked = Runtime.ResourceTables.BotwTable;
chkTpFileTable.Checked = Runtime.ResourceTables.TpTable;
chkFrameCamera.Checked = Runtime.FrameCamera;
chkAlwaysSaveAll.Checked = Runtime.AlwaysSaveAll;
chkAlwaysCompressOnSave.Checked = Runtime.AlwaysCompressOnSave;
chkViewportGrid.Checked = Runtime.displayGrid;
chkViewportAxisLines.Checked = Runtime.displayAxisLines;
@ -664,6 +665,11 @@ namespace Toolbox
Runtime.FrameCamera = chkFrameCamera.Checked;
}
private void chkAlwaysSaveAll_CheckedChanged(object sender, EventArgs e)
{
Runtime.AlwaysSaveAll = chkAlwaysSaveAll.Checked;
}
private void chkAlwaysCompressOnSave_CheckedChanged(object sender, EventArgs e) {
Runtime.AlwaysCompressOnSave = chkAlwaysCompressOnSave.Checked;
}

View File

@ -47,6 +47,9 @@
this.hashCalculatorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.batchExportTexturesAllSupportedFormatsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.batchExportModelsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.batchReplaceFTPToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.batchRenameBNTXToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.batchReplaceTXTGToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.experimentalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.windowsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cascadeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -192,7 +195,10 @@
this.batchToolStripMenuItem,
this.hashCalculatorToolStripMenuItem,
this.batchExportTexturesAllSupportedFormatsToolStripMenuItem,
this.batchExportModelsToolStripMenuItem});
this.batchExportModelsToolStripMenuItem,
this.batchReplaceFTPToolStripMenuItem,
this.batchReplaceTXTGToolStripMenuItem,
this.batchRenameBNTXToolStripMenuItem,});
this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";
this.toolsToolStripMenuItem.Size = new System.Drawing.Size(46, 21);
this.toolsToolStripMenuItem.Text = "Tools";
@ -231,6 +237,27 @@
this.batchExportModelsToolStripMenuItem.Text = "Batch Export Models";
this.batchExportModelsToolStripMenuItem.Click += new System.EventHandler(this.batchExportModelsToolStripMenuItem_Click);
//
// batchReplaceFTPToolStripMenuItem
//
this.batchReplaceFTPToolStripMenuItem.Name = "batchReplaceFTPToolStripMenuItem";
this.batchReplaceFTPToolStripMenuItem.Size = new System.Drawing.Size(316, 22);
this.batchReplaceFTPToolStripMenuItem.Text = "Batch Replace FTP";
this.batchReplaceFTPToolStripMenuItem.Click += new System.EventHandler(this.batchReplaceFTPToolStripMenuItem_Click);
//
// batchReplaceTXTGToolStripMenuItem
//
this.batchReplaceTXTGToolStripMenuItem.Name = "batchReplaceTXTGToolStripMenuItem";
this.batchReplaceTXTGToolStripMenuItem.Size = new System.Drawing.Size(316, 22);
this.batchReplaceTXTGToolStripMenuItem.Text = "Batch Replace TXTG";
this.batchReplaceTXTGToolStripMenuItem.Click += new System.EventHandler(this.batchReplaceTXTGToolStripMenuItem_Click);
//
// batchRenameBNTXToolStripMenuItem
//
this.batchRenameBNTXToolStripMenuItem.Name = "batchRenameBNTXToolStripMenuItem";
this.batchRenameBNTXToolStripMenuItem.Size = new System.Drawing.Size(316, 22);
this.batchRenameBNTXToolStripMenuItem.Text = "Batch Rename BNTX from Filename";
this.batchRenameBNTXToolStripMenuItem.Click += new System.EventHandler(this.batchRenameBNTXToolStripMenuItem_Click);
//
// experimentalToolStripMenuItem
//
this.experimentalToolStripMenuItem.Name = "experimentalToolStripMenuItem";
@ -590,6 +617,9 @@
private System.Windows.Forms.ToolStripMenuItem hashCalculatorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem batchExportTexturesAllSupportedFormatsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem batchExportModelsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem batchReplaceFTPToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem batchReplaceTXTGToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem batchRenameBNTXToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem donateToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openUserFolderToolStripMenuItem;
}

View File

@ -17,6 +17,10 @@ using System.Reflection;
using OpenTK.Graphics.OpenGL;
using Toolbox.Library.NodeWrappers;
using Toolbox.Library.Rendering;
using Bfres.Structs;
using Syroot.NintenTools.NSW.Bntx;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
using FirstPlugin;
namespace Toolbox
{
@ -475,7 +479,16 @@ namespace Toolbox
if (format != null)
{
if (!format.CanSave)
return;
{
if (Runtime.AlwaysSaveAll)
{
continue;
}
else
{
return;
}
}
string FileName = format.FilePath;
if (!File.Exists(FileName))
@ -488,7 +501,16 @@ namespace Toolbox
sfd.FileName = format.FileName;
if (sfd.ShowDialog() != DialogResult.OK)
return;
{
if (Runtime.AlwaysSaveAll)
{
continue;
}
else
{
return;
}
}
FileName = sfd.FileName;
}
@ -498,7 +520,14 @@ namespace Toolbox
if (format is STGenericWrapper && !(format is STGenericTexture))
{
((STGenericWrapper)format).Export(FileName);
return;
if (Runtime.AlwaysSaveAll)
{
continue;
}
else
{
return;
}
}
if (node is ArchiveBase)
@ -1396,6 +1425,131 @@ namespace Toolbox
}
}
private void batchReplaceTXTGToolStripMenuItem_Click(object sender, EventArgs e)
{
BatchReplaceTXTG();
}
private void BatchReplaceTXTG()
{
ObjectEditor ObjectEditor = (ObjectEditor)ActiveMdiChild;
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
foreach (TreeNode node in ObjectEditor.GetNodes())
{
STGenericWrapper foundNode = (STGenericWrapper)node;
if (foundNode == null)
{
continue;
}
foreach (string file in System.IO.Directory.GetFiles(sfd.SelectedPath))
{
if (!file.Contains(foundNode.Text + "."))
{
continue;
}
foundNode.Replace(file);
}
}
}
}
private void batchReplaceFTPToolStripMenuItem_Click(object sender, EventArgs e)
{
BatchReplaceFTP();
}
private void BatchReplaceFTP()
{
ObjectEditor ObjectEditor = (ObjectEditor)ActiveMdiChild;
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
foreach (TreeNode node in ObjectEditor.GetNodes())
{
TreeNode foundNode = FindNodeByText(node, "Texture Pattern Animations");
// Skip if no Texture Pattern Animation node
if (foundNode == null)
{
continue;
}
string parentName = foundNode.FullPath.Split('\\')[0];
string sourcePath = Path.Combine(sfd.SelectedPath, parentName + ".bfres");
// Skip if no path found
if (!Directory.Exists(sourcePath))
{
continue;
}
BFRESGroupNode groupNode = (BFRESGroupNode)foundNode;
groupNode.ReplaceAll(sourcePath);
}
}
}
private TreeNode FindNodeByText(TreeNode treeNode, string searchText)
{
// Check if the current node matches the searchText.
if (treeNode.Text == searchText)
{
return treeNode; // Found a match, return the current node.
}
// Recursively search in each child node.
foreach (TreeNode tn in treeNode.Nodes)
{
TreeNode result = FindNodeByText(tn, searchText);
if (result != null)
{
return result; // If a match is found in the child nodes, return it.
}
}
// If no match is found in this subtree, return null.
return null;
}
private void batchRenameBNTXToolStripMenuItem_Click(object sender, EventArgs e)
{
ObjectEditor ObjectEditor = (ObjectEditor)ActiveMdiChild;
foreach (TreeNode node in ObjectEditor.GetNodes())
{
FirstPlugin.BNTX foundNode = (FirstPlugin.BNTX)node;
// Skip if no BNTX
if (foundNode == null)
{
continue;
}
string fileName = Path.GetFileNameWithoutExtension(foundNode.FilePath).Split('.')[0];
// Rename file
foundNode.Text = fileName;
if (foundNode.BinaryTexFile != null)
{
foundNode.BinaryTexFile.Name = fileName;
}
string textureKey = foundNode.Textures.Keys.FirstOrDefault();
TextureData textureData = foundNode.Textures.Values.FirstOrDefault();
if (textureData != null)
{
textureData.Text = fileName;
textureData.Name = fileName;
textureData.Texture.Name = fileName;
foundNode.Textures.Remove(textureKey);
foundNode.Textures.Add(fileName, textureData);
}
}
ObjectEditor.Update();
}
private List<string> failedFiles = new List<string>();
private List<string> batchExportFileList = new List<string>();
private void BatchExportModels(string[] files, string outputFolder)

View File

@ -73,6 +73,7 @@
<HintPath>Lib\OpenTK.GLControl.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Syroot.NintenTools.NSW.Bntx, Version=1.2.3.0, Culture=neutral, PublicKeyToken=null" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />