mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-27 01:12:54 +08:00
YPT/XML conversion progress
This commit is contained in:
parent
39eed4c2e9
commit
b11d350294
@ -4655,6 +4655,57 @@ namespace CodeWalker.GameFiles
|
|||||||
writer.Write(this.DrawablesCount2);
|
writer.Write(this.DrawablesCount2);
|
||||||
writer.Write(this.Unknown_3Ch);
|
writer.Write(this.Unknown_3Ch);
|
||||||
}
|
}
|
||||||
|
public void WriteXml(StringBuilder sb, int indent, string ddsfolder)
|
||||||
|
{
|
||||||
|
if (Drawables?.data_items != null)
|
||||||
|
{
|
||||||
|
for (int i=0; i< Drawables.data_items.Length; i++)
|
||||||
|
{
|
||||||
|
var d = Drawables.data_items[i];
|
||||||
|
var h = (MetaHash)((i < (Hashes?.Length ?? 0)) ? Hashes[i] : 0);
|
||||||
|
YddXml.OpenTag(sb, indent, "Item");
|
||||||
|
YddXml.StringTag(sb, indent + 1, "Name", YddXml.XmlEscape(h.ToCleanString()));
|
||||||
|
d.WriteXml(sb, indent + 1, ddsfolder);
|
||||||
|
YddXml.CloseTag(sb, indent, "Item");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ReadXml(XmlNode node, string ddsfolder)
|
||||||
|
{
|
||||||
|
var drawables = new List<DrawableBase>();
|
||||||
|
var drawablehashes = new List<uint>();
|
||||||
|
|
||||||
|
var inodes = node.SelectNodes("Item");
|
||||||
|
if (inodes != null)
|
||||||
|
{
|
||||||
|
foreach (XmlNode inode in inodes)
|
||||||
|
{
|
||||||
|
var h = XmlMeta.GetHash(Xml.GetChildInnerText(inode, "Name"));
|
||||||
|
var d = new DrawableBase();
|
||||||
|
d.ReadXml(inode, ddsfolder);
|
||||||
|
drawables.Add(d);
|
||||||
|
drawablehashes.Add(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Hashes = drawablehashes.ToArray();
|
||||||
|
Drawables = new ResourcePointerArray64<DrawableBase>();
|
||||||
|
Drawables.data_items = drawables.ToArray();
|
||||||
|
}
|
||||||
|
public static void WriteXmlNode(DrawableBaseDictionary d, StringBuilder sb, int indent, string ddsfolder, string name = "DrawableDictionary")
|
||||||
|
{
|
||||||
|
if (d == null) return;
|
||||||
|
YddXml.OpenTag(sb, indent, name);
|
||||||
|
d.WriteXml(sb, indent + 1, ddsfolder);
|
||||||
|
YddXml.CloseTag(sb, indent, name);
|
||||||
|
}
|
||||||
|
public static DrawableBaseDictionary ReadXmlNode(XmlNode node, string ddsfolder)
|
||||||
|
{
|
||||||
|
if (node == null) return null;
|
||||||
|
var d = new DrawableBaseDictionary();
|
||||||
|
d.ReadXml(node, ddsfolder);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
public override IResourceBlock[] GetReferences()
|
public override IResourceBlock[] GetReferences()
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -736,7 +736,7 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
// reference data
|
// reference data
|
||||||
//public ResourceSimpleArray<T> Entries;
|
//public ResourceSimpleArray<T> Entries;
|
||||||
public T[] data_items { get; private set; }
|
public T[] data_items { get; set; }
|
||||||
|
|
||||||
private ResourceSimpleArray<T> data_block;//used for saving.
|
private ResourceSimpleArray<T> data_block;//used for saving.
|
||||||
|
|
||||||
@ -1395,9 +1395,11 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ulong[] data_pointers { get; private set; }
|
public ulong[] data_pointers { get; set; }
|
||||||
public T[] data_items { get; set; }
|
public T[] data_items { get; set; }
|
||||||
|
|
||||||
|
public bool ManualPointerOverride = false;//use this to manually write data_pointers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ResourcePointerArray64()
|
public ResourcePointerArray64()
|
||||||
@ -1424,13 +1426,22 @@ namespace CodeWalker.GameFiles
|
|||||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||||
{
|
{
|
||||||
// update...
|
// update...
|
||||||
var list = new List<ulong>();
|
if (ManualPointerOverride == false)
|
||||||
foreach (var x in data_items)
|
{
|
||||||
if (x != null)
|
var list = new List<ulong>();
|
||||||
list.Add((uint)x.FilePosition);
|
foreach (var x in data_items)
|
||||||
else
|
{
|
||||||
list.Add((uint)0);
|
if (x != null)
|
||||||
data_pointers = list.ToArray();
|
{
|
||||||
|
list.Add((uint)x.FilePosition);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.Add(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data_pointers = list.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
// write...
|
// write...
|
||||||
foreach (var x in data_pointers)
|
foreach (var x in data_pointers)
|
||||||
@ -1442,8 +1453,13 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
var list = new List<IResourceBlock>();
|
var list = new List<IResourceBlock>();
|
||||||
|
|
||||||
foreach (var x in data_items)
|
if (ManualPointerOverride == false)
|
||||||
list.Add(x);
|
{
|
||||||
|
foreach (var x in data_items)
|
||||||
|
{
|
||||||
|
list.Add(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return list.ToArray();
|
return list.ToArray();
|
||||||
}
|
}
|
||||||
|
@ -1042,7 +1042,7 @@ namespace CodeWalker.Forms
|
|||||||
{
|
{
|
||||||
items.Add(kvp);
|
items.Add(kvp);
|
||||||
}
|
}
|
||||||
//items.Sort((a, b) => { return a.Value?.Name?.CompareTo(b.Value?.Name ?? "") ?? 0; });
|
items.Sort((a, b) => { return ((MetaHash)a.Key).ToCleanString().CompareTo(((MetaHash)b.Key).ToCleanString()); });
|
||||||
foreach (var kvp in items)
|
foreach (var kvp in items)
|
||||||
{
|
{
|
||||||
AddDrawableTreeNode(kvp.Value, kvp.Key, check);
|
AddDrawableTreeNode(kvp.Value, kvp.Key, check);
|
||||||
|
Loading…
Reference in New Issue
Block a user