mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-01-25 15:02:56 +08:00
YPT/XML conversion progress?
This commit is contained in:
parent
c3e212d0d0
commit
dff9c8738e
@ -4446,7 +4446,7 @@ namespace CodeWalker.GameFiles
|
||||
// structure data
|
||||
public ulong NamePointer { get; set; }
|
||||
public ResourceSimpleList64_s<LightAttributes_s> LightAttributes { get; set; }
|
||||
public ulong ParticlesPointer { get; set; } // pointer in YPT files! TODO: investigate what it points to!
|
||||
public ulong UnkPointer { get; set; }
|
||||
public ulong BoundPointer { get; set; }
|
||||
|
||||
// reference data
|
||||
@ -4466,7 +4466,7 @@ namespace CodeWalker.GameFiles
|
||||
// read structure data
|
||||
this.NamePointer = reader.ReadUInt64();
|
||||
this.LightAttributes = reader.ReadBlock<ResourceSimpleList64_s<LightAttributes_s>>();
|
||||
this.ParticlesPointer = reader.ReadUInt64();
|
||||
this.UnkPointer = reader.ReadUInt64();
|
||||
this.BoundPointer = reader.ReadUInt64();
|
||||
|
||||
try
|
||||
@ -4487,12 +4487,12 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex) //sometimes error here for loading particles! different drawable type? base only?
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorMessage = ex.ToString();
|
||||
}
|
||||
|
||||
if (ParticlesPointer != 0)
|
||||
if (UnkPointer != 0)
|
||||
{ }
|
||||
}
|
||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||
@ -4506,7 +4506,7 @@ namespace CodeWalker.GameFiles
|
||||
// write structure data
|
||||
writer.Write(this.NamePointer);
|
||||
writer.WriteBlock(this.LightAttributes);
|
||||
writer.Write(this.ParticlesPointer);
|
||||
writer.Write(this.UnkPointer);
|
||||
writer.Write(this.BoundPointer);
|
||||
}
|
||||
public override void WriteXml(StringBuilder sb, int indent, string ddsfolder)
|
||||
@ -4574,7 +4574,60 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
}
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))] public class DrawableBaseDictionary : ResourceFileBase
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))] public class DrawablePtfx : DrawableBase
|
||||
{
|
||||
public override long BlockLength
|
||||
{
|
||||
get { return 176; }
|
||||
}
|
||||
|
||||
// structure data
|
||||
public ulong UnkPointer { get; set; }
|
||||
|
||||
|
||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||
{
|
||||
base.Read(reader, parameters);
|
||||
|
||||
// read structure data
|
||||
this.UnkPointer = reader.ReadUInt64();
|
||||
|
||||
if (UnkPointer != 0)
|
||||
{ }
|
||||
}
|
||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||
{
|
||||
base.Write(writer, parameters);
|
||||
|
||||
// write structure data
|
||||
writer.Write(this.UnkPointer);
|
||||
}
|
||||
public override void WriteXml(StringBuilder sb, int indent, string ddsfolder)
|
||||
{
|
||||
base.WriteXml(sb, indent, ddsfolder);
|
||||
}
|
||||
public override void ReadXml(XmlNode node, string ddsfolder)
|
||||
{
|
||||
base.ReadXml(node, ddsfolder);
|
||||
}
|
||||
public static void WriteXmlNode(DrawablePtfx d, StringBuilder sb, int indent, string ddsfolder, string name = "Drawable")
|
||||
{
|
||||
if (d == null) return;
|
||||
YdrXml.OpenTag(sb, indent, name);
|
||||
d.WriteXml(sb, indent + 1, ddsfolder);
|
||||
YdrXml.CloseTag(sb, indent, name);
|
||||
}
|
||||
public static DrawablePtfx ReadXmlNode(XmlNode node, string ddsfolder)
|
||||
{
|
||||
if (node == null) return null;
|
||||
var d = new DrawablePtfx();
|
||||
d.ReadXml(node, ddsfolder);
|
||||
return d;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))] public class DrawablePtfxDictionary : ResourceFileBase
|
||||
{
|
||||
public override long BlockLength
|
||||
{
|
||||
@ -4596,7 +4649,7 @@ namespace CodeWalker.GameFiles
|
||||
// reference data
|
||||
//public ResourceSimpleArray<uint_r> Hashes { get; set; }
|
||||
public uint[] Hashes { get; set; }
|
||||
public ResourcePointerArray64<DrawableBase> Drawables { get; set; }
|
||||
public ResourcePointerArray64<DrawablePtfx> Drawables { get; set; }
|
||||
|
||||
|
||||
private ResourceSystemStructBlock<uint> HashesBlock = null;//only used for saving
|
||||
@ -4620,7 +4673,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
// read reference data
|
||||
this.Hashes = reader.ReadUintsAt(this.HashesPointer, this.HashesCount1);
|
||||
this.Drawables = reader.ReadBlockAt<ResourcePointerArray64<DrawableBase>>(this.DrawablesPointer, this.DrawablesCount1);
|
||||
this.Drawables = reader.ReadBlockAt<ResourcePointerArray64<DrawablePtfx>>(this.DrawablesPointer, this.DrawablesCount1);
|
||||
|
||||
//if (Unknown_10h != 0)
|
||||
//{ }
|
||||
@ -4672,7 +4725,7 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
public void ReadXml(XmlNode node, string ddsfolder)
|
||||
{
|
||||
var drawables = new List<DrawableBase>();
|
||||
var drawables = new List<DrawablePtfx>();
|
||||
var drawablehashes = new List<uint>();
|
||||
|
||||
var inodes = node.SelectNodes("Item");
|
||||
@ -4681,7 +4734,7 @@ namespace CodeWalker.GameFiles
|
||||
foreach (XmlNode inode in inodes)
|
||||
{
|
||||
var h = XmlMeta.GetHash(Xml.GetChildInnerText(inode, "Name"));
|
||||
var d = new DrawableBase();
|
||||
var d = new DrawablePtfx();
|
||||
d.ReadXml(inode, ddsfolder);
|
||||
drawables.Add(d);
|
||||
drawablehashes.Add(h);
|
||||
@ -4689,20 +4742,20 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
|
||||
Hashes = drawablehashes.ToArray();
|
||||
Drawables = new ResourcePointerArray64<DrawableBase>();
|
||||
Drawables = new ResourcePointerArray64<DrawablePtfx>();
|
||||
Drawables.data_items = drawables.ToArray();
|
||||
}
|
||||
public static void WriteXmlNode(DrawableBaseDictionary d, StringBuilder sb, int indent, string ddsfolder, string name = "DrawableDictionary")
|
||||
public static void WriteXmlNode(DrawablePtfxDictionary 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)
|
||||
public static DrawablePtfxDictionary ReadXmlNode(XmlNode node, string ddsfolder)
|
||||
{
|
||||
if (node == null) return null;
|
||||
var d = new DrawableBaseDictionary();
|
||||
var d = new DrawablePtfxDictionary();
|
||||
d.ReadXml(node, ddsfolder);
|
||||
return d;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace CodeWalker.GameFiles
|
||||
// reference data
|
||||
public string_r Name { get; set; }
|
||||
public TextureDictionary TextureDictionary { get; set; }
|
||||
public DrawableBaseDictionary DrawableDictionary { get; set; }
|
||||
public DrawablePtfxDictionary DrawableDictionary { get; set; }
|
||||
public ParticleRuleDictionary ParticleRuleDictionary { get; set; }
|
||||
public ParticleEffectRuleDictionary EffectRuleDictionary { get; set; }
|
||||
public ParticleEmitterRuleDictionary EmitterRuleDictionary { get; set; }
|
||||
@ -86,7 +86,7 @@ namespace CodeWalker.GameFiles
|
||||
// read reference data
|
||||
this.Name = reader.ReadBlockAt<string_r>(this.NamePointer);
|
||||
this.TextureDictionary = reader.ReadBlockAt<TextureDictionary>(this.TextureDictionaryPointer);
|
||||
this.DrawableDictionary = reader.ReadBlockAt<DrawableBaseDictionary>(this.DrawableDictionaryPointer);
|
||||
this.DrawableDictionary = reader.ReadBlockAt<DrawablePtfxDictionary>(this.DrawableDictionaryPointer);
|
||||
this.ParticleRuleDictionary = reader.ReadBlockAt<ParticleRuleDictionary>(this.ParticleRuleDictionaryPointer);
|
||||
this.EffectRuleDictionary = reader.ReadBlockAt<ParticleEffectRuleDictionary>(this.EmitterRuleDictionaryPointer);
|
||||
this.EmitterRuleDictionary = reader.ReadBlockAt<ParticleEmitterRuleDictionary>(this.EffectRuleDictionaryPointer);
|
||||
@ -150,7 +150,7 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
if (DrawableDictionary != null)
|
||||
{
|
||||
DrawableBaseDictionary.WriteXmlNode(DrawableDictionary, sb, indent, ddsfolder, "DrawableDictionary");
|
||||
DrawablePtfxDictionary.WriteXmlNode(DrawableDictionary, sb, indent, ddsfolder, "DrawableDictionary");
|
||||
}
|
||||
if (TextureDictionary != null)
|
||||
{
|
||||
@ -181,7 +181,7 @@ namespace CodeWalker.GameFiles
|
||||
var dnode = node.SelectSingleNode("DrawableDictionary");
|
||||
if (dnode != null)
|
||||
{
|
||||
DrawableDictionary = DrawableBaseDictionary.ReadXmlNode(dnode, ddsfolder);
|
||||
DrawableDictionary = DrawablePtfxDictionary.ReadXmlNode(dnode, ddsfolder);
|
||||
}
|
||||
var tnode = node.SelectSingleNode("TextureDictionary");
|
||||
if (tnode != null)
|
||||
@ -221,7 +221,7 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
}
|
||||
|
||||
var drwdict = new Dictionary<MetaHash, DrawableBase>();
|
||||
var drwdict = new Dictionary<MetaHash, DrawablePtfx>();
|
||||
if (DrawableDictionary?.Drawables?.data_items != null)
|
||||
{
|
||||
var max = Math.Min(DrawableDictionary.Drawables.data_items.Length, (DrawableDictionary.Hashes?.Length ?? 0));
|
||||
@ -320,7 +320,7 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
foreach (var pdrw in ptr.Drawables.data_items)
|
||||
{
|
||||
if (drwdict.TryGetValue(pdrw.NameHash, out DrawableBase drw))
|
||||
if (drwdict.TryGetValue(pdrw.NameHash, out DrawablePtfx drw))
|
||||
{
|
||||
pdrw.Drawable = drw;
|
||||
}
|
||||
@ -1762,7 +1762,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
// reference data
|
||||
public string_r Name { get; set; }
|
||||
public DrawableBase Drawable { get; set; }
|
||||
public DrawablePtfx Drawable { get; set; }
|
||||
|
||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||
{
|
||||
@ -1779,7 +1779,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
// read reference data
|
||||
this.Name = reader.ReadBlockAt<string_r>(this.NamePointer);
|
||||
this.Drawable = reader.ReadBlockAt<DrawableBase>(this.DrawablePointer);
|
||||
this.Drawable = reader.ReadBlockAt<DrawablePtfx>(this.DrawablePointer);
|
||||
|
||||
if (!string.IsNullOrEmpty(Name?.Value))
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
// structure data
|
||||
public uint FileVFT { get; set; }
|
||||
public uint FileUnknown { get; set; }
|
||||
public uint FileUnknown { get; set; } = 1;
|
||||
public ulong FilePagesInfoPointer { get; set; }
|
||||
|
||||
// reference data
|
||||
|
Loading…
Reference in New Issue
Block a user