mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 06:52:55 +08:00
MRF/XML conversion
This commit is contained in:
parent
f0567d315b
commit
ddf689ae81
File diff suppressed because it is too large
Load Diff
@ -4543,6 +4543,39 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
else
|
||||
{ }
|
||||
|
||||
var xml = MrfXml.GetXml(mrffile);
|
||||
var mrf2 = XmlMrf.GetMrf(xml);
|
||||
var ndata2 = mrf2.Save();
|
||||
if (ndata2.Length == odata.Length)
|
||||
{
|
||||
for (int i = 0; i < ndata2.Length; i++)
|
||||
{
|
||||
if (ndata2[i] != odata[i] && !mrfDiffCanBeIgnored(i, mrffile))
|
||||
{ break; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{ }
|
||||
|
||||
bool mrfDiffCanBeIgnored(int fileOffset, MrfFile originalMrf)
|
||||
{
|
||||
foreach (var n in originalMrf.AllNodes)
|
||||
{
|
||||
if (n is MrfNodeStateBase state)
|
||||
{
|
||||
// If TransitionCount is 0, the TransitionsOffset value can be ignored.
|
||||
// TransitionsOffset in original MRFs isn't always set to 0 in this case,
|
||||
// XML-imported MRFs always set it to 0
|
||||
if (state.TransitionCount == 0 && fileOffset == (state.FileOffset + 0x1C))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ }
|
||||
|
@ -147,6 +147,11 @@ namespace CodeWalker.GameFiles
|
||||
HeightmapFile hmf = RpfFile.GetFile<HeightmapFile>(e, data);
|
||||
return GetXml(hmf, out filename, outputfolder);
|
||||
}
|
||||
else if (fnl.EndsWith(".mrf"))
|
||||
{
|
||||
MrfFile mrf = RpfFile.GetFile<MrfFile>(e, data);
|
||||
return GetXml(mrf, out filename, outputfolder);
|
||||
}
|
||||
filename = fn;
|
||||
return string.Empty;
|
||||
}
|
||||
@ -314,6 +319,12 @@ namespace CodeWalker.GameFiles
|
||||
filename = fn + ".xml";
|
||||
return HmapXml.GetXml(hmf);
|
||||
}
|
||||
public static string GetXml(MrfFile mrf, out string filename, string outputfolder)
|
||||
{
|
||||
var fn = (mrf?.Name) ?? "";
|
||||
filename = fn + ".xml";
|
||||
return MrfXml.GetXml(mrf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2231,6 +2242,7 @@ namespace CodeWalker.GameFiles
|
||||
Fxc = 20,
|
||||
Heightmap = 21,
|
||||
Ypdb = 22,
|
||||
Mrf = 23,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ namespace CodeWalker.GameFiles
|
||||
return GetHeightmapData(doc);
|
||||
case MetaFormat.Ypdb:
|
||||
return GetYpdbData(doc);
|
||||
case MetaFormat.Mrf:
|
||||
return GetMrfData(doc);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -194,6 +196,12 @@ namespace CodeWalker.GameFiles
|
||||
if (ypdb.WeightSet == null) return null;
|
||||
return ypdb.Save();
|
||||
}
|
||||
public static byte[] GetMrfData(XmlDocument doc)
|
||||
{
|
||||
var mrf = XmlMrf.GetMrf(doc);
|
||||
if (mrf == null) return null;
|
||||
return mrf.Save();
|
||||
}
|
||||
|
||||
|
||||
public static string GetXMLFormatName(MetaFormat mformat)
|
||||
@ -222,6 +230,7 @@ namespace CodeWalker.GameFiles
|
||||
case MetaFormat.CacheFile: return "CacheFile XML";
|
||||
case MetaFormat.Heightmap: return "Heightmap XML";
|
||||
case MetaFormat.Ypdb: return "YPDB XML";
|
||||
case MetaFormat.Mrf: return "MRF XML";
|
||||
default: return "XML";
|
||||
}
|
||||
}
|
||||
@ -320,6 +329,10 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
mformat = MetaFormat.Ypdb;
|
||||
}
|
||||
if (fnamel.EndsWith(".mrf.xml"))
|
||||
{
|
||||
mformat = MetaFormat.Mrf;
|
||||
}
|
||||
return mformat;
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ namespace CodeWalker
|
||||
InitFileType(".png", "Portable Network Graphics", 16);
|
||||
InitFileType(".dds", "DirectDraw Surface", 16);
|
||||
InitFileType(".ytd", "Texture Dictionary", 16, FileTypeAction.ViewYtd, true);
|
||||
InitFileType(".mrf", "Move Network File", 18, FileTypeAction.ViewMrf);
|
||||
InitFileType(".mrf", "Move Network File", 18, FileTypeAction.ViewMrf, true);
|
||||
InitFileType(".ycd", "Clip Dictionary", 18, FileTypeAction.ViewYcd, true);
|
||||
InitFileType(".ypt", "Particle Effect", 18, FileTypeAction.ViewModel, true);
|
||||
InitFileType(".ybn", "Static Collisions", 19, FileTypeAction.ViewModel, true);
|
||||
@ -1793,9 +1793,9 @@ namespace CodeWalker
|
||||
private void ViewMrf(string name, string path, byte[] data, RpfFileEntry e)
|
||||
{
|
||||
var mrf = RpfFile.GetFile<MrfFile>(e, data);
|
||||
GenericForm f = new GenericForm(this);
|
||||
MetaForm f = new MetaForm(this);
|
||||
f.Show();
|
||||
f.LoadFile(mrf, mrf.RpfFileEntry);
|
||||
f.LoadMeta(mrf);
|
||||
}
|
||||
private void ViewNametable(string name, string path, byte[] data, RpfFileEntry e)
|
||||
{
|
||||
|
@ -388,6 +388,20 @@ namespace CodeWalker.Forms
|
||||
metaFormat = MetaFormat.Ypdb;
|
||||
}
|
||||
}
|
||||
public void LoadMeta(MrfFile mrf)
|
||||
{
|
||||
var fn = ((mrf?.RpfFileEntry?.Name) ?? "") + ".xml";
|
||||
Xml = MrfXml.GetXml(mrf);
|
||||
FileName = fn;
|
||||
RawPropertyGrid.SelectedObject = mrf;
|
||||
rpfFileEntry = mrf?.RpfFileEntry;
|
||||
modified = false;
|
||||
metaFormat = MetaFormat.XML;
|
||||
if (mrf?.RpfFileEntry != null)
|
||||
{
|
||||
metaFormat = MetaFormat.Mrf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user