Release v0.4.5.10
Some fixes and changes
This commit is contained in:
+396
-438
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.Types;
|
||||
using KKdMainLib.MessagePack;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib.A3DA
|
||||
{
|
||||
@@ -22,7 +22,7 @@ namespace KKdMainLib.A3DA
|
||||
private string nameView;
|
||||
private string value;
|
||||
private string[] dataArray;
|
||||
private Values UsedValues;
|
||||
private Dictionary<int?, double?> UsedValues;
|
||||
private Dictionary<string, object> Dict;
|
||||
|
||||
private bool IsX => Data.Header.Format == Main.Format.X || Data.Header.Format == Main.Format.XHD;
|
||||
@@ -32,7 +32,7 @@ namespace KKdMainLib.A3DA
|
||||
|
||||
public A3DA()
|
||||
{ Data = new A3DAData(); Dict = new Dictionary<string, object>();
|
||||
IO = File.OpenWriter(); UsedValues = new Values(); }
|
||||
IO = File.OpenWriter(); UsedValues = new Dictionary<int?, double?>(); }
|
||||
|
||||
public int A3DAReader(string file)
|
||||
{
|
||||
@@ -900,7 +900,7 @@ namespace KKdMainLib.A3DA
|
||||
IO.ReadKey(ref Data.CameraAuxiliary.Saturate , CompressF16);
|
||||
}
|
||||
|
||||
if (Data.CameraRoot != null)
|
||||
if (Data.CameraRoot != null)
|
||||
for (i0 = 0; i0 < Data.CameraRoot.Length; i0++)
|
||||
{
|
||||
IO.ReadMT(ref Data.CameraRoot[i0].MT , CompressF16);
|
||||
@@ -1006,7 +1006,7 @@ namespace KKdMainLib.A3DA
|
||||
{
|
||||
int i0 = 0;
|
||||
int i1 = 0;
|
||||
if (A3DCOpt) { UsedValues.BinOffset = new List<int?>(); UsedValues.Value = new List<double?>(); }
|
||||
if (A3DCOpt) UsedValues = new Dictionary<int?, double?>();
|
||||
|
||||
if (Data.Header.Format > Main.Format.FT)
|
||||
{
|
||||
@@ -1296,19 +1296,17 @@ namespace KKdMainLib.A3DA
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!UsedValues.Value.Contains(Key.Value) || !A3DCOpt)
|
||||
if (!UsedValues.ContainsValue(Key.Value) || !A3DCOpt)
|
||||
{
|
||||
Key.BinOffset = IO.Position;
|
||||
IO.Write( Key.Type );
|
||||
IO.Write((float?)Key.Value);
|
||||
if (A3DCOpt)
|
||||
{ UsedValues.BinOffset.Add(Key.BinOffset); UsedValues.Value.Add(Key.Value); }
|
||||
{ UsedValues.Add(Key.BinOffset, Key.Value); }
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < UsedValues.Value.Count; i++)
|
||||
if (UsedValues.Value[i] == Key.Value)
|
||||
{ Key.BinOffset = UsedValues.BinOffset[i]; return; }
|
||||
else if (UsedValues.ContainsValue(Key.Value))
|
||||
{ Key.BinOffset = UsedValues.GetKey(Key.Value); return; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1320,430 +1318,396 @@ namespace KKdMainLib.A3DA
|
||||
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
if (MsgPack.Element("A3D", out MsgPack A3D))
|
||||
if (!MsgPack.Element("A3D", out MsgPack A3D)) { MsgPack = null; return; }
|
||||
|
||||
Data.Header = new PDHead();
|
||||
Enum.TryParse(A3D.ReadString("Format"), out Data.Header.Format);
|
||||
MsgPack Temp = new MsgPack();
|
||||
|
||||
if (A3D.Element("_", out Temp))
|
||||
{
|
||||
Data.Header = new PDHead();
|
||||
Enum.TryParse(A3D.ReadString("Format"), out Data.Header.Format);
|
||||
MsgPack Temp = new MsgPack();
|
||||
|
||||
if (A3D.Element("_", out Temp))
|
||||
Data._ = new _
|
||||
{
|
||||
Data._ = new _
|
||||
{
|
||||
CompressF16 = Temp.ReadNInt32("CompressF16" ),
|
||||
ConverterVersion = Temp.ReadString("ConverterVersion"),
|
||||
FileName = Temp.ReadString("FileName" ),
|
||||
PropertyVersion = Temp.ReadString("PropertyVersion" ),
|
||||
};
|
||||
}
|
||||
|
||||
if (A3D.Element("Ambient", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.Ambient = new Ambient[((object[])Temp.Object).Length];
|
||||
MsgPack Ambient = new MsgPack();
|
||||
|
||||
for (i = 0; i < Data.Ambient.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
Ambient = (MsgPack)Temp[i];
|
||||
Data.Ambient[i] = new Ambient
|
||||
{
|
||||
Name = Ambient.ReadString ( "Name"),
|
||||
LightDiffuse = Ambient.ReadRGBAKey( "LightDiffuse"),
|
||||
RimLightDiffuse = Ambient.ReadRGBAKey("RimLightDiffuse"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("CameraAuxiliary", out MsgPack CameraAuxiliary))
|
||||
Data.CameraAuxiliary = new CameraAuxiliary
|
||||
{
|
||||
AutoExposure = CameraAuxiliary.ReadKey("AutoExposure"),
|
||||
Exposure = CameraAuxiliary.ReadKey( "Exposure"),
|
||||
Gamma = CameraAuxiliary.ReadKey("Gamma" ),
|
||||
GammaRate = CameraAuxiliary.ReadKey("GammaRate" ),
|
||||
Saturate = CameraAuxiliary.ReadKey("Saturate" ),
|
||||
};
|
||||
|
||||
if (A3D.Element("CameraRoot", out MsgPack CameraRoot, typeof(object[])))
|
||||
{
|
||||
Data.CameraRoot = new CameraRoot[((object[])CameraRoot.Object).Length];
|
||||
MsgPack _Root = new MsgPack();
|
||||
for (i = 0; i < Data.CameraRoot.Length; i++)
|
||||
if (CameraRoot[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
_Root = (MsgPack)CameraRoot[i];
|
||||
Data.CameraRoot[i] = new CameraRoot
|
||||
{
|
||||
MT = _Root.ReadMT(),
|
||||
Interest = _Root.ReadMT("Interest"),
|
||||
};
|
||||
if (!_Root.Element("ViewPoint", out MsgPack ViewPoint)) continue;
|
||||
|
||||
Data.CameraRoot[i].ViewPoint = new ViewPoint
|
||||
{
|
||||
MT = ViewPoint.ReadMT(),
|
||||
Aspect = ViewPoint.ReadNDouble("Aspect" ),
|
||||
CameraApertureH = ViewPoint.ReadNDouble("CameraApertureH"),
|
||||
CameraApertureW = ViewPoint.ReadNDouble("CameraApertureW"),
|
||||
FOVHorizontal = ViewPoint.ReadNDouble("FOVHorizontal" ),
|
||||
FocalLength = ViewPoint.ReadKey ("FocalLength" ),
|
||||
FOV = ViewPoint.ReadKey ("FOV" ),
|
||||
Roll = ViewPoint.ReadKey ("Roll" ),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("Chara", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.Chara = new ModelTransform[((object[])Temp.Object).Length];
|
||||
for (i = 0; i < Data.Chara.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
Data.Chara[i] = ((MsgPack)Temp[i]).ReadMT();
|
||||
}
|
||||
|
||||
if (A3D.Element("Curve", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.Curve = new Curve[((object[])Temp.Object).Length];
|
||||
MsgPack Curve = new MsgPack();
|
||||
for (i = 0; i < Data.Curve.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
Curve = (MsgPack)Temp[i];
|
||||
Data.Curve[i] = new Curve
|
||||
{
|
||||
Name = Curve.ReadString("Name"),
|
||||
CV = Curve.ReadKey ("CV"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("DOF", out Temp, typeof(object[])))
|
||||
Data.DOF = new DOF
|
||||
{
|
||||
MT = Temp.ReadMT(),
|
||||
Name = Temp.ReadString("Name"),
|
||||
};
|
||||
|
||||
if (A3D.Element("Event", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.Event = new Event[((object[])Temp.Object).Length];
|
||||
MsgPack Event = new MsgPack();
|
||||
for (i = 0; i < Data.Event.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
Event = (MsgPack)Temp[i];
|
||||
Data.Event[i] = new Event
|
||||
{
|
||||
Begin = Event.ReadNDouble( "Begin" ),
|
||||
ClipBegin = Event.ReadNDouble("ClipBegin" ),
|
||||
ClipEnd = Event.ReadNDouble("ClipEnd" ),
|
||||
End = Event.ReadNDouble( "End" ),
|
||||
Name = Event.ReadString ("Name" ),
|
||||
Param1 = Event.ReadString ("Param1" ),
|
||||
Ref = Event.ReadString ("Ref" ),
|
||||
TimeRefScale = Event.ReadNDouble("TimeRefScale"),
|
||||
Type = Event.ReadNInt32 ("Type" ),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("Fog", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.Fog = new Fog[((object[])Temp.Object).Length];
|
||||
MsgPack Fog = new MsgPack();
|
||||
for (i = 0; i < Data.Fog.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
Fog = (MsgPack)Temp[i];
|
||||
Data.Fog[i] = new Fog
|
||||
{
|
||||
Id = Fog.ReadNInt32 ("Id" ),
|
||||
Density = Fog.ReadKey ("Density"),
|
||||
Diffuse = Fog.ReadRGBAKey("Diffuse"),
|
||||
End = Fog.ReadKey ("End" ),
|
||||
Start = Fog.ReadKey ("Start" ),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("Light", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.Light = new Light[((object[])Temp.Object).Length];
|
||||
MsgPack Light = new MsgPack();
|
||||
for (i = 0; i < Data.Light.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
Light = (MsgPack)Temp[i];
|
||||
Data.Light[i] = new Light
|
||||
{
|
||||
Id = Light.ReadNInt32 ("Id" ),
|
||||
Name = Light.ReadString ("Name" ),
|
||||
Type = Light.ReadString ("Type" ),
|
||||
Ambient = Light.ReadRGBAKey("Ambient" ),
|
||||
Diffuse = Light.ReadRGBAKey("Diffuse" ),
|
||||
Incandescence = Light.ReadRGBAKey("Incandescence"),
|
||||
Position = Light.ReadMT ("Position" ),
|
||||
Specular = Light.ReadRGBAKey("Specular" ),
|
||||
SpotDirection = Light.ReadMT ("SpotDirection"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("MaterialList", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.MaterialList = new MaterialList[((object[])Temp.Object).Length];
|
||||
MsgPack MaterialList = new MsgPack();
|
||||
for (i = 0; i < Data.MaterialList.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
MaterialList = (MsgPack)Temp[i];
|
||||
Data.MaterialList[i] = new MaterialList
|
||||
{
|
||||
HashName = MaterialList.ReadString ( "HashName"),
|
||||
Name = MaterialList.ReadString ( "Name"),
|
||||
BlendColor = MaterialList.ReadRGBAKey( "BlendColor"),
|
||||
GlowIntensity = MaterialList.ReadKey ("GlowIntensity"),
|
||||
Incandescence = MaterialList.ReadRGBAKey("Incandescence"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("MObjectHRC", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.MObjectHRC = new MObjectHRC[((object[])Temp.Object).Length];
|
||||
MsgPack _Node = new MsgPack();
|
||||
MsgPack _Instance = new MsgPack();
|
||||
MsgPack MObjectHRC = new MsgPack();
|
||||
for (i0 = 0; i0 < Data.MObjectHRC.Length; i0++)
|
||||
{
|
||||
if (Temp[i0].GetType() == typeof(MsgPack))
|
||||
{
|
||||
MObjectHRC = (MsgPack)Temp[i0];
|
||||
Data.MObjectHRC[i0] = new MObjectHRC
|
||||
{
|
||||
MT = MObjectHRC.ReadMT(),
|
||||
Name = MObjectHRC.ReadString("Name"),
|
||||
};
|
||||
|
||||
if (MObjectHRC.Element("JointOrient", out MsgPack JointOrient, typeof(MsgPack)))
|
||||
{
|
||||
Data.MObjectHRC[i0].JointOrient = new Vector3<double?>
|
||||
{
|
||||
X = JointOrient.ReadDouble("X"),
|
||||
Y = JointOrient.ReadDouble("Y"),
|
||||
Z = JointOrient.ReadDouble("Z"),
|
||||
};
|
||||
}
|
||||
|
||||
if (MObjectHRC.Element("Instance", out MsgPack Instance, typeof(object[])))
|
||||
{
|
||||
Data.MObjectHRC[i0].Instance =
|
||||
new Instance[((object[])Instance.Object).Length];
|
||||
for (i1 = 0; i1 < Data.MObjectHRC[i0].Instance.Length; i1++)
|
||||
{
|
||||
if (Instance[i1].GetType() != typeof(MsgPack)) continue;
|
||||
|
||||
_Instance = (MsgPack)Instance[i1];
|
||||
Data.MObjectHRC[i0].Instance[i1] = new Instance
|
||||
{
|
||||
MT = _Instance.ReadMT(),
|
||||
Name = _Instance.ReadString( "Name"),
|
||||
Shadow = _Instance.ReadNInt32( "Shadow"),
|
||||
UIDName = _Instance.ReadString("UIDName"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (MObjectHRC.Element("Node", out MsgPack Node, typeof(object[])))
|
||||
{
|
||||
Data.MObjectHRC[i0].Node = new Node[((object[])Node.Object).Length];
|
||||
for (i1 = 0; i1 < Data.MObjectHRC[i0].Node.Length; i1++)
|
||||
{
|
||||
if (Node[i1].GetType() != typeof(MsgPack)) continue;
|
||||
|
||||
_Node = (MsgPack)Node[i1];
|
||||
Data.MObjectHRC[i0].Node[i1] = new Node
|
||||
{
|
||||
MT = _Node.ReadMT(),
|
||||
Name = _Node.ReadString( "Name"),
|
||||
Parent = _Node.ReadNInt32("Parent"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("MObjectHRCList", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.MObjectHRCList = new string[((object[])Temp.Object).Length];
|
||||
for (i = 0; i < Data.MObjectHRCList.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
Data.MObjectHRCList[i] = ((MsgPack)Temp[i]).ReadString();
|
||||
}
|
||||
|
||||
if (A3D.Element("Motion", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.Motion = new string[((object[])Temp.Object).Length];
|
||||
for (i = 0; i < Data.Motion.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
Data.Motion[i] = ((MsgPack)Temp[i]).ReadString();
|
||||
}
|
||||
|
||||
if (A3D.Element("Object", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.Object = new Object[((object[])Temp.Object).Length];
|
||||
MsgPack _TP = new MsgPack();
|
||||
MsgPack _TT = new MsgPack();
|
||||
MsgPack Object = new MsgPack();
|
||||
for (i0 = 0; i0 < Data.Object.Length; i0++)
|
||||
if (Temp[i0].GetType() == typeof(MsgPack))
|
||||
{
|
||||
Object = (MsgPack)Temp[i0];
|
||||
Data.Object[i0] = new Object
|
||||
{
|
||||
MT = Object.ReadMT(),
|
||||
Morph = Object.ReadString("Morph" ),
|
||||
MorphOffset = Object.ReadNInt32("MorphOffset"),
|
||||
Name = Object.ReadString( "Name"),
|
||||
ParentName = Object.ReadString( "ParentName"),
|
||||
UIDName = Object.ReadString( "UIDName"),
|
||||
};
|
||||
|
||||
if (Object.Element("TP", out MsgPack TP, typeof(object[])))
|
||||
{
|
||||
Data.Object[i0].TP = new Object.TexturePattern[((object[])TP.Object).Length];
|
||||
for (i1 = 0; i1 < Data.Object[i0].TP.Length; i1++)
|
||||
{
|
||||
if (TP[i1].GetType() != typeof(MsgPack)) continue;
|
||||
|
||||
_TP = (MsgPack)TP[i1];
|
||||
Data.Object[i0].TP[i1] = new Object.TexturePattern
|
||||
{
|
||||
Name = _TP.ReadString("Name" ),
|
||||
Pat = _TP.ReadString("Pat" ),
|
||||
PatOffset = _TP.ReadNInt32("PatOffset"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.Element("TT", out MsgPack TT, typeof(object[])))
|
||||
{
|
||||
Data.Object[i0].TT = new Object.TextureTransform[((object[])TT.Object).Length];
|
||||
for (i1 = 0; i1 < Data.Object[i0].TT.Length; i1++)
|
||||
{
|
||||
if (TT[i1].GetType() != typeof(MsgPack)) continue;
|
||||
|
||||
_TT = (MsgPack)TT[i1];
|
||||
Data.Object[i0].TT[i1] = new Object.TextureTransform
|
||||
{
|
||||
Name = _TT.ReadString("Name"),
|
||||
C = _TT.ReadKeyUV ("C" ),
|
||||
O = _TT.ReadKeyUV ("O" ),
|
||||
R = _TT.ReadKeyUV ("R" ),
|
||||
Ro = _TT.ReadKey ("Ro" ),
|
||||
RF = _TT.ReadKey ("RF" ),
|
||||
TF = _TT.ReadKeyUV ("TF" ),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("ObjectHRC", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.ObjectHRC = new ObjectHRC[((object[])Temp.Object).Length];
|
||||
MsgPack _Node = new MsgPack();
|
||||
MsgPack _Instance = new MsgPack();
|
||||
MsgPack ObjectHRC = new MsgPack();
|
||||
for (i0 = 0; i0 < Data.ObjectHRC.Length; i0++)
|
||||
if (Temp[i0].GetType() == typeof(MsgPack))
|
||||
{
|
||||
ObjectHRC = (MsgPack)Temp[i0];
|
||||
Data.ObjectHRC[i0] = new ObjectHRC
|
||||
{
|
||||
Name = ObjectHRC.ReadString ( "Name"),
|
||||
Shadow = ObjectHRC.ReadNDouble( "Shadow"),
|
||||
UIDName = ObjectHRC.ReadString ("UIDName"),
|
||||
};
|
||||
|
||||
if (ObjectHRC.Element("JointOrient", out MsgPack JointOrient, typeof(MsgPack)))
|
||||
{
|
||||
Data.ObjectHRC[i0].JointOrient = new Vector3<double?>
|
||||
{
|
||||
X = JointOrient.ReadDouble("X"),
|
||||
Y = JointOrient.ReadDouble("Y"),
|
||||
Z = JointOrient.ReadDouble("Z"),
|
||||
};
|
||||
}
|
||||
|
||||
if (ObjectHRC.Element("Node", out MsgPack Node, typeof(object[])))
|
||||
{
|
||||
Data.ObjectHRC[i0].Node = new Node[((object[])Node.Object).Length];
|
||||
for (i1 = 0; i1 < Data.ObjectHRC[i0].Node.Length; i1++)
|
||||
{
|
||||
if (Node[i1].GetType() != typeof(MsgPack)) continue;
|
||||
|
||||
_Node = (MsgPack)Node[i1];
|
||||
Data.ObjectHRC[i0].Node[i1] = new Node
|
||||
{
|
||||
MT = _Node.ReadMT(),
|
||||
Name = _Node.ReadString( "Name"),
|
||||
Parent = _Node.ReadInt32 ("Parent"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("ObjectHRCList", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.ObjectHRCList = new string[((object[])Temp.Object).Length];
|
||||
for (i = 0; i < Data.ObjectHRCList.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
Data.ObjectHRCList[i] = ((MsgPack)Temp[i]).ReadString();
|
||||
}
|
||||
|
||||
if (A3D.Element("ObjectList", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.ObjectList = new string[((object[])Temp.Object).Length];
|
||||
for (i = 0; i < Data.ObjectList.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
Data.ObjectList[i] = ((MsgPack)Temp[i]).ReadString();
|
||||
}
|
||||
|
||||
if (A3D.Element("PlayControl", out Temp))
|
||||
Data.PlayControl = new PlayControl
|
||||
{
|
||||
Begin = Temp.ReadNDouble("Begin" ),
|
||||
Div = Temp.ReadNDouble("Div" ),
|
||||
FPS = Temp.ReadNDouble("FPS" ),
|
||||
Offset = Temp.ReadNDouble("Offset"),
|
||||
Size = Temp.ReadNDouble("Size" ),
|
||||
};
|
||||
|
||||
if (A3D.Element("Point", out Temp, typeof(object[])))
|
||||
{
|
||||
Data.Point = new ModelTransform[((object[])Temp.Object).Length];
|
||||
for (i = 0; i < Data.Point.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
Data.Point[i] = ((MsgPack)Temp[i]).ReadMT();
|
||||
}
|
||||
|
||||
if (A3D.Element("PostProcess", out Temp))
|
||||
Data.PostProcess = new PostProcess
|
||||
{
|
||||
Ambient = Temp.ReadRGBAKey("Ambient" ),
|
||||
Diffuse = Temp.ReadRGBAKey("Diffuse" ),
|
||||
LensFlare = Temp.ReadKey ("LensFlare"),
|
||||
LensGhost = Temp.ReadKey ("LensGhost"),
|
||||
LensShaft = Temp.ReadKey ("LensShaft"),
|
||||
Specular = Temp.ReadRGBAKey("Specular" ),
|
||||
};
|
||||
|
||||
Temp = null;
|
||||
CompressF16 = Temp.ReadNInt32("CompressF16" ),
|
||||
ConverterVersion = Temp.ReadString("ConverterVersion"),
|
||||
FileName = Temp.ReadString("FileName" ),
|
||||
PropertyVersion = Temp.ReadString("PropertyVersion" ),
|
||||
};
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("Ambient", out Temp))
|
||||
{
|
||||
Data.Ambient = new Ambient[Temp.Array.Length];
|
||||
MsgPack Ambient;
|
||||
|
||||
for (i = 0; i < Data.Ambient.Length; i++)
|
||||
{
|
||||
Ambient = Temp[i] as MsgPack;
|
||||
Data.Ambient[i] = new Ambient
|
||||
{
|
||||
Name = Ambient.ReadString ( "Name"),
|
||||
LightDiffuse = Ambient.ReadRGBAKey( "LightDiffuse"),
|
||||
RimLightDiffuse = Ambient.ReadRGBAKey("RimLightDiffuse"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("CameraAuxiliary", out Temp))
|
||||
Data.CameraAuxiliary = new CameraAuxiliary
|
||||
{
|
||||
AutoExposure = Temp.ReadKey("AutoExposure"),
|
||||
Exposure = Temp.ReadKey( "Exposure"),
|
||||
Gamma = Temp.ReadKey("Gamma" ),
|
||||
GammaRate = Temp.ReadKey("GammaRate" ),
|
||||
Saturate = Temp.ReadKey("Saturate" ),
|
||||
};
|
||||
|
||||
if (A3D.Element<MsgPack>("CameraRoot", out Temp))
|
||||
{
|
||||
Data.CameraRoot = new CameraRoot[Temp.Array.Length];
|
||||
MsgPack _Root;
|
||||
for (i = 0; i < Data.CameraRoot.Length; i++)
|
||||
{
|
||||
_Root = Temp[i] as MsgPack;
|
||||
Data.CameraRoot[i] = new CameraRoot
|
||||
{
|
||||
MT = _Root.ReadMT(),
|
||||
Interest = _Root.ReadMT("Interest"),
|
||||
};
|
||||
if (!_Root.Element("ViewPoint", out MsgPack ViewPoint)) continue;
|
||||
|
||||
Data.CameraRoot[i].ViewPoint = new ViewPoint
|
||||
{
|
||||
MT = ViewPoint.ReadMT(),
|
||||
Aspect = ViewPoint.ReadNDouble("Aspect" ),
|
||||
CameraApertureH = ViewPoint.ReadNDouble("CameraApertureH"),
|
||||
CameraApertureW = ViewPoint.ReadNDouble("CameraApertureW"),
|
||||
FOVHorizontal = ViewPoint.ReadNDouble("FOVHorizontal" ),
|
||||
FocalLength = ViewPoint.ReadKey ("FocalLength" ),
|
||||
FOV = ViewPoint.ReadKey ("FOV" ),
|
||||
Roll = ViewPoint.ReadKey ("Roll" ),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("Chara", out Temp))
|
||||
{
|
||||
Data.Chara = new ModelTransform[Temp.Array.Length];
|
||||
for (i = 0; i < Data.Chara.Length; i++)
|
||||
Data.Chara[i] = (Temp[i] as MsgPack).ReadMT();
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("Curve", out Temp))
|
||||
{
|
||||
Data.Curve = new Curve[Temp.Array.Length];
|
||||
MsgPack Curve;
|
||||
for (i = 0; i < Data.Curve.Length; i++)
|
||||
{
|
||||
Curve = Temp[i] as MsgPack;
|
||||
Data.Curve[i] = new Curve
|
||||
{
|
||||
Name = Curve.ReadString("Name"),
|
||||
CV = Curve.ReadKey ("CV"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element("DOF", out Temp))
|
||||
Data.DOF = new DOF
|
||||
{
|
||||
MT = Temp.ReadMT(),
|
||||
Name = Temp.ReadString("Name"),
|
||||
};
|
||||
|
||||
if (A3D.Element<MsgPack>("Event", out Temp))
|
||||
{
|
||||
Data.Event = new Event[Temp.Array.Length];
|
||||
MsgPack Event;
|
||||
for (i = 0; i < Data.Event.Length; i++)
|
||||
{
|
||||
Event = Temp[i] as MsgPack;
|
||||
Data.Event[i] = new Event
|
||||
{
|
||||
Begin = Event.ReadNDouble( "Begin" ),
|
||||
ClipBegin = Event.ReadNDouble("ClipBegin" ),
|
||||
ClipEnd = Event.ReadNDouble("ClipEnd" ),
|
||||
End = Event.ReadNDouble( "End" ),
|
||||
Name = Event.ReadString ("Name" ),
|
||||
Param1 = Event.ReadString ("Param1" ),
|
||||
Ref = Event.ReadString ("Ref" ),
|
||||
TimeRefScale = Event.ReadNDouble("TimeRefScale"),
|
||||
Type = Event.ReadNInt32 ("Type" ),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("Fog", out Temp))
|
||||
{
|
||||
Data.Fog = new Fog[Temp.Array.Length];
|
||||
MsgPack Fog;
|
||||
for (i = 0; i < Data.Fog.Length; i++)
|
||||
{
|
||||
Fog = Temp[i] as MsgPack;
|
||||
Data.Fog[i] = new Fog
|
||||
{
|
||||
Id = Fog.ReadNInt32 ("Id" ),
|
||||
Density = Fog.ReadKey ("Density"),
|
||||
Diffuse = Fog.ReadRGBAKey("Diffuse"),
|
||||
End = Fog.ReadKey ("End" ),
|
||||
Start = Fog.ReadKey ("Start" ),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("Light", out Temp))
|
||||
{
|
||||
Data.Light = new Light[Temp.Array.Length];
|
||||
MsgPack Light = new MsgPack();
|
||||
for (i = 0; i < Data.Light.Length; i++)
|
||||
{
|
||||
Light = Temp[i] as MsgPack;
|
||||
Data.Light[i] = new Light
|
||||
{
|
||||
Id = Light.ReadNInt32 ("Id" ),
|
||||
Name = Light.ReadString ("Name" ),
|
||||
Type = Light.ReadString ("Type" ),
|
||||
Ambient = Light.ReadRGBAKey("Ambient" ),
|
||||
Diffuse = Light.ReadRGBAKey("Diffuse" ),
|
||||
Incandescence = Light.ReadRGBAKey("Incandescence"),
|
||||
Position = Light.ReadMT ("Position" ),
|
||||
Specular = Light.ReadRGBAKey("Specular" ),
|
||||
SpotDirection = Light.ReadMT ("SpotDirection"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("MaterialList", out Temp))
|
||||
{
|
||||
Data.MaterialList = new MaterialList[Temp.Array.Length];
|
||||
MsgPack MaterialList = new MsgPack();
|
||||
for (i = 0; i < Data.MaterialList.Length; i++)
|
||||
{
|
||||
MaterialList = Temp[i] as MsgPack;
|
||||
Data.MaterialList[i] = new MaterialList
|
||||
{
|
||||
HashName = MaterialList.ReadString ( "HashName"),
|
||||
Name = MaterialList.ReadString ( "Name"),
|
||||
BlendColor = MaterialList.ReadRGBAKey( "BlendColor"),
|
||||
GlowIntensity = MaterialList.ReadKey ("GlowIntensity"),
|
||||
Incandescence = MaterialList.ReadRGBAKey("Incandescence"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("MObjectHRC", out Temp))
|
||||
{
|
||||
Data.MObjectHRC = new MObjectHRC[Temp.Array.Length];
|
||||
MsgPack _Node = new MsgPack();
|
||||
MsgPack _Instance = new MsgPack();
|
||||
MsgPack MObjectHRC = new MsgPack();
|
||||
for (i0 = 0; i0 < Data.MObjectHRC.Length; i0++)
|
||||
{
|
||||
MObjectHRC = Temp[i0] as MsgPack;
|
||||
Data.MObjectHRC[i0] = new MObjectHRC
|
||||
{
|
||||
MT = MObjectHRC.ReadMT(),
|
||||
Name = MObjectHRC.ReadString("Name"),
|
||||
};
|
||||
|
||||
if (MObjectHRC.Element("JointOrient", out MsgPack JointOrient))
|
||||
Data.MObjectHRC[i0].JointOrient = new Vector3<double?>
|
||||
{
|
||||
X = JointOrient.ReadDouble("X"),
|
||||
Y = JointOrient.ReadDouble("Y"),
|
||||
Z = JointOrient.ReadDouble("Z"),
|
||||
};
|
||||
|
||||
if (MObjectHRC.Element<MsgPack>("Instance", out MsgPack Instance))
|
||||
{
|
||||
Data.MObjectHRC[i0].Instance = new Instance[Instance.Array.Length];
|
||||
for (i1 = 0; i1 < Data.MObjectHRC[i0].Instance.Length; i1++)
|
||||
{
|
||||
_Instance = Instance[i1] as MsgPack;
|
||||
Data.MObjectHRC[i0].Instance[i1] = new Instance
|
||||
{
|
||||
MT = _Instance.ReadMT(),
|
||||
Name = _Instance.ReadString( "Name"),
|
||||
Shadow = _Instance.ReadNInt32( "Shadow"),
|
||||
UIDName = _Instance.ReadString("UIDName"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (MObjectHRC.Element<MsgPack>("Node", out MsgPack Node))
|
||||
{
|
||||
Data.MObjectHRC[i0].Node = new Node[Temp.Array.Length];
|
||||
for (i1 = 0; i1 < Data.MObjectHRC[i0].Node.Length; i1++)
|
||||
{
|
||||
_Node = Node[i1] as MsgPack;
|
||||
Data.MObjectHRC[i0].Node[i1] = new Node
|
||||
{
|
||||
MT = _Node.ReadMT(),
|
||||
Name = _Node.ReadString( "Name"),
|
||||
Parent = _Node.ReadNInt32("Parent"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("MObjectHRCList", out Temp))
|
||||
{
|
||||
Data.MObjectHRCList = new string[Temp.Array.Length];
|
||||
for (i = 0; i < Data.MObjectHRCList.Length; i++)
|
||||
Data.MObjectHRCList[i] = (Temp[i] as MsgPack).ReadString();
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("Motion", out Temp))
|
||||
{
|
||||
Data.Motion = new string[Temp.Array.Length];
|
||||
for (i = 0; i < Data.Motion.Length; i++)
|
||||
Data.Motion[i] = (Temp[i] as MsgPack).ReadString();
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("Object", out Temp))
|
||||
{
|
||||
Data.Object = new Object[Temp.Array.Length];
|
||||
MsgPack _TP = new MsgPack();
|
||||
MsgPack _TT = new MsgPack();
|
||||
MsgPack Object = new MsgPack();
|
||||
for (i0 = 0; i0 < Data.Object.Length; i0++)
|
||||
{
|
||||
Object = Temp[i0] as MsgPack;
|
||||
Data.Object[i0] = new Object
|
||||
{
|
||||
MT = Object.ReadMT(),
|
||||
Morph = Object.ReadString("Morph" ),
|
||||
MorphOffset = Object.ReadNInt32("MorphOffset"),
|
||||
Name = Object.ReadString( "Name"),
|
||||
ParentName = Object.ReadString( "ParentName"),
|
||||
UIDName = Object.ReadString( "UIDName"),
|
||||
};
|
||||
|
||||
if (Object.Element<MsgPack>("TP", out MsgPack TP))
|
||||
{
|
||||
Data.Object[i0].TP = new Object.TexturePattern[TP.Array.Length];
|
||||
for (i1 = 0; i1 < Data.Object[i0].TP.Length; i1++)
|
||||
{
|
||||
_TP = TP[i1] as MsgPack;
|
||||
Data.Object[i0].TP[i1] = new Object.TexturePattern
|
||||
{
|
||||
Name = _TP.ReadString("Name" ),
|
||||
Pat = _TP.ReadString("Pat" ),
|
||||
PatOffset = _TP.ReadNInt32("PatOffset"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.Element<MsgPack>("TT", out MsgPack TT))
|
||||
{
|
||||
Data.Object[i0].TT = new Object.TextureTransform[TT.Array.Length];
|
||||
for (i1 = 0; i1 < Data.Object[i0].TT.Length; i1++)
|
||||
{
|
||||
_TT = TT[i1] as MsgPack;
|
||||
Data.Object[i0].TT[i1] = new Object.TextureTransform
|
||||
{
|
||||
Name = _TT.ReadString("Name"),
|
||||
C = _TT.ReadKeyUV ("C" ),
|
||||
O = _TT.ReadKeyUV ("O" ),
|
||||
R = _TT.ReadKeyUV ("R" ),
|
||||
Ro = _TT.ReadKey ("Ro" ),
|
||||
RF = _TT.ReadKey ("RF" ),
|
||||
TF = _TT.ReadKeyUV ("TF" ),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("ObjectHRC", out Temp))
|
||||
{
|
||||
Data.ObjectHRC = new ObjectHRC[Temp.Array.Length];
|
||||
MsgPack _Node = new MsgPack();
|
||||
MsgPack _Instance = new MsgPack();
|
||||
MsgPack ObjectHRC = new MsgPack();
|
||||
for (i0 = 0; i0 < Data.ObjectHRC.Length; i0++)
|
||||
{
|
||||
ObjectHRC = Temp[i0] as MsgPack;
|
||||
Data.ObjectHRC[i0] = new ObjectHRC
|
||||
{
|
||||
Name = ObjectHRC.ReadString ( "Name"),
|
||||
Shadow = ObjectHRC.ReadNDouble( "Shadow"),
|
||||
UIDName = ObjectHRC.ReadString ("UIDName"),
|
||||
};
|
||||
|
||||
if (ObjectHRC.Element("JointOrient", out MsgPack JointOrient))
|
||||
Data.ObjectHRC[i0].JointOrient = new Vector3<double?>
|
||||
{
|
||||
X = JointOrient.ReadDouble("X"),
|
||||
Y = JointOrient.ReadDouble("Y"),
|
||||
Z = JointOrient.ReadDouble("Z"),
|
||||
};
|
||||
|
||||
if (ObjectHRC.Element<MsgPack>("Node", out MsgPack Node))
|
||||
{
|
||||
Data.ObjectHRC[i0].Node = new Node[Node.Array.Length];
|
||||
for (i1 = 0; i1 < Data.ObjectHRC[i0].Node.Length; i1++)
|
||||
{
|
||||
_Node = Node[i1] as MsgPack;
|
||||
Data.ObjectHRC[i0].Node[i1] = new Node
|
||||
{
|
||||
MT = _Node.ReadMT(),
|
||||
Name = _Node.ReadString( "Name"),
|
||||
Parent = _Node.ReadInt32 ("Parent"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("ObjectHRCList", out Temp))
|
||||
{
|
||||
Data.ObjectHRCList = new string[Temp.Array.Length];
|
||||
for (i = 0; i < Data.ObjectHRCList.Length; i++)
|
||||
Data.ObjectHRCList[i] = (Temp[i] as MsgPack).ReadString();
|
||||
}
|
||||
|
||||
if (A3D.Element<MsgPack>("ObjectList", out Temp))
|
||||
{
|
||||
Data.ObjectList = new string[Temp.Array.Length];
|
||||
for (i = 0; i < Data.ObjectList.Length; i++)
|
||||
Data.ObjectList[i] = (Temp[i] as MsgPack).ReadString();
|
||||
}
|
||||
|
||||
if (A3D.Element("PlayControl", out Temp))
|
||||
Data.PlayControl = new PlayControl
|
||||
{
|
||||
Begin = Temp.ReadNDouble("Begin" ),
|
||||
Div = Temp.ReadNDouble("Div" ),
|
||||
FPS = Temp.ReadNDouble("FPS" ),
|
||||
Offset = Temp.ReadNDouble("Offset"),
|
||||
Size = Temp.ReadNDouble("Size" ),
|
||||
};
|
||||
|
||||
if (A3D.Element<MsgPack>("Point", out Temp))
|
||||
{
|
||||
Data.Point = new ModelTransform[Temp.Array.Length];
|
||||
for (i = 0; i < Data.Point.Length; i++)
|
||||
Data.Point[i] = (Temp[i] as MsgPack).ReadMT();
|
||||
}
|
||||
|
||||
if (A3D.Element("PostProcess", out Temp))
|
||||
Data.PostProcess = new PostProcess
|
||||
{
|
||||
Ambient = Temp.ReadRGBAKey("Ambient" ),
|
||||
Diffuse = Temp.ReadRGBAKey("Diffuse" ),
|
||||
LensFlare = Temp.ReadKey ("LensFlare"),
|
||||
LensGhost = Temp.ReadKey ("LensGhost"),
|
||||
LensShaft = Temp.ReadKey ("LensShaft"),
|
||||
Specular = Temp.ReadRGBAKey("Specular" ),
|
||||
};
|
||||
|
||||
Temp = null;
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
@@ -2310,12 +2274,6 @@ namespace KKdMainLib.A3DA
|
||||
public Key A;
|
||||
}
|
||||
|
||||
public struct Values
|
||||
{
|
||||
public List< int?> BinOffset;
|
||||
public List<double?> Value;
|
||||
}
|
||||
|
||||
public class Vector3<T>
|
||||
{
|
||||
public T X;
|
||||
|
||||
+14
-16
@@ -188,7 +188,7 @@ namespace KKdMainLib.A3DA
|
||||
{
|
||||
if (MT.BinOffset == null) return;
|
||||
|
||||
IO.Position = IO.Offset + (int)MT.BinOffset;
|
||||
IO.Position = (int)MT.BinOffset;
|
||||
|
||||
IO.ReadOffset(out MT.Scale);
|
||||
IO.ReadOffset(out MT.Rot );
|
||||
@@ -217,7 +217,7 @@ namespace KKdMainLib.A3DA
|
||||
if (Key == null) return;
|
||||
if (Key.BinOffset == null || Key.BinOffset < 0) return;
|
||||
|
||||
IO.Position = IO.Offset + (int)Key.BinOffset;
|
||||
IO.Position = (int)Key.BinOffset;
|
||||
Key.Type = IO.ReadInt32();
|
||||
|
||||
Key.Value = IO.ReadSingle();
|
||||
@@ -314,27 +314,25 @@ namespace KKdMainLib.A3DA
|
||||
|
||||
if (Key.Type < 2) return Key;
|
||||
|
||||
if (!k.Element("Trans", out MsgPack Trans, typeof(object[]))) return Key;
|
||||
if (!k.Element<MsgPack>("Trans", out MsgPack Trans)) return Key;
|
||||
|
||||
Key.Length = ((object[])Trans.Object).Length;
|
||||
Key.Length = Trans.Array.Length;
|
||||
Key.Trans = new Key.Transform[Key.Length.Value];
|
||||
MsgPack _Trans = new MsgPack();
|
||||
byte i1 = 0;
|
||||
for (int i = 0; i < Key.Length; i++)
|
||||
{
|
||||
Key.Trans[i] = new Key.Transform();
|
||||
if (Trans[i].GetType() != typeof(MsgPack)) continue;
|
||||
if (Trans[i] is MsgPack _Trans)
|
||||
{
|
||||
if (_Trans.Array == null) continue;
|
||||
Key.Trans[i].Type = _Trans.Array.Length - 1;
|
||||
Key.Trans[i].Value = new double[Key.Trans[i].Type];
|
||||
|
||||
Key.Trans[i].Frame = (_Trans[0] as MsgPack).ReadDouble();
|
||||
|
||||
_Trans = (MsgPack)Trans[i];
|
||||
if (_Trans.Object.GetType() != typeof(object[])) continue;
|
||||
Key.Trans[i].Type = ((object[])_Trans.Object).Length - 1;
|
||||
Key.Trans[i].Value = new double[Key.Trans[i].Type];
|
||||
|
||||
if (_Trans[0].GetType() != typeof(MsgPack)) continue;
|
||||
Key.Trans[i].Frame = ((MsgPack)_Trans[0]).ReadDouble();
|
||||
|
||||
for (i1 = 0; i1 < Key.Trans[i].Type; i1++)
|
||||
Key.Trans[i].Value[i1] = ((MsgPack)_Trans[i1 + 1]).ReadDouble();
|
||||
for (i1 = 0; i1 < Key.Trans[i].Type; i1++)
|
||||
Key.Trans[i].Value[i1] = ((MsgPack)_Trans[i1 + 1]).ReadDouble();
|
||||
}
|
||||
}
|
||||
return Key;
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
//Original: aet.bt Version: 1.2 by samyuu
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
using KKdMainLib.Types;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public class Aet
|
||||
{
|
||||
public Aet()
|
||||
{ }
|
||||
|
||||
public struct Header
|
||||
{
|
||||
public int MAINPointer;
|
||||
public float Unk;
|
||||
public float Duration;
|
||||
public float FrameRate;
|
||||
public Vector2<int> Resolution;
|
||||
public int Always0;
|
||||
public int AnimationPointerTableSize;
|
||||
public int AnimationPointerTableOffset;
|
||||
public int TextureMetadataCount;
|
||||
public int TextureMetadataOffset;
|
||||
public Vector2<int> Empty;
|
||||
public Vector2<int> Unused;
|
||||
}
|
||||
|
||||
public struct AnimationPointer
|
||||
{
|
||||
public int Count;
|
||||
public string G;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,980 @@
|
||||
//Original: AetSet.bt Version: 2.0 by samyuu
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib.Aet
|
||||
{
|
||||
public class Aet
|
||||
{
|
||||
public Aet()
|
||||
{ AET = new AetHeader(); i = i0 = 0; IO = null; }
|
||||
|
||||
public AetHeader AET;
|
||||
|
||||
private int i, i0;
|
||||
private Stream IO;
|
||||
|
||||
private const string x00 = "\0";
|
||||
|
||||
public void AETReader(string file)
|
||||
{
|
||||
IO = File.OpenReader(file + ".bin", true);
|
||||
|
||||
AET.MAIN = IO.ReadPointer<AetData>();
|
||||
AET.TOUCH = IO.ReadPointer<AetData>();
|
||||
if (AET.MAIN.Offset > 0)
|
||||
{
|
||||
AETReader(ref AET.MAIN);
|
||||
if (AET.TOUCH.Offset > 0)
|
||||
AETReader(ref AET.TOUCH);
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void AETWriter(string file)
|
||||
{
|
||||
if (AET.MAIN.Offset < 0) return;
|
||||
IO = File.OpenWriter(file + ".bin", true);
|
||||
|
||||
IO.Position = 0x20;
|
||||
AETWriter(ref AET.MAIN );
|
||||
|
||||
if (AET.TOUCH.Offset >= 0)
|
||||
{
|
||||
IO.Position = IO.Length + 0x20;
|
||||
AETWriter(ref AET.TOUCH);
|
||||
}
|
||||
|
||||
IO.Position = 0;
|
||||
IO.Write(AET.MAIN.Offset);
|
||||
if (AET.TOUCH.Offset > 0) IO.Write(AET.TOUCH.Offset);
|
||||
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void AETReader(ref Pointer<AetData> AET)
|
||||
{
|
||||
IO.Position = AET.Offset;
|
||||
ref AetData Aet = ref AET.Value;
|
||||
|
||||
Aet.Name = IO.ReadPointerString();
|
||||
Aet.Unk = IO.ReadSingle();
|
||||
Aet.Duration = IO.ReadSingle();
|
||||
Aet.FrameRate = IO.ReadSingle();
|
||||
IO.ReadInt32();
|
||||
Aet.Width = IO.ReadInt32();
|
||||
Aet.Height = IO.ReadInt32();
|
||||
Aet.DontChange = IO.ReadInt32();
|
||||
if (Aet.DontChange != 0) { IO.Close(); return; }
|
||||
Aet.LayObjPointers = IO.ReadCountPointer<CountPointer<int>>();
|
||||
CountPointer<SpriteEntry> Sprites = IO.ReadCountPointer<SpriteEntry>();
|
||||
Aet.Unknown = IO.ReadCountPointer<int>();
|
||||
|
||||
Aet.LayObjDict = new Dictionary<int, int>();
|
||||
Aet.ObjectsDict = new Dictionary<int, AetObject>();
|
||||
Aet.SprEntsDict = new Dictionary<int, SpriteEntry>();
|
||||
Aet.SpritesDict = new Dictionary<int, Sprite>();
|
||||
|
||||
IO.Position = Aet.LayObjPointers.Offset;
|
||||
for (i = 0; i < Aet.LayObjPointers.Count; i++)
|
||||
{
|
||||
Aet.LayObjDict.Add(i, IO.Position);
|
||||
Aet.LayObjPointers.Entries[i] = IO.ReadCountPointer<int>();
|
||||
}
|
||||
|
||||
for (i = 0; i < Aet.LayObjPointers.Count; i++)
|
||||
{
|
||||
IO.Position = Aet.LayObjPointers.Entries[i].Offset;
|
||||
for (i0 = 0; i0 < Aet.LayObjPointers.Entries[i].Count; i0++)
|
||||
Aet.LayObjPointers.Entries[i].Entries[i0] = IO.ReadAetObject(ref Aet.ObjectsDict);
|
||||
}
|
||||
|
||||
IO.Position = Sprites.Offset;
|
||||
for (i = 0; i < Sprites.Count; i++)
|
||||
{
|
||||
SpriteEntry SprEnt = new SpriteEntry();
|
||||
int Offset = IO.Position;
|
||||
|
||||
SprEnt.Unknown = IO.ReadInt32();
|
||||
SprEnt.Width = IO.ReadInt16();
|
||||
SprEnt.Height = IO.ReadInt16();
|
||||
SprEnt.Frames = IO.ReadSingle();
|
||||
SprEnt.Sprites = IO.ReadCountPointer<int>();
|
||||
long Position = IO.LongPosition;
|
||||
IO.Position = SprEnt.Sprites.Offset;
|
||||
for (i0 = 0; i0 < SprEnt.Sprites.Count; i0++)
|
||||
{
|
||||
Sprite Spr = new Sprite();
|
||||
int OffsetLocal = IO.Position;
|
||||
Spr.Name = IO.ReadPointerString();
|
||||
Spr.ID = IO.ReadInt32();
|
||||
Aet.SpritesDict.Add(OffsetLocal, Spr);
|
||||
SprEnt.Sprites.Entries[i0] = OffsetLocal;
|
||||
}
|
||||
IO.LongPosition = Position;
|
||||
Aet.SprEntsDict.Add(Offset, SprEnt);
|
||||
}
|
||||
}
|
||||
|
||||
public void AETWriter(ref Pointer<AetData> AET)
|
||||
{
|
||||
ref AetData Aet = ref AET.Value;
|
||||
|
||||
if (Aet.SpritesArr != null)
|
||||
{
|
||||
List<int> WrittenSprites = new List<int>();
|
||||
for (i = 0; i < Aet.SprEntsArr.Length; i++)
|
||||
{
|
||||
ref SpriteEntry SprEnt = ref Aet.SprEntsArr[i].Value;
|
||||
if (SprEnt.Sprites.Count < 1) continue;
|
||||
SprEnt.Sprites.Offset = IO.Position;
|
||||
for (i0 = 0; i0 < SprEnt.Sprites.Count; i0++)
|
||||
{
|
||||
ref int I = ref SprEnt.Sprites.Entries[i0];
|
||||
Aet.SpritesArr[Aet.SpritesIndDict[I]].Offset = IO.Position;
|
||||
IO.Write(0);
|
||||
IO.Write(Aet.SpritesArr[Aet.SpritesIndDict[I]].Value.ID);
|
||||
WrittenSprites.Add(Aet.SpritesIndDict[I]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < Aet.SpritesArr.Length; i++)
|
||||
if (!WrittenSprites.Contains(i))
|
||||
{
|
||||
Aet.SpritesArr[i].Offset = IO.Position;
|
||||
IO.Write(0);
|
||||
IO.Write(Aet.SpritesArr[i].Value.ID);
|
||||
WrittenSprites.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
IO.Align(0x20);
|
||||
for (i = 0; i < Aet.SprEntsArr.Length; i++)
|
||||
{
|
||||
Aet.SprEntsArr[i].Offset = IO.Position;
|
||||
ref SpriteEntry SprEnt = ref Aet.SprEntsArr[i].Value;
|
||||
IO.Write(SprEnt.Unknown);
|
||||
IO.Write(SprEnt.Width);
|
||||
IO.Write(SprEnt.Height);
|
||||
IO.Write(SprEnt.Frames);
|
||||
IO.Write(SprEnt.Sprites.Count);
|
||||
IO.Write(SprEnt.Sprites.Offset);
|
||||
}
|
||||
|
||||
IO.Align(0x20);
|
||||
Aet.LayObjPointers.Offset = IO.Position;
|
||||
for (i = 0; i < Aet.LayObjPointers.Count; i++)
|
||||
{
|
||||
Aet.LayObjPointers.Entries[i].Offset = IO.Position;
|
||||
IO.Write(0L);
|
||||
}
|
||||
|
||||
List<int> NullValPointers = new List<int>();
|
||||
for (i = 0; i < Aet.LayObjPointers.Count; i++)
|
||||
{
|
||||
for (i0 = 0; i0 < Aet.LayObjPointers.Entries[i].Count; i0++)
|
||||
{
|
||||
ref int I = ref Aet.LayObjPointers.Entries[i].Entries[i0];
|
||||
IO.Write(ref Aet.ObjectsArr[I].Value, ref NullValPointers);
|
||||
}
|
||||
|
||||
IO.Align(0x20);
|
||||
for (i0 = 0; i0 < Aet.LayObjPointers.Entries[i].Count; i0++)
|
||||
{
|
||||
ref int I = ref Aet.LayObjPointers.Entries[i].Entries[i0];
|
||||
IO.Write(ref Aet.ObjectsArr[I].Value, ref Aet.ObjectsArr[I].Offset);
|
||||
}
|
||||
}
|
||||
|
||||
IO.Align(0x20);
|
||||
AET.Offset = IO.Position;
|
||||
IO.Write(0L);
|
||||
IO.Write(Aet.Duration);
|
||||
IO.Write(Aet.FrameRate);
|
||||
IO.Write(0);
|
||||
IO.Write(Aet.Width);
|
||||
IO.Write(Aet.Height);
|
||||
IO.Write(0);
|
||||
IO.Write(0L);
|
||||
IO.Write(0L);
|
||||
IO.Write(0L);
|
||||
IO.Write(0L);
|
||||
|
||||
IO.Align(0x10);
|
||||
{
|
||||
Dictionary<string, int> UsedValues = new Dictionary<string, int>();
|
||||
|
||||
if (Aet.SpritesArr != null)
|
||||
for (i = 0; i < Aet.SpritesArr.Length; i++)
|
||||
IO.WritePointerString(ref UsedValues, ref Aet.SpritesArr[i].Value.Name);
|
||||
|
||||
//IO.Align(0x4);
|
||||
for (i = 0; i < Aet.ObjectsArr.Length; i++)
|
||||
{
|
||||
ref AetObject Obj = ref Aet.ObjectsArr[i].Value;
|
||||
if (Obj.Type == ObjType.Pic)
|
||||
for (i0 = 0; i0 < Obj.Pic.Value.Marker.Count; i0++)
|
||||
IO.WritePointerString(ref UsedValues, ref Obj.Pic.Value.Marker.Entries[i0].Name);
|
||||
else if (Obj.Type == ObjType.Eff)
|
||||
for (i0 = 0; i0 < Obj.Eff.Value.Marker.Count; i0++)
|
||||
IO.WritePointerString(ref UsedValues, ref Obj.Eff.Value.Marker.Entries[i0].Name);
|
||||
|
||||
IO.WritePointerString(ref UsedValues, ref Obj.Name);
|
||||
}
|
||||
|
||||
//IO.Align(0x4);
|
||||
|
||||
Aet.Name.Offset = IO.Position;
|
||||
IO.Write(Aet.Name.Value + x00);
|
||||
}
|
||||
|
||||
if (Aet.Unknown.Count > 0)
|
||||
{
|
||||
IO.Align(0x10);
|
||||
Aet.Unknown.Offset = IO.Position;
|
||||
for (i = 0; i < Aet.Unknown.Count * 10; i++)
|
||||
IO.Write(0L);
|
||||
}
|
||||
|
||||
IO.Align(0x10);
|
||||
int ReturnPosition = IO.Position;
|
||||
for (i = 0; i < NullValPointers.Count; i++)
|
||||
{
|
||||
IO.Position = NullValPointers[i];
|
||||
IO.Write(ReturnPosition + i * 4);
|
||||
}
|
||||
IO.Position = ReturnPosition;
|
||||
for (i = 0; i < NullValPointers.Count; i++) IO.Write(0);
|
||||
|
||||
IO.Align(1, true);
|
||||
|
||||
for (i = 0; i < Aet.ObjectsArr.Length; i++)
|
||||
{
|
||||
ref AetObject Obj = ref Aet.ObjectsArr[i].Value;
|
||||
if (Obj.Type == ObjType.Pic)
|
||||
{
|
||||
IO.Position = Obj.Pic.Offset;
|
||||
IO.Write(Aet.SprEntsArr[Aet.SprEntsIndDict[Obj.Pic.Value.SpriteEntryID]].Offset);
|
||||
IO.Write(Obj.Pic.Value.ParentObjectID > -1 ?
|
||||
Aet.ObjectsArr[Obj.Pic.Value.ParentObjectID].Offset : 0);
|
||||
IO.Write(Obj.Eff.Value.Marker.Count );
|
||||
IO.Write(Obj.Eff.Value.Marker.Offset);
|
||||
ref CountPointer<Marker> Marker = ref Obj.Pic.Value.Marker;
|
||||
IO.Position = Marker.Offset;
|
||||
for (i0 = 0; i0 < Marker.Count; i0++)
|
||||
{
|
||||
IO.Write(Marker.Entries[i0].Frame);
|
||||
IO.Write(Marker.Entries[i0]. Name.Offset);
|
||||
}
|
||||
}
|
||||
else if (Obj.Type == ObjType.Eff)
|
||||
{
|
||||
IO.Position = Obj.Eff.Offset;
|
||||
IO.Write(Aet.LayObjPointers.Entries[Obj.Eff.Value.LayerID].Offset);
|
||||
IO.Write(Obj.Eff.Value.ParentObjectID > -1 ?
|
||||
Aet.ObjectsArr[Obj.Eff.Value.ParentObjectID].Offset : 0);
|
||||
IO.Write(Obj.Eff.Value.Marker.Count );
|
||||
IO.Write(Obj.Eff.Value.Marker.Offset);
|
||||
ref CountPointer<Marker> Marker = ref Obj.Eff.Value.Marker;
|
||||
IO.Position = Marker.Offset;
|
||||
for (i0 = 0; i0 < Marker.Count; i0++)
|
||||
{
|
||||
IO.Write(Marker.Entries[i0].Frame);
|
||||
IO.Write(Marker.Entries[i0]. Name.Offset);
|
||||
}
|
||||
}
|
||||
|
||||
IO.Position = Aet.ObjectsArr[i].Offset;
|
||||
IO.Write(Obj.Name.Offset);
|
||||
}
|
||||
|
||||
if (Aet.SpritesArr != null)
|
||||
for (i = 0; i < Aet.SpritesArr.Length; i++)
|
||||
{
|
||||
IO.Position = Aet.SpritesArr[i].Offset;
|
||||
IO.Write(Aet.SpritesArr[i].Value.Name.Offset);
|
||||
}
|
||||
|
||||
for (i = 0; i < Aet.LayObjPointers.Count; i++)
|
||||
{
|
||||
IO.Position = Aet.LayObjPointers.Entries[i].Offset;
|
||||
IO.Write(Aet.LayObjPointers.Entries[i].Count);
|
||||
IO.Write(Aet.LayObjPointers.Entries[i].Count > 0 ?
|
||||
Aet.ObjectsArr[Aet.ObjectsIndDict[Aet.LayObjPointers.Entries[i].Entries[0]]].Offset : 0);
|
||||
}
|
||||
|
||||
IO.Position = AET.Offset;
|
||||
IO.Write(Aet.Name.Offset);
|
||||
IO.Position = AET.Offset + 0x20;
|
||||
IO.Write(Aet.LayObjPointers.Count );
|
||||
IO.Write(Aet.LayObjPointers.Offset);
|
||||
IO.Write(Aet.SprEntsArr.Length);
|
||||
IO.Write(Aet.SprEntsArr[0].Offset);
|
||||
if (Aet.Unknown.Count > 0)
|
||||
{ IO.Write(Aet.Unknown.Count); IO.Write(Aet.Unknown.Offset); }
|
||||
else IO.Write(0L);
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
AET = new AetHeader();
|
||||
AET.MAIN .Offset = -1;
|
||||
AET.TOUCH.Offset = -1;
|
||||
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
if (!MsgPack.Element<MsgPack>("Aet", out MsgPack Aet)) { MsgPack = null; return; }
|
||||
|
||||
if (Aet.Array != null)
|
||||
if (Aet.Array.Length == 1)
|
||||
{
|
||||
if (Aet.Array[0] is MsgPack MAIN ) MsgPackReader(MAIN , ref AET.MAIN );
|
||||
}
|
||||
else if (Aet.Array.Length == 2)
|
||||
{
|
||||
if (Aet.Array[0] is MsgPack MAIN ) MsgPackReader(MAIN , ref AET.MAIN );
|
||||
if (Aet.Array[1] is MsgPack TOUCH) MsgPackReader(TOUCH, ref AET.TOUCH);
|
||||
}
|
||||
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
if (this.AET.MAIN .Offset <= 0) return;
|
||||
MsgPack AET = new MsgPack("Aet", this.AET.TOUCH.Offset > 0 ? 2 : 1);
|
||||
|
||||
AET[0] = MsgPackWriter(ref this.AET.MAIN);
|
||||
if (this.AET.TOUCH.Offset > 0) AET[1] = MsgPackWriter(ref this.AET.TOUCH);
|
||||
|
||||
AET.WriteAfterAll(true, file, JSON);
|
||||
}
|
||||
|
||||
public void MsgPackReader(MsgPack AET, ref Pointer<AetData> AetData)
|
||||
{
|
||||
MsgPack Temp = new MsgPack();
|
||||
|
||||
AetData.Offset = -1;
|
||||
ref AetData Aet = ref AetData.Value;
|
||||
|
||||
Aet.Name.Value = AET.ReadString("Name" );
|
||||
Aet.Unk = AET.ReadSingle("Unk" );
|
||||
Aet.Duration = AET.ReadSingle("Duration" );
|
||||
Aet.FrameRate = AET.ReadSingle("FrameRate");
|
||||
Aet.Width = AET.ReadInt32("Width" );
|
||||
Aet.Height = AET.ReadInt32("Height");
|
||||
|
||||
if (AET.Element<MsgPack>("Layers", out MsgPack Layers))
|
||||
{
|
||||
Aet.LayObjPointers.Count = Layers.Array.Length;
|
||||
for (i = 0; i < Aet.LayObjPointers.Count; i++)
|
||||
if (Layers[i] is MsgPack ObjectID)
|
||||
{
|
||||
Aet.LayObjPointers.Entries[i].Count =
|
||||
ObjectID.Array == null ? 0 : ObjectID.Array.Length;
|
||||
for (i0 = 0; i0 < Aet.LayObjPointers.Entries[i].Count; i0++)
|
||||
if (ObjectID.Array[i0] is MsgPack msg)
|
||||
Aet.LayObjPointers.Entries[i].Entries[i0] = msg.ReadInt32();
|
||||
}
|
||||
}
|
||||
else return;
|
||||
|
||||
Aet.ObjectsIndDict = new Dictionary<int, int>();
|
||||
Aet.SprEntsIndDict = new Dictionary<int, int>();
|
||||
Aet.SpritesIndDict = new Dictionary<int, int>();
|
||||
|
||||
int? ID = null;
|
||||
if (AET.Element("SpriteEntry", out Temp))
|
||||
{
|
||||
Aet.SprEntsArr = new Pointer<SpriteEntry>[1];
|
||||
ID = Aet.SprEntsArr[0].Value.ReadMP(Temp);
|
||||
if (ID != null) Aet.SprEntsIndDict.Add(ID.Value, 0);
|
||||
}
|
||||
else if (AET.Element<MsgPack>("SpriteEntries", out Temp))
|
||||
{
|
||||
Aet.SprEntsArr = new Pointer<SpriteEntry>[Temp.Array.Length];
|
||||
for (i = 0; i < Aet.SprEntsArr.Length; i++)
|
||||
if (Temp[i] is MsgPack SpriteEntry)
|
||||
{
|
||||
ID = Aet.SprEntsArr[i].Value.ReadMP(SpriteEntry);
|
||||
if (ID != null) Aet.SprEntsIndDict.Add(ID.Value, i);
|
||||
}
|
||||
}
|
||||
else return;
|
||||
|
||||
if (AET.Element("Object", out Temp))
|
||||
{
|
||||
Aet.ObjectsArr = new Pointer<AetObject>[1];
|
||||
ID = Aet.ObjectsArr[0].Value.ReadMP(Temp, 0, ref Aet);
|
||||
if (ID != null) Aet.ObjectsIndDict.Add(ID.Value, 0);
|
||||
}
|
||||
else if (AET.Element<MsgPack>("Objects", out Temp))
|
||||
{
|
||||
Aet.ObjectsArr = new Pointer<AetObject>[Temp.Array.Length];
|
||||
for (i = 0; i < Aet.ObjectsArr.Length; i++)
|
||||
if (Temp[i] is MsgPack Object)
|
||||
{
|
||||
ID = Aet.ObjectsArr[i].Value.ReadMP(Object, i, ref Aet);
|
||||
if (ID != null) Aet.ObjectsIndDict.Add(ID.Value, i);
|
||||
}
|
||||
}
|
||||
else return;
|
||||
|
||||
if (AET.Element("Sprite", out Temp))
|
||||
{
|
||||
Aet.SpritesArr = new Pointer<Sprite>[1];
|
||||
ID = Aet.SpritesArr[0].Value.ReadMP(Temp);
|
||||
if (ID != null) Aet.SpritesIndDict.Add(ID.Value, 0);
|
||||
}
|
||||
else if (AET.Element<MsgPack>("Sprites", out Temp))
|
||||
{
|
||||
Aet.SpritesArr = new Pointer<Sprite>[Temp.Array.Length];
|
||||
for (i = 0; i < Aet.SpritesArr.Length; i++)
|
||||
if (Temp[i] is MsgPack Sprite)
|
||||
{
|
||||
ID = Aet.SpritesArr[i].Value.ReadMP(Sprite);
|
||||
if (ID != null) Aet.SpritesIndDict.Add(ID.Value, i);
|
||||
}
|
||||
}
|
||||
if (AET.Element("Unknown", out Temp))
|
||||
Aet.Unknown.Count = Temp.ReadInt32();
|
||||
|
||||
AetData.Offset = 0;
|
||||
}
|
||||
|
||||
|
||||
public MsgPack MsgPackWriter(ref Pointer<AetData> AetData)
|
||||
{
|
||||
if (AetData.Offset <= 0) return null;
|
||||
ref AetData Aet = ref AetData.Value;
|
||||
|
||||
Aet.ObjectsIndDict = Aet.ObjectsDict.GetIndDict();
|
||||
Aet.SpritesIndDict = Aet.SpritesDict.GetIndDict();
|
||||
Aet.SprEntsIndDict = Aet.SprEntsDict.GetIndDict();
|
||||
Aet.ObjectsArr = Aet.ObjectsDict.ToPointerArray();
|
||||
Aet.SpritesArr = Aet.SpritesDict.ToPointerArray();
|
||||
Aet.SprEntsArr = Aet.SprEntsDict.ToPointerArray();
|
||||
Aet.ObjectsDict = null;
|
||||
Aet.SpritesDict = null;
|
||||
Aet.SprEntsDict = null;
|
||||
|
||||
MsgPack AET = new MsgPack().Add("Name", Aet.Name.Value).Add("Duration",
|
||||
Aet.Duration).Add("FrameRate", Aet.FrameRate).Add("Width",
|
||||
Aet.Width).Add("Height", Aet.Height).Add("Unk", Aet.Unk);
|
||||
|
||||
if (Aet.LayObjPointers.Count > 0)
|
||||
{
|
||||
MsgPack Layers = new MsgPack("Layers", Aet.LayObjPointers.Count);
|
||||
for (i = 0; i < Aet.LayObjPointers.Count; i++)
|
||||
if (Aet.LayObjPointers.Entries[i].Count > 0)
|
||||
{
|
||||
MsgPack Objects = new MsgPack(Aet.LayObjPointers.Entries[i].Count);
|
||||
for (i0 = 0; i0 < Aet.LayObjPointers.Entries[i].Count; i0++)
|
||||
Objects[i0] = Aet.ObjectsIndDict[Aet.LayObjPointers.Entries[i].Entries[i0]];
|
||||
Layers[i] = Objects;
|
||||
}
|
||||
AET.Add(Layers);
|
||||
}
|
||||
|
||||
if (Aet.SprEntsArr.Length == 1)
|
||||
AET.Add(Aet.SprEntsArr[0].Value.WriteMP(0, ref Aet.SpritesIndDict, "SpriteEntry"));
|
||||
else if (Aet.SprEntsArr.Length > 0)
|
||||
{
|
||||
MsgPack SpriteEntries = new MsgPack("SpriteEntries", Aet.SprEntsArr.Length);
|
||||
for (i = 0; i < Aet.SprEntsArr.Length; i++)
|
||||
SpriteEntries[i] = Aet.SprEntsArr[i].Value.WriteMP(i, ref Aet.SpritesIndDict);
|
||||
AET.Add(SpriteEntries);
|
||||
}
|
||||
|
||||
if (Aet.ObjectsArr.Length == 1)
|
||||
AET.Add(Aet.ObjectsArr[0].Value.WriteMP(0, ref Aet, "Object"));
|
||||
else if (Aet.ObjectsArr.Length > 1)
|
||||
{
|
||||
MsgPack Objects = new MsgPack("Objects", Aet.ObjectsArr.Length);
|
||||
for (i = 0; i < Aet.ObjectsArr.Length; i++)
|
||||
Objects[i] = Aet.ObjectsArr[i].Value.WriteMP(i, ref Aet);
|
||||
AET.Add(Objects);
|
||||
}
|
||||
|
||||
if (Aet.SpritesArr.Length == 1)
|
||||
AET.Add(Aet.SpritesArr[0].Value.WriteMP(0, "Sprite"));
|
||||
else if (Aet.SpritesArr.Length > 1)
|
||||
{
|
||||
MsgPack Sprites = new MsgPack("Sprites", Aet.SpritesArr.Length);
|
||||
for (i = 0; i < Aet.SpritesArr.Length; i++)
|
||||
Sprites[i] = Aet.SpritesArr[i].Value.WriteMP(i);
|
||||
AET.Add(Sprites);
|
||||
}
|
||||
|
||||
if (Aet.Unknown.Count > 0)
|
||||
AET.Add("Unknown", Aet.Unknown.Count);
|
||||
|
||||
return AET;
|
||||
}
|
||||
}
|
||||
|
||||
public struct AetHeader
|
||||
{
|
||||
public Pointer<AetData> MAIN ;
|
||||
public Pointer<AetData> TOUCH;
|
||||
}
|
||||
|
||||
public struct AetData
|
||||
{
|
||||
public Pointer<string> Name;
|
||||
public float Unk;
|
||||
public float Duration;
|
||||
public float FrameRate;
|
||||
public int Width;
|
||||
public int Height;
|
||||
public int DontChange;
|
||||
public CountPointer<CountPointer<int>> LayObjPointers;
|
||||
public CountPointer<int> Unknown;
|
||||
|
||||
public Dictionary<int, int> LayObjDict;
|
||||
public Dictionary<int, int> ObjectsIndDict;
|
||||
public Dictionary<int, int> SpritesIndDict;
|
||||
public Dictionary<int, int> SprEntsIndDict;
|
||||
public Pointer< AetObject>[] ObjectsArr;
|
||||
public Pointer<SpriteEntry>[] SprEntsArr;
|
||||
public Pointer< Sprite>[] SpritesArr;
|
||||
public Dictionary<int, AetObject> ObjectsDict;
|
||||
public Dictionary<int, SpriteEntry> SprEntsDict;
|
||||
public Dictionary<int, Sprite> SpritesDict;
|
||||
}
|
||||
|
||||
public struct AetObject
|
||||
{
|
||||
public int Offset;
|
||||
public Pointer<string> Name;
|
||||
public float StartTime0;
|
||||
public float LoopDuration;
|
||||
public float StartTime1;
|
||||
public float PlaybackSpeed;
|
||||
public byte Unk0;
|
||||
public byte Unk1;
|
||||
public byte Unk2;
|
||||
public ObjType Type;
|
||||
public Pointer<Pic> Pic;
|
||||
public Pointer<Aif> Aif;
|
||||
public Pointer<Eff> Eff;
|
||||
|
||||
public int? ReadMP(MsgPack msg, int i, ref AetData Aet)
|
||||
{
|
||||
Name.Value = msg.ReadString("Name" );
|
||||
StartTime0 = msg.ReadSingle("StartTime0" );
|
||||
LoopDuration = msg.ReadSingle("LoopDuration" );
|
||||
StartTime1 = msg.ReadSingle("StartTime1" );
|
||||
PlaybackSpeed = msg.ReadSingle("PlaybackSpeed");
|
||||
Unk0 = msg.ReadUInt8("Unk0");
|
||||
Unk1 = msg.ReadUInt8("Unk1");
|
||||
Unk2 = msg.ReadUInt8("Unk2");
|
||||
if (msg.Element("Pic", out MsgPack Pic))
|
||||
{ Type = ObjType.Pic; this.Pic = new Pointer<Pic>() { Value = new Pic().ReadMP(Pic, i, ref Aet) }; }
|
||||
else if (msg.Element("Aif", out MsgPack Aif))
|
||||
{ Type = ObjType.Aif; this.Aif = new Pointer<Aif>() { Value = new Aif().ReadMP(Aif) }; }
|
||||
else if (msg.Element("Eff", out MsgPack Eff))
|
||||
{ Type = ObjType.Eff; this.Eff = new Pointer<Eff>() { Value = new Eff().ReadMP(Eff, i, ref Aet) }; }
|
||||
else Type = ObjType.Nop;
|
||||
|
||||
return msg.ReadNInt32("ID");
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(int Id, ref AetData Aet, string name = null)
|
||||
{
|
||||
MsgPack AetObject = new MsgPack(name).Add("ID", Id).Add("Name", Name.Value)
|
||||
.Add("StartTime0", StartTime0).Add("LoopDuration", LoopDuration)
|
||||
.Add("StartTime1", StartTime1).Add("PlaybackSpeed", PlaybackSpeed)
|
||||
.Add("Unk0", Unk0).Add("Unk1", Unk1).Add("Unk2", Unk2);
|
||||
|
||||
if (Type == ObjType.Pic) AetObject.Add(Pic.Value.WriteMP(ref Aet));
|
||||
else if (Type == ObjType.Aif) AetObject.Add(Aif.Value.WriteMP());
|
||||
else if (Type == ObjType.Eff) AetObject.Add(Eff.Value.WriteMP(ref Aet));
|
||||
return AetObject;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Pic
|
||||
{
|
||||
public int SpriteEntryID;
|
||||
public int ParentObjectID;
|
||||
public CountPointer<Marker> Marker;
|
||||
public Pointer<AnimationData> Data;
|
||||
|
||||
public Pic ReadMP(MsgPack msg, int i, ref AetData Aet)
|
||||
{
|
||||
int SpriteEntryID = msg.ReadInt32("SpriteEntryID");
|
||||
if (Aet.SprEntsIndDict.ContainsValue(SpriteEntryID))
|
||||
this.SpriteEntryID = Aet.SprEntsIndDict.GetKey(SpriteEntryID);
|
||||
|
||||
this.ParentObjectID = -1;
|
||||
int? ParentObjectID = msg.ReadNInt32("ParentObjectID");
|
||||
if (ParentObjectID != null)
|
||||
this.ParentObjectID = ParentObjectID.Value;
|
||||
|
||||
if (msg.Element("Marker", out MsgPack Marker))
|
||||
{
|
||||
this.Marker.Count = 1;
|
||||
this.Marker.Entries[0].ReadMP(Marker);
|
||||
}
|
||||
else if (msg.Element<MsgPack>("Markers", out MsgPack Markers))
|
||||
{
|
||||
this.Marker.Count = Markers.Array.Length;
|
||||
for (i = 0; i < Markers.Array.Length; i++)
|
||||
if (Markers[i] is MsgPack Object)
|
||||
this.Marker.Entries[i].ReadMP(Object);
|
||||
}
|
||||
else this.Marker.Entries = null;
|
||||
|
||||
Data.Value.ReadMP(msg);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(ref AetData Aet)
|
||||
{
|
||||
MsgPack Pic = new MsgPack("Pic");
|
||||
if (Aet.SprEntsIndDict.ContainsKey(SpriteEntryID))
|
||||
Pic.Add("SpriteEntryID", Aet.SprEntsIndDict[SpriteEntryID]);
|
||||
if (ParentObjectID > 0)
|
||||
if (Aet.ObjectsIndDict.ContainsKey(ParentObjectID))
|
||||
Pic.Add("ParentObjectID", Aet.ObjectsIndDict[ParentObjectID]);
|
||||
|
||||
if (Marker.Count == 1)
|
||||
Pic.Add(Marker.Entries[0].WriteMP("Marker"));
|
||||
else if (Marker.Count > 1)
|
||||
{
|
||||
MsgPack Markers = new MsgPack("Markers", Marker.Count);
|
||||
for (int i = 0; i < Marker.Count; i++)
|
||||
Markers[i] = Marker.Entries[i].WriteMP();
|
||||
Pic.Add(Markers);
|
||||
}
|
||||
|
||||
Pic.Add(Data.Value.WriteMP());
|
||||
return Pic;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Aif
|
||||
{
|
||||
public Pointer<int> Value;
|
||||
public int Zero0;
|
||||
public int Zero1;
|
||||
public int Zero2;
|
||||
public int Zero3;
|
||||
public int Pointer;
|
||||
public CountPointer<float> Unk0;
|
||||
public CountPointer<float> Unk1;
|
||||
public CountPointer<float> Unk2;
|
||||
public CountPointer<float> Unk3;
|
||||
|
||||
public Aif ReadMP(MsgPack msg)
|
||||
{
|
||||
Value.Value = msg.ReadInt32("Value");
|
||||
|
||||
msg.ReadMP(ref Unk0, "Unk0");
|
||||
msg.ReadMP(ref Unk1, "Unk1");
|
||||
msg.ReadMP(ref Unk2, "Unk2");
|
||||
msg.ReadMP(ref Unk3, "Unk3");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgPack WriteMP() =>
|
||||
new MsgPack("Aif").Add("Value", Value.Value).Add(Unk0.WriteMP("Unk0")).Add(Unk1
|
||||
.WriteMP("Unk1")).Add(Unk2.WriteMP("Unk2")).Add(Unk3.WriteMP("Unk3"));
|
||||
}
|
||||
|
||||
public struct Eff
|
||||
{
|
||||
public int LayerID;
|
||||
public int ParentObjectID;
|
||||
public CountPointer<Marker> Marker;
|
||||
public Pointer<AnimationData> Data;
|
||||
|
||||
public Eff ReadMP(MsgPack msg, int i, ref AetData Aet)
|
||||
{
|
||||
LayerID = msg.ReadInt32("LayerID");
|
||||
|
||||
this.ParentObjectID = -1;
|
||||
int? ParentObjectID = msg.ReadNInt32("ParentObjectID");
|
||||
if (ParentObjectID != null)
|
||||
this.ParentObjectID = ParentObjectID.Value;
|
||||
|
||||
if (msg.Element("Marker", out MsgPack Marker))
|
||||
{
|
||||
this.Marker.Count = 1;
|
||||
this.Marker.Entries[0].ReadMP(Marker);
|
||||
}
|
||||
else if (msg.Element<MsgPack>("Markers", out MsgPack Markers))
|
||||
{
|
||||
this.Marker.Count = Markers.Array.Length;
|
||||
for (i = 0; i < Markers.Array.Length; i++)
|
||||
if (Markers[i] is MsgPack Object)
|
||||
this.Marker.Entries[i].ReadMP(Object);
|
||||
}
|
||||
else this.Marker.Entries = null;
|
||||
|
||||
Data.Value.ReadMP(msg);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(ref AetData Aet)
|
||||
{
|
||||
MsgPack Eff = new MsgPack("Eff");
|
||||
if (Aet.LayObjDict.ContainsValue(LayerID))
|
||||
Eff.Add("LayerID", Aet.LayObjDict.GetKey(LayerID));
|
||||
if (ParentObjectID > 0)
|
||||
if (Aet.ObjectsIndDict.ContainsKey(ParentObjectID))
|
||||
Eff.Add("ParentObjectID", Aet.ObjectsIndDict[ParentObjectID]);
|
||||
|
||||
if (Marker.Count == 1)
|
||||
Eff.Add(Marker.Entries[0].WriteMP("Marker"));
|
||||
else if (Marker.Count > 1)
|
||||
{
|
||||
MsgPack Markers = new MsgPack("Markers", Marker.Count);
|
||||
for (int i = 0; i < Marker.Count; i++)
|
||||
Markers[i] = Marker.Entries[i].WriteMP();
|
||||
Eff.Add(Markers);
|
||||
}
|
||||
|
||||
Eff.Add(Data.Value.WriteMP());
|
||||
|
||||
return Eff;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Marker
|
||||
{
|
||||
public float Frame;
|
||||
public Pointer<string> Name;
|
||||
|
||||
public void ReadMP(MsgPack mp)
|
||||
{ Frame = mp.ReadSingle("Frame"); Name.Value = mp.ReadString("Name"); }
|
||||
|
||||
public MsgPack WriteMP(string name = null) =>
|
||||
new MsgPack(name).Add("Frame", Frame).Add("Name", Name.Value);
|
||||
}
|
||||
|
||||
public struct SubAnimationData
|
||||
{
|
||||
public KeyFrameEntry OriginX;
|
||||
public KeyFrameEntry OriginY;
|
||||
public KeyFrameEntry PositionX;
|
||||
public KeyFrameEntry PositionY;
|
||||
public KeyFrameEntry Rotation;
|
||||
public KeyFrameEntry ScaleX;
|
||||
public KeyFrameEntry ScaleY;
|
||||
public KeyFrameEntry Opacity;
|
||||
|
||||
public void ReadMP(MsgPack msg)
|
||||
{
|
||||
OriginX.ReadMP(msg, "OriginX");
|
||||
OriginY.ReadMP(msg, "OriginY");
|
||||
PositionX.ReadMP(msg, "PositionX");
|
||||
PositionY.ReadMP(msg, "PositionY");
|
||||
Rotation .ReadMP(msg, "Rotation" );
|
||||
ScaleX.ReadMP(msg, "ScaleX");
|
||||
ScaleY.ReadMP(msg, "ScaleY");
|
||||
Opacity .ReadMP(msg, "Opacity" );
|
||||
}
|
||||
|
||||
public MsgPack WriteMP()
|
||||
{
|
||||
MsgPack AnimationData = new MsgPack("SubAnimationData");
|
||||
WriteMP(ref AnimationData);
|
||||
return AnimationData;
|
||||
}
|
||||
|
||||
public void WriteMP(ref MsgPack msg)
|
||||
{
|
||||
msg.Add( OriginX.WriteMP( "OriginX"));
|
||||
msg.Add( OriginY.WriteMP( "OriginY"));
|
||||
msg.Add(PositionX.WriteMP("PositionX"));
|
||||
msg.Add(PositionY.WriteMP("PositionY"));
|
||||
msg.Add(Rotation .WriteMP("Rotation" ));
|
||||
msg.Add( ScaleX.WriteMP( "ScaleX"));
|
||||
msg.Add( ScaleY.WriteMP( "ScaleY"));
|
||||
msg.Add(Opacity .WriteMP("Opacity" ));
|
||||
}
|
||||
}
|
||||
|
||||
public struct AnimationData
|
||||
{
|
||||
public BlendMode BlendMode;
|
||||
public byte Unk0;
|
||||
public bool UseTextureMask;
|
||||
public byte Unk1;
|
||||
public SubAnimationData Anim;
|
||||
public Pointer<SubAnimationData> SubAnim;
|
||||
|
||||
public void ReadMP(MsgPack msg)
|
||||
{
|
||||
if (!msg.Element("AnimationData", out MsgPack Data)) return;
|
||||
|
||||
System.Enum.TryParse(Data.ReadString("BlendMode"), out BlendMode);
|
||||
Unk0 = Data.ReadUInt8 ("Unk0");
|
||||
UseTextureMask = Data.ReadBoolean("UseTextureMask");
|
||||
Unk1 = Data.ReadUInt8 ("Unk1");
|
||||
|
||||
Anim.ReadMP(Data);
|
||||
|
||||
SubAnim.Offset = -1;
|
||||
if (Data.Element("SubAnimationData", out MsgPack SubAnimationData))
|
||||
{ SubAnim.Offset = 0; SubAnim.Value.ReadMP(SubAnimationData); }
|
||||
}
|
||||
|
||||
public MsgPack WriteMP()
|
||||
{
|
||||
MsgPack AnimationData = new MsgPack("AnimationData")
|
||||
.Add("BlendMode", BlendMode.ToString()).Add("Unk0", Unk0)
|
||||
.Add("UseTextureMask", UseTextureMask) .Add("Unk1", Unk1);
|
||||
|
||||
Anim.WriteMP(ref AnimationData);
|
||||
if (SubAnim.Offset > 0)
|
||||
AnimationData.Add(SubAnim.Value.WriteMP());
|
||||
return AnimationData;
|
||||
}
|
||||
}
|
||||
|
||||
public struct KeyFrameEntry
|
||||
{
|
||||
public int Count;
|
||||
public int Offset;
|
||||
public float Value;
|
||||
public float[] ArrValue;
|
||||
public float[] KeyFrame;
|
||||
public float[] Interpolation;
|
||||
|
||||
public void ReadMP(MsgPack msg, string name)
|
||||
{
|
||||
float? Value = msg.ReadNSingle(name);
|
||||
if (Value != null) { Count = 1; this.Value = Value.Value; return; }
|
||||
if (!msg.Element<MsgPack>(name, out MsgPack Temp)) return;
|
||||
|
||||
MsgPack temp;
|
||||
Count = Temp.Array.Length;
|
||||
if (Count == 0) return;
|
||||
ArrValue = new float[Count];
|
||||
KeyFrame = new float[Count];
|
||||
Interpolation = new float[Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
temp = Temp[i] as MsgPack;
|
||||
KeyFrame [i] = temp.ReadSingle("KeyFrame" );
|
||||
ArrValue [i] = temp.ReadSingle("Value" );
|
||||
Interpolation[i] = temp.ReadSingle("Interpolation");
|
||||
}
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(string name)
|
||||
{
|
||||
if (Count < 1) return MsgPack.Null;
|
||||
if (Count == 1) return new MsgPack(name, MsgPack.Types.Float32, Value);
|
||||
MsgPack KFE = new MsgPack(name, Count);
|
||||
for (int i = 0; i < Count; i++) KFE[i] = new MsgPack().Add("KeyFrame", KeyFrame[i])
|
||||
.Add("Value", ArrValue[i]).Add("Interpolation", Interpolation[i]);
|
||||
return KFE;
|
||||
}
|
||||
}
|
||||
|
||||
public struct SpriteEntry
|
||||
{
|
||||
public int Unknown;
|
||||
public short Width;
|
||||
public short Height;
|
||||
public float Frames;
|
||||
public CountPointer<int> Sprites;
|
||||
|
||||
public int? ReadMP(MsgPack msg)
|
||||
{
|
||||
Unknown = msg.ReadInt32 ("Unknown");
|
||||
Width = msg.ReadInt16 ("Width" );
|
||||
Height = msg.ReadInt16 ("Height" );
|
||||
Frames = msg.ReadSingle("Frames" );
|
||||
|
||||
if (msg.Element("SpriteID", out MsgPack SpriteID))
|
||||
{
|
||||
Sprites = new CountPointer<int> { Count = 1 };
|
||||
Sprites.Entries[0] = SpriteID.ReadInt32();
|
||||
}
|
||||
else if (msg.Element<MsgPack>("SpriteIDs", out MsgPack SpriteIDs))
|
||||
{
|
||||
Sprites = new CountPointer<int> { Count = SpriteIDs.Array.Length };
|
||||
for (int i0 = 0; i0 < Sprites.Count; i0++)
|
||||
Sprites.Entries[i0] = (SpriteIDs[i0] as MsgPack).ReadInt32();
|
||||
}
|
||||
|
||||
return msg.ReadNInt32("ID");
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(int Id, ref Dictionary<int, int> SpritesIndDict, string Name = null)
|
||||
{
|
||||
MsgPack SpriteEntry = new MsgPack(Name).Add("ID", Id)
|
||||
.Add("Width", Width).Add("Height", Height).Add("Unknown", Unknown);
|
||||
|
||||
if (Sprites.Count > 0) SpriteEntry.Add("Frames", Frames);
|
||||
|
||||
if (Sprites.Count == 1)
|
||||
SpriteEntry.Add("SpriteID", SpritesIndDict[Sprites.Entries[0]]);
|
||||
else if (Sprites.Count > 1)
|
||||
{
|
||||
MsgPack SpriteIDs = new MsgPack("SpriteIDs", Sprites.Count);
|
||||
for (int i0 = 0; i0 < Sprites.Count; i0++)
|
||||
SpriteIDs[i0] = SpritesIndDict[Sprites.Entries[i0]];
|
||||
SpriteEntry.Add(SpriteIDs);
|
||||
}
|
||||
|
||||
return SpriteEntry;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Sprite
|
||||
{
|
||||
public Pointer<string> Name;
|
||||
public int ID;
|
||||
|
||||
public MsgPack WriteMP(int Id, string name = null) =>
|
||||
new MsgPack(name).Add("ID", Id).Add("Name", Name.Value).Add("SprDB_ID", ID);
|
||||
|
||||
public int? ReadMP(MsgPack mp)
|
||||
{ ID = mp.ReadInt32("SprDB_ID"); Name.Value = mp.ReadString("Name"); return mp.ReadNInt32("ID"); }
|
||||
}
|
||||
|
||||
public struct CountPointer<T>
|
||||
{
|
||||
public int Count { get => Entries == null ? 0 : Entries.Length; set => Entries = new T[value]; }
|
||||
public int Offset;
|
||||
|
||||
public T[] Entries;
|
||||
|
||||
public override string ToString() => Entries.ToString();
|
||||
}
|
||||
|
||||
public struct Pointer<T>
|
||||
{
|
||||
public int Offset;
|
||||
public T Value;
|
||||
|
||||
public override string ToString() => Value.ToString();
|
||||
}
|
||||
|
||||
public enum ObjType : byte
|
||||
{
|
||||
Nop = 0,
|
||||
Pic = 1,
|
||||
Aif = 2,
|
||||
Eff = 3,
|
||||
}
|
||||
|
||||
public enum BlendMode : byte
|
||||
{
|
||||
Alpha = 3,
|
||||
Additive = 5,
|
||||
DstColorZero = 6,
|
||||
SrcAlphaOneMinusSrcColor = 7,
|
||||
Transparent = 8,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,465 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib.Aet
|
||||
{
|
||||
public static class AetExt
|
||||
{
|
||||
private static System.Text.Encoding ShiftJIS = System.Text.Encoding.GetEncoding(932);
|
||||
|
||||
public static Dictionary<TKey, int> GetIndDict<TKey, TVal>(this Dictionary<TKey, TVal> Dict)
|
||||
{
|
||||
List<TKey> Keys = Dict.Keys.ToList();
|
||||
Dictionary<TKey, int> IndDict = new Dictionary<TKey, int>();
|
||||
for (int i = 0; i < Keys.Count; i++)
|
||||
IndDict.Add(Keys[i], i);
|
||||
return IndDict;
|
||||
}
|
||||
|
||||
public static Pointer<T>[] ToPointerArray<T>(this Dictionary<int, T> val)
|
||||
{
|
||||
Pointer<T>[] arr = new Pointer<T>[val.Count];
|
||||
for (int i = 0; i < val.Count; i++)
|
||||
arr[i] = val.ElementAt(i).ToPointer();
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static Pointer<T> ReadPointer<T>(this Stream IO) =>
|
||||
new Pointer<T> { Offset = IO.ReadInt32() };
|
||||
|
||||
public static Pointer<string> ReadPointerString(this Stream IO)
|
||||
{ Pointer<string> val = IO.ReadPointer<string>();
|
||||
val.Value = IO.ReadStringAtOffset(val.Offset); return val; }
|
||||
|
||||
public static Pointer<string> ReadPointerStringShiftJIS(this Stream IO)
|
||||
{ Pointer<string> val = IO.ReadPointer<string>();
|
||||
val.Value = ShiftJIS.GetString(IO.ReadAtOffset(val.Offset)); return val; }
|
||||
|
||||
public static void WriteShiftJIS(this Stream IO, string String) =>
|
||||
IO.Write(ShiftJIS.GetBytes(String));
|
||||
|
||||
public static CountPointer<T> ReadCountPointer<T>(this Stream IO)
|
||||
{ CountPointer<T> val = new CountPointer<T> { Count = IO.ReadInt32(),
|
||||
Offset = IO.ReadInt32() }; val.Entries = new T[val.Count]; return val; }
|
||||
|
||||
|
||||
public static Pointer<T> ToPointer<T>(this KeyValuePair<int, T> val) =>
|
||||
new Pointer<T> { Offset = val.Key, Value = val.Value };
|
||||
|
||||
public static void ReadMP(this MsgPack msg, ref CountPointer<float> val, string Name)
|
||||
{
|
||||
val.Offset = 0;
|
||||
val.Entries = null;
|
||||
if (msg.ContainsKey(Name))
|
||||
{
|
||||
val.Count = 1;
|
||||
val.Entries[0] = msg.ReadSingle(Name);
|
||||
}
|
||||
else if(msg.Element<MsgPack>(Name, out MsgPack Temp))
|
||||
{
|
||||
val.Count = Temp.Array.Length;
|
||||
for (int i = 0; i < val.Count; i++)
|
||||
if (Temp[i] is MsgPack temp)
|
||||
val.Entries[i] = temp.ReadSingle();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static MsgPack WriteMP(this CountPointer<float> val, string Name)
|
||||
{
|
||||
if (val.Count == 1) return new MsgPack(Name, MsgPack.Types.Float32, val.Entries[0]);
|
||||
else if (val.Count > 1)
|
||||
{
|
||||
MsgPack Val = new MsgPack(Name, val.Count);
|
||||
for (int i = 0; i < val.Count; i++) Val[i] = val.Entries[i];
|
||||
return Val;
|
||||
}
|
||||
return MsgPack.Null;
|
||||
}
|
||||
|
||||
public static int ReadAetObject(this Stream IO, ref Dictionary<int, AetObject> ObjectsDict)
|
||||
{
|
||||
AetObject Anim = new AetObject();
|
||||
int AnimOffset = IO.Position;
|
||||
if (ObjectsDict.ContainsKey(AnimOffset)) return AnimOffset;
|
||||
Anim.Name = IO.ReadPointerString();
|
||||
Anim.StartTime0 = IO.ReadSingle();
|
||||
Anim.LoopDuration = IO.ReadSingle();
|
||||
Anim.StartTime1 = IO.ReadSingle();
|
||||
Anim.PlaybackSpeed = IO.ReadSingle();
|
||||
Anim.Unk0 = IO.ReadByte();
|
||||
Anim.Unk1 = IO.ReadByte();
|
||||
Anim.Unk2 = IO.ReadByte();
|
||||
Anim.Type = (ObjType)IO.ReadByte();
|
||||
if (Anim.Type == ObjType.Pic) Anim.Pic = IO.ReadPic(ref ObjectsDict);
|
||||
else if (Anim.Type == ObjType.Aif) Anim.Aif = IO.ReadAif();
|
||||
else if (Anim.Type == ObjType.Eff) Anim.Eff = IO.ReadEff(ref ObjectsDict);
|
||||
IO.Position = AnimOffset + 0x30;
|
||||
if (!ObjectsDict.ContainsKey(AnimOffset))
|
||||
ObjectsDict.Add(AnimOffset, Anim);
|
||||
return AnimOffset;
|
||||
}
|
||||
|
||||
public static void Write(this Stream IO, ref AetObject Anim, ref List<int> NullValPointers)
|
||||
{
|
||||
if (Anim.Type == ObjType.Pic)
|
||||
{
|
||||
if (Anim.Pic.Value.Marker.Count > 0)
|
||||
{
|
||||
Anim.Pic.Value.Marker.Offset = IO.Position;
|
||||
for (int i = 0; i < Anim.Pic.Value.Marker.Count; i++) IO.Write(0L);
|
||||
}
|
||||
IO.Write(ref Anim.Pic.Value.Data, ref NullValPointers);
|
||||
}
|
||||
else if (Anim.Type == ObjType.Aif) IO.Write(ref Anim.Aif);
|
||||
else if (Anim.Type == ObjType.Eff)
|
||||
{
|
||||
if (Anim.Eff.Value.Marker.Count > 0)
|
||||
{
|
||||
Anim.Eff.Value.Marker.Offset = IO.Position;
|
||||
for (int i = 0; i < Anim.Eff.Value.Marker.Count; i++) IO.Write(0L);
|
||||
}
|
||||
IO.Write(ref Anim.Eff.Value.Data, ref NullValPointers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void Write(this Stream IO, ref AetObject Anim, ref int Offset)
|
||||
{
|
||||
Offset = IO.Position;
|
||||
IO.Write(0);
|
||||
IO.Write(Anim.StartTime0 );
|
||||
IO.Write(Anim.LoopDuration );
|
||||
IO.Write(Anim.StartTime1 );
|
||||
IO.Write(Anim.PlaybackSpeed);
|
||||
IO.Write(Anim.Unk0);
|
||||
IO.Write(Anim.Unk1);
|
||||
IO.Write(Anim.Unk2);
|
||||
IO.Write((byte)Anim.Type);
|
||||
if (Anim.Type == ObjType.Pic) IO.Write(ref Anim.Pic);
|
||||
else if (Anim.Type == ObjType.Aif)
|
||||
{
|
||||
Anim.Aif.Offset = IO.Position;
|
||||
IO.Write(Anim.Aif.Value.Value.Offset);
|
||||
IO.Write(0L);
|
||||
IO.Write(0L);
|
||||
IO.Write(Anim.Aif.Value.Pointer);
|
||||
}
|
||||
else if (Anim.Type == ObjType.Eff) IO.Write(ref Anim.Eff);
|
||||
else { IO.Write(0L); IO.Write(0L); IO.Write(0L); }
|
||||
}
|
||||
|
||||
public static Pointer<Pic> ReadPic(this Stream IO, ref Dictionary<int, AetObject> ObjectsDict)
|
||||
{
|
||||
Pointer<Pic> Pic = new Pointer<Pic> { Offset = IO.Position,
|
||||
Value = new Pic
|
||||
{
|
||||
SpriteEntryID = IO.ReadInt32(),
|
||||
ParentObjectID = IO.ReadInt32(),
|
||||
Marker = IO.ReadCountPointer<Marker>()
|
||||
}
|
||||
};
|
||||
Pic.Value.Data.Offset = IO.ReadInt32();
|
||||
IO.ReadAnimData(ref Pic.Value.Data);
|
||||
|
||||
IO.Position = Pic.Value.Marker.Offset;
|
||||
for (int i = 0; i < Pic.Value.Marker.Count; i++)
|
||||
{
|
||||
Pic.Value.Marker.Entries[i].Frame = IO.ReadSingle();
|
||||
Pic.Value.Marker.Entries[i]. Name = IO.ReadPointerStringShiftJIS();
|
||||
}
|
||||
|
||||
return Pic;
|
||||
}
|
||||
|
||||
public static void Write(this Stream IO, ref Pointer<Pic> Pic)
|
||||
{
|
||||
Pic.Offset = IO.Position;
|
||||
IO.Write(0L);
|
||||
if (Pic.Value.Marker.Count > 0)
|
||||
{
|
||||
IO.Write(Pic.Value.Marker.Count );
|
||||
IO.Write(Pic.Value.Marker.Offset);
|
||||
}
|
||||
else IO.Write(0L);
|
||||
IO.Write(Pic.Value.Data .Offset);
|
||||
IO.Write(0);
|
||||
}
|
||||
|
||||
public static Pointer<Aif> ReadAif(this Stream IO)
|
||||
{
|
||||
Pointer<Aif> Aif = new Pointer<Aif> { Offset = IO.Position,
|
||||
Value = new Aif
|
||||
{
|
||||
Value = IO.ReadPointer<int>(),
|
||||
Zero0 = IO.ReadInt32(),
|
||||
Zero1 = IO.ReadInt32(),
|
||||
Zero2 = IO.ReadInt32(),
|
||||
Zero3 = IO.ReadInt32(),
|
||||
Pointer = IO.ReadInt32(),
|
||||
}
|
||||
};
|
||||
|
||||
IO.Position = Aif.Value.Value.Offset;
|
||||
Aif.Value.Value.Value = IO.ReadInt32();
|
||||
|
||||
IO.Position = Aif.Value.Pointer;
|
||||
Aif.Value.Unk0 = IO.ReadCountPointer<float>();
|
||||
Aif.Value.Unk1 = IO.ReadCountPointer<float>();
|
||||
Aif.Value.Unk2 = IO.ReadCountPointer<float>();
|
||||
Aif.Value.Unk3 = IO.ReadCountPointer<float>();
|
||||
|
||||
IO.Position = Aif.Value.Unk0.Offset;
|
||||
for (int i = 0; i < Aif.Value.Unk0.Count; i++) Aif.Value.Unk0.Entries[i] = IO.ReadSingle();
|
||||
IO.Position = Aif.Value.Unk1.Offset;
|
||||
for (int i = 0; i < Aif.Value.Unk1.Count; i++) Aif.Value.Unk1.Entries[i] = IO.ReadSingle();
|
||||
IO.Position = Aif.Value.Unk2.Offset;
|
||||
for (int i = 0; i < Aif.Value.Unk2.Count; i++) Aif.Value.Unk2.Entries[i] = IO.ReadSingle();
|
||||
IO.Position = Aif.Value.Unk3.Offset;
|
||||
for (int i = 0; i < Aif.Value.Unk3.Count; i++) Aif.Value.Unk3.Entries[i] = IO.ReadSingle();
|
||||
|
||||
return Aif;
|
||||
}
|
||||
|
||||
public static void Write(this Stream IO, ref Pointer<Aif> Aif)
|
||||
{
|
||||
if (Aif.Value.Unk0.Count > 0) { Aif.Value.Unk0.Offset = IO.Position;
|
||||
for (int i = 0; i < Aif.Value.Unk0.Count; i++) IO.Write(Aif.Value.Unk0.Entries[i]); }
|
||||
if (Aif.Value.Unk1.Count > 0) { Aif.Value.Unk1.Offset = IO.Position;
|
||||
for (int i = 0; i < Aif.Value.Unk1.Count; i++) IO.Write(Aif.Value.Unk1.Entries[i]); }
|
||||
if (Aif.Value.Unk2.Count > 0) { Aif.Value.Unk2.Offset = IO.Position;
|
||||
for (int i = 0; i < Aif.Value.Unk2.Count; i++) IO.Write(Aif.Value.Unk2.Entries[i]); }
|
||||
if (Aif.Value.Unk3.Count > 0) { Aif.Value.Unk3.Offset = IO.Position;
|
||||
for (int i = 0; i < Aif.Value.Unk3.Count; i++) IO.Write(Aif.Value.Unk3.Entries[i]); }
|
||||
|
||||
IO.Align(0x10);
|
||||
Aif.Value.Value.Offset = IO.Position;
|
||||
IO.Write(Aif.Value.Value.Value);
|
||||
|
||||
IO.Align(0x10);
|
||||
Aif.Value.Pointer = IO.Position;
|
||||
if (Aif.Value.Unk0.Count > 0) { IO.Write(Aif.Value.Unk0.Count); IO.Write(Aif.Value.Unk0.Offset); }
|
||||
else IO.Write(0L);
|
||||
if (Aif.Value.Unk1.Count > 0) { IO.Write(Aif.Value.Unk1.Count); IO.Write(Aif.Value.Unk1.Offset); }
|
||||
else IO.Write(0L);
|
||||
if (Aif.Value.Unk2.Count > 0) { IO.Write(Aif.Value.Unk2.Count); IO.Write(Aif.Value.Unk2.Offset); }
|
||||
else IO.Write(0L);
|
||||
if (Aif.Value.Unk3.Count > 0) { IO.Write(Aif.Value.Unk3.Count); IO.Write(Aif.Value.Unk3.Offset); }
|
||||
else IO.Write(0L);
|
||||
}
|
||||
|
||||
public static Pointer<Eff> ReadEff(this Stream IO, ref Dictionary<int, AetObject> ObjectsDict)
|
||||
{
|
||||
Pointer<Eff> Eff = new Pointer<Eff> { Offset = IO.Position,
|
||||
Value = new Eff
|
||||
{
|
||||
LayerID = IO.ReadInt32(),
|
||||
ParentObjectID = IO.ReadInt32(),
|
||||
Marker = IO.ReadCountPointer<Marker>()
|
||||
}
|
||||
};
|
||||
Eff.Value.Data.Offset = IO.ReadInt32();
|
||||
IO.Position = Eff.Value.LayerID;
|
||||
CountPointer<AetObject> AetObjEntry = IO.ReadCountPointer<AetObject>();
|
||||
IO.Position = AetObjEntry.Offset;
|
||||
for (int i = 0; i < AetObjEntry.Count; i++) IO.ReadAetObject(ref ObjectsDict);
|
||||
IO.Position = Eff.Value.Marker.Offset;
|
||||
for (int i = 0; i < Eff.Value.Marker.Count; i++)
|
||||
{
|
||||
Eff.Value.Marker.Entries[i].Frame = IO.ReadSingle();
|
||||
Eff.Value.Marker.Entries[i]. Name = IO.ReadPointerStringShiftJIS();
|
||||
}
|
||||
IO.ReadAnimData(ref Eff.Value.Data);
|
||||
|
||||
return Eff;
|
||||
}
|
||||
|
||||
public static void Write(this Stream IO, ref Pointer<Eff> Eff)
|
||||
{
|
||||
Eff.Offset = IO.Position;
|
||||
IO.Write(0L);
|
||||
if (Eff.Value.Marker.Count > 0)
|
||||
{
|
||||
IO.Write(Eff.Value.Marker.Count );
|
||||
IO.Write(Eff.Value.Marker.Offset);
|
||||
}
|
||||
else IO.Write(0L);
|
||||
IO.Write(Eff.Value.Data.Offset);
|
||||
IO.Write(0);
|
||||
}
|
||||
|
||||
public static void ReadAnimData(this Stream IO, ref Pointer<AnimationData> Anim)
|
||||
{
|
||||
ref AnimationData Data = ref Anim.Value;
|
||||
IO.Position = Anim.Offset;
|
||||
Data.BlendMode = (BlendMode)IO.ReadByte();
|
||||
Data.Unk0 = IO.ReadByte();
|
||||
Data.UseTextureMask = IO.ReadBoolean();
|
||||
Data.Unk1 = IO.ReadByte();
|
||||
Data.Anim = IO.ReadSubAnimData();
|
||||
Data.SubAnim = IO.ReadPointer<SubAnimationData>();
|
||||
|
||||
IO.ReadSubAnimData(ref Data.Anim);
|
||||
|
||||
if (Data.SubAnim.Offset > 0)
|
||||
{
|
||||
IO.Position = Data.SubAnim.Offset;
|
||||
Data.SubAnim.Value = IO.ReadSubAnimData();
|
||||
IO.ReadSubAnimData(ref Data.SubAnim.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public static SubAnimationData ReadSubAnimData(this Stream IO)
|
||||
{
|
||||
SubAnimationData Data = new SubAnimationData() { };
|
||||
Data. OriginX = IO.ReadKeyFrameEntry();
|
||||
Data. OriginY = IO.ReadKeyFrameEntry();
|
||||
Data.PositionX = IO.ReadKeyFrameEntry();
|
||||
Data.PositionY = IO.ReadKeyFrameEntry();
|
||||
Data.Rotation = IO.ReadKeyFrameEntry();
|
||||
Data. ScaleX = IO.ReadKeyFrameEntry();
|
||||
Data. ScaleY = IO.ReadKeyFrameEntry();
|
||||
Data.Opacity = IO.ReadKeyFrameEntry();
|
||||
return Data;
|
||||
}
|
||||
|
||||
public static void ReadSubAnimData(this Stream IO, ref SubAnimationData Data)
|
||||
{
|
||||
IO.ReadKeyFrameEntry(ref Data. OriginX);
|
||||
IO.ReadKeyFrameEntry(ref Data. OriginY);
|
||||
IO.ReadKeyFrameEntry(ref Data.PositionX);
|
||||
IO.ReadKeyFrameEntry(ref Data.PositionY);
|
||||
IO.ReadKeyFrameEntry(ref Data.Rotation );
|
||||
IO.ReadKeyFrameEntry(ref Data. ScaleX);
|
||||
IO.ReadKeyFrameEntry(ref Data. ScaleY);
|
||||
IO.ReadKeyFrameEntry(ref Data.Opacity );
|
||||
}
|
||||
|
||||
public static void Write(this Stream IO, ref Pointer<AnimationData> Anim, ref List<int> NullValPointers)
|
||||
{
|
||||
ref AnimationData Data = ref Anim.Value;
|
||||
|
||||
byte SubFlags = 0;
|
||||
if (Data.SubAnim.Offset > -1)
|
||||
SubFlags = IO.Write(ref Data.SubAnim.Value);
|
||||
|
||||
byte Flags = IO.Write(ref Data.Anim);
|
||||
|
||||
if (Data.SubAnim.Offset > -1)
|
||||
{
|
||||
IO.Align(0x20);
|
||||
Data.SubAnim.Offset = IO.Position;
|
||||
IO.Write(ref Data.SubAnim.Value, ref NullValPointers, Flags);
|
||||
}
|
||||
|
||||
IO.Align(0x20);
|
||||
Anim.Offset = IO.Position;
|
||||
IO.WriteByte((byte) Data.BlendMode);
|
||||
IO.WriteByte( Data.Unk0);
|
||||
IO.WriteByte((byte)(Data.UseTextureMask ? 1 : 0));
|
||||
IO.WriteByte( Data.Unk1);
|
||||
|
||||
IO.Write(ref Data.Anim, ref NullValPointers, Flags);
|
||||
IO.Write(Data.SubAnim.Offset > -1 ? Data.SubAnim.Offset : 0);
|
||||
}
|
||||
|
||||
public static byte Write(this Stream IO, ref SubAnimationData Data)
|
||||
{
|
||||
int Flags = 0;
|
||||
Flags |= IO.Write(ref Data. OriginX) ? 0b10000000 : 0;
|
||||
Flags |= IO.Write(ref Data. OriginY) ? 0b01000000 : 0;
|
||||
Flags |= IO.Write(ref Data.PositionX) ? 0b00100000 : 0;
|
||||
Flags |= IO.Write(ref Data.PositionY) ? 0b00010000 : 0;
|
||||
Flags |= IO.Write(ref Data.Rotation ) ? 0b00001000 : 0;
|
||||
Flags |= IO.Write(ref Data. ScaleX) ? 0b00000100 : 0;
|
||||
Flags |= IO.Write(ref Data. ScaleY) ? 0b00000010 : 0;
|
||||
Flags |= IO.Write(ref Data.Opacity ) ? 0b00000001 : 0;
|
||||
return (byte)Flags;
|
||||
}
|
||||
|
||||
public static void Write(this Stream IO, ref SubAnimationData Data, ref List<int> NullValPointers, byte Flags)
|
||||
{
|
||||
IO.Write(Data. OriginX.Count );
|
||||
if ((Flags & 0b10000000) == 0b10000000) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Data. OriginX.Offset);
|
||||
IO.Write(Data. OriginY.Count );
|
||||
if ((Flags & 0b01000000) == 0b01000000) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Data. OriginY.Offset);
|
||||
IO.Write(Data.PositionX.Count );
|
||||
if ((Flags & 0b00100000) == 0b00100000) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Data.PositionX.Offset);
|
||||
IO.Write(Data.PositionY.Count );
|
||||
if ((Flags & 0b00010000) == 0b00010000) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Data.PositionY.Offset);
|
||||
IO.Write(Data.Rotation .Count );
|
||||
if ((Flags & 0b00001000) == 0b00001000) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Data.Rotation .Offset);
|
||||
IO.Write(Data. ScaleX.Count );
|
||||
if ((Flags & 0b00000100) == 0b00000100) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Data. ScaleX.Offset);
|
||||
IO.Write(Data. ScaleY.Count );
|
||||
if ((Flags & 0b00000010) == 0b00000010) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Data. ScaleY.Offset);
|
||||
IO.Write(Data.Opacity .Count );
|
||||
if ((Flags & 0b00000001) == 0b00000001) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Data.Opacity .Offset);
|
||||
}
|
||||
|
||||
public static KeyFrameEntry ReadKeyFrameEntry(this Stream IO) =>
|
||||
new KeyFrameEntry { Count = IO.ReadInt32(), Offset = IO.ReadInt32() };
|
||||
|
||||
public static void ReadKeyFrameEntry(this Stream IO, ref KeyFrameEntry entry)
|
||||
{
|
||||
if (entry.Count < 1) return;
|
||||
IO.Position = entry.Offset;
|
||||
if (entry.Count == 1) { entry.Value = IO.ReadSingle(); return; }
|
||||
|
||||
entry.Interpolation = new float[entry.Count];
|
||||
entry.KeyFrame = new float[entry.Count];
|
||||
entry.ArrValue = new float[entry.Count];
|
||||
for (int i = 0; i < entry.Count; i++) entry.KeyFrame [i] = IO.ReadSingle();
|
||||
for (int i = 0; i < entry.Count; i++)
|
||||
{ entry.ArrValue[i] = IO.ReadSingle(); entry.Interpolation[i] = IO.ReadSingle(); }
|
||||
}
|
||||
|
||||
public static bool Write(this Stream IO, ref KeyFrameEntry entry)
|
||||
{
|
||||
if (entry.Count == 0) return false;
|
||||
|
||||
if (entry.Count > 2) IO.Align(0x20);
|
||||
entry.Offset = IO.Position;
|
||||
if (entry.Count == 1) if (entry.Value == 0) return true;
|
||||
else { IO.Write(entry.Value); return false; }
|
||||
|
||||
for (int i = 0; i < entry.Count; i++) IO.Write(entry.KeyFrame [i]);
|
||||
for (int i = 0; i < entry.Count; i++)
|
||||
{ IO.Write(entry.ArrValue[i]); IO.Write(entry.Interpolation[i]); }
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void ReadMP(this CountPointer<Marker> mark, MsgPack msg)
|
||||
{
|
||||
if (msg.Element("Marker", out MsgPack Marker))
|
||||
{
|
||||
mark.Count = 1;
|
||||
mark.Entries[0].ReadMP(Marker);
|
||||
}
|
||||
else if (msg.Element<MsgPack>("Markers", out MsgPack Markers))
|
||||
{
|
||||
mark.Count = Markers.Array.Length;
|
||||
for (int i = 0; i < mark.Count; i++)
|
||||
mark.Entries[i].ReadMP(Markers[i] as MsgPack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WritePointerString(this Stream IO,
|
||||
ref Dictionary<string, int> Dict, ref Pointer<string> Str)
|
||||
{
|
||||
if (Dict.ContainsKey(Str.Value)) Str.Offset = Dict[Str.Value];
|
||||
else
|
||||
{ Str.Offset = IO.Position; Dict.Add(Str.Value, Str.Offset); IO.WriteShiftJIS(Str.Value + "\0"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-10
@@ -3,7 +3,6 @@
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
@@ -193,12 +192,11 @@ namespace KKdMainLib.DB
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
if (MsgPack.Element("AetDB", out MsgPack AetDB, typeof(object[])))
|
||||
if (MsgPack.Element<MsgPack>("AetDB", out MsgPack AetDB))
|
||||
{
|
||||
AetSets = new AetSet[((object[])AetDB.Object).Length];
|
||||
AetSets = new AetSet[AetDB.Array.Length];
|
||||
for (int i = 0; i < AetSets.Length; i++)
|
||||
if (AetDB[i].GetType() == typeof(MsgPack))
|
||||
AetSets[i].ReadMsgPack((MsgPack)AetDB[i]);
|
||||
AetSets[i].ReadMsgPack(AetDB[i] as MsgPack);
|
||||
}
|
||||
MsgPack = null;
|
||||
}
|
||||
@@ -248,13 +246,11 @@ namespace KKdMainLib.DB
|
||||
NewId = msg.ReadBoolean("NewId" );
|
||||
SpriteSetId = msg.ReadNUInt16("SpriteSetId");
|
||||
|
||||
if (msg.Element("Aets", out MsgPack Aets, typeof(object[])))
|
||||
if (msg.Element<MsgPack>("Aets", out MsgPack Aets))
|
||||
{
|
||||
object Aet;
|
||||
this .Aets = new AET[((object[])Aets.Object).Length];
|
||||
this.Aets = new AET[Aets.Array.Length];
|
||||
for (int i0 = 0; i0 < this.Aets.Length; i0++)
|
||||
{ Aet = Aets[i0]; if (Aet.GetType() == typeof(MsgPack))
|
||||
this.Aets[i0].ReadMsgPack((MsgPack)Aet); }
|
||||
this.Aets[i0].ReadMsgPack(Aets[i0] as MsgPack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-17
@@ -3,11 +3,10 @@ using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.A3DA;
|
||||
using KKdMainLib.MessagePack;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
public struct Auth
|
||||
public class Auth
|
||||
{
|
||||
public int Signature { get; private set; }
|
||||
public string[] Category { get; private set; }
|
||||
@@ -104,28 +103,25 @@ namespace KKdMainLib.DB
|
||||
|
||||
if (MsgPack.Element("AuthDB", out MsgPack AuthDB))
|
||||
{
|
||||
if (AuthDB.Element("Category", out MsgPack Temp, typeof(object[])))
|
||||
if (AuthDB.Element("Category", out MsgPack Temp))
|
||||
{
|
||||
this.Category = new string[((object[])Temp.Object).Length];
|
||||
MsgPack Category;
|
||||
this.Category = new string[Temp.Array.Length];
|
||||
for (int i = 0; i < this.Category.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
{ Category = (MsgPack)Temp[i]; this.Category[i] = Category.ReadString(); }
|
||||
this.Category[i] = (Temp[i] as MsgPack).ReadString();
|
||||
}
|
||||
|
||||
if (AuthDB.Element("UID", out Temp, typeof(object[])))
|
||||
if (AuthDB.Element("UID", out Temp))
|
||||
{
|
||||
_UID = new UID[((object[])Temp.Object).Length];
|
||||
_UID = new UID[Temp.Array.Length];
|
||||
MsgPack UID;
|
||||
for (int i = 0; i < _UID.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
UID = (MsgPack)Temp[i];
|
||||
_UID[i].Category = UID.ReadString("C");
|
||||
_UID[i].OrgUid = UID.ReadNInt32("O");
|
||||
_UID[i].Size = UID.ReadNInt32("S");
|
||||
_UID[i].Value = UID.ReadString("V");
|
||||
}
|
||||
{
|
||||
UID = Temp[i] as MsgPack;
|
||||
_UID[i].Category = UID.ReadString("C");
|
||||
_UID[i].OrgUid = UID.ReadNInt32("O");
|
||||
_UID[i].Size = UID.ReadNInt32("S");
|
||||
_UID[i].Value = UID.ReadString("V");
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgPack = null;
|
||||
|
||||
+9
-15
@@ -3,7 +3,6 @@
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
@@ -250,12 +249,11 @@ namespace KKdMainLib.DB
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
if (MsgPack.Element("SprDB", out MsgPack SprDB, typeof(object[])))
|
||||
if (MsgPack.Element<MsgPack>("SprDB", out MsgPack SprDB))
|
||||
{
|
||||
SpriteSets = new SpriteSet[((object[])SprDB.Object).Length];
|
||||
SpriteSets = new SpriteSet[SprDB.Array.Length];
|
||||
for (int i = 0; i < SpriteSets.Length; i++)
|
||||
if (SprDB[i].GetType() == typeof(MsgPack))
|
||||
SpriteSets[i].ReadMsgPack((MsgPack)SprDB[i]);
|
||||
SpriteSets[i].ReadMsgPack(SprDB[i] as MsgPack);
|
||||
}
|
||||
MsgPack = null;
|
||||
}
|
||||
@@ -302,22 +300,18 @@ namespace KKdMainLib.DB
|
||||
Name = msg.ReadString ("Name" );
|
||||
NewId = msg.ReadBoolean("NewId" );
|
||||
|
||||
if (msg.Element( "Sprites", out MsgPack Sprites, typeof(object[])))
|
||||
if (msg.Element<MsgPack>( "Sprites", out MsgPack Sprites))
|
||||
{
|
||||
object Sprite;
|
||||
this .Sprites = new SpriteTexture[((object[])Sprites.Object).Length];
|
||||
this .Sprites = new SpriteTexture[Sprites.Array.Length];
|
||||
for (int i0 = 0; i0 < this.Sprites.Length; i0++)
|
||||
{ Sprite = Sprites[i0]; if (Sprites.GetType() == typeof(MsgPack))
|
||||
this.Sprites[i0].ReadMsgPack((MsgPack)Sprite); }
|
||||
this.Sprites[i0].ReadMsgPack(Sprites[i0] as MsgPack);
|
||||
}
|
||||
|
||||
if (msg.Element("Textures", out MsgPack Textures, typeof(object[])))
|
||||
if (msg.Element<MsgPack>("Textures", out MsgPack Textures))
|
||||
{
|
||||
object Texture;
|
||||
this .Textures = new SpriteTexture[((object[])Textures.Object).Length];
|
||||
this .Textures = new SpriteTexture[Textures.Array.Length];
|
||||
for (int i0 = 0; i0 < this.Textures.Length; i0++)
|
||||
{ Texture = Textures[i0]; if (Texture.GetType() == typeof(MsgPack))
|
||||
this.Textures[i0].ReadMsgPack((MsgPack)Texture); }
|
||||
this.Textures[i0].ReadMsgPack(Textures[i0] as MsgPack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-29
@@ -157,7 +157,7 @@ namespace KKdMainLib
|
||||
IO.Align(0x10, true);
|
||||
|
||||
if (Header.IsX) IO.Seek(Header.Lenght + 0x28, 0);
|
||||
else IO.Seek(Header.Lenght + 0x20, 0);
|
||||
else IO.Seek(Header.Lenght + 0x20, 0);
|
||||
for (int i0 = 0; i0 < Dex.Length; i0++)
|
||||
{
|
||||
IO.Write(Dex[i0].MainOffset);
|
||||
@@ -173,7 +173,7 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
if (Header.IsX) IO.Seek(Position0 - 8, 0);
|
||||
else IO.Seek(Position0 - 4, 0);
|
||||
else IO.Seek(Position0 - 4, 0);
|
||||
IO.Write(Position1);
|
||||
|
||||
if (IO.Format > Main.Format.F)
|
||||
@@ -197,37 +197,29 @@ namespace KKdMainLib
|
||||
Header = new PDHead();
|
||||
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
if (!MsgPack.Element<MsgPack>("Dex", out MsgPack Dex)) return;
|
||||
|
||||
if (MsgPack.Element("Dex", out MsgPack Dex, typeof(object[])))
|
||||
{
|
||||
MsgPack Temp = new MsgPack();
|
||||
this.Dex = new EXP[Dex.Array.Length];
|
||||
for (i0 = 0; i0 < this.Dex.Length; i0++)
|
||||
if (Dex[i0] is MsgPack EXP)
|
||||
{
|
||||
this.Dex[i0] = new EXP { Name = EXP.ReadString("Name") };
|
||||
|
||||
this.Dex = new EXP[((object[])Dex.Object).Length];
|
||||
MsgPack EXP = new MsgPack();
|
||||
for (i0 = 0; i0 < this.Dex.Length; i0++)
|
||||
if (Dex[i0].GetType() == typeof(MsgPack))
|
||||
if (EXP.Element<MsgPack>("Main", out MsgPack Main))
|
||||
{
|
||||
this.Dex[i0] = new EXP();
|
||||
EXP = (MsgPack)Dex[i0];
|
||||
this.Dex[i0].Name = EXP.ReadString("Name");
|
||||
if (EXP.Element("Main", out Temp, typeof(object[])))
|
||||
{
|
||||
this.Dex[i0].Main = new List<EXPElement>
|
||||
{ Capacity = ((object[])Temp.Object).Length };
|
||||
for (i1 = 0; i1 < this.Dex[i0].Main.Capacity; i1++)
|
||||
if (Temp[i1].GetType() == typeof(MsgPack))
|
||||
this.Dex[i0].Main.Add(ReadEXP((MsgPack)Temp[i1]));
|
||||
}
|
||||
if (EXP.Element("Eyes", out Temp, typeof(object[])))
|
||||
{
|
||||
this.Dex[i0].Eyes = new List<EXPElement>
|
||||
{ Capacity = ((object[])Temp.Object).Length };
|
||||
for (i1 = 0; i1 < this.Dex[i0].Eyes.Capacity; i1++)
|
||||
if (Temp[i1].GetType() == typeof(MsgPack))
|
||||
this.Dex[i0].Eyes.Add(ReadEXP((MsgPack)Temp[i1]));
|
||||
}
|
||||
this.Dex[i0].Main = new List<EXPElement>();
|
||||
for (i1 = 0; i1 < Main.Array.Length; i1++)
|
||||
if (Main[i1] is MsgPack Exp)
|
||||
this.Dex[i0].Main.Add(ReadEXP(Exp));
|
||||
}
|
||||
}
|
||||
if (EXP.Element<MsgPack>("Eyes", out MsgPack Eyes))
|
||||
{
|
||||
this.Dex[i0].Eyes = new List<EXPElement>();
|
||||
for (i1 = 0; i1 < Eyes.Array.Length; i1++)
|
||||
if (Eyes[i1] is MsgPack Exp)
|
||||
this.Dex[i0].Eyes.Add(ReadEXP(Exp));
|
||||
}
|
||||
}
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
|
||||
+152
-205
@@ -1,174 +1,94 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Xml.Linq;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public class DataBank
|
||||
{
|
||||
public DataBank()
|
||||
{ Success = false; Xml = null; IO = null; pvList = null; }
|
||||
public DataBank() { Success = false; IO = null; pvList = null; }
|
||||
|
||||
public bool Success { get; private set; }
|
||||
|
||||
private Xml Xml;
|
||||
private Stream IO;
|
||||
private int i;
|
||||
|
||||
private PvList[] pvList;
|
||||
|
||||
private const string d = ".";
|
||||
private const string c = ",";
|
||||
|
||||
public bool Success { get; private set; }
|
||||
|
||||
public void DBReader(string file)
|
||||
{
|
||||
Success = false;
|
||||
if (!File.Exists(file)) return;
|
||||
string text = File.ReadAllText(file);
|
||||
while (text.Contains("%")) text = WebUtility.UrlDecode(text);
|
||||
string[] array = text.Split(',');
|
||||
|
||||
string out_data = File.ReadAllText(file);
|
||||
while (out_data.Contains("%")) out_data = WebUtility.UrlDecode(out_data);
|
||||
|
||||
string[] data_split = out_data.Split(',');
|
||||
|
||||
if (file.Contains("PvList"))
|
||||
if (file.Contains("PvList") && array.Length % 7 < 2)
|
||||
{
|
||||
if (data_split.Length % 7 < 2)
|
||||
{
|
||||
int Count = data_split.Length / 7;
|
||||
pvList = new PvList[Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
pvList[i].SetValue(data_split, i);
|
||||
Success = true;
|
||||
return;
|
||||
}
|
||||
pvList = new PvList[array.Length / 7];
|
||||
for (i = 0; i < pvList.Length; i++) pvList[i].SetValue(array, i);
|
||||
Success = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void DBWriter(string file)
|
||||
{
|
||||
if (!Success) return;
|
||||
|
||||
|
||||
IO = File.OpenWriter();
|
||||
if (file.Contains("PvList"))
|
||||
if (pvList.Length > 0)
|
||||
for (int i = 0; i < pvList.Length; i++)
|
||||
{
|
||||
if (pvList.Length != 0)
|
||||
for (i = 0; i < pvList.Length; i++)
|
||||
IO.Write(UrlEncode(pvList[i].ToString() +
|
||||
(i + 1 != pvList.Length ? c : "")));
|
||||
((i + 1 != pvList.Length) ? "," : "")));
|
||||
else IO.Write("%2A%2A%2A");
|
||||
}
|
||||
|
||||
byte[] data = IO.ToArray(true);
|
||||
|
||||
ushort checksum = DCC.CalculateChecksum(data);
|
||||
uint time = (uint)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
|
||||
File.WriteAllBytes(file + "_" + checksum + "_" + time + ".dat", data);
|
||||
byte[] data = IO.ToArray(Close: true);
|
||||
ushort num = DCC.CalculateChecksum(data);
|
||||
uint num2 = (uint)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
File.WriteAllBytes(file + "_" + num + "_" + num2 + ".dat", data);
|
||||
}
|
||||
|
||||
public void XMLReader(string file)
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
Success = false;
|
||||
MsgPack msgPack = file.ReadMP(JSON);
|
||||
bool compact = msgPack.ReadBoolean("Compact");
|
||||
|
||||
if (!File.Exists(file)) return;
|
||||
|
||||
Xml = new Xml();
|
||||
Xml.OpenXml(file, true);
|
||||
|
||||
if (file.Contains("PvList"))
|
||||
foreach (XElement PvList in Xml.doc.Elements("PvList"))
|
||||
{
|
||||
int Count = 0;
|
||||
foreach (XElement PV in PvList.Elements()) if (PV.Name == "PV") Count++;
|
||||
|
||||
pvList = new PvList[Count];
|
||||
int i = 0;
|
||||
foreach (XElement PV in PvList.Elements())
|
||||
{
|
||||
pvList[i].SetValue(PV);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Success = true;
|
||||
if (file.Contains("PvList") && msgPack.Element<MsgPack>("PvList", out MsgPack PvList))
|
||||
{
|
||||
pvList = new PvList[PvList.Array.Length];
|
||||
for (i = 0; i < pvList.Length; i++)
|
||||
pvList[i].SetValue((MsgPack)PvList[i], compact);
|
||||
Success = true;
|
||||
}
|
||||
msgPack = null;
|
||||
}
|
||||
|
||||
public void XMLWriter(string file)
|
||||
public void MsgPackWriter(string file, bool JSON, bool Compact = true)
|
||||
{
|
||||
if (!Success) return;
|
||||
|
||||
Xml = new Xml { Compact = true };
|
||||
MsgPack msgPack = new MsgPack();
|
||||
|
||||
if (file.Contains("PvList"))
|
||||
{
|
||||
XElement PvList = new XElement("PvList");
|
||||
foreach (PvList pv in pvList)
|
||||
PvList.Add(pv.WriteXml(Xml, "PV"));
|
||||
Xml.doc.Add(PvList);
|
||||
}
|
||||
if (Compact) msgPack.Add("Compact", Compact);
|
||||
|
||||
if (File.Exists(file)) File.Delete(file);
|
||||
Xml.SaveXml(file);
|
||||
MsgPack PvList = new MsgPack("PvList", pvList.Length);
|
||||
for (i = 0; i < pvList.Length; i++) PvList[i] = pvList[i].WriteMP(Compact);
|
||||
msgPack.Add(PvList);
|
||||
}
|
||||
msgPack.Write(file, JSON).Dispose();
|
||||
}
|
||||
|
||||
public struct Player
|
||||
{
|
||||
public int Score0;
|
||||
public int Score1;
|
||||
public string Name0;
|
||||
public string Name1;
|
||||
public int Diff;
|
||||
public bool Has2P => Name1 != null;
|
||||
|
||||
public void SetValue(string[] data, int i = 0, int offset = 0)
|
||||
{
|
||||
string[] arr = data[i * 13 + 0 + offset * 4].Split('.');
|
||||
Score0 = int.Parse(arr[0]);
|
||||
if (arr.Length > 1) Score1 = int.Parse(arr[1]);
|
||||
|
||||
string temp = "";
|
||||
for (int i1 = 0; i1 < data[i * 13 + 1 + offset * 4].Length; i1++)
|
||||
{
|
||||
temp += data[i * 13 + 1 + offset * 4][i1];
|
||||
if (temp.EndsWith("xxx")) { Name0 = temp.Remove(temp.Length - 3); temp = ""; }
|
||||
}
|
||||
if (arr.Length == 1) Name0 = temp;
|
||||
else Name1 = temp;
|
||||
Diff = int.Parse(data[i * 13 + 2 + offset * 4]);
|
||||
}
|
||||
|
||||
public void SetValue(XElement value)
|
||||
{
|
||||
Name1 = null;
|
||||
foreach (XAttribute Entry in value.Attributes())
|
||||
if (Entry.Name == "Score" ) Score0 = int.Parse(Entry.Value);
|
||||
else if (Entry.Name == "Name" ) Name0 = Entry.Value;
|
||||
else if (Entry.Name == "Diff" ) Diff = int.Parse(Entry.Value);
|
||||
else if (Entry.Name == "Score0") Score0 = int.Parse(Entry.Value);
|
||||
else if (Entry.Name == "Score1") Score1 = int.Parse(Entry.Value);
|
||||
else if (Entry.Name == "Name0" ) Name0 = Entry.Value;
|
||||
else if (Entry.Name == "Name1" ) Name1 = Entry.Value;
|
||||
}
|
||||
|
||||
public XElement WriteXml(Xml Xml, string name)
|
||||
{
|
||||
XElement element = new XElement(name);
|
||||
if (!Has2P)
|
||||
{
|
||||
Xml.Writer(element, Score0, "Score");
|
||||
Xml.Writer(element, Name0 , "Name" );
|
||||
}
|
||||
else
|
||||
{
|
||||
Xml.Writer(element, Score0, "Score0");
|
||||
Xml.Writer(element, Score1, "Score1");
|
||||
Xml.Writer(element, Name0 , "Name0" );
|
||||
Xml.Writer(element, Name1 , "Name1" );
|
||||
}
|
||||
Xml.Writer(element, Diff, "Diff");
|
||||
return element;
|
||||
}
|
||||
|
||||
public override string ToString() => (Score0 + (Has2P ? d + Score1 : "") + c + UrlEncode(Name0) +
|
||||
(Has2P ? "xxx" + UrlEncode(Name1) : "") + c + Diff + c + (Has2P ? "0.1" : "0")).Replace("*", "%2A");
|
||||
}
|
||||
|
||||
public static string UrlEncode(string value) => WebUtility.UrlEncode(value).Replace("+", "%20");
|
||||
public static string UrlEncode(string value) =>
|
||||
WebUtility.UrlEncode(value).Replace("+", "%20");
|
||||
|
||||
public struct PvList
|
||||
{
|
||||
@@ -182,120 +102,147 @@ namespace KKdMainLib
|
||||
|
||||
public void SetValue(string[] data, int i = 0)
|
||||
{
|
||||
ID = int.Parse(data[i * 7 + 0]);
|
||||
ID = int.Parse(data[i * 7]);
|
||||
Enable = int.Parse(data[i * 7 + 1]) == 1;
|
||||
Extra = int.Parse(data[i * 7 + 2]) == 1;
|
||||
Extra = int.Parse(data[i * 7 + 2]) == 1;
|
||||
AdvDemoStart.SetValue(data[i * 7 + 3]);
|
||||
AdvDemoEnd .SetValue(data[i * 7 + 4]);
|
||||
StartShow .SetValue(data[i * 7 + 5]);
|
||||
EndShow .SetValue(data[i * 7 + 6]);
|
||||
}
|
||||
|
||||
public override string ToString() => UrlEncode(ID +
|
||||
c + (Enable ? 1 : 0) + c + (Extra ? 1 : 0) +
|
||||
c + AdvDemoStart.ToString() + c + AdvDemoEnd.ToString() +
|
||||
c + StartShow .ToString() + c + EndShow .ToString());
|
||||
|
||||
public void SetValue(XElement Value)
|
||||
public void SetValue(MsgPack msg, bool Compact)
|
||||
{
|
||||
Enable = true;
|
||||
foreach (XAttribute Entry in Value.Attributes())
|
||||
if (Entry.Name == "ID" ) ID = int.Parse(Entry.Value);
|
||||
else if (Entry.Name == "Enable" ) Enable = bool.Parse(Entry.Value);
|
||||
else if (Entry.Name == "Extra" ) Extra = bool.Parse(Entry.Value);
|
||||
MsgPack Temp = new MsgPack();
|
||||
this.Enable = true;
|
||||
this.Extra = false;
|
||||
|
||||
AdvDemoStart.SetDefaultUpper();
|
||||
AdvDemoEnd .SetDefaultLower();
|
||||
StartShow .SetDefaultLower();
|
||||
EndShow .SetDefaultUpper();
|
||||
|
||||
foreach (XElement value in Value.Elements())
|
||||
if (value.Name == "AdvDemoStart") AdvDemoStart.SetValue(value);
|
||||
else if (value.Name == "AdvDemoEnd" ) AdvDemoEnd .SetValue(value);
|
||||
else if (value.Name == "StartShow" ) StartShow .SetValue(value);
|
||||
else if (value.Name == "EndShow" ) EndShow .SetValue(value);
|
||||
ID = msg.ReadInt32("ID");
|
||||
bool? Enable = msg.ReadNBoolean("Enable");
|
||||
bool? Extra = msg.ReadNBoolean("Extra");
|
||||
if (Enable.HasValue) this.Enable = (bool)Enable;
|
||||
if (Extra .HasValue) this.Extra = (bool)Extra ;
|
||||
if (Compact)
|
||||
{
|
||||
AdvDemoStart.SetValue(msg.ReadNInt32("AdvDemoStart"), true);
|
||||
AdvDemoEnd .SetValue(msg.ReadNInt32("AdvDemoEnd" ), false);
|
||||
StartShow .SetValue(msg.ReadNInt32("StartShow" ), false);
|
||||
EndShow .SetValue(msg.ReadNInt32( "EndShow" ), true);
|
||||
return;
|
||||
}
|
||||
if (msg.Element("AdvDemoStart", out Temp)) AdvDemoStart.SetValue(Temp, true);
|
||||
if (msg.Element("AdvDemoEnd" , out Temp)) AdvDemoEnd .SetValue(Temp, false);
|
||||
if (msg.Element("StartShow" , out Temp)) StartShow .SetValue(Temp, false);
|
||||
if (msg.Element( "EndShow" , out Temp)) EndShow .SetValue(Temp, true);
|
||||
}
|
||||
|
||||
public XElement WriteXml(Xml Xml, string name)
|
||||
public MsgPack WriteMP(bool Compact)
|
||||
{
|
||||
XElement element = new XElement(name);
|
||||
Xml.Writer(element, ID , "ID" );
|
||||
if (!Enable) Xml.Writer(element, Enable, "Enable");
|
||||
if ( Extra ) Xml.Writer(element, Extra , "Extra" );
|
||||
if (AdvDemoEnd.WriteLower)
|
||||
element.Add(AdvDemoStart.WriteXml(Xml, "AdvDemoStart"));
|
||||
if (AdvDemoEnd.WriteLower)
|
||||
element.Add(AdvDemoEnd .WriteXml(Xml, "AdvDemoEnd" ));
|
||||
if (StartShow .WriteLower)
|
||||
element.Add(StartShow .WriteXml(Xml, "StartShow" ));
|
||||
if ( EndShow .WriteUpper)
|
||||
element.Add(EndShow .WriteXml(Xml, "EndShow" ));
|
||||
return element;
|
||||
MsgPack msgPack = new MsgPack();
|
||||
msgPack.Add("ID", ID);
|
||||
if (!Enable) msgPack.Add("Enable", Enable);
|
||||
if ( Extra ) msgPack.Add("Extra" , Extra );
|
||||
if (Compact)
|
||||
{
|
||||
if (AdvDemoStart.WriteLower) msgPack.Add("AdvDemoStart", AdvDemoStart.WriteInt());
|
||||
if (AdvDemoEnd .WriteLower) msgPack.Add("AdvDemoEnd" , AdvDemoEnd .WriteInt());
|
||||
if (StartShow .WriteLower) msgPack.Add("StartShow" , StartShow .WriteInt());
|
||||
if ( EndShow .WriteUpper) msgPack.Add( "EndShow" , EndShow .WriteInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AdvDemoStart.WriteLower) msgPack.Add(AdvDemoStart.WriteMP("AdvDemoStart"));
|
||||
if (AdvDemoEnd .WriteLower) msgPack.Add(AdvDemoEnd .WriteMP("AdvDemoEnd" ));
|
||||
if (StartShow .WriteLower) msgPack.Add(StartShow .WriteMP("StartShow" ));
|
||||
if ( EndShow .WriteUpper) msgPack.Add( EndShow .WriteMP( "EndShow" ));
|
||||
}
|
||||
return msgPack;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
UrlEncode(ID + "," + (Enable ? 1 : 0) + "," + (Extra ? 1 : 0) + "," +
|
||||
AdvDemoStart.ToString() + "," + AdvDemoEnd.ToString() + "," +
|
||||
StartShow.ToString() + "," + EndShow.ToString());
|
||||
}
|
||||
|
||||
private const string d = ".";
|
||||
private const string c = ",";
|
||||
|
||||
public struct Date
|
||||
{
|
||||
private int year ;
|
||||
private int year;
|
||||
private int month;
|
||||
private int day ;
|
||||
private int day;
|
||||
|
||||
public int Year { get => year; set { year = value; CheckDate(); } }
|
||||
|
||||
public int Year { get => year ; set { year = value; CheckDate(); } }
|
||||
public int Month { get => month; set { month = value; CheckDate(); } }
|
||||
public int Day { get => day ; set { day = value; CheckDate(); } }
|
||||
|
||||
public bool WriteUpper => (Year == 2029 && Month == 1 && Day == 1) ^ true;
|
||||
public bool WriteLower => (Year == 2000 && Month == 1 && Day == 1) ^ true;
|
||||
public int Day { get => day; set { day = value; CheckDate(); } }
|
||||
|
||||
public void SetDefaultLower() => Year = 1999;
|
||||
public bool WriteUpper => Year != 2029 || Month != 1 || Day != 1;
|
||||
public bool WriteLower => Year != 2000 || Month != 1 || Day != 1;
|
||||
|
||||
public void SetDefaultLower() => Year = 2000;
|
||||
public void SetDefaultUpper() => Year = 2029;
|
||||
|
||||
public void SetValue(string data)
|
||||
{
|
||||
string[] arr = data.Split('-');
|
||||
if (arr.Length != 3) return;
|
||||
Year = int.Parse(arr[0]);
|
||||
Month = int.Parse(arr[1]);
|
||||
Day = int.Parse(arr[2]);
|
||||
string[] array = data.Split('-');
|
||||
if (array.Length == 3)
|
||||
{
|
||||
Year = int.Parse(array[0]);
|
||||
Month = int.Parse(array[1]);
|
||||
Day = int.Parse(array[2]);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetValue(int? YMD, bool SetDefaultUpper)
|
||||
{
|
||||
if (!SetDefaultUpper) SetDefaultLower();
|
||||
else this.SetDefaultUpper();
|
||||
if (YMD != null)
|
||||
{
|
||||
year = YMD.Value / 10000;
|
||||
month = YMD.Value / 100 % 100;
|
||||
day = YMD.Value % 100;
|
||||
CheckDate();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetValue(MsgPack msg, bool SetDefaultUpper)
|
||||
{
|
||||
if (!SetDefaultUpper) SetDefaultLower();
|
||||
else this.SetDefaultUpper();
|
||||
int? Year = msg.ReadNInt32( "Year");
|
||||
int? Month = msg.ReadNInt32("Month");
|
||||
int? Day = msg.ReadNInt32( "Day");
|
||||
if ( Year != null) year = Year.Value;
|
||||
if (Month != null) month = Month.Value;
|
||||
if ( Day != null) day = Day.Value;
|
||||
CheckDate();
|
||||
}
|
||||
|
||||
public int WriteInt() =>
|
||||
(Year * 100 + Month) * 100 + Day;
|
||||
|
||||
public MsgPack WriteMP(string name) =>
|
||||
new MsgPack(name).Add("Year", Year).Add("Month", Month).Add("Day", Day);
|
||||
|
||||
private void CheckDate()
|
||||
{
|
||||
if (year < 2000) { year = 2000; month = 1; day = 1; return; }
|
||||
else if (year >= 2029) { year = 2029; month = 1; day = 1; return; }
|
||||
|
||||
if (month < 1) month = 1;
|
||||
if (year < 2000) { year = 2000; month = 1; day = 1; return; }
|
||||
if (year >= 2029) { year = 2029; month = 1; day = 1; return; }
|
||||
if (month < 1) month = 1;
|
||||
else if (month > 12) month = 12;
|
||||
if (day < 1) day = 1;
|
||||
else if (day > 31 && (month == 1 || month == 3 || month == 5 ||
|
||||
month == 7 || month == 8 || month == 10 || month == 12)) day = 31;
|
||||
else if (day > 30 && (month == 4 || month == 6 || month == 9 || month == 11)) day = 30;
|
||||
else if (day > 29 && month == 2 && year % 4 == 0) day = 29;
|
||||
else if (day > 28 && month == 2 && year % 4 != 0) day = 29;
|
||||
if (day < 1) day = 1;
|
||||
else if (day > 31 && (month == 1 || month == 3 || month == 5 ||
|
||||
month == 7 || month == 8 || month == 10 || month == 12)) day = 31;
|
||||
else if (day > 30 && (month == 4 || month == 6 ||
|
||||
month == 9 || month == 11)) day = 30;
|
||||
else if (day > 29 && month == 2 && year % 4 == 0) day = 29;
|
||||
else if (day > 28 && month == 2 && year % 4 != 0) day = 28;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
Year.ToString("d4") + "-" + Month.ToString("d2") + "-" + Day.ToString("d2");
|
||||
|
||||
public void SetValue(XElement value)
|
||||
{
|
||||
foreach (XAttribute Entry in value.Attributes())
|
||||
if (Entry.Name == "Year" ) Year = int.Parse(Entry.Value);
|
||||
else if (Entry.Name == "Month") Month = int.Parse(Entry.Value);
|
||||
else if (Entry.Name == "Day" ) Day = int.Parse(Entry.Value);
|
||||
}
|
||||
|
||||
public XElement WriteXml(Xml Xml, string name)
|
||||
{
|
||||
XElement element = new XElement(name);
|
||||
Xml.Writer(element, Year , "Year" );
|
||||
Xml.Writer(element, Month, "Month");
|
||||
Xml.Writer(element, Day , "Day" );
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -238,8 +238,7 @@ namespace KKdMainLib
|
||||
{
|
||||
Files[i] = new FARCFile { Name = files[i] };
|
||||
string ext = Path.GetExtension(files[i]).ToLower();
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".vag")
|
||||
Signature = Farc.FArc;
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".vag") Signature = Farc.FArc;
|
||||
}
|
||||
files = null;
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@ namespace KKdMainLib.IO
|
||||
return Data.Replace("\r", "").Split('\n'); }
|
||||
|
||||
public static void WriteAllBytes(string file, byte[] data)
|
||||
{ Stream IO = OpenWriter(file); IO.Write(data); IO.Close(); }
|
||||
{ Stream IO = OpenWriter(file, true); IO.Write(data); IO.Close(); }
|
||||
|
||||
public static void WriteAllText (string file, string data)
|
||||
{ Stream IO = OpenWriter(file); IO.Write(data); IO.Close(); }
|
||||
{ Stream IO = OpenWriter(file, true); IO.Write(data); IO.Close(); }
|
||||
|
||||
public static void WriteAllLines(string file, string[] data)
|
||||
{ Stream IO = OpenWriter(file); for (int i = 0; i < data.Length; i++)
|
||||
{ Stream IO = OpenWriter(file, true); for (int i = 0; i < data.Length; i++)
|
||||
IO.Write(data[i] + "\r\n"); IO.Close(); }
|
||||
|
||||
public static bool Exists(string file) => MSIO.File.Exists(file);
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace KKdMainLib.IO
|
||||
public static byte[] NullTerminated (this Stream stream, byte End = 0)
|
||||
{
|
||||
List<byte> s = new List<byte>();
|
||||
while (true && stream.LongPosition >= 0 && stream.LongPosition < stream.LongLength)
|
||||
while (stream.LongPosition < stream.LongLength)
|
||||
{
|
||||
byte a = stream.ReadByte();
|
||||
if (a == End) break;
|
||||
@@ -38,5 +38,34 @@ namespace KKdMainLib.IO
|
||||
if (!stream.Assert(next[i])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static long ReadIntX(this Stream stream ) => stream.IsX ?
|
||||
stream.ReadInt64() : stream.ReadUInt32Endian( );
|
||||
public static long ReadIntX(this Stream stream, bool IsBE) => stream.IsX ?
|
||||
stream.ReadInt64() : stream.ReadUInt32Endian(IsBE);
|
||||
|
||||
public static byte[] ReadAtOffset(this Stream stream, long Offset = 0, long Length = 0)
|
||||
{
|
||||
byte[] arr = null;
|
||||
long Position = stream.LongPosition;
|
||||
if (Offset == 0) { Position += stream.IsX ? 8 : 4; Offset = stream.ReadIntX(); }
|
||||
stream.LongPosition = Offset;
|
||||
if (Length == 0) arr = stream.NullTerminated();
|
||||
else arr = stream.ReadBytes(Length);
|
||||
stream.LongPosition = Position;
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static string ReadStringAtOffset(this Stream stream, long Offset = 0, long Length = 0)
|
||||
{
|
||||
string s = null;
|
||||
long Position = stream.LongPosition;
|
||||
if (Offset == 0) { Position += stream.IsX ? 8 : 4; Offset = stream.ReadIntX(); }
|
||||
stream.LongPosition = Offset;
|
||||
if (Length == 0) s = stream.NullTerminatedUTF8();
|
||||
else s = stream.ReadStringUTF8(Length);
|
||||
stream.LongPosition = Position;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+62
-64
@@ -7,7 +7,7 @@ namespace KKdMainLib.IO
|
||||
public unsafe class Stream : IDisposable
|
||||
{
|
||||
private MSIO.Stream stream;
|
||||
private int i, i0, TempBitRead, TempBitWrite;
|
||||
private int I, i, i0, TempBitRead, TempBitWrite;
|
||||
private ushort ValRead;
|
||||
private byte BitRead, BitWrite, ValWrite;
|
||||
private byte[] buf;
|
||||
@@ -54,7 +54,7 @@ namespace KKdMainLib.IO
|
||||
ValRead = ValRead = BitWrite = 0;
|
||||
stream = output;
|
||||
Format = Main.Format.NULL;
|
||||
buf = new byte[16];
|
||||
buf = new byte[128];
|
||||
IsBE = isBE;
|
||||
data = Data;
|
||||
}
|
||||
@@ -176,43 +176,51 @@ namespace KKdMainLib.IO
|
||||
public void Write( float? val) => Write(val.GetValueOrDefault());
|
||||
public void Write(double? val) => Write(val.GetValueOrDefault());
|
||||
|
||||
public void Write( bool* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write( sbyte* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write( byte* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write( short* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write(ushort* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write( int* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write( uint* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write( long* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write( ulong* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write( float* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
public void Write(double* val, int Length) { for (i = 0; i < Length; i++) Write(val[i]); }
|
||||
|
||||
public void WriteEndian( short* val, int Length) { for (i = 0; i < Length; i++) WriteEndian(val[i]); }
|
||||
public void WriteEndian(ushort* val, int Length) { for (i = 0; i < Length; i++) WriteEndian(val[i]); }
|
||||
public void WriteEndian( int* val, int Length) { for (i = 0; i < Length; i++) WriteEndian(val[i]); }
|
||||
public void WriteEndian( uint* val, int Length) { for (i = 0; i < Length; i++) WriteEndian(val[i]); }
|
||||
public void WriteEndian( long* val, int Length) { for (i = 0; i < Length; i++) WriteEndian(val[i]); }
|
||||
public void WriteEndian( ulong* val, int Length) { for (i = 0; i < Length; i++) WriteEndian(val[i]); }
|
||||
public void WriteEndian( float* val, int Length) { for (i = 0; i < Length; i++) WriteEndian(val[i]); }
|
||||
public void WriteEndian(double* val, int Length) { for (i = 0; i < Length; i++) WriteEndian(val[i]); }
|
||||
public void Write( bool* val, int Length) { for (i = 0; i < Length; i++) stream.WriteByte((byte)(val[i] ? 1 : 0)); }
|
||||
public void Write( sbyte* val, int Length) { for (i = 0; i < Length; i++) stream.WriteByte((byte) val[i]); }
|
||||
public void Write( byte* val, int Length) { for (i = 0; i < Length; i++) stream.WriteByte( val[i]); }
|
||||
public void Write( short* val, int Length) { for (i = 0; i < Length; i++) ToArray(2, val[i]); }
|
||||
public void Write(ushort* val, int Length) { for (i = 0; i < Length; i++) ToArray(2, val[i]); }
|
||||
public void Write( int* val, int Length) { for (i = 0; i < Length; i++) ToArray(4, val[i]); }
|
||||
public void Write( uint* val, int Length) { for (i = 0; i < Length; i++) ToArray(4, val[i]); }
|
||||
public void Write( long* val, int Length) { for (i = 0; i < Length; i++) ToArray(8, val[i]); }
|
||||
public void Write( ulong* val, int Length) { for (i = 0; i < Length; i++) ToArray(8, val[i]); }
|
||||
public void Write( float* val, int Length) { for (i = 0; i < Length; i++) ToArray(4, *( uint*)&val[i]); }
|
||||
public void Write(double* val, int Length) { for (i = 0; i < Length; i++) ToArray(4, *(ulong*)&val[i]); }
|
||||
|
||||
public void WriteEndian( short* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, Endian(val[i], 2, IsBE)); }
|
||||
public void WriteEndian(ushort* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, Endian(val[i], 2, IsBE)); }
|
||||
public void WriteEndian( int* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(val[i], 4, IsBE)); }
|
||||
public void WriteEndian( uint* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(val[i], 4, IsBE)); }
|
||||
public void WriteEndian( long* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(val[i], 8, IsBE)); }
|
||||
public void WriteEndian( ulong* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(val[i], 8, IsBE)); }
|
||||
public void WriteEndian( float* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(*( uint*)&val[i], 4, IsBE)); }
|
||||
public void WriteEndian(double* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(*(ulong*)&val[i], 8, IsBE)); }
|
||||
|
||||
public void WriteEndian( short* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) WriteEndian(val[i], IsBE); }
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, Endian(val[i], 2, IsBE)); }
|
||||
public void WriteEndian(ushort* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) WriteEndian(val[i], IsBE); }
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, Endian(val[i], 2, IsBE)); }
|
||||
public void WriteEndian( int* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) WriteEndian(val[i], IsBE); }
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(val[i], 4, IsBE)); }
|
||||
public void WriteEndian( uint* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) WriteEndian(val[i], IsBE); }
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(val[i], 4, IsBE)); }
|
||||
public void WriteEndian( long* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) WriteEndian(val[i], IsBE); }
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(val[i], 8, IsBE)); }
|
||||
public void WriteEndian( ulong* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) WriteEndian(val[i], IsBE); }
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(val[i], 8, IsBE)); }
|
||||
public void WriteEndian( float* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) WriteEndian(val[i], IsBE); }
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(*( uint*)&val[i], 4, IsBE)); }
|
||||
public void WriteEndian(double* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) WriteEndian(val[i], IsBE); }
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(*(ulong*)&val[i], 8, IsBE)); }
|
||||
|
||||
public void Write( char val, bool UTF8 = true)
|
||||
{ if (UTF8) Write(val.ToString().ToUTF8()); else Write(val.ToString().ToASCII()); }
|
||||
@@ -238,28 +246,33 @@ namespace KKdMainLib.IO
|
||||
public void WriteEndian(double val, bool IsBE) => ToArray(8, Endian(*(ulong*)&val, 8, IsBE));
|
||||
|
||||
public long Endian( long BE, byte Length, bool IsBE)
|
||||
{ if (IsBE) { for (byte i = 0; i < Length; i++) { buf[i] = (byte)BE; BE >>= 8; } BE = 0;
|
||||
for (byte i = 0; i < Length; i++) { BE |= buf[i]; if (i < Length - 1) BE <<= 8; } } return BE; }
|
||||
{ if (IsBE) { for (I = 0; I < Length; I++) { buf[I] = (byte)BE; BE >>= 8; } BE = 0;
|
||||
for (I = 0; I < Length; I++) { BE |= buf[I]; if (I < Length - 1) BE <<= 8; } } return BE; }
|
||||
|
||||
public ulong Endian( ulong BE, byte Length, bool IsBE)
|
||||
{ if (IsBE) { for (byte i = 0; i < Length; i++) { buf[i] = (byte)BE; BE >>= 8; } BE = 0;
|
||||
for (byte i = 0; i < Length; i++) { BE |= buf[i]; if (i < Length - 1) BE <<= 8; } } return BE; }
|
||||
{ if (IsBE) { for (I = 0; I < Length; I++) { buf[I] = (byte)BE; BE >>= 8; } BE = 0;
|
||||
for (I = 0; I < Length; I++) { BE |= buf[I]; if (I < Length - 1) BE <<= 8; } } return BE; }
|
||||
|
||||
private void ToArray(byte L, long val)
|
||||
{ CheckWrited(); for (i = 0; i < L; i++) { buf[i] = (byte)val; val >>= 8; } Write(buf, L); }
|
||||
{ CheckWrited(); for (I = 0; I < L; I++) { buf[I] = (byte)val; val >>= 8; } stream.Write(buf, 0, L); }
|
||||
|
||||
private void ToArray(byte L, ulong val)
|
||||
{ CheckWrited(); for (i = 0; i < L; i++) { buf[i] = (byte)val; val >>= 8; } Write(buf, L); }
|
||||
{ CheckWrited(); for (I = 0; I < L; I++) { buf[I] = (byte)val; val >>= 8; } stream.Write(buf, 0, L); }
|
||||
|
||||
private long IntFromArray(byte L, bool IsBE = false) { Read(L); long val = 0; if (IsBE)
|
||||
for (i = 0; i < L; i++) { val <<= 8; val |= buf[i ]; } else
|
||||
for (i = L; i > 0; i--) { val <<= 8; val |= buf[i - 1]; } return val; }
|
||||
private long IntFromArray(byte L) { stream.Read(buf, 0, L); long val = 0;
|
||||
for (I = L; I > 0; I--) { val <<= 8; val |= buf[I - 1]; } return val; }
|
||||
|
||||
private ulong UIntFromArray(byte L, bool IsBE = false) { Read(L); ulong val = 0; if (IsBE)
|
||||
for (i = 0; i < L; i++) { val <<= 8; val |= buf[i ]; } else
|
||||
for (i = L; i > 0; i--) { val <<= 8; val |= buf[i - 1]; } return val; }
|
||||
private ulong UIntFromArray(byte L) { stream.Read(buf, 0, L); ulong val = 0;
|
||||
for (I = L; I > 0; I--) { val <<= 8; val |= buf[I - 1]; } return val; }
|
||||
|
||||
private void Read(byte Length) => stream.Read(buf, 0, Length);
|
||||
private long IntFromArray(byte L, bool IsBE) { stream.Read(buf, 0, L); long val = 0; if (IsBE)
|
||||
for (I = 0; I < L; I++) { val <<= 8; val |= buf[I ]; } else
|
||||
for (I = L; I > 0; I--) { val <<= 8; val |= buf[I - 1]; } return val; }
|
||||
|
||||
private ulong UIntFromArray(byte L, bool IsBE) { stream.Read(buf, 0, L); ulong val = 0; if (IsBE)
|
||||
for (I = 0; I < L; I++) { val <<= 8; val |= buf[I ]; } else
|
||||
for (I = L; I > 0; I--) { val <<= 8; val |= buf[I - 1]; } return val; }
|
||||
|
||||
public char ReadChar(bool UTF8 = true)
|
||||
{ if (UTF8) return ReadCharUTF8();
|
||||
else return (char)stream.ReadByte(); }
|
||||
@@ -269,17 +282,17 @@ namespace KKdMainLib.IO
|
||||
byte t;
|
||||
int T;
|
||||
int val = 0;
|
||||
for (i = 0, i0 = 4; i < i0; i++)
|
||||
for (I = 0, i0 = 4; I < i0; I++)
|
||||
{
|
||||
T = stream.ReadByte();
|
||||
if (T == -1) return '\uFFFF';
|
||||
t = (byte)T;
|
||||
|
||||
if ((t & 0xC0) == 0x80 && i > 0) val = (val << 6) | (t & 0x3F);
|
||||
else if ((t & 0x80) == 0x00 && i == 0) return (char)t;
|
||||
else if ((t & 0xE0) == 0xC0 && i == 0) { val = t & 0x1F; i0 = 2; }
|
||||
else if ((t & 0xF0) == 0xE0 && i == 0) { val = t & 0x0F; i0 = 3; }
|
||||
else if ((t & 0xF8) == 0xF0 && i == 0) { val = t & 0x07; i0 = 4; }
|
||||
if ((t & 0xC0) == 0x80 && I > 0) val = (val << 6) | (t & 0x3F);
|
||||
else if ((t & 0x80) == 0x00 && I == 0) return (char)t;
|
||||
else if ((t & 0xE0) == 0xC0 && I == 0) { val = t & 0x1F; i0 = 2; }
|
||||
else if ((t & 0xF0) == 0xE0 && I == 0) { val = t & 0x0F; i0 = 3; }
|
||||
else if ((t & 0xF8) == 0xF0 && I == 0) { val = t & 0x07; i0 = 4; }
|
||||
else return '\uFFFF';
|
||||
}
|
||||
return (char)val;
|
||||
@@ -357,21 +370,6 @@ namespace KKdMainLib.IO
|
||||
LongPosition = Offset;
|
||||
return Data;
|
||||
}
|
||||
|
||||
public long ReadIntX( ) => IsX ? ReadInt64() : ReadUInt32Endian( );
|
||||
public long ReadIntX(bool IsBE) => IsX ? ReadInt64() : ReadUInt32Endian(IsBE);
|
||||
|
||||
public string ReadStringAtOffset(long Offset = 0, long Length = 0)
|
||||
{
|
||||
string s = null;
|
||||
long Position = LongPosition;
|
||||
if (Offset == 0) { Position += IsX ? 8 : 4; Offset = ReadIntX(); }
|
||||
LongPosition = Offset;
|
||||
if (Length == 0) s = this.NullTerminatedUTF8();
|
||||
else s = ReadStringUTF8(Length);
|
||||
LongPosition = Position;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SeekOrigin
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="A3DA\A3DAExt.cs" />
|
||||
<Compile Include="A3DA\A3DA.cs" />
|
||||
<Compile Include="Aet\Aet.cs" />
|
||||
<Compile Include="Aet\AetExt.cs" />
|
||||
<Compile Include="DB\Aet.cs" />
|
||||
<Compile Include="DB\Auth.cs" />
|
||||
<Compile Include="DB\Spr.cs" />
|
||||
@@ -52,7 +54,6 @@
|
||||
<Compile Include="Types\Half.cs" />
|
||||
<Compile Include="Types\Vector2.cs" />
|
||||
<Compile Include="Types\Vector3.cs" />
|
||||
<Compile Include="Aet.cs" />
|
||||
<Compile Include="DataBank.cs" />
|
||||
<Compile Include="DCC.cs" />
|
||||
<Compile Include="DEX.cs" />
|
||||
@@ -64,7 +65,6 @@
|
||||
<Compile Include="POF.cs" />
|
||||
<Compile Include="STR.cs" />
|
||||
<Compile Include="Text.cs" />
|
||||
<Compile Include="Xml.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -72,8 +72,6 @@
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
+16
-14
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
@@ -70,8 +71,8 @@ namespace KKdMainLib
|
||||
string MsgPack = GetArgs("MessagePack", true, "mp");
|
||||
string JSON = GetArgs("JSON", true, "json");
|
||||
string BIN = GetArgs("BIN", true, "bin");
|
||||
string XML = GetArgs("XML", true, "xml");
|
||||
|
||||
string WAV = GetArgs("WAV", true, "wav");
|
||||
|
||||
FileNames = new string[0];
|
||||
if (code == 1)
|
||||
{
|
||||
@@ -79,14 +80,14 @@ namespace KKdMainLib
|
||||
OpenFileDialog ofd = new OpenFileDialog { InitialDirectory =
|
||||
Application.StartupPath, Multiselect = true };
|
||||
|
||||
if (filetype == "a3da") ofd.Filter = GetArgs("A3DA", "a3da", "json", "mp") +
|
||||
if (filetype == "a3da") ofd.Filter = GetArgs("A3DA", "a3da", "json", "mp") +
|
||||
GetArgs("A3DA", true, "a3da") + JSON + MsgPack;
|
||||
else if (filetype == "bin" ) ofd.Filter = GetArgs("BIN" , "bin", "json", "mp") +
|
||||
BIN + JSON + MsgPack;
|
||||
else if (filetype == "bon" ) ofd.Filter = GetArgs("BON" , "bon", "bin", "json", "mp") +
|
||||
GetArgs("BON", true, "bon") + BIN + JSON + MsgPack;
|
||||
else if (filetype == "databank") ofd.Filter = GetArgs("DAT" , "dat", "xml") +
|
||||
GetArgs("DAT", true, "dat") + XML;
|
||||
else if (filetype == "databank") ofd.Filter = GetArgs("DAT", "dat", "json", "mp") +
|
||||
GetArgs("DAT", true, "dat") + JSON + MsgPack;
|
||||
else if (filetype == "dex" ) ofd.Filter = GetArgs("DEX" , "dex", "bin", "json", "mp") +
|
||||
GetArgs("DEX", true, "dex") + BIN + JSON + MsgPack;
|
||||
else if (filetype == "diva") ofd.Filter = GetArgs("DIVA", "diva", "wav") +
|
||||
@@ -96,17 +97,15 @@ namespace KKdMainLib
|
||||
else if (filetype == "farc") ofd.Filter = "FARC Archives (*.farc)|*.farc";
|
||||
else if (filetype == "image") ofd.Filter = GetArgs("Image", "dds", "png") +
|
||||
GetArgs("DDS", true, "dds") + GetArgs("PNG", true, "png");
|
||||
else if (filetype == "kki") ofd.Filter = GetArgs("KKI", "kki");
|
||||
else if (filetype == "mot") ofd.Filter = GetArgs("MOT", "mot", "json", "mp") +
|
||||
GetArgs("MOT", true, "mot") + JSON + MsgPack;
|
||||
else if (filetype == "ppd") ofd.Filter = GetArgs("PPD", "ppd", "pak", "mod") +
|
||||
else if (filetype == "json") ofd.Filter = "JSON (*.json)|*.json";
|
||||
else if (filetype == "kki" ) ofd.Filter = GetArgs("KKI", "kki");
|
||||
else if (filetype == "ppd" ) ofd.Filter = GetArgs("PPD", "ppd", "pak", "mod") +
|
||||
GetArgs("PPD", true, "ppd") + GetArgs("PAK", true, "pak") + GetArgs("MOD", true, "mod");
|
||||
else if (filetype == "str") ofd.Filter = GetArgs("STR", "str", "bin", "json", "mp") +
|
||||
else if (filetype == "str" ) ofd.Filter = GetArgs("STR", "str", "bin", "json", "mp") +
|
||||
GetArgs("STR", true, "str") + BIN + JSON + MsgPack;
|
||||
else if (filetype == "vag") ofd.Filter = GetArgs("VAG", "vag", "wav") +
|
||||
else if (filetype == "vag" ) ofd.Filter = GetArgs("VAG", "vag", "wav") +
|
||||
GetArgs("VAG", true, "vag") + GetArgs("WAV", true, "wav");
|
||||
else if (filetype == "xml") ofd.Filter = GetArgs("XML", "xml");
|
||||
else ofd.Filter = GetArgs("All;", false, "*");
|
||||
else ofd.Filter = GetArgs("All;", false, "*");
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
FileNames = ofd.FileNames;
|
||||
@@ -280,7 +279,10 @@ namespace KKdMainLib
|
||||
}
|
||||
else if (!Dict.ContainsKey(args[0])) Dict.Add(args[0], value);
|
||||
}
|
||||
|
||||
|
||||
public static TKey GetKey<TKey, TVal>(this Dictionary<TKey, TVal> Dict, TVal val) =>
|
||||
Dict.First((KeyValuePair<TKey, TVal> x) => x.Value.Equals(val)).Key;
|
||||
|
||||
public static string ToTitleCase(this string s)
|
||||
{ return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s); }
|
||||
|
||||
|
||||
@@ -15,27 +15,36 @@ namespace KKdMainLib.MessagePack
|
||||
|
||||
public void Close() => _IO.Close();
|
||||
|
||||
public MsgPack Read() => ReadValue(null);
|
||||
public MsgPack Read() => ReadValue();
|
||||
|
||||
private string ReadKey() => ReadString();
|
||||
|
||||
private MsgPack ReadValue()
|
||||
{
|
||||
char c = _IO.SkipWhitespace().PeekCharUTF8();
|
||||
object obj = null;
|
||||
if (c == '{') obj = ReadObject();
|
||||
return new MsgPack(null, true, obj);
|
||||
}
|
||||
|
||||
private MsgPack ReadValue(string Key)
|
||||
{
|
||||
char c = _IO.SkipWhitespace().PeekCharUTF8();
|
||||
object obj = null;
|
||||
if (char.IsDigit(c))
|
||||
obj = ReadNumber ();
|
||||
switch (c)
|
||||
{
|
||||
case '"': obj = ReadString (); break;
|
||||
case '{': obj = ReadObject (); break;
|
||||
case '[': obj = ReadArray (); break;
|
||||
case '-': obj = ReadNumber (); break;
|
||||
case 't':
|
||||
case 'f': obj = ReadBoolean(); break;
|
||||
case 'n': obj = ReadNull (); break;
|
||||
}
|
||||
return new MsgPack(Key, obj);
|
||||
obj = ReadNumber ();
|
||||
else
|
||||
switch (c)
|
||||
{
|
||||
case '"': obj = ReadString (); break;
|
||||
case '{': obj = ReadObject (); break;
|
||||
case '[': obj = ReadArray (); break;
|
||||
case '-': obj = ReadNumber (); break;
|
||||
case 't':
|
||||
case 'f': obj = ReadBoolean(); break;
|
||||
case 'n': obj = ReadNull (); break;
|
||||
}
|
||||
return new MsgPack(Key, true, obj);
|
||||
}
|
||||
|
||||
private string ReadString()
|
||||
@@ -154,17 +163,17 @@ namespace KKdMainLib.MessagePack
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ReadNull() => _IO.Assert("null");
|
||||
private object ReadNull() { _IO.Assert("null"); return null; }
|
||||
|
||||
private string ReadDigits()
|
||||
{ string s = ""; while (char.IsDigit(_IO.SkipWhitespace().
|
||||
PeekCharUTF8())) s += _IO.ReadCharUTF8(); return s; }
|
||||
|
||||
public JSONIO Write(MsgPack MsgPack, bool Close, string End = "\n", string TabChar = "\t")
|
||||
public JSONIO Write(MsgPack MsgPack, bool Close, string End = "\n", string TabChar = " ")
|
||||
{ Write(MsgPack, End, TabChar, "", true); if (Close) this.Close(); return this; }
|
||||
|
||||
public JSONIO Write(MsgPack MsgPack, bool Close, bool Style = false)
|
||||
{ Write(MsgPack, "\n", "\t", "", Style); if (Close) this.Close(); return this; }
|
||||
{ Write(MsgPack, "\n", " ", "", Style); if (Close) this.Close(); return this; }
|
||||
|
||||
private JSONIO Write(MsgPack MsgPack, string End, string TabChar, string Tab, bool Style)
|
||||
{
|
||||
@@ -172,46 +181,43 @@ namespace KKdMainLib.MessagePack
|
||||
Tab += TabChar;
|
||||
if (MsgPack.Name != null) _IO.Write("\"" + MsgPack.Name + "\":" + (Style ? " " : ""));
|
||||
if (MsgPack.Object == null) { WriteNil(); return this; }
|
||||
|
||||
Type type = MsgPack.Object.GetType();
|
||||
if (type == typeof(List<object>))
|
||||
|
||||
if (MsgPack.List != null)
|
||||
{
|
||||
List<object> Obj = (List<object>)MsgPack.Object;
|
||||
WriteMap();
|
||||
if (Style) _IO.Write(End);
|
||||
for (int i = 0; i < Obj. Count; i++)
|
||||
for (int i = 0; i < MsgPack.List.Count; i++)
|
||||
{
|
||||
if (Style) _IO.Write(Tab);
|
||||
Write(Obj[i], Obj[i].GetType(), End, TabChar, Tab, Style);
|
||||
if (i + 1 < Obj. Count) _IO.Write(',');
|
||||
Write(MsgPack.List[i], End, TabChar, Tab, Style);
|
||||
if (i + 1 < MsgPack.List. Count) _IO.Write(',');
|
||||
if (Style) _IO.Write(End);
|
||||
}
|
||||
if (Style) _IO.Write(OldTab);
|
||||
WriteMap(true);
|
||||
}
|
||||
else if (type == typeof(object[]))
|
||||
else if (MsgPack.Array != null)
|
||||
{
|
||||
object[] Obj = (object[])MsgPack.Object;
|
||||
WriteArr();
|
||||
if (Style) _IO.Write(End);
|
||||
for (int i = 0; i < Obj.Length; i++)
|
||||
for (int i = 0; i < MsgPack.Array.Length; i++)
|
||||
{
|
||||
if (Style) _IO.Write(Tab);
|
||||
Write(Obj[i], Obj[i].GetType(), End, TabChar, Tab, Style);
|
||||
if (i + 1 < Obj.Length) _IO.Write(',');
|
||||
Write(MsgPack.Array[i], End, TabChar, Tab, Style);
|
||||
if (i + 1 < MsgPack.Array.Length) _IO.Write(',');
|
||||
if (Style) _IO.Write(End);
|
||||
}
|
||||
if (Style) _IO.Write(OldTab);
|
||||
WriteArr(true);
|
||||
}
|
||||
else if (type == typeof(MsgPack))
|
||||
Write((MsgPack)MsgPack.Object, End, TabChar, Tab, Style);
|
||||
else Write(MsgPack.Object, type, End, TabChar, Tab, Style);
|
||||
else if (MsgPack.Object is MsgPack msg)
|
||||
Write(msg, End, TabChar, Tab, Style);
|
||||
else Write(MsgPack.Object, End, TabChar, Tab, Style);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Write(object obj, Type type, string End, string TabChar, string Tab, bool Style)
|
||||
private void Write(object obj, string End, string TabChar, string Tab, bool Style)
|
||||
{
|
||||
if (obj == null) { WriteNil(); return; }
|
||||
switch (obj)
|
||||
|
||||
@@ -17,6 +17,24 @@ namespace KKdMainLib.MessagePack
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
public static void WriteAfterAll(this MsgPack mp, bool Temp, string file, bool JSON = false)
|
||||
{ if (Temp) new MsgPack().Add(mp).WriteAfterAll(file, JSON).Dispose();
|
||||
else mp .WriteAfterAll(file, JSON); }
|
||||
|
||||
public static MsgPack WriteAfterAll(this MsgPack mp, string file, bool JSON = false)
|
||||
{
|
||||
byte[] data = null;
|
||||
if (JSON)
|
||||
{ JSONIO IO = new JSONIO(File.OpenWriter());
|
||||
IO.Write(mp, false, true); data = IO._IO.ToArray(true); }
|
||||
else
|
||||
{ MPIO IO = new MPIO(File.OpenWriter());
|
||||
IO.Write(mp, false ); data = IO._IO.ToArray(true); }
|
||||
File.WriteAllBytes(file + (JSON ? ".json" : ".mp"), data);
|
||||
return mp;
|
||||
}
|
||||
|
||||
|
||||
public static void Write(this MsgPack mp, bool Temp, string file, bool JSON = false)
|
||||
{ if (Temp) new MsgPack().Add(mp).Write(file, JSON).Dispose();
|
||||
else mp .Write(file, JSON); }
|
||||
@@ -31,5 +49,11 @@ namespace KKdMainLib.MessagePack
|
||||
IO.Write(mp, true ); IO = null; }
|
||||
return mp;
|
||||
}
|
||||
|
||||
public static void ToJSON (this string file) =>
|
||||
file.ReadMP( ).Write(file, true).Dispose();
|
||||
|
||||
public static void ToMsgPack(this string file) =>
|
||||
file.ReadMP(true).Write(file ).Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace KKdMainLib.MessagePack
|
||||
public Types Type;
|
||||
public string Name;
|
||||
public object Object;
|
||||
|
||||
public object[] Array => Object is object[] List ? List : null;
|
||||
public List<object> List => Object is List<object> Array ? Array : null;
|
||||
|
||||
public MsgPack( Types Type = Types.Map32) => NewMsgPack(null, Type);
|
||||
public MsgPack(string Name, Types Type = Types.Map32) => NewMsgPack(Name, Type);
|
||||
@@ -16,7 +19,7 @@ namespace KKdMainLib.MessagePack
|
||||
public MsgPack(string Name, long Count) => NewMsgPack(Name, Count);
|
||||
public MsgPack(string Name, Types Type, object Object)
|
||||
{ this.Name = Name; this.Type = Type; this.Object = Object; }
|
||||
public MsgPack(string Name, object Object)
|
||||
public MsgPack(string Name, bool TypeIsntKnown, object Object)
|
||||
{
|
||||
switch (Object)
|
||||
{
|
||||
@@ -37,6 +40,7 @@ namespace KKdMainLib.MessagePack
|
||||
case double val: Type = Types.Float64; break;
|
||||
case string val: Type = Types. Str32; break;
|
||||
case Ext val: Type = Types. Ext32; break;
|
||||
case null: Type = Types. Nil; break;
|
||||
}
|
||||
this.Name = Name; this.Object = Object;
|
||||
}
|
||||
@@ -44,8 +48,11 @@ namespace KKdMainLib.MessagePack
|
||||
public static MsgPack Null => null;
|
||||
|
||||
public object this[int index]
|
||||
{ get { return ((object[])Object)[index]; }
|
||||
set { object[] Data = (object[])Object; Data[index] = value; Object = Data; } }
|
||||
{ get { if (Array != null) return Array[index]; return null; }
|
||||
set { if (Array != null) Array[index] = value; } }
|
||||
|
||||
public MsgPack Add(object obj)
|
||||
{ if (obj != null && List != null) List.Add(obj); return this; }
|
||||
|
||||
public MsgPack(List<object> Object, string Name, Types Type)
|
||||
{ this.Object = Object; this.Name = Name; this.Type = Type; }
|
||||
@@ -54,19 +61,8 @@ namespace KKdMainLib.MessagePack
|
||||
{ Object = new List<object>(); this.Name = Name; this.Type = Type; }
|
||||
|
||||
private void NewMsgPack(string Name, long Count)
|
||||
{ if (Count > 0) Object = new object[Count]; else Object = null; this.Name = Name; Type = Types.Arr32; }
|
||||
|
||||
public MsgPack Add(object obj)
|
||||
{ if (obj != null) if (typeof(List<object>) == Object.GetType())
|
||||
{ List<object> Obj = (List<object>)Object; Obj.Add(obj); Object = Obj; } return this; }
|
||||
|
||||
public MsgPack ToArray()
|
||||
{ if (typeof(List<object> ) == Object.GetType())
|
||||
{ Object = ((List<object> ) Object) .ToArray(); Type = Types.Arr32; } return this; }
|
||||
|
||||
public MsgPack ToList()
|
||||
{ if (typeof( object[]) == Object.GetType())
|
||||
{ Object = (( object[]) Object).OfType<object>().ToList (); Type = Types.Map32; } return this; }
|
||||
{ if (Count > 0) { Object = new object[Count]; }
|
||||
else Object = null; this.Name = Name; Type = Types.Arr32; }
|
||||
|
||||
public void Dispose()
|
||||
{ Type = 0; Name = null; Object = null; }
|
||||
@@ -197,105 +193,72 @@ namespace KKdMainLib.MessagePack
|
||||
public double ReadDouble() => ReadNDouble().GetValueOrDefault();
|
||||
|
||||
public bool? ReadNBoolean()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof( bool)) return ( bool) Object; return null; ; }
|
||||
{ if (Object is bool Boolean) return Boolean; return null; }
|
||||
public sbyte? ReadNInt8()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof( long)) return ( sbyte)( long)Object;
|
||||
else if (Object.GetType() == typeof( ulong)) return ( sbyte)(ulong)Object; return null; }
|
||||
{ if (Object is long Int64) return ( sbyte) Int64;
|
||||
else if (Object is ulong UInt64) return ( sbyte) UInt64; return null; }
|
||||
public byte? ReadNUInt8()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof( long)) return ( byte)( long)Object;
|
||||
else if (Object.GetType() == typeof( ulong)) return ( byte)(ulong)Object; return null; }
|
||||
{ if (Object is long Int64) return ( byte) Int64;
|
||||
else if (Object is ulong UInt64) return ( byte) UInt64; return null; }
|
||||
public short? ReadNInt16()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof( long)) return ( short)( long)Object;
|
||||
else if (Object.GetType() == typeof( ulong)) return ( short)(ulong)Object; return null; }
|
||||
{ if (Object is long Int64) return ( short) Int64;
|
||||
else if (Object is ulong UInt64) return ( short) UInt64; return null; }
|
||||
public ushort? ReadNUInt16()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof( long)) return (ushort)( long)Object;
|
||||
else if (Object.GetType() == typeof( ulong)) return (ushort)(ulong)Object; return null; }
|
||||
{ if (Object is long Int64) return (ushort) Int64;
|
||||
else if (Object is ulong UInt64) return (ushort) UInt64; return null; }
|
||||
public int? ReadNInt32()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof( long)) return ( int)( long)Object;
|
||||
else if (Object.GetType() == typeof( ulong)) return ( int)(ulong)Object; return null; }
|
||||
{ if (Object is long Int64) return ( int) Int64;
|
||||
else if (Object is ulong UInt64) return ( int) UInt64; return null; }
|
||||
public uint? ReadNUInt32()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof( long)) return ( uint)( long)Object;
|
||||
else if (Object.GetType() == typeof( ulong)) return ( uint)(ulong)Object; return null; }
|
||||
{ if (Object is long Int64) return ( uint) Int64;
|
||||
else if (Object is ulong UInt64) return ( uint) UInt64; return null; }
|
||||
public long? ReadNInt64()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof( long)) return ( long) Object;
|
||||
else if (Object.GetType() == typeof( ulong)) return ( long)(ulong)Object; return null; }
|
||||
{ if (Object is long Int64) return ( long) Int64;
|
||||
else if (Object is ulong UInt64) return ( long) UInt64; return null; }
|
||||
public ulong? ReadNUInt64()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof( ulong)) return ( ulong) Object;
|
||||
else if (Object.GetType() == typeof( long)) return ( ulong)( long)Object; return null; }
|
||||
{ if (Object is long Int64) return ( ulong) Int64;
|
||||
else if (Object is ulong UInt64) return ( ulong) UInt64; return null; }
|
||||
public float? ReadNSingle()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof(double)) return (float)(double)Object;
|
||||
else if (Object.GetType() == typeof( float)) return (float) Object;
|
||||
else if (Object.GetType() == typeof( long)) return (float)( long)Object;
|
||||
else if (Object.GetType() == typeof( ulong)) return (float)( ulong)Object; return null; }
|
||||
{ if (Object is long Int64) return ( float) Int64;
|
||||
else if (Object is ulong UInt64) return ( float) UInt64;
|
||||
else if (Object is float Float32) return ( float)Float32;
|
||||
else if (Object is double Float64) return ( float)Float64; return null; }
|
||||
public double? ReadNDouble()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof(double)) return (double) Object;
|
||||
else if (Object.GetType() == typeof( float)) return (double)(float)Object;
|
||||
else if (Object.GetType() == typeof( long)) return (double)( long)Object;
|
||||
else if (Object.GetType() == typeof( ulong)) return (double)(ulong)Object; return null; }
|
||||
{ if (Object is long Int64) return (double) Int64;
|
||||
else if (Object is ulong UInt64) return (double) UInt64;
|
||||
else if (Object is float Float32) return (double)Float32;
|
||||
else if (Object is double Float64) return (double)Float64; return null; }
|
||||
public string ReadString()
|
||||
{ if (Object == null) return null;
|
||||
if (Object.GetType() == typeof(string)) return (string) Object; return null; }
|
||||
|
||||
public bool Element(string Name, out MsgPack MsgPack, Type Type)
|
||||
{ if (Element(out MsgPack, Name)) return MsgPack.Object.GetType() == Type; return false; }
|
||||
{ if (Object is string String) return String; return null; }
|
||||
|
||||
public bool Element<T>(string Name, out MsgPack MsgPack)
|
||||
{
|
||||
if (Element(Name, out MsgPack))
|
||||
{
|
||||
if (MsgPack.Array == null) return false;
|
||||
|
||||
for (int i = 0; i < MsgPack.Array.Length; i++)
|
||||
if (!(MsgPack[i] is T)) return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Element(string Name, out MsgPack MsgPack)
|
||||
{ if (Element(out MsgPack, Name)) return MsgPack != null; return false; }
|
||||
|
||||
public bool Element(out MsgPack MsgPack, string Name)
|
||||
{
|
||||
MsgPack = null;
|
||||
if (Object == null) return false;
|
||||
|
||||
Type type = Object.GetType();
|
||||
if (type == typeof(List<object>))
|
||||
{
|
||||
List<object> Obj = (List<object>)Object;
|
||||
foreach (object obj in Obj)
|
||||
{
|
||||
if (obj == null) continue; type = obj.GetType();
|
||||
if (type == typeof(MsgPack)) if (((MsgPack)obj).Name == Name)
|
||||
{ MsgPack = (MsgPack)obj; return true; }
|
||||
}
|
||||
}
|
||||
else if (type == typeof(object[]))
|
||||
{
|
||||
object[] Obj = (object[])Object;
|
||||
foreach (object obj in Obj)
|
||||
{
|
||||
if (obj == null) continue; type = obj.GetType();
|
||||
if (type == typeof(MsgPack)) if (((MsgPack)obj).Name == Name)
|
||||
{ MsgPack = (MsgPack)obj; return true; }
|
||||
}
|
||||
}
|
||||
if (List != null)
|
||||
foreach (object obj in List)
|
||||
if (obj is MsgPack msg) if (msg.Name == Name) { MsgPack = msg; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ContainsKey(string Name)
|
||||
{
|
||||
if (Object == null) return false;
|
||||
|
||||
Type type = Object.GetType();
|
||||
if (type == typeof(List<object>))
|
||||
{
|
||||
List<object> Obj = (List<object>)Object;
|
||||
foreach (object obj in Obj)
|
||||
{
|
||||
if (obj == null) continue; type = obj.GetType();
|
||||
if (type == typeof(MsgPack)) if (((MsgPack)obj).Name == Name) return true;
|
||||
}
|
||||
}
|
||||
if (List == null) return false;
|
||||
|
||||
foreach (object obj in List)
|
||||
if (obj is MsgPack msg) if (msg.Name == Name) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("2BA7EFC6-91D1-8BBC-C487-06C7F36CC789")]
|
||||
[assembly: AssemblyVersion("0.4.5.9")]
|
||||
[assembly: AssemblyFileVersion("0.4.5.9")]
|
||||
[assembly: AssemblyVersion("0.4.5.10")]
|
||||
[assembly: AssemblyFileVersion("0.4.5.10")]
|
||||
|
||||
+11
-14
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
@@ -176,21 +175,19 @@ namespace KKdMainLib
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
if (MsgPack.Element("STR", out MsgPack STR))
|
||||
{
|
||||
if (STR.Element("Strings", out MsgPack Strings, typeof(object[])))
|
||||
if (!MsgPack.Element("STR", out MsgPack STR)) return;
|
||||
|
||||
if (!STR.Element<MsgPack>("Strings", out MsgPack Strings)) return;
|
||||
|
||||
STRs = new String[Strings.Array.Length];
|
||||
for (int i = 0; i < STRs.Length; i++)
|
||||
if (Strings[i] is MsgPack String)
|
||||
{
|
||||
STRs = new String[((object[])Strings.Object).Length];
|
||||
MsgPack String;
|
||||
for (int i = 0; i < STRs.Length; i++)
|
||||
if (Strings[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
String = (MsgPack)Strings[i];
|
||||
STRs[i].ID = String.ReadInt32 ("ID" );
|
||||
STRs[i].Str = String.ReadString("Str");
|
||||
}
|
||||
String = (MsgPack)Strings[i];
|
||||
STRs[i].ID = String.ReadInt32("ID");
|
||||
STRs[i].Str = String.ReadString("Str");
|
||||
}
|
||||
}
|
||||
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public class Xml
|
||||
{
|
||||
public XDocument doc;
|
||||
|
||||
public bool Compact = false;
|
||||
|
||||
public Xml() { doc = new XDocument(); }
|
||||
|
||||
public void OpenXml(string file, bool compact)
|
||||
{
|
||||
doc = XDocument.Load(file);
|
||||
Compact = compact;
|
||||
}
|
||||
|
||||
public void SaveXml(string file)
|
||||
{
|
||||
XmlWriter writer = XmlWriter.Create(file, settings);
|
||||
doc.Save(writer);
|
||||
writer.Dispose();
|
||||
Compact = false;
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
public readonly XmlWriterSettings settings = new XmlWriterSettings
|
||||
{ Encoding = Encoding.UTF8, NewLineChars = "\n", Indent = true, IndentChars = "\t" };
|
||||
|
||||
public void Reader(XElement Child, ref bool value, string localName)
|
||||
{ if (Child.Name == localName) value = bool.Parse(Child.Value); }
|
||||
|
||||
public void Reader(XAttribute Entry, ref bool value, string localName)
|
||||
{ if (Entry.Name == localName) value = bool.Parse(Entry.Value); }
|
||||
|
||||
public void Reader(XElement Child, ref int value, string localName)
|
||||
{ if (Child.Name == localName) value = int.Parse(Child.Value); }
|
||||
|
||||
public void Reader(XAttribute Entry, ref int value, string localName)
|
||||
{ if (Entry.Name == localName) value = int.Parse(Entry.Value); }
|
||||
|
||||
public void Reader(XElement Child, ref uint value, string localName)
|
||||
{ if (Child.Name == localName) value = uint.Parse(Child.Value); }
|
||||
|
||||
public void Reader(XAttribute Entry, ref uint value, string localName)
|
||||
{ if (Entry.Name == localName) value = uint.Parse(Entry.Value); }
|
||||
|
||||
public void Reader(XElement Child, ref long value, string localName)
|
||||
{ if (Child.Name == localName) value = long.Parse(Child.Value); }
|
||||
|
||||
public void Reader(XAttribute Entry, ref long value, string localName)
|
||||
{ if (Entry.Name == localName) value = long.Parse(Entry.Value); }
|
||||
|
||||
public void Reader(XElement Child, ref ulong value, string localName)
|
||||
{ if (Child.Name == localName) value = ulong.Parse(Child.Value); }
|
||||
|
||||
public void Reader(XAttribute Entry, ref ulong value, string localName)
|
||||
{ if (Entry.Name == localName) value = ulong.Parse(Entry.Value); }
|
||||
|
||||
public void Reader(XElement Child, ref double value, string localName)
|
||||
{ if (Child.Name == localName) value = Child.Value.ToDouble(); }
|
||||
|
||||
public void Reader(XAttribute Entry, ref double value, string localName)
|
||||
{ if (Entry.Name == localName) value = Entry.Value.ToDouble(); }
|
||||
|
||||
public void Reader(XElement Child, ref string value, string localName)
|
||||
{ if (Child.Name == localName) value = Child.Value; }
|
||||
|
||||
public void Reader(XAttribute Entry, ref string value, string localName)
|
||||
{ if (Entry.Name == localName) value = Entry.Value; }
|
||||
|
||||
public void Reader(XElement Child, ref string[] value, string localName, params char[] Separate)
|
||||
{ if (Child.Name == localName) value = Child.Value.Split(Separate); }
|
||||
|
||||
public void Reader(XAttribute Entry, ref string[] value, string localName, params char[] Separate)
|
||||
{ if (Entry.Name == localName) value = Entry.Value.Split(Separate); }
|
||||
|
||||
public void Writer(XElement element, bool value, string localName) =>
|
||||
Writer(element, value.ToString().ToLower(), localName);
|
||||
|
||||
public void Writer(XElement element, long value, string localName) =>
|
||||
Writer(element, value.ToString().ToLower(), localName);
|
||||
|
||||
public void Writer(XElement element, ulong value, string localName) =>
|
||||
Writer(element, value.ToString().ToLower(), localName);
|
||||
|
||||
public void Writer(XElement element, double value, string localName) =>
|
||||
Writer(element, value.ToString(), localName);
|
||||
|
||||
public void Writer(XElement element, string value, string localName)
|
||||
{
|
||||
if (Compact && value != "" && value != null)
|
||||
element.Add(new XAttribute(localName, value));
|
||||
else if (!Compact)
|
||||
element.Add(new XElement(localName, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
+87
-103
@@ -6,124 +6,108 @@ namespace KKdSoundLib
|
||||
public unsafe class DIVA
|
||||
{
|
||||
public DIVAFile Data = new DIVAFile();
|
||||
|
||||
public string file = "";
|
||||
private int c, i;
|
||||
|
||||
public DIVA() { Data = new DIVAFile(); file = ""; }
|
||||
public DIVA(string filepath) { Data = new DIVAFile(); file = filepath; }
|
||||
public DIVA() { Data = new DIVAFile(); }
|
||||
|
||||
public void DIVAReader(bool ToArray = false)
|
||||
public void DIVAReader(string file, bool ToArray = false)
|
||||
{
|
||||
if (File.Exists(file + ".diva"))
|
||||
{
|
||||
Data = new DIVAFile();
|
||||
Stream reader = File.OpenReader(file + ".diva");
|
||||
if (!File.Exists(file + ".diva")) return;
|
||||
|
||||
if (reader.ReadString(0x04) == "DIVA")
|
||||
{
|
||||
reader.ReadInt32();
|
||||
Data.Size = reader.ReadUInt32();
|
||||
Data.SampleRate = reader.ReadUInt32();
|
||||
Data.SamplesCount = reader.ReadUInt32();
|
||||
reader.ReadInt64();
|
||||
Data.Channels = reader.ReadUInt16();
|
||||
reader.ReadUInt16();
|
||||
Data.Name = reader.ReadString(0x20);
|
||||
Data = new DIVAFile();
|
||||
Stream reader = File.OpenReader(file + ".diva");
|
||||
|
||||
Stream writer = File.OpenWriter();
|
||||
if (!ToArray) writer = File.OpenWriter(file + ".wav", true);
|
||||
writer.LongPosition = 0x2C;
|
||||
if (reader.ReadString(0x04) != "DIVA") { reader.Close(); return; }
|
||||
|
||||
byte value = 0;
|
||||
int[] current = new int[Data.Channels];
|
||||
int[] currentclamp = new int[Data.Channels];
|
||||
sbyte[] stepindex = new sbyte[Data.Channels];
|
||||
float f;
|
||||
reader.ReadInt32();
|
||||
Data.Size = reader.ReadUInt32();
|
||||
Data.SampleRate = reader.ReadUInt32();
|
||||
Data.SamplesCount = reader.ReadUInt32();
|
||||
reader.ReadInt64();
|
||||
Data.Channels = reader.ReadUInt16();
|
||||
reader.ReadUInt16();
|
||||
Data.Name = reader.ReadString(0x20);
|
||||
|
||||
int* currentPtr = current.GetPtr();
|
||||
int* currentclampPtr = currentclamp.GetPtr();
|
||||
sbyte* stepindexPtr = stepindex.GetPtr();
|
||||
|
||||
for (i = 0; i < Data.SamplesCount; i++)
|
||||
for (c = 0; c < Data.Channels; c++)
|
||||
{
|
||||
value = reader.ReadHalfByte();
|
||||
IMADecoder(value, ref currentPtr[c], ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
f = (float)(currentPtr[c] / 32768.0);
|
||||
writer.Write(f);
|
||||
}
|
||||
|
||||
WAV.Header Header = new WAV.Header
|
||||
{ Bytes = 4, Channels = Data.Channels, Format = 3,
|
||||
SampleRate = Data.SampleRate, Size = Data.SamplesCount * Data.Channels * 4};
|
||||
writer.Write(Header, 0);
|
||||
if (ToArray) Data.Data = writer.ToArray();
|
||||
writer.Close();
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] BuildWavHeader(WAV.Header Header, short Bytes)
|
||||
{
|
||||
Stream writer = File.OpenWriter();
|
||||
writer.Write(Header);
|
||||
byte[] Data = writer.ToArray();
|
||||
if (!ToArray) writer = File.OpenWriter(file + ".wav", true);
|
||||
writer.LongPosition = 0x2C;
|
||||
|
||||
byte value = 0;
|
||||
int[] current = new int[Data.Channels];
|
||||
int[] currentclamp = new int[Data.Channels];
|
||||
sbyte[] stepindex = new sbyte[Data.Channels];
|
||||
float f;
|
||||
|
||||
int* currentPtr = current.GetPtr();
|
||||
int* currentclampPtr = currentclamp.GetPtr();
|
||||
sbyte* stepindexPtr = stepindex.GetPtr();
|
||||
|
||||
for (i = 0; i < Data.SamplesCount; i++)
|
||||
for (c = 0; c < Data.Channels; c++)
|
||||
{
|
||||
value = reader.ReadHalfByte();
|
||||
IMADecoder(value, ref currentPtr[c], ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
f = (float)(currentPtr[c] / 32768.0);
|
||||
writer.Write(f);
|
||||
}
|
||||
|
||||
WAV.Header Header = new WAV.Header { Bytes = 4, Channels = Data.Channels, Format = 3,
|
||||
SampleRate = Data.SampleRate, Size = Data.SamplesCount * Data.Channels * 4 };
|
||||
writer.Write(Header, 0);
|
||||
if (ToArray) Data.Data = writer.ToArray();
|
||||
writer.Close();
|
||||
return Data;
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
|
||||
public void DIVAWriter()
|
||||
public void DIVAWriter(string file)
|
||||
{
|
||||
if (File.Exists(file + ".wav"))
|
||||
{
|
||||
Stream reader = File.OpenReader(file + ".wav");
|
||||
Stream writer = File.OpenWriter(file + ".diva", true);
|
||||
|
||||
Data = new DIVAFile();
|
||||
WAV.Header Header = reader.ReadWAVHeader();
|
||||
if (Header.IsSupported)
|
||||
if (!File.Exists(file + ".wav")) return;
|
||||
|
||||
Stream reader = File.OpenReader(file + ".wav");
|
||||
|
||||
Data = new DIVAFile();
|
||||
WAV.Header Header = reader.ReadWAVHeader();
|
||||
if (!Header.IsSupported) { reader.Close(); return; }
|
||||
|
||||
Stream writer = File.OpenWriter(file + ".diva", true);
|
||||
Data.Channels = Header.Channels;
|
||||
Data.SampleRate = Header.SampleRate;
|
||||
writer.LongPosition = 0x40;
|
||||
|
||||
byte value = 0;
|
||||
int[] sample = new int[Data.Channels];
|
||||
int[] current = new int[Data.Channels];
|
||||
int[] currentclamp = new int[Data.Channels];
|
||||
sbyte[] stepindex = new sbyte[Data.Channels];
|
||||
|
||||
int* samplePtr = sample.GetPtr();
|
||||
int* currentPtr = current.GetPtr();
|
||||
int* currentclampPtr = currentclamp.GetPtr();
|
||||
sbyte* stepindexPtr = stepindex.GetPtr();
|
||||
Data.SamplesCount = Header.Size / Header.Channels / Header.Bytes;
|
||||
|
||||
for (i = 0; i < Data.SamplesCount; i++)
|
||||
for (c = 0; c < Header.Channels; c++)
|
||||
{
|
||||
Data.Channels = Header.Channels;
|
||||
Data.SampleRate = Header.SampleRate;
|
||||
writer.LongPosition = 0x40;
|
||||
|
||||
byte value = 0;
|
||||
int[] sample = new int[Data.Channels];
|
||||
int[] current = new int[Data.Channels];
|
||||
int[] currentclamp = new int[Data.Channels];
|
||||
sbyte[] stepindex = new sbyte[Data.Channels];
|
||||
|
||||
int* samplePtr = sample.GetPtr();
|
||||
int* currentPtr = current.GetPtr();
|
||||
int* currentclampPtr = currentclamp.GetPtr();
|
||||
sbyte* stepindexPtr = stepindex.GetPtr();
|
||||
Data.SamplesCount = Header.Size / Header.Channels / Header.Bytes;
|
||||
|
||||
for (i = 0; i < Data.SamplesCount; i++)
|
||||
for (c = 0; c < Header.Channels; c++)
|
||||
{
|
||||
samplePtr[c] = (reader.ReadWAVSample(Header.Bytes, Header.Format) * 0x8000).CFTI();
|
||||
value = IMAEncoder(samplePtr[c], ref currentPtr[c],
|
||||
ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
writer.Write(value, 4);
|
||||
}
|
||||
writer.CheckWrited();
|
||||
|
||||
writer.LongPosition = 0x00;
|
||||
writer.Write("DIVA");
|
||||
writer.Write(0x00);
|
||||
writer.Write((Data.SamplesCount * Data.Channels).Align(2, 2));
|
||||
writer.Write(Data.SampleRate);
|
||||
writer.Write(Data.SamplesCount);
|
||||
writer.Write(0x00);
|
||||
writer.Write(0x00);
|
||||
writer.Write(Data.Channels);
|
||||
samplePtr[c] = (reader.ReadWAVSample(Header.Bytes, Header.Format) * 0x8000).CFTI();
|
||||
value = IMAEncoder(samplePtr[c], ref currentPtr[c],
|
||||
ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
writer.Write(value, 4);
|
||||
}
|
||||
reader.Close();
|
||||
writer.Close();
|
||||
}
|
||||
writer.CheckWrited();
|
||||
|
||||
writer.LongPosition = 0x00;
|
||||
writer.Write("DIVA");
|
||||
writer.Write(0x00);
|
||||
writer.Write((Data.SamplesCount * Data.Channels).Align(2, 2));
|
||||
writer.Write(Data.SampleRate);
|
||||
writer.Write(Data.SamplesCount);
|
||||
writer.Write(0x00);
|
||||
writer.Write(0x00);
|
||||
writer.Write(Data.Channels);
|
||||
writer.Close();
|
||||
reader.Close();
|
||||
}
|
||||
|
||||
private void IMADecoder(byte value, ref int current, ref int currentclamp, ref sbyte stepindex)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using KKdMainLib.IO;
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
{
|
||||
@@ -15,10 +17,10 @@ namespace KKdSoundLib
|
||||
|
||||
public static void Write(this Stream IO, double Sample, ushort Bytes, ushort Format)
|
||||
{
|
||||
if (Bytes == 2) IO.Write ((ushort)(Sample * 0x00008000));
|
||||
else if (Bytes == 4 && Format == 0x01) IO.Write (( int)(Sample * 0x80000000));
|
||||
else if (Bytes == 4 && Format == 0x03) IO.Write ((float) Sample);
|
||||
else if (Bytes == 8 && Format == 0x03) IO.Write ( Sample);
|
||||
if (Bytes == 2) IO.Write((Sample * 0x00008000).CFTS());
|
||||
else if (Bytes == 4 && Format == 0x01) IO.Write((Sample * 0x80000000).CFTI());
|
||||
else if (Bytes == 4 && Format == 0x03) IO.Write((float)Sample);
|
||||
else if (Bytes == 8 && Format == 0x03) IO.Write( Sample);
|
||||
}
|
||||
|
||||
public static WAV.Header ReadWAVHeader(this Stream IO)
|
||||
@@ -46,7 +48,7 @@ namespace KKdSoundLib
|
||||
Header.Format = IO.ReadUInt16();
|
||||
}
|
||||
if (Header.Bytes < 1 || (Header.Bytes > 4 && Header.Bytes != 8)) return Header;
|
||||
if (Header.Bytes > 0 && Header.Bytes < 4 && Header.Format == 3) return Header;
|
||||
if (Header.Bytes > 0 && Header.Bytes < 4 && Header.Format == 3 ) return Header;
|
||||
if (Header.Bytes == 8 && Header.Format == 1) return Header;
|
||||
IO.Seek(Offset + 0x14, 0);
|
||||
if (IO.ReadString(4) != "data") return Header;
|
||||
|
||||
@@ -46,8 +46,6 @@
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdMainLib\KKdMainLib.csproj">
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("D8A3F2D7-10CC-5723-EC9A-45D3B9C2DFEA")]
|
||||
[assembly: AssemblyVersion("0.0.2.2")]
|
||||
[assembly: AssemblyFileVersion("0.0.2.2")]
|
||||
[assembly: AssemblyVersion("0.0.2.3")]
|
||||
[assembly: AssemblyFileVersion("0.0.2.3")]
|
||||
|
||||
+72
-44
@@ -12,19 +12,17 @@ namespace KKdSoundLib
|
||||
private const uint BS = 28; //VAGBlockSize
|
||||
private int[] Samp1, Samp2, Samp3, Samp4;
|
||||
private int* S1Ptr, S2Ptr, S3Ptr, S4Ptr;
|
||||
private bool Success = false;
|
||||
|
||||
public VAGFile VAGData = new VAGFile();
|
||||
public string file = "";
|
||||
|
||||
public VAG() { VAGData = new VAGFile(); file = "";
|
||||
public VAG() { VAGData = new VAGFile();
|
||||
HEVAG1Ptr = HEVAG1.GetPtr(); HEVAG2Ptr = HEVAG2.GetPtr();
|
||||
HEVAG3Ptr = HEVAG3.GetPtr(); HEVAG4Ptr = HEVAG4.GetPtr();
|
||||
}
|
||||
|
||||
public VAG(string filepath) { VAGData = new VAGFile(); file = filepath; }
|
||||
HEVAG3Ptr = HEVAG3.GetPtr(); HEVAG4Ptr = HEVAG4.GetPtr(); }
|
||||
|
||||
public void VAGReader()
|
||||
public void VAGReader(string file)
|
||||
{
|
||||
Success = false;
|
||||
if (!File.Exists(file + ".vag")) return;
|
||||
|
||||
VAGData = new VAGFile();
|
||||
@@ -146,6 +144,7 @@ namespace KKdSoundLib
|
||||
|
||||
VAGData.DataPtr = VAGData.OriginDataPtr;
|
||||
reader.Close();
|
||||
Success = true;
|
||||
}
|
||||
|
||||
private void DecodeHEVAG()
|
||||
@@ -175,33 +174,44 @@ namespace KKdSoundLib
|
||||
}
|
||||
}
|
||||
|
||||
public void WAVWriterStraight()
|
||||
public void WAVWriterStraight(string file, bool IgnoreEndFlags = false)
|
||||
{
|
||||
if (!Success) return;
|
||||
byte Flag = VAGData.Flags[0];
|
||||
if (Flag == 7) return;
|
||||
WAV.Header Header = new WAV.Header();
|
||||
Stream writer = File.OpenWriter(file + ".wav", true);
|
||||
writer.LongPosition = 0x2C;
|
||||
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
writer.Write(f);
|
||||
}
|
||||
|
||||
for (i1 = 0, i2 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
{
|
||||
Flag = VAGData.Flags[i1];
|
||||
if (Flag == 5 || Flag > 6) break;
|
||||
|
||||
if (Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
writer.Write(f);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.Write(0f);
|
||||
|
||||
if (Flag == 1) break;
|
||||
for (i1 = 0, i2 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
{
|
||||
Flag = VAGData.Flags[i1];
|
||||
if (!IgnoreEndFlags && Flag == 5 || Flag == 7) break;
|
||||
if (Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
writer.Write(f);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.Write(0f);
|
||||
|
||||
if (!IgnoreEndFlags && Flag == 1) break;
|
||||
}
|
||||
VAGData.DataPtr = VAGData.OriginDataPtr;
|
||||
|
||||
@@ -211,29 +221,36 @@ namespace KKdSoundLib
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
public void WAVWriter()
|
||||
public void WAVWriter(string file, bool IgnoreEndFlags = false)
|
||||
{
|
||||
if (!Success) return;
|
||||
byte Flag = VAGData.Flags[0];
|
||||
if (Flag == 7) return;
|
||||
WAV.Header Header = new WAV.Header();
|
||||
Stream writer;
|
||||
if (Flag == 6) writer = File.OpenWriter(file + ".loop.0.wav", true);
|
||||
else writer = File.OpenWriter(file + ".0.wav", true);
|
||||
if (!IgnoreEndFlags && Flag == 6) writer = File.OpenWriter(file + ".loop.0.wav", true);
|
||||
else writer = File.OpenWriter(file + ".0.wav", true);
|
||||
writer.LongPosition = 0x2C;
|
||||
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
writer.Write(f);
|
||||
}
|
||||
if (Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
writer.Write(f);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.Write(0f);
|
||||
|
||||
VAGData.DataPtr += VBS;
|
||||
|
||||
for (i1 = 1, i2 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
{
|
||||
Flag = VAGData.Flags[i1];
|
||||
if (Flag == 5 || Flag > 6) break;
|
||||
else if (Flag == 6)
|
||||
if (!IgnoreEndFlags && Flag == 5 || Flag == 7) break;
|
||||
else if (!IgnoreEndFlags && Flag == 6)
|
||||
{
|
||||
Header = new WAV.Header { Bytes = 4, Channels = ch, Format = 3, SampleRate =
|
||||
VAGData.SampleRate, Size = writer.UIntPosition - 0x2C };
|
||||
@@ -245,15 +262,20 @@ namespace KKdSoundLib
|
||||
writer.LongPosition = 0x2C;
|
||||
}
|
||||
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
writer.Write(f);
|
||||
}
|
||||
if (!IgnoreEndFlags && Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
writer.Write(f);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.Write(0f);
|
||||
|
||||
if (Flag == 1) break;
|
||||
else if (Flag == 3)
|
||||
if (!IgnoreEndFlags && Flag == 1) break;
|
||||
else if (!IgnoreEndFlags && Flag == 3)
|
||||
{
|
||||
Header = new WAV.Header { Bytes = 4, Channels = ch, Format = 3, SampleRate =
|
||||
VAGData.SampleRate, Size = writer.UIntPosition - 0x2C };
|
||||
@@ -276,8 +298,9 @@ namespace KKdSoundLib
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
public int WAVReaderStraight(bool ExtendedFlagging = false)
|
||||
public int WAVReaderStraight(string file, bool ExtendedFlagging = false)
|
||||
{
|
||||
Success = false;
|
||||
VAGData = new VAGFile();
|
||||
Stream reader = File.OpenReader(file + ".wav");
|
||||
WAV.Header Header = reader.ReadWAVHeader();
|
||||
@@ -318,16 +341,18 @@ namespace KKdSoundLib
|
||||
VAGData.Flags[VAGData.Size - 1] = 0x1;
|
||||
|
||||
reader.Close();
|
||||
Success = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int WAVReader(bool ExtendedFlagging = false)
|
||||
public int WAVReader(string file, bool ExtendedFlagging = false)
|
||||
{
|
||||
Success = false;
|
||||
string[] Files;
|
||||
bool HasLoop = false;
|
||||
bool[] Loop;
|
||||
{
|
||||
if (!file.EndsWith(".0")) return WAVReaderStraight();
|
||||
if (!file.EndsWith(".0")) return WAVReaderStraight(file);
|
||||
file = file.Remove(file.Length - 2);
|
||||
i2 = 0;
|
||||
System.Collections.Generic.List<string> files =
|
||||
@@ -430,11 +455,13 @@ namespace KKdSoundLib
|
||||
VAGData.Channels = ch;
|
||||
VAGData.SampleRate = SampleRate;
|
||||
|
||||
Success = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void VAGWriter(bool HEVAG = true)
|
||||
public void VAGWriter(string file, bool HEVAG = true)
|
||||
{
|
||||
if (!Success) return;
|
||||
VAGData.Name = Path.GetFileName(file);
|
||||
Stream writer = File.OpenWriter(file + ".vag", true);
|
||||
Samp1 = new int[ch]; S1Ptr = Samp1.GetPtr();
|
||||
@@ -465,6 +492,7 @@ namespace KKdSoundLib
|
||||
if (HEVAG) writer.Write(VAGData.Channels);
|
||||
else writer.Write((ushort)0x1);
|
||||
writer.Write(VAGData.Name);
|
||||
writer.LongLength = 0x30;
|
||||
writer.LongPosition = 0x30;
|
||||
|
||||
if (HEVAG)
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="classes\DataBase.cs" />
|
||||
<Compile Include="classes\Tools\A3D.cs" />
|
||||
<Compile Include="classes\Tools\AET.cs" />
|
||||
<Compile Include="classes\Tools\DB.cs" />
|
||||
<Compile Include="classes\Tools\DEX.cs" />
|
||||
<Compile Include="classes\Tools\DIV.cs" />
|
||||
@@ -52,8 +53,6 @@
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdMainLib\KKdMainLib.csproj">
|
||||
|
||||
+26
-15
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.Types;
|
||||
using KKdMain = KKdMainLib.Main;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
@@ -15,14 +16,13 @@ namespace PD_Tool
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.Title = "PD_Tool";
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
while (function != "Q") MainMenu();
|
||||
Exit();
|
||||
}
|
||||
|
||||
string header;
|
||||
long header;
|
||||
Stream reader;
|
||||
KKdFARC Farc;
|
||||
|
||||
@@ -34,16 +34,16 @@ namespace PD_Tool
|
||||
else if (File.Exists(arg))
|
||||
{
|
||||
reader = File.OpenReader(arg);
|
||||
header = reader.ReadString(8);
|
||||
header = reader.ReadInt64();
|
||||
reader.Close();
|
||||
if (header.ToUpper() == "DIVAFILE") DIVAFILE.Decrypt(arg);
|
||||
if (header == 0x454C494641564944) KKdMainLib.DIVAFILE.Decrypt(arg);
|
||||
}
|
||||
}
|
||||
Exit();
|
||||
}
|
||||
|
||||
private static bool JSON = false;
|
||||
|
||||
|
||||
private static void MainMenu()
|
||||
{
|
||||
Console.Title = "PD_Tool";
|
||||
@@ -58,6 +58,7 @@ namespace PD_Tool
|
||||
KKdMain.ConsoleDesign("4. Encrypt to DIVAFILE");
|
||||
KKdMain.ConsoleDesign("5. DB_Tools");
|
||||
KKdMain.ConsoleDesign("6. Converting Tools");
|
||||
KKdMain.ConsoleDesign(JSON ? "7. MsgPack to JSON" : "7. JSON to MsgPack");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign(JSON ? "M. MessagePack" : "J. JSON");
|
||||
KKdMain.ConsoleDesign("Q. Quit");
|
||||
@@ -90,11 +91,12 @@ namespace PD_Tool
|
||||
KKdMain.ConsoleDesign(" Choose tool:");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign("1. A3DA Converter");
|
||||
KKdMain.ConsoleDesign("2. DEX Converter");
|
||||
KKdMain.ConsoleDesign("3. DIVA Converter");
|
||||
KKdMain.ConsoleDesign("4. STR Converter");
|
||||
KKdMain.ConsoleDesign("5. VAG Converter");
|
||||
KKdMain.ConsoleDesign("6. DataBank Converter");
|
||||
KKdMain.ConsoleDesign("2. AET Converter");
|
||||
KKdMain.ConsoleDesign("3. DataBank Converter");
|
||||
KKdMain.ConsoleDesign("4. DEX Converter");
|
||||
KKdMain.ConsoleDesign("5. DIVA Converter");
|
||||
KKdMain.ConsoleDesign("6. STR Converter");
|
||||
KKdMain.ConsoleDesign("7. VAG Converter");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign("R. Return to Main Menu");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
@@ -103,13 +105,22 @@ namespace PD_Tool
|
||||
string Function = Console.ReadLine();
|
||||
Console.Clear();
|
||||
if (Function == "1") Tools.A3D.Processor(JSON);
|
||||
else if (Function == "2") Tools.DEX.Processor(JSON);
|
||||
else if (Function == "3") Tools.DIV.Processor();
|
||||
else if (Function == "4") Tools.STR.Processor(JSON);
|
||||
else if (Function == "5") Tools.VAG.Processor();
|
||||
else if (Function == "6") Tools.DB .Processor();
|
||||
else if (Function == "2") Tools.AET.Processor(JSON);
|
||||
else if (Function == "3") Tools.DB .Processor(JSON);
|
||||
else if (Function == "4") Tools.DEX.Processor(JSON);
|
||||
else if (Function == "5") Tools.DIV.Processor();
|
||||
else if (Function == "6") Tools.STR.Processor(JSON);
|
||||
else if (Function == "7") Tools.VAG.Processor();
|
||||
else function = Function;
|
||||
}
|
||||
else if (function == "7")
|
||||
{
|
||||
KKdMain.Choose(1, JSON ? "mp" : "json", out string[] FileNames);
|
||||
if (JSON) foreach (string file in FileNames)
|
||||
KKdMainLib.MessagePack.MPExt.ToJSON (file.Replace(Path.GetExtension(file), ""));
|
||||
else foreach (string file in FileNames)
|
||||
KKdMainLib.MessagePack.MPExt.ToMsgPack(file.Replace(Path.GetExtension(file), ""));
|
||||
}
|
||||
}
|
||||
|
||||
public static void Exit() => Environment.Exit(0);
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
|
||||
[assembly: AssemblyVersion("0.4.5.9")]
|
||||
[assembly: AssemblyFileVersion("0.4.5.9")]
|
||||
[assembly: AssemblyVersion("0.4.5.10")]
|
||||
[assembly: AssemblyFileVersion("0.4.5.10")]
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace PD_Tool
|
||||
Auth.MsgPackReader(filepath, ext == ".json");
|
||||
Auth.BINWriter (filepath);
|
||||
}
|
||||
Auth = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +84,7 @@ namespace PD_Tool
|
||||
Aet.MsgPackReader(filepath, ext == ".json");
|
||||
Aet.BINWriter (filepath);
|
||||
}
|
||||
Aet = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +114,7 @@ namespace PD_Tool
|
||||
Spr.MsgPackReader(filepath, ext == ".json");
|
||||
Spr.BINWriter (filepath);
|
||||
}
|
||||
Spr = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,34 +47,33 @@ namespace PD_Tool.Tools
|
||||
|
||||
KKdA3DA A;
|
||||
foreach (string file in FileNames)
|
||||
try
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
Console.Title = "A3DA Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
A = new KKdA3DA();
|
||||
if (ext == ".a3da")
|
||||
{
|
||||
A.A3DAReader (filepath);
|
||||
A.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
else if (ext == ".mp" )
|
||||
{
|
||||
A.MsgPackReader(filepath, JSON);
|
||||
A.IO = File.OpenWriter(filepath + ".a3da", true);
|
||||
if (A.Data.Header.Format < Main.Format.F2LE)
|
||||
A.Data._.CompressF16 = Format == Main.Format.MGF ? 2 : 1;
|
||||
A.Data.Header.Format = Format;
|
||||
{
|
||||
A = new KKdA3DA();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
if (A.Data.Header.Format > Main.Format.DT && A.Data.Header.Format != Main.Format.FT)
|
||||
A.A3DCWriter(filepath);
|
||||
else
|
||||
A.A3DAWriter();
|
||||
}
|
||||
Console.Title = "A3DA Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".a3da")
|
||||
{
|
||||
A.A3DAReader (filepath);
|
||||
A.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
catch (Exception e)
|
||||
{ Console.WriteLine(e); }
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
A.MsgPackReader(filepath, ext == ".json");
|
||||
A.IO = File.OpenWriter(filepath + ".a3da", true);
|
||||
if (A.Data.Header.Format < Main.Format.F2LE)
|
||||
A.Data._.CompressF16 = Format == Main.Format.MGF ? 2 : 1;
|
||||
A.Data.Header.Format = Format;
|
||||
|
||||
if (A.Data.Header.Format > Main.Format.DT && A.Data.Header.Format != Main.Format.FT)
|
||||
A.A3DCWriter(filepath);
|
||||
else
|
||||
A.A3DAWriter();
|
||||
}
|
||||
A = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdAet = KKdMainLib.Aet.Aet;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
public class AET
|
||||
{
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "AET Converter";
|
||||
KKdAet Aet;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
Aet = new KKdAet();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "AET Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
{
|
||||
Aet. AETReader(filepath);
|
||||
Aet.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
Aet.MsgPackReader(filepath, ext == ".json");
|
||||
Aet. AETWriter(filepath);
|
||||
}
|
||||
Aet = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
-30
@@ -6,45 +6,59 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
public class DB
|
||||
{
|
||||
public static void Processor()
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "DataBank Converter";
|
||||
Main.Choose(1, "databank", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
Console.Clear();
|
||||
string format = "";
|
||||
Main.ConsoleDesign(true);
|
||||
Main.ConsoleDesign(" Choose type of exporting file:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. Compact");
|
||||
Main.ConsoleDesign("2. Normal");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
format = Console.ReadLine();
|
||||
|
||||
DataBank DB;
|
||||
string[] file_split;
|
||||
int File_Checksum = 0, Get_Checksum;
|
||||
foreach (string file in FileNames)
|
||||
//try
|
||||
{
|
||||
string filename = Path.GetFileNameWithoutExtension(file);
|
||||
file_split = filename.Split('_');
|
||||
DB = new DataBank();
|
||||
if (file_split.Length == 5 && file.EndsWith(".dat"))
|
||||
{
|
||||
if (int.TryParse(file_split[3], out File_Checksum))
|
||||
{
|
||||
Get_Checksum = DCC.CalculateChecksum(file);
|
||||
if (File_Checksum == Get_Checksum)
|
||||
{
|
||||
string filepath = file.Replace(filename + ".dat", "");
|
||||
Console.Title = "DataBank Converter: " + filename;
|
||||
DB.DBReader(file);
|
||||
DB.XMLWriter(filepath + file_split[0] + "_" +
|
||||
file_split[1] + "_" + file_split[2] + ".xml");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (file.EndsWith(".xml"))
|
||||
{
|
||||
string filepath = file.Replace(Path.GetExtension(file), "");
|
||||
Console.Title = "DataBank Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
DB.XMLReader(file);
|
||||
DB.DBWriter(filepath);
|
||||
}
|
||||
}
|
||||
//catch (Exception e) { Console.WriteLine(e.Message); }
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
string filename = Path.GetFileNameWithoutExtension(file);
|
||||
file_split = filename.Split('_');
|
||||
DB = new DataBank();
|
||||
if (file_split.Length == 5 && ext == ".dat")
|
||||
{
|
||||
if (!int.TryParse(file_split[3], out File_Checksum)) continue;
|
||||
|
||||
Get_Checksum = DCC.CalculateChecksum(file);
|
||||
if (File_Checksum != Get_Checksum) continue;
|
||||
|
||||
filepath = file.Replace(filename + ".dat", "");
|
||||
Console.Title = "DataBank Converter: " + filename;
|
||||
DB. DBReader(file);
|
||||
DB.MsgPackWriter(filepath + file_split[0] + "_" +
|
||||
file_split[1] + "_" + file_split[2], JSON, format != "2");
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
Console.Title = "DataBank Converter: " + filename;
|
||||
DB.MsgPackReader(filepath, JSON);
|
||||
DB. DBWriter(filepath);
|
||||
}
|
||||
DB = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,13 @@ namespace PD_Tool.Tools
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
bool MP = true;
|
||||
bool MP = true;
|
||||
bool _JSON = true;
|
||||
foreach (string file in FileNames)
|
||||
if (file.EndsWith(".mp" ))
|
||||
{ MP = false; break; }
|
||||
{ MP = false; break; }
|
||||
else if (file.EndsWith(".json"))
|
||||
{ _JSON = false; break; }
|
||||
|
||||
Console.Clear();
|
||||
string format = "";
|
||||
@@ -29,7 +32,8 @@ namespace PD_Tool.Tools
|
||||
Main.ConsoleDesign("1. F/FT PS3/PS4/PSVita");
|
||||
Main.ConsoleDesign("2. F2nd PS3/PSVita");
|
||||
Main.ConsoleDesign("3. X PS4/PSVita");
|
||||
if (MP) Main.ConsoleDesign("9. MessagePack");
|
||||
if ( MP && !JSON) Main.ConsoleDesign("9. MessagePack");
|
||||
if (_JSON && JSON) Main.ConsoleDesign("9. JSON");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
@@ -39,22 +43,25 @@ namespace PD_Tool.Tools
|
||||
if (format == "1") Format = Main.Format.F ;
|
||||
else if (format == "2") Format = Main.Format.F2LE;
|
||||
else if (format == "3") Format = Main.Format.X ;
|
||||
else if (format == "9" && MP ) Format = Main.Format.NULL;
|
||||
else if (format == "9" && (MP && _JSON)) Format = Main.Format.NULL;
|
||||
else return;
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
DEX = new KKdDEX();
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "DEX Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin" || ext == ".dex")
|
||||
DEX.DEXReader(filepath, ext);
|
||||
DEX. DEXReader(filepath, ext );
|
||||
else DEX.MsgPackReader(filepath, JSON);
|
||||
|
||||
if (Format > Main.Format.NULL)
|
||||
DEX.DEXWriter(filepath, Format);
|
||||
else DEX.MsgPackWriter(filepath, JSON);
|
||||
DEX. DEXWriter(filepath, Format);
|
||||
else DEX.MsgPackWriter(filepath, JSON );
|
||||
DEX = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,28 +11,23 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
Console.Title = "DIVA Converter";
|
||||
Main.Choose(1, "diva", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
DIVA DIVA;
|
||||
foreach (string file in FileNames)
|
||||
try
|
||||
{
|
||||
string filepath = file.Replace(Path.GetExtension(file), "");
|
||||
string ext = Path.GetExtension(file);
|
||||
Console.Title = "DIVA Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
DIVA = new DIVA(filepath);
|
||||
switch (ext.ToLower())
|
||||
{
|
||||
case ".diva":
|
||||
DIVA.DIVAReader();
|
||||
break;
|
||||
case ".wav":
|
||||
DIVA.DIVAWriter();
|
||||
break;
|
||||
}
|
||||
GC.Collect();
|
||||
}
|
||||
catch (Exception e) { Console.WriteLine(e.Message); }
|
||||
{
|
||||
DIVA = new DIVA();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "DIVA Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".diva") DIVA.DIVAReader(filepath);
|
||||
else if (ext == ".wav" ) DIVA.DIVAWriter(filepath);
|
||||
DIVA = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,9 @@ namespace PD_Tool.Tools
|
||||
string ext = "";
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
Data = new KKdSTR();
|
||||
|
||||
Console.Title = "PD_Tool: Converter Tools: STR Reader: " +
|
||||
@@ -33,6 +34,7 @@ namespace PD_Tool.Tools
|
||||
Data.MsgPackReader(filepath, JSON);
|
||||
Data.STRWriter (filepath);
|
||||
}
|
||||
Data = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
Console.Title = "VAG Converter";
|
||||
Main.Choose(1, "vag", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
bool InputWAV = false;
|
||||
foreach (string file in FileNames)
|
||||
if (Path.GetExtension(file) == ".wav")
|
||||
@@ -29,31 +33,22 @@ namespace PD_Tool.Tools
|
||||
Main.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string format = Console.ReadLine();
|
||||
HE_VAG = format != "2";
|
||||
HE_VAG = format == "2";
|
||||
}
|
||||
|
||||
KKdVAG VAG;
|
||||
foreach (string file in FileNames)
|
||||
try
|
||||
{
|
||||
string ext = Path.GetExtension(file);
|
||||
string filepath = file.Remove(file.Length - ext.Length);
|
||||
Console.Title = "VAG Converter: " +
|
||||
Path.GetFileNameWithoutExtension(file);
|
||||
VAG = new KKdVAG() { file = filepath };
|
||||
switch (ext.ToLower())
|
||||
{
|
||||
case ".vag":
|
||||
VAG.VAGReader();
|
||||
VAG.WAVWriter();
|
||||
break;
|
||||
case ".wav":
|
||||
VAG.WAVReader();
|
||||
VAG.VAGWriter(HE_VAG);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e) { Console.WriteLine(e.Message); }
|
||||
{
|
||||
VAG = new KKdVAG();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "VAG Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".vag") { VAG.VAGReader(filepath); VAG.WAVWriter(filepath ); }
|
||||
else if (ext == ".wav") { VAG.WAVReader(filepath); VAG.VAGWriter(filepath, HE_VAG); }
|
||||
VAG = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user