Automatically open ctex files for narc if a bfres is opened. Fix aces texture mapping
This commit is contained in:
parent
33ae4c5635
commit
134b8e295c
@ -135,7 +135,7 @@ namespace FirstPlugin
|
||||
|
||||
public bool AddFile(ArchiveFileInfo archiveFileInfo)
|
||||
{
|
||||
FileEntry file = new FileEntry();
|
||||
FileEntry file = new FileEntry(this);
|
||||
file.FileName = archiveFileInfo.FileName;
|
||||
file.CreateEntry(archiveFileInfo.FileData, true);
|
||||
files.Add(file);
|
||||
@ -203,9 +203,31 @@ namespace FirstPlugin
|
||||
}
|
||||
public class FileEntry : ArchiveFileInfo
|
||||
{
|
||||
public FileEntry()
|
||||
BEA ArchiveFile;
|
||||
public FileEntry(BEA bea)
|
||||
{
|
||||
ArchiveFile = bea;
|
||||
}
|
||||
|
||||
private bool IsTexturesLoaded = false;
|
||||
public override IFileFormat OpenFile()
|
||||
{
|
||||
var FileFormat = base.OpenFile();
|
||||
bool IsModel = FileFormat is BFRES;
|
||||
|
||||
if (IsModel && !IsTexturesLoaded)
|
||||
{
|
||||
IsTexturesLoaded = true;
|
||||
foreach (var file in ArchiveFile.Files)
|
||||
{
|
||||
if (Utils.GetExtension(file.FileName) == ".ftxb")
|
||||
{
|
||||
file.FileFormat = file.OpenFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.OpenFile();
|
||||
}
|
||||
|
||||
public ushort unk1;
|
||||
@ -281,7 +303,7 @@ namespace FirstPlugin
|
||||
|
||||
public FileEntry SetupFileEntry(ASST asset)
|
||||
{
|
||||
FileEntry fileEntry = new FileEntry();
|
||||
FileEntry fileEntry = new FileEntry(this);
|
||||
fileEntry.FileName = asset.FileName;
|
||||
fileEntry.unk1 = asset.unk;
|
||||
fileEntry.unk2 = asset.unk2;
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
using Toolbox.Library.Forms;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
@ -77,23 +77,45 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public FileEntry(string Name)
|
||||
public NARC ArchiveFile;
|
||||
|
||||
public FileEntry(NARC narc, string Name)
|
||||
{
|
||||
ArchiveFile = narc;
|
||||
FileName = Name.Replace(" ", string.Empty).RemoveIllegaleFolderNameCharacters();
|
||||
}
|
||||
|
||||
public override byte[] FileData
|
||||
{
|
||||
get
|
||||
{
|
||||
return DecompressBlock();
|
||||
}
|
||||
get { return DecompressBlock(); }
|
||||
set
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsTexturesLoaded = false;
|
||||
public override IFileFormat OpenFile()
|
||||
{
|
||||
var FileFormat = base.OpenFile();
|
||||
bool IsModel = FileFormat is BFRES;
|
||||
|
||||
if (IsModel && !IsTexturesLoaded)
|
||||
{
|
||||
IsTexturesLoaded = true;
|
||||
foreach (var file in ArchiveFile.Files)
|
||||
{
|
||||
if (Utils.GetExtension(file.FileName) == ".cbntx")
|
||||
{
|
||||
Console.WriteLine($"Opening cbntx {file.FileName}");
|
||||
file.FileFormat = file.OpenFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.OpenFile();
|
||||
}
|
||||
|
||||
private byte[] DecompressBlock()
|
||||
{
|
||||
byte[] data = GetBlock();
|
||||
@ -128,7 +150,7 @@ namespace FirstPlugin
|
||||
|
||||
if (IsGZIP)
|
||||
data = STLibraryCompression.GZIP.Decompress(filedata);
|
||||
else
|
||||
else
|
||||
data = STLibraryCompression.ZLIB.Decompress(filedata, false);
|
||||
}
|
||||
|
||||
@ -153,7 +175,7 @@ namespace FirstPlugin
|
||||
List<byte> Data = new List<byte>();
|
||||
for (ushort i = 0; i < header.FATB.FileCount; i++)
|
||||
{
|
||||
FileEntries.Add(new FileEntry(names[i])
|
||||
FileEntries.Add(new FileEntry(this, names[i])
|
||||
{
|
||||
entry = header.FATB.FileEntries[i],
|
||||
fileImage = header.FIMG,
|
||||
@ -183,7 +205,6 @@ namespace FirstPlugin
|
||||
|
||||
//EFE for REing format https://github.com/Gericom/EveryFileExplorer/blob/f9f00d193c9608d71c9a23d9f3ab7e752f4ada2a/NDS/NitroSystem/FND/NARC.cs
|
||||
|
||||
|
||||
public class Header
|
||||
{
|
||||
public string Signature;
|
||||
@ -278,7 +299,7 @@ namespace FirstPlugin
|
||||
Size = reader.ReadUInt32();
|
||||
dataBlock = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position));
|
||||
}
|
||||
}
|
||||
}
|
||||
public class FileNameTable
|
||||
{
|
||||
public string Signature;
|
||||
|
@ -792,6 +792,29 @@ namespace FirstPlugin
|
||||
texture.Type = MatTexture.TextureType.Shadow;
|
||||
}
|
||||
}
|
||||
else if (mat.ShaderAssign.ShaderArchiveName == "ssg")
|
||||
{
|
||||
bool IsAlbedo0 = texture.SamplerName == "_a0";
|
||||
bool IsNormal = texture.SamplerName == "_n0";
|
||||
bool IsEmissive = texture.SamplerName == "_e0";
|
||||
bool IsSpecular = texture.SamplerName == "_s0";
|
||||
|
||||
if (IsAlbedo0)
|
||||
{
|
||||
m.HasDiffuseMap = true;
|
||||
texture.Type = MatTexture.TextureType.Diffuse;
|
||||
}
|
||||
if (IsNormal)
|
||||
{
|
||||
m.HasNormalMap = true;
|
||||
texture.Type = MatTexture.TextureType.Normal;
|
||||
}
|
||||
if (IsSpecular)
|
||||
{
|
||||
m.HasSpecularMap = true;
|
||||
texture.Type = MatTexture.TextureType.Specular;
|
||||
}
|
||||
}
|
||||
else if (Runtime.activeGame == Runtime.ActiveGame.Bezel)
|
||||
{
|
||||
bool IsAlbedo0 = useSampler == "_a0";
|
||||
|
Loading…
x
Reference in New Issue
Block a user