mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-08-19 00:19:19 +08:00
Merge branch 'dexyfex:master' into master
This commit is contained in:
commit
63f42f9fcc
326
CodeWalker.Core/GameFiles/FileTypes/DistantLightsFile.cs
Normal file
326
CodeWalker.Core/GameFiles/FileTypes/DistantLightsFile.cs
Normal file
@ -0,0 +1,326 @@
|
|||||||
|
using SharpDX;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using TC = System.ComponentModel.TypeConverterAttribute;
|
||||||
|
using EXP = System.ComponentModel.ExpandableObjectConverter;
|
||||||
|
|
||||||
|
namespace CodeWalker.GameFiles
|
||||||
|
{
|
||||||
|
[TC(typeof(EXP))] public class DistantLightsFile : GameFile, PackedFile
|
||||||
|
{
|
||||||
|
public bool HD { get; set; } = true;
|
||||||
|
public uint GridSize { get; set; } = 32;
|
||||||
|
public uint CellSize { get; set; } = 512;
|
||||||
|
public uint CellCount { get; set; } = 1024;
|
||||||
|
public uint NodeCount { get; set; }
|
||||||
|
public uint PathCount { get; set; }
|
||||||
|
public uint[] PathIndices { get; set; } //CellCount
|
||||||
|
public uint[] PathCounts1 { get; set; } //CellCount
|
||||||
|
public uint[] PathCounts2 { get; set; } //CellCount
|
||||||
|
public DistantLightsNode[] Nodes { get; set; } //NodeCount
|
||||||
|
public DistantLightsPath[] Paths { get; set; } //PathCount
|
||||||
|
public DistantLightsCell[] Cells { get; set; } //CellCount (built from loaded data)
|
||||||
|
|
||||||
|
|
||||||
|
public DistantLightsFile() : base(null, GameFileType.DistantLights)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public DistantLightsFile(RpfFileEntry entry) : base(entry, GameFileType.DistantLights)
|
||||||
|
{
|
||||||
|
RpfFileEntry = entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Load(byte[] data, RpfFileEntry entry)
|
||||||
|
{
|
||||||
|
if (entry != null)
|
||||||
|
{
|
||||||
|
RpfFileEntry = entry;
|
||||||
|
Name = entry.Name;
|
||||||
|
|
||||||
|
if (!entry.NameLower.EndsWith("_hd.dat"))
|
||||||
|
{
|
||||||
|
HD = false;
|
||||||
|
GridSize = 16;
|
||||||
|
CellSize = 1024;
|
||||||
|
CellCount = 256;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using (MemoryStream ms = new MemoryStream(data))
|
||||||
|
{
|
||||||
|
DataReader r = new DataReader(ms, Endianess.BigEndian);
|
||||||
|
|
||||||
|
Read(r);
|
||||||
|
};
|
||||||
|
|
||||||
|
Loaded = true;
|
||||||
|
}
|
||||||
|
public byte[] Save()
|
||||||
|
{
|
||||||
|
MemoryStream s = new MemoryStream();
|
||||||
|
DataWriter w = new DataWriter(s);
|
||||||
|
|
||||||
|
Write(w);
|
||||||
|
|
||||||
|
var buf = new byte[s.Length];
|
||||||
|
s.Position = 0;
|
||||||
|
s.Read(buf, 0, buf.Length);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void Read(DataReader r)
|
||||||
|
{
|
||||||
|
NodeCount = r.ReadUInt32();
|
||||||
|
PathCount = r.ReadUInt32();
|
||||||
|
PathIndices = new uint[CellCount];
|
||||||
|
PathCounts1 = new uint[CellCount];
|
||||||
|
PathCounts2 = new uint[CellCount];
|
||||||
|
Nodes = new DistantLightsNode[NodeCount];
|
||||||
|
Paths = new DistantLightsPath[PathCount];
|
||||||
|
for (uint i = 0; i < CellCount; i++)
|
||||||
|
{
|
||||||
|
PathIndices[i] = r.ReadUInt32();
|
||||||
|
}
|
||||||
|
for (uint i = 0; i < CellCount; i++)
|
||||||
|
{
|
||||||
|
PathCounts1[i] = r.ReadUInt32();
|
||||||
|
}
|
||||||
|
for (uint i = 0; i < CellCount; i++)
|
||||||
|
{
|
||||||
|
PathCounts2[i] = r.ReadUInt32();
|
||||||
|
}
|
||||||
|
for (uint i = 0; i < NodeCount; i++)
|
||||||
|
{
|
||||||
|
Nodes[i] = new DistantLightsNode(r);
|
||||||
|
}
|
||||||
|
for (uint i = 0; i < PathCount; i++)
|
||||||
|
{
|
||||||
|
Paths[i] = new DistantLightsPath(r, HD);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BuildCells();
|
||||||
|
|
||||||
|
}
|
||||||
|
private void Write(DataWriter w)
|
||||||
|
{
|
||||||
|
w.Write(NodeCount);
|
||||||
|
w.Write(PathCount);
|
||||||
|
|
||||||
|
for (uint i = 0; i < CellCount; i++)
|
||||||
|
{
|
||||||
|
w.Write(PathIndices[i]);
|
||||||
|
}
|
||||||
|
for (uint i = 0; i < CellCount; i++)
|
||||||
|
{
|
||||||
|
w.Write(PathCounts1[i]);
|
||||||
|
}
|
||||||
|
for (uint i = 0; i < CellCount; i++)
|
||||||
|
{
|
||||||
|
w.Write(PathCounts2[i]);
|
||||||
|
}
|
||||||
|
for (uint i = 0; i < NodeCount; i++)
|
||||||
|
{
|
||||||
|
Nodes[i].Write(w);
|
||||||
|
}
|
||||||
|
for (uint i = 0; i < PathCount; i++)
|
||||||
|
{
|
||||||
|
Paths[i].Write(w, HD);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void BuildCells()
|
||||||
|
{
|
||||||
|
for (uint i = 0; i < PathCount; i++)
|
||||||
|
{
|
||||||
|
var path = Paths[i];
|
||||||
|
path.Nodes = new DistantLightsNode[path.NodeCount];
|
||||||
|
for (uint n = 0; n < path.NodeCount; n++)
|
||||||
|
{
|
||||||
|
path.Nodes[n] = Nodes[path.NodeIndex + n];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Cells = new DistantLightsCell[CellCount];
|
||||||
|
for (uint x = 0; x < GridSize; x++)
|
||||||
|
{
|
||||||
|
for (uint y = 0; y < GridSize; y++)
|
||||||
|
{
|
||||||
|
var i = x * GridSize + y;
|
||||||
|
var cell = new DistantLightsCell();
|
||||||
|
cell.Index = i;
|
||||||
|
cell.CellX = x;
|
||||||
|
cell.CellY = y;
|
||||||
|
cell.CellMin = new Vector2(x, y) * CellSize - 8192.0f;
|
||||||
|
cell.CellMax = cell.CellMin + CellSize;
|
||||||
|
var pc1 = PathCounts1[i];
|
||||||
|
if (pc1 > 0)
|
||||||
|
{
|
||||||
|
cell.Paths1 = new DistantLightsPath[pc1];
|
||||||
|
for (uint l = 0; l < pc1; l++)
|
||||||
|
{
|
||||||
|
cell.Paths1[l] = Paths[PathIndices[i] + l];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var pc2 = PathCounts2[i];
|
||||||
|
if (pc2 > 0)
|
||||||
|
{
|
||||||
|
cell.Paths2 = new DistantLightsPath[pc2];
|
||||||
|
for (uint l = 0; l < pc2; l++)
|
||||||
|
{
|
||||||
|
cell.Paths2[l] = Paths[PathIndices[i] + l + pc1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Cells[i] = cell;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[TC(typeof(EXP))] public class DistantLightsNode
|
||||||
|
{
|
||||||
|
public short X { get; set; }
|
||||||
|
public short Y { get; set; }
|
||||||
|
public short Z { get; set; }
|
||||||
|
|
||||||
|
public DistantLightsNode()
|
||||||
|
{ }
|
||||||
|
public DistantLightsNode(DataReader r)
|
||||||
|
{
|
||||||
|
Read(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Read(DataReader r)
|
||||||
|
{
|
||||||
|
X = r.ReadInt16();
|
||||||
|
Y = r.ReadInt16();
|
||||||
|
Z = r.ReadInt16();
|
||||||
|
}
|
||||||
|
public void Write(DataWriter w)
|
||||||
|
{
|
||||||
|
w.Write(X);
|
||||||
|
w.Write(Y);
|
||||||
|
w.Write(Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 Vector
|
||||||
|
{
|
||||||
|
get { return new Vector3(X, Y, Z); }
|
||||||
|
set { X = (short)Math.Round(value.X); Y = (short)Math.Round(value.Y); Z = (short)Math.Round(value.Z); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Vector.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TC(typeof(EXP))] public class DistantLightsPath
|
||||||
|
{
|
||||||
|
public short CenterX { get; set; }
|
||||||
|
public short CenterY { get; set; }
|
||||||
|
public ushort SizeX { get; set; }
|
||||||
|
public ushort SizeY { get; set; }
|
||||||
|
public ushort NodeIndex { get; set; }
|
||||||
|
public ushort NodeCount { get; set; }
|
||||||
|
public ushort Short7 { get; set; }
|
||||||
|
public ushort Short8 { get; set; }
|
||||||
|
public float Float1 { get; set; }
|
||||||
|
public byte Byte1 { get; set; }
|
||||||
|
public byte Byte2 { get; set; }
|
||||||
|
public byte Byte3 { get; set; }
|
||||||
|
public byte Byte4 { get; set; }
|
||||||
|
|
||||||
|
public DistantLightsNode[] Nodes { get; set; }
|
||||||
|
|
||||||
|
public DistantLightsPath()
|
||||||
|
{ }
|
||||||
|
public DistantLightsPath(DataReader r, bool hd)
|
||||||
|
{
|
||||||
|
Read(r, hd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Read(DataReader r, bool hd)
|
||||||
|
{
|
||||||
|
CenterX = r.ReadInt16();
|
||||||
|
CenterY = r.ReadInt16();
|
||||||
|
SizeX = r.ReadUInt16();
|
||||||
|
SizeY = r.ReadUInt16();
|
||||||
|
NodeIndex = r.ReadUInt16();
|
||||||
|
NodeCount = r.ReadUInt16();
|
||||||
|
if (hd)
|
||||||
|
{
|
||||||
|
Short7 = r.ReadUInt16();
|
||||||
|
Short8 = r.ReadUInt16();
|
||||||
|
Float1 = r.ReadSingle();
|
||||||
|
Byte1 = r.ReadByte();
|
||||||
|
Byte2 = r.ReadByte();
|
||||||
|
Byte3 = r.ReadByte();
|
||||||
|
Byte4 = r.ReadByte();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Byte1 = r.ReadByte();
|
||||||
|
Byte2 = r.ReadByte();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Write(DataWriter w, bool hd)
|
||||||
|
{
|
||||||
|
w.Write(CenterX);
|
||||||
|
w.Write(CenterY);
|
||||||
|
w.Write(SizeX);
|
||||||
|
w.Write(SizeY);
|
||||||
|
w.Write(NodeIndex);
|
||||||
|
w.Write(NodeCount);
|
||||||
|
if (hd)
|
||||||
|
{
|
||||||
|
w.Write(Short7);
|
||||||
|
w.Write(Short8);
|
||||||
|
w.Write(Float1);
|
||||||
|
w.Write(Byte1);
|
||||||
|
w.Write(Byte2);
|
||||||
|
w.Write(Byte3);
|
||||||
|
w.Write(Byte4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
w.Write(Byte1);
|
||||||
|
w.Write(Byte2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return CenterX.ToString() + ", " + CenterY.ToString() + ", " + SizeX.ToString() + ", " + SizeY.ToString() + ", " +
|
||||||
|
NodeIndex.ToString() + ", " + NodeCount.ToString() + ", " + Short7.ToString() + ", " + Short8.ToString() + ", " +
|
||||||
|
FloatUtil.ToString(Float1) + ", " + Byte1.ToString() + ", " + Byte2.ToString() + ", " + Byte3.ToString() + ", " + Byte4.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TC(typeof(EXP))] public class DistantLightsCell
|
||||||
|
{
|
||||||
|
public uint Index { get; set; }
|
||||||
|
public uint CellX { get; set; }
|
||||||
|
public uint CellY { get; set; }
|
||||||
|
public Vector2 CellMin { get; set; }
|
||||||
|
public Vector2 CellMax { get; set; }
|
||||||
|
public DistantLightsPath[] Paths1 { get; set; }
|
||||||
|
public DistantLightsPath[] Paths2 { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Index.ToString() + " (" + CellX.ToString() + ", " + CellY.ToString() + ") - " +
|
||||||
|
(Paths1?.Length ?? 0).ToString() + ", " + (Paths2?.Length ?? 0).ToString() + " - (" +
|
||||||
|
CellMin.ToString() + " - " + CellMax.ToString() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace CodeWalker.GameFiles
|
namespace CodeWalker.GameFiles
|
||||||
{
|
{
|
||||||
@ -56,10 +58,68 @@ namespace CodeWalker.GameFiles
|
|||||||
InitDictionaries();
|
InitDictionaries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] Save()
|
||||||
|
{
|
||||||
|
byte[] data = ResourceBuilder.Build(ExpressionDictionary, 25); //yed is type/version 25...
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void InitDictionaries()
|
public void InitDictionaries()
|
||||||
{
|
{
|
||||||
ExprMap = ExpressionDictionary?.ExprMap ?? new Dictionary<MetaHash, Expression>();
|
ExprMap = ExpressionDictionary?.ExprMap ?? new Dictionary<MetaHash, Expression>();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class YedXml : MetaXmlBase
|
||||||
|
{
|
||||||
|
|
||||||
|
public static string GetXml(YedFile yed, string outputFolder = "")
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendLine(XmlHeader);
|
||||||
|
|
||||||
|
if (yed?.ExpressionDictionary != null)
|
||||||
|
{
|
||||||
|
ExpressionDictionary.WriteXmlNode(yed.ExpressionDictionary, sb, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class XmlYed
|
||||||
|
{
|
||||||
|
|
||||||
|
public static YedFile GetYed(string xml, string inputFolder = "")
|
||||||
|
{
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
doc.LoadXml(xml);
|
||||||
|
return GetYed(doc, inputFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YedFile GetYed(XmlDocument doc, string inputFolder = "")
|
||||||
|
{
|
||||||
|
YedFile r = new YedFile();
|
||||||
|
|
||||||
|
var node = doc.DocumentElement;
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
r.ExpressionDictionary = ExpressionDictionary.ReadXmlNode(node);
|
||||||
|
|
||||||
|
r.InitDictionaries();
|
||||||
|
}
|
||||||
|
|
||||||
|
r.Name = Path.GetFileName(inputFolder);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace CodeWalker.GameFiles
|
namespace CodeWalker.GameFiles
|
||||||
{
|
{
|
||||||
@ -58,4 +60,51 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class YvrXml : MetaXmlBase
|
||||||
|
{
|
||||||
|
|
||||||
|
public static string GetXml(YvrFile yvr)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendLine(XmlHeader);
|
||||||
|
|
||||||
|
if (yvr?.Records != null)
|
||||||
|
{
|
||||||
|
VehicleRecordList.WriteXmlNode(yvr.Records, sb, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class XmlYvr
|
||||||
|
{
|
||||||
|
|
||||||
|
public static YvrFile GetYvr(string xml, string inputFolder = "")
|
||||||
|
{
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
doc.LoadXml(xml);
|
||||||
|
return GetYvr(doc, inputFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YvrFile GetYvr(XmlDocument doc, string inputFolder = "")
|
||||||
|
{
|
||||||
|
YvrFile r = new YvrFile();
|
||||||
|
|
||||||
|
var node = doc.DocumentElement;
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
r.Records = VehicleRecordList.ReadXmlNode(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
r.Name = Path.GetFileName(inputFolder);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace CodeWalker.GameFiles
|
namespace CodeWalker.GameFiles
|
||||||
{
|
{
|
||||||
@ -58,4 +60,52 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class YwrXml : MetaXmlBase
|
||||||
|
{
|
||||||
|
|
||||||
|
public static string GetXml(YwrFile ywr)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendLine(XmlHeader);
|
||||||
|
|
||||||
|
if (ywr?.Waypoints != null)
|
||||||
|
{
|
||||||
|
WaypointRecordList.WriteXmlNode(ywr.Waypoints, sb, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class XmlYwr
|
||||||
|
{
|
||||||
|
|
||||||
|
public static YwrFile GetYwr(string xml, string inputFolder = "")
|
||||||
|
{
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
doc.LoadXml(xml);
|
||||||
|
return GetYwr(doc, inputFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YwrFile GetYwr(XmlDocument doc, string inputFolder = "")
|
||||||
|
{
|
||||||
|
YwrFile r = new YwrFile();
|
||||||
|
|
||||||
|
var node = doc.DocumentElement;
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
r.Waypoints = WaypointRecordList.ReadXmlNode(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
r.Name = Path.GetFileName(inputFolder);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ namespace CodeWalker.GameFiles
|
|||||||
Heightmap = 27,
|
Heightmap = 27,
|
||||||
Watermap = 28,
|
Watermap = 28,
|
||||||
Mrf = 29,
|
Mrf = 29,
|
||||||
|
DistantLights = 30,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,6 +212,8 @@ namespace CodeWalker.GameFiles
|
|||||||
//TestYfts();
|
//TestYfts();
|
||||||
//TestYpts();
|
//TestYpts();
|
||||||
//TestYnvs();
|
//TestYnvs();
|
||||||
|
//TestYvrs();
|
||||||
|
//TestYwrs();
|
||||||
//TestYmaps();
|
//TestYmaps();
|
||||||
//TestMrfs();
|
//TestMrfs();
|
||||||
//TestPlacements();
|
//TestPlacements();
|
||||||
@ -3518,6 +3520,15 @@ namespace CodeWalker.GameFiles
|
|||||||
YedFile yed = new YedFile(rfe);
|
YedFile yed = new YedFile(rfe);
|
||||||
RpfMan.LoadFile(yed, rfe);
|
RpfMan.LoadFile(yed, rfe);
|
||||||
|
|
||||||
|
var xml = YedXml.GetXml(yed);
|
||||||
|
var yed2 = XmlYed.GetYed(xml);
|
||||||
|
var data2 = yed2.Save();
|
||||||
|
var yed3 = new YedFile();
|
||||||
|
RpfFile.LoadResourceFile(yed3, data2, 25);//full roundtrip
|
||||||
|
var xml2 = YedXml.GetXml(yed3);
|
||||||
|
if (xml != xml2)
|
||||||
|
{ }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
@ -4396,6 +4407,102 @@ namespace CodeWalker.GameFiles
|
|||||||
if (errorfiles.Count > 0)
|
if (errorfiles.Count > 0)
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
public void TestYvrs()
|
||||||
|
{
|
||||||
|
|
||||||
|
var exceptions = new List<Exception>();
|
||||||
|
|
||||||
|
foreach (RpfFile file in AllRpfs)
|
||||||
|
{
|
||||||
|
foreach (RpfEntry entry in file.AllEntries)
|
||||||
|
{
|
||||||
|
#if !DEBUG
|
||||||
|
try
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
var rfe = entry as RpfFileEntry;
|
||||||
|
if (rfe == null) continue;
|
||||||
|
|
||||||
|
if (rfe.NameLower.EndsWith(".yvr"))
|
||||||
|
{
|
||||||
|
if (rfe.NameLower == "agencyprep001.yvr") continue; //this file seems corrupted
|
||||||
|
|
||||||
|
UpdateStatus(string.Format(entry.Path));
|
||||||
|
|
||||||
|
YvrFile yvr = new YvrFile(rfe);
|
||||||
|
RpfMan.LoadFile(yvr, rfe);
|
||||||
|
|
||||||
|
var xml = YvrXml.GetXml(yvr);
|
||||||
|
var yvr2 = XmlYvr.GetYvr(xml);
|
||||||
|
var data2 = yvr2.Save();
|
||||||
|
var yvr3 = new YvrFile();
|
||||||
|
RpfFile.LoadResourceFile(yvr3, data2, 1);//full roundtrip
|
||||||
|
var xml2 = YvrXml.GetXml(yvr3);
|
||||||
|
if (xml != xml2)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if !DEBUG
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
UpdateStatus("Error! " + ex.ToString());
|
||||||
|
exceptions.Add(ex);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exceptions.Count > 0)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
public void TestYwrs()
|
||||||
|
{
|
||||||
|
|
||||||
|
var exceptions = new List<Exception>();
|
||||||
|
|
||||||
|
foreach (RpfFile file in AllRpfs)
|
||||||
|
{
|
||||||
|
foreach (RpfEntry entry in file.AllEntries)
|
||||||
|
{
|
||||||
|
#if !DEBUG
|
||||||
|
try
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
var rfe = entry as RpfFileEntry;
|
||||||
|
if (rfe == null) continue;
|
||||||
|
|
||||||
|
if (rfe.NameLower.EndsWith(".ywr"))
|
||||||
|
{
|
||||||
|
UpdateStatus(string.Format(entry.Path));
|
||||||
|
|
||||||
|
YwrFile ywr = new YwrFile(rfe);
|
||||||
|
RpfMan.LoadFile(ywr, rfe);
|
||||||
|
|
||||||
|
var xml = YwrXml.GetXml(ywr);
|
||||||
|
var ywr2 = XmlYwr.GetYwr(xml);
|
||||||
|
var data2 = ywr2.Save();
|
||||||
|
var ywr3 = new YwrFile();
|
||||||
|
RpfFile.LoadResourceFile(ywr3, data2, 1);//full roundtrip
|
||||||
|
var xml2 = YwrXml.GetXml(ywr3);
|
||||||
|
if (xml != xml2)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if !DEBUG
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
UpdateStatus("Error! " + ex.ToString());
|
||||||
|
exceptions.Add(ex);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exceptions.Count > 0)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
public void TestYmaps()
|
public void TestYmaps()
|
||||||
{
|
{
|
||||||
foreach (RpfFile file in AllRpfs)
|
foreach (RpfFile file in AllRpfs)
|
||||||
|
@ -18617,6 +18617,91 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//MRF related hashes from Disquse
|
||||||
|
statemachine = 429383484,
|
||||||
|
success = 975994832,
|
||||||
|
cutting = 1599956773,
|
||||||
|
leftfailure = 1765753571,
|
||||||
|
enterfinish = 663756144,
|
||||||
|
approach = 61579965,
|
||||||
|
win = 3732660434,
|
||||||
|
loss = 42942348,
|
||||||
|
altwalk = 2629052680,
|
||||||
|
standidle = 1244639780,
|
||||||
|
bottlehold = 1250922115,
|
||||||
|
bottleshake = 2761060053,
|
||||||
|
champagnespray = 2153350042,
|
||||||
|
back = 927041140,
|
||||||
|
front = 2314350754,
|
||||||
|
partone = 1335537449,
|
||||||
|
parttwo = 2585437493,
|
||||||
|
partthree = 3894308744,
|
||||||
|
partfour = 4103663607,
|
||||||
|
partfive = 288022579,
|
||||||
|
backpartone = 3350093298,
|
||||||
|
backparttwo = 3195341626,
|
||||||
|
backpartthree = 3228129062,
|
||||||
|
backpartfour = 1672309095,
|
||||||
|
backpartfive = 3417257801,
|
||||||
|
wobble = 3603821314,
|
||||||
|
x_axis = 3546530265,
|
||||||
|
y_axis = 2645075825,
|
||||||
|
z_axis = 1604254135,
|
||||||
|
drill_force = 1362721915,
|
||||||
|
shake_intensity = 612782192,
|
||||||
|
horizontal_aim = 3036116190,
|
||||||
|
verticle_aim = 3709155216,
|
||||||
|
direction_up_down = 1282217224,
|
||||||
|
phase_out = 3243435260,
|
||||||
|
upperbodyonoff = 2718654972,
|
||||||
|
introphase = 3905075704,
|
||||||
|
pitch = 1061927116,
|
||||||
|
isblocked = 2611301023,
|
||||||
|
isfirstperson = 1776409970,
|
||||||
|
idle2 = 2046496619,
|
||||||
|
idle3 = 2202608135,
|
||||||
|
idle4 = 1261318610,
|
||||||
|
lossfinished = 2337837154,
|
||||||
|
winfinished = 3589054106,
|
||||||
|
introfinished = 3677288433,
|
||||||
|
outrofinished = 601717917,
|
||||||
|
leftfailfinish = 1788424853,
|
||||||
|
readyforfadein = 3896574076,
|
||||||
|
idlestarted = 1321201090,
|
||||||
|
blendout = 1842457532,
|
||||||
|
idle_a = 3851133436,
|
||||||
|
escape = 3655182927,
|
||||||
|
upperbodyclipended = 3141014298,
|
||||||
|
result_perfect = 2007828787,
|
||||||
|
result_good = 1148916770,
|
||||||
|
result_average = 1939741573,
|
||||||
|
result_bad = 1402208964,
|
||||||
|
perfectresult = 452682106,
|
||||||
|
goodresult = 1109180461,
|
||||||
|
averageresult = 2674371639,
|
||||||
|
badresult = 3234678822,
|
||||||
|
cancelneutral = 3758646108,
|
||||||
|
dance = 1152043290,
|
||||||
|
stage_1_loop = 2623060900,
|
||||||
|
stage_2_loop = 3632312862,
|
||||||
|
stage_3_loop = 125163859,
|
||||||
|
stage_4_loop = 931907947,
|
||||||
|
no_bag = 429567348,
|
||||||
|
nomover_filter = 819979025,
|
||||||
|
botharms_filter = 384947232,
|
||||||
|
rightarm_nospine_filter = 1924927269,
|
||||||
|
upperbodyfeathered_filter = 265147401,
|
||||||
|
ignoremoverblend_filter = 2738335535,
|
||||||
|
upperbodyandik_filter = 4248997943,
|
||||||
|
bonemask_head_neck_and_l_arm = 3177231635,
|
||||||
|
bonemask_head_neck_and_r_arm = 3921347753,
|
||||||
|
bonemask_head_neck_and_arms = 1573924551,
|
||||||
|
bonemask_headonly = 697476694,
|
||||||
|
bonemask_upperonly = 3633914286,
|
||||||
|
bonemask_armonly_l = 1739926164,
|
||||||
|
bonemask_armonly_r = 3772128476,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,7 +105,22 @@ namespace CodeWalker.GameFiles
|
|||||||
else if (fnl.EndsWith(".yld"))
|
else if (fnl.EndsWith(".yld"))
|
||||||
{
|
{
|
||||||
YldFile yld = RpfFile.GetFile<YldFile>(e, data);
|
YldFile yld = RpfFile.GetFile<YldFile>(e, data);
|
||||||
return GetXml(yld, out filename, outputfolder);
|
return GetXml(yld, out filename);
|
||||||
|
}
|
||||||
|
else if (fnl.EndsWith(".yed"))
|
||||||
|
{
|
||||||
|
YedFile yed = RpfFile.GetFile<YedFile>(e, data);
|
||||||
|
return GetXml(yed, out filename);
|
||||||
|
}
|
||||||
|
else if (fnl.EndsWith(".ywr"))
|
||||||
|
{
|
||||||
|
YwrFile ywr = RpfFile.GetFile<YwrFile>(e, data);
|
||||||
|
return GetXml(ywr, out filename);
|
||||||
|
}
|
||||||
|
else if (fnl.EndsWith(".yvr"))
|
||||||
|
{
|
||||||
|
YvrFile yvr = RpfFile.GetFile<YvrFile>(e, data);
|
||||||
|
return GetXml(yvr, out filename);
|
||||||
}
|
}
|
||||||
else if (fnl.EndsWith(".awc"))
|
else if (fnl.EndsWith(".awc"))
|
||||||
{
|
{
|
||||||
@ -235,11 +250,29 @@ namespace CodeWalker.GameFiles
|
|||||||
filename = fn + ".xml";
|
filename = fn + ".xml";
|
||||||
return YptXml.GetXml(ypt, outputfolder);
|
return YptXml.GetXml(ypt, outputfolder);
|
||||||
}
|
}
|
||||||
public static string GetXml(YldFile yld, out string filename, string outputfolder)
|
public static string GetXml(YldFile yld, out string filename)
|
||||||
{
|
{
|
||||||
var fn = (yld?.Name) ?? "";
|
var fn = (yld?.Name) ?? "";
|
||||||
filename = fn + ".xml";
|
filename = fn + ".xml";
|
||||||
return YldXml.GetXml(yld, outputfolder);
|
return YldXml.GetXml(yld);
|
||||||
|
}
|
||||||
|
public static string GetXml(YedFile yed, out string filename)
|
||||||
|
{
|
||||||
|
var fn = (yed?.Name) ?? "";
|
||||||
|
filename = fn + ".xml";
|
||||||
|
return YedXml.GetXml(yed);
|
||||||
|
}
|
||||||
|
public static string GetXml(YwrFile ywr, out string filename)
|
||||||
|
{
|
||||||
|
var fn = (ywr?.Name) ?? "";
|
||||||
|
filename = fn + ".xml";
|
||||||
|
return YwrXml.GetXml(ywr);
|
||||||
|
}
|
||||||
|
public static string GetXml(YvrFile yvr, out string filename)
|
||||||
|
{
|
||||||
|
var fn = (yvr?.Name) ?? "";
|
||||||
|
filename = fn + ".xml";
|
||||||
|
return YvrXml.GetXml(yvr);
|
||||||
}
|
}
|
||||||
public static string GetXml(AwcFile awc, out string filename, string outputfolder)
|
public static string GetXml(AwcFile awc, out string filename, string outputfolder)
|
||||||
{
|
{
|
||||||
@ -2169,8 +2202,11 @@ namespace CodeWalker.GameFiles
|
|||||||
Yft = 13,
|
Yft = 13,
|
||||||
Ypt = 14,
|
Ypt = 14,
|
||||||
Yld = 15,
|
Yld = 15,
|
||||||
Awc = 16,
|
Yed = 16,
|
||||||
Heightmap = 17,
|
Ywr = 17,
|
||||||
|
Yvr = 18,
|
||||||
|
Awc = 19,
|
||||||
|
Heightmap = 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,10 @@
|
|||||||
using System;
|
using SharpDX;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace CodeWalker.GameFiles
|
namespace CodeWalker.GameFiles
|
||||||
{
|
{
|
||||||
@ -11,7 +13,7 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
public override long BlockLength => 0x20;
|
public override long BlockLength => 0x20;
|
||||||
|
|
||||||
public ResourceSimpleList64<VehicleRecordEntry> Entries;
|
public ResourceSimpleList64<VehicleRecordEntry> Entries { get; set; }
|
||||||
|
|
||||||
public VehicleRecordList()
|
public VehicleRecordList()
|
||||||
{
|
{
|
||||||
@ -24,13 +26,68 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
this.Entries = reader.ReadBlock<ResourceSimpleList64<VehicleRecordEntry>>();
|
this.Entries = reader.ReadBlock<ResourceSimpleList64<VehicleRecordEntry>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||||
{
|
{
|
||||||
base.Write(writer, parameters);
|
base.Write(writer, parameters);
|
||||||
|
|
||||||
writer.WriteBlock(this.Entries);
|
writer.WriteBlock(this.Entries);
|
||||||
}
|
}
|
||||||
|
public void WriteXml(StringBuilder sb, int indent)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Entries?.data_items != null)
|
||||||
|
{
|
||||||
|
foreach (var e in Entries.data_items)
|
||||||
|
{
|
||||||
|
YvrXml.OpenTag(sb, indent, "Item");
|
||||||
|
e.WriteXml(sb, indent + 1);
|
||||||
|
YvrXml.CloseTag(sb, indent, "Item");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void ReadXml(XmlNode node)
|
||||||
|
{
|
||||||
|
var entries = new List<VehicleRecordEntry>();
|
||||||
|
|
||||||
|
var inodes = node.SelectNodes("Item");
|
||||||
|
if (inodes != null)
|
||||||
|
{
|
||||||
|
foreach (XmlNode inode in inodes)
|
||||||
|
{
|
||||||
|
var e = new VehicleRecordEntry();
|
||||||
|
e.ReadXml(inode);
|
||||||
|
entries.Add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Entries = new ResourceSimpleList64<VehicleRecordEntry>();
|
||||||
|
Entries.data_items = entries.ToArray();
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void WriteXmlNode(VehicleRecordList l, StringBuilder sb, int indent, string name = "VehicleRecordList")
|
||||||
|
{
|
||||||
|
if (l == null) return;
|
||||||
|
if ((l.Entries?.data_items == null) || (l.Entries.data_items.Length == 0))
|
||||||
|
{
|
||||||
|
YvrXml.SelfClosingTag(sb, indent, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YvrXml.OpenTag(sb, indent, name);
|
||||||
|
l.WriteXml(sb, indent + 1);
|
||||||
|
YvrXml.CloseTag(sb, indent, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static VehicleRecordList ReadXmlNode(XmlNode node)
|
||||||
|
{
|
||||||
|
if (node == null) return null;
|
||||||
|
var l = new VehicleRecordList();
|
||||||
|
l.ReadXml(node);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override Tuple<long, IResourceBlock>[] GetParts()
|
public override Tuple<long, IResourceBlock>[] GetParts()
|
||||||
{
|
{
|
||||||
@ -50,22 +107,104 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
// structure data
|
// structure data
|
||||||
public uint Time;
|
public uint Time;
|
||||||
public short VelocityX;
|
public short VelocityX; //factor to convert to m/s is 273.0583 .. or 1/0.0036622214, or 32767/120
|
||||||
public short VelocityY;
|
public short VelocityY;
|
||||||
public short VelocityZ;
|
public short VelocityZ;
|
||||||
public sbyte RightX;
|
public sbyte RightX;
|
||||||
public sbyte RightY;
|
public sbyte RightY;
|
||||||
public sbyte RightZ;
|
public sbyte RightZ;
|
||||||
public sbyte TopX;
|
public sbyte ForwardX;
|
||||||
public sbyte TopY;
|
public sbyte ForwardY;
|
||||||
public sbyte TopZ;
|
public sbyte ForwardZ;
|
||||||
public byte SteeringAngle;
|
public sbyte SteeringAngle; // factor to convert to game angle is 20 (ie radians)
|
||||||
public byte GasPedalPower;
|
public sbyte GasPedalPower; //-100 to +100, negative = reverse
|
||||||
public byte BrakePedalPower;
|
public sbyte BrakePedalPower;//0 to 100
|
||||||
public byte HandbrakeUsed;
|
public byte HandbrakeUsed;//0 or 1
|
||||||
public float PositionX;
|
public Vector3 Position;
|
||||||
public float PositionY;
|
|
||||||
public float PositionZ;
|
public Vector3 Velocity
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new Vector3(VelocityX / 273.0583f, VelocityY / 273.0583f, VelocityZ / 273.0583f);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
VelocityX = (short)Math.Round(value.X * 273.0583f);
|
||||||
|
VelocityY = (short)Math.Round(value.Y * 273.0583f);
|
||||||
|
VelocityZ = (short)Math.Round(value.Z * 273.0583f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Vector3 Forward
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new Vector3(ForwardX / 127.0f, ForwardY / 127.0f, ForwardZ / 127.0f);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ForwardX = (sbyte)Math.Round(value.X * 127.0f);
|
||||||
|
ForwardY = (sbyte)Math.Round(value.Y * 127.0f);
|
||||||
|
ForwardZ = (sbyte)Math.Round(value.Z * 127.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Vector3 Right
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new Vector3(RightX / 127.0f, RightY / 127.0f, RightZ / 127.0f);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
RightX = (sbyte)Math.Round(value.X * 127.0f);
|
||||||
|
RightY = (sbyte)Math.Round(value.Y * 127.0f);
|
||||||
|
RightZ = (sbyte)Math.Round(value.Z * 127.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public float Steering
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SteeringAngle / 20.0f;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SteeringAngle = (sbyte)Math.Round(value * 20.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public float GasPedal
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GasPedalPower / 100.0f;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
GasPedalPower = (sbyte)Math.Round(value * 100.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public float BrakePedal
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return BrakePedalPower / 100.0f;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
BrakePedalPower = (sbyte)Math.Round(value * 100.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool Handbrake
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return HandbrakeUsed == 1;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
HandbrakeUsed = value ? (byte)1 : (byte)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||||
{
|
{
|
||||||
@ -77,18 +216,15 @@ namespace CodeWalker.GameFiles
|
|||||||
this.RightX = (sbyte)reader.ReadByte();
|
this.RightX = (sbyte)reader.ReadByte();
|
||||||
this.RightY = (sbyte)reader.ReadByte();
|
this.RightY = (sbyte)reader.ReadByte();
|
||||||
this.RightZ = (sbyte)reader.ReadByte();
|
this.RightZ = (sbyte)reader.ReadByte();
|
||||||
this.TopX = (sbyte)reader.ReadByte();
|
this.ForwardX = (sbyte)reader.ReadByte();
|
||||||
this.TopY = (sbyte)reader.ReadByte();
|
this.ForwardY = (sbyte)reader.ReadByte();
|
||||||
this.TopZ = (sbyte)reader.ReadByte();
|
this.ForwardZ = (sbyte)reader.ReadByte();
|
||||||
this.SteeringAngle = reader.ReadByte();
|
this.SteeringAngle = (sbyte)reader.ReadByte();
|
||||||
this.GasPedalPower = reader.ReadByte();
|
this.GasPedalPower = (sbyte)reader.ReadByte();
|
||||||
this.BrakePedalPower = reader.ReadByte();
|
this.BrakePedalPower = (sbyte)reader.ReadByte();
|
||||||
this.HandbrakeUsed = reader.ReadByte();
|
this.HandbrakeUsed = reader.ReadByte();
|
||||||
this.PositionX = reader.ReadSingle();
|
this.Position = reader.ReadVector3();
|
||||||
this.PositionY = reader.ReadSingle();
|
|
||||||
this.PositionZ = reader.ReadSingle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||||
{
|
{
|
||||||
// write structure data
|
// write structure data
|
||||||
@ -96,20 +232,43 @@ namespace CodeWalker.GameFiles
|
|||||||
writer.Write(this.VelocityX);
|
writer.Write(this.VelocityX);
|
||||||
writer.Write(this.VelocityY);
|
writer.Write(this.VelocityY);
|
||||||
writer.Write(this.VelocityZ);
|
writer.Write(this.VelocityZ);
|
||||||
writer.Write(this.RightX);
|
writer.Write((byte)this.RightX);
|
||||||
writer.Write(this.RightY);
|
writer.Write((byte)this.RightY);
|
||||||
writer.Write(this.RightZ);
|
writer.Write((byte)this.RightZ);
|
||||||
writer.Write(this.TopX);
|
writer.Write((byte)this.ForwardX);
|
||||||
writer.Write(this.TopY);
|
writer.Write((byte)this.ForwardY);
|
||||||
writer.Write(this.TopZ);
|
writer.Write((byte)this.ForwardZ);
|
||||||
writer.Write(this.SteeringAngle);
|
writer.Write((byte)this.SteeringAngle);
|
||||||
writer.Write(this.GasPedalPower);
|
writer.Write((byte)this.GasPedalPower);
|
||||||
writer.Write(this.BrakePedalPower);
|
writer.Write((byte)this.BrakePedalPower);
|
||||||
writer.Write(this.HandbrakeUsed);
|
writer.Write(this.HandbrakeUsed);
|
||||||
writer.Write(this.PositionX);
|
writer.Write(this.Position);
|
||||||
writer.Write(this.PositionY);
|
|
||||||
writer.Write(this.PositionZ);
|
|
||||||
}
|
}
|
||||||
|
public void WriteXml(StringBuilder sb, int indent)
|
||||||
|
{
|
||||||
|
YvrXml.ValueTag(sb, indent, "Time", Time.ToString());
|
||||||
|
YvrXml.SelfClosingTag(sb, indent, "Position " + FloatUtil.GetVector3XmlString(Position));
|
||||||
|
YvrXml.SelfClosingTag(sb, indent, "Velocity " + FloatUtil.GetVector3XmlString(Velocity));
|
||||||
|
YvrXml.SelfClosingTag(sb, indent, "Forward " + FloatUtil.GetVector3XmlString(Forward));
|
||||||
|
YvrXml.SelfClosingTag(sb, indent, "Right " + FloatUtil.GetVector3XmlString(Right));
|
||||||
|
YvrXml.ValueTag(sb, indent, "Steering", FloatUtil.ToString(Steering));
|
||||||
|
YvrXml.ValueTag(sb, indent, "GasPedal", FloatUtil.ToString(GasPedal));
|
||||||
|
YvrXml.ValueTag(sb, indent, "BrakePedal", FloatUtil.ToString(BrakePedal));
|
||||||
|
YvrXml.ValueTag(sb, indent, "Handbrake", Handbrake.ToString());
|
||||||
|
}
|
||||||
|
public void ReadXml(XmlNode node)
|
||||||
|
{
|
||||||
|
Time = Xml.GetChildUIntAttribute(node, "Time", "value");
|
||||||
|
Position = Xml.GetChildVector3Attributes(node, "Position");
|
||||||
|
Velocity = Xml.GetChildVector3Attributes(node, "Velocity");
|
||||||
|
Forward = Xml.GetChildVector3Attributes(node, "Forward");
|
||||||
|
Right = Xml.GetChildVector3Attributes(node, "Right");
|
||||||
|
Steering = Xml.GetChildFloatAttribute(node, "Steering", "value");
|
||||||
|
GasPedal = Xml.GetChildFloatAttribute(node, "GasPedal", "value");
|
||||||
|
BrakePedal = Xml.GetChildFloatAttribute(node, "BrakePedal", "value");
|
||||||
|
Handbrake = Xml.GetChildBoolAttribute(node, "Handbrake", "value");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using System;
|
using SharpDX;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace CodeWalker.GameFiles
|
namespace CodeWalker.GameFiles
|
||||||
{
|
{
|
||||||
@ -38,7 +40,6 @@ namespace CodeWalker.GameFiles
|
|||||||
this.EntriesCount
|
this.EntriesCount
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||||
{
|
{
|
||||||
base.Write(writer, parameters);
|
base.Write(writer, parameters);
|
||||||
@ -56,6 +57,61 @@ namespace CodeWalker.GameFiles
|
|||||||
writer.Write(this.Unknown_28h);
|
writer.Write(this.Unknown_28h);
|
||||||
writer.Write(this.Unknown_2Ch);
|
writer.Write(this.Unknown_2Ch);
|
||||||
}
|
}
|
||||||
|
public void WriteXml(StringBuilder sb, int indent)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Entries?.Data != null)
|
||||||
|
{
|
||||||
|
foreach (var e in Entries.Data)
|
||||||
|
{
|
||||||
|
YwrXml.OpenTag(sb, indent, "Item");
|
||||||
|
e.WriteXml(sb, indent + 1);
|
||||||
|
YwrXml.CloseTag(sb, indent, "Item");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void ReadXml(XmlNode node)
|
||||||
|
{
|
||||||
|
var entries = new List<WaypointRecordEntry>();
|
||||||
|
|
||||||
|
var inodes = node.SelectNodes("Item");
|
||||||
|
if (inodes != null)
|
||||||
|
{
|
||||||
|
foreach (XmlNode inode in inodes)
|
||||||
|
{
|
||||||
|
var e = new WaypointRecordEntry();
|
||||||
|
e.ReadXml(inode);
|
||||||
|
entries.Add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Entries = new ResourceSimpleArray<WaypointRecordEntry>();
|
||||||
|
Entries.Data = entries;
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void WriteXmlNode(WaypointRecordList l, StringBuilder sb, int indent, string name = "WaypointRecordList")
|
||||||
|
{
|
||||||
|
if (l == null) return;
|
||||||
|
if ((l.Entries?.Data == null) || (l.Entries.Data.Count == 0))
|
||||||
|
{
|
||||||
|
YwrXml.SelfClosingTag(sb, indent, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YwrXml.OpenTag(sb, indent, name);
|
||||||
|
l.WriteXml(sb, indent + 1);
|
||||||
|
YwrXml.CloseTag(sb, indent, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static WaypointRecordList ReadXmlNode(XmlNode node)
|
||||||
|
{
|
||||||
|
if (node == null) return null;
|
||||||
|
var l = new WaypointRecordList();
|
||||||
|
l.ReadXml(node);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override IResourceBlock[] GetReferences()
|
public override IResourceBlock[] GetReferences()
|
||||||
{
|
{
|
||||||
@ -70,9 +126,7 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
public override long BlockLength => 20;
|
public override long BlockLength => 20;
|
||||||
|
|
||||||
public float PositionX;
|
public Vector3 Position;
|
||||||
public float PositionY;
|
|
||||||
public float PositionZ;
|
|
||||||
public ushort Unk0;
|
public ushort Unk0;
|
||||||
public ushort Unk1;
|
public ushort Unk1;
|
||||||
public ushort Unk2;
|
public ushort Unk2;
|
||||||
@ -81,26 +135,38 @@ namespace CodeWalker.GameFiles
|
|||||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||||
{
|
{
|
||||||
// read structure data
|
// read structure data
|
||||||
this.PositionX = reader.ReadSingle();
|
this.Position = reader.ReadVector3();
|
||||||
this.PositionY = reader.ReadSingle();
|
|
||||||
this.PositionZ = reader.ReadSingle();
|
|
||||||
this.Unk0 = reader.ReadUInt16();
|
this.Unk0 = reader.ReadUInt16();
|
||||||
this.Unk1 = reader.ReadUInt16();
|
this.Unk1 = reader.ReadUInt16();
|
||||||
this.Unk2 = reader.ReadUInt16();
|
this.Unk2 = reader.ReadUInt16();
|
||||||
this.Unk3 = reader.ReadUInt16();
|
this.Unk3 = reader.ReadUInt16();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||||
{
|
{
|
||||||
// write structure data
|
// write structure data
|
||||||
writer.Write(this.PositionX);
|
writer.Write(this.Position);
|
||||||
writer.Write(this.PositionY);
|
|
||||||
writer.Write(this.PositionZ);
|
|
||||||
writer.Write(this.Unk0);
|
writer.Write(this.Unk0);
|
||||||
writer.Write(this.Unk1);
|
writer.Write(this.Unk1);
|
||||||
writer.Write(this.Unk2);
|
writer.Write(this.Unk2);
|
||||||
writer.Write(this.Unk3);
|
writer.Write(this.Unk3);
|
||||||
}
|
}
|
||||||
|
public void WriteXml(StringBuilder sb, int indent)
|
||||||
|
{
|
||||||
|
YwrXml.SelfClosingTag(sb, indent, "Position " + FloatUtil.GetVector3XmlString(Position));
|
||||||
|
YwrXml.ValueTag(sb, indent, "Unk0", Unk0.ToString());
|
||||||
|
YwrXml.ValueTag(sb, indent, "Unk1", Unk1.ToString());
|
||||||
|
YwrXml.ValueTag(sb, indent, "Unk2", Unk2.ToString());
|
||||||
|
YwrXml.ValueTag(sb, indent, "Unk3", Unk3.ToString());
|
||||||
|
}
|
||||||
|
public void ReadXml(XmlNode node)
|
||||||
|
{
|
||||||
|
Position = Xml.GetChildVector3Attributes(node, "Position");
|
||||||
|
Unk0 = (ushort)Xml.GetChildUIntAttribute(node, "Unk0", "value");
|
||||||
|
Unk1 = (ushort)Xml.GetChildUIntAttribute(node, "Unk1", "value");
|
||||||
|
Unk2 = (ushort)Xml.GetChildUIntAttribute(node, "Unk2", "value");
|
||||||
|
Unk3 = (ushort)Xml.GetChildUIntAttribute(node, "Unk3", "value");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,10 +276,10 @@ namespace CodeWalker
|
|||||||
InitFileType(".gfx", "Scaleform Flash", 7);
|
InitFileType(".gfx", "Scaleform Flash", 7);
|
||||||
InitFileType(".ynd", "Path Nodes", 8, FileTypeAction.ViewYnd, true);
|
InitFileType(".ynd", "Path Nodes", 8, FileTypeAction.ViewYnd, true);
|
||||||
InitFileType(".ynv", "Nav Mesh", 9, FileTypeAction.ViewModel, true);
|
InitFileType(".ynv", "Nav Mesh", 9, FileTypeAction.ViewModel, true);
|
||||||
InitFileType(".yvr", "Vehicle Record", 9, FileTypeAction.ViewYvr);
|
InitFileType(".yvr", "Vehicle Record", 9, FileTypeAction.ViewYvr, true);
|
||||||
InitFileType(".ywr", "Waypoint Record", 9, FileTypeAction.ViewYwr);
|
InitFileType(".ywr", "Waypoint Record", 9, FileTypeAction.ViewYwr, true);
|
||||||
InitFileType(".fxc", "Compiled Shaders", 9, FileTypeAction.ViewFxc);
|
InitFileType(".fxc", "Compiled Shaders", 9, FileTypeAction.ViewFxc);
|
||||||
InitFileType(".yed", "Expression Dictionary", 9, FileTypeAction.ViewYed);
|
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);
|
||||||
InitFileType(".asi", "ASI Plugin", 9);
|
InitFileType(".asi", "ASI Plugin", 9);
|
||||||
@ -313,6 +313,8 @@ namespace CodeWalker
|
|||||||
InitSubFileType(".dat", "cache_y.dat", "Cache File", 6, FileTypeAction.ViewCacheDat, true);
|
InitSubFileType(".dat", "cache_y.dat", "Cache File", 6, FileTypeAction.ViewCacheDat, true);
|
||||||
InitSubFileType(".dat", "heightmap.dat", "Heightmap", 6, FileTypeAction.ViewHeightmap, true);
|
InitSubFileType(".dat", "heightmap.dat", "Heightmap", 6, FileTypeAction.ViewHeightmap, true);
|
||||||
InitSubFileType(".dat", "heightmapheistisland.dat", "Heightmap", 6, FileTypeAction.ViewHeightmap, true);
|
InitSubFileType(".dat", "heightmapheistisland.dat", "Heightmap", 6, FileTypeAction.ViewHeightmap, true);
|
||||||
|
InitSubFileType(".dat", "distantlights.dat", "Distant Lights", 6, FileTypeAction.ViewDistantLights);
|
||||||
|
InitSubFileType(".dat", "distantlights_hd.dat", "Distant Lights", 6, FileTypeAction.ViewDistantLights);
|
||||||
}
|
}
|
||||||
private void InitFileType(string ext, string name, int imgidx, FileTypeAction defaultAction = FileTypeAction.ViewHex, bool xmlConvertible = false)
|
private void InitFileType(string ext, string name, int imgidx, FileTypeAction defaultAction = FileTypeAction.ViewHex, bool xmlConvertible = false)
|
||||||
{
|
{
|
||||||
@ -1404,6 +1406,7 @@ namespace CodeWalker
|
|||||||
case FileTypeAction.ViewYfd:
|
case FileTypeAction.ViewYfd:
|
||||||
case FileTypeAction.ViewHeightmap:
|
case FileTypeAction.ViewHeightmap:
|
||||||
case FileTypeAction.ViewMrf:
|
case FileTypeAction.ViewMrf:
|
||||||
|
case FileTypeAction.ViewDistantLights:
|
||||||
return true;
|
return true;
|
||||||
case FileTypeAction.ViewHex:
|
case FileTypeAction.ViewHex:
|
||||||
default:
|
default:
|
||||||
@ -1539,6 +1542,9 @@ namespace CodeWalker
|
|||||||
case FileTypeAction.ViewNametable:
|
case FileTypeAction.ViewNametable:
|
||||||
ViewNametable(name, path, data, fe);
|
ViewNametable(name, path, data, fe);
|
||||||
break;
|
break;
|
||||||
|
case FileTypeAction.ViewDistantLights:
|
||||||
|
ViewDistantLights(name, path, data, fe);
|
||||||
|
break;
|
||||||
case FileTypeAction.ViewHex:
|
case FileTypeAction.ViewHex:
|
||||||
default:
|
default:
|
||||||
ViewHex(name, path, data);
|
ViewHex(name, path, data);
|
||||||
@ -1748,16 +1754,16 @@ namespace CodeWalker
|
|||||||
private void ViewYed(string name, string path, byte[] data, RpfFileEntry e)
|
private void ViewYed(string name, string path, byte[] data, RpfFileEntry e)
|
||||||
{
|
{
|
||||||
var yed = RpfFile.GetFile<YedFile>(e, data);
|
var yed = RpfFile.GetFile<YedFile>(e, data);
|
||||||
GenericForm f = new GenericForm(this);
|
MetaForm f = new MetaForm(this);
|
||||||
f.Show();
|
f.Show();
|
||||||
f.LoadFile(yed, yed.RpfFileEntry);
|
f.LoadMeta(yed);
|
||||||
}
|
}
|
||||||
private void ViewYld(string name, string path, byte[] data, RpfFileEntry e)
|
private void ViewYld(string name, string path, byte[] data, RpfFileEntry e)
|
||||||
{
|
{
|
||||||
var yld = RpfFile.GetFile<YldFile>(e, data);
|
var yld = RpfFile.GetFile<YldFile>(e, data);
|
||||||
GenericForm f = new GenericForm(this);
|
MetaForm f = new MetaForm(this);
|
||||||
f.Show();
|
f.Show();
|
||||||
f.LoadFile(yld, yld.RpfFileEntry);
|
f.LoadMeta(yld);
|
||||||
}
|
}
|
||||||
private void ViewYfd(string name, string path, byte[] data, RpfFileEntry e)
|
private void ViewYfd(string name, string path, byte[] data, RpfFileEntry e)
|
||||||
{
|
{
|
||||||
@ -1793,6 +1799,13 @@ namespace CodeWalker
|
|||||||
f.Show();
|
f.Show();
|
||||||
f.LoadNametable(name, path, data, e);
|
f.LoadNametable(name, path, data, e);
|
||||||
}
|
}
|
||||||
|
private void ViewDistantLights(string name, string path, byte[] data, RpfFileEntry e)
|
||||||
|
{
|
||||||
|
var dlf = RpfFile.GetFile<DistantLightsFile>(e, data);
|
||||||
|
GenericForm f = new GenericForm(this);
|
||||||
|
f.Show();
|
||||||
|
f.LoadFile(dlf, dlf.RpfFileEntry);
|
||||||
|
}
|
||||||
|
|
||||||
private RpfFileEntry CreateFileEntry(string name, string path, ref byte[] data)
|
private RpfFileEntry CreateFileEntry(string name, string path, ref byte[] data)
|
||||||
{
|
{
|
||||||
@ -2741,6 +2754,18 @@ namespace CodeWalker
|
|||||||
{
|
{
|
||||||
mformat = MetaFormat.Yld;
|
mformat = MetaFormat.Yld;
|
||||||
}
|
}
|
||||||
|
if (fnamel.EndsWith(".yed.xml"))
|
||||||
|
{
|
||||||
|
mformat = MetaFormat.Yed;
|
||||||
|
}
|
||||||
|
if (fnamel.EndsWith(".ywr.xml"))
|
||||||
|
{
|
||||||
|
mformat = MetaFormat.Ywr;
|
||||||
|
}
|
||||||
|
if (fnamel.EndsWith(".yvr.xml"))
|
||||||
|
{
|
||||||
|
mformat = MetaFormat.Yvr;
|
||||||
|
}
|
||||||
if (fnamel.EndsWith(".awc.xml"))
|
if (fnamel.EndsWith(".awc.xml"))
|
||||||
{
|
{
|
||||||
mformat = MetaFormat.Awc;
|
mformat = MetaFormat.Awc;
|
||||||
@ -2924,6 +2949,39 @@ namespace CodeWalker
|
|||||||
data = yld.Save();
|
data = yld.Save();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MetaFormat.Yed:
|
||||||
|
{
|
||||||
|
var yed = XmlYed.GetYed(doc, fpathin);
|
||||||
|
if (yed.ExpressionDictionary == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show(fname + ": Schema not supported.", "Cannot import YED XML");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
data = yed.Save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MetaFormat.Ywr:
|
||||||
|
{
|
||||||
|
var ywr = XmlYwr.GetYwr(doc, fpathin);
|
||||||
|
if (ywr.Waypoints == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show(fname + ": Schema not supported.", "Cannot import YWR XML");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
data = ywr.Save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MetaFormat.Yvr:
|
||||||
|
{
|
||||||
|
var yvr = XmlYvr.GetYvr(doc, fpathin);
|
||||||
|
if (yvr.Records == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show(fname + ": Schema not supported.", "Cannot import YVR XML");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
data = yvr.Save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MetaFormat.Awc:
|
case MetaFormat.Awc:
|
||||||
{
|
{
|
||||||
var awc = XmlAwc.GetAwc(doc, fpathin);
|
var awc = XmlAwc.GetAwc(doc, fpathin);
|
||||||
@ -4819,6 +4877,7 @@ namespace CodeWalker
|
|||||||
ViewHeightmap = 23,
|
ViewHeightmap = 23,
|
||||||
ViewMrf = 24,
|
ViewMrf = 24,
|
||||||
ViewNametable = 25,
|
ViewNametable = 25,
|
||||||
|
ViewDistantLights = 26,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -318,6 +318,34 @@ namespace CodeWalker.Forms
|
|||||||
metaFormat = MetaFormat.Ynd;
|
metaFormat = MetaFormat.Ynd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void LoadMeta(YldFile yld)
|
||||||
|
{
|
||||||
|
var fn = ((yld?.RpfFileEntry?.Name) ?? "") + ".xml";
|
||||||
|
Xml = MetaXml.GetXml(yld, out fn);
|
||||||
|
FileName = fn;
|
||||||
|
RawPropertyGrid.SelectedObject = yld;
|
||||||
|
rpfFileEntry = yld?.RpfFileEntry;
|
||||||
|
modified = false;
|
||||||
|
metaFormat = MetaFormat.XML;
|
||||||
|
if (yld?.RpfFileEntry != null)
|
||||||
|
{
|
||||||
|
metaFormat = MetaFormat.Yld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void LoadMeta(YedFile yed)
|
||||||
|
{
|
||||||
|
var fn = ((yed?.RpfFileEntry?.Name) ?? "") + ".xml";
|
||||||
|
Xml = MetaXml.GetXml(yed, out fn);
|
||||||
|
FileName = fn;
|
||||||
|
RawPropertyGrid.SelectedObject = yed;
|
||||||
|
rpfFileEntry = yed?.RpfFileEntry;
|
||||||
|
modified = false;
|
||||||
|
metaFormat = MetaFormat.XML;
|
||||||
|
if (yed?.RpfFileEntry != null)
|
||||||
|
{
|
||||||
|
metaFormat = MetaFormat.Yed;
|
||||||
|
}
|
||||||
|
}
|
||||||
public void LoadMeta(CacheDatFile cachedat)
|
public void LoadMeta(CacheDatFile cachedat)
|
||||||
{
|
{
|
||||||
var fn = ((cachedat?.FileEntry?.Name) ?? "") + ".xml";
|
var fn = ((cachedat?.FileEntry?.Name) ?? "") + ".xml";
|
||||||
@ -404,6 +432,24 @@ namespace CodeWalker.Forms
|
|||||||
}
|
}
|
||||||
data = ynd.Save();
|
data = ynd.Save();
|
||||||
break;
|
break;
|
||||||
|
case MetaFormat.Yld:
|
||||||
|
var yld = XmlYld.GetYld(doc);
|
||||||
|
if (yld.ClothDictionary == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Schema not supported.", "Cannot import YLD XML");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
data = yld.Save();
|
||||||
|
break;
|
||||||
|
case MetaFormat.Yed:
|
||||||
|
var yed = XmlYed.GetYed(doc);
|
||||||
|
if (yed.ExpressionDictionary == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Schema not supported.", "Cannot import YED XML");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
data = yed.Save();
|
||||||
|
break;
|
||||||
case MetaFormat.CacheFile:
|
case MetaFormat.CacheFile:
|
||||||
MessageBox.Show("Sorry, CacheFile import is not supported.", "Cannot import CacheFile XML");
|
MessageBox.Show("Sorry, CacheFile import is not supported.", "Cannot import CacheFile XML");
|
||||||
return false;
|
return false;
|
||||||
|
36
CodeWalker/Forms/YvrForm.Designer.cs
generated
36
CodeWalker/Forms/YvrForm.Designer.cs
generated
@ -41,9 +41,9 @@
|
|||||||
this.RightXColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.RightXColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.RightYColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.RightYColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.RightZColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.RightZColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.TopXColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.ForwardXColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.TopYColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.ForwardYColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.TopZColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.ForwardZColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.SteeringAngleColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.SteeringAngleColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.GasPedalPowerColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.GasPedalPowerColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.BrakePedalPowerColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.BrakePedalPowerColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
@ -81,9 +81,9 @@
|
|||||||
this.RightXColumn,
|
this.RightXColumn,
|
||||||
this.RightYColumn,
|
this.RightYColumn,
|
||||||
this.RightZColumn,
|
this.RightZColumn,
|
||||||
this.TopXColumn,
|
this.ForwardXColumn,
|
||||||
this.TopYColumn,
|
this.ForwardYColumn,
|
||||||
this.TopZColumn,
|
this.ForwardZColumn,
|
||||||
this.SteeringAngleColumn,
|
this.SteeringAngleColumn,
|
||||||
this.GasPedalPowerColumn,
|
this.GasPedalPowerColumn,
|
||||||
this.BrakePedalPowerColumn,
|
this.BrakePedalPowerColumn,
|
||||||
@ -146,20 +146,20 @@
|
|||||||
this.RightZColumn.Text = "Right Z";
|
this.RightZColumn.Text = "Right Z";
|
||||||
this.RightZColumn.Width = 48;
|
this.RightZColumn.Width = 48;
|
||||||
//
|
//
|
||||||
// TopXColumn
|
// ForwardXColumn
|
||||||
//
|
//
|
||||||
this.TopXColumn.Text = "Top X";
|
this.ForwardXColumn.Text = "Fwd X";
|
||||||
this.TopXColumn.Width = 44;
|
this.ForwardXColumn.Width = 44;
|
||||||
//
|
//
|
||||||
// TopYColumn
|
// ForwardYColumn
|
||||||
//
|
//
|
||||||
this.TopYColumn.Text = "Top Y";
|
this.ForwardYColumn.Text = "Fwd Y";
|
||||||
this.TopYColumn.Width = 44;
|
this.ForwardYColumn.Width = 44;
|
||||||
//
|
//
|
||||||
// TopZColumn
|
// ForwardZColumn
|
||||||
//
|
//
|
||||||
this.TopZColumn.Text = "Top Z";
|
this.ForwardZColumn.Text = "Fwd Z";
|
||||||
this.TopZColumn.Width = 44;
|
this.ForwardZColumn.Width = 44;
|
||||||
//
|
//
|
||||||
// SteeringAngleColumn
|
// SteeringAngleColumn
|
||||||
//
|
//
|
||||||
@ -236,9 +236,9 @@
|
|||||||
private System.Windows.Forms.ColumnHeader RightXColumn;
|
private System.Windows.Forms.ColumnHeader RightXColumn;
|
||||||
private System.Windows.Forms.ColumnHeader RightYColumn;
|
private System.Windows.Forms.ColumnHeader RightYColumn;
|
||||||
private System.Windows.Forms.ColumnHeader RightZColumn;
|
private System.Windows.Forms.ColumnHeader RightZColumn;
|
||||||
private System.Windows.Forms.ColumnHeader TopXColumn;
|
private System.Windows.Forms.ColumnHeader ForwardXColumn;
|
||||||
private System.Windows.Forms.ColumnHeader TopYColumn;
|
private System.Windows.Forms.ColumnHeader ForwardYColumn;
|
||||||
private System.Windows.Forms.ColumnHeader TopZColumn;
|
private System.Windows.Forms.ColumnHeader ForwardZColumn;
|
||||||
private System.Windows.Forms.ColumnHeader SteeringAngleColumn;
|
private System.Windows.Forms.ColumnHeader SteeringAngleColumn;
|
||||||
private System.Windows.Forms.ColumnHeader GasPedalPowerColumn;
|
private System.Windows.Forms.ColumnHeader GasPedalPowerColumn;
|
||||||
private System.Windows.Forms.ColumnHeader BrakePedalPowerColumn;
|
private System.Windows.Forms.ColumnHeader BrakePedalPowerColumn;
|
||||||
|
@ -66,42 +66,42 @@ namespace CodeWalker.Forms
|
|||||||
private string GenerateText()
|
private string GenerateText()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.AppendLine("PositionX, PositionY, PositionZ, Time, VelocityX, VelocityY, VelocityZ, RightX, RightY, RightZ, TopX, TopY, TopZ, SteeringAngle, GasPedalPower, BrakePedalPower, HandbrakeUsed");
|
sb.AppendLine("PositionX, PositionY, PositionZ, Time, VelocityX, VelocityY, VelocityZ, RightX, RightY, RightZ, ForwardX, ForwardY, ForwardZ, SteeringAngle, GasPedalPower, BrakePedalPower, HandbrakeUsed");
|
||||||
foreach (var entry in yvr.Records.Entries.data_items)
|
foreach (var entry in yvr.Records.Entries.data_items)
|
||||||
{
|
{
|
||||||
sb.Append(FloatUtil.ToString(entry.PositionX));
|
sb.Append(FloatUtil.ToString(entry.Position.X));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(FloatUtil.ToString(entry.PositionY));
|
sb.Append(FloatUtil.ToString(entry.Position.Y));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(FloatUtil.ToString(entry.PositionZ));
|
sb.Append(FloatUtil.ToString(entry.Position.Z));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.Time.ToString());
|
sb.Append(entry.Time.ToString());
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.VelocityX.ToString());
|
sb.Append(FloatUtil.ToString(entry.Velocity.X));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.VelocityY.ToString());
|
sb.Append(FloatUtil.ToString(entry.Velocity.Y));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.VelocityZ.ToString());
|
sb.Append(FloatUtil.ToString(entry.Velocity.Z));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.RightX.ToString());
|
sb.Append(FloatUtil.ToString(entry.Right.X));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.RightY.ToString());
|
sb.Append(FloatUtil.ToString(entry.Right.Y));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.RightZ.ToString());
|
sb.Append(FloatUtil.ToString(entry.Right.Z));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.TopX.ToString());
|
sb.Append(FloatUtil.ToString(entry.Forward.X));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.TopY.ToString());
|
sb.Append(FloatUtil.ToString(entry.Forward.Y));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.TopZ.ToString());
|
sb.Append(FloatUtil.ToString(entry.Forward.Z));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.SteeringAngle.ToString());
|
sb.Append(FloatUtil.ToString(entry.Steering));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.GasPedalPower.ToString());
|
sb.Append(FloatUtil.ToString(entry.GasPedal));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.BrakePedalPower.ToString());
|
sb.Append(FloatUtil.ToString(entry.BrakePedal));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.HandbrakeUsed.ToString());
|
sb.Append(entry.Handbrake.ToString());
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
}
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
@ -114,23 +114,23 @@ namespace CodeWalker.Forms
|
|||||||
{
|
{
|
||||||
string[] row =
|
string[] row =
|
||||||
{
|
{
|
||||||
FloatUtil.ToString(entry.PositionX),
|
FloatUtil.ToString(entry.Position.X),
|
||||||
FloatUtil.ToString(entry.PositionY),
|
FloatUtil.ToString(entry.Position.Y),
|
||||||
FloatUtil.ToString(entry.PositionZ),
|
FloatUtil.ToString(entry.Position.Z),
|
||||||
entry.Time.ToString(),
|
entry.Time.ToString(),
|
||||||
entry.VelocityX.ToString(),
|
FloatUtil.ToString(entry.Velocity.X),
|
||||||
entry.VelocityY.ToString(),
|
FloatUtil.ToString(entry.Velocity.Y),
|
||||||
entry.VelocityZ.ToString(),
|
FloatUtil.ToString(entry.Velocity.Z),
|
||||||
entry.RightX.ToString(),
|
FloatUtil.ToString(entry.Right.X),
|
||||||
entry.RightY.ToString(),
|
FloatUtil.ToString(entry.Right.Y),
|
||||||
entry.RightZ.ToString(),
|
FloatUtil.ToString(entry.Right.Z),
|
||||||
entry.TopX.ToString(),
|
FloatUtil.ToString(entry.Forward.X),
|
||||||
entry.TopY.ToString(),
|
FloatUtil.ToString(entry.Forward.Y),
|
||||||
entry.TopZ.ToString(),
|
FloatUtil.ToString(entry.Forward.Z),
|
||||||
entry.SteeringAngle.ToString(),
|
FloatUtil.ToString(entry.Steering),
|
||||||
entry.GasPedalPower.ToString(),
|
FloatUtil.ToString(entry.GasPedal),
|
||||||
entry.BrakePedalPower.ToString(),
|
FloatUtil.ToString(entry.BrakePedal),
|
||||||
entry.HandbrakeUsed.ToString(),
|
entry.Handbrake.ToString(),
|
||||||
};
|
};
|
||||||
MainListView.Items.Add(new ListViewItem(row));
|
MainListView.Items.Add(new ListViewItem(row));
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,11 @@ namespace CodeWalker.Forms
|
|||||||
sb.AppendLine("PositionX, PositionY, PositionZ, Unk0, Unk1, Unk2, Unk3");
|
sb.AppendLine("PositionX, PositionY, PositionZ, Unk0, Unk1, Unk2, Unk3");
|
||||||
foreach (var entry in ywr.Waypoints.Entries)
|
foreach (var entry in ywr.Waypoints.Entries)
|
||||||
{
|
{
|
||||||
sb.Append(FloatUtil.ToString(entry.PositionX));
|
sb.Append(FloatUtil.ToString(entry.Position.X));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(FloatUtil.ToString(entry.PositionY));
|
sb.Append(FloatUtil.ToString(entry.Position.Y));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(FloatUtil.ToString(entry.PositionZ));
|
sb.Append(FloatUtil.ToString(entry.Position.Z));
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(entry.Unk0.ToString());
|
sb.Append(entry.Unk0.ToString());
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
@ -97,9 +97,9 @@ namespace CodeWalker.Forms
|
|||||||
{
|
{
|
||||||
string[] row =
|
string[] row =
|
||||||
{
|
{
|
||||||
FloatUtil.ToString(entry.PositionX),
|
FloatUtil.ToString(entry.Position.X),
|
||||||
FloatUtil.ToString(entry.PositionY),
|
FloatUtil.ToString(entry.Position.Y),
|
||||||
FloatUtil.ToString(entry.PositionZ),
|
FloatUtil.ToString(entry.Position.Z),
|
||||||
entry.Unk0.ToString(),
|
entry.Unk0.ToString(),
|
||||||
entry.Unk1.ToString(),
|
entry.Unk1.ToString(),
|
||||||
entry.Unk2.ToString(),
|
entry.Unk2.ToString(),
|
||||||
|
Loading…
Reference in New Issue
Block a user