1
0
mirror of synced 2025-01-31 20:25:23 +01:00

Add dialog for replacing unswizzled images for nutexb

This commit is contained in:
KillzXGaming 2020-07-11 11:19:25 -04:00
parent 8cbc45f3a1
commit 7ca392bdfe

View File

@ -263,6 +263,8 @@ namespace FirstPlugin
} }
public override void Replace(string FileName) public override void Replace(string FileName)
{
if (IsSwizzled)
{ {
var tex = new TextureData(); var tex = new TextureData();
tex.Replace(FileName, MipCount, 0, Format); tex.Replace(FileName, MipCount, 0, Format);
@ -291,8 +293,54 @@ namespace FirstPlugin
ImageData = SetImageData(output); ImageData = SetImageData(output);
data.Clear(); data.Clear();
}
else
{
GenericTextureImporterList importer = new GenericTextureImporterList(SupportedFormats);
GenericTextureImporterSettings settings = new GenericTextureImporterSettings();
if (Utils.GetExtension(FileName) == ".dds" ||
Utils.GetExtension(FileName) == ".dds2")
{
settings.LoadDDS(FileName);
importer.LoadSettings(new List<GenericTextureImporterSettings>() { settings, });
ApplySettings(settings);
UpdateEditor(); UpdateEditor();
} }
else
{
settings.LoadBitMap(FileName);
importer.LoadSettings(new List<GenericTextureImporterSettings>() { settings, });
if (importer.ShowDialog() == DialogResult.OK)
{
if (settings.GenerateMipmaps && !settings.IsFinishedCompressing)
{
settings.DataBlockOutput.Clear();
settings.DataBlockOutput.Add(settings.GenerateMips(importer.CompressionMode, importer.MultiThreading));
}
ApplySettings(settings);
UpdateEditor();
}
}
}
UpdateEditor();
}
private void ApplySettings(GenericTextureImporterSettings settings)
{
//Combine all arrays
this.ImageData = Utils.CombineByteArray(settings.DataBlockOutput.ToArray());
this.Width = settings.TexWidth;
this.Height = settings.TexHeight;
this.Format = settings.Format;
this.MipCount = settings.MipCount;
this.Depth = settings.Depth;
this.ArrayCount = (uint)settings.DataBlockOutput.Count;
NutFormat = ConvertGenericToNutFormat(this.Format);
}
private byte[] SetImageData(byte[] output) private byte[] SetImageData(byte[] output)
{ {