Merge pull request #54 from emcifuntik/master

Fixed name for ymts (Now we can add clothes as DLCs)
This commit is contained in:
dexyfex 2019-10-30 22:39:24 +11:00 committed by GitHub
commit dc8cc398ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 11 deletions

View File

@ -51,7 +51,7 @@ namespace CodeWalker.GameFiles
public ResourceSimpleArray<MetaStructureInfo> StructureInfos { get; set; } public ResourceSimpleArray<MetaStructureInfo> StructureInfos { get; set; }
public ResourceSimpleArray<MetaEnumInfo> EnumInfos { get; set; } public ResourceSimpleArray<MetaEnumInfo> EnumInfos { get; set; }
public ResourceSimpleArray<MetaDataBlock> DataBlocks { get; set; } public ResourceSimpleArray<MetaDataBlock> DataBlocks { get; set; }
public string Name { get; private set; } public string Name { get; set; }
//public string[] Strings { get; set; } //public string[] Strings { get; set; }
private string_r NameBlock = null; private string_r NameBlock = null;

View File

@ -348,7 +348,7 @@ namespace CodeWalker.GameFiles
public Meta GetMeta() public Meta GetMeta(string metaName = "")
{ {
Meta m = new Meta(); Meta m = new Meta();
m.FileVFT = 0x405bc808; m.FileVFT = 0x405bc808;
@ -395,6 +395,8 @@ namespace CodeWalker.GameFiles
} }
m.DataBlocksCount = (short)m.DataBlocks.Count; m.DataBlocksCount = (short)m.DataBlocks.Count;
m.Name = metaName;
return m; return m;
} }

View File

@ -128,13 +128,13 @@ namespace CodeWalker.GameFiles
{ {
var cont = new MetaCont(meta); var cont = new MetaCont(meta);
WriteNode(sb, 0, cont, meta.RootBlockIndex, 0, XmlTagMode.Structure); WriteNode(sb, 0, cont, meta.RootBlockIndex, 0, XmlTagMode.Structure, 0, (string)meta.Name);
} }
return sb.ToString(); return sb.ToString();
} }
private static void WriteNode(StringBuilder sb, int indent, MetaCont cont, int blockId, int offset, XmlTagMode tagMode = XmlTagMode.None, MetaName structName = 0) private static void WriteNode(StringBuilder sb, int indent, MetaCont cont, int blockId, int offset, XmlTagMode tagMode = XmlTagMode.None, MetaName structName = 0, string metaName = "")
{ {
var block = cont.Meta.GetBlock(blockId); var block = cont.Meta.GetBlock(blockId);
@ -168,13 +168,13 @@ namespace CodeWalker.GameFiles
switch (tagMode) switch (tagMode)
{ {
case XmlTagMode.Structure: case XmlTagMode.Structure:
OpenTag(sb, indent, name); OpenTag(sb, indent, name, true, metaName);
break; break;
case XmlTagMode.Item: case XmlTagMode.Item:
OpenTag(sb, indent, "Item"); OpenTag(sb, indent, "Item", true, metaName);
break; break;
case XmlTagMode.ItemAndType: case XmlTagMode.ItemAndType:
OpenTag(sb, indent, "Item type=\"" + name + "\""); OpenTag(sb, indent, "Item type=\"" + name + "\"", true, metaName);
break; break;
} }
@ -1599,12 +1599,19 @@ namespace CodeWalker.GameFiles
sb.Append("</error>"); sb.Append("</error>");
sb.AppendLine(); sb.AppendLine();
} }
public static void OpenTag(StringBuilder sb, int indent, string name, bool appendLine = true) public static void OpenTag(StringBuilder sb, int indent, string name, bool appendLine = true, string metaName = "")
{ {
Indent(sb, indent); Indent(sb, indent);
sb.Append("<"); sb.Append("<");
sb.Append(name); sb.Append(name);
if (string.IsNullOrWhiteSpace(metaName))
{
sb.Append(">"); sb.Append(">");
}
else
{
sb.Append(" name=\"" + metaName + "\">");
}
if (appendLine) sb.AppendLine(); if (appendLine) sb.AppendLine();
} }
public static void CloseTag(StringBuilder sb, int indent, string name, bool appendLine = true) public static void CloseTag(StringBuilder sb, int indent, string name, bool appendLine = true)

View File

@ -15,9 +15,12 @@ namespace CodeWalker.GameFiles
Traverse(doc.DocumentElement, mb, 0, true); Traverse(doc.DocumentElement, mb, 0, true);
var meta = mb.GetMeta(); XmlNode metaName = doc.DocumentElement.Attributes.GetNamedItem("name");
return meta; if (metaName != null)
return mb.GetMeta(metaName.Value);
else
return mb.GetMeta();
} }
private static byte[] Traverse(XmlNode node, MetaBuilder mb, MetaName type = 0, bool isRoot = false) private static byte[] Traverse(XmlNode node, MetaBuilder mb, MetaName type = 0, bool isRoot = false)