Release v0.4.5.9
Some fixes and changes
This commit is contained in:
+5
-14
@@ -22,7 +22,6 @@ namespace KKdMainLib.A3DA
|
||||
private string nameView;
|
||||
private string value;
|
||||
private string[] dataArray;
|
||||
private MsgPack MsgPack;
|
||||
private Values UsedValues;
|
||||
private Dictionary<string, object> Dict;
|
||||
|
||||
@@ -1313,16 +1312,13 @@ namespace KKdMainLib.A3DA
|
||||
}
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file)
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
int i = 0;
|
||||
int i0 = 0;
|
||||
int i1 = 0;
|
||||
|
||||
MPIO IO = new MPIO(File.OpenReader(file + ".mp"));
|
||||
MsgPack = IO.Read();
|
||||
IO.Close();
|
||||
IO = null;
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
if (MsgPack.Element("A3D", out MsgPack A3D))
|
||||
{
|
||||
@@ -1751,7 +1747,7 @@ namespace KKdMainLib.A3DA
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file)
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
int i = 0;
|
||||
int i0 = 0;
|
||||
@@ -2036,13 +2032,8 @@ namespace KKdMainLib.A3DA
|
||||
.Add(Data.PostProcess.LensGhost.WriteMP("LensGhost"))
|
||||
.Add(Data.PostProcess.LensShaft.WriteMP("LensShaft"))
|
||||
.Add(Data.PostProcess.Specular .WriteMP("Specular" )));
|
||||
|
||||
MsgPack = new MsgPack(MsgPack.Types.FixMap).Add(A3D);
|
||||
|
||||
MPIO IO = new MPIO(File.OpenWriter(file + ".mp", true));
|
||||
IO.Write(MsgPack, true);
|
||||
IO = null;
|
||||
MsgPack = null;
|
||||
|
||||
A3D.Write(true, file, JSON);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//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,272 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
public class Aet
|
||||
{
|
||||
public AetSet[] AetSets;
|
||||
|
||||
private Stream IO;
|
||||
private int i, i0, i1, i2;
|
||||
|
||||
public void BINReader(string file)
|
||||
{
|
||||
IO = File.OpenReader(file + ".bin");
|
||||
|
||||
int aetSetsLength = IO.ReadInt32();
|
||||
int aetSetsOffset = IO.ReadInt32();
|
||||
int aetsLength = IO.ReadInt32();
|
||||
int aetsOffset = IO.ReadInt32();
|
||||
|
||||
IO.Position = aetSetsOffset;
|
||||
AetSets = new AetSet[aetSetsLength];
|
||||
for (i = 0; i < aetSetsLength; i++)
|
||||
{
|
||||
AetSets[i].Id = IO.ReadInt32();
|
||||
AetSets[i].Name = IO.ReadStringAtOffset();
|
||||
AetSets[i].FileName = IO.ReadStringAtOffset();
|
||||
IO.ReadInt32();
|
||||
AetSets[i].SpriteSetId = IO.ReadInt32();
|
||||
}
|
||||
|
||||
int setIndex;
|
||||
AET aet = new AET();
|
||||
int[] AetCount = new int[aetSetsLength];
|
||||
|
||||
IO.Position = aetsOffset;
|
||||
for (i = 0; i < aetsLength; i++)
|
||||
{
|
||||
IO.LongPosition += 10;
|
||||
setIndex = IO.ReadInt16();
|
||||
AetCount[setIndex]++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < aetSetsLength; i++)
|
||||
{
|
||||
AetSets[i].Aets = new AET[AetCount[i]];
|
||||
AetCount[i] = 0;
|
||||
}
|
||||
|
||||
IO.Position = aetsOffset;
|
||||
for (i = 0; i < aetsLength; i++)
|
||||
{
|
||||
aet.Id = IO.ReadInt32();
|
||||
aet.Name = IO.ReadStringAtOffset();
|
||||
IO.ReadInt16();
|
||||
setIndex = IO.ReadInt16();
|
||||
|
||||
AetSets[setIndex].Aets[AetCount[setIndex]] = aet; AetCount[setIndex]++;
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
|
||||
public void BINWriter(string file)
|
||||
{
|
||||
if (AetSets == null) return;
|
||||
if (AetSets.Length == 0) return;
|
||||
|
||||
List<string> SetName = new List<string>();
|
||||
List<string> SetFileName = new List<string>();
|
||||
|
||||
List<int> Ids = new List<int>();
|
||||
List<int> SetIds = new List<int>();
|
||||
|
||||
List<int> NotAdd = new List<int>();
|
||||
AET temp;
|
||||
AetSet set;
|
||||
|
||||
for (i = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
set = AetSets[i];
|
||||
if (set. Name != null)
|
||||
if (SetName .Contains(set. Name)) { NotAdd.Add(i); continue; }
|
||||
else SetName .Add (set. Name);
|
||||
if (set.FileName != null)
|
||||
if (SetFileName.Contains(set.FileName)) { NotAdd.Add(i); continue; }
|
||||
else SetFileName.Add (set.FileName);
|
||||
|
||||
if (set.NewId)
|
||||
{
|
||||
AetSets[i].Id = null;
|
||||
for (i0 = 0; i0 < set.Aets.Length; i0++) AetSets[i].Aets[i0].Id = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (set.Id != null)
|
||||
if (SetIds.Contains((int)set.Id)) { NotAdd.Add(i); continue; }
|
||||
else SetIds.Add ((int)set.Id);
|
||||
|
||||
for (i0 = 0; i0 < set.Aets.Length; i0++)
|
||||
{
|
||||
temp = set.Aets[i0];
|
||||
if (temp.Id != null)
|
||||
if ( Ids.Contains((int)temp.Id)) { NotAdd.Add(i); break; }
|
||||
else Ids.Add ((int)temp.Id);
|
||||
}
|
||||
}
|
||||
SetName = null;
|
||||
SetFileName = null;
|
||||
|
||||
for (i = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
set = AetSets[i];
|
||||
if (NotAdd.Contains(i)) continue;
|
||||
if (!set.NewId) continue;
|
||||
|
||||
i1 = 0;
|
||||
if (set.Id == null) while (true)
|
||||
{ if (!SetIds.Contains(i1)) { AetSets[i].Id = i1; SetIds.Add(i1); break; } i1++; }
|
||||
|
||||
for (i0 = 0, i1 = 0; i0 < set.Aets.Length; i0++)
|
||||
if (set.Aets[i0].Id == null) while (true) { if (!Ids.Contains(i1))
|
||||
{ AetSets[i].Aets[i0].Id = i1; Ids.Add(i1); break; } i1++; }
|
||||
}
|
||||
|
||||
Ids = null;
|
||||
SetIds = null;
|
||||
|
||||
for (i = 0, i0 = 0, i2 = 0; i < AetSets.Length; i++)
|
||||
if (!NotAdd.Contains(i)) { i0 += AetSets[i].Aets.Length; i2++; }
|
||||
|
||||
i1 = i0 * 12;
|
||||
i1 = i1.Align(0x20) + 0x20;
|
||||
|
||||
IO = File.OpenWriter(file + ".bin", true);
|
||||
IO.Write(i2);
|
||||
IO.Write(i1);
|
||||
IO.Write(i0);
|
||||
IO.Write(0x20);
|
||||
IO.Write(0x9066906690669066);
|
||||
IO.Write(0x9066906690669066);
|
||||
|
||||
IO.Position = (i1 + i2 * 0x14).Align(0x20);
|
||||
for (i = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) continue;
|
||||
AetSets[i]. NameOffset = IO.Position; IO.Write(AetSets[i]. Name + "\0");
|
||||
AetSets[i].FileNameOffset = IO.Position; IO.Write(AetSets[i].FileName + "\0");
|
||||
}
|
||||
|
||||
for (i = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) continue;
|
||||
for (i0 = 0; i0 < AetSets[i].Aets.Length; i0++)
|
||||
{ AetSets[i].Aets[i0].NameOffset = IO.Position; IO.Write(AetSets[i].Aets[i0].Name + "\0"); }
|
||||
}
|
||||
IO.Align(0x08, true);
|
||||
|
||||
IO.Position = 0x20;
|
||||
for (i = 0, i2 = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
for (i0 = 0; i0 < AetSets[i].Aets.Length; i0++)
|
||||
{
|
||||
IO.Write(AetSets[i].Aets[i0].Id );
|
||||
IO.Write(AetSets[i].Aets[i0].NameOffset);
|
||||
IO.Write((ushort) i0 );
|
||||
IO.Write((ushort)(i - i2));
|
||||
}
|
||||
}
|
||||
IO.Align(0x20);
|
||||
for (i = 0, i2 = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
IO.Write(AetSets[i].Id );
|
||||
IO.Write(AetSets[i]. NameOffset);
|
||||
IO.Write(AetSets[i].FileNameOffset);
|
||||
IO.Write(i - i2);
|
||||
IO.Write(AetSets[i].SpriteSetId );
|
||||
}
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
if (MsgPack.Element("AetDB", out MsgPack AetDB, typeof(object[])))
|
||||
{
|
||||
AetSets = new AetSet[((object[])AetDB.Object).Length];
|
||||
for (int i = 0; i < AetSets.Length; i++)
|
||||
if (AetDB[i].GetType() == typeof(MsgPack))
|
||||
AetSets[i].ReadMsgPack((MsgPack)AetDB[i]);
|
||||
}
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
if (AetSets == null) return;
|
||||
if (AetSets.Length == 0) return;
|
||||
|
||||
MsgPack AetDB = new MsgPack("AetDB", AetSets.Length);
|
||||
for (i = 0; i < AetSets.Length; i++)
|
||||
AetDB[i] = AetSets[i].WriteMsgPack();
|
||||
|
||||
AetDB.Write(true, file, JSON);
|
||||
}
|
||||
|
||||
public struct AET
|
||||
{
|
||||
public int NameOffset;
|
||||
public int? Id;
|
||||
public string Name;
|
||||
|
||||
public void ReadMsgPack(MsgPack msg)
|
||||
{ Id = msg.ReadNUInt16("Id"); Name = msg.ReadString("Name"); }
|
||||
|
||||
public MsgPack WriteMsgPack() =>
|
||||
new MsgPack().Add("Id", Id).Add("Name", Name);
|
||||
}
|
||||
|
||||
public struct AetSet
|
||||
{
|
||||
public int NameOffset;
|
||||
public int FileNameOffset;
|
||||
public int? Id;
|
||||
public int? SpriteSetId;
|
||||
public bool NewId;
|
||||
public string Name;
|
||||
public string FileName;
|
||||
public AET[] Aets;
|
||||
|
||||
public void ReadMsgPack(MsgPack msg)
|
||||
{
|
||||
FileName = msg.ReadString ("FileName" );
|
||||
Id = msg.ReadNUInt16( "Id");
|
||||
Name = msg.ReadString ( "Name" );
|
||||
NewId = msg.ReadBoolean("NewId" );
|
||||
SpriteSetId = msg.ReadNUInt16("SpriteSetId");
|
||||
|
||||
if (msg.Element("Aets", out MsgPack Aets, typeof(object[])))
|
||||
{
|
||||
object Aet;
|
||||
this .Aets = new AET[((object[])Aets.Object).Length];
|
||||
for (int i0 = 0; i0 < this.Aets.Length; i0++)
|
||||
{ Aet = Aets[i0]; if (Aet.GetType() == typeof(MsgPack))
|
||||
this.Aets[i0].ReadMsgPack((MsgPack)Aet); }
|
||||
}
|
||||
}
|
||||
|
||||
public MsgPack WriteMsgPack()
|
||||
{
|
||||
MsgPack Aets = new MsgPack("Aets", this.Aets.Length);
|
||||
for (int i0 = 0; i0 < this.Aets.Length; i0++)
|
||||
Aets[i0] = this.Aets[i0].WriteMsgPack();
|
||||
|
||||
return new MsgPack().Add("FileName", FileName).Add("Id", Id)
|
||||
.Add("Name", Name).Add("SpriteSetId", SpriteSetId).Add(Aets);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-22
@@ -14,7 +14,7 @@ namespace KKdMainLib.DB
|
||||
public UID[] _UID { get; private set; }
|
||||
public Stream IO { get; private set; }
|
||||
|
||||
public int BINReader(string file)
|
||||
public void BINReader(string file)
|
||||
{
|
||||
Dictionary<string, object> Dict = new Dictionary<string, object>();
|
||||
string[] dataArray;
|
||||
@@ -23,9 +23,9 @@ namespace KKdMainLib.DB
|
||||
|
||||
IO.Format = Main.Format.F;
|
||||
Signature = IO.ReadInt32();
|
||||
if (Signature != 0x44334123) return 0;
|
||||
if (Signature != 0x44334123) return;
|
||||
Signature = IO.ReadInt32();
|
||||
if (Signature != 0x5F5F5F41) return 0;
|
||||
if (Signature != 0x5F5F5F41) return;
|
||||
IO.ReadInt64();
|
||||
|
||||
string[] STRData = IO.ReadString(IO.Length - IO.Position).Replace("\r", "").Split('\n');
|
||||
@@ -50,13 +50,13 @@ namespace KKdMainLib.DB
|
||||
for (int i0 = 0; i0 < _UID.Length; i0++)
|
||||
{
|
||||
Dict.FindValue(out _UID[i0].Category, "uid." + i0 + ".category");
|
||||
Dict.FindValue(out _UID[i0].OrgUid , "uid." + i0 + ".org_uid" );
|
||||
Dict.FindValue(out _UID[i0].Size , "uid." + i0 + ".size" );
|
||||
Dict.FindValue(out _UID[i0].Value , "uid." + i0 + ".value" );
|
||||
}
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void BINWriter(string file)
|
||||
@@ -84,6 +84,8 @@ namespace KKdMainLib.DB
|
||||
if (_UID[SO[i]].Category != null)
|
||||
if (_UID[SO[i]].Category != "")
|
||||
IO.Write("uid." + SO[i] + ".category=", _UID[SO[i]].Category);
|
||||
if (_UID[SO[i]].OrgUid != null)
|
||||
IO.Write("uid." + SO[i] + ".org_uid=" , _UID[SO[i]].OrgUid );
|
||||
if (_UID[SO[i]].Size != null)
|
||||
IO.Write("uid." + SO[i] + ".size=" , _UID[SO[i]].Size );
|
||||
if (_UID[SO[i]].Value != null)
|
||||
@@ -96,36 +98,31 @@ namespace KKdMainLib.DB
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file)
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
MPIO IO = new MPIO(File.OpenReader(file + ".mp"));
|
||||
MsgPack MsgPack = IO.Read();
|
||||
IO.Close();
|
||||
IO = null;
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
if (MsgPack.Element("AuthDB", out MsgPack AuthDB))
|
||||
{
|
||||
if (AuthDB.Element("Category", out MsgPack Temp, typeof(object[])))
|
||||
{
|
||||
this.Category = new string[((object[])Temp.Object).Length];
|
||||
MsgPack Category = new MsgPack();
|
||||
MsgPack Category;
|
||||
for (int i = 0; i < this.Category.Length; i++)
|
||||
if (Temp[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
Category = (MsgPack)Temp[i];
|
||||
this.Category[i] = Category.ReadString();
|
||||
}
|
||||
{ Category = (MsgPack)Temp[i]; this.Category[i] = Category.ReadString(); }
|
||||
}
|
||||
|
||||
if (AuthDB.Element("UID", out Temp, typeof(object[])))
|
||||
{
|
||||
_UID = new UID[((object[])Temp.Object).Length];
|
||||
MsgPack UID = new MsgPack();
|
||||
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");
|
||||
}
|
||||
@@ -134,7 +131,7 @@ namespace KKdMainLib.DB
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file)
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
MsgPack AuthDB = new MsgPack("AuthDB");
|
||||
if (Category != null)
|
||||
@@ -151,22 +148,19 @@ namespace KKdMainLib.DB
|
||||
for (int i = 0; i < _UID.Length; i++)
|
||||
UID[i] = new MsgPack()
|
||||
.Add("C", _UID[i].Category)
|
||||
.Add("O", _UID[i].OrgUid )
|
||||
.Add("S", _UID[i].Size )
|
||||
.Add("V", _UID[i].Value );
|
||||
AuthDB.Add(UID);
|
||||
}
|
||||
|
||||
MsgPack MsgPack = new MsgPack(MsgPack.Types.FixMap).Add(AuthDB);
|
||||
|
||||
MPIO IO = new MPIO(File.OpenWriter(file + ".mp", true));
|
||||
IO.Write(MsgPack, true);
|
||||
IO = null;
|
||||
MsgPack = null;
|
||||
AuthDB.Write(true, file, JSON);
|
||||
}
|
||||
|
||||
public struct UID
|
||||
{
|
||||
public int? Size;
|
||||
public int? OrgUid;
|
||||
public string Value;
|
||||
public string Category;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
// Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.Types;
|
||||
using KKdMainLib.MessagePack;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
public class BoneData
|
||||
{
|
||||
public Stream IO;
|
||||
public BONE Data;
|
||||
|
||||
private int i, i0;
|
||||
|
||||
public BoneData()
|
||||
{ Data = new BONE(); }
|
||||
|
||||
public void BONReader(string file, string ext)
|
||||
{
|
||||
Data = new BONE { Header = new PDHead() };
|
||||
IO = File.OpenReader(file + ext);
|
||||
|
||||
IO.Format = Main.Format.F;
|
||||
Data.Header.Signature = IO.ReadInt32();
|
||||
if (Data.Header.Signature == 0x454E4F42)
|
||||
{
|
||||
Data.Header = IO.ReadHeader(true);
|
||||
Data.POF = Data.Header.AddPOF();
|
||||
}
|
||||
if (Data.Header.Signature != 0x09102720)
|
||||
return;
|
||||
|
||||
Data.Skeleton = new SkeletonEntry[IO.ReadInt32Endian()];
|
||||
Data.SkeletonsOffset = IO.ReadUInt32Endian(ref Data.POF);
|
||||
Data.SkeletonNamesOffset = IO.ReadUInt32Endian();
|
||||
if (Data.SkeletonNamesOffset == 0)
|
||||
{
|
||||
IO.IsX = true;
|
||||
IO.Format = Main.Format.X;
|
||||
Data.POF.POFOffsets = new List<long>();
|
||||
IO.Seek(Data.Header.Lenght, 0);
|
||||
IO.LongOffset = Data.Header.Lenght;
|
||||
Data.Header.Signature = IO.ReadInt32();
|
||||
Data.Skeleton = new SkeletonEntry[IO.ReadInt32Endian()];
|
||||
Data.SkeletonsOffset = IO.ReadInt64();
|
||||
Data.SkeletonNamesOffset = IO.ReadInt64(ref Data.POF);
|
||||
}
|
||||
else
|
||||
{
|
||||
IO.LongPosition -= 4;
|
||||
IO.GetOffset(ref Data.POF);
|
||||
IO.LongPosition += 4;
|
||||
}
|
||||
|
||||
Data.SkeletonEntryOffset = new long[Data.Skeleton.Length];
|
||||
IO.LongPosition = Data.SkeletonsOffset;
|
||||
for (i0 = 0; i0 < Data.Skeleton.Length; i0++)
|
||||
Data.SkeletonEntryOffset[i0] = IO.ReadIntX(ref Data.POF);
|
||||
|
||||
for (i0 = 0; i0 < Data.Skeleton.Length; i0++)
|
||||
{
|
||||
Data.Skeleton[i0] = new SkeletonEntry();
|
||||
IO.LongPosition = Data.SkeletonEntryOffset[i0];
|
||||
|
||||
Data.Skeleton[i0].BoneOffset = IO.ReadIntX(ref Data.POF);
|
||||
Data.Skeleton[i0].Position = new Vector3<float>[IO.ReadIntX()];
|
||||
Data.Skeleton[i0].PositionOffset = IO.ReadIntX(ref Data.POF);
|
||||
Data.Skeleton[i0].Field02Offset = IO.ReadIntX(ref Data.POF);
|
||||
Data.Skeleton[i0].BoneName1 = new string[IO.ReadIntX()];
|
||||
Data.Skeleton[i0].BoneName1Offset = IO.ReadIntX(ref Data.POF);
|
||||
Data.Skeleton[i0].BoneName2 = new string[IO.ReadIntX()];
|
||||
Data.Skeleton[i0].BoneName2Offset = IO.ReadIntX(ref Data.POF);
|
||||
Data.Skeleton[i0].ParentIndiceOffset = IO.ReadIntX(ref Data.POF);
|
||||
|
||||
IO.LongPosition = Data.SkeletonNamesOffset + i0 << (IO.IsX ? 3 : 2);
|
||||
|
||||
Data.Skeleton[i0].Name = IO.ReadStringAtOffset(ref Data.POF);
|
||||
IO.LongPosition = Data.Skeleton[i0].BoneOffset;
|
||||
|
||||
long Count = 0;
|
||||
string Name = "";
|
||||
while (true)
|
||||
{
|
||||
IO.ReadUInt64();
|
||||
Name = IO.ReadStringAtOffset(ref Data.POF);
|
||||
if (Name == "End") break;
|
||||
Count++;
|
||||
}
|
||||
|
||||
Data.Skeleton[i0].Bone = new BoneEntry[Count];
|
||||
for (i = 0; i < Count; i++)
|
||||
{
|
||||
Data.Skeleton[i0].Bone[i].Type = (BoneType)IO.ReadByte ();
|
||||
Data.Skeleton[i0].Bone[i].HasParent = IO.ReadBoolean();
|
||||
Data.Skeleton[i0].Bone[i].ParentNameIndex = IO.ReadByte ();
|
||||
Data.Skeleton[i0].Bone[i].Field01 = IO.ReadByte ();
|
||||
Data.Skeleton[i0].Bone[i].PairNameIndex = IO.ReadByte ();
|
||||
Data.Skeleton[i0].Bone[i].Field02 = IO.ReadByte ();
|
||||
IO.ReadInt16Endian();
|
||||
Data.Skeleton[i0].Bone[i].Name = IO.ReadStringAtOffset(ref Data.POF);
|
||||
}
|
||||
|
||||
IO.LongPosition = Data.Skeleton[i0].PositionOffset;
|
||||
for (i = 0; i < Data.Skeleton[i0].Position.Length; i++)
|
||||
Data.Skeleton[i0].Position[i] = new Vector3<float>(IO.ReadSingleEndian(),
|
||||
IO.ReadSingleEndian(), IO.ReadSingleEndian());
|
||||
|
||||
IO.LongPosition = Data.Skeleton[i0].Field02Offset;
|
||||
Data.Skeleton[i0].Field02 = IO.ReadIntX();
|
||||
|
||||
IO.LongPosition = Data.Skeleton[i0].BoneName1Offset;
|
||||
for (i = 0; i < Data.Skeleton[i0].BoneName1.Length; i++)
|
||||
Data.Skeleton[i0].BoneName1[i] = IO.ReadStringAtOffset(ref Data.POF);
|
||||
|
||||
IO.LongPosition = Data.Skeleton[i0].BoneName2Offset;
|
||||
for (i = 0; i < Data.Skeleton[i0].BoneName2.Length; i++)
|
||||
Data.Skeleton[i0].BoneName2[i] = IO.ReadStringAtOffset(ref Data.POF);
|
||||
|
||||
IO.LongPosition = Data.Skeleton[i0].ParentIndiceOffset;
|
||||
for (i = 0; i < Data.Skeleton[i0].BoneName2.Length; i++)
|
||||
Data.Skeleton[i0].ParentIndice[i] = IO.ReadInt16Endian();
|
||||
}
|
||||
if (IO.Format > Main.Format.F)
|
||||
{
|
||||
IO.LongPosition = Data.POF.Offset;
|
||||
IO.ReadPOF(ref Data.POF);
|
||||
}
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void BONWriter(string file, Main.Format Format)
|
||||
{
|
||||
IO = File.OpenWriter(file + ".bon", true);
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
MsgPack BoneDB = new MsgPack("BoneDB", Data.Skeleton.Length);
|
||||
for (i0 = 0; i0 < Data.Skeleton.Length; i0++)
|
||||
{
|
||||
MsgPack Skeleton = new MsgPack().Add("Name" , Data.Skeleton[i0].Name )
|
||||
.Add("Field02", Data.Skeleton[i0].Field02);
|
||||
|
||||
MsgPack Bone = new MsgPack("Bone", Data.Skeleton[i0].Bone.Length);
|
||||
for (i = 0; i < Data.Skeleton[i0].Bone.Length; i++)
|
||||
Bone[i] = new MsgPack().Add("Type" , (byte) Data.Skeleton[i0].Bone[i].Type )
|
||||
.Add("HasParent" , Data.Skeleton[i0].Bone[i].HasParent )
|
||||
.Add("ParentNameIndex", Data.Skeleton[i0].Bone[i].ParentNameIndex)
|
||||
.Add("Field01" , Data.Skeleton[i0].Bone[i].Field01 )
|
||||
.Add("PairNameIndex" , Data.Skeleton[i0].Bone[i].PairNameIndex )
|
||||
.Add("Field02" , Data.Skeleton[i0].Bone[i].Field02 )
|
||||
.Add("Name" , Data.Skeleton[i0].Bone[i].Name );
|
||||
Skeleton.Add(Bone);
|
||||
|
||||
MsgPack Position = new MsgPack("Position", Data.Skeleton[i0].Position.Length);
|
||||
for (i = 0; i < Data.Skeleton[i0].Position.Length; i++)
|
||||
Position[i] = new MsgPack().Add("X", Data.Skeleton[i0].Position[i].X)
|
||||
.Add("Y", Data.Skeleton[i0].Position[i].Y)
|
||||
.Add("Z", Data.Skeleton[i0].Position[i].Z);
|
||||
Skeleton.Add(Position);
|
||||
|
||||
MsgPack BoneName1 = new MsgPack("BoneName1", Data.Skeleton[i0].BoneName1.Length);
|
||||
for (i = 0; i < Data.Skeleton[i0].BoneName1.Length; i++)
|
||||
BoneName1[i] = Data.Skeleton[i0].BoneName1[i];
|
||||
Skeleton.Add(BoneName1);
|
||||
|
||||
MsgPack BoneName2 = new MsgPack("BoneName2", Data.Skeleton[i0].BoneName2.Length);
|
||||
for (i = 0; i < Data.Skeleton[i0].BoneName2.Length; i++)
|
||||
BoneName2[i] = Data.Skeleton[i0].BoneName2[i];
|
||||
Skeleton.Add(BoneName2);
|
||||
|
||||
MsgPack ParentIndice = new MsgPack("ParentIndice", Data.Skeleton[i0].ParentIndice.Length);
|
||||
for (i = 0; i < Data.Skeleton[i0].ParentIndice.Length; i++)
|
||||
ParentIndice[i] = Data.Skeleton[i0].ParentIndice[i];
|
||||
BoneDB[i0] = Skeleton.Add(ParentIndice);
|
||||
}
|
||||
|
||||
BoneDB.Write(true, file, JSON);
|
||||
}
|
||||
|
||||
/*public struct Bone
|
||||
{
|
||||
public List<string> Names;
|
||||
public List<long> Offsets;
|
||||
}*/
|
||||
|
||||
public struct BONE
|
||||
{
|
||||
public long SkeletonsOffset;
|
||||
public long SkeletonNamesOffset;
|
||||
public POF POF;
|
||||
public PDHead Header;
|
||||
public long[] SkeletonEntryOffset;
|
||||
public SkeletonEntry[] Skeleton;
|
||||
}
|
||||
|
||||
public struct BoneEntry
|
||||
{
|
||||
public bool HasParent;
|
||||
public byte Field01;
|
||||
public byte Field02;
|
||||
public byte PairNameIndex;
|
||||
public byte ParentNameIndex;
|
||||
public string Name;
|
||||
public BoneType Type;
|
||||
}
|
||||
|
||||
public enum BoneType : byte
|
||||
{
|
||||
Rotation = 0,
|
||||
Type1 = 1,
|
||||
Position = 2,
|
||||
Type3 = 3,
|
||||
Type4 = 4,
|
||||
Type5 = 5,
|
||||
Type6 = 6,
|
||||
};
|
||||
|
||||
public struct SkeletonEntry
|
||||
{
|
||||
public long BoneOffset;
|
||||
public long Field02Offset;
|
||||
public long PositionOffset;
|
||||
public long BoneName1Offset;
|
||||
public long BoneName2Offset;
|
||||
public long ParentIndiceOffset;
|
||||
|
||||
public long Field02;
|
||||
public string Name;
|
||||
public short[] ParentIndice;
|
||||
public string[] BoneName1;
|
||||
public string[] BoneName2;
|
||||
public BoneEntry[] Bone;
|
||||
public Vector3<float>[] Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
public class Spr
|
||||
{
|
||||
public SpriteSet[] SpriteSets;
|
||||
|
||||
private Stream IO;
|
||||
private int i, i0, i1, i2;
|
||||
|
||||
public void BINReader(string file)
|
||||
{
|
||||
/*Stream IO0 = File.OpenReader(file + "0.bin");
|
||||
Stream IO1 = File.OpenReader(file + "1.bin");
|
||||
|
||||
List<int> _0 = new List<int>();
|
||||
List<int> _1 = new List<int>();
|
||||
IO0.Position = 0x20;
|
||||
for (i = 0; i < 124; i++)
|
||||
{ _0.Add(IO0.ReadInt32()); IO0.LongPosition += 8; }
|
||||
IO1.Position = 0x20;
|
||||
for (i = 0; i < 124; i++)
|
||||
{ _1.Add(IO1.ReadInt32()); IO1.LongPosition += 8; }
|
||||
IO0.Close();
|
||||
IO1.Close();
|
||||
|
||||
IO = File.OpenWriter(@"F:\Source\MikuMikuModel\DatabaseConverter\msgpack-json-tools\aet_gam_pv643.bin");
|
||||
IO.Position = 0x10;
|
||||
for (i = 0; i < 108; i++)
|
||||
{ IO.ReadInt32(); i1 = _1[_0.IndexOf(IO.ReadInt32())]; IO.Position -= 4; IO.Write(i1); }
|
||||
IO.Close();*/
|
||||
|
||||
IO = File.OpenReader(file + ".bin");
|
||||
|
||||
int spriteSetsLength = IO.ReadInt32();
|
||||
int spriteSetsOffset = IO.ReadInt32();
|
||||
int spritesLength = IO.ReadInt32();
|
||||
int spritesOffset = IO.ReadInt32();
|
||||
|
||||
IO.Position = spriteSetsOffset;
|
||||
SpriteSets = new SpriteSet[spriteSetsLength];
|
||||
for (i = 0; i < spriteSetsLength; i++)
|
||||
{
|
||||
SpriteSets[i].Id = IO.ReadInt32();
|
||||
SpriteSets[i].Name = IO.ReadStringAtOffset();
|
||||
SpriteSets[i].FileName = IO.ReadStringAtOffset();
|
||||
IO.ReadInt32();
|
||||
}
|
||||
|
||||
int setIndex;
|
||||
bool IsTexture;
|
||||
SpriteTexture st = new SpriteTexture();
|
||||
int[] SprCount = new int[spriteSetsLength];
|
||||
int[] TexCount = new int[spriteSetsLength];
|
||||
|
||||
IO.Position = spritesOffset;
|
||||
for (i = 0; i < spritesLength; i++)
|
||||
{
|
||||
IO.LongPosition += 10;
|
||||
setIndex = IO.ReadInt16();
|
||||
IsTexture = (setIndex & 0x1000) == 0x1000;
|
||||
setIndex &= 0xFFF;
|
||||
|
||||
if (IsTexture) TexCount[setIndex]++;
|
||||
else SprCount[setIndex]++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < spriteSetsLength; i++)
|
||||
{
|
||||
SpriteSets[i].Sprites = new SpriteTexture[SprCount[i]];
|
||||
SpriteSets[i].Textures = new SpriteTexture[TexCount[i]];
|
||||
|
||||
SprCount[i] = 0;
|
||||
TexCount[i] = 0;
|
||||
}
|
||||
|
||||
IO.Position = spritesOffset;
|
||||
for (i = 0; i < spritesLength; i++)
|
||||
{
|
||||
st.Id = IO.ReadInt32();
|
||||
st.Name = IO.ReadStringAtOffset();
|
||||
IO.ReadInt16();
|
||||
setIndex = IO.ReadInt16();
|
||||
IsTexture = (setIndex & 0x1000) == 0x1000;
|
||||
setIndex &= 0xFFF;
|
||||
|
||||
if (IsTexture) { SpriteSets[setIndex].Textures[TexCount[setIndex]] = st; TexCount[setIndex]++; }
|
||||
else { SpriteSets[setIndex]. Sprites[SprCount[setIndex]] = st; SprCount[setIndex]++; }
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void BINWriter(string file)
|
||||
{
|
||||
if (SpriteSets == null) return;
|
||||
if (SpriteSets.Length == 0) return;
|
||||
|
||||
List<string> SetName = new List<string>();
|
||||
List<string> SetFileName = new List<string>();
|
||||
|
||||
List<int> Ids = new List<int>();
|
||||
List<int> SetIds = new List<int>();
|
||||
|
||||
List<int> NotAdd = new List<int>();
|
||||
SpriteTexture temp;
|
||||
SpriteSet set;
|
||||
|
||||
for (i = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
set = SpriteSets[i];
|
||||
if (set. Name != null)
|
||||
if (SetName .Contains(set. Name)) { NotAdd.Add(i); continue; }
|
||||
else SetName .Add (set. Name);
|
||||
if (set.FileName != null)
|
||||
if (SetFileName.Contains(set.FileName)) { NotAdd.Add(i); continue; }
|
||||
else SetFileName.Add (set.FileName);
|
||||
|
||||
if (set.NewId)
|
||||
{
|
||||
SpriteSets[i].Id = null;
|
||||
for (i0 = 0; i0 < set.Textures.Length; i0++) SpriteSets[i].Textures[i0].Id = null;
|
||||
for (i0 = 0; i0 < set. Sprites.Length; i0++) SpriteSets[i]. Sprites[i0].Id = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (set.Id != null)
|
||||
if (SetIds.Contains((int)set.Id)) { NotAdd.Add(i); continue; }
|
||||
else SetIds.Add ((int)set.Id);
|
||||
|
||||
for (i0 = 0; i0 < set. Sprites.Length; i0++)
|
||||
{
|
||||
temp = set. Sprites[i0];
|
||||
if (temp.Id != null)
|
||||
if ( Ids.Contains((int)temp.Id)) { NotAdd.Add(i); break; }
|
||||
else Ids.Add ((int)temp.Id);
|
||||
}
|
||||
if (i0 + 1 != set.Sprites.Length) continue;
|
||||
|
||||
for (i0 = 0; i0 < set.Textures.Length; i0++)
|
||||
{
|
||||
temp = set.Textures[i0];
|
||||
if (temp.Id != null)
|
||||
if ( Ids.Contains((int)temp.Id)) { NotAdd.Add(i); break; }
|
||||
else Ids.Add ((int)temp.Id);
|
||||
}
|
||||
}
|
||||
SetName = null;
|
||||
SetFileName = null;
|
||||
|
||||
for (i = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
set = SpriteSets[i];
|
||||
if (NotAdd.Contains(i)) continue;
|
||||
if (!set.NewId) continue;
|
||||
|
||||
i1 = 0;
|
||||
if (set.Id == null) while (true)
|
||||
{ if (!SetIds.Contains(i1)) { SpriteSets[i].Id = i1; SetIds.Add(i1); break; } i1++; }
|
||||
|
||||
for (i0 = 0, i1 = 0; i0 < set. Sprites.Length; i0++)
|
||||
if (set. Sprites[i0].Id == null) while (true) { if (!Ids.Contains(i1))
|
||||
{ SpriteSets[i]. Sprites[i0].Id = i1; Ids.Add(i1); break; } i1++; }
|
||||
|
||||
for (i0 = 0, i1 = 0; i0 < set.Textures.Length; i0++)
|
||||
if (set.Textures[i0].Id == null) while (true) { if (!Ids.Contains(i1))
|
||||
{ SpriteSets[i].Textures[i0].Id = i1; Ids.Add(i1); break; } i1++; }
|
||||
}
|
||||
|
||||
Ids = null;
|
||||
SetIds = null;
|
||||
|
||||
|
||||
|
||||
for (i = 0, i0 = 0, i2 = 0; i < SpriteSets.Length; i++)
|
||||
if (!NotAdd.Contains(i)) { i0 += SpriteSets[i].Sprites.Length + SpriteSets[i].Textures.Length; i2++; }
|
||||
|
||||
i1 = i0 * 12;
|
||||
i1 = i1.Align(0x20) + 0x20;
|
||||
|
||||
IO = File.OpenWriter(file + ".bin", true);
|
||||
IO.Write(i2);
|
||||
IO.Write(i1);
|
||||
IO.Write(i0);
|
||||
IO.Write(0x20);
|
||||
IO.Write(0x9066906690669066);
|
||||
IO.Write(0x9066906690669066);
|
||||
|
||||
IO.Position = (i1 + i2 * 0x10).Align(0x20);
|
||||
for (i = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) continue;
|
||||
SpriteSets[i]. NameOffset = IO.Position; IO.Write(SpriteSets[i]. Name + "\0");
|
||||
SpriteSets[i].FileNameOffset = IO.Position; IO.Write(SpriteSets[i].FileName + "\0");
|
||||
}
|
||||
|
||||
for (i = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) continue;
|
||||
for (i0 = 0; i0 < SpriteSets[i].Textures.Length; i0++)
|
||||
{ SpriteSets[i].Textures[i0].NameOffset = IO.Position; IO.Write(SpriteSets[i].Textures[i0].Name + "\0"); }
|
||||
|
||||
for (i0 = 0; i0 < SpriteSets[i]. Sprites.Length; i0++)
|
||||
{ SpriteSets[i]. Sprites[i0].NameOffset = IO.Position; IO.Write(SpriteSets[i]. Sprites[i0].Name + "\0"); }
|
||||
}
|
||||
|
||||
IO.Align(0x08, true);
|
||||
IO.Position = 0x20;
|
||||
for (i = 0, i2 = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
for (i0 = 0; i0 < SpriteSets[i].Textures.Length; i0++)
|
||||
{
|
||||
IO.Write(SpriteSets[i].Textures[i0].Id );
|
||||
IO.Write(SpriteSets[i].Textures[i0].NameOffset);
|
||||
IO.Write((ushort) i0 );
|
||||
IO.Write((ushort)(0x1000 | (i - i2)));
|
||||
}
|
||||
|
||||
for (i0 = 0; i0 < SpriteSets[i]. Sprites.Length; i0++)
|
||||
{
|
||||
IO.Write(SpriteSets[i]. Sprites[i0].Id );
|
||||
IO.Write(SpriteSets[i]. Sprites[i0].NameOffset);
|
||||
IO.Write((ushort) i0 );
|
||||
IO.Write((ushort)(i - i2));
|
||||
}
|
||||
}
|
||||
IO.Align(0x20);
|
||||
for (i = 0, i2 = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
IO.Write(SpriteSets[i].Id );
|
||||
IO.Write(SpriteSets[i]. NameOffset);
|
||||
IO.Write(SpriteSets[i].FileNameOffset);
|
||||
IO.Write(i - i2);
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool JSON = false)
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
if (MsgPack.Element("SprDB", out MsgPack SprDB, typeof(object[])))
|
||||
{
|
||||
SpriteSets = new SpriteSet[((object[])SprDB.Object).Length];
|
||||
for (int i = 0; i < SpriteSets.Length; i++)
|
||||
if (SprDB[i].GetType() == typeof(MsgPack))
|
||||
SpriteSets[i].ReadMsgPack((MsgPack)SprDB[i]);
|
||||
}
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
if (SpriteSets == null) return;
|
||||
if (SpriteSets.Length == 0) return;
|
||||
|
||||
MsgPack SprDB = new MsgPack("SprDB", SpriteSets.Length);
|
||||
for (i = 0; i < SpriteSets.Length; i++) SprDB[i] = SpriteSets[i].WriteMsgPack();
|
||||
|
||||
SprDB.Write(true, file, JSON);
|
||||
}
|
||||
|
||||
public struct SpriteTexture
|
||||
{
|
||||
public int NameOffset;
|
||||
public int? Id;
|
||||
public string Name;
|
||||
|
||||
public void ReadMsgPack(MsgPack msg)
|
||||
{ Id = msg.ReadNInt32("Id"); Name = msg.ReadString("Name"); }
|
||||
|
||||
public MsgPack WriteMsgPack() =>
|
||||
new MsgPack().Add("Id", Id).Add("Name", Name);
|
||||
}
|
||||
|
||||
public struct SpriteSet
|
||||
{
|
||||
public int NameOffset;
|
||||
public int FileNameOffset;
|
||||
public int? Id;
|
||||
public bool NewId;
|
||||
public string Name;
|
||||
public string FileName;
|
||||
public SpriteTexture[] Sprites;
|
||||
public SpriteTexture[] Textures;
|
||||
|
||||
public void ReadMsgPack(MsgPack msg)
|
||||
{
|
||||
FileName = msg.ReadString ("FileName");
|
||||
Id = msg.ReadNInt32 ( "Id" );
|
||||
Name = msg.ReadString ("Name" );
|
||||
NewId = msg.ReadBoolean("NewId" );
|
||||
|
||||
if (msg.Element( "Sprites", out MsgPack Sprites, typeof(object[])))
|
||||
{
|
||||
object Sprite;
|
||||
this .Sprites = new SpriteTexture[((object[])Sprites.Object).Length];
|
||||
for (int i0 = 0; i0 < this.Sprites.Length; i0++)
|
||||
{ Sprite = Sprites[i0]; if (Sprites.GetType() == typeof(MsgPack))
|
||||
this.Sprites[i0].ReadMsgPack((MsgPack)Sprite); }
|
||||
}
|
||||
|
||||
if (msg.Element("Textures", out MsgPack Textures, typeof(object[])))
|
||||
{
|
||||
object Texture;
|
||||
this .Textures = new SpriteTexture[((object[])Textures.Object).Length];
|
||||
for (int i0 = 0; i0 < this.Textures.Length; i0++)
|
||||
{ Texture = Textures[i0]; if (Texture.GetType() == typeof(MsgPack))
|
||||
this.Textures[i0].ReadMsgPack((MsgPack)Texture); }
|
||||
}
|
||||
}
|
||||
|
||||
public MsgPack WriteMsgPack()
|
||||
{
|
||||
MsgPack Sprites = new MsgPack( "Sprites", this.Sprites.Length);
|
||||
for (int i0 = 0; i0 < this.Sprites.Length; i0++)
|
||||
Sprites[i0] = this.Sprites[i0].WriteMsgPack();
|
||||
|
||||
MsgPack Textures = new MsgPack("Textures", this.Textures.Length);
|
||||
for (int i0 = 0; i0 < this.Textures.Length; i0++)
|
||||
Textures[i0] = this.Textures[i0].WriteMsgPack();
|
||||
|
||||
return new MsgPack().Add("FileName", FileName).Add("Id", Id).Add("Name", Name).Add(Sprites).Add(Textures);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//Original research by Samyuu
|
||||
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public static class DCC //Databank_Checksum_Calculator
|
||||
{
|
||||
private static readonly ushort[] ChecksumLookupTable = {
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
|
||||
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
|
||||
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
|
||||
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
|
||||
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
|
||||
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
|
||||
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
|
||||
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
|
||||
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
|
||||
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
|
||||
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
|
||||
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
|
||||
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
|
||||
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
|
||||
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
|
||||
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
|
||||
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
|
||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
|
||||
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
|
||||
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
|
||||
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
|
||||
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
|
||||
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
|
||||
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0,
|
||||
};
|
||||
|
||||
public static ushort CalculateChecksum(string file) => CalculateChecksum(File.ReadAllBytes(file));
|
||||
|
||||
public static ushort CalculateChecksum(byte[] data)
|
||||
{
|
||||
ushort result = 0xFFFF;
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
result = (ushort)(ChecksumLookupTable[(result >> 8) ^ data[i]] ^ (result << 8));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-14
@@ -12,8 +12,7 @@ namespace KKdMainLib
|
||||
|
||||
private int Offset = 0;
|
||||
private PDHead Header;
|
||||
|
||||
private MsgPack MsgPack;
|
||||
|
||||
public Stream IO;
|
||||
public EXP[] Dex;
|
||||
|
||||
@@ -190,17 +189,14 @@ namespace KKdMainLib
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string filepath)
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
int i0 = 0;
|
||||
int i1 = 0;
|
||||
this.Dex = new EXP[0];
|
||||
Header = new PDHead();
|
||||
|
||||
MPIO IO = new MPIO(File.OpenReader(filepath + ".mp"));
|
||||
MsgPack = IO.Read();
|
||||
IO.Close();
|
||||
IO = null;
|
||||
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
if (MsgPack.Element("Dex", out MsgPack Dex, typeof(object[])))
|
||||
{
|
||||
@@ -240,7 +236,7 @@ namespace KKdMainLib
|
||||
ID = mp.ReadUInt16("I"), Value = mp.ReadSingle("V"),
|
||||
Trans = mp.ReadSingle("T") };
|
||||
|
||||
public void MsgPackWriter(string filepath)
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
int i0 = 0;
|
||||
int i1 = 0;
|
||||
@@ -260,11 +256,7 @@ namespace KKdMainLib
|
||||
Dex[i0] = EXP;
|
||||
}
|
||||
|
||||
MsgPack = new MsgPack(MsgPack.Types.FixMap).Add(Dex);
|
||||
|
||||
MPIO IO = new MPIO(File.OpenWriter(filepath + ".mp", true));
|
||||
IO.Write(MsgPack, true);
|
||||
IO = null;
|
||||
Dex.Write(true, file, JSON);
|
||||
}
|
||||
|
||||
private MsgPack WriteEXP(EXPElement element) =>
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace KKdMainLib
|
||||
|
||||
public static void Decrypt(this string file)
|
||||
{
|
||||
Console.Title = "DIVAFILE Decrypt - File: " + MSIO.Path.GetFileName(file);
|
||||
Console.Title = "DIVAFILE Decrypt - File: " + Path.GetFileName(file);
|
||||
Stream reader = File.OpenReader(file);
|
||||
if (reader.ReadInt64() != 0x454C494641564944)
|
||||
{ reader.Close(); return; }
|
||||
@@ -35,7 +35,7 @@ namespace KKdMainLib
|
||||
|
||||
public static void Encrypt(this string file)
|
||||
{
|
||||
Console.Title = "DIVAFILE Encrypt - File: " + MSIO.Path.GetFileName(file);
|
||||
Console.Title = "DIVAFILE Encrypt - File: " + Path.GetFileName(file);
|
||||
Stream reader = File.OpenReader(file);
|
||||
int FileLenghtOrigin = reader.Length;
|
||||
int FileLenght = FileLenghtOrigin.Align(16);
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Xml.Linq;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public class DataBank
|
||||
{
|
||||
public DataBank()
|
||||
{ Success = false; Xml = null; IO = null; pvList = null; }
|
||||
|
||||
public bool Success { get; private set; }
|
||||
|
||||
private Xml Xml;
|
||||
private Stream IO;
|
||||
|
||||
private PvList[] pvList;
|
||||
|
||||
public void DBReader(string file)
|
||||
{
|
||||
Success = false;
|
||||
if (!File.Exists(file)) return;
|
||||
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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++)
|
||||
IO.Write(UrlEncode(pvList[i].ToString() +
|
||||
(i + 1 != pvList.Length ? c : "")));
|
||||
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);
|
||||
}
|
||||
|
||||
public void XMLReader(string file)
|
||||
{
|
||||
Success = false;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void XMLWriter(string file)
|
||||
{
|
||||
if (!Success) return;
|
||||
|
||||
Xml = new Xml { Compact = true };
|
||||
|
||||
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 (File.Exists(file)) File.Delete(file);
|
||||
Xml.SaveXml(file);
|
||||
}
|
||||
|
||||
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 struct PvList
|
||||
{
|
||||
public int ID;
|
||||
public bool Enable;
|
||||
public bool Extra;
|
||||
public Date AdvDemoStart;
|
||||
public Date AdvDemoEnd;
|
||||
public Date StartShow;
|
||||
public Date EndShow;
|
||||
|
||||
public void SetValue(string[] data, int i = 0)
|
||||
{
|
||||
ID = int.Parse(data[i * 7 + 0]);
|
||||
Enable = int.Parse(data[i * 7 + 1]) == 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)
|
||||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public XElement WriteXml(Xml Xml, string name)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private const string d = ".";
|
||||
private const string c = ",";
|
||||
|
||||
public struct Date
|
||||
{
|
||||
private int year ;
|
||||
private int month;
|
||||
private int day ;
|
||||
|
||||
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 void SetDefaultLower() => Year = 1999;
|
||||
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]);
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -35,16 +35,16 @@ namespace KKdMainLib
|
||||
Files = null;
|
||||
Signature = Farc.FArC;
|
||||
FT = false;
|
||||
Console.Title = "FARC Extractor - Archive: " + MSIO.Path.GetFileName(file);
|
||||
if (!MSIO.File.Exists(file))
|
||||
Console.Title = "FARC Extractor - Archive: " + Path.GetFileName(file);
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
Console.WriteLine("File {0} doesn't exist.", MSIO.Path.GetFileName(file));
|
||||
Console.WriteLine("File {0} doesn't exist.", Path.GetFileName(file));
|
||||
Console.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
Stream reader = File.OpenReader(file);
|
||||
string directory = MSIO.Path.GetFullPath(file).Replace(MSIO.Path.GetExtension(file), "");
|
||||
string directory = Path.GetFullPath(file).Replace(Path.GetExtension(file), "");
|
||||
Signature = (Farc)reader.ReadInt32Endian(true);
|
||||
if (Signature != Farc.FArc && Signature != Farc.FArC && Signature != Farc.FARC)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ namespace KKdMainLib
|
||||
|
||||
if (SaveToDisk)
|
||||
{
|
||||
File.WriteAllBytes(MSIO.Path.Combine(directory, Files[i].Name), Files[i].Data);
|
||||
File.WriteAllBytes(Path.Combine(directory, Files[i].Name), Files[i].Data);
|
||||
Files[i].Data = null;
|
||||
}
|
||||
}
|
||||
@@ -157,8 +157,8 @@ namespace KKdMainLib
|
||||
GZipStream gZipStream;
|
||||
if (Encrypted)
|
||||
{
|
||||
gZipStream = new GZipStream(new MSIO.
|
||||
MemoryStream(Files[i].Data), CompressionMode.Decompress);
|
||||
gZipStream = new GZipStream(new MSIO.MemoryStream(
|
||||
Files[i].Data), CompressionMode.Decompress);
|
||||
stream.Close();
|
||||
}
|
||||
else gZipStream = new GZipStream(stream, CompressionMode.Decompress);
|
||||
@@ -177,7 +177,7 @@ namespace KKdMainLib
|
||||
|
||||
if (SaveToDisk)
|
||||
{
|
||||
File.WriteAllBytes(MSIO.Path.Combine(directory, Files[i].Name), Files[i].Data);
|
||||
File.WriteAllBytes(Path.Combine(directory, Files[i].Name), Files[i].Data);
|
||||
Files[i].Data = null;
|
||||
}
|
||||
|
||||
@@ -231,14 +231,14 @@ namespace KKdMainLib
|
||||
{
|
||||
Files = null;
|
||||
FT = false;
|
||||
string[] files = MSIO.Directory.GetFiles(file);
|
||||
string[] files = Directory.GetFiles(file);
|
||||
Files = new FARCFile[files.Length];
|
||||
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
Files[i] = new FARCFile { Name = files[i] };
|
||||
string ext = MSIO.Path.GetExtension(files[i]).ToLower();
|
||||
if (ext == ".a3da" || ext == ".mot" || ext == ".vag")
|
||||
string ext = Path.GetExtension(files[i]).ToLower();
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".vag")
|
||||
Signature = Farc.FArc;
|
||||
}
|
||||
files = null;
|
||||
@@ -259,7 +259,7 @@ namespace KKdMainLib
|
||||
}
|
||||
int HeaderPartLength = Signature == Farc.FArc ? 0x09 : 0x0D;
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
HeaderWriter.Length += MSIO.Path.GetFileName(Files[i].Name).Length + HeaderPartLength;
|
||||
HeaderWriter.Length += Path.GetFileName(Files[i].Name).Length + HeaderPartLength;
|
||||
writer.WriteEndian(HeaderWriter.Length, true);
|
||||
writer.Write(HeaderWriter.ToArray(true));
|
||||
HeaderWriter = null;
|
||||
@@ -276,7 +276,7 @@ namespace KKdMainLib
|
||||
else writer.Seek(0x0C, 0);
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
{
|
||||
writer.Write(MSIO.Path.GetFileName(Files[i].Name) + "\0");
|
||||
writer.Write(Path.GetFileName(Files[i].Name) + "\0");
|
||||
writer.WriteEndian(Files[i].Offset, true);
|
||||
if (Signature != Farc.FArc)
|
||||
writer.WriteEndian(Files[i].SizeComp, true);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using MSIO = System.IO;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public static class Directory
|
||||
{
|
||||
public static bool Exists(string path) => MSIO.Directory.Exists(path);
|
||||
public static void Delete(string path) => MSIO.Directory.Delete(path);
|
||||
public static string GetCurrentDirectory() => MSIO.Directory.GetCurrentDirectory();
|
||||
public static string[] GetFiles(string path) => MSIO.Directory.GetFiles(path);
|
||||
public static string[] GetDirectories(string path) => MSIO.Directory.GetDirectories(path);
|
||||
public static MSIO.DirectoryInfo CreateDirectory(string path) => MSIO.Directory.CreateDirectory(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,10 @@ namespace KKdMainLib.IO
|
||||
{ Stream IO = OpenWriter(file); 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++) IO.Write(data[i] + "\r\n"); IO.Close(); }
|
||||
{ Stream IO = OpenWriter(file); 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);
|
||||
public static void Delete(string file) => MSIO.File.Delete(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 (true && stream.LongPosition >= 0 && stream.LongPosition < stream.LongLength)
|
||||
{
|
||||
byte a = stream.ReadByte();
|
||||
if (a == End) break;
|
||||
@@ -19,5 +19,24 @@ namespace KKdMainLib.IO
|
||||
}
|
||||
return s.ToArray();
|
||||
}
|
||||
public static char PeekCharUTF8(this Stream stream)
|
||||
{ long LongPosition = stream.LongPosition; char val = stream.ReadCharUTF8();
|
||||
stream.LongPosition = LongPosition; return val; }
|
||||
public static Stream SkipWhitespace(this Stream stream)
|
||||
{
|
||||
long LongPosition = stream.LongPosition;
|
||||
while (true)
|
||||
if (char.IsWhiteSpace(stream.ReadCharUTF8())) LongPosition = stream.LongPosition;
|
||||
else { stream.LongPosition = LongPosition; break; }
|
||||
return stream;
|
||||
}
|
||||
public static bool Assert(this Stream stream, char next)
|
||||
{ if (stream.PeekCharUTF8() == next) { stream.ReadCharUTF8(); return true; } else return false; }
|
||||
public static bool Assert(this Stream stream, string next)
|
||||
{
|
||||
for (var i = 0; i < next.Length; i++)
|
||||
if (!stream.Assert(next[i])) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using MSIO = System.IO;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public static class Path
|
||||
{
|
||||
public static string GetFileName(string path) =>
|
||||
MSIO.Path.GetFileName(path);
|
||||
public static string GetFileNameWithoutExtension(string path) =>
|
||||
MSIO.Path.GetFileNameWithoutExtension(path);
|
||||
public static string GetExtension(string path) =>
|
||||
MSIO.Path.GetExtension(path);
|
||||
public static string GetFullPath(string path) =>
|
||||
MSIO.Path.GetFullPath(path);
|
||||
public static string Combine(string path1, string path2) =>
|
||||
MSIO.Path.Combine(path1, path2);
|
||||
public static string Combine(string path1, string path2, string path3) =>
|
||||
MSIO.Path.Combine(path1, path2, path3);
|
||||
public static string Combine(string path1, string path2, string path3, string path4) =>
|
||||
MSIO.Path.Combine(path1, path2, path3, path4);
|
||||
public static string Combine(params string[] paths) =>
|
||||
MSIO.Path.Combine(paths);
|
||||
}
|
||||
}
|
||||
+52
-8
@@ -28,12 +28,16 @@ namespace KKdMainLib.IO
|
||||
public uint UIntOffset { get => (uint)LongOffset; set => LongOffset = value; }
|
||||
public long LongOffset;
|
||||
|
||||
public int Length { get => ( int)stream. Length; set => stream.SetLength (value); }
|
||||
public uint UIntLength { get => (uint)stream. Length; set => stream.SetLength (value); }
|
||||
public long LongLength { get => stream. Length; set => stream.SetLength (value); }
|
||||
public int Position { get => ( int)stream.Position; set => stream.Position = value ; }
|
||||
public uint UIntPosition { get => (uint)stream.Position; set => stream.Position = value ; }
|
||||
public long LongPosition { get => stream.Position; set => stream.Position = value ; }
|
||||
public int Length { get => ( int)stream.Length; set => stream.SetLength(value); }
|
||||
public uint UIntLength { get => (uint)stream.Length; set => stream.SetLength(value); }
|
||||
public long LongLength { get => stream.Length; set => stream.SetLength(value); }
|
||||
|
||||
public int Position
|
||||
{ get => ( int)stream.Position - Offset; set => stream.Position = value + Offset; }
|
||||
public uint UIntPosition
|
||||
{ get => (uint)stream.Position - UIntOffset; set => stream.Position = value + UIntOffset; }
|
||||
public long LongPosition
|
||||
{ get => stream.Position - LongOffset; set => stream.Position = value + LongOffset; }
|
||||
|
||||
public bool CanRead => stream.CanRead;
|
||||
public bool CanSeek => stream.CanSeek;
|
||||
@@ -45,6 +49,7 @@ namespace KKdMainLib.IO
|
||||
public Stream(MSIO.Stream output = null, byte[] Data = null, bool isBE = false)
|
||||
{
|
||||
if (output == null) output = MSIO.Stream.Null;
|
||||
LongOffset = 0;
|
||||
BitRead = 8;
|
||||
ValRead = ValRead = BitWrite = 0;
|
||||
stream = output;
|
||||
@@ -255,10 +260,34 @@ namespace KKdMainLib.IO
|
||||
for (i = L; i > 0; i--) { val <<= 8; val |= buf[i - 1]; } return val; }
|
||||
|
||||
private void Read(byte Length) => stream.Read(buf, 0, Length);
|
||||
public char ReadChar(bool UTF8 = true)
|
||||
{ if (UTF8) return ReadCharUTF8();
|
||||
else return (char)stream.ReadByte(); }
|
||||
|
||||
public char ReadCharUTF8()
|
||||
{
|
||||
byte t;
|
||||
int T;
|
||||
int val = 0;
|
||||
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; }
|
||||
else return '\uFFFF';
|
||||
}
|
||||
return (char)val;
|
||||
}
|
||||
|
||||
public string ReadString(long Length, bool UTF8 = true)
|
||||
{ if (UTF8) return ReadStringUTF8 (Length);
|
||||
else return ReadStringASCII(Length); }
|
||||
else return ReadStringASCII(Length); }
|
||||
|
||||
public string ReadStringUTF8 (long Length) => ReadBytes(Length).ToUTF8 ();
|
||||
public string ReadStringASCII(long Length) => ReadBytes(Length).ToASCII();
|
||||
@@ -266,7 +295,7 @@ namespace KKdMainLib.IO
|
||||
|
||||
public string ReadString(long? Length, bool UTF8 = true)
|
||||
{ if (UTF8) return ReadStringUTF8 (Length);
|
||||
else return ReadStringASCII(Length); }
|
||||
else return ReadStringASCII(Length); }
|
||||
|
||||
public string ReadStringUTF8 (long? Length) => ReadBytes(Length).ToUTF8 ();
|
||||
public string ReadStringASCII(long? Length) => ReadBytes(Length).ToASCII();
|
||||
@@ -328,6 +357,21 @@ 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
|
||||
|
||||
@@ -36,22 +36,33 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="A3DA\A3DAExt.cs" />
|
||||
<Compile Include="A3DA\A3DA.cs" />
|
||||
<Compile Include="DB\Aet.cs" />
|
||||
<Compile Include="DB\Auth.cs" />
|
||||
<Compile Include="DEX.cs" />
|
||||
<Compile Include="DIVAFILE.cs" />
|
||||
<Compile Include="DB\Spr.cs" />
|
||||
<Compile Include="IO\Directory.cs" />
|
||||
<Compile Include="IO\File.cs" />
|
||||
<Compile Include="IO\IOExtensions.cs" />
|
||||
<Compile Include="IO\Path.cs" />
|
||||
<Compile Include="IO\Stream.cs" />
|
||||
<Compile Include="MathExtensions.cs" />
|
||||
<Compile Include="MessagePack\JSONIO.cs" />
|
||||
<Compile Include="MessagePack\MPExt.cs" />
|
||||
<Compile Include="MessagePack\MsgPack.cs" />
|
||||
<Compile Include="MessagePack\IO.cs" />
|
||||
<Compile Include="STR.cs" />
|
||||
<Compile Include="Types\Half.cs" />
|
||||
<Compile Include="A3DA\A3DA.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" />
|
||||
<Compile Include="DIVAFILE.cs" />
|
||||
<Compile Include="FARC.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="MathExtensions.cs" />
|
||||
<Compile Include="PDHeader.cs" />
|
||||
<Compile Include="POF.cs" />
|
||||
<Compile Include="STR.cs" />
|
||||
<Compile Include="Text.cs" />
|
||||
<Compile Include="Xml.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
+33
-33
@@ -68,6 +68,7 @@ namespace KKdMainLib
|
||||
public static string Choose(int code, string filetype, out string[] FileNames)
|
||||
{
|
||||
string MsgPack = GetArgs("MessagePack", true, "mp");
|
||||
string JSON = GetArgs("JSON", true, "json");
|
||||
string BIN = GetArgs("BIN", true, "bin");
|
||||
string XML = GetArgs("XML", true, "xml");
|
||||
|
||||
@@ -78,28 +79,30 @@ namespace KKdMainLib
|
||||
OpenFileDialog ofd = new OpenFileDialog { InitialDirectory =
|
||||
Application.StartupPath, Multiselect = true };
|
||||
|
||||
if (filetype == "a3da") ofd.Filter = GetArgs("A3DA", "a3da", "mp") +
|
||||
GetArgs("A3DA", true, "a3da") + MsgPack;
|
||||
else if (filetype == "bin" ) ofd.Filter = GetArgs("BIN" , "bin", "mp") +
|
||||
BIN + MsgPack;
|
||||
else if (filetype == "bon" ) ofd.Filter = GetArgs("BON" , "bon", "bin", "mp") +
|
||||
GetArgs("BON", true, "bon") + BIN + MsgPack;
|
||||
else if (filetype == "dex" ) ofd.Filter = GetArgs("DEX" , "dex", "bin", "mp") +
|
||||
GetArgs("DEX", true, "dex") + BIN + MsgPack;
|
||||
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 == "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") +
|
||||
GetArgs("DIVA", true, "diva") + GetArgs("WAV", true, "wav");
|
||||
else if (filetype == "dsc" ) ofd.Filter = GetArgs("DSC" , "dsc", "mp") +
|
||||
GetArgs("DSC", true, "dsc") + MsgPack;
|
||||
else if (filetype == "dsc" ) ofd.Filter = GetArgs("DSC" , "dsc", "json", "mp") +
|
||||
GetArgs("DSC", true, "dsc") + JSON + MsgPack;
|
||||
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", "mp") +
|
||||
GetArgs("MOT", true, "mot") + MsgPack;
|
||||
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") +
|
||||
GetArgs("PPD", true, "ppd") + GetArgs("PAK", true, "pak") + GetArgs("MOD", true, "mod");
|
||||
else if (filetype == "str") ofd.Filter = GetArgs("STR", "str", "bin", "mp") +
|
||||
GetArgs("STR", true, "str") + BIN + MsgPack;
|
||||
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") +
|
||||
GetArgs("VAG", true, "vag") + GetArgs("WAV", true, "wav");
|
||||
else if (filetype == "xml") ofd.Filter = GetArgs("XML", "xml");
|
||||
@@ -296,42 +299,45 @@ namespace KKdMainLib
|
||||
NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
|
||||
|
||||
public static string ToString(this bool? d) => d.GetValueOrDefault().ToString();
|
||||
|
||||
public static string ToString(this bool d) => d.ToString().ToLower();
|
||||
|
||||
public static string ToString(this sbyte? d) => d.GetValueOrDefault().ToString();
|
||||
public static string ToString(this sbyte d) => d.ToString();
|
||||
public static string ToString(this byte? d) => d.GetValueOrDefault().ToString();
|
||||
public static string ToString(this byte d) => d.ToString();
|
||||
public static string ToString(this short? d) => d.GetValueOrDefault().ToString();
|
||||
public static string ToString(this short d) => d.ToString();
|
||||
public static string ToString(this ushort? d) => d.GetValueOrDefault().ToString();
|
||||
public static string ToString(this ushort d) => d.ToString();
|
||||
public static string ToString(this int? d) => d.GetValueOrDefault().ToString();
|
||||
public static string ToString(this int d) => d.ToString();
|
||||
public static string ToString(this uint? d) => d.GetValueOrDefault().ToString();
|
||||
public static string ToString(this uint d) => d.ToString();
|
||||
public static string ToString(this long? d) => d.GetValueOrDefault().ToString();
|
||||
public static string ToString(this long d) => d.ToString();
|
||||
public static string ToString(this ulong? d) => d.GetValueOrDefault().ToString();
|
||||
public static string ToString(this ulong d) => d.ToString();
|
||||
public static string ToString(this float? d, byte round) => d.GetValueOrDefault().ToString(round);
|
||||
public static string ToString(this float? d) => d.GetValueOrDefault().ToString();
|
||||
|
||||
public static string ToString(this float d, byte round) =>
|
||||
Math.Round(d, round).ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
|
||||
public static string ToString(this float d) =>
|
||||
d .ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
|
||||
public static string ToString(this double? d, byte round) => d.GetValueOrDefault().ToString(round);
|
||||
public static string ToString(this double? d) => d.GetValueOrDefault().ToString();
|
||||
|
||||
public static string ToString(this double d, byte round) =>
|
||||
Math.Round(d, round).ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
|
||||
public static string ToString(this double d) =>
|
||||
d .ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
|
||||
public static float ToSingle(this string s) =>
|
||||
float. Parse(s.Replace(".", NumberDecimalSeparator));
|
||||
|
||||
public static bool ToSingle(this string s, out float value) =>
|
||||
float.TryParse(s.Replace(".", NumberDecimalSeparator), out value);
|
||||
|
||||
public static double ToDouble(this string s) =>
|
||||
double. Parse(s.Replace(".", NumberDecimalSeparator));
|
||||
|
||||
public static bool ToDouble(this string s, out double value) =>
|
||||
double.TryParse(s.Replace(".", NumberDecimalSeparator), out value);
|
||||
|
||||
public static bool ToSingle(this string s, out float? value)
|
||||
{ bool Val = ToSingle(s, out float val); value = val; return Val; }
|
||||
|
||||
public static bool ToDouble(this string s, out double? value)
|
||||
{ bool Val = ToDouble(s, out double val); value = val; return Val; }
|
||||
|
||||
@@ -350,11 +356,5 @@ namespace KKdMainLib
|
||||
X = 10,
|
||||
XHD = 11,
|
||||
}
|
||||
|
||||
public struct ThreadArgs
|
||||
{
|
||||
public int Thread;
|
||||
public int ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,20 +55,19 @@ namespace KKdMainLib.MessagePack
|
||||
{ MsgPack.Object = ( long)(sbyte)Unk; MsgPack.Type = MsgPack.Types.NegInt; }
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
bool Boolean = false;
|
||||
while (!Boolean)
|
||||
|
||||
while (true)
|
||||
{
|
||||
Boolean = ReadNil (ref MsgPack);
|
||||
Boolean = ReadArr (ref MsgPack);
|
||||
Boolean = ReadMap (ref MsgPack);
|
||||
Boolean = ReadExt (ref MsgPack);
|
||||
Boolean = ReadString (ref MsgPack);
|
||||
Boolean = ReadBoolean(ref MsgPack);
|
||||
Boolean = ReadBytes (ref MsgPack);
|
||||
Boolean = ReadInt (ref MsgPack);
|
||||
Boolean = ReadUInt (ref MsgPack);
|
||||
Boolean = ReadFloat (ref MsgPack);
|
||||
if (ReadNil (ref MsgPack)) break;
|
||||
if (ReadArr (ref MsgPack)) break;
|
||||
if (ReadMap (ref MsgPack)) break;
|
||||
if (ReadExt (ref MsgPack)) break;
|
||||
if (ReadString (ref MsgPack)) break;
|
||||
if (ReadBoolean(ref MsgPack)) break;
|
||||
if (ReadBytes (ref MsgPack)) break;
|
||||
if (ReadInt (ref MsgPack)) break;
|
||||
if (ReadUInt (ref MsgPack)) break;
|
||||
if (ReadFloat (ref MsgPack)) break;
|
||||
break;
|
||||
}
|
||||
return MsgPack;
|
||||
@@ -139,7 +138,7 @@ namespace KKdMainLib.MessagePack
|
||||
int Length = 0;
|
||||
if (Type == MsgPack.Types.Str8 ) Length = _IO.ReadByte();
|
||||
else if (Type == MsgPack.Types.Str16) Length = _IO.ReadInt16Endian(true);
|
||||
else Length = _IO.ReadInt32Endian(true);
|
||||
else Length = _IO.ReadInt32Endian(true);
|
||||
return _IO.ReadString(Length);
|
||||
}
|
||||
return null;
|
||||
@@ -191,52 +190,40 @@ namespace KKdMainLib.MessagePack
|
||||
return true;
|
||||
}
|
||||
|
||||
public IO Write(MsgPack MsgPack, bool Close = false)
|
||||
public IO Write(MsgPack MsgPack, bool Close)
|
||||
{ Write(MsgPack); if (Close) this.Close(); return this; }
|
||||
|
||||
|
||||
public IO Write(MsgPack MsgPack)
|
||||
{
|
||||
if (MsgPack.Name != null) Write(MsgPack.Name);
|
||||
if (MsgPack.Object == null) { WriteNil(); return this; }
|
||||
|
||||
if (MsgPack.Object.GetType() == typeof(List<object>))
|
||||
{
|
||||
List<object> Obj = (List<object>)MsgPack.Object;
|
||||
WriteMap(Obj.Count);
|
||||
foreach (object obj in Obj) Write(obj);
|
||||
}
|
||||
else if (MsgPack.Object.GetType() == typeof(object[]))
|
||||
{
|
||||
object[] Obj = (object[])MsgPack.Object;
|
||||
WriteArr(Obj.Length);
|
||||
foreach (object obj in Obj) Write(obj);
|
||||
}
|
||||
else Write(MsgPack.Object);
|
||||
|
||||
Write(MsgPack.Object);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Write(object obj)
|
||||
{
|
||||
if (obj == null ) WriteNil ();
|
||||
else if (obj.GetType() == typeof(MsgPack)) Write((MsgPack)obj);
|
||||
else
|
||||
if (obj == null) { WriteNil(); return; }
|
||||
switch (obj)
|
||||
{
|
||||
Type type = obj.GetType();
|
||||
if (type == typeof(byte[])) Write((byte[])obj);
|
||||
else if (type == typeof( bool)) Write(( bool)obj);
|
||||
else if (type == typeof( sbyte)) Write(( sbyte)obj);
|
||||
else if (type == typeof( byte)) Write(( byte)obj);
|
||||
else if (type == typeof( short)) Write(( short)obj);
|
||||
else if (type == typeof(ushort)) Write((ushort)obj);
|
||||
else if (type == typeof( int)) Write(( int)obj);
|
||||
else if (type == typeof( uint)) Write(( uint)obj);
|
||||
else if (type == typeof( long)) Write(( long)obj);
|
||||
else if (type == typeof( ulong)) Write(( ulong)obj);
|
||||
else if (type == typeof( float)) Write(( float)obj);
|
||||
else if (type == typeof(double)) Write((double)obj);
|
||||
else if (type == typeof(string)) Write((string)obj);
|
||||
else if (type == typeof(MsgPack.Ext)) Write((MsgPack.Ext)obj);
|
||||
case List<object> val: WriteMap(val.Count );
|
||||
foreach (object Val in val) Write(Val); break;
|
||||
case object[] val: WriteArr(val.Length);
|
||||
foreach (object Val in val) Write(Val); break;
|
||||
case MsgPack val: Write(val); break;
|
||||
case byte[] val: Write(val); break;
|
||||
case bool val: Write(val); break;
|
||||
case sbyte val: Write(val); break;
|
||||
case byte val: Write(val); break;
|
||||
case short val: Write(val); break;
|
||||
case ushort val: Write(val); break;
|
||||
case int val: Write(val); break;
|
||||
case uint val: Write(val); break;
|
||||
case long val: Write(val); break;
|
||||
case ulong val: Write(val); break;
|
||||
case float val: Write(val); break;
|
||||
case double val: Write(val); break;
|
||||
case string val: Write(val); break;
|
||||
case MsgPack.Ext val: Write(val); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +300,7 @@ namespace KKdMainLib.MessagePack
|
||||
else { _IO.Write((byte) 0xDF); _IO.WriteEndian( val, true); }
|
||||
}
|
||||
|
||||
private void WriteExt(MsgPack.Ext val)
|
||||
private void Write(MsgPack.Ext val)
|
||||
{
|
||||
if (val.Data == null) { WriteNil(); return; }
|
||||
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
//Original or reader part: https://github.com/MarcosLopezC/LightJson/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib.MessagePack
|
||||
{
|
||||
public class JSONIO
|
||||
{
|
||||
public Stream _IO;
|
||||
|
||||
public JSONIO( ) => _IO = File.OpenWriter();
|
||||
public JSONIO(Stream IO) => _IO = IO;
|
||||
|
||||
public void Close() => _IO.Close();
|
||||
|
||||
public MsgPack Read() => ReadValue(null);
|
||||
|
||||
private string ReadKey() => ReadString();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private string ReadString()
|
||||
{
|
||||
if (!_IO.Assert('"')) return null;
|
||||
char c;
|
||||
string s = "";
|
||||
while (true)
|
||||
{
|
||||
c = _IO.ReadCharUTF8();
|
||||
|
||||
if (c == '\\')
|
||||
{
|
||||
c = _IO.ReadCharUTF8();
|
||||
|
||||
switch (char.ToLower(c))
|
||||
{
|
||||
case '"' :
|
||||
case '\\':
|
||||
case '/' : s += c; break;
|
||||
case 'b' : s += '\b'; break;
|
||||
case 'f' : s += '\f'; break;
|
||||
case 'n' : s += '\n'; break;
|
||||
case 'r' : s += '\r'; break;
|
||||
case 't' : s += '\t'; break;
|
||||
case 'u' : s += ReadUnicodeLiteral(); break;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
else if (c == '"') break;
|
||||
else if (char.IsControl(c)) return null;
|
||||
else s += c;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private char ReadUnicodeLiteral() =>
|
||||
(char)((((((ReadHexDigit() << 4) | ReadHexDigit()) << 4) | ReadHexDigit()) << 4) | ReadHexDigit());
|
||||
|
||||
private int ReadHexDigit() => byte.Parse(_IO.ReadCharUTF8().ToString(),
|
||||
System.Globalization.NumberStyles.HexNumber);
|
||||
|
||||
private List<object> ReadObject()
|
||||
{
|
||||
List<object> Obj = new List<object>();
|
||||
if (!_IO.Assert('{')) return null;
|
||||
if (_IO.SkipWhitespace().PeekCharUTF8() == '}') { _IO.ReadCharUTF8(); return null; }
|
||||
|
||||
string key;
|
||||
while (true)
|
||||
{
|
||||
_IO.SkipWhitespace();
|
||||
|
||||
key = ReadString();
|
||||
if (!_IO.SkipWhitespace().Assert(':')) return null;
|
||||
Obj.Add(ReadValue(key));
|
||||
|
||||
_IO.SkipWhitespace();
|
||||
|
||||
var next = _IO.ReadCharUTF8();
|
||||
|
||||
if (next == '}') break;
|
||||
else if (next == ',') continue;
|
||||
else return null;
|
||||
}
|
||||
|
||||
return Obj;
|
||||
}
|
||||
|
||||
private object[] ReadArray()
|
||||
{
|
||||
List<object> Obj = new List<object>();
|
||||
if (!_IO.Assert('[')) return null;
|
||||
if (_IO.SkipWhitespace().PeekCharUTF8() == ']') { _IO.ReadCharUTF8(); return null; }
|
||||
|
||||
char c;
|
||||
while (true)
|
||||
{
|
||||
Obj.Add(ReadValue(null));
|
||||
c = _IO.SkipWhitespace().ReadCharUTF8();
|
||||
|
||||
if (c == ']') break;
|
||||
else if (c == ',') continue;
|
||||
else return null;
|
||||
}
|
||||
return Obj.ToArray();
|
||||
}
|
||||
|
||||
private object ReadNumber()
|
||||
{
|
||||
string s = " ";
|
||||
_IO.SkipWhitespace();
|
||||
if (_IO.PeekCharUTF8() == '-') s += _IO.ReadCharUTF8();
|
||||
if (_IO.PeekCharUTF8() == '0') s += _IO.ReadCharUTF8();
|
||||
else s += ReadDigits ();
|
||||
if (_IO.PeekCharUTF8() == '.') s += _IO.ReadCharUTF8() + ReadDigits();
|
||||
else return long.Parse(s);
|
||||
|
||||
char c = _IO.PeekCharUTF8();
|
||||
if (c == 'e' || c == 'E')
|
||||
{
|
||||
s += _IO.ReadCharUTF8();
|
||||
c = _IO.PeekCharUTF8();
|
||||
if (c == '+' || c == '-') s += _IO.ReadCharUTF8();
|
||||
s += ReadDigits();
|
||||
}
|
||||
return s.ToDouble();
|
||||
}
|
||||
|
||||
private bool ReadBoolean()
|
||||
{
|
||||
char c = _IO.PeekCharUTF8();
|
||||
if (c == 't' && _IO.Assert( "true")) return true;
|
||||
else if (c == 'f' && _IO.Assert("false")) return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ReadNull() => _IO.Assert("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")
|
||||
{ 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; }
|
||||
|
||||
private JSONIO Write(MsgPack MsgPack, string End, string TabChar, string Tab, bool Style)
|
||||
{
|
||||
string OldTab = Tab;
|
||||
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>))
|
||||
{
|
||||
List<object> Obj = (List<object>)MsgPack.Object;
|
||||
WriteMap();
|
||||
if (Style) _IO.Write(End);
|
||||
for (int i = 0; i < Obj. Count; i++)
|
||||
{
|
||||
if (Style) _IO.Write(Tab);
|
||||
Write(Obj[i], Obj[i].GetType(), End, TabChar, Tab, Style);
|
||||
if (i + 1 < Obj. Count) _IO.Write(',');
|
||||
if (Style) _IO.Write(End);
|
||||
}
|
||||
if (Style) _IO.Write(OldTab);
|
||||
WriteMap(true);
|
||||
}
|
||||
else if (type == typeof(object[]))
|
||||
{
|
||||
object[] Obj = (object[])MsgPack.Object;
|
||||
WriteArr();
|
||||
if (Style) _IO.Write(End);
|
||||
for (int i = 0; i < Obj.Length; i++)
|
||||
{
|
||||
if (Style) _IO.Write(Tab);
|
||||
Write(Obj[i], Obj[i].GetType(), End, TabChar, Tab, Style);
|
||||
if (i + 1 < Obj.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);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Write(object obj, Type type, string End, string TabChar, string Tab, bool Style)
|
||||
{
|
||||
if (obj == null) { WriteNil(); return; }
|
||||
switch (obj)
|
||||
{
|
||||
case MsgPack val: Write(val, End, TabChar, Tab, Style); break;
|
||||
case bool val: Write(val); break;
|
||||
case string val: Write(val); break;
|
||||
case sbyte val: _IO.Write(Main.ToString(val)); break;
|
||||
case byte val: _IO.Write(Main.ToString(val)); break;
|
||||
case short val: _IO.Write(Main.ToString(val)); break;
|
||||
case ushort val: _IO.Write(Main.ToString(val)); break;
|
||||
case int val: _IO.Write(Main.ToString(val)); break;
|
||||
case uint val: _IO.Write(Main.ToString(val)); break;
|
||||
case long val: _IO.Write(Main.ToString(val)); break;
|
||||
case ulong val: _IO.Write(Main.ToString(val)); break;
|
||||
case float val: _IO.Write(Main.ToString(val)); break;
|
||||
case double val: _IO.Write(Main.ToString(val)); break;
|
||||
}
|
||||
}
|
||||
private void Write( bool val) => _IO.Write(val ? "true" : "false");
|
||||
private void Write(string val) => _IO.Write("\"" + val
|
||||
.Replace("\\", "\\\\").Replace("/" , "\\/").Replace("\'", "\\\'").Replace("\"", "\\\"")
|
||||
.Replace("\0", "\\0" ).Replace("\a", "\\a").Replace("\b", "\\b" ).Replace("\f", "\\f" )
|
||||
.Replace("\n", "\\n" ).Replace("\r", "\\r").Replace("\t", "\\t" ) + "\"");
|
||||
|
||||
private void WriteNil() => _IO.Write("null");
|
||||
private void WriteArr(bool End = false) => _IO.Write(End ? "]" : "[");
|
||||
private void WriteMap(bool End = false) => _IO.Write(End ? "}" : "{");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using KKdMainLib.IO;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib.MessagePack
|
||||
{
|
||||
public static class MPExt
|
||||
{
|
||||
public static MsgPack ReadMP(this string file, bool JSON = false)
|
||||
{
|
||||
MsgPack MsgPack;
|
||||
if (JSON)
|
||||
{ JSONIO IO = new JSONIO(File.OpenReader(file + ".json"));
|
||||
MsgPack = IO.Read(); IO.Close(); IO = null; }
|
||||
else
|
||||
{ MPIO IO = new MPIO(File.OpenReader(file + ".mp" ));
|
||||
MsgPack = IO.Read(); IO.Close(); IO = null; }
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
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); }
|
||||
|
||||
public static MsgPack Write(this MsgPack mp, string file, bool JSON = false)
|
||||
{
|
||||
if (JSON)
|
||||
{ JSONIO IO = new JSONIO(File.OpenWriter(file + ".json", true));
|
||||
IO.Write(mp, true, true); IO = null; }
|
||||
else
|
||||
{ MPIO IO = new MPIO(File.OpenWriter(file + ".mp" , true));
|
||||
IO.Write(mp, true ); IO = null; }
|
||||
return mp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KKdMainLib.MessagePack
|
||||
{
|
||||
public class MsgPack
|
||||
public class MsgPack : IDisposable
|
||||
{
|
||||
public Types Type;
|
||||
public string Name;
|
||||
@@ -15,6 +16,30 @@ 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)
|
||||
{
|
||||
switch (Object)
|
||||
{
|
||||
case List<object> val: Type = Types. Map32; break;
|
||||
case object[] val: Type = Types. Arr32; break;
|
||||
case MsgPack val: Type = Types. Map32; break;
|
||||
case byte[] val: Type = Types. Bin32; break;
|
||||
case bool val: Type = val ? Types.True : Types.False; break;
|
||||
case sbyte val: Type = Types. Int8 ; break;
|
||||
case byte val: Type = Types. UInt8 ; break;
|
||||
case short val: Type = Types. Int16; break;
|
||||
case ushort val: Type = Types. UInt16; break;
|
||||
case int val: Type = Types. Int32; break;
|
||||
case uint val: Type = Types. UInt32; break;
|
||||
case long val: Type = Types. Int64; break;
|
||||
case ulong val: Type = Types. UInt64; break;
|
||||
case float val: Type = Types.Float32; break;
|
||||
case double val: Type = Types.Float64; break;
|
||||
case string val: Type = Types. Str32; break;
|
||||
case Ext val: Type = Types. Ext32; break;
|
||||
}
|
||||
this.Name = Name; this.Object = Object;
|
||||
}
|
||||
|
||||
public static MsgPack Null => null;
|
||||
|
||||
@@ -30,12 +55,22 @@ namespace KKdMainLib.MessagePack
|
||||
|
||||
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; }
|
||||
|
||||
public void Dispose()
|
||||
{ Type = 0; Name = null; Object = null; }
|
||||
|
||||
public MsgPack Add( sbyte? val) => Add(null, val);
|
||||
public MsgPack Add( byte? val) => Add(null, val);
|
||||
public MsgPack Add( short? val) => Add(null, val);
|
||||
@@ -247,6 +282,23 @@ namespace KKdMainLib.MessagePack
|
||||
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;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum Types : byte
|
||||
{
|
||||
PosInt = 0b00000000,
|
||||
|
||||
+20
-2
@@ -28,7 +28,11 @@ namespace KKdMainLib
|
||||
return POF;
|
||||
}
|
||||
public static Stream GetOffset(this Stream stream, ref POF POF)
|
||||
{if (stream.Format > Main.Format.F) POF.POFOffsets.Add(stream.Position - (stream.IsX ? stream.Offset : 0x00)); return stream; }
|
||||
{
|
||||
if (POF != null) if (stream.Format > Main.Format.F)
|
||||
POF.POFOffsets.Add(stream.Position - (stream.IsX ? stream.Offset : 0x00));
|
||||
return stream;
|
||||
}
|
||||
|
||||
public static void ReadPOF(this Stream stream, ref POF POF)
|
||||
{
|
||||
@@ -108,6 +112,20 @@ namespace KKdMainLib
|
||||
stream.Align(16, true);
|
||||
stream.WriteEOFC(ID);
|
||||
}
|
||||
|
||||
|
||||
public static long ReadUInt32Endian(this Stream IO, ref POF POF) =>
|
||||
IO.GetOffset(ref POF).ReadUInt32Endian();
|
||||
public static long ReadUInt32Endian(this Stream IO, ref POF POF, bool IsBE) =>
|
||||
IO.GetOffset(ref POF).ReadUInt32Endian(IsBE);
|
||||
public static long ReadInt64(this Stream IO, ref POF POF) =>
|
||||
IO.GetOffset(ref POF).ReadInt64();
|
||||
|
||||
public static long ReadIntX(this Stream IO, ref POF POF ) =>
|
||||
IO.IsX ? IO.ReadInt64() : IO.ReadUInt32Endian( );
|
||||
public static long ReadIntX(this Stream IO, ref POF POF, bool IsBE) =>
|
||||
IO.IsX ? IO.ReadInt64() : IO.ReadUInt32Endian(IsBE);
|
||||
|
||||
public static string ReadStringAtOffset(this Stream IO, ref POF POF, long Offset = 0, long Length = 0) =>
|
||||
IO.GetOffset(ref POF).ReadStringAtOffset(Offset, Length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.8")]
|
||||
[assembly: AssemblyFileVersion("0.4.5.8")]
|
||||
[assembly: AssemblyVersion("0.4.5.9")]
|
||||
[assembly: AssemblyFileVersion("0.4.5.9")]
|
||||
|
||||
+23
-38
@@ -17,9 +17,8 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
public STR()
|
||||
{ Count = 0; Offset = 0; OffsetX = 0; STRs = null; POF = null; Header = new PDHead(); }
|
||||
|
||||
public long Count;
|
||||
{ Offset = 0; OffsetX = 0; STRs = null; POF = null; Header = new PDHead(); }
|
||||
|
||||
private long Offset;
|
||||
private long OffsetX;
|
||||
public String[] STRs;
|
||||
@@ -39,7 +38,7 @@ namespace KKdMainLib
|
||||
POF = Header.AddPOF();
|
||||
reader.Position = Header.Lenght;
|
||||
|
||||
Count = reader.ReadInt32Endian();
|
||||
long Count = reader.ReadInt32Endian();
|
||||
Offset = reader.ReadInt32Endian();
|
||||
|
||||
if (Offset == 0)
|
||||
@@ -72,7 +71,7 @@ namespace KKdMainLib
|
||||
else
|
||||
{
|
||||
reader.Position -= 4;
|
||||
Count = 0;
|
||||
int Count = 0;
|
||||
for (int a = 0, i = 0; reader.Position > 0 && reader.Position < reader.Length; i++, Count++)
|
||||
{
|
||||
a = reader.ReadInt32();
|
||||
@@ -102,6 +101,7 @@ namespace KKdMainLib
|
||||
POF = new POF();
|
||||
writer.IsBE = writer.Format == Main.Format.F2BE;
|
||||
|
||||
long Count = STRs.LongLength;
|
||||
if (writer.Format > Main.Format.FT)
|
||||
{
|
||||
writer.Position = 0x40;
|
||||
@@ -172,56 +172,41 @@ namespace KKdMainLib
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string filepath)
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
//STRs = new List<String>();
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
|
||||
Xml Xml = new Xml();
|
||||
Xml.OpenXml(filepath + ".xml", true);
|
||||
Xml.Compact = true;
|
||||
int i = 0;
|
||||
foreach (XElement STR_ in Xml.doc.Elements("STR"))
|
||||
if (MsgPack.Element("STR", out MsgPack STR))
|
||||
{
|
||||
foreach (XAttribute Entry in STR_.Attributes())
|
||||
if (Entry.Name == "Format")
|
||||
Enum.TryParse(Entry.Value, out Header.Format);
|
||||
foreach (XElement STREntry in STR_.Elements())
|
||||
if (STR.Element("Strings", out MsgPack Strings, typeof(object[])))
|
||||
{
|
||||
if (STREntry.Name == "STREntry")
|
||||
{
|
||||
String Str = new String();
|
||||
foreach (XAttribute Entry in STREntry.Attributes())
|
||||
STRs = new String[((object[])Strings.Object).Length];
|
||||
MsgPack String;
|
||||
for (int i = 0; i < STRs.Length; i++)
|
||||
if (Strings[i].GetType() == typeof(MsgPack))
|
||||
{
|
||||
if (Entry.Name == "ID" ) Str.ID = int.Parse(Entry.Value);
|
||||
if (Entry.Name == "String") Str.Str = Entry.Value ;
|
||||
String = (MsgPack)Strings[i];
|
||||
STRs[i].ID = String.ReadInt32 ("ID" );
|
||||
STRs[i].Str = String.ReadString("Str");
|
||||
}
|
||||
//STRs.Add(Str);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Count = i;
|
||||
MsgPack = null;
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string filepath)
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
MsgPack STR_ = new MsgPack("STR").Add("Format", Header.Format.ToString()).Add("Count", Count);
|
||||
MsgPack Strings = new MsgPack("Strings", Count);
|
||||
for (int i = 0; i < Count; i++)
|
||||
MsgPack STR_ = new MsgPack("STR").Add("Format", Header.Format.ToString());
|
||||
MsgPack Strings = new MsgPack("Strings", STRs.Length);
|
||||
for (int i = 0; i < STRs.Length; i++)
|
||||
{
|
||||
Strings[i] = new MsgPack().Add("ID", STRs[i].ID);
|
||||
if (STRs[i].Str != null)
|
||||
if (STRs[i].Str != "")
|
||||
if (STRs[i].Str != null) if (STRs[i].Str != "")
|
||||
((MsgPack)Strings[i]).Add("S", STRs[i].Str); ;
|
||||
}
|
||||
STR_.Add(Strings);
|
||||
|
||||
MsgPack MsgPack = new MsgPack(MsgPack.Types.FixMap).Add(STR_);
|
||||
|
||||
MPIO IO = new MPIO(File.OpenWriter(filepath + ".mp", true));
|
||||
IO.Write(MsgPack, true);
|
||||
IO = null;
|
||||
MsgPack = null;
|
||||
STR_.Write(true, file, JSON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib.Types
|
||||
{
|
||||
public class Vector2<T>
|
||||
{
|
||||
public T X;
|
||||
public T Y;
|
||||
public T Z;
|
||||
|
||||
public Vector2()
|
||||
{ X = default(T); Y = default(T); Z = default(T); }
|
||||
|
||||
public Vector2(T X, T Y, T Z)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib.Types
|
||||
{
|
||||
public class Vector3<T>
|
||||
{
|
||||
public T X;
|
||||
public T Y;
|
||||
public T Z;
|
||||
|
||||
public Vector3()
|
||||
{ X = default(T); Y = default(T); Z = default(T); }
|
||||
|
||||
public Vector3(T X, T Y, T Z)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; }
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,6 +1,5 @@
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using MSIO = System.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
{
|
||||
@@ -16,7 +15,7 @@ namespace KKdSoundLib
|
||||
|
||||
public void DIVAReader(bool ToArray = false)
|
||||
{
|
||||
if (MSIO.File.Exists(file + ".diva"))
|
||||
if (File.Exists(file + ".diva"))
|
||||
{
|
||||
Data = new DIVAFile();
|
||||
Stream reader = File.OpenReader(file + ".diva");
|
||||
@@ -77,7 +76,7 @@ namespace KKdSoundLib
|
||||
|
||||
public void DIVAWriter()
|
||||
{
|
||||
if (MSIO.File.Exists(file + ".wav"))
|
||||
if (File.Exists(file + ".wav"))
|
||||
{
|
||||
Stream reader = File.OpenReader(file + ".wav");
|
||||
Stream writer = File.OpenWriter(file + ".diva", true);
|
||||
@@ -106,7 +105,8 @@ namespace KKdSoundLib
|
||||
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]);
|
||||
value = IMAEncoder(samplePtr[c], ref currentPtr[c],
|
||||
ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
writer.Write(value, 4);
|
||||
}
|
||||
writer.CheckWrited();
|
||||
|
||||
@@ -70,7 +70,9 @@ namespace KKdSoundLib
|
||||
else IO.Write(Header.Size + 0x3C);
|
||||
IO.Write("WAVE");
|
||||
IO.Write("fmt ");
|
||||
IO.Write(0x10);
|
||||
if (Header.Format != 0xFFFE) IO.Write(0x10);
|
||||
else IO.Write(0x28);
|
||||
|
||||
IO.Write(Header.Format);
|
||||
IO.Write((short)Header.Channels);
|
||||
IO.Write(Header.SampleRate);
|
||||
|
||||
@@ -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.1")]
|
||||
[assembly: AssemblyFileVersion("0.0.2.1")]
|
||||
[assembly: AssemblyVersion("0.0.2.2")]
|
||||
[assembly: AssemblyFileVersion("0.0.2.2")]
|
||||
|
||||
+4
-5
@@ -1,6 +1,5 @@
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using MSIO = System.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
{
|
||||
@@ -26,7 +25,7 @@ namespace KKdSoundLib
|
||||
|
||||
public void VAGReader()
|
||||
{
|
||||
if (!MSIO.File.Exists(file + ".vag")) return;
|
||||
if (!File.Exists(file + ".vag")) return;
|
||||
|
||||
VAGData = new VAGFile();
|
||||
Stream reader = File.OpenReader(file + ".vag", true);
|
||||
@@ -337,12 +336,12 @@ namespace KKdSoundLib
|
||||
new System.Collections.Generic.List< bool>();
|
||||
while (true)
|
||||
{
|
||||
if (MSIO.File.Exists(file + "." + i2 + ".wav"))
|
||||
if (File.Exists(file + "." + i2 + ".wav"))
|
||||
{
|
||||
files.Add(file + "." + i2 + ".wav");
|
||||
loop.Add(false);
|
||||
}
|
||||
else if (MSIO.File.Exists(file + "." + i2 + ".loop.wav"))
|
||||
else if (File.Exists(file + "." + i2 + ".loop.wav"))
|
||||
{
|
||||
files.Add(file + "." + i2 + ".loop.wav");
|
||||
loop.Add(true);
|
||||
@@ -436,7 +435,7 @@ namespace KKdSoundLib
|
||||
|
||||
public void VAGWriter(bool HEVAG = true)
|
||||
{
|
||||
VAGData.Name = MSIO.Path.GetFileName(file);
|
||||
VAGData.Name = Path.GetFileName(file);
|
||||
Stream writer = File.OpenWriter(file + ".vag", true);
|
||||
Samp1 = new int[ch]; S1Ptr = Samp1.GetPtr();
|
||||
Samp2 = new int[ch]; S2Ptr = Samp2.GetPtr();
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="classes\DataBase.cs" />
|
||||
<Compile Include="classes\Tools\A3D.cs" />
|
||||
<Compile Include="classes\Tools\DB.cs" />
|
||||
<Compile Include="classes\Tools\DEX.cs" />
|
||||
<Compile Include="classes\Tools\DIV.cs" />
|
||||
<Compile Include="classes\Tools\STR.cs" />
|
||||
|
||||
+22
-18
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
using MSIO = System.IO;
|
||||
using KKdMain = KKdMainLib.Main;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
@@ -16,7 +15,7 @@ namespace PD_Tool
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.Title = "PD_Tool";
|
||||
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
while (function != "Q") MainMenu();
|
||||
@@ -30,9 +29,9 @@ namespace PD_Tool
|
||||
foreach (string arg in args)
|
||||
{
|
||||
Farc = new KKdFARC();
|
||||
if (MSIO.Directory.Exists(arg)) Farc.Pack(arg);
|
||||
else if (MSIO.File.Exists(arg) && MSIO.Path.GetExtension(arg) == ".farc") Farc.UnPack(arg, true);
|
||||
else if (MSIO.File.Exists(arg))
|
||||
if (Directory.Exists(arg)) Farc.Pack(arg);
|
||||
else if (File.Exists(arg) && Path.GetExtension(arg) == ".farc") Farc.UnPack(arg, true);
|
||||
else if (File.Exists(arg))
|
||||
{
|
||||
reader = File.OpenReader(arg);
|
||||
header = reader.ReadString(8);
|
||||
@@ -43,6 +42,8 @@ namespace PD_Tool
|
||||
Exit();
|
||||
}
|
||||
|
||||
private static bool JSON = false;
|
||||
|
||||
private static void MainMenu()
|
||||
{
|
||||
Console.Title = "PD_Tool";
|
||||
@@ -58,6 +59,7 @@ namespace PD_Tool
|
||||
KKdMain.ConsoleDesign("5. DB_Tools");
|
||||
KKdMain.ConsoleDesign("6. Converting Tools");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign(JSON ? "M. MessagePack" : "J. JSON");
|
||||
KKdMain.ConsoleDesign("Q. Quit");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign(true);
|
||||
@@ -66,19 +68,20 @@ namespace PD_Tool
|
||||
function = Console.ReadLine().ToUpper();
|
||||
bool isNumber = int.TryParse(function, out int result);
|
||||
if (isNumber) Functions();
|
||||
if (function == "M") JSON = false;
|
||||
else if (function == "J") JSON = true ;
|
||||
}
|
||||
|
||||
private static void Functions()
|
||||
{
|
||||
Console.Clear();
|
||||
if (function == "1" || function == "2")
|
||||
FARC.Processor(function == "1");
|
||||
if (function == "1" || function == "2") FARC.Processor(function == "1");
|
||||
else if (function == "3" || function == "4")
|
||||
{
|
||||
KKdMain.Choose(1, "", out string[] FileNames);
|
||||
foreach (string FileName in FileNames) DIVAFILE.Decrypt(FileName);
|
||||
}
|
||||
else if (function == "5") DataBase.Processor();
|
||||
else if (function == "5") DataBase.Processor(JSON);
|
||||
else if (function == "6")
|
||||
{
|
||||
Console.Clear();
|
||||
@@ -86,24 +89,25 @@ namespace PD_Tool
|
||||
KKdMain.ConsoleDesign(true);
|
||||
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("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(false);
|
||||
KKdMain.ConsoleDesign("R. Return to Main Menu");
|
||||
KKdMain.ConsoleDesign("Q. Quit");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string Function = Console.ReadLine();
|
||||
Console.Clear();
|
||||
if (Function == "1") Tools.A3D.Processor();
|
||||
else if (Function == "2") Tools.DEX.Processor();
|
||||
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();
|
||||
else if (Function == "4") Tools.STR.Processor(JSON);
|
||||
else if (Function == "5") Tools.VAG.Processor();
|
||||
else if (Function == "6") Tools.DB .Processor();
|
||||
else function = Function;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.7")]
|
||||
[assembly: AssemblyFileVersion("0.4.5.7")]
|
||||
[assembly: AssemblyVersion("0.4.5.9")]
|
||||
[assembly: AssemblyFileVersion("0.4.5.9")]
|
||||
|
||||
+74
-10
@@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.DB;
|
||||
using DB = KKdMainLib.DB;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public class DataBase
|
||||
{
|
||||
public static void Processor()
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "DB Converter";
|
||||
Console.Clear();
|
||||
@@ -15,17 +15,23 @@ namespace PD_Tool
|
||||
Main.ConsoleDesign(" Choose type of DataBase file:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. Auth DB Converter");
|
||||
Main.ConsoleDesign("2. AET DB Converter");
|
||||
Main.ConsoleDesign("3. SPR DB Converter");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("R. Return to Main Menu");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string format = Console.ReadLine();
|
||||
if (format == "1") AuthDBProcessor();
|
||||
if (format == "1") AuthDBProcessor(JSON);
|
||||
if (format == "2") AETDBProcessor(JSON);
|
||||
if (format == "3") SPRDBProcessor(JSON);
|
||||
}
|
||||
|
||||
public static void AuthDBProcessor()
|
||||
public static void AuthDBProcessor(bool JSON)
|
||||
{
|
||||
Console.Title = "Auth DB Converter";
|
||||
Auth Auth = new Auth();
|
||||
DB.Auth Auth;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
@@ -33,22 +39,80 @@ namespace PD_Tool
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
Console.Title = "Auth: DB Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
Auth = new Auth();
|
||||
Console.Title = "Auth DB Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
Auth = new DB.Auth();
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
|
||||
if (ext == ".bin")
|
||||
{
|
||||
Auth.BINReader (filepath);
|
||||
Auth.MsgPackWriter(filepath);
|
||||
Auth.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
else if (ext == ".mp")
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
Auth.MsgPackReader(filepath);
|
||||
Auth.MsgPackReader(filepath, ext == ".json");
|
||||
Auth.BINWriter (filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void AETDBProcessor(bool JSON)
|
||||
{
|
||||
Console.Title = "AET DB Converter";
|
||||
DB.Aet Aet;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
Console.Title = "AET DB Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
Aet = new DB.Aet();
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
|
||||
if (ext == ".bin")
|
||||
{
|
||||
Aet.BINReader (filepath);
|
||||
Aet.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
Aet.MsgPackReader(filepath, ext == ".json");
|
||||
Aet.BINWriter (filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SPRDBProcessor(bool JSON)
|
||||
{
|
||||
Console.Title = "SPR DB Converter";
|
||||
DB.Spr Spr;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
Console.Title = "SPR DB Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
Spr = new DB.Spr();
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
|
||||
if (ext == ".bin")
|
||||
{
|
||||
Spr.BINReader (filepath);
|
||||
Spr.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
Spr.MsgPackReader(filepath, ext == ".json");
|
||||
Spr.BINWriter (filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using MSIO = System.IO;
|
||||
using KKdA3DA = KKdMainLib.A3DA.A3DA;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
class A3D
|
||||
{
|
||||
public static void Processor()
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "A3DA Converter";
|
||||
Main.Choose(1, "a3da", out string[] FileNames);
|
||||
@@ -50,20 +49,19 @@ namespace PD_Tool.Tools
|
||||
foreach (string file in FileNames)
|
||||
try
|
||||
{
|
||||
ext = MSIO.Path.GetExtension(file);
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
Console.Title = "A3DA Converter: " +
|
||||
MSIO.Path.GetFileNameWithoutExtension(file);
|
||||
Console.Title = "A3DA Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
A = new KKdA3DA();
|
||||
if (ext == ".a3da")
|
||||
{
|
||||
A.A3DAReader (filepath);
|
||||
A.MsgPackWriter(filepath);
|
||||
A.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
else if (ext == ".mp" )
|
||||
{
|
||||
A.MsgPackReader(filepath);
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
public class DB
|
||||
{
|
||||
public static void Processor()
|
||||
{
|
||||
Console.Title = "DataBank Converter";
|
||||
Main.Choose(1, "databank", out string[] FileNames);
|
||||
|
||||
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); }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using MSIO = System.IO;
|
||||
using KKdMainLib.IO;
|
||||
using KKdDEX = KKdMainLib.DEX;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
public class DEX
|
||||
{
|
||||
public static void Processor()
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "DEX Converter";
|
||||
KKdDEX DEX;
|
||||
@@ -45,16 +45,16 @@ namespace PD_Tool.Tools
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
DEX = new KKdDEX();
|
||||
ext = MSIO.Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(MSIO.Path.GetExtension(file), "");
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
|
||||
if (ext == ".bin" || ext == ".dex")
|
||||
DEX.DEXReader(filepath, ext);
|
||||
else DEX.MsgPackReader(filepath);
|
||||
else DEX.MsgPackReader(filepath, JSON);
|
||||
|
||||
if (Format > Main.Format.NULL)
|
||||
DEX.DEXWriter(filepath, Format);
|
||||
else DEX.MsgPackWriter(filepath);
|
||||
else DEX.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using MSIO = System.IO;
|
||||
using KKdMainLib.IO;
|
||||
using KKdSTR = KKdMainLib.STR;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
public class STR
|
||||
{
|
||||
public static void Processor()
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "STR Converter";
|
||||
Main.Choose(1, "str", out string[] FileNames);
|
||||
@@ -17,20 +17,20 @@ namespace PD_Tool.Tools
|
||||
string ext = "";
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
filepath = file.Replace(MSIO.Path.GetExtension(file), "");
|
||||
ext = MSIO.Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
Data = new KKdSTR();
|
||||
|
||||
Console.Title = "PD_Tool: Converter Tools: STR Reader: " +
|
||||
MSIO.Path.GetFileNameWithoutExtension(file);
|
||||
Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".str" || ext == ".bin")
|
||||
{
|
||||
Data.STRReader (filepath, ext);
|
||||
Data.MsgPackWriter(filepath);
|
||||
Data.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
else if (ext == ".mp")
|
||||
{
|
||||
Data.MsgPackReader(filepath);
|
||||
Data.MsgPackReader(filepath, JSON);
|
||||
Data.STRWriter (filepath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace PD_Tool.Tools
|
||||
Main.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string format = Console.ReadLine();
|
||||
HE_VAG = format == "2";
|
||||
HE_VAG = format != "2";
|
||||
}
|
||||
|
||||
KKdVAG VAG;
|
||||
|
||||
Reference in New Issue
Block a user