FXC/XML conversion

This commit is contained in:
dexy 2022-05-20 17:52:51 +10:00
parent a2f34ddf05
commit 1648378010
5 changed files with 769 additions and 72 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4577,6 +4577,34 @@ namespace CodeWalker.GameFiles
} }
else else
{ } { }
var xml1 = FxcXml.GetXml(fxcfile);//won't output bytecodes with no output folder
var fxc1 = XmlFxc.GetFxc(xml1);
var xml2 = FxcXml.GetXml(fxc1);
if (xml1 != xml2)
{ }
for (int i = 0; i < fxcfile.Shaders.Length; i++)
{
if (fxc1.Shaders[i].Name != fxcfile.Shaders[i].Name)
{ }
fxc1.Shaders[i].ByteCode = fxcfile.Shaders[i].ByteCode;
}
var xdata = fxc1.Save();
if (xdata.Length == odata.Length)
{
for (int i = 0; i < xdata.Length; i++)
{
if (xdata[i] != odata[i])
{ break; }
}
}
else
{ }
} }
else else
{ } { }

View File

@ -132,6 +132,11 @@ namespace CodeWalker.GameFiles
AwcFile awc = RpfFile.GetFile<AwcFile>(e, data); AwcFile awc = RpfFile.GetFile<AwcFile>(e, data);
return GetXml(awc, out filename, outputfolder); return GetXml(awc, out filename, outputfolder);
} }
else if (fnl.EndsWith(".fxc"))
{
FxcFile fxc = RpfFile.GetFile<FxcFile>(e, data);
return GetXml(fxc, out filename, outputfolder);
}
else if (fnl.EndsWith("cache_y.dat")) else if (fnl.EndsWith("cache_y.dat"))
{ {
CacheDatFile cdf = RpfFile.GetFile<CacheDatFile>(e, data); CacheDatFile cdf = RpfFile.GetFile<CacheDatFile>(e, data);
@ -291,6 +296,12 @@ namespace CodeWalker.GameFiles
filename = fn + ".xml"; filename = fn + ".xml";
return AwcXml.GetXml(awc, outputfolder); return AwcXml.GetXml(awc, outputfolder);
} }
public static string GetXml(FxcFile fxc, out string filename, string outputfolder)
{
var fn = (fxc?.Name) ?? "";
filename = fn + ".xml";
return FxcXml.GetXml(fxc, outputfolder);
}
public static string GetXml(CacheDatFile cdf, out string filename, string outputfolder) public static string GetXml(CacheDatFile cdf, out string filename, string outputfolder)
{ {
var fn = (cdf?.FileEntry?.Name) ?? ""; var fn = (cdf?.FileEntry?.Name) ?? "";
@ -2217,8 +2228,9 @@ namespace CodeWalker.GameFiles
Ywr = 17, Ywr = 17,
Yvr = 18, Yvr = 18,
Awc = 19, Awc = 19,
Heightmap = 20, Fxc = 20,
Ypdb = 21, Heightmap = 21,
Ypdb = 22,
} }
} }

View File

@ -51,6 +51,8 @@ namespace CodeWalker.GameFiles
return GetYvrData(doc, fpathin); return GetYvrData(doc, fpathin);
case MetaFormat.Awc: case MetaFormat.Awc:
return GetAwcData(doc, fpathin); return GetAwcData(doc, fpathin);
case MetaFormat.Fxc:
return GetFxcData(doc, fpathin);
case MetaFormat.CacheFile: case MetaFormat.CacheFile:
return GetCacheFileData(doc); return GetCacheFileData(doc);
case MetaFormat.Heightmap: case MetaFormat.Heightmap:
@ -168,6 +170,12 @@ namespace CodeWalker.GameFiles
if (awc.Streams == null) return null; if (awc.Streams == null) return null;
return awc.Save(); return awc.Save();
} }
public static byte[] GetFxcData(XmlDocument doc, string fpathin)
{
var fxc = XmlFxc.GetFxc(doc, fpathin);
if (fxc.Shaders == null) return null;
return fxc.Save();
}
public static byte[] GetCacheFileData(XmlDocument doc) public static byte[] GetCacheFileData(XmlDocument doc)
{ {
var cdf = XmlCacheDat.GetCacheDat(doc); var cdf = XmlCacheDat.GetCacheDat(doc);
@ -210,6 +218,7 @@ namespace CodeWalker.GameFiles
case MetaFormat.Ywr: return "YWR XML"; case MetaFormat.Ywr: return "YWR XML";
case MetaFormat.Yvr: return "YVR XML"; case MetaFormat.Yvr: return "YVR XML";
case MetaFormat.Awc: return "AWC XML"; case MetaFormat.Awc: return "AWC XML";
case MetaFormat.Fxc: return "FXC XML";
case MetaFormat.CacheFile: return "CacheFile XML"; case MetaFormat.CacheFile: return "CacheFile XML";
case MetaFormat.Heightmap: return "Heightmap XML"; case MetaFormat.Heightmap: return "Heightmap XML";
case MetaFormat.Ypdb: return "YPDB XML"; case MetaFormat.Ypdb: return "YPDB XML";
@ -295,6 +304,10 @@ namespace CodeWalker.GameFiles
{ {
mformat = MetaFormat.Awc; mformat = MetaFormat.Awc;
} }
if (fnamel.EndsWith(".fxc.xml"))
{
mformat = MetaFormat.Fxc;
}
if (fnamel.EndsWith("cache_y.dat.xml")) if (fnamel.EndsWith("cache_y.dat.xml"))
{ {
mformat = MetaFormat.CacheFile; mformat = MetaFormat.CacheFile;

View File

@ -278,7 +278,7 @@ namespace CodeWalker
InitFileType(".ynv", "Nav Mesh", 9, FileTypeAction.ViewModel, true); InitFileType(".ynv", "Nav Mesh", 9, FileTypeAction.ViewModel, true);
InitFileType(".yvr", "Vehicle Record", 9, FileTypeAction.ViewYvr, true); InitFileType(".yvr", "Vehicle Record", 9, FileTypeAction.ViewYvr, true);
InitFileType(".ywr", "Waypoint Record", 9, FileTypeAction.ViewYwr, true); InitFileType(".ywr", "Waypoint Record", 9, FileTypeAction.ViewYwr, true);
InitFileType(".fxc", "Compiled Shaders", 9, FileTypeAction.ViewFxc); InitFileType(".fxc", "Compiled Shaders", 9, FileTypeAction.ViewFxc, true);
InitFileType(".yed", "Expression Dictionary", 9, FileTypeAction.ViewYed, true); InitFileType(".yed", "Expression Dictionary", 9, FileTypeAction.ViewYed, true);
InitFileType(".yld", "Cloth Dictionary", 9, FileTypeAction.ViewYld, true); InitFileType(".yld", "Cloth Dictionary", 9, FileTypeAction.ViewYld, true);
InitFileType(".yfd", "Frame Filter Dictionary", 9, FileTypeAction.ViewYfd); InitFileType(".yfd", "Frame Filter Dictionary", 9, FileTypeAction.ViewYfd);
@ -2107,7 +2107,7 @@ namespace CodeWalker
var nl = file?.File?.NameLower ?? file?.Name?.ToLowerInvariant(); var nl = file?.File?.NameLower ?? file?.Name?.ToLowerInvariant();
if (!string.IsNullOrEmpty(nl)) if (!string.IsNullOrEmpty(nl))
{ {
needfolder = nl.EndsWith(".ytd") || nl.EndsWith(".ydr") || nl.EndsWith(".ydd") || nl.EndsWith(".yft") || nl.EndsWith(".ypt") || nl.EndsWith(".awc"); needfolder = nl.EndsWith(".ytd") || nl.EndsWith(".ydr") || nl.EndsWith(".ydd") || nl.EndsWith(".yft") || nl.EndsWith(".ypt") || nl.EndsWith(".awc") || nl.EndsWith(".fxc");
} }
} }