Load external string file by flag
This commit is contained in:
parent
a39456b0cc
commit
826a96b265
Binary file not shown.
@ -809,8 +809,19 @@ namespace FirstPlugin
|
|||||||
|
|
||||||
MeshCodec = new MeshCodec();
|
MeshCodec = new MeshCodec();
|
||||||
|
|
||||||
bool isMeshCodec = MeshCodec.IsMeshCodecBfres(stream);
|
var externalFlags = MeshCodec.GetExternalFlags(stream);
|
||||||
if (isMeshCodec)
|
//External flags used
|
||||||
|
if (externalFlags != (MeshCodec.ExternalFlags)0)
|
||||||
|
{
|
||||||
|
//Ensure it uses mc compressor for save
|
||||||
|
this.IFileInfo.FileIsCompressed = true;
|
||||||
|
// this.IFileInfo.FileCompression = new MeshCodecFormat();
|
||||||
|
if (!this.FileName.EndsWith(".mc"))
|
||||||
|
this.FileName += ".mc";
|
||||||
|
if (!this.FilePath.EndsWith(".mc"))
|
||||||
|
this.FilePath += ".mc";
|
||||||
|
}
|
||||||
|
if (externalFlags.HasFlag(MeshCodec.ExternalFlags.HasExternalString))
|
||||||
MeshCodec.Prepare();
|
MeshCodec.Prepare();
|
||||||
|
|
||||||
if (IsWiiU)
|
if (IsWiiU)
|
||||||
@ -834,7 +845,8 @@ namespace FirstPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMeshCodec)
|
//Mesh codec type of bfres, load textures externallly
|
||||||
|
if (externalFlags != (MeshCodec.ExternalFlags)0)
|
||||||
{
|
{
|
||||||
MeshCodec.PrepareTexToGo(resFile);
|
MeshCodec.PrepareTexToGo(resFile);
|
||||||
STTextureFolder texfolder = new STTextureFolder("TexToGo");
|
STTextureFolder texfolder = new STTextureFolder("TexToGo");
|
||||||
|
@ -20,26 +20,37 @@ namespace FirstPlugin
|
|||||||
|
|
||||||
public List<TXTG> TextureList = new List<TXTG>();
|
public List<TXTG> TextureList = new List<TXTG>();
|
||||||
|
|
||||||
public static bool IsMeshCodecBfres(Stream stream)
|
public static ExternalFlags GetExternalFlags(Stream stream)
|
||||||
{
|
{
|
||||||
using (var reader = new FileReader(stream, true))
|
using (var reader = new FileReader(stream, true))
|
||||||
{
|
{
|
||||||
reader.Seek(10, SeekOrigin.Begin);
|
using (reader.TemporarySeek(10, SeekOrigin.Begin))
|
||||||
byte version = reader.ReadByte();
|
|
||||||
if (version < 10)
|
|
||||||
{
|
{
|
||||||
reader.Position = 0;
|
byte version = reader.ReadByte();
|
||||||
return false;
|
//Check if bfres supports external strings or not
|
||||||
|
if (version < 10)
|
||||||
|
return (ExternalFlags)0;
|
||||||
|
|
||||||
|
//Check external flags
|
||||||
|
reader.SeekBegin(0xee);
|
||||||
|
ExternalFlags flag = (ExternalFlags)reader.ReadByte();
|
||||||
|
byte flag2 = reader.ReadByte();
|
||||||
|
if (flag2 == 1) //flag custom set by bfres resave to detect an mc resave
|
||||||
|
return ExternalFlags.MeshCodecResave;
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Seek(238, SeekOrigin.Begin);
|
//Flags thanks to watertoon
|
||||||
byte flag = reader.ReadByte();
|
public enum ExternalFlags : byte
|
||||||
byte flag2 = reader.ReadByte(); //flag custom set by bfres resave
|
{
|
||||||
|
IsExternalModelUninitalized = 1 << 0,
|
||||||
|
HasExternalString = 1 << 1,
|
||||||
|
HoldsExternalStrings = 1 << 2,
|
||||||
|
HasExternalGPU = 1 << 3,
|
||||||
|
|
||||||
reader.Position = 0;
|
MeshCodecResave = 1 << 7,
|
||||||
//Check if flag is external buffer .mc binary
|
|
||||||
return flag == 11 || flag2 == 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Prepare()
|
public static void Prepare()
|
||||||
@ -68,7 +79,7 @@ namespace FirstPlugin
|
|||||||
LoadExternalStrings();
|
LoadExternalStrings();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadExternalStrings()
|
public static void LoadExternalStrings()
|
||||||
{
|
{
|
||||||
if (ExternalStringBinary != null)
|
if (ExternalStringBinary != null)
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user