Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87d4862af5 | ||
|
|
b26cdc8b5c | ||
|
|
6e2f5746b0 |
@@ -1,5 +1,7 @@
|
||||
.vs
|
||||
build
|
||||
KKdBaseLib/bin
|
||||
KKdBaseLib/obj
|
||||
KKdMainLib/bin
|
||||
KKdMainLib/obj
|
||||
KKdMathLib/bin
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
//Original research by Samyuu
|
||||
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public static class DCC //Databank_Checksum_Calculator
|
||||
{
|
||||
@@ -41,14 +39,11 @@ namespace KKdMainLib
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
using System;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public static unsafe class Extensions
|
||||
{
|
||||
private const double RadPi = 180 / Math.PI;
|
||||
public static double ToDegrees(this double val) => val * RadPi;
|
||||
public static double ToRadians(this double val) => val / RadPi;
|
||||
|
||||
public static double Acos (this double d ) => Math.Acos (d );
|
||||
public static double Asin (this double d ) => Math.Asin (d );
|
||||
public static double Atan (this double d ) => Math.Atan (d );
|
||||
public static double Aсtg (this double d ) => 1 / Math.Atan (d );
|
||||
public static double Cos (this double d ) => Math.Cos (d );
|
||||
public static double Cosh (this double val) => Math.Cosh (val);
|
||||
public static double Sin (this double a ) => Math.Sin (a );
|
||||
public static double Sinh (this double val) => Math.Sinh (val);
|
||||
public static double Tan (this double a ) => Math.Tan (a );
|
||||
public static double Tanh (this double val) => Math.Tanh (val);
|
||||
public static double Ctg (this double a ) => 1 / Math.Tan (a );
|
||||
public static double Ctgh (this double val) => 1 / Math.Tanh (val);
|
||||
|
||||
public static double Abs (this double val) => Math.Abs (val);
|
||||
public static double Ceiling(this double a ) => Math.Ceiling(a );
|
||||
public static double Exp (this double d ) => Math.Exp (d );
|
||||
public static double Log (this double d ) => Math.Log (d );
|
||||
public static double Log10 (this double d ) => Math.Log10 (d );
|
||||
public static double Round (this double d ) => Math.Round (d );
|
||||
public static int Sign (this double val) => Math.Sign (val);
|
||||
public static double Sqrt (this double d ) => Math.Sqrt (d );
|
||||
|
||||
|
||||
public static double Atan2(this double y , double x ) => Math.Atan2(y , x );
|
||||
public static double Log (this double val , double newBase) => Math.Log (val , newBase);
|
||||
public static double Max (this double val1, double val2 ) => Math.Max (val1, val2 );
|
||||
public static double Min (this double val1, double val2 ) => Math.Min (val1, val2 );
|
||||
public static double Pow (this double x , double y ) => Math.Pow (x , y );
|
||||
public static double Round(this double val , int d ) => Math.Round(val , d );
|
||||
|
||||
public static float ToDegrees(this float val) => (float)(val * RadPi);
|
||||
public static float ToRadians(this float val) => (float)(val / RadPi);
|
||||
|
||||
public static float Acos (this float d ) => (float) Math.Acos (d ) ;
|
||||
public static float Asin (this float d ) => (float) Math.Asin (d ) ;
|
||||
public static float Atan (this float d ) => (float) Math.Atan (d ) ;
|
||||
public static float Aсtg (this float d ) => (float)(1 / Math.Atan (d ));
|
||||
public static float Cos (this float d ) => (float) Math.Cos (d ) ;
|
||||
public static float Cosh (this float val) => (float) Math.Cosh (val) ;
|
||||
public static float Sin (this float a ) => (float) Math.Sin (a ) ;
|
||||
public static float Sinh (this float val) => (float) Math.Sinh (val) ;
|
||||
public static float Tan (this float a ) => (float) Math.Tan (a ) ;
|
||||
public static float Tanh (this float val) => (float) Math.Tanh (val) ;
|
||||
public static float Ctg (this float a ) => (float)(1 / Math.Tan (a ));
|
||||
public static float Ctgh (this float val) => (float)(1 / Math.Tanh (val));
|
||||
|
||||
public static float Abs (this float val) => Math.Abs (val) ;
|
||||
public static float Ceiling(this float a ) => (float) Math.Ceiling(a ) ;
|
||||
public static float Exp (this float d ) => (float) Math.Exp (d ) ;
|
||||
public static float Log (this float d ) => (float) Math.Log (d ) ;
|
||||
public static float Log10 (this float d ) => (float) Math.Log10 (d ) ;
|
||||
public static float Round (this float d ) => (float) Math.Round (d ) ;
|
||||
public static float Sqrt (this float d ) => (float) Math.Sqrt (d ) ;
|
||||
|
||||
|
||||
public static float Atan2(this float y , float x ) => (float)Math.Atan2(y , x );
|
||||
public static float Log (this float val , float newBase) => (float)Math.Log (val , newBase);
|
||||
public static float Max (this float val1, float val2 ) => Math.Max (val1, val2 );
|
||||
public static float Min (this float val1, float val2 ) => Math.Min (val1, val2 );
|
||||
public static float Pow (this float x , float y ) => (float)Math.Pow (x , y );
|
||||
public static float Round(this float val , int d ) => (float)Math.Round(val , d );
|
||||
|
||||
public static void FloorCeiling( ref double Value) =>
|
||||
Value = Value % 1 >= 0.5 ? (long)(Value + 0.5) : (long) Value;
|
||||
|
||||
public static long FloorCeiling(this double Value) =>
|
||||
Value % 1 >= 0.5 ? (long)(Value + 0.5) : (long) Value;
|
||||
|
||||
public static int Align(this int value, int alignement, int divide = 1) =>
|
||||
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
|
||||
|
||||
public static uint Align(this uint value, uint alignement, uint divide = 1) =>
|
||||
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
|
||||
|
||||
public static long Align(this long value, long alignement, long divide = 1) =>
|
||||
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
|
||||
|
||||
public static ulong Align(this ulong value, ulong alignement, ulong divide = 1) =>
|
||||
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
|
||||
|
||||
public static byte[] buf = new byte[8];
|
||||
public static byte* bufPtr = buf.GetPtr();
|
||||
|
||||
public static long Endian(this long LE, byte Len, bool IsBE)
|
||||
{ if (IsBE) { for (byte i = 0; i < Len; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < Len; i++) { LE |= bufPtr[i]; if (i < Len - 1) LE <<= 8; } } return LE; }
|
||||
|
||||
public static ulong Endian(this ulong LE, byte Len, bool IsBE)
|
||||
{ if (IsBE) { for (byte i = 0; i < Len; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < Len; i++) { LE |= bufPtr[i]; if (i < Len - 1) LE <<= 8; } } return LE; }
|
||||
|
||||
public static sbyte CITSB(this int c)
|
||||
{ if (c > 0x0000007F) c = 0x0000007F;
|
||||
else if (c < -0x00000080) c = -0x00000080; return ( sbyte)c; }
|
||||
|
||||
public static byte CITB (this int c)
|
||||
{ if (c > 0x000000FF) c = 0x000000FF;
|
||||
else if (c < 0x00000000) c = 0x00000000; return ( byte)c; }
|
||||
|
||||
public static short CITS (this int c)
|
||||
{ if (c > 0x00007FFF) c = 0x00007FFF;
|
||||
else if (c < -0x00008000) c = -0x00008000; return ( short)c; }
|
||||
|
||||
public static ushort CITUS(this int c)
|
||||
{ if (c > 0x0000FFFF) c = 0x0000FFFF;
|
||||
else if (c < 0x00000000) c = 0x00000000; return (ushort)c; }
|
||||
|
||||
public static sbyte CFTSB(this float c)
|
||||
{ c = c.Round(); if (c > 0x0000007F) c = 0x0000007F;
|
||||
else if (c < -0x00000080) c = -0x00000080; return ( sbyte)c; }
|
||||
|
||||
public static byte CFTB (this float c)
|
||||
{ c = c.Round(); if (c > 0x000000FF) c = 0x000000FF;
|
||||
else if (c < 0x00000000) c = 0x00000000; return ( byte)c; }
|
||||
|
||||
public static short CFTS (this float c)
|
||||
{ c = c.Round(); if (c > 0x00007FFF) c = 0x00007FFF;
|
||||
else if (c < -0x00008000) c = -0x00008000; return ( short)c; }
|
||||
|
||||
public static ushort CFTUS(this float c)
|
||||
{ c = c.Round(); if (c > 0x0000FFFF) c = 0x0000FFFF;
|
||||
else if (c < 0x00000000) c = 0x00000000; return (ushort)c; }
|
||||
|
||||
public static int CFTI (this float c)
|
||||
{ c = c.Round(); return ( int)c; }
|
||||
|
||||
public static uint CFTUI(this float c)
|
||||
{ c = c.Round(); return ( uint)c; }
|
||||
|
||||
public static sbyte CFTSB(this double c)
|
||||
{ c = c.Round(); if (c > 0x0000007F) c = 0x0000007F;
|
||||
else if (c < -0x00000080) c = -0x00000080; return ( sbyte)c; }
|
||||
|
||||
public static byte CFTB (this double c)
|
||||
{ c = c.Round(); if (c > 0x000000FF) c = 0x000000FF;
|
||||
else if (c < 0x00000000) c = 0x00000000; return ( byte)c; }
|
||||
|
||||
public static short CFTS (this double c)
|
||||
{ c = c.Round(); if (c > 0x00007FFF) c = 0x00007FFF;
|
||||
else if (c < -0x00008000) c = -0x00008000; return ( short)c; }
|
||||
|
||||
public static ushort CFTUS(this double c)
|
||||
{ c = c.Round(); if (c > 0x0000FFFF) c = 0x0000FFFF;
|
||||
else if (c < 0x00000000) c = 0x00000000; return (ushort)c; }
|
||||
|
||||
public static int CFTI (this double c)
|
||||
{ c = c.Round(); if (c > 0x7FFFFFFF) c = 0x7FFFFFFF;
|
||||
else if (c < -0x80000000) c = -0x80000000; return ( int)c; }
|
||||
|
||||
public static uint CFTUI(this double c)
|
||||
{ c = c.Round(); if (c > 0xFFFFFFFF) c = 0xFFFFFFFF;
|
||||
else if (c < 0x00000000) c = 0x00000000; return ( uint)c; }
|
||||
|
||||
public static int ToInt32(this float f) => *( int*)&f;
|
||||
public static uint ToUInt32(this float f) => *( uint*)&f;
|
||||
public static long ToInt64(this double f) => *( long*)&f;
|
||||
public static ulong ToUInt64(this double f) => *(ulong*)&f;
|
||||
|
||||
public static float ToSingle(this int i) => *( float*)&i;
|
||||
public static float ToSingle(this uint i) => *( float*)&i;
|
||||
public static double ToSingle(this long i) => *(double*)&i;
|
||||
public static double ToSingle(this ulong i) => *(double*)&i;
|
||||
|
||||
public static sbyte* GetPtr(this sbyte[] array) { fixed ( sbyte* tempPtr = array) return tempPtr; }
|
||||
public static byte* GetPtr(this byte[] array) { fixed ( byte* tempPtr = array) return tempPtr; }
|
||||
public static short* GetPtr(this short[] array) { fixed ( short* tempPtr = array) return tempPtr; }
|
||||
public static ushort* GetPtr(this ushort[] array) { fixed (ushort* tempPtr = array) return tempPtr; }
|
||||
public static int* GetPtr(this int[] array) { fixed ( int* tempPtr = array) return tempPtr; }
|
||||
public static uint* GetPtr(this uint[] array) { fixed ( uint* tempPtr = array) return tempPtr; }
|
||||
public static long* GetPtr(this long[] array) { fixed ( long* tempPtr = array) return tempPtr; }
|
||||
public static ulong* GetPtr(this ulong[] array) { fixed ( ulong* tempPtr = array) return tempPtr; }
|
||||
public static float* GetPtr(this float[] array) { fixed ( float* tempPtr = array) return tempPtr; }
|
||||
public static double* GetPtr(this double[] array) { fixed (double* tempPtr = array) return tempPtr; }
|
||||
|
||||
public static string ToString(this int d, bool IsBE) =>
|
||||
BitConverter.GetBytes((int)((long)d).Endian(4, IsBE)).ToASCII();
|
||||
|
||||
public static string ToString(this object d)
|
||||
{
|
||||
if (d == null) return "Null";
|
||||
else if (d is bool Boolean) return Boolean ? "true" : "false";
|
||||
else if (d is float F32 ) return ToString(F32);
|
||||
else if (d is double F64 ) return ToString(F64);
|
||||
return d.ToString();
|
||||
}
|
||||
|
||||
private static readonly string NumberDecimalSeparator =
|
||||
System.Globalization.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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct ENRS
|
||||
{
|
||||
public int Offset;
|
||||
public int Count;
|
||||
public int Size;
|
||||
public int Repeat;
|
||||
public SubENRS[] Sub;
|
||||
|
||||
public static unsafe ENRS[] Read(byte[] data)
|
||||
{
|
||||
byte* ptr = data.GetPtr();
|
||||
int i, i0;
|
||||
int ENRSCount = ((int*)ptr)[1];
|
||||
ENRS[] ENRSArr = new ENRS[ENRSCount];
|
||||
ptr += 0x10;
|
||||
|
||||
ENRS ENR = new ENRS();
|
||||
for (i = 0; i < ENRSCount; i++)
|
||||
{
|
||||
ENR.Offset = ReadENRSValue(ref ptr) + ENR.Offset;
|
||||
ENR.Count = ReadENRSValue(ref ptr);
|
||||
ENR.Size = ReadENRSValue(ref ptr);
|
||||
ENR.Repeat = ReadENRSValue(ref ptr);
|
||||
|
||||
if (ENR.Repeat > 0)
|
||||
{
|
||||
ENR.Sub = new SubENRS[ENR.Count];
|
||||
for (i0 = 0; i0 < ENR.Count; i0++)
|
||||
{
|
||||
ENR.Sub[i0].Skip = ReadENRSValue(ref ptr, out ENR.Sub[i0].Type);
|
||||
ENR.Sub[i0].Reverse = ReadENRSValue(ref ptr);
|
||||
|
||||
if (ENR.Sub[i0].Type == Type.Invalid) return null;
|
||||
|
||||
if (i0 > 0) ENR.Sub[i0].Skip += ENR.Sub[i0 - 1].Skip + ENR.Sub[i0 - 1].Reverse *
|
||||
((ENR.Sub[i0].Type == Type.WORD) ? 2 : (ENR.Sub[i0].Type == Type.DWORD) ? 4 : 8);
|
||||
}
|
||||
}
|
||||
else ENR.Sub = null;
|
||||
ENRSArr[i] = ENR;
|
||||
}
|
||||
return ENRSArr;
|
||||
}
|
||||
|
||||
private static unsafe int ReadENRSValue(ref byte* ptr, out Type Rev)
|
||||
{
|
||||
int V = *ptr & 0xF;
|
||||
Rev = (Type)(*ptr & 0x30);
|
||||
Value Val = (Value)(*ptr & 0xC0);
|
||||
ptr++;
|
||||
if (Val == Value.Int32 )
|
||||
{ V = (V << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; }
|
||||
else if (Val == Value.Int16 )
|
||||
{ V = (V << 8) | ptr[0]; ptr += 1; }
|
||||
else if (Val == Value.Invalid) V = 0;
|
||||
return V;
|
||||
}
|
||||
|
||||
private static unsafe int ReadENRSValue(ref byte* ptr)
|
||||
{
|
||||
int V = *ptr & 0x3F;
|
||||
Value Val = (Value)(*ptr & 0xC0);
|
||||
ptr++;
|
||||
if (Val == Value.Int32 )
|
||||
{ V = (V << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; }
|
||||
else if (Val == Value.Int16 )
|
||||
{ V = (V << 8) | ptr[0]; ptr += 1; }
|
||||
else if (Val == Value.Invalid) V = 0;
|
||||
return V;
|
||||
}
|
||||
|
||||
public enum Type : byte
|
||||
{
|
||||
WORD = 0b00000000,
|
||||
DWORD = 0b00010000,
|
||||
QWORD = 0b00100000,
|
||||
Invalid = 0b00110000,
|
||||
}
|
||||
|
||||
public enum Value : byte
|
||||
{
|
||||
Int8 = 0b00000000,
|
||||
Int16 = 0b01000000,
|
||||
Int32 = 0b10000000,
|
||||
Invalid = 0b11000000,
|
||||
}
|
||||
|
||||
public struct SubENRS
|
||||
{
|
||||
public int Skip;
|
||||
public int Reverse;
|
||||
public Type Type;
|
||||
|
||||
public override string ToString() => "Skip: " + Skip + "; Reverse: " + Reverse + "; Type: " + Type;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
"Offset: " + Offset + "; Count: " + Count + "; " + "Size: " + Size + "; Repeat: " + Repeat;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct Header
|
||||
{
|
||||
public int Signature;
|
||||
public int DataSize;
|
||||
public int Length;
|
||||
public Format Format;
|
||||
public int ID;
|
||||
public int SectionSize;
|
||||
public int SubID;
|
||||
public int InnerSignature;
|
||||
public int SectionSignature;
|
||||
|
||||
public bool IsBE => Format == Format.F2BE;
|
||||
public bool IsX => Format == Format.X || Format == Format.XHD;
|
||||
|
||||
public override string ToString() => Signature.ToString(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct POF
|
||||
{
|
||||
public static unsafe KKdList<long> Read(byte[] data, bool ShiftX)
|
||||
{
|
||||
Value Val = 0;
|
||||
KKdList<long> Offsets = KKdList<long>.New;
|
||||
byte* ptr = data.GetPtr();
|
||||
int i = 0, Offset = 0, V = 0;
|
||||
byte BitShift = (byte)(ShiftX ? 3 : 2);
|
||||
|
||||
int Length = *(int*)ptr - 4; ptr += 4;
|
||||
while (Length > i)
|
||||
{
|
||||
V = *ptr & 0x3F;
|
||||
Val = (Value)(*ptr & 0xC0);
|
||||
ptr++; i++;
|
||||
if (Val == Value.Int32 )
|
||||
{ V = (V << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; i += 3; }
|
||||
else if (Val == Value.Int16 )
|
||||
{ V = (V << 8) | ptr[0]; ptr += 1; i += 3; }
|
||||
else if (Val == Value.Invalid) break;
|
||||
Offset += V;
|
||||
Offsets.Add(Offset << BitShift);
|
||||
}
|
||||
return Offsets;
|
||||
}
|
||||
|
||||
public static unsafe byte[] Write(KKdList<long> Offsets, bool ShiftX)
|
||||
{
|
||||
Offsets.Sort();
|
||||
int Length = 5;
|
||||
long Offset = 0;
|
||||
byte BitShift = (byte)(ShiftX ? 3 : 2);
|
||||
int Max1 = 0x00FF >> BitShift;
|
||||
int Max2 = 0xFFFF >> BitShift;
|
||||
for (int i = 0; i < Offsets.Count; i++)
|
||||
{
|
||||
Offset = Offsets[i];
|
||||
if (i > 0) { Offset -= Offsets[i - 1]; if (Offset == 0) continue; }
|
||||
|
||||
Offset >>= BitShift;
|
||||
if (Offset <= Max1) Length += 1;
|
||||
else if (Offset <= Max2) Length += 2;
|
||||
else Length += 4;
|
||||
}
|
||||
|
||||
byte[] data = new byte[Length.Align(0x10)];
|
||||
byte* ptr = data.GetPtr();
|
||||
|
||||
Value Val = 0;
|
||||
*(int*)ptr = Length; ptr += 4;
|
||||
for (int i = 0; i < Offsets.Count; i++)
|
||||
{
|
||||
Offset = Offsets[i];
|
||||
if (i > 0) { Offset -= Offsets[i - 1]; if (Offset == 0) continue; }
|
||||
|
||||
Offset >>= BitShift;
|
||||
Val = Offset > Max2 ? Value.Int32 : Offset > Max1 ? Value.Int16 : Value.Int8;
|
||||
if (Offset <= Max1) *ptr = (byte)((byte)Val | Offset );
|
||||
else if (Offset <= Max2) { *ptr = (byte)((byte)Val | (Offset >> 8)); ptr++;
|
||||
*ptr = (byte) Offset ; }
|
||||
else { *ptr = (byte)((byte)Val | (Offset >> 24)); ptr++;
|
||||
*ptr = (byte) (Offset >> 16) ; ptr++;
|
||||
*ptr = (byte) (Offset >> 8) ; ptr++;
|
||||
*ptr = (byte) Offset ; }
|
||||
ptr++;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public enum Value : byte
|
||||
{
|
||||
Invalid = 0b00000000,
|
||||
Int8 = 0b01000000,
|
||||
Int16 = 0b10000000,
|
||||
Int32 = 0b11000000,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct Struct
|
||||
{
|
||||
public Header Header;
|
||||
public byte[] Data;
|
||||
public Struct[] SubStructs;
|
||||
public bool EOFC;
|
||||
public ENRS[] ENRS;
|
||||
public KKdList<long> POF;
|
||||
|
||||
public long DataOffset;
|
||||
|
||||
public override string ToString() => Header.ToString() + (SubStructs != null ?
|
||||
"; SubStructs: " + SubStructs.Length : "") + (ENRS != null ? "; Has ENRS" : "") +
|
||||
(POF.NotNull ? "; Has POF" : "") + (EOFC ? "; Has EOFC" : "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public enum Format : byte
|
||||
{
|
||||
NULL = 0,
|
||||
DT = 1,
|
||||
PDA = 2,
|
||||
DT2 = 3,
|
||||
DTe = 4,
|
||||
F = 5,
|
||||
FT = 6,
|
||||
F2LE = 7,
|
||||
F2BE = 8,
|
||||
MGF = 9,
|
||||
X = 10,
|
||||
XHD = 11,
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace KKdMainLib.Types
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Half : IFormattable
|
||||
{
|
||||
@@ -10,6 +10,8 @@ namespace KKdMainLib.Types
|
||||
|
||||
public static explicit operator ushort(Half bits) => bits._value;
|
||||
|
||||
public static explicit operator float(Half h) => (float)(double)h;
|
||||
|
||||
public static explicit operator double(Half h)
|
||||
{
|
||||
if (h._value == 0x0000) return +0;
|
||||
@@ -29,54 +31,51 @@ namespace KKdMainLib.Types
|
||||
return d;
|
||||
}
|
||||
|
||||
public static explicit operator Half( float val) => (Half)(double)val;
|
||||
|
||||
public static explicit operator Half(double val)
|
||||
{
|
||||
Half h = new Half();
|
||||
if (val == +0 ) h._value = 0x0000;
|
||||
else if (val == -0 ) h._value = 0x8000;
|
||||
else if (val == double.NaN ) h._value = 0x7FFF;
|
||||
else if (val == -double.NaN ) h._value = 0xFFFF;
|
||||
else if (val == double.PositiveInfinity) h._value = 0x7C00;
|
||||
else if (val == double.NegativeInfinity) h._value = 0xFC00;
|
||||
else h._value = ToDouble(val);
|
||||
else if (val == double.NaN ) h._value = 0x7FFF;
|
||||
else if (val == -double.NaN ) h._value = 0xFFFF;
|
||||
else
|
||||
{
|
||||
ushort Sign = (ushort)(val < 0 ? 0x8000 : 0);
|
||||
val = Math.Abs(val);
|
||||
double Pow1 = 1;
|
||||
double Pow2 = 1 << 10;
|
||||
double x = 0;
|
||||
|
||||
int MaxPow = (1 << 4);
|
||||
|
||||
int i = 0;
|
||||
while (i < MaxPow && i > -MaxPow + 1)
|
||||
{
|
||||
Pow1 = Math.Pow(2, i);
|
||||
x = val / Pow1;
|
||||
if (x >= 1 && x < 2)
|
||||
{
|
||||
ushort exponent_max = (ushort)Math.Ceiling(x * Pow2);
|
||||
ushort exponent_min = (ushort)Math.Floor (x * Pow2);
|
||||
ushort exponent = Math.Abs(x - exponent_max / Pow2) >
|
||||
Math.Abs(x - exponent_min / Pow2) ? exponent_max : exponent_min;
|
||||
ushort mantissa = (ushort)(i + MaxPow - 1);
|
||||
h._value = (ushort)(Sign | ((mantissa & 0x001F) << 10) | (exponent & 0x03FF));
|
||||
return h;
|
||||
}
|
||||
if (val < 1) i--;
|
||||
else i++;
|
||||
}
|
||||
h._value = (ushort)(Sign | 0x7C00);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
public static ushort ToDouble(double val)
|
||||
{
|
||||
ushort Sign = 0;
|
||||
if (val < 0)
|
||||
Sign = 0x8000;
|
||||
val = Math.Abs(val);
|
||||
double Pow1 = 1;
|
||||
double Pow2 = 1 << 10;
|
||||
double x = 0;
|
||||
|
||||
int MaxPow = (1 << 4);
|
||||
|
||||
int i = 0;
|
||||
while (i < MaxPow && i > -MaxPow + 1)
|
||||
{
|
||||
Pow1 = Math.Pow(2, i);
|
||||
x = val / Pow1;
|
||||
if (x >= 1 && x < 2)
|
||||
{
|
||||
ushort exponent_max = (ushort)Math.Ceiling(x * Pow2);
|
||||
ushort exponent_min = (ushort)Math.Floor (x * Pow2);
|
||||
ushort exponent = Math.Abs(x - exponent_max / Pow2) >
|
||||
Math.Abs(x - exponent_min / Pow2) ? exponent_max : exponent_min;
|
||||
ushort mantissa = (ushort)(i + MaxPow - 1);
|
||||
ushort d = (ushort)(Sign | ((mantissa & 0x001F) << 10) | (exponent & 0x03FF));
|
||||
return d;
|
||||
}
|
||||
else if (val < 1) i--;
|
||||
else i++;
|
||||
}
|
||||
|
||||
return i >= +0 ? (ushort)0x7C00 : (ushort)0xFC00;
|
||||
}
|
||||
|
||||
public override string ToString() => ((double)this).ToString();
|
||||
public override string ToString() => Extensions.ToString((double)this);
|
||||
public string ToString(string format, IFormatProvider formatProvider) =>
|
||||
((double)this).ToString(format, formatProvider);
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
@@ -0,0 +1,115 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public interface IKF<TKey, TVal>
|
||||
{
|
||||
TKey F { get; set; }
|
||||
|
||||
IKF<TKey, TVal> Check();
|
||||
string ToString();
|
||||
string ToString(bool Brackets);
|
||||
}
|
||||
|
||||
public struct KFT0<TKey, TVal> : IKF<TKey, TVal>
|
||||
{
|
||||
public TKey F { get; set; }
|
||||
|
||||
public KFT0(TKey F = default)
|
||||
{ this.F = F; }
|
||||
|
||||
public KFT0<TKey, TVal> ToT0() => this;
|
||||
public KFT1<TKey, TVal> ToT1() => new KFT1<TKey, TVal>(F);
|
||||
public KFT2<TKey, TVal> ToT2() => new KFT2<TKey, TVal>(F);
|
||||
public KFT3<TKey, TVal> ToT3() => new KFT3<TKey, TVal>(F);
|
||||
|
||||
public IKF<TKey, TVal> Check() => this;
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets = true) =>
|
||||
Extensions.ToString(F);
|
||||
}
|
||||
|
||||
public struct KFT1<TKey, TVal> : IKF<TKey, TVal>
|
||||
{
|
||||
public TKey F { get; set; }
|
||||
public TVal V;
|
||||
|
||||
public KFT1(TKey F = default, TVal V = default)
|
||||
{ this.F = F; this.V = V; }
|
||||
|
||||
public KFT0<TKey, TVal> ToT0() => new KFT0<TKey, TVal>(F);
|
||||
public KFT1<TKey, TVal> ToT1() => this;
|
||||
public KFT2<TKey, TVal> ToT2() => new KFT2<TKey, TVal>(F, V);
|
||||
public KFT3<TKey, TVal> ToT3() => new KFT3<TKey, TVal>(F, V);
|
||||
|
||||
public IKF<TKey, TVal> Check() =>
|
||||
V.Equals(default(TVal)) ? (IKF<TKey, TVal>)ToT0() : this;
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets = true) =>
|
||||
(Brackets ? "(" : "") + Extensions.ToString(F) + "," +
|
||||
Extensions.ToString(V) + (Brackets ? ")" : "");
|
||||
}
|
||||
|
||||
public struct KFT2<TKey, TVal> : IKF<TKey, TVal>
|
||||
{
|
||||
public TKey F { get; set; }
|
||||
public TVal V;
|
||||
public TVal T;
|
||||
|
||||
public KFT2(TKey F = default, TVal V = default, TVal T = default)
|
||||
{ this.F = F; this.V = V; this.T = T; }
|
||||
|
||||
public KFT0<TKey, TVal> ToT0() => new KFT0<TKey, TVal>(F);
|
||||
public KFT1<TKey, TVal> ToT1() => new KFT1<TKey, TVal>(F, V);
|
||||
public KFT2<TKey, TVal> ToT2() => this;
|
||||
public KFT3<TKey, TVal> ToT3() => new KFT3<TKey, TVal>(F, V, T, T);
|
||||
|
||||
public KFT3<TKey, TVal> ToT3(IKF<TKey, TVal> Previous) =>
|
||||
Previous is KFT2<TKey, TVal> PreviousT2 ?
|
||||
new KFT3<TKey, TVal>(F, V, PreviousT2.T, T) :
|
||||
new KFT3<TKey, TVal>(F, V, T, T);
|
||||
|
||||
public IKF<TKey, TVal> Check() =>
|
||||
T.Equals(default(TVal)) ? (V.Equals(default(TVal)) ?
|
||||
(IKF<TKey, TVal>)ToT0() : ToT1()) : this;
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets) =>
|
||||
(Brackets ? "(" : "") + Extensions.ToString(F) + "," + Extensions.
|
||||
ToString(V) + "," + Extensions.ToString(T) + (Brackets ? ")" : "");
|
||||
}
|
||||
|
||||
public struct KFT3<TKey, TVal> : IKF<TKey, TVal>
|
||||
{
|
||||
public TKey F { get; set; }
|
||||
public TVal V;
|
||||
public TVal T1;
|
||||
public TVal T2;
|
||||
|
||||
public KFT3(TKey F = default, TVal V = default, TVal T1 = default, TVal T2 = default)
|
||||
{ this.F = F; this.V = V; this.T1 = T1; this.T2 = T2; }
|
||||
|
||||
public KFT0<TKey, TVal> ToT0() => new KFT0<TKey, TVal>(F);
|
||||
public KFT1<TKey, TVal> ToT1() => new KFT1<TKey, TVal>(F, V);
|
||||
public KFT2<TKey, TVal> ToT2() => new KFT2<TKey, TVal>(F, V, T1);
|
||||
public KFT3<TKey, TVal> ToT3() => this;
|
||||
|
||||
public IKF<TKey, TVal> Check() =>
|
||||
T1.Equals(default(TVal)) && T2.Equals(default(TVal)) ?
|
||||
(V.Equals(default(TVal)) ? ToT0() : (IKF<TKey, TVal>)ToT1()) :
|
||||
T1.Equals(T2) ? (IKF<TKey, TVal>)ToT2() : this;
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets) =>
|
||||
(Brackets ? "(" : "") + Extensions.ToString(F) + "," + Extensions.ToString(V) + "," +
|
||||
Extensions.ToString(T1) + "," + Extensions.ToString(T2) + (Brackets ? ")" : "");
|
||||
|
||||
public IKF<TKey, TVal> ToT2(IKF<TKey, TVal> Previous, out IKF<TKey, TVal> Current)
|
||||
{
|
||||
Current = Previous is KFT2<TKey, TVal> PreviousT2
|
||||
? new KFT2<TKey, TVal>(PreviousT2.F, PreviousT2.V, T1)
|
||||
: new KFT2<TKey, TVal>(F, V, T1);
|
||||
return new KFT2<TKey, TVal>(F, V, T2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{437F63F1-8C23-429E-AB14-38B85C9EDB16}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>KKdBaseLib</RootNamespace>
|
||||
<AssemblyName>KKdBaseLib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<NoWarn>IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>embedded</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<NoWarn>IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="F2\ENRS.cs" />
|
||||
<Compile Include="F2\Header.cs" />
|
||||
<Compile Include="F2\POF.cs" />
|
||||
<Compile Include="F2\Struct.cs" />
|
||||
<Compile Include="DCC.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="Format.cs" />
|
||||
<Compile Include="Half.cs" />
|
||||
<Compile Include="IKF.cs" />
|
||||
<Compile Include="KKdList.cs" />
|
||||
<Compile Include="MsgPack.cs" />
|
||||
<Compile Include="Pointer.cs" />
|
||||
<Compile Include="Text.cs" />
|
||||
<Compile Include="Vector.cs" />
|
||||
<Compile Include="Vector3.cs" />
|
||||
<Compile Include="Vector4.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KKdMainLib.Types
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct KKdList<T> : IEnumerator, IEnumerable
|
||||
{
|
||||
@@ -17,20 +18,12 @@ namespace KKdMainLib.Types
|
||||
public bool NotNull => array != null;
|
||||
|
||||
public int Capacity { get => array != null ? array.Length : -1;
|
||||
set
|
||||
{
|
||||
if (array != null) System.Array.Resize(ref array, value);
|
||||
else array = new T[value];
|
||||
}
|
||||
}
|
||||
set { if (array != null) System.Array.Resize(ref array, value); else array = new T[value];
|
||||
if (Count >= value) Count = value; } }
|
||||
|
||||
|
||||
public KKdList(T[] Array)
|
||||
{
|
||||
index = 0;
|
||||
Count = Array.Length;
|
||||
array = Array;
|
||||
}
|
||||
{ index = 0; Count = Array.Length; array = Array; }
|
||||
|
||||
public T Current => index < Count ? array[index] : default;
|
||||
|
||||
@@ -64,17 +57,19 @@ namespace KKdMainLib.Types
|
||||
{
|
||||
if (IsNull) return;
|
||||
|
||||
for (int i = index; i < Count; i++)
|
||||
array[i] = array[i + 1];
|
||||
for (int i = index + 1; i < Count; i++)
|
||||
array[i - 1] = array[i];
|
||||
Count--;
|
||||
}
|
||||
|
||||
public void RemoveRange(int IndexStart, int IndexEnd)
|
||||
{
|
||||
if (IndexEnd - IndexStart < 1) return;
|
||||
if (IsNull) return;
|
||||
if (IndexEnd - IndexStart < 1) return;
|
||||
|
||||
for (int i = IndexStart; i < Count; i++)
|
||||
array[i] = array[i + IndexEnd - IndexStart];
|
||||
Count -= IndexEnd - IndexStart;
|
||||
}
|
||||
|
||||
public T[] ToArray() => array;
|
||||
@@ -84,7 +79,7 @@ namespace KKdMainLib.Types
|
||||
if (IsNull) return false;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (array[i] == null && val == null) return true;
|
||||
else if ( val == null) continue;
|
||||
else if (array[i] == null || val == null) continue;
|
||||
else if (array[i] .Equals(val) ) return true;
|
||||
return false;
|
||||
}
|
||||
@@ -94,9 +89,22 @@ namespace KKdMainLib.Types
|
||||
if (IsNull) return -1;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (array[i] == null && val == null) return i;
|
||||
else if ( val == null) continue;
|
||||
else if (array[i] == null || val == null) continue;
|
||||
else if (array[i] .Equals(val) ) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void Sort()
|
||||
{ List<T> List = (List<T>)this; List.Sort(); array = List.ToArray(); Count = List.Count; }
|
||||
|
||||
public static explicit operator KKdList<T>( List<T> List) =>
|
||||
new KKdList<T> { array = List.ToArray(), Count = List.Count };
|
||||
|
||||
public static explicit operator List<T>(KKdList<T> List)
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
for (int i = 0; i < List.Count; i++) list.Add(List[i]);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using KKdMainLib.Types;
|
||||
|
||||
namespace KKdMainLib.MessagePack
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct MsgPack : IDisposable, IEquatable<MsgPack>
|
||||
{
|
||||
@@ -107,7 +106,7 @@ namespace KKdMainLib.MessagePack
|
||||
public MsgPack Add(string Val, ulong val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, float val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, double val) => Add(new MsgPack(Val, val));
|
||||
|
||||
|
||||
public bool ReadBoolean(string Name) => ReadNBoolean(Name).GetValueOrDefault();
|
||||
public sbyte ReadInt8(string Name) => ReadNInt8(Name).GetValueOrDefault();
|
||||
public byte ReadUInt8(string Name) => ReadNUInt8(Name).GetValueOrDefault();
|
||||
@@ -120,30 +119,126 @@ namespace KKdMainLib.MessagePack
|
||||
public float ReadSingle(string Name) => ReadNSingle(Name).GetValueOrDefault();
|
||||
public double ReadDouble(string Name) => ReadNDouble(Name).GetValueOrDefault();
|
||||
|
||||
public bool? ReadNBoolean(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack.ReadNBoolean() : null;
|
||||
public sbyte? ReadNInt8(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNInt8 () : null;
|
||||
public byte? ReadNUInt8(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNUInt8 () : null;
|
||||
public short? ReadNInt16(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNInt16() : null;
|
||||
public ushort? ReadNUInt16(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNUInt16() : null;
|
||||
public int? ReadNInt32(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNInt32() : null;
|
||||
public uint? ReadNUInt32(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNUInt32() : null;
|
||||
public long? ReadNInt64(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNInt64() : null;
|
||||
public ulong? ReadNUInt64(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNUInt64() : null;
|
||||
public float? ReadNSingle(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNSingle() : null;
|
||||
public double? ReadNDouble(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNDouble() : null;
|
||||
public string ReadString(string Name) =>
|
||||
Element(Name, out MsgPack MsgPack) ? MsgPack. ReadString() : null;
|
||||
public bool? ReadNBoolean(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is bool Boolean) return Boolean;
|
||||
return null;
|
||||
}
|
||||
public sbyte? ReadNInt8(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return ( sbyte) UInt8 ;
|
||||
return null;
|
||||
}
|
||||
public byte? ReadNUInt8(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return ( byte) Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return UInt8 ;
|
||||
return null;
|
||||
}
|
||||
public short? ReadNInt16(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return UInt8 ;
|
||||
else if (MsgPack.Object is short Int16) return Int16;
|
||||
else if (MsgPack.Object is ushort UInt16) return ( short) UInt16;
|
||||
return null;
|
||||
}
|
||||
public ushort? ReadNUInt16(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return (ushort) Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return UInt8 ;
|
||||
else if (MsgPack.Object is short Int16) return (ushort) Int16;
|
||||
else if (MsgPack.Object is ushort UInt16) return UInt16;
|
||||
return null;
|
||||
}
|
||||
public int? ReadNInt32(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return UInt8 ;
|
||||
else if (MsgPack.Object is short Int16) return Int16;
|
||||
else if (MsgPack.Object is ushort UInt16) return UInt16;
|
||||
else if (MsgPack.Object is int Int32) return Int32;
|
||||
else if (MsgPack.Object is uint UInt32) return ( int) UInt32;
|
||||
return null;
|
||||
}
|
||||
public uint? ReadNUInt32(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return ( uint) Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return UInt8 ;
|
||||
else if (MsgPack.Object is short Int16) return ( uint) Int16;
|
||||
else if (MsgPack.Object is ushort UInt16) return UInt16;
|
||||
else if (MsgPack.Object is int Int32) return ( uint) Int32;
|
||||
else if (MsgPack.Object is uint UInt32) return UInt32;
|
||||
return null;
|
||||
}
|
||||
public long? ReadNInt64(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return UInt8 ;
|
||||
else if (MsgPack.Object is short Int16) return Int16;
|
||||
else if (MsgPack.Object is ushort UInt16) return UInt16;
|
||||
else if (MsgPack.Object is int Int32) return Int32;
|
||||
else if (MsgPack.Object is uint UInt32) return UInt32;
|
||||
else if (MsgPack.Object is long Int64) return Int64;
|
||||
else if (MsgPack.Object is ulong UInt64) return ( long) UInt64;
|
||||
return null;
|
||||
}
|
||||
public ulong? ReadNUInt64(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return ( ulong) Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return UInt8 ;
|
||||
else if (MsgPack.Object is short Int16) return ( ulong) Int16;
|
||||
else if (MsgPack.Object is ushort UInt16) return UInt16;
|
||||
else if (MsgPack.Object is int Int32) return ( ulong) Int32;
|
||||
else if (MsgPack.Object is uint UInt32) return UInt32;
|
||||
else if (MsgPack.Object is long Int64) return ( ulong) Int64;
|
||||
else if (MsgPack.Object is ulong UInt64) return UInt64;
|
||||
return null;
|
||||
}
|
||||
public float? ReadNSingle(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return UInt8 ;
|
||||
else if (MsgPack.Object is short Int16) return Int16;
|
||||
else if (MsgPack.Object is ushort UInt16) return UInt16;
|
||||
else if (MsgPack.Object is int Int32) return Int32;
|
||||
else if (MsgPack.Object is uint UInt32) return UInt32;
|
||||
else if (MsgPack.Object is long Int64) return Int64;
|
||||
else if (MsgPack.Object is float Float32) return Float32;
|
||||
else if (MsgPack.Object is double Float64) return ( float)Float64;
|
||||
return null;
|
||||
}
|
||||
public double? ReadNDouble(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is sbyte Int8 ) return Int8 ;
|
||||
else if (MsgPack.Object is byte UInt8 ) return UInt8 ;
|
||||
else if (MsgPack.Object is short Int16) return Int16;
|
||||
else if (MsgPack.Object is ushort UInt16) return UInt16;
|
||||
else if (MsgPack.Object is int Int32) return Int32;
|
||||
else if (MsgPack.Object is uint UInt32) return UInt32;
|
||||
else if (MsgPack.Object is long Int64) return Int64;
|
||||
else if (MsgPack.Object is float Float32) return Float32;
|
||||
else if (MsgPack.Object is double Float64) return Float64;
|
||||
return null;
|
||||
}
|
||||
public string ReadString(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is string String) return String;
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool ReadBoolean() => ReadNBoolean().GetValueOrDefault();
|
||||
public sbyte ReadInt8() => ReadNInt8().GetValueOrDefault();
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Pointer<T>
|
||||
{
|
||||
public int Offset;
|
||||
public T Value;
|
||||
|
||||
public override string ToString() => Extensions.ToString(Value);
|
||||
}
|
||||
|
||||
public struct CountPointer<T>
|
||||
{
|
||||
public int Count { get => Entries != null ? Entries.Length : 0;
|
||||
set => Entries = value < 0 ? null : new T[value]; }
|
||||
public int Offset;
|
||||
public T[] Entries;
|
||||
|
||||
|
||||
public T this[int index]
|
||||
{ get => Count > 0 ? Entries[index] : default;
|
||||
set { if (Count > 0) Entries[index] = value; } }
|
||||
|
||||
public override string ToString() => Count < 1 ? "No Entries" :
|
||||
Count == 1 ? Entries[0].ToString() : "Count: " + Count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("KKdBaseLib")]
|
||||
[assembly: AssemblyDescription("A base library")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("KKdBaseLib")]
|
||||
[assembly: AssemblyCopyright("korenkonder © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("437F63F1-8C23-429E-AB14-38B85C9EDB16")]
|
||||
[assembly: AssemblyVersion("0.4.7.2")]
|
||||
[assembly: AssemblyFileVersion("0.4.7.2")]
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Text;
|
||||
|
||||
namespace KKdMainLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public static class Text
|
||||
{
|
||||
public readonly static Encoding ShiftJIS = Encoding.GetEncoding(932);
|
||||
|
||||
public static string ToASCII(this byte[] Array) => Encoding.ASCII.GetString(Array ?? new byte[0]);
|
||||
public static string ToUTF8 (this byte[] Array) => Encoding.UTF8 .GetString(Array ?? new byte[0]);
|
||||
public static byte[] ToASCII(this string Data ) => Encoding.ASCII.GetBytes (Data ?? "" );
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdMainLib.Types
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Vector2<T>
|
||||
{
|
||||
@@ -0,0 +1,77 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Vector3
|
||||
{
|
||||
public double X;
|
||||
public double Y;
|
||||
public double Z;
|
||||
|
||||
public Vector3(double X, double Y, double Z)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; }
|
||||
|
||||
public double Length => (X * X + Y * Y + Z * Z).Sqrt();
|
||||
public Vector3 Normalized => this = Length == 0 ? new Vector3() : this / Length;
|
||||
|
||||
public static Vector3 operator +(Vector3 left, Vector3 right)
|
||||
{ left.X += right.X; left.Y += right.Y; left.Z += right.Z; return left; }
|
||||
public static Vector3 operator -(Vector3 left, Vector3 right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; left.Z -= right.Z; return left; }
|
||||
public static Vector3 operator -(Vector3 vec)
|
||||
{ vec.X = -vec.X; vec.Y = -vec.Y; vec.Z = -vec.Z; return vec; }
|
||||
public static Vector3 operator *(Vector3 vec, double scale)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; return vec; }
|
||||
public static Vector3 operator *( double scale, Vector3 vec)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; return vec; }
|
||||
public static Vector3 operator *(Vector3 vec, Vector3 scale)
|
||||
{ vec.X *= scale.X; vec.Y *= scale.Y; vec.Z *= scale.Z; return vec; }
|
||||
public static Vector3 operator /(Vector3 vec, double scale)
|
||||
{ vec.X /= scale ; vec.Y /= scale ; vec.Z /= scale ; return vec; }
|
||||
public static Vector3 operator /(Vector3 vec, Vector3 scale)
|
||||
{ vec.X /= scale.X; vec.Y /= scale.Y; vec.Z /= scale.Z; return vec; }
|
||||
public static bool operator ==(Vector3 A, Vector3 B) => A.Equals(B);
|
||||
public static bool operator !=(Vector3 A, Vector3 B) => !A.Equals(B);
|
||||
|
||||
public static double Distance (Vector3 left, Vector3 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) *
|
||||
(right.Y - left.Y) + (right.Z - left.Z) * (right.Z - left.Z).Sqrt();
|
||||
public static double DistanceSquared(Vector3 left, Vector3 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) *
|
||||
(right.Y - left.Y) + (right.Z - left.Z) * (right.Z - left.Z);
|
||||
public static double Dot (Vector3 left, Vector3 right) =>
|
||||
(left.X * right.X) + (left.Y * right.Y) + (left.Z * right.Z);
|
||||
public static Vector3 Cross(Vector3 left, Vector3 right) =>
|
||||
new Vector3 { X = (left.Y * right.Z) - (left.Z * right.Y),
|
||||
Y = (left.Z * right.X) - (left.X * right.Z),
|
||||
Z = (left.X * right.Y) - (left.Y * right.X), };
|
||||
public static Vector3 Lerp (Vector3 a, Vector3 b, double blend) =>
|
||||
new Vector3 { X = blend * (b.X - a.X) + a.X,
|
||||
Y = blend * (b.Y - a.Y) + a.Y,
|
||||
Z = blend * (b.Z - a.Z) + a.Z };
|
||||
public static Vector3 Lerp (Vector3 a, Vector3 b, Vector3 blend) =>
|
||||
new Vector3 { X = blend.X * (b.X - a.X) + a.X,
|
||||
Y = blend.Y * (b.Y - a.Y) + a.Y,
|
||||
Z = blend.Z * (b.Z - a.Z) + a.Z };
|
||||
public Vector3 Round( ) =>
|
||||
new Vector3 { X = X.Round( ), Y = Y.Round( ), Z = Z.Round( ) };
|
||||
public Vector3 Round(int d) =>
|
||||
new Vector3 { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d) };
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
int hashCode = X.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ Y.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ Z.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
public override bool Equals(object obj) =>
|
||||
obj is Vector3 vec ? Equals(vec) : false;
|
||||
public bool Equals(Vector3 other) =>
|
||||
X == other.X && Y == other.Y && Z == other.Z;
|
||||
|
||||
public override string ToString() => $"{X},{Y},{Z}";
|
||||
public string ToString(int d) => $"{X.Round(d)},{Y.Round(d)},{Z.Round(d)}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Vector4
|
||||
{
|
||||
public double X;
|
||||
public double Y;
|
||||
public double Z;
|
||||
public double W;
|
||||
|
||||
public Vector4(double X, double Y, double Z, double W)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; this.W = W; }
|
||||
|
||||
public double Length => (X * X + Y * Y + Z * Z + W * W).Sqrt();
|
||||
public Vector4 Normalized => this = Length == 0 ? new Vector4() : this / Length;
|
||||
|
||||
public static Vector4 operator +(Vector4 left, Vector4 right)
|
||||
{ left.X += right.X; left.Y += right.Y; left.Z += right.Z; left.W += right.W; return left; }
|
||||
public static Vector4 operator -(Vector4 left, Vector4 right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; left.Z -= right.Z; left.W -= right.W; return left; }
|
||||
public static Vector4 operator -(Vector4 vec)
|
||||
{ vec.X = -vec.X; vec.Y = -vec.Y; vec.Z = -vec.Z; vec.W = -vec.W; return vec; }
|
||||
public static Vector4 operator *(Vector4 vec, double scale)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; vec.W *= scale ; return vec; }
|
||||
public static Vector4 operator *( double scale, Vector4 vec)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; vec.W *= scale ; return vec; }
|
||||
public static Vector4 operator *(Vector4 vec, Vector4 scale)
|
||||
{ vec.X *= scale.X; vec.Y *= scale.Y; vec.Z *= scale.Z; vec.W *= scale.W; return vec; }
|
||||
public static Vector4 operator /(Vector4 vec, double scale)
|
||||
{ vec.X /= scale ; vec.Y /= scale ; vec.Z /= scale ; vec.W /= scale ; return vec; }
|
||||
public static Vector4 operator /(Vector4 vec, Vector4 scale)
|
||||
{ vec.X /= scale.X; vec.Y /= scale.Y; vec.Z /= scale.Z; vec.W /= scale.W; return vec; }
|
||||
public static bool operator ==(Vector4 A, Vector4 B) => A.Equals(B);
|
||||
public static bool operator !=(Vector4 A, Vector4 B) => !A.Equals(B);
|
||||
|
||||
public static double Distance (Vector4 left, Vector4 right) =>
|
||||
((right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W)).Sqrt();
|
||||
public static double DistanceSquared(Vector4 left, Vector4 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W);
|
||||
public static double Dot (Vector4 left, Vector4 right) =>
|
||||
(left.X * right.X) + (left.Y * right.Y) + (left.Z * right.Z) + (left.W * right.W);
|
||||
public static Vector4 Lerp (Vector4 a, Vector4 b, double blend) =>
|
||||
new Vector4 { X = blend * (b.X - a.X) + a.X,
|
||||
Y = blend * (b.Y - a.Y) + a.Y,
|
||||
Z = blend * (b.Z - a.Z) + a.Z,
|
||||
W = blend * (b.W - a.W) + a.W };
|
||||
public static Vector4 Lerp (Vector4 a, Vector4 b, Vector4 blend) =>
|
||||
new Vector4 { X = blend.X * (b.X - a.X) + a.X,
|
||||
Y = blend.Y * (b.Y - a.Y) + a.Y,
|
||||
Z = blend.Z * (b.Z - a.Z) + a.Z,
|
||||
W = blend.W * (b.W - a.W) + a.W };
|
||||
public Vector4 Round( ) =>
|
||||
new Vector4 { X = X.Round( ), Y = Y.Round( ), Z = Z.Round( ), W = W.Round( ) };
|
||||
public Vector4 Round(int d) =>
|
||||
new Vector4 { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d), W = W.Round(d) };
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
int hashCode = X.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ Y.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ Z.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ W.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
public override bool Equals(object obj) =>
|
||||
obj is Vector4 vec ? Equals(vec) : false;
|
||||
public bool Equals(Vector4 other) =>
|
||||
X == other.X && Y == other.Y && Z == other.Z && W == other.W;
|
||||
|
||||
public override string ToString() => $"{X},{Y},{Z},{W}";
|
||||
public string ToString(int d) => $"{X.Round(d)},{Y.Round(d)},{Z.Round(d)},{W.Round(d)}";
|
||||
}
|
||||
}
|
||||
+202
-258
@@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.Types;
|
||||
using KKdMainLib.MessagePack;
|
||||
using Extensions = KKdBaseLib.Extensions;
|
||||
|
||||
namespace KKdMainLib.A3DA
|
||||
{
|
||||
public class A3DA
|
||||
{
|
||||
private const bool A3DCOpt = true;
|
||||
private bool A3DCOpt = true;
|
||||
private const string d = ".";
|
||||
|
||||
private int i, i0, i1;
|
||||
@@ -24,11 +24,10 @@ namespace KKdMainLib.A3DA
|
||||
private Dictionary<int?, double?> UsedValues;
|
||||
private Dictionary<string, object> Dict;
|
||||
|
||||
private bool IsX => Data.Format == Main.Format.X || Data.Format == Main.Format.XHD;
|
||||
private bool IsX => Data.Format == Format.X || Data.Format == Format.XHD;
|
||||
|
||||
public Stream IO;
|
||||
public A3DAData Data;
|
||||
//public PDHead Header;
|
||||
|
||||
public A3DA()
|
||||
{ Data = new A3DAData(); Dict = new Dictionary<string, object>();
|
||||
@@ -47,11 +46,12 @@ namespace KKdMainLib.A3DA
|
||||
dataArray = new string[4];
|
||||
Dict = new Dictionary<string, object>();
|
||||
Data = new A3DAData();
|
||||
PDHead Header = new PDHead();
|
||||
Header Header = new Header();
|
||||
|
||||
Data.Format = IO.Format = Main.Format.F;
|
||||
Data.Format = IO.Format = Format.F;
|
||||
Header.SectionSignature = IO.ReadInt32();
|
||||
if (Header.SectionSignature == 0x41443341) { Header = IO.ReadHeader(true); Data.Format = Header.Format; }
|
||||
if (Header.SectionSignature == 0x41443341)
|
||||
{ Header = IO.ReadHeader(true, true); Data.Format = Header.Format; }
|
||||
if (Header.SectionSignature != 0x44334123) { IO.Close(); return 0; }
|
||||
|
||||
IO.Offset = IO.Position - 4;
|
||||
@@ -60,7 +60,7 @@ namespace KKdMainLib.A3DA
|
||||
if (Header.SectionSignature == 0x5F5F5F41)
|
||||
{
|
||||
IO.Position = 0x10;
|
||||
Header.Format = IO.Format = Main.Format.DT;
|
||||
Header.Format = IO.Format = Format.DT;
|
||||
}
|
||||
else if (Header.SectionSignature == 0x5F5F5F43)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ namespace KKdMainLib.A3DA
|
||||
}
|
||||
else { IO.Close(); return 0; }
|
||||
|
||||
if (Header.Format == Main.Format.DT)
|
||||
if (Header.Format == Format.DT)
|
||||
Data.StringLength = IO.Length - 0x10;
|
||||
|
||||
string[] STRData = IO.ReadString(Data.StringLength).Replace("\r", "").Split('\n');
|
||||
@@ -96,20 +96,21 @@ namespace KKdMainLib.A3DA
|
||||
|
||||
A3DAReader();
|
||||
|
||||
if (Header.Format >= Main.Format.F && Header.Format != Main.Format.FT)
|
||||
if (Header.SectionSignature == 0x5F5F5F43)
|
||||
{
|
||||
IO.Position = IO.Offset + Data.BinaryOffset;
|
||||
IO.Offset = IO.Position;
|
||||
IO.Position = 0;
|
||||
IO = File.OpenReader(IO.ReadBytes(Data.BinaryLength));
|
||||
A3DCReader();
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
|
||||
name = "";
|
||||
nameView = "";
|
||||
dataArray = null;
|
||||
Dict = null;
|
||||
IO = null;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -168,14 +169,14 @@ namespace KKdMainLib.A3DA
|
||||
if (Dict.FindValue(out value, "dof.name"))
|
||||
{
|
||||
Data.DOF = new DOF { Name = value };
|
||||
Data.Format = Main.Format.FT;
|
||||
Data.Format = Format.FT;
|
||||
Data.DOF.MT = Dict.ReadMT("dof" + d);
|
||||
}
|
||||
|
||||
if (Dict.FindValue(out value, "ambient.length"))
|
||||
{
|
||||
Data.Ambient = new Ambient[int.Parse(value)];
|
||||
Data.Format = Main.Format.MGF;
|
||||
Data.Format = Format.MGF;
|
||||
for (i0 = 0; i0 < Data.Ambient.Length; i0++)
|
||||
{
|
||||
name = "ambient" + d + i0 + d;
|
||||
@@ -343,7 +344,7 @@ namespace KKdMainLib.A3DA
|
||||
if (Dict.FindValue(out value, "material_list.length"))
|
||||
{
|
||||
Data.MaterialList = new MaterialList[int.Parse(value)];
|
||||
Data.Format = Main.Format.X;
|
||||
Data.Format = Format.X;
|
||||
for (i0 = 0; i0 < Data.MaterialList.Length; i0++)
|
||||
{
|
||||
name = "material_list" + d + i0 + d;
|
||||
@@ -488,7 +489,7 @@ namespace KKdMainLib.A3DA
|
||||
IO.Write("_.file_name=", Data._.FileName);
|
||||
IO.Write("_.property.version=", Data._.PropertyVersion);
|
||||
|
||||
if (Data.Ambient != null && Data.Format == Main.Format.MGF)
|
||||
if (Data.Ambient != null && Data.Format == Format.MGF)
|
||||
{
|
||||
SO0 = Data.Ambient.Length.SortWriter();
|
||||
SOi0 = 0;
|
||||
@@ -569,7 +570,7 @@ namespace KKdMainLib.A3DA
|
||||
IO.Write("curve.length=", Data.Curve.Length);
|
||||
}
|
||||
|
||||
if (Data.DOF != null && Data.Format == Main.Format.FT)
|
||||
if (Data.DOF != null && Data.Format == Format.FT)
|
||||
{
|
||||
IO.Write("dof.name=", Data.DOF.Name);
|
||||
IO.Write(Data.DOF.MT, "dof" + d, A3DC, IsX);
|
||||
@@ -1014,7 +1015,7 @@ namespace KKdMainLib.A3DA
|
||||
public byte[] A3DCWriter()
|
||||
{
|
||||
if (A3DCOpt) UsedValues = new Dictionary<int?, double?>();
|
||||
if (Data.Format < Main.Format.F2LE) Data._.CompressF16 = null;
|
||||
if (Data.Format < Format.F2LE) Data._.CompressF16 = null;
|
||||
|
||||
IO = File.OpenWriter();
|
||||
for (byte i = 0; i < 2; i++)
|
||||
@@ -1025,9 +1026,9 @@ namespace KKdMainLib.A3DA
|
||||
if (Data.CameraRoot != null)
|
||||
for (i0 = 0; i0 < Data.CameraRoot.Length; i0++)
|
||||
{
|
||||
IO.WriteOffset(ref Data.CameraRoot[i0].Interest, ReturnToOffset);
|
||||
IO.WriteOffset(ref Data.CameraRoot[i0]. MT, ReturnToOffset);
|
||||
IO.WriteOffset(ref Data.CameraRoot[i0].VP. MT, ReturnToOffset);
|
||||
IO.WriteOffset(ref Data.CameraRoot[i0].Interest, ReturnToOffset);
|
||||
}
|
||||
|
||||
if (Data.DOF != null)
|
||||
@@ -1085,12 +1086,12 @@ namespace KKdMainLib.A3DA
|
||||
if (Data.CameraRoot != null)
|
||||
for (i0 = 0; i0 < Data.CameraRoot.Length; i0++)
|
||||
{
|
||||
Write(ref Data.CameraRoot[i0].Interest);
|
||||
Write(ref Data.CameraRoot[i0]. MT);
|
||||
Write(ref Data.CameraRoot[i0].VP. MT);
|
||||
Write(ref Data.CameraRoot[i0].VP.FOV );
|
||||
Write(ref Data.CameraRoot[i0].VP.FocalLength);
|
||||
Write(ref Data.CameraRoot[i0].VP.Roll );
|
||||
Write(ref Data.CameraRoot[i0].VP.FocalLength);
|
||||
Write(ref Data.CameraRoot[i0].VP.FOV );
|
||||
Write(ref Data.CameraRoot[i0].Interest);
|
||||
}
|
||||
|
||||
if (Data.Chara != null)
|
||||
@@ -1101,16 +1102,14 @@ namespace KKdMainLib.A3DA
|
||||
for (i0 = 0; i0 < Data.Curve.Length; i0++)
|
||||
Write(ref Data.Curve[i0].CV);
|
||||
|
||||
if (Data.DOF != null && Data.Format == Main.Format.FT)
|
||||
if (Data.DOF != null && Data.Format == Format.FT)
|
||||
Write(ref Data.DOF.MT);
|
||||
|
||||
if (Data.Fog != null)
|
||||
for (i0 = 0; i0 < Data.Fog.Length; i0++)
|
||||
if (Data.Light != null)
|
||||
for (i0 = 0; i0 < Data.Light.Length; i0++)
|
||||
{
|
||||
Write(ref Data.Fog[i0].Density);
|
||||
Write(ref Data.Fog[i0].Diffuse);
|
||||
Write(ref Data.Fog[i0].End );
|
||||
Write(ref Data.Fog[i0].Start );
|
||||
Write(ref Data.Light[i0].Position );
|
||||
Write(ref Data.Light[i0].SpotDirection);
|
||||
}
|
||||
|
||||
if (Data.Light != null)
|
||||
@@ -1120,8 +1119,15 @@ namespace KKdMainLib.A3DA
|
||||
Write(ref Data.Light[i0].Diffuse );
|
||||
Write(ref Data.Light[i0].Incandescence);
|
||||
Write(ref Data.Light[i0].Specular );
|
||||
Write(ref Data.Light[i0].Position );
|
||||
Write(ref Data.Light[i0].SpotDirection);
|
||||
}
|
||||
|
||||
if (Data.Fog != null)
|
||||
for (i0 = 0; i0 < Data.Fog.Length; i0++)
|
||||
{
|
||||
Write(ref Data.Fog[i0].Density);
|
||||
Write(ref Data.Fog[i0].Diffuse);
|
||||
Write(ref Data.Fog[i0].Start );
|
||||
Write(ref Data.Fog[i0].End );
|
||||
}
|
||||
|
||||
if (Data.MObjectHRC != null)
|
||||
@@ -1178,8 +1184,8 @@ namespace KKdMainLib.A3DA
|
||||
Write(ref Data.PostProcess.Diffuse );
|
||||
Write(ref Data.PostProcess.Specular );
|
||||
Write(ref Data.PostProcess.LensFlare);
|
||||
Write(ref Data.PostProcess.LensGhost);
|
||||
Write(ref Data.PostProcess.LensShaft);
|
||||
Write(ref Data.PostProcess.LensGhost);
|
||||
}
|
||||
|
||||
IO.Align(0x10, true);
|
||||
@@ -1188,7 +1194,7 @@ namespace KKdMainLib.A3DA
|
||||
byte[] A3DAData = A3DAWriter(true);
|
||||
|
||||
IO = File.OpenWriter();
|
||||
IO.Offset = Data.Format > Main.Format.FT ? 0x40 : 0;
|
||||
IO.Offset = Data.Format > Format.FT ? 0x40 : 0;
|
||||
IO.Position = 0x40;
|
||||
|
||||
Data.StringOffset = IO.Position;
|
||||
@@ -1218,15 +1224,15 @@ namespace KKdMainLib.A3DA
|
||||
IO.WriteEndian(Data.BinaryLength, true);
|
||||
IO.WriteEndian(0x20, true);
|
||||
|
||||
if (Data.Format > Main.Format.FT)
|
||||
if (Data.Format > Format.FT)
|
||||
{
|
||||
IO.Position = A3DCEnd;
|
||||
IO.WriteEOFC(0);
|
||||
IO.Offset = 0;
|
||||
IO.Position = 0;
|
||||
PDHead Header = new PDHead { Signature = 0x41443341, Format = Main.Format.F2LE,
|
||||
Header Header = new Header { Signature = 0x41443341, Format = Format.F2LE,
|
||||
DataSize = A3DCEnd, SectionSize = A3DCEnd, InnerSignature = 0x01131010 };
|
||||
IO.Write(Header);
|
||||
IO.Write(Header, true);
|
||||
}
|
||||
|
||||
return IO.ToArray(true);
|
||||
@@ -1246,61 +1252,30 @@ namespace KKdMainLib.A3DA
|
||||
|
||||
private void Write(ref Key Key, bool F16 = false)
|
||||
{
|
||||
if (Key == null) return;
|
||||
if (Key == null || Key.Type == null) return;
|
||||
|
||||
int i = 0;
|
||||
if (Key.Trans != null)
|
||||
{
|
||||
Key.BinOffset = IO.Position;
|
||||
int Type = Key.Type.Value;
|
||||
int Type = (int)Key.Type & 0xFF;
|
||||
if (Key.EPTypePost.HasValue) Type |= (Key.EPTypePost.Value & 0xF) << 12;
|
||||
if (Key.EPTypePre .HasValue) Type |= (Key.EPTypePre .Value & 0xF) << 12;
|
||||
if (Key.EPTypePre .HasValue) Type |= (Key.EPTypePre .Value & 0xF) << 8;
|
||||
IO.Write(Type);
|
||||
IO.Write(0x00);
|
||||
IO.Write((float)Key.Max);
|
||||
IO.Write(Key.Trans.Length);
|
||||
for (i = 0; i < Key.Trans.Length; i++)
|
||||
{
|
||||
if (Key.Trans[i] is KeyFrameT0<double, double> TransT0)
|
||||
{
|
||||
if (F16 && CompressF16 > 0)
|
||||
{ IO.Write((ushort)TransT0.Frame); IO.Write((ushort)0); }
|
||||
else
|
||||
{ IO.Write(( float)TransT0.Frame); IO.Write(( float)0); }
|
||||
if (F16 && CompressF16 == 2) IO.Write(0 );
|
||||
else IO.Write(0L);
|
||||
}
|
||||
else if (Key.Trans[i] is KeyFrameT1<double, double> TransT1)
|
||||
{
|
||||
if (F16 && CompressF16 > 0)
|
||||
{ IO.Write((ushort)TransT1.Frame); IO.Write(( Half)TransT1.Value); }
|
||||
else
|
||||
{ IO.Write(( float)TransT1.Frame); IO.Write((float)TransT1.Value); }
|
||||
if (F16 && CompressF16 == 2) IO.Write(0 );
|
||||
else IO.Write(0L);
|
||||
}
|
||||
else if (Key.Trans[i] is KeyFrameT2<double, double> TransT2)
|
||||
{
|
||||
if (F16 && CompressF16 > 0)
|
||||
{ IO.Write((ushort)TransT2.Frame); IO.Write(( Half)TransT2.Value); }
|
||||
else
|
||||
{ IO.Write(( float)TransT2.Frame); IO.Write((float)TransT2.Value); }
|
||||
if (F16 && CompressF16 == 2)
|
||||
{ IO.Write(( Half)TransT2.Interpolation); IO.Write(( Half)TransT2.Interpolation); }
|
||||
else
|
||||
{ IO.Write(( float)TransT2.Interpolation); IO.Write((float)TransT2.Interpolation); }
|
||||
}
|
||||
else if (Key.Trans[i] is KeyFrameT3<double, double> TransT3)
|
||||
{
|
||||
if (F16 && CompressF16 > 0)
|
||||
{ IO.Write((ushort)TransT3.Frame); IO.Write(( Half)TransT3.Value); }
|
||||
else
|
||||
{ IO.Write(( float)TransT3.Frame); IO.Write((float)TransT3.Value); }
|
||||
if (F16 && CompressF16 == 2)
|
||||
{ IO.Write(( Half)TransT3.Interpolation1); IO.Write(( Half)TransT3.Interpolation2); }
|
||||
else
|
||||
{ IO.Write(( float)TransT3.Interpolation1); IO.Write((float)TransT3.Interpolation2); }
|
||||
}
|
||||
ref KFT3<double, double> KF = ref Key.Trans[i];
|
||||
if (F16 && CompressF16 > 0)
|
||||
{ IO.Write((ushort)KF.F ); IO.Write(( Half)KF.V ); }
|
||||
else
|
||||
{ IO.Write(( float)KF.F ); IO.Write((float)KF.V ); }
|
||||
if (F16 && CompressF16 == 2)
|
||||
{ IO.Write(( Half)KF.T1); IO.Write(( Half)KF.T2); }
|
||||
else
|
||||
{ IO.Write(( float)KF.T1); IO.Write((float)KF.T2); }
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1308,8 +1283,8 @@ namespace KKdMainLib.A3DA
|
||||
if (!UsedValues.ContainsValue(Key.Value) || !A3DCOpt)
|
||||
{
|
||||
Key.BinOffset = IO.Position;
|
||||
IO.Write( Key.Type );
|
||||
IO.Write((float?)Key.Value);
|
||||
IO.Write(( int)Key.Type );
|
||||
IO.Write((float)Key.Value);
|
||||
if (A3DCOpt)
|
||||
{ UsedValues.Add(Key.BinOffset, Key.Value); }
|
||||
return;
|
||||
@@ -1322,7 +1297,7 @@ namespace KKdMainLib.A3DA
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
|
||||
if (!MsgPack.Element("A3D", out MsgPack A3D)) { MsgPack = MsgPack.New; return; }
|
||||
if (!MsgPack.Element("A3D", out MsgPack A3D)) { MsgPack.Dispose(); return; }
|
||||
MsgPackReader(A3D);
|
||||
}
|
||||
|
||||
@@ -1983,14 +1958,13 @@ namespace KKdMainLib.A3DA
|
||||
public static Key ReadKey(this Dictionary<string, object> Dict, string Temp)
|
||||
{
|
||||
Key Key = new Key();
|
||||
Dict.FindValue(out Key.BinOffset, Temp + BO );
|
||||
Dict.FindValue(out Key.Type , Temp + "type");
|
||||
if ( Dict.FindValue(out Key.BinOffset, Temp + BO )) return Key;
|
||||
if (!Dict.FindValue(out int Type , Temp + "type")) return null;
|
||||
|
||||
if (Key.BinOffset == null && Key.Type == null) return null;
|
||||
if (Key.Type == null) return Key;
|
||||
if (Key.Type == 0x0000) return Key;
|
||||
|
||||
if (Key.Type == 0x0001) { Dict.FindValue(out Key.Value, Temp + "value"); return Key; }
|
||||
if (Key.BinOffset != null) return null;
|
||||
Key.Type = (Key.Interpolation)Type;
|
||||
if (Type == 0x0000) return Key;
|
||||
if (Type == 0x0001) { Dict.FindValue(out Key.Value, Temp + "value"); return Key; }
|
||||
|
||||
int i = 0;
|
||||
Dict.FindValue(out Key.EPTypePost, Temp + "ep_type_post");
|
||||
@@ -2000,66 +1974,60 @@ namespace KKdMainLib.A3DA
|
||||
if (Dict.StartsWith(Temp + "raw_data"))
|
||||
Dict.FindValue(out Key.RawData.KeyType, Temp + "raw_data_key_type");
|
||||
|
||||
if (Key.Length != null)
|
||||
{
|
||||
int Type;
|
||||
Key.Trans = new IKeyFrame<double, double>[(int)Key.Length];
|
||||
for (i = 0; i < Key.Length; i++)
|
||||
if (Dict.FindValue(out value, Temp + "key" + d + i + d + "data"))
|
||||
{
|
||||
dataArray = value.Replace("(", "").Replace(")", "").Split(',');
|
||||
Type = dataArray.Length - 1;
|
||||
if (Type == 0) Key.Trans[i] = new KeyFrameT0<double, double>
|
||||
{ Frame = dataArray[0].ToDouble() };
|
||||
else if (Type == 1) Key.Trans[i] = new KeyFrameT1<double, double>
|
||||
{ Frame = dataArray[0].ToDouble(), Value = dataArray[1].ToDouble() };
|
||||
else if (Type == 2) Key.Trans[i] = new KeyFrameT2<double, double>
|
||||
{ Frame = dataArray[0].ToDouble(), Value = dataArray[1].ToDouble(),
|
||||
Interpolation = dataArray[2].ToDouble() };
|
||||
else if (Type == 3) Key.Trans[i] = new KeyFrameT3<double, double>
|
||||
{ Frame = dataArray[0].ToDouble(), Value = dataArray[1].ToDouble(),
|
||||
Interpolation1 = dataArray[2].ToDouble(),
|
||||
Interpolation2 = dataArray[3].ToDouble() };
|
||||
Key.Trans[i] = Key.Trans[i].Check();
|
||||
}
|
||||
}
|
||||
else if (Key.RawData.KeyType != null)
|
||||
if (Key.RawData.KeyType != 0)
|
||||
{
|
||||
ref string[] ValueList = ref Key.RawData.ValueList;
|
||||
Dict.FindValue(out Key.RawData.ValueType, Temp + "raw_data.value_type");
|
||||
if (Dict.FindValue(out value, Temp + "raw_data.value_list"))
|
||||
Key.RawData.ValueList = value.Split(',');
|
||||
ValueList = value.Split(',');
|
||||
Dict.FindValue(out Key.RawData.ValueListSize, Temp + "raw_data.value_list_size");
|
||||
value = "";
|
||||
|
||||
int DS = (int)Key.RawData.KeyType + 1;
|
||||
int DS = Key.RawData.KeyType + 1;
|
||||
Key.Length = Key.RawData.ValueListSize / DS;
|
||||
Key.Trans = new IKeyFrame<double, double>[(int)Key.Length];
|
||||
Key.Trans = new KFT3<double, double>[Key.Length];
|
||||
if (Key.RawData.KeyType == 0)
|
||||
for (i = 0; i < Key.Length; i++)
|
||||
Key.Trans[i] = new KeyFrameT0<double, double>
|
||||
{ Frame = Key.RawData.ValueList[i * DS + 0].ToDouble() }.Check();
|
||||
Key.Trans[i] = new KFT3<double, double>
|
||||
(ValueList[i * DS + 0].ToDouble());
|
||||
else if (Key.RawData.KeyType == 1)
|
||||
for (i = 0; i < Key.Length; i++)
|
||||
Key.Trans[i] = new KeyFrameT1<double, double>
|
||||
{ Frame = Key.RawData.ValueList[i * DS + 0].ToDouble(),
|
||||
Value = Key.RawData.ValueList[i * DS + 1].ToDouble() }.Check();
|
||||
Key.Trans[i] = new KFT3<double, double>
|
||||
(ValueList[i * DS + 0].ToDouble(), ValueList[i * DS + 1].ToDouble());
|
||||
else if (Key.RawData.KeyType == 2)
|
||||
for (i = 0; i < Key.Length; i++)
|
||||
Key.Trans[i] = new KeyFrameT2<double, double>
|
||||
{ Frame = Key.RawData.ValueList[i * DS + 0].ToDouble(),
|
||||
Value = Key.RawData.ValueList[i * DS + 1].ToDouble(),
|
||||
Interpolation = Key.RawData.ValueList[i * DS + 2].ToDouble() }.Check();
|
||||
Key.Trans[i] = new KFT3<double, double>
|
||||
(ValueList[i * DS + 0].ToDouble(), ValueList[i * DS + 1].ToDouble(),
|
||||
ValueList[i * DS + 2].ToDouble(), ValueList[i * DS + 2].ToDouble());
|
||||
else if (Key.RawData.KeyType == 3)
|
||||
for (i = 0; i < Key.Length; i++)
|
||||
Key.Trans[i] = new KeyFrameT3<double, double>
|
||||
{ Frame = Key.RawData.ValueList[i * DS + 0].ToDouble(),
|
||||
Value = Key.RawData.ValueList[i * DS + 1].ToDouble(),
|
||||
Interpolation1 = Key.RawData.ValueList[i * DS + 2].ToDouble(),
|
||||
Interpolation2 = Key.RawData.ValueList[i * DS + 3].ToDouble() }.Check();
|
||||
Key.Trans[i] = new KFT3<double, double>
|
||||
(ValueList[i * DS + 0].ToDouble(), ValueList[i * DS + 1].ToDouble(),
|
||||
ValueList[i * DS + 2].ToDouble(), ValueList[i * DS + 3].ToDouble());
|
||||
|
||||
for (i = 0; i < Key.Length; i++) Key.Trans[i].Check();
|
||||
Key.RawData.ValueList = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Key.Trans = new KFT3<double, double>[Key.Length];
|
||||
for (i = 0; i < Key.Length; i++)
|
||||
{
|
||||
if (!Dict.FindValue(out value, Temp + "key" + d + i + d + "data")) continue;
|
||||
|
||||
dataArray = value.Replace("(", "").Replace(")", "").Split(',');
|
||||
Type = dataArray.Length - 1;
|
||||
if (Type == 0) Key.Trans[i] = new KFT3<double, double>
|
||||
(dataArray[0].ToDouble());
|
||||
else if (Type == 1) Key.Trans[i] = new KFT3<double, double>
|
||||
(dataArray[0].ToDouble(), dataArray[1].ToDouble());
|
||||
else if (Type == 2) Key.Trans[i] = new KFT3<double, double>
|
||||
(dataArray[0].ToDouble(), dataArray[1].ToDouble(),
|
||||
dataArray[2].ToDouble(), dataArray[2].ToDouble());
|
||||
else if (Type == 3) Key.Trans[i] = new KFT3<double, double>
|
||||
(dataArray[0].ToDouble(), dataArray[1].ToDouble(),
|
||||
dataArray[2].ToDouble(), dataArray[3].ToDouble());
|
||||
}
|
||||
}
|
||||
return Key;
|
||||
}
|
||||
|
||||
@@ -2099,7 +2067,7 @@ namespace KKdMainLib.A3DA
|
||||
|
||||
public static void Write(this Stream IO, Key Key, string Temp, bool A3DC = false)
|
||||
{
|
||||
if (Key == null) return;
|
||||
if (Key == null || Key.Type == null) return;
|
||||
|
||||
if (A3DC) { IO.Write(Temp + BO + "=", Key.BinOffset); return; }
|
||||
|
||||
@@ -2107,69 +2075,65 @@ namespace KKdMainLib.A3DA
|
||||
if (Key.Trans != null)
|
||||
if (Key.Trans.Length == 0)
|
||||
{
|
||||
IO.Write(Temp + "type=", Key.Type);
|
||||
IO.Write(Temp + "type=", (int)Key.Type);
|
||||
if (Key.Type > 0) IO.Write(Temp + "value=", Key.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Key.EPTypePost != null) IO.Write(Temp + "ep_type_post=", Key.EPTypePost);
|
||||
if (Key.EPTypePre != null) IO.Write(Temp + "ep_type_pre=" , Key.EPTypePre );
|
||||
if (Key.RawData.KeyType == null && Key.Trans != null)
|
||||
if (Key.RawData.KeyType == 0 && Key.Trans != null)
|
||||
{
|
||||
IKF<double, double> KF;
|
||||
SO = Key.Trans.Length.SortWriter();
|
||||
for (i = 0; i < Key.Trans.Length; i++)
|
||||
{
|
||||
SOi = SO[i];
|
||||
IO.Write(Temp + "key" + d + SOi + d + "data=", Key.Trans[SOi].ToString());
|
||||
if (Key.Trans[SOi] is KeyFrameT0<double, double>)
|
||||
IO.Write(Temp + "key" + d + SOi + d + "type=", 0);
|
||||
else if (Key.Trans[SOi] is KeyFrameT1<double, double>)
|
||||
IO.Write(Temp + "key" + d + SOi + d + "type=", 1);
|
||||
else if (Key.Trans[SOi] is KeyFrameT2<double, double>)
|
||||
IO.Write(Temp + "key" + d + SOi + d + "type=", 2);
|
||||
else if (Key.Trans[SOi] is KeyFrameT3<double, double>)
|
||||
IO.Write(Temp + "key" + d + SOi + d + "type=", 3);
|
||||
KF = Key.Trans[SOi].Check();
|
||||
IO.Write(Temp + "key" + d + SOi + d + "data=", KF.ToString());
|
||||
int Type = 0;
|
||||
if (KF is KFT0<double, double>) Type = 0;
|
||||
else if (KF is KFT1<double, double>) Type = 1;
|
||||
else if (KF is KFT2<double, double>) Type = 2;
|
||||
else if (KF is KFT3<double, double>) Type = 3;
|
||||
IO.Write(Temp + "key" + d + SOi + d + "type=", Type);
|
||||
}
|
||||
IO.Write(Temp + "key.length=", Key.Length);
|
||||
if (Key.Max != null) IO.Write(Temp + "max=", Key.Max);
|
||||
}
|
||||
else if (Key.Trans != null)
|
||||
{
|
||||
Key.RawData.KeyType = 0;
|
||||
int Length = Key.Trans.Length;
|
||||
ref int KeyType = ref Key.RawData.KeyType;
|
||||
KeyType = 0;
|
||||
IKF<double, double> KF;
|
||||
if (Key.Max != null) IO.Write(Temp + "max=", Key.Max);
|
||||
for (i = 0; i < Key.Trans.Length; i++)
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
if (Key.Trans[i] is KeyFrameT0<double, double> &&
|
||||
Key.RawData.KeyType < 0) Key.RawData.KeyType = 0;
|
||||
else if (Key.Trans[i] is KeyFrameT1<double, double> &&
|
||||
Key.RawData.KeyType < 1) Key.RawData.KeyType = 1;
|
||||
else if (Key.Trans[i] is KeyFrameT2<double, double> &&
|
||||
Key.RawData.KeyType < 2) Key.RawData.KeyType = 2;
|
||||
else if (Key.Trans[i] is KeyFrameT3<double, double> &&
|
||||
Key.RawData.KeyType < 3) break;
|
||||
KF = Key.Trans[i].Check();
|
||||
if (KF is KFT0<double, double> && KeyType < 0) KeyType = 0;
|
||||
else if (KF is KFT1<double, double> && KeyType < 1) KeyType = 1;
|
||||
else if (KF is KFT2<double, double> && KeyType < 2) KeyType = 2;
|
||||
else if (KF is KFT3<double, double> && KeyType < 3) break;
|
||||
}
|
||||
Key.RawData.ValueListSize = Key.Trans.Length * (Key.RawData.KeyType + 1);
|
||||
Key.RawData.ValueListSize = Length * KeyType + Length;
|
||||
IO.Write(Temp + "raw_data.value_list=");
|
||||
if (Key.RawData.KeyType == 0) for (i = 0; i < Key.Trans.Length; i++)
|
||||
IO.Write(Key.Trans[i].ToKeyFrameT0().ToString(false) +
|
||||
((i + 1 < Key.Trans.Length) ? "," : ""));
|
||||
else if (Key.RawData.KeyType == 1) for (i = 0; i < Key.Trans.Length; i++)
|
||||
IO.Write(Key.Trans[i].ToKeyFrameT1().ToString(false) +
|
||||
((i + 1 < Key.Trans.Length) ? "," : ""));
|
||||
else if (Key.RawData.KeyType == 2) for (i = 0; i < Key.Trans.Length; i++)
|
||||
IO.Write(Key.Trans[i].ToKeyFrameT2().ToString(false) +
|
||||
((i + 1 < Key.Trans.Length) ? "," : ""));
|
||||
else if (Key.RawData.KeyType == 3) for (i = 0; i < Key.Trans.Length; i++)
|
||||
IO.Write(Key.Trans[i].ToKeyFrameT3().ToString(false) +
|
||||
((i + 1 < Key.Trans.Length) ? "," : ""));
|
||||
IO.Position = IO.Position - 1;
|
||||
if (KeyType == 0) for (i = 0; i < Length; i++)
|
||||
IO.Write(Key.Trans[i].ToT0().ToString(false) + ((i + 1 < Length) ? "," : ""));
|
||||
else if (KeyType == 1) for (i = 0; i < Length; i++)
|
||||
IO.Write(Key.Trans[i].ToT1().ToString(false) + ((i + 1 < Length) ? "," : ""));
|
||||
else if (KeyType == 2) for (i = 0; i < Length; i++)
|
||||
IO.Write(Key.Trans[i].ToT2().ToString(false) + ((i + 1 < Length) ? "," : ""));
|
||||
else if (KeyType == 3) for (i = 0; i < Length; i++)
|
||||
IO.Write(Key.Trans[i].ToT3().ToString(false) + ((i + 1 < Length) ? "," : ""));
|
||||
IO.Position--;
|
||||
IO.Write('\n');
|
||||
IO.Write(Temp + "raw_data.value_list_size=", Key.RawData.ValueListSize);
|
||||
IO.Write(Temp + "raw_data.value_type=" , Key.RawData.ValueType );
|
||||
IO.Write(Temp + "raw_data_key_type=" , Key.RawData. KeyType );
|
||||
}
|
||||
IO.Write(Temp + "type=", Key.Type & 0xFF);
|
||||
if (Key.RawData.KeyType == null && Key.Trans == null && Key.Value != null)
|
||||
IO.Write(Temp + "type=", (int)Key.Type);
|
||||
if (Key.RawData.KeyType == 0 && Key.Trans == null && Key.Value != null)
|
||||
if (Key.Value != 0) IO.Write(Temp + "value=", Key.Value);
|
||||
}
|
||||
|
||||
@@ -2207,38 +2171,36 @@ namespace KKdMainLib.A3DA
|
||||
if (Key.BinOffset == null || Key.BinOffset < 0) return;
|
||||
|
||||
IO.Position = (int)Key.BinOffset;
|
||||
Key.Type = IO.ReadInt32();
|
||||
int Type = IO.ReadInt32();
|
||||
|
||||
Key.Value = IO.ReadSingle();
|
||||
if (Key.Type == 0x0000 || Key.Type == 0x0001) return;
|
||||
Key.Type = (Key.Interpolation)(Type & 0xFF);
|
||||
if (Key.Type < Key.Interpolation.Lerp) return;
|
||||
Key.Max = IO.ReadSingle();
|
||||
Key.Length = IO.ReadInt32 ();
|
||||
if (Key.Type >> 8 != 0)
|
||||
if (Type >> 8 != 0)
|
||||
{
|
||||
Key.EPTypePost = (Key.Type >> 12) & 0xF;
|
||||
Key.EPTypePre = (Key.Type >> 8) & 0xF;
|
||||
Key.EPTypePost = (Type >> 12) & 0xF;
|
||||
Key.EPTypePre = (Type >> 8) & 0xF;
|
||||
if (Key.EPTypePost == 0) Key.EPTypePost = null;
|
||||
if (Key.EPTypePre == 0) Key.EPTypePre = null;
|
||||
}
|
||||
Key.Type = Key.Type & 0xFF;
|
||||
Key.Trans = new IKeyFrame<double, double>[(int)Key.Length];
|
||||
KeyFrameT3<double, double> Temp;
|
||||
Key.Trans = new KFT3<double, double>[Key.Length];
|
||||
KFT3<double, double> Temp;
|
||||
for (int i = 0; i < Key.Length; i++)
|
||||
{
|
||||
Temp = new KeyFrameT3<double, double>();
|
||||
Temp = new KFT3<double, double>();
|
||||
if (F16 && C_F16 > 0)
|
||||
{ Temp.Frame = IO.ReadUInt16(); Temp.Value = (double)IO.ReadHalf (); }
|
||||
{ Temp.F = IO.ReadUInt16(); Temp.V = (double)IO.ReadHalf (); }
|
||||
else
|
||||
{ Temp.Frame = IO.ReadSingle(); Temp.Value = IO.ReadSingle(); }
|
||||
{ Temp.F = IO.ReadSingle(); Temp.V = IO.ReadSingle(); }
|
||||
|
||||
if (F16 && C_F16 == 2)
|
||||
{ Temp.Interpolation1 = (double)IO.ReadHalf ();
|
||||
Temp.Interpolation2 = (double)IO.ReadHalf (); }
|
||||
{ Temp.T1 = (double)IO.ReadHalf (); Temp.T2 = (double)IO.ReadHalf (); }
|
||||
else
|
||||
{ Temp.Interpolation1 = IO.ReadSingle();
|
||||
Temp.Interpolation2 = IO.ReadSingle(); }
|
||||
{ Temp.T1 = IO.ReadSingle(); Temp.T2 = IO.ReadSingle(); }
|
||||
|
||||
Key.Trans[i] = Temp.Check();
|
||||
Key.Trans[i] = Temp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2304,47 +2266,36 @@ namespace KKdMainLib.A3DA
|
||||
{
|
||||
if (k.Object == null) return null;
|
||||
|
||||
Key Key = new Key { EPTypePost = k.ReadNInt32("EPTypePost"),
|
||||
EPTypePre = k.ReadNInt32("EPTypePre"), Max = k.ReadNDouble("Max"),
|
||||
Type = k.ReadNInt32("Type"), Value = k.ReadNDouble("Value") };
|
||||
Key Key = new Key { EPTypePost = k.ReadNInt32("EPTypePost"), EPTypePre =
|
||||
k.ReadNInt32("EPTypePre"), Max = k.ReadNDouble("Max"), Value = k.ReadNDouble("Value") };
|
||||
if (!Enum.TryParse(k.ReadString("Type"), out Key.Interpolation Type)) { Key.Value = null; return Key; }
|
||||
Key.Type = Type;
|
||||
if (Key.Type == 0) { Key.Value = 0; return Key; }
|
||||
else if (Key.Type < Key.Interpolation.Lerp) return Key;
|
||||
|
||||
if (k.ReadBoolean("RawData")) Key.RawData = new Key.RawD() { KeyType = -1, ValueType = "float" };
|
||||
if (Key.Type == 0) Key.Value = 0.0;
|
||||
|
||||
if (Key.Type < 2) return Key;
|
||||
|
||||
if (!k.ElementArray("Trans", out MsgPack Trans)) return Key;
|
||||
|
||||
Key.Length = Trans.Array.Length;
|
||||
Key.Trans = new IKeyFrame<double, double>[Key.Length.Value];
|
||||
Key.Trans = new KFT3<double, double>[Key.Length];
|
||||
for (int i = 0; i < Key.Length; i++)
|
||||
{
|
||||
if (Trans[i].Array == null) continue;
|
||||
else if (Trans[i].Array.Length == 0) continue;
|
||||
else if (Trans[i].Array.Length == 1)
|
||||
Key.Trans[i] = new KeyFrameT0<double, double>
|
||||
{ Frame = Trans[i][0].ReadDouble() };
|
||||
Key.Trans[i] = new KFT3<double, double>
|
||||
(Trans[i][0].ReadDouble());
|
||||
else if (Trans[i].Array.Length == 2)
|
||||
Key.Trans[i] = new KeyFrameT1<double, double>
|
||||
{
|
||||
Frame = Trans[i][0].ReadDouble(),
|
||||
Value = Trans[i][1].ReadDouble(),
|
||||
};
|
||||
Key.Trans[i] = new KFT3<double, double>
|
||||
(Trans[i][0].ReadDouble(), Trans[i][1].ReadDouble());
|
||||
else if (Trans[i].Array.Length == 3)
|
||||
Key.Trans[i] = new KeyFrameT2<double, double>
|
||||
{
|
||||
Frame = Trans[i][0].ReadDouble(),
|
||||
Value = Trans[i][1].ReadDouble(),
|
||||
Interpolation = Trans[i][2].ReadDouble(),
|
||||
};
|
||||
Key.Trans[i] = new KFT3<double, double>
|
||||
(Trans[i][0].ReadDouble(), Trans[i][1].ReadDouble(),
|
||||
Trans[i][2].ReadDouble(), Trans[i][2].ReadDouble());
|
||||
else if (Trans[i].Array.Length == 4)
|
||||
Key.Trans[i] = new KeyFrameT3<double, double>
|
||||
{
|
||||
Frame = Trans[i][0].ReadDouble(),
|
||||
Value = Trans[i][1].ReadDouble(),
|
||||
Interpolation1 = Trans[i][2].ReadDouble(),
|
||||
Interpolation2 = Trans[i][3].ReadDouble(),
|
||||
};
|
||||
Key.Trans[i] = Key.Trans[i].Check();
|
||||
Key.Trans[i] = new KFT3<double, double>
|
||||
(Trans[i][0].ReadDouble(), Trans[i][1].ReadDouble(),
|
||||
Trans[i][2].ReadDouble(), Trans[i][3].ReadDouble());
|
||||
}
|
||||
return Key;
|
||||
}
|
||||
@@ -2375,49 +2326,32 @@ namespace KKdMainLib.A3DA
|
||||
|
||||
public static MsgPack Add(this MsgPack MsgPack, string name, Key Key)
|
||||
{
|
||||
if (Key == null) return MsgPack;
|
||||
if (Key.Type == null) return MsgPack;
|
||||
if (Key == null || Key.Type == null) return MsgPack;
|
||||
|
||||
MsgPack Keys = new MsgPack(name).Add("Type", Key.Type);
|
||||
if (Key.Trans != null)
|
||||
MsgPack Keys = new MsgPack(name).Add("Type", Key.Type.ToString());
|
||||
if (Key.Trans != null && Key.Type != Key.Interpolation.Null)
|
||||
{
|
||||
Keys = Keys.Add("Max", Key.Max).Add("EPTypePost", Key.EPTypePost).Add("EPTypePre", Key.EPTypePre);
|
||||
|
||||
if (Key.RawData.KeyType != null) Keys.Add("RawData", true);
|
||||
if (Key.RawData.KeyType != 0) Keys.Add("RawData", true);
|
||||
|
||||
MsgPack Trans = new MsgPack(Key.Trans.Length, "Trans");
|
||||
MsgPack K;
|
||||
for (int i = 0; i < Key.Trans.Length; i++)
|
||||
if (Key.Trans[i] is KeyFrameT0<double, double> KeyFrameT0)
|
||||
{
|
||||
K = new MsgPack(1);
|
||||
K[0] = (MsgPack)KeyFrameT0.Frame;
|
||||
Trans[i] = K;
|
||||
}
|
||||
else if (Key.Trans[i] is KeyFrameT1<double, double> KeyFrameT1)
|
||||
{
|
||||
K = new MsgPack(2);
|
||||
K[0] = (MsgPack)KeyFrameT1.Frame;
|
||||
K[1] = (MsgPack)KeyFrameT1.Value;
|
||||
Trans[i] = K;
|
||||
}
|
||||
else if (Key.Trans[i] is KeyFrameT2<double, double> KeyFrameT2)
|
||||
{
|
||||
K = new MsgPack(3);
|
||||
K[0] = (MsgPack)KeyFrameT2.Frame;
|
||||
K[1] = (MsgPack)KeyFrameT2.Value;
|
||||
K[2] = (MsgPack)KeyFrameT2.Interpolation;
|
||||
Trans[i] = K;
|
||||
}
|
||||
else if (Key.Trans[i] is KeyFrameT3<double, double> KeyFrameT3)
|
||||
{
|
||||
K = new MsgPack(4);
|
||||
K[0] = (MsgPack)KeyFrameT3.Frame;
|
||||
K[1] = (MsgPack)KeyFrameT3.Value;
|
||||
K[2] = (MsgPack)KeyFrameT3.Interpolation1;
|
||||
K[3] = (MsgPack)KeyFrameT3.Interpolation2;
|
||||
Trans[i] = K;
|
||||
}
|
||||
{
|
||||
IKF<double, double> KF = Key.Trans[i].Check();
|
||||
if (KF is KFT0<double, double> KFT0)
|
||||
Trans[i] = new MsgPack(null, new MsgPack[]
|
||||
{ (MsgPack)KFT0.F });
|
||||
else if (KF is KFT1<double, double> KFT1)
|
||||
Trans[i] = new MsgPack(null, new MsgPack[]
|
||||
{ (MsgPack)KFT1.F, (MsgPack)KFT1.V });
|
||||
else if (KF is KFT2<double, double> KFT2)
|
||||
Trans[i] = new MsgPack(null, new MsgPack[]
|
||||
{ (MsgPack)KFT2.F, (MsgPack)KFT2.V, (MsgPack)KFT2.T });
|
||||
else if (KF is KFT3<double, double> KFT3)
|
||||
Trans[i] = new MsgPack(null, new MsgPack[]
|
||||
{ (MsgPack)KFT3.F, (MsgPack)KFT3.V, (MsgPack)KFT3.T1, (MsgPack)KFT3.T2, });
|
||||
}
|
||||
Keys.Add(Trans);
|
||||
}
|
||||
else if (Key.Value != 0) Keys.Add("Value", Key.Value);
|
||||
@@ -2435,7 +2369,7 @@ namespace KKdMainLib.A3DA
|
||||
public static void Write(this Stream IO, string Data, double? val, byte r)
|
||||
{ if (val != null) IO.Write(Data, (double)val, r); }
|
||||
public static void Write(this Stream IO, string Data, ref bool val) =>
|
||||
IO.Write(Data, Main.ToString(val));
|
||||
IO.Write(Data, Extensions.ToString(val));
|
||||
public static void Write(this Stream IO, string Data, long val) =>
|
||||
IO.Write(Data, val.ToString( ));
|
||||
public static void Write(this Stream IO, string Data, ulong val) =>
|
||||
@@ -2457,6 +2391,8 @@ namespace KKdMainLib.A3DA
|
||||
public int StringLength;
|
||||
public int StringOffset;
|
||||
|
||||
public Format Format;
|
||||
|
||||
public string[] Motion;
|
||||
public string[] ObjectList;
|
||||
public string[] ObjectHRCList;
|
||||
@@ -2472,7 +2408,6 @@ namespace KKdMainLib.A3DA
|
||||
public ObjectHRC[] ObjectHRC;
|
||||
public CameraRoot[] CameraRoot;
|
||||
public MObjectHRC[] MObjectHRC;
|
||||
public Main.Format Format;
|
||||
public PlayControl PlayControl;
|
||||
public PostProcess PostProcess;
|
||||
public MaterialList[] MaterialList;
|
||||
@@ -2560,23 +2495,32 @@ namespace KKdMainLib.A3DA
|
||||
|
||||
public class Key
|
||||
{
|
||||
public int? Type;
|
||||
public int? Length;
|
||||
public Interpolation? Type;
|
||||
public int Length;
|
||||
public int? BinOffset;
|
||||
public int? EPTypePre;
|
||||
public int? EPTypePost;
|
||||
public double? Max;
|
||||
public double? Value;
|
||||
public RawD RawData;
|
||||
public IKeyFrame<double, double>[] Trans;
|
||||
public KFT3<double, double>[] Trans;
|
||||
|
||||
public struct RawD
|
||||
{
|
||||
public int? KeyType;
|
||||
public int? ValueListSize;
|
||||
public int KeyType;
|
||||
public int ValueListSize;
|
||||
public string ValueType;
|
||||
public string[] ValueList;
|
||||
}
|
||||
|
||||
public enum Interpolation
|
||||
{
|
||||
Null = 0,
|
||||
Value = 1,
|
||||
Lerp = 2,
|
||||
Hermite = 3,
|
||||
Hold = 4,
|
||||
}
|
||||
}
|
||||
|
||||
public struct Light
|
||||
|
||||
+4
-15
@@ -1,8 +1,8 @@
|
||||
//Original: AetSet.bt Version: 2.0 by samyuu
|
||||
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.Types;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib.Aet
|
||||
{
|
||||
@@ -200,8 +200,7 @@ namespace KKdMainLib.Aet
|
||||
{
|
||||
IO.Align(0x10);
|
||||
Aet.Unknown.Offset = IO.Position;
|
||||
for (i = 0; i < Aet.Unknown.Count * 10; i++)
|
||||
IO.Write(0L);
|
||||
for (i = 0; i < Aet.Unknown.Count * 10; i++) IO.Write(0L);
|
||||
}
|
||||
|
||||
IO.Align(0x10);
|
||||
@@ -213,7 +212,7 @@ namespace KKdMainLib.Aet
|
||||
for (i = 0; i < NullValPointers.Count; i++)
|
||||
{
|
||||
IO.Position = NullValPointers[i];
|
||||
IO.Write(ReturnPosition + i * 4);
|
||||
IO.Write(ReturnPosition + i << 2);
|
||||
}
|
||||
|
||||
for (i = 0; i < Aet.Layers.Count; i++)
|
||||
@@ -436,15 +435,6 @@ namespace KKdMainLib.Aet
|
||||
|
||||
public static class AetExt
|
||||
{
|
||||
private readonly static System.Text.Encoding ShiftJIS = System.Text.Encoding.GetEncoding(932);
|
||||
|
||||
public static Pointer<string> ReadPointerStringShiftJIS(this Stream IO)
|
||||
{ Pointer<string> val = IO.ReadPointer<string>();
|
||||
val.Value = ShiftJIS.GetString(IO.ReadAtOffset(val.Offset)); return val; }
|
||||
|
||||
public static void WriteShiftJIS(this Stream IO, string String) =>
|
||||
IO.Write(ShiftJIS.GetBytes(String));
|
||||
|
||||
public static MsgPack ReadMP(this MsgPack msg, ref CountPointer<float> val, string Name)
|
||||
{
|
||||
val.Offset = 0;
|
||||
@@ -870,7 +860,6 @@ namespace KKdMainLib.Aet
|
||||
public struct AetHeader
|
||||
{
|
||||
public Pointer<AetData>[] Data;
|
||||
public POF POF;
|
||||
}
|
||||
|
||||
public struct AetData
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
@@ -198,7 +198,7 @@ namespace KKdMainLib.DB
|
||||
for (int i = 0; i < AetSets.Length; i++)
|
||||
AetSets[i].ReadMsgPack(AetDB[i]);
|
||||
}
|
||||
MsgPack = MsgPack.New;
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.A3DA;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
@@ -20,7 +20,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
IO = File.OpenReader(file + ".bin");
|
||||
|
||||
IO.Format = Main.Format.F;
|
||||
IO.Format = Format.F;
|
||||
Signature = IO.ReadInt32();
|
||||
if (Signature != 0x44334123) return;
|
||||
Signature = IO.ReadInt32();
|
||||
@@ -117,7 +117,7 @@ namespace KKdMainLib.DB
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgPack = MsgPack.New;
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
|
||||
+19
-17
@@ -1,8 +1,8 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
@@ -84,8 +84,8 @@ namespace KKdMainLib.DB
|
||||
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> Ids = new List<int>();
|
||||
List<int> SetIds = new List<int>();
|
||||
|
||||
List<int> NotAdd = new List<int>();
|
||||
SpriteTexture temp;
|
||||
@@ -143,13 +143,13 @@ namespace KKdMainLib.DB
|
||||
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++; }
|
||||
while (set.Textures[i0].Id == null)
|
||||
if (!Ids.Contains(i1)) Ids.Add((int)(SpriteSets[i].Textures[i0].Id = i1)); else i1++;
|
||||
|
||||
for (i0 = 0, i1 = 0; i0 < set. Sprites.Length; i0++)
|
||||
while (set. Sprites[i0].Id == null)
|
||||
if (!Ids.Contains(i1)) Ids.Add((int)(SpriteSets[i]. Sprites[i0].Id = i1)); else i1++;
|
||||
}
|
||||
|
||||
Ids = null;
|
||||
@@ -175,18 +175,20 @@ namespace KKdMainLib.DB
|
||||
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 (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"); }
|
||||
}
|
||||
|
||||
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"); }
|
||||
SpriteSets[i]. NameOffset = IO.Position; IO.Write(SpriteSets[i]. Name + "\0");
|
||||
SpriteSets[i].FileNameOffset = IO.Position; IO.Write(SpriteSets[i].FileName + "\0");
|
||||
}
|
||||
|
||||
IO.Align(0x08, true);
|
||||
@@ -235,7 +237,7 @@ namespace KKdMainLib.DB
|
||||
for (int i = 0; i < SpriteSets.Length; i++)
|
||||
SpriteSets[i].ReadMsgPack(SprDB[i]);
|
||||
}
|
||||
MsgPack = MsgPack.New;
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
|
||||
+42
-42
@@ -1,41 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public class DEX
|
||||
{
|
||||
public DEX()
|
||||
{ Dex = null; Header = new PDHead(); }
|
||||
{ Dex = null; Header = new Header(); }
|
||||
|
||||
private int Offset = 0;
|
||||
private PDHead Header;
|
||||
private Header Header;
|
||||
private Stream IO;
|
||||
|
||||
public EXP[] Dex;
|
||||
|
||||
public int DEXReader(string filepath, string ext)
|
||||
{
|
||||
Header = new PDHead();
|
||||
Header = new Header();
|
||||
IO = File.OpenReader(filepath + ext);
|
||||
|
||||
Header.Format = Main.Format.F;
|
||||
Header.Format = Format.F;
|
||||
Header.SectionSignature = IO.ReadInt32();
|
||||
if (Header.SectionSignature == 0x43505845)
|
||||
Header = IO.ReadHeader(true);
|
||||
if (Header.SectionSignature != 0x64)
|
||||
return 0;
|
||||
Header = IO.ReadHeader(true, true);
|
||||
if (Header.SectionSignature != 0x64) return 0;
|
||||
|
||||
Offset = IO.Position - 0x4;
|
||||
IO.Offset = IO.Position - 0x4;
|
||||
Dex = new EXP[IO.ReadInt32()];
|
||||
int DEXOffset = IO.ReadInt32();
|
||||
if (IO.ReadInt32() == 0x00) Header.Format = Main.Format.X;
|
||||
int DEXNameOffset = IO.ReadInt32();
|
||||
if (Header.IsX) IO.ReadInt32();
|
||||
if (DEXNameOffset == 0x00) { Header.Format = Format.X; DEXNameOffset = (int)IO.ReadInt64(); }
|
||||
|
||||
IO.Seek(DEXOffset + Offset, 0);
|
||||
IO.Seek(DEXOffset, 0);
|
||||
for (int i0 = 0; i0 < Dex.Length; i0++)
|
||||
Dex[i0] = new EXP { Main = new List<EXPElement>(), Eyes = new List<EXPElement>() };
|
||||
|
||||
@@ -46,7 +44,7 @@ namespace KKdMainLib
|
||||
Dex[i0].EyesOffset = IO.ReadInt32();
|
||||
if (Header.IsX) IO.ReadInt32();
|
||||
}
|
||||
IO.Seek(DEXNameOffset + Offset, 0);
|
||||
IO.Seek(DEXNameOffset, 0);
|
||||
for (int i0 = 0; i0 < Dex.Length; i0++)
|
||||
{
|
||||
Dex[i0].NameOffset = IO.ReadInt32();
|
||||
@@ -70,7 +68,7 @@ namespace KKdMainLib
|
||||
break;
|
||||
}
|
||||
|
||||
IO.Seek(Dex[i0].EyesOffset + Offset, 0);
|
||||
IO.Seek(Dex[i0].EyesOffset, 0);
|
||||
while(true)
|
||||
{
|
||||
element.Frame = IO.ReadSingle();
|
||||
@@ -80,25 +78,23 @@ namespace KKdMainLib
|
||||
element.Trans = IO.ReadSingle();
|
||||
Dex[i0].Eyes.Add(element);
|
||||
|
||||
if (element.Frame == 999999 || element.Both == 0xFFFF)
|
||||
break;
|
||||
if (element.Frame == 999999 || element.Both == 0xFFFF) break;
|
||||
}
|
||||
|
||||
IO.Seek(Dex[i0].NameOffset + Offset, 0);
|
||||
Dex[i0].Name = IO.NullTerminatedUTF8();
|
||||
Dex[i0].Name = IO.ReadStringAtOffset(Dex[i0].NameOffset);
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void DEXWriter(string filepath, Main.Format Format)
|
||||
public void DEXWriter(string filepath, Format Format)
|
||||
{
|
||||
Header = new PDHead() { Format = Format };
|
||||
IO = File.OpenWriter(filepath + (Format > Main.Format.F ? ".dex" : ".bin"), true);
|
||||
IO.Format = Format;
|
||||
Header = new Header();
|
||||
IO = File.OpenWriter(filepath + (Format > Format.F ? ".dex" : ".bin"), true);
|
||||
Header.Format = IO.Format = Format;
|
||||
|
||||
IO.Offset = Format > Main.Format.F ? 0x20 : 0;
|
||||
IO.Offset = Format > Format.F ? 0x20 : 0;
|
||||
IO.Write(0x64);
|
||||
IO.Write(Dex.Length);
|
||||
|
||||
@@ -157,7 +153,7 @@ namespace KKdMainLib
|
||||
IO.Position = Position0 - (Header.IsX ? 8 : 4);
|
||||
IO.Write(Position1);
|
||||
|
||||
if (Format > Main.Format.F)
|
||||
if (Format > Format.F)
|
||||
{
|
||||
Offset = IO.Length;
|
||||
IO.Offset = 0;
|
||||
@@ -172,15 +168,15 @@ namespace KKdMainLib
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
public int MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
int i0 = 0;
|
||||
int i1 = 0;
|
||||
this.Dex = new EXP[0];
|
||||
Header = new PDHead();
|
||||
Header = new Header();
|
||||
|
||||
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
|
||||
if (!MsgPack.ElementArray("Dex", out MsgPack Dex)) return;
|
||||
if (!MsgPack.ElementArray("Dex", out MsgPack Dex)) return 0;
|
||||
|
||||
this.Dex = new EXP[Dex.Array.Length];
|
||||
for (i0 = 0; i0 < this.Dex.Length; i0++)
|
||||
@@ -191,23 +187,19 @@ namespace KKdMainLib
|
||||
{
|
||||
this.Dex[i0].Main = new List<EXPElement>();
|
||||
for (i1 = 0; i1 < Main.Array.Length; i1++)
|
||||
this.Dex[i0].Main.Add(ReadEXP(Main[i1]));
|
||||
this.Dex[i0].Main.Add(EXPElement.Read(Main[i1]));
|
||||
}
|
||||
if (Dex[i0].ElementArray("Eyes", out MsgPack Eyes))
|
||||
{
|
||||
this.Dex[i0].Eyes = new List<EXPElement>();
|
||||
for (i1 = 0; i1 < Eyes.Array.Length; i1++)
|
||||
this.Dex[i0].Eyes.Add(ReadEXP(Eyes[i1]));
|
||||
this.Dex[i0].Eyes.Add(EXPElement.Read(Eyes[i1]));
|
||||
}
|
||||
}
|
||||
MsgPack = MsgPack.New;
|
||||
MsgPack.Dispose();
|
||||
return 1;
|
||||
}
|
||||
|
||||
private EXPElement ReadEXP(MsgPack mp) =>
|
||||
new EXPElement() { Frame = mp.ReadSingle("F"), Both = mp.ReadUInt16("B"),
|
||||
ID = mp.ReadUInt16("I"), Value = mp.ReadSingle("V"),
|
||||
Trans = mp.ReadSingle("T") };
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
int i0 = 0;
|
||||
@@ -218,12 +210,12 @@ namespace KKdMainLib
|
||||
MsgPack EXP = MsgPack.New.Add("Name", this.Dex[i0].Name);
|
||||
MsgPack Main = new MsgPack(this.Dex[i0].Main.Count, "Main");
|
||||
for (i1 = 0; i1 < this.Dex[i0].Main.Count; i1++)
|
||||
Main[i1] = WriteEXP(this.Dex[i0].Main[i1]);
|
||||
Main[i1] = this.Dex[i0].Main[i1].Write();
|
||||
EXP.Add(Main);
|
||||
|
||||
MsgPack Eyes = new MsgPack(this.Dex[i0].Eyes.Count, "Eyes");
|
||||
for (i1 = 0; i1 < this.Dex[i0].Eyes.Count; i1++)
|
||||
Eyes[i1] = WriteEXP(this.Dex[i0].Eyes[i1]);
|
||||
Eyes[i1] = this.Dex[i0].Eyes[i1].Write();
|
||||
EXP.Add(Eyes);
|
||||
Dex[i0] = EXP;
|
||||
}
|
||||
@@ -231,10 +223,6 @@ namespace KKdMainLib
|
||||
Dex.Write(true, file, JSON);
|
||||
}
|
||||
|
||||
private MsgPack WriteEXP(EXPElement element) =>
|
||||
MsgPack.New.Add("F", element.Frame).Add("B", element.Both ).Add("I", element.ID )
|
||||
.Add("V", element.Value).Add("T", element.Trans);
|
||||
|
||||
public struct EXP
|
||||
{
|
||||
public int MainOffset;
|
||||
@@ -243,6 +231,8 @@ namespace KKdMainLib
|
||||
public string Name;
|
||||
public List<EXPElement> Main;
|
||||
public List<EXPElement> Eyes;
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
|
||||
public struct EXPElement
|
||||
@@ -252,6 +242,16 @@ namespace KKdMainLib
|
||||
public ushort ID;
|
||||
public float Value;
|
||||
public float Trans;
|
||||
|
||||
public static EXPElement Read(MsgPack msg) =>
|
||||
new EXPElement() { Frame = msg.ReadSingle("F"), Both = msg.ReadUInt16("B"),
|
||||
ID = msg.ReadUInt16("I"), Value = msg.ReadSingle("V"),
|
||||
Trans = msg.ReadSingle("T"), };
|
||||
|
||||
public MsgPack Write() =>
|
||||
MsgPack.New.Add("F", Frame).Add("B", Both )
|
||||
.Add("I", ID).Add("V", Value)
|
||||
.Add("T", Trans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+28
-28
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using MSIO = System.IO;
|
||||
|
||||
@@ -13,54 +14,53 @@ namespace KKdMainLib
|
||||
|
||||
public static void Decrypt(this string file)
|
||||
{
|
||||
Console.Title = "DIVAFILE Decrypt - File: " + Path.GetFileName(file);
|
||||
Stream reader = File.OpenReader(file);
|
||||
if (reader.ReadInt64() != 0x454C494641564944)
|
||||
{ reader.Close(); return; }
|
||||
int StreamLenght = reader.ReadInt32();
|
||||
int FileLenght = reader.ReadInt32();
|
||||
byte[] decrypted = new byte[StreamLenght];
|
||||
reader.Seek(0, 0);
|
||||
Stream IO = File.OpenReader(file);
|
||||
if (IO.ReadInt64() != 0x454C494641564944)
|
||||
{ IO.Close(); return; }
|
||||
int StreamLength = IO.ReadInt32();
|
||||
int FileLength = IO.ReadInt32();
|
||||
byte[] encrypted = IO.ReadBytes(StreamLength);
|
||||
byte[] decrypted = new byte[StreamLength];
|
||||
IO.Close();
|
||||
|
||||
using (AesManaged crypto = new AesManaged())
|
||||
{
|
||||
crypto.Key = Key; crypto.IV = new byte[16];
|
||||
crypto.Mode = CipherMode.ECB; crypto.Padding = PaddingMode.Zeros;
|
||||
using (CryptoStream cryptoData = new CryptoStream(reader.BaseStream,
|
||||
using (CryptoStream cryptoData = new CryptoStream(new MSIO.MemoryStream(encrypted),
|
||||
crypto.CreateDecryptor(crypto.Key, crypto.IV), CryptoStreamMode.Read))
|
||||
cryptoData.Read(decrypted, 0, StreamLenght);
|
||||
cryptoData.Read(decrypted, 0, StreamLength);
|
||||
}
|
||||
Stream writer = File.OpenWriter(file, FileLenght);
|
||||
for (int i = 0x10; i < StreamLenght && i < FileLenght + 0x10; i++)
|
||||
writer.Write(decrypted[i]);
|
||||
writer.Close();
|
||||
IO = File.OpenWriter(file, FileLength);
|
||||
IO.Write(decrypted, FileLength < StreamLength ? FileLength : StreamLength);
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public static void Encrypt(this string file)
|
||||
{
|
||||
Console.Title = "DIVAFILE Encrypt - File: " + Path.GetFileName(file);
|
||||
Stream reader = File.OpenReader(file);
|
||||
int FileLenghtOrigin = reader.Length;
|
||||
int FileLenght = FileLenghtOrigin.Align(16);
|
||||
reader.Close();
|
||||
Stream IO = File.OpenReader(file);
|
||||
int FileLengthOrigin = IO.Length;
|
||||
int FileLength = FileLengthOrigin.Align(16);
|
||||
IO.Close();
|
||||
byte[] In = File.OpenReader(file).ToArray(true);
|
||||
byte[] Inalign = new byte[FileLenght];
|
||||
byte[] Inalign = new byte[FileLength];
|
||||
for (int i = 0; i < In.Length; i++) Inalign[i] = In[i];
|
||||
In = null;
|
||||
byte[] encrypted = new byte[FileLenght];
|
||||
byte[] encrypted = new byte[FileLength];
|
||||
using (AesManaged crypto = new AesManaged())
|
||||
{
|
||||
crypto.Key = Key; crypto.IV = new byte[16];
|
||||
crypto.Mode = CipherMode.ECB; crypto.Padding = PaddingMode.Zeros;
|
||||
using (CryptoStream cryptoData = new CryptoStream(new MSIO.MemoryStream(Inalign),
|
||||
crypto.CreateEncryptor(crypto.Key, crypto.IV), CryptoStreamMode.Read))
|
||||
cryptoData.Read(encrypted, 0, FileLenght);
|
||||
cryptoData.Read(encrypted, 0, FileLength);
|
||||
}
|
||||
Stream writer = File.OpenWriter(file, Inalign.Length);
|
||||
writer.Write(0x454C494641564944);
|
||||
writer.Write(FileLenght);
|
||||
writer.Write(FileLenghtOrigin);
|
||||
writer.Write(encrypted);
|
||||
writer.Close();
|
||||
IO = File.OpenWriter(file, Inalign.Length);
|
||||
IO.Write(0x454C494641564944);
|
||||
IO.Write(FileLength);
|
||||
IO.Write(FileLengthOrigin);
|
||||
IO.Write(encrypted);
|
||||
IO.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-23
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
@@ -100,13 +100,13 @@ namespace KKdMainLib
|
||||
Success = true;
|
||||
}
|
||||
|
||||
MsgPack = MsgPack.New;
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON, bool Compact = true)
|
||||
{
|
||||
if (!Success) return;
|
||||
MsgPack msgPack = MsgPack.New;
|
||||
MsgPack MsgPack = MsgPack.New;
|
||||
|
||||
if (file.Contains("psrData"))
|
||||
{
|
||||
@@ -114,23 +114,23 @@ namespace KKdMainLib
|
||||
{
|
||||
MsgPack psrData = new MsgPack(psrDat.Length, "psrData");
|
||||
for (i = 0; i < psrDat.Length; i++) psrData[i] = psrDat[i].WriteMP();
|
||||
msgPack.Add(psrData);
|
||||
MsgPack.Add(psrData);
|
||||
}
|
||||
else msgPack.Add(new MsgPack("psrData", null));
|
||||
else MsgPack.Add(new MsgPack("psrData", null));
|
||||
}
|
||||
else if (file.Contains("PvList"))
|
||||
{
|
||||
if (psrDat != null)
|
||||
if (pvList != null)
|
||||
{
|
||||
if (Compact) msgPack.Add("Compact", Compact);
|
||||
if (Compact) MsgPack.Add("Compact", Compact);
|
||||
|
||||
MsgPack PvList = new MsgPack(pvList.Length, "PvList");
|
||||
for (i = 0; i < pvList.Length; i++) PvList[i] = pvList[i].WriteMP(Compact);
|
||||
msgPack.Add(PvList);
|
||||
MsgPack.Add(PvList);
|
||||
}
|
||||
else msgPack.Add(new MsgPack("PvList", null));
|
||||
else MsgPack.Add(new MsgPack("PvList", null));
|
||||
}
|
||||
msgPack.Write(file, JSON).Dispose();
|
||||
MsgPack.Write(file, JSON).Dispose();
|
||||
}
|
||||
|
||||
public static string UrlEncode(string value) =>
|
||||
@@ -278,25 +278,25 @@ namespace KKdMainLib
|
||||
|
||||
public MsgPack WriteMP(bool Compact)
|
||||
{
|
||||
MsgPack msgPack = MsgPack.New;
|
||||
msgPack.Add("ID", PV_ID);
|
||||
if (!Enable) msgPack.Add("Enable", Enable);
|
||||
if ( Extra ) msgPack.Add("Extra" , Extra );
|
||||
MsgPack MsgPack = MsgPack.New;
|
||||
MsgPack.Add("ID", PV_ID);
|
||||
if (!Enable) MsgPack.Add("Enable", Enable);
|
||||
if ( Extra ) MsgPack.Add("Extra" , Extra );
|
||||
if (Compact)
|
||||
{
|
||||
if (AdvDemoStart.WriteLower) msgPack.Add("AdvDemoStart", AdvDemoStart.WriteInt());
|
||||
if (AdvDemoEnd .WriteLower) msgPack.Add("AdvDemoEnd" , AdvDemoEnd .WriteInt());
|
||||
if (StartShow .WriteLower) msgPack.Add("StartShow" , StartShow .WriteInt());
|
||||
if ( EndShow .WriteUpper) msgPack.Add( "EndShow" , EndShow .WriteInt());
|
||||
if (AdvDemoStart.WriteLower) MsgPack.Add("AdvDemoStart", AdvDemoStart.WriteInt());
|
||||
if (AdvDemoEnd .WriteLower) MsgPack.Add("AdvDemoEnd" , AdvDemoEnd .WriteInt());
|
||||
if (StartShow .WriteLower) MsgPack.Add("StartShow" , StartShow .WriteInt());
|
||||
if ( EndShow .WriteUpper) MsgPack.Add( "EndShow" , EndShow .WriteInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AdvDemoStart.WriteLower) msgPack.Add(AdvDemoStart.WriteMP("AdvDemoStart"));
|
||||
if (AdvDemoEnd .WriteLower) msgPack.Add(AdvDemoEnd .WriteMP("AdvDemoEnd" ));
|
||||
if (StartShow .WriteLower) msgPack.Add(StartShow .WriteMP("StartShow" ));
|
||||
if ( EndShow .WriteUpper) msgPack.Add( EndShow .WriteMP( "EndShow" ));
|
||||
if (AdvDemoStart.WriteLower) MsgPack.Add(AdvDemoStart.WriteMP("AdvDemoStart"));
|
||||
if (AdvDemoEnd .WriteLower) MsgPack.Add(AdvDemoEnd .WriteMP("AdvDemoEnd" ));
|
||||
if (StartShow .WriteLower) MsgPack.Add(StartShow .WriteMP("StartShow" ));
|
||||
if ( EndShow .WriteUpper) MsgPack.Add( EndShow .WriteMP( "EndShow" ));
|
||||
}
|
||||
return msgPack;
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public static class HeaderExtensions
|
||||
{
|
||||
public static Header ReadHeader(this Stream stream, bool Seek, bool ReadSectionSignature = true)
|
||||
{
|
||||
if (Seek)
|
||||
if (stream.LongPosition > 4) stream.LongPosition -= 4;
|
||||
else stream.LongPosition = 0;
|
||||
return stream.ReadHeader(ReadSectionSignature);
|
||||
}
|
||||
|
||||
public static Header ReadHeader(this Stream stream, bool ReadSectionSignature = true)
|
||||
{
|
||||
Header Header = new Header { Format = Format.F2LE, Signature = stream.ReadInt32(),
|
||||
DataSize = stream.ReadInt32(), Length = stream.ReadInt32() };
|
||||
if (stream.ReadUInt32() == 0x18000000)
|
||||
{ Header.Format = Format.F2BE; }
|
||||
Header.ID = stream.ReadInt32();
|
||||
Header.SectionSize = stream.ReadInt32();
|
||||
Header.SubID = stream.ReadInt32();
|
||||
stream.ReadInt32();
|
||||
if (Header.Length == 0x40)
|
||||
{
|
||||
stream.ReadInt64();
|
||||
stream.ReadInt64();
|
||||
Header.InnerSignature = stream.ReadInt32();
|
||||
stream.ReadInt32();
|
||||
stream.ReadInt64();
|
||||
}
|
||||
stream.Format = Header.Format;
|
||||
if (ReadSectionSignature) Header.SectionSignature = stream.ReadInt32Endian();
|
||||
return Header;
|
||||
}
|
||||
|
||||
public static void Write(this Stream stream, Header Header, bool Extended = false)
|
||||
{
|
||||
stream.Write(Header.Signature);
|
||||
stream.Write(Header.DataSize);
|
||||
stream.Write((Header.Format < Format.X && Extended) ? 0x40 : 0x20);
|
||||
stream.Write(Header.Format == Format.F2BE ? 0x18000000 : 0x10000000);
|
||||
stream.Write(Header.ID);
|
||||
stream.Write(Header.SectionSize);
|
||||
stream.Write(Header.SubID);
|
||||
stream.Write(0x00);
|
||||
if (Header.Format < Format.X && Extended)
|
||||
{
|
||||
stream.Write(Header.Format < Format.MGF ? (int)((Header.SectionSignature ^
|
||||
(Header.DataSize * (long)Header.Signature)) - Header.ID + Header.SectionSize) : 0);
|
||||
stream.Write(0x00);
|
||||
stream.Write(0x00L);
|
||||
stream.Write(Header.InnerSignature);
|
||||
stream.Write(0x00);
|
||||
stream.Write(0x00L);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteEOFC(this Stream stream, int ID = 0) =>
|
||||
stream.Write(new Header { ID = ID, Length = 0x20, Signature = 0x43464F45 });
|
||||
}
|
||||
|
||||
public static class POFExtensions
|
||||
{
|
||||
public static void Write(this Stream stream, ref KKdList<long> Offsets, int ID, bool ShiftX)
|
||||
{
|
||||
byte[] data = POF.Write(Offsets, ShiftX);
|
||||
Header Header = new Header { ID = ID, Format = Format.F2LE,
|
||||
Length = 0x20, Signature = ShiftX ? 0x31464F50 : 0x30464F50 };
|
||||
Header.DataSize = Header.SectionSize = data.Length;
|
||||
stream.Write(Header);
|
||||
stream.Write(data);
|
||||
stream.WriteEOFC(ID);
|
||||
}
|
||||
}
|
||||
|
||||
public static class StructExtensions
|
||||
{
|
||||
public static Struct ReadStruct(byte[] Data)
|
||||
{
|
||||
Stream stream = File.OpenReader(Data);
|
||||
Struct Struct = stream.ReadStruct(stream.ReadHeader(false));
|
||||
stream.Close();
|
||||
return Struct;
|
||||
}
|
||||
|
||||
public static Struct ReadStruct(this Stream stream, Header Header)
|
||||
{
|
||||
Struct Struct = new Struct { Header = Header, DataOffset =
|
||||
stream.Position, Data = stream.ReadBytes(Header.SectionSize) };
|
||||
int ID = Header.ID;
|
||||
|
||||
KKdList<Struct> SubStructs = KKdList<Struct>.New;
|
||||
long Length = stream.Length - stream.Position;
|
||||
long Position = 0;
|
||||
while (Length > Position)
|
||||
{
|
||||
Header = stream.ReadHeader(false);
|
||||
Position += Header.Length + Header.DataSize;
|
||||
if (Header.ID == ID && Header.Signature == 0x43464F45)
|
||||
{ Struct.EOFC = true; break; }
|
||||
else if (Header.ID == 0 && (Header.Signature == 0x30464F50 ||
|
||||
Header.Signature == 0x31464F50 || Header.Signature == 0x53524E45))
|
||||
SubStructs.Add(new Struct { Header = Header, DataOffset =
|
||||
stream.Position, Data = stream.ReadBytes(Header.SectionSize) });
|
||||
else if (Header.ID <= ID)
|
||||
{ stream.LongPosition -= Header.Length; break; }
|
||||
else SubStructs.Add(stream.ReadStruct(Header));
|
||||
}
|
||||
|
||||
for (int i = 0; i < SubStructs.Capacity; i++)
|
||||
{
|
||||
string Sig = SubStructs[i].Header.ToString();
|
||||
if (Sig == "ENRS" || Sig == "EOFC" || Sig == "POF0" || Sig == "POF1")
|
||||
{
|
||||
if (Sig == "EOFC") Struct.EOFC = true;
|
||||
else if (Sig == "ENRS") Struct.ENRS = ENRS.Read(SubStructs[i].Data);
|
||||
else Struct.POF = POF .Read(SubStructs[i].Data, Sig == "POF1");
|
||||
SubStructs.RemoveAt(i); SubStructs.Capacity--; i--;
|
||||
}
|
||||
}
|
||||
|
||||
if (SubStructs.Capacity > 0) Struct.SubStructs = SubStructs.ToArray();
|
||||
return Struct;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MPExt
|
||||
{
|
||||
public static MsgPack ReadMP(this byte[] array, bool JSON = false)
|
||||
{
|
||||
MsgPack MsgPack;
|
||||
if (JSON)
|
||||
{ JSON IO = new JSON(File.OpenReader(array));
|
||||
MsgPack = IO.Read( ); IO.Close(); }
|
||||
else
|
||||
{ MP IO = new MP(File.OpenReader(array));
|
||||
MsgPack = IO.Read(true); IO.Close(); }
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
public static MsgPack ReadMPAllAtOnce(this string file, bool JSON = false)
|
||||
{
|
||||
MsgPack MsgPack;
|
||||
if (JSON)
|
||||
{ JSON IO = new JSON(File.OpenReader(file + ".json", true));
|
||||
MsgPack = IO.Read( ); IO.Close(); }
|
||||
else
|
||||
{ MP IO = new MP(File.OpenReader(file + ".mp" , true));
|
||||
MsgPack = IO.Read(true); IO.Close(); }
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
public static MsgPack ReadMP(this string file, bool JSON = false)
|
||||
{
|
||||
MsgPack MsgPack;
|
||||
if (JSON)
|
||||
{ JSON IO = new JSON(File.OpenReader(file + ".json"));
|
||||
MsgPack = IO.Read( ); IO.Close(); }
|
||||
else
|
||||
{ MP IO = new MP(File.OpenReader(file + ".mp" ));
|
||||
MsgPack = IO.Read(true); IO.Close(); }
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
public static void Write(this MsgPack mp, bool Temp, string file, bool JSON = false)
|
||||
{ if (Temp) MsgPack.New.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)
|
||||
{ JSON IO = new JSON(File.OpenWriter(file + ".json", true));
|
||||
IO.Write(mp, "\n", " ").Close(); }
|
||||
else
|
||||
{ MP IO = new MP(File.OpenWriter(file + ".mp" , true));
|
||||
IO.Write(mp ).Close(); }
|
||||
return mp;
|
||||
}
|
||||
|
||||
public static void WriteAfterAll(this MsgPack mp, bool Temp, string file, bool JSON = false)
|
||||
{ if (Temp) MsgPack.New.Add(mp).WriteAfterAll(file, JSON).Dispose();
|
||||
else mp .WriteAfterAll(file, JSON); }
|
||||
|
||||
public static MsgPack WriteAfterAll(this MsgPack mp, string file, bool JSON = false)
|
||||
{
|
||||
byte[] data = null;
|
||||
if (JSON)
|
||||
{ JSON IO = new JSON(File.OpenWriter());
|
||||
IO.Write(mp, true); data = IO.ToArray(true); }
|
||||
else
|
||||
{ MP IO = new MP(File.OpenWriter());
|
||||
IO.Write(mp ); data = IO.ToArray(true); }
|
||||
File.WriteAllBytes(file + (JSON ? ".json" : ".mp"), data);
|
||||
return mp;
|
||||
}
|
||||
|
||||
public static void ToJSON (this string file) =>
|
||||
file.ReadMP( ).Write(file, true).Dispose();
|
||||
|
||||
public static void ToMsgPack(this string file) =>
|
||||
file.ReadMP(true).Write(file ).Dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib.F2
|
||||
{
|
||||
public struct Bloom
|
||||
{
|
||||
public CountPointer<BLT> BLTs;
|
||||
private Stream IO;
|
||||
private Header Header;
|
||||
private int i;
|
||||
|
||||
public void BLTReader(string file)
|
||||
{
|
||||
BLTs = default;
|
||||
IO = File.OpenReader(file + ".blt", true);
|
||||
Header = IO.ReadHeader();
|
||||
if (Header.Signature != 0x544D4C42 || Header.InnerSignature != 0x3) return;
|
||||
IO.Position -= 0x4;
|
||||
|
||||
BLTs = IO.ReadCountPointerEndian<BLT>();
|
||||
if (BLTs.Count < 1) { IO.Close(); BLTs.Count = -1; return; }
|
||||
|
||||
if (BLTs.Count > 0 && BLTs.Offset == 0) { IO.Close(); BLTs.Count = -1; return; }
|
||||
|
||||
IO.Position = BLTs.Offset;
|
||||
for (i = 0; i < BLTs.Count; i++)
|
||||
{
|
||||
ref BLT BLT = ref BLTs.Entries[i];
|
||||
IO.ReadInt32Endian();
|
||||
BLT.Color .X = IO.ReadSingleEndian();
|
||||
BLT.Color .Y = IO.ReadSingleEndian();
|
||||
BLT.Color .Z = IO.ReadSingleEndian();
|
||||
BLT.Brightpass.X = IO.ReadSingleEndian();
|
||||
BLT.Brightpass.Y = IO.ReadSingleEndian();
|
||||
BLT.Brightpass.Z = IO.ReadSingleEndian();
|
||||
BLT.Range = IO.ReadSingleEndian();
|
||||
}
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
if (BLTs.Count < 1) return;
|
||||
|
||||
IO = File.OpenWriter();
|
||||
IO.WriteShiftJIS("ID,ColorR,ColorG,ColorB,BrightpassR,BrightpassG,BrightpassB,Range\n");
|
||||
for (i = 0; i < BLTs.Count; i++)
|
||||
IO.Write(i + "," + BLTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_bloom.txt", IO.ToArray(true));
|
||||
}
|
||||
|
||||
public struct BLT
|
||||
{
|
||||
public Vector3 Color;
|
||||
public Vector3 Brightpass;
|
||||
public float Range;
|
||||
|
||||
public override string ToString() => Color .ToString(6) + "," +
|
||||
Brightpass.ToString(6) + "," +
|
||||
Range .ToString(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib.F2
|
||||
{
|
||||
public struct ColorCorrection
|
||||
{
|
||||
public CountPointer<CCT> CCTs;
|
||||
private Stream IO;
|
||||
private Header Header;
|
||||
private int i;
|
||||
|
||||
public void CCTReader(string file)
|
||||
{
|
||||
CCTs = default;
|
||||
IO = File.OpenReader(file + ".cct", true);
|
||||
Header = IO.ReadHeader();
|
||||
if (Header.Signature != 0x54524343 || Header.InnerSignature != 0x3) return;
|
||||
IO.Position -= 0x4;
|
||||
|
||||
CCTs = IO.ReadCountPointerEndian<CCT>();
|
||||
if (CCTs.Count < 1) { IO.Close(); CCTs.Count = -1; return; }
|
||||
|
||||
if (CCTs.Count > 0 && CCTs.Offset == 0) { IO.Close(); CCTs.Count = -1; return; }
|
||||
|
||||
IO.Position = CCTs.Offset;
|
||||
for (i = 0; i < CCTs.Count; i++)
|
||||
{
|
||||
ref CCT CCT = ref CCTs.Entries[i];
|
||||
IO.ReadInt32Endian();
|
||||
CCT.Hue = IO.ReadSingleEndian();
|
||||
CCT.Saturation = IO.ReadSingleEndian();
|
||||
CCT.Lightness = IO.ReadSingleEndian();
|
||||
CCT.Exposure = IO.ReadSingleEndian();
|
||||
CCT.Gamma.X = IO.ReadSingleEndian();
|
||||
CCT.Gamma.Y = IO.ReadSingleEndian();
|
||||
CCT.Gamma.Z = IO.ReadSingleEndian();
|
||||
CCT.Contrast = IO.ReadSingleEndian();
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
if (CCTs.Count < 1) return;
|
||||
|
||||
IO = File.OpenWriter();
|
||||
IO.WriteShiftJIS("ID,Hue,Saturation,Lightness,Exposure,GammaR,GammaG,GammaB,Contrast\n");
|
||||
for (i = 0; i < CCTs.Count; i++)
|
||||
IO.Write(i + "," + CCTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_cc.txt", IO.ToArray(true));
|
||||
}
|
||||
|
||||
public struct CCT
|
||||
{
|
||||
public float Hue;
|
||||
public float Saturation;
|
||||
public float Lightness;
|
||||
public float Exposure;
|
||||
public Vector3 Gamma;
|
||||
public float Contrast;
|
||||
|
||||
public override string ToString() => Hue .ToString(6) + "," +
|
||||
Saturation.ToString(6) + "," +
|
||||
Lightness .ToString(6) + "," +
|
||||
Exposure .ToString(6) + "," +
|
||||
Gamma .ToString(6) + "," +
|
||||
Contrast .ToString(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib.F2
|
||||
{
|
||||
public struct DOF
|
||||
{
|
||||
public CountPointer<DFT> DFTs;
|
||||
private Stream IO;
|
||||
private Header Header;
|
||||
private int i;
|
||||
|
||||
public void DFTReader(string file)
|
||||
{
|
||||
DFTs = default;
|
||||
IO = File.OpenReader(file + ".dft", true);
|
||||
Header = IO.ReadHeader();
|
||||
if (Header.Signature != 0x54464F44 || Header.InnerSignature != 0x3) return;
|
||||
IO.Position -= 0x4;
|
||||
|
||||
DFTs = IO.ReadCountPointerEndian<DFT>();
|
||||
if (DFTs.Count < 1) { IO.Close(); DFTs.Count = -1; return; }
|
||||
|
||||
if (DFTs.Count > 0 && DFTs.Offset == 0) { IO.Close(); DFTs.Count = -1; return; }
|
||||
|
||||
IO.Position = DFTs.Offset;
|
||||
for (i = 0; i < DFTs.Count; i++)
|
||||
{
|
||||
ref DFT DFT = ref DFTs.Entries[i];
|
||||
IO.ReadInt32Endian();
|
||||
DFT. Focus = IO.ReadSingleEndian();
|
||||
DFT. FocusRange = IO.ReadSingleEndian();
|
||||
DFT.FuzzingRange = IO.ReadSingleEndian();
|
||||
DFT.Ratio = IO.ReadSingleEndian();
|
||||
DFT.Quality = IO.ReadSingleEndian();
|
||||
if (IO.IsX) IO.ReadInt32();
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
if (DFTs.Count < 1) return;
|
||||
|
||||
IO = File.OpenWriter();
|
||||
IO.WriteShiftJIS("ID,Focus,FocusRange,FuzzingRange,Ratio,Quality\n");
|
||||
for (i = 0; i < DFTs.Count; i++)
|
||||
IO.Write(i + "," + DFTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_dof.txt", IO.ToArray(true));
|
||||
}
|
||||
|
||||
public struct DFT
|
||||
{
|
||||
public float Focus;
|
||||
public float FocusRange;
|
||||
public float FuzzingRange;
|
||||
public float Ratio;
|
||||
public float Quality;
|
||||
|
||||
public override string ToString() => Focus .ToString(6) + "," +
|
||||
FocusRange.ToString(6) + "," +
|
||||
FuzzingRange.ToString(6) + "," +
|
||||
Ratio .ToString(6) + "," +
|
||||
Quality .ToString(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib.F2
|
||||
{
|
||||
public struct Light
|
||||
{
|
||||
public CountPointer<CountPointer<LIT>> LITs;
|
||||
private Stream IO;
|
||||
private Header Header;
|
||||
private int i, i0;
|
||||
|
||||
public void LITReader(string file)
|
||||
{
|
||||
LITs = default;
|
||||
IO = File.OpenReader(file + ".lit", true);
|
||||
Header = IO.ReadHeader();
|
||||
if (Header.Signature != 0x4354494C || Header.InnerSignature != 0x2 ||
|
||||
Header.SectionSignature != 0x2) return;
|
||||
|
||||
LITs = IO.ReadCountPointerEndian<CountPointer<LIT>>();
|
||||
if (LITs.Count < 1) { IO.Close(); LITs.Count = -1; return; }
|
||||
|
||||
IO.Position = LITs.Offset;
|
||||
for (i = 0; i < LITs.Count; i++)
|
||||
{
|
||||
LITs[i] = IO.ReadCountPointerX<LIT>();
|
||||
if ((LITs[i].Count > 0 || LITs[i].Offset == 0) && !IO.IsX) { IO.Close(); LITs.Count = -1; return; }
|
||||
}
|
||||
|
||||
for (i = 0; i < LITs.Count; i++)
|
||||
{
|
||||
IO.Position = LITs[i].Offset;
|
||||
for (i0 = 0; i0 < LITs[i].Count; i0++)
|
||||
{
|
||||
ref LIT LIT = ref LITs.Entries[i].Entries[i0];
|
||||
LIT.Id = (Id )IO.ReadInt32Endian();
|
||||
LIT.Flags = (Flags)IO.ReadInt32Endian();
|
||||
LIT.Type = (Type )IO.ReadInt32Endian();
|
||||
if (IO.IsX) { IO.ReadInt64(); IO.ReadInt64(); IO.ReadInt64(); }
|
||||
LIT.Ambient .X = IO.ReadSingleEndian();
|
||||
LIT.Ambient .Y = IO.ReadSingleEndian();
|
||||
LIT.Ambient .Z = IO.ReadSingleEndian();
|
||||
LIT.Ambient .W = IO.ReadSingleEndian();
|
||||
LIT.Diffuse .X = IO.ReadSingleEndian();
|
||||
LIT.Diffuse .Y = IO.ReadSingleEndian();
|
||||
LIT.Diffuse .Z = IO.ReadSingleEndian();
|
||||
LIT.Diffuse .W = IO.ReadSingleEndian();
|
||||
LIT.Specular .X = IO.ReadSingleEndian();
|
||||
LIT.Specular .Y = IO.ReadSingleEndian();
|
||||
LIT.Specular .Z = IO.ReadSingleEndian();
|
||||
LIT.Specular .W = IO.ReadSingleEndian();
|
||||
LIT.Position .X = IO.ReadSingleEndian();
|
||||
LIT.Position .Y = IO.ReadSingleEndian();
|
||||
LIT.Position .Z = IO.ReadSingleEndian();
|
||||
LIT.ToneCurve.X = IO.ReadSingleEndian();
|
||||
LIT.ToneCurve.Y = IO.ReadSingleEndian();
|
||||
LIT.ToneCurve.Z = IO.ReadSingleEndian();
|
||||
if (IO.IsX) { IO.ReadInt64(); IO.ReadInt64(); IO.ReadInt64();
|
||||
IO.ReadInt64(); IO.ReadInt64(); IO.ReadInt32(); }
|
||||
}
|
||||
}
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
i = 0;
|
||||
if (LITs.Count < 1) return;
|
||||
|
||||
IO = File.OpenWriter();
|
||||
IO.WriteShiftJIS("Type,AmbientR,AmbientG,AmbientB,DiffuseR,DiffuseG,DiffuseB,SpecularR,SpecularG," +
|
||||
"SpecularB,SpecularA,PosX,PosY,PosZ,ToneCurveBegin,ToneCurveEnd,ToneCurveBlendRate," +
|
||||
(file.EndsWith("_chara") ? "コメント" : "ID") + "\n");
|
||||
for (i0 = 0; i0 < LITs[i].Count; i0++)
|
||||
IO.Write(LITs[i][i0] + "," + i + "\n");
|
||||
File.WriteAllBytes(file + "_light.txt", IO.ToArray(true));
|
||||
}
|
||||
|
||||
public struct LIT
|
||||
{
|
||||
public Id Id;
|
||||
public Flags Flags;
|
||||
public Type Type;
|
||||
public Vector4 Ambient;
|
||||
public Vector4 Diffuse;
|
||||
public Vector4 Specular;
|
||||
public Vector3 Position;
|
||||
public Vector3 ToneCurve;
|
||||
|
||||
public override string ToString() => Flags == 0 ? ",,,,,,,,,,,,,,,," : Type + "," +
|
||||
((Flags & Flags.Ambient ) == 0 ? ",,," : Ambient .ToString(6) + ",") +
|
||||
((Flags & Flags.Diffuse ) == 0 ? ",,," : Diffuse .ToString(6) + ",") +
|
||||
((Flags & Flags.Specular ) == 0 ? ",,,," : Specular .ToString(6) + ",") +
|
||||
((Flags & Flags.Position ) == 0 ? ",,," : Position .ToString(6) + ",") +
|
||||
((Flags & Flags.ToneCurve) == 0 ? ",,," : ToneCurve.ToString(6));
|
||||
}
|
||||
|
||||
public enum Id : int
|
||||
{
|
||||
CHARA = 0,
|
||||
STAGE = 1,
|
||||
SUN = 2,
|
||||
REFLECT = 3,
|
||||
SHADOW = 4,
|
||||
CHARA_COLOR = 5,
|
||||
CHARA_F = 6,
|
||||
PROJECTION = 7,
|
||||
}
|
||||
|
||||
public enum Type : int
|
||||
{
|
||||
OFF = 0,
|
||||
PARALLEL = 1,
|
||||
POINT = 2,
|
||||
SPOT = 3,
|
||||
}
|
||||
|
||||
public enum Flags : int
|
||||
{
|
||||
Type = 0b0000000001,
|
||||
Ambient = 0b0000000010,
|
||||
Diffuse = 0b0000000100,
|
||||
Specular = 0b0000001000,
|
||||
Position = 0b0000010000,
|
||||
ToneCurve = 0b1000000000,
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -2,6 +2,7 @@
|
||||
|
||||
using System.IO.Compression;
|
||||
using System.Security.Cryptography;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using MSIO = System.IO;
|
||||
|
||||
@@ -203,7 +204,7 @@ namespace KKdMainLib
|
||||
return SkipData;
|
||||
}
|
||||
|
||||
public void Pack()
|
||||
public void Pack(Farc Signature = Farc.FArC)
|
||||
{
|
||||
NewFARC();
|
||||
string[] files = Directory.GetFiles(DirectoryPath);
|
||||
@@ -211,6 +212,7 @@ namespace KKdMainLib
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
Files[i] = new FARCFile { Name = Path.GetFileName(files[i]), Data = File.ReadAllBytes(files[i]) };
|
||||
files = null;
|
||||
this.Signature = Signature;
|
||||
Save();
|
||||
}
|
||||
|
||||
@@ -219,7 +221,8 @@ namespace KKdMainLib
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
{
|
||||
string ext = Path.GetExtension(Files[i].Name).ToLower();
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".vag") Signature = Farc.FArc;
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".drs" || ext == ".dve" || ext == ".vag")
|
||||
{ Signature = Farc.FArc; break; }
|
||||
}
|
||||
|
||||
Stream writer = File.OpenWriter(DirectoryPath + ".farc", true);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using MSIO = System.IO;
|
||||
using MSIO = System.IO;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
using KKdBaseLib;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static string NullTerminatedASCII(this Stream stream, byte End = 0) =>
|
||||
stream.NullTerminated(End).ToASCII();
|
||||
public static string NullTerminatedUTF8 (this Stream stream, byte End = 0) =>
|
||||
stream.NullTerminated(End).ToUTF8 ();
|
||||
public static byte[] NullTerminated (this Stream stream, byte End = 0)
|
||||
{
|
||||
KKdList<byte> s = KKdList<byte>.New;
|
||||
while (stream.LongPosition < stream.LongLength)
|
||||
{
|
||||
byte a = stream.ReadByte();
|
||||
if (a == End) break;
|
||||
else s.Add(a);
|
||||
}
|
||||
return s.ToArray();
|
||||
}
|
||||
|
||||
public static byte PeekByte(this Stream stream)
|
||||
{ byte val = stream.ReadByte(); stream.LongPosition--; return val; }
|
||||
public static char PeekCharASCII(this Stream stream)
|
||||
{ byte val = stream.ReadByte(); stream.LongPosition--; return (char)val; }
|
||||
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)
|
||||
{
|
||||
while (true)
|
||||
if (char.IsWhiteSpace(stream.PeekCharUTF8())) stream.ReadCharUTF8();
|
||||
else break;
|
||||
return stream;
|
||||
}
|
||||
|
||||
public static bool Assert(this Stream stream, byte next)
|
||||
{ if (stream.PeekByte() == next) { stream.PeekByte(); return true; } else return false; }
|
||||
public static bool Assert(this Stream stream, byte[] next)
|
||||
{
|
||||
for (var i = 0; i < next.Length; i++)
|
||||
if (!stream.Assert(next[i])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool AssertASCII(this Stream stream, char next)
|
||||
{ if (stream.PeekCharUTF8() == next) { stream.ReadCharUTF8(); return true; } else return false; }
|
||||
public static bool AssertASCII(this Stream stream, string next)
|
||||
{
|
||||
for (var i = 0; i < next.Length; i++)
|
||||
if (!stream.AssertASCII(next[i])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static long ReadIntX(this Stream stream ) => stream.IsX ?
|
||||
stream.ReadInt64() : stream.ReadUInt32Endian( );
|
||||
public static long ReadIntX(this Stream stream, bool IsBE) => stream.IsX ?
|
||||
stream.ReadInt64() : stream.ReadUInt32Endian(IsBE);
|
||||
|
||||
public static void WriteX(this Stream stream, long val, ref KKdList<long> POF)
|
||||
{ if (stream.IsX) stream.Write ( val);
|
||||
else stream.WriteEndian((int)val); POF.Add(stream.Position); }
|
||||
public static void WriteX(this Stream stream, long val, ref KKdList<long> POF, bool IsBE)
|
||||
{ if (stream.IsX) stream.Write ( val );
|
||||
else stream.WriteEndian((int)val, IsBE); POF.Add(stream.Position); }
|
||||
|
||||
public static void WriteX(this Stream stream, long val)
|
||||
{ if (stream.IsX) stream.Write ( val);
|
||||
else stream.WriteEndian((int)val); }
|
||||
public static void WriteX(this Stream stream, long val, bool IsBE)
|
||||
{ if (stream.IsX) stream.Write ( val );
|
||||
else stream.WriteEndian((int)val, IsBE); }
|
||||
|
||||
public static byte[] ReadAtOffset(this Stream stream, long Offset = -1, long Length = -1)
|
||||
{
|
||||
byte[] arr = null;
|
||||
long Position = stream.LongPosition;
|
||||
if (Offset == -1) { Position += stream.IsX ? 8 : 4; Offset = stream.ReadIntX(); }
|
||||
stream.LongPosition = Offset;
|
||||
if (Length == -1) arr = stream.NullTerminated();
|
||||
else arr = stream.ReadBytes(Length);
|
||||
stream.LongPosition = Position;
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static string ReadStringAtOffset(this Stream stream, long Offset = -1, long Length = -1)
|
||||
{
|
||||
string s = null;
|
||||
long Position = stream.LongPosition;
|
||||
if (Offset == -1) { Position += stream.IsX ? 8 : 4; Offset = stream.ReadIntX(); }
|
||||
stream.LongPosition = Offset;
|
||||
if (Length == -1) s = stream.NullTerminatedUTF8();
|
||||
else s = stream.ReadStringUTF8(Length);
|
||||
stream.LongPosition = Position;
|
||||
return s;
|
||||
}
|
||||
|
||||
public static Pointer<string> ReadPointerStringShiftJIS(this Stream IO)
|
||||
{ Pointer<string> val = IO.ReadPointer<string>();
|
||||
val.Value = IO.ReadStringShiftJISAtOffset(val.Offset); return val; }
|
||||
|
||||
public static string ReadStringShiftJISAtOffset(this Stream IO, long Offset = 0, long Length = 0) =>
|
||||
Text.ShiftJIS.GetString(IO.ReadAtOffset(Offset, Length));
|
||||
|
||||
public static void WriteShiftJIS(this Stream IO, string String) =>
|
||||
IO.Write(Text.ShiftJIS.GetBytes(String));
|
||||
|
||||
public static Pointer<T> ReadPointer<T>(this Stream IO) =>
|
||||
new Pointer<T> { Offset = IO.ReadInt32() };
|
||||
|
||||
public static Pointer<string> ReadPointerString(this Stream IO)
|
||||
{ Pointer<string> val = IO.ReadPointer<string>();
|
||||
val.Value = IO.ReadStringAtOffset(val.Offset); return val; }
|
||||
|
||||
public static CountPointer<T> ReadCountPointer<T>(this Stream IO) =>
|
||||
new CountPointer<T> { Count = IO.ReadInt32(), Offset = IO.ReadInt32() };
|
||||
|
||||
public static Pointer<T> ReadPointerEndian<T>(this Stream IO) =>
|
||||
new Pointer<T> { Offset = IO.ReadInt32Endian() };
|
||||
|
||||
public static Pointer<string> ReadPointerStringEndian(this Stream IO)
|
||||
{ Pointer<string> val = IO.ReadPointerEndian<string>();
|
||||
val.Value = IO.ReadStringAtOffset(val.Offset); return val; }
|
||||
|
||||
public static CountPointer<T> ReadCountPointerEndian<T>(this Stream IO) =>
|
||||
new CountPointer<T> { Count = IO.ReadInt32Endian(), Offset = IO.ReadInt32Endian() };
|
||||
|
||||
public static Pointer<T> ReadPointerX<T>(this Stream IO) =>
|
||||
new Pointer<T> { Offset = (int)IO.ReadIntX() };
|
||||
|
||||
public static Pointer<string> ReadPointerStringX(this Stream IO)
|
||||
{ Pointer<string> val = IO.ReadPointerX<string>();
|
||||
val.Value = IO.ReadStringAtOffset(val.Offset); return val; }
|
||||
|
||||
public static CountPointer<T> ReadCountPointerX<T>(this Stream IO) =>
|
||||
new CountPointer<T> { Count = (int)IO.ReadIntX(), Offset = (int)IO.ReadIntX() };
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public static class IOExtensions
|
||||
{
|
||||
public static string NullTerminatedASCII(this Stream stream, byte End = 0) =>
|
||||
stream.NullTerminated(End).ToASCII();
|
||||
public static string NullTerminatedUTF8 (this Stream stream, byte End = 0) =>
|
||||
stream.NullTerminated(End).ToUTF8 ();
|
||||
public static byte[] NullTerminated (this Stream stream, byte End = 0)
|
||||
{
|
||||
List<byte> s = new List<byte>();
|
||||
while (stream.LongPosition < stream.LongLength)
|
||||
{
|
||||
byte a = stream.ReadByte();
|
||||
if (a == End) break;
|
||||
else s.Add(a);
|
||||
}
|
||||
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)
|
||||
{
|
||||
while (true)
|
||||
if (char.IsWhiteSpace(stream.PeekCharUTF8())) stream.ReadCharUTF8();
|
||||
else 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;
|
||||
}
|
||||
|
||||
public static long ReadIntX(this Stream stream ) => stream.IsX ?
|
||||
stream.ReadInt64() : stream.ReadUInt32Endian( );
|
||||
public static long ReadIntX(this Stream stream, bool IsBE) => stream.IsX ?
|
||||
stream.ReadInt64() : stream.ReadUInt32Endian(IsBE);
|
||||
|
||||
public static void WriteX(this Stream stream, long val)
|
||||
{ if (stream.IsX) stream.Write ( val);
|
||||
else stream.WriteEndian((int)val); }
|
||||
public static void WriteX(this Stream stream, long val, bool IsBE)
|
||||
{ if (stream.IsX) stream.Write ( val );
|
||||
else stream.WriteEndian((int)val, IsBE); }
|
||||
|
||||
public static byte[] ReadAtOffset(this Stream stream, long Offset = 0, long Length = 0)
|
||||
{
|
||||
byte[] arr = null;
|
||||
long Position = stream.LongPosition;
|
||||
if (Offset == 0) { Position += stream.IsX ? 8 : 4; Offset = stream.ReadIntX(); }
|
||||
stream.LongPosition = Offset;
|
||||
if (Length == 0) arr = stream.NullTerminated();
|
||||
else arr = stream.ReadBytes(Length);
|
||||
stream.LongPosition = Position;
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static string ReadStringAtOffset(this Stream stream, long Offset = 0, long Length = 0)
|
||||
{
|
||||
string s = null;
|
||||
long Position = stream.LongPosition;
|
||||
if (Offset == 0) { Position += stream.IsX ? 8 : 4; Offset = stream.ReadIntX(); }
|
||||
stream.LongPosition = Offset;
|
||||
if (Length == 0) s = stream.NullTerminatedUTF8();
|
||||
else s = stream.ReadStringUTF8(Length);
|
||||
stream.LongPosition = Position;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
//Original or reader part: https://github.com/MarcosLopezC/LightJson/
|
||||
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.Types;
|
||||
using KKdBaseLib;
|
||||
using BaseExtensions = KKdBaseLib.Extensions;
|
||||
|
||||
namespace KKdMainLib.MessagePack
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public class JSONIO
|
||||
public struct JSON
|
||||
{
|
||||
public Stream _IO;
|
||||
public JSON(Stream IO) => _IO = IO;
|
||||
|
||||
public JSONIO( ) => _IO = File.OpenWriter();
|
||||
public JSONIO(Stream IO) => _IO = IO;
|
||||
private Stream _IO;
|
||||
|
||||
public void Close() => _IO.Close();
|
||||
|
||||
@@ -66,7 +65,8 @@ namespace KKdMainLib.MessagePack
|
||||
}
|
||||
}
|
||||
else if (c == '"') break;
|
||||
else if (char.IsControl(c)) return null;
|
||||
else if (char.IsControl(c))
|
||||
return null;
|
||||
else s += c;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ namespace KKdMainLib.MessagePack
|
||||
{
|
||||
KKdList<MsgPack> Obj = KKdList<MsgPack>.New;
|
||||
if (!_IO.Assert('{')) return KKdList<MsgPack>.Null;
|
||||
if (_IO.SkipWhitespace().PeekCharUTF8() == '}') { _IO.ReadCharUTF8(); return KKdList<MsgPack>.Null; }
|
||||
if (_IO.SkipWhitespace().PeekCharUTF8() == '}')
|
||||
{ _IO.ReadCharUTF8(); return KKdList<MsgPack>.Null; }
|
||||
|
||||
string key;
|
||||
char c;
|
||||
@@ -110,7 +111,8 @@ namespace KKdMainLib.MessagePack
|
||||
{
|
||||
KKdList<MsgPack> Obj = KKdList<MsgPack>.New;
|
||||
if (!_IO.Assert('[')) return null;
|
||||
if (_IO.SkipWhitespace().PeekCharUTF8() == ']') { _IO.ReadCharUTF8(); return null; }
|
||||
if (_IO.SkipWhitespace().PeekCharUTF8() == ']')
|
||||
{ _IO.ReadCharUTF8(); return null; }
|
||||
|
||||
char c;
|
||||
while (true)
|
||||
@@ -171,19 +173,19 @@ namespace KKdMainLib.MessagePack
|
||||
{ string s = ""; while (char.IsDigit(_IO.SkipWhitespace().
|
||||
PeekCharUTF8())) s += _IO.ReadCharUTF8(); return s; }
|
||||
|
||||
public JSONIO Write(MsgPack MsgPack, string End = "\n", string TabChar = " ")
|
||||
{ Write(MsgPack, End, TabChar, "", true); return this; }
|
||||
public JSON Write(MsgPack MsgPack, string End = "\n", string TabChar = " ") =>
|
||||
Write(MsgPack, End, TabChar, "", true);
|
||||
|
||||
public JSONIO Write(MsgPack MsgPack, bool Style = false)
|
||||
{ Write(MsgPack, "\n", " ", "", Style); return this; }
|
||||
public JSON Write(MsgPack MsgPack, bool Style = false) =>
|
||||
Write(MsgPack, "\n", " ", "", Style);
|
||||
|
||||
private JSONIO Write(MsgPack MsgPack, string End, string TabChar, string Tab, bool Style, bool IsArray = false)
|
||||
private JSON Write(MsgPack MsgPack, string End, string TabChar, string Tab, bool Style, bool IsArray = false)
|
||||
{
|
||||
string OldTab = Tab;
|
||||
Tab += TabChar;
|
||||
if (MsgPack.Name != null && !IsArray) _IO.Write("\"" + MsgPack.Name + "\":" + (Style ? " " : ""));
|
||||
if (MsgPack.Object == null) { WriteNil(); return this; }
|
||||
|
||||
|
||||
if (MsgPack.List.NotNull)
|
||||
{
|
||||
WriteMap();
|
||||
@@ -226,34 +228,13 @@ namespace KKdMainLib.MessagePack
|
||||
if (Style) _IO.Write(OldTab);
|
||||
WriteArr(true);
|
||||
}
|
||||
else if (MsgPack.Object is MsgPack msg)
|
||||
Write(msg, End, TabChar, Tab, Style);
|
||||
else Write(MsgPack.Object, End, TabChar, Tab, Style);
|
||||
else if (MsgPack.Object is MsgPack msg) Write(msg, End, TabChar, Tab, Style);
|
||||
else if (MsgPack.Object is string str) Write(str);
|
||||
else _IO.Write(BaseExtensions.ToString(MsgPack.Object));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Write(object obj, 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("\0", "\\0" ).Replace("\b", "\\b").Replace("\f", "\\f" )
|
||||
@@ -1,15 +1,13 @@
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.Types;
|
||||
using KKdBaseLib;
|
||||
|
||||
namespace KKdMainLib.MessagePack
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public class IO
|
||||
public struct MP
|
||||
{
|
||||
public Stream _IO;
|
||||
public MP(Stream IO) => _IO = IO;
|
||||
|
||||
public IO( ) => _IO = File.OpenWriter();
|
||||
public IO(Stream IO) => _IO = IO;
|
||||
private Stream _IO;
|
||||
|
||||
public void Close() => _IO.Close();
|
||||
|
||||
@@ -19,50 +17,37 @@ namespace KKdMainLib.MessagePack
|
||||
{
|
||||
MsgPack MsgPack = MsgPack.New;
|
||||
byte Unk = _IO.ReadByte();
|
||||
if (!Array) { MsgPack.Name = ReadString((Types)Unk); Unk = _IO.ReadByte(); }
|
||||
Types Type = (Types)Unk;
|
||||
if (!Array)
|
||||
{
|
||||
MsgPack.Name = ReadString(Type);
|
||||
if (MsgPack.Name != null) { Unk = _IO.ReadByte(); Type = (Types)Unk; }
|
||||
}
|
||||
|
||||
bool FixArr = Type >= Types.FixArr && Type <= Types.FixArrMax;
|
||||
bool FixMap = Type >= Types.FixMap && Type <= Types.FixMapMax;
|
||||
bool FixStr = Type >= Types.FixStr && Type <= Types.FixStrMax;
|
||||
bool PosInt = Type >= Types.PosInt && Type <= Types.PosIntMax;
|
||||
bool NegInt = Type >= Types.NegInt && Type <= Types.NegIntMax;
|
||||
if (FixArr || FixMap || FixStr || PosInt || NegInt)
|
||||
if (Type >= Types.FixMap && Type <= Types.FixMapMax)
|
||||
{
|
||||
if (FixMap)
|
||||
{
|
||||
MsgPack.Object = KKdList<MsgPack>.New;
|
||||
for (int i = 0; i < Unk - (byte)Types.FixMap; i++) MsgPack.Add( Read(false));
|
||||
}
|
||||
else if (FixArr)
|
||||
{
|
||||
MsgPack.Object = new MsgPack[Unk - (byte)Types.FixArr];
|
||||
for (int i = 0; i < Unk - (byte)Types.FixArr; i++) MsgPack[i] = Read( true);
|
||||
}
|
||||
else if (FixStr) MsgPack.Object = ReadString( Type);
|
||||
else if (PosInt) MsgPack.Object = Unk;
|
||||
else if (NegInt) MsgPack.Object = (sbyte)Unk;
|
||||
return MsgPack;
|
||||
MsgPack.Object = KKdList<MsgPack>.New;
|
||||
for (int i = 0; i < Unk - (byte)Types.FixMap; i++) MsgPack.Add( Read(false));
|
||||
}
|
||||
|
||||
while (true)
|
||||
else if (Type >= Types.FixArr && Type <= Types.FixArrMax)
|
||||
{
|
||||
if (ReadNil (ref MsgPack, ref Type)) break;
|
||||
if (ReadArr (ref MsgPack, ref Type)) break;
|
||||
if (ReadMap (ref MsgPack, ref Type)) break;
|
||||
if (ReadExt (ref MsgPack, ref Type)) break;
|
||||
if (ReadString (ref MsgPack, ref Type)) break;
|
||||
if (ReadBoolean(ref MsgPack, ref Type)) break;
|
||||
if (ReadBytes (ref MsgPack, ref Type)) break;
|
||||
if (ReadInt (ref MsgPack, ref Type)) break;
|
||||
if (ReadUInt (ref MsgPack, ref Type)) break;
|
||||
if (ReadFloat (ref MsgPack, ref Type)) break;
|
||||
break;
|
||||
MsgPack.Object = new MsgPack[Unk - (byte)Types.FixArr];
|
||||
for (int i = 0; i < Unk - (byte)Types.FixArr; i++) MsgPack[i] = Read( true);
|
||||
}
|
||||
else if (Type >= Types.FixStr && Type <= Types.FixStrMax) MsgPack.Object = ReadString(Type);
|
||||
else if (Type >= Types.PosInt && Type <= Types.PosIntMax) MsgPack.Object = Unk;
|
||||
else if (Type >= Types.NegInt && Type <= Types.NegIntMax) MsgPack.Object = (sbyte)Unk;
|
||||
else
|
||||
while (true)
|
||||
{
|
||||
if (ReadNil (ref MsgPack, ref Type)) break;
|
||||
if (ReadArr (ref MsgPack, ref Type)) break;
|
||||
if (ReadMap (ref MsgPack, ref Type)) break;
|
||||
if (ReadExt (ref MsgPack, ref Type)) break;
|
||||
if (ReadString (ref MsgPack, ref Type)) break;
|
||||
if (ReadBoolean(ref MsgPack, ref Type)) break;
|
||||
if (ReadBytes (ref MsgPack, ref Type)) break;
|
||||
if (ReadInt (ref MsgPack, ref Type)) break;
|
||||
if (ReadUInt (ref MsgPack, ref Type)) break;
|
||||
if (ReadFloat (ref MsgPack, ref Type)) break;
|
||||
break;
|
||||
}
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
@@ -182,7 +167,7 @@ namespace KKdMainLib.MessagePack
|
||||
return true;
|
||||
}
|
||||
|
||||
public IO Write(MsgPack MsgPack, bool IsArray = false)
|
||||
public MP Write(MsgPack MsgPack, bool IsArray = false)
|
||||
{
|
||||
if (MsgPack.Name != null && !IsArray) Write(MsgPack.Name);
|
||||
Write(MsgPack.Object);
|
||||
+27
-25
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using KKdMainLib.Types;
|
||||
using KKdBaseLib;
|
||||
using MSIO = System.IO;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
@@ -7,18 +7,16 @@ namespace KKdMainLib.IO
|
||||
public unsafe class Stream : IDisposable
|
||||
{
|
||||
private MSIO.Stream stream;
|
||||
private int I, i, i0, TempBitRead, TempBitWrite;
|
||||
private ushort ValRead;
|
||||
private byte BitRead, BitWrite, ValWrite;
|
||||
private int I, i, i0, BitRead, BitWrite, TempBitRead, TempBitWrite, ValRead, ValWrite;
|
||||
private byte[] buf;
|
||||
|
||||
private Main.Format _format = Main.Format.NULL;
|
||||
private Format _format = Format.NULL;
|
||||
|
||||
public Main.Format Format
|
||||
public Format Format
|
||||
{ get => _format;
|
||||
set { _format = value;
|
||||
IsBE = _format == Main.Format.F2BE;
|
||||
IsX = _format == Main.Format.X || _format == Main.Format.XHD; } }
|
||||
IsBE = _format == Format.F2BE;
|
||||
IsX = _format == Format.X || _format == Format.XHD; } }
|
||||
|
||||
public bool IsBE = false;
|
||||
public bool IsX = false;
|
||||
@@ -27,9 +25,12 @@ namespace KKdMainLib.IO
|
||||
public uint UIntOffset { get => (uint)LongOffset; set => LongOffset = value; }
|
||||
public long LongOffset;
|
||||
|
||||
public int Length { get => ( int)stream.Length - Offset; set => stream.SetLength(value + Offset); }
|
||||
public uint UIntLength { get => (uint)stream.Length - UIntOffset; set => stream.SetLength(value + UIntOffset); }
|
||||
public long LongLength { get => stream.Length - LongOffset; set => stream.SetLength(value + LongOffset); }
|
||||
public int Length { get => ( int)stream.Length - Offset;
|
||||
set => stream.SetLength(value + Offset); }
|
||||
public uint UIntLength { get => (uint)stream.Length - UIntOffset;
|
||||
set => stream.SetLength(value + UIntOffset); }
|
||||
public long LongLength { get => stream.Length - LongOffset;
|
||||
set => stream.SetLength(value + LongOffset); }
|
||||
|
||||
public int Position
|
||||
{ get => ( int)stream.Position - Offset; set => stream.Position = value + Offset; }
|
||||
@@ -52,7 +53,7 @@ namespace KKdMainLib.IO
|
||||
BitRead = 8;
|
||||
ValRead = ValRead = BitWrite = 0;
|
||||
stream = output;
|
||||
Format = Main.Format.NULL;
|
||||
Format = Format.NULL;
|
||||
buf = new byte[128];
|
||||
IsBE = isBE;
|
||||
}
|
||||
@@ -322,18 +323,18 @@ namespace KKdMainLib.IO
|
||||
public string ReadStringUTF8 (long? Length) => ReadBytes(Length).ToUTF8 ();
|
||||
public string ReadStringASCII(long? Length) => ReadBytes(Length).ToASCII();
|
||||
|
||||
public byte[] ReadBytes(long Length, int Offset = 0)
|
||||
{ byte[] Buf = new byte[Length]; if (Offset > 0) stream.Position = Offset;
|
||||
public byte[] ReadBytes(long Length, int Offset = -1)
|
||||
{ byte[] Buf = new byte[Length]; if (Offset > -1) stream.Position = Offset;
|
||||
stream.Read(Buf, 0, (int)Length); return Buf; }
|
||||
|
||||
public void ReadBytes(long Length, byte[] Buf, long Offset = 0)
|
||||
{ if (Offset > 0) stream.Position = Offset; stream.Read(Buf, 0, (int)Length); }
|
||||
public void ReadBytes(long Length, byte[] Buf, long Offset = -1)
|
||||
{ if (Offset > -1) stream.Position = Offset; stream.Read(Buf, 0, (int)Length); }
|
||||
|
||||
public byte[] ReadBytes(long? Length, int Offset = 0)
|
||||
public byte[] ReadBytes(long? Length, int Offset = -1)
|
||||
{ if (Length == null) return new byte[0]; else return ReadBytes((long)Length, Offset); }
|
||||
|
||||
public void ReadBytes(long Length, byte Bits, byte[] Buf, long Offset = 0)
|
||||
{ if (Offset > 0) stream.Seek(Offset, 0);
|
||||
public void ReadBytes(long Length, byte Bits, byte[] Buf, long Offset = -1)
|
||||
{ if (Offset > -1) stream.Seek(Offset, 0);
|
||||
if (Bits > 0 && Bits < 8) for (i0 = 0; i0 < Length; i0++) Buf[i0] = ReadBits(Bits); }
|
||||
|
||||
public byte ReadBits(byte Bits)
|
||||
@@ -351,8 +352,9 @@ namespace KKdMainLib.IO
|
||||
|
||||
public byte ReadHalfByte() => ReadBits(4);
|
||||
|
||||
public void Write(byte val, byte Bits)
|
||||
public void Write(int val, byte Bits)
|
||||
{
|
||||
val &= (1 << Bits) - 1;
|
||||
BitWrite += Bits;
|
||||
TempBitWrite = 8 - BitWrite;
|
||||
if (TempBitWrite < 0)
|
||||
@@ -362,11 +364,12 @@ namespace KKdMainLib.IO
|
||||
stream.WriteByte((byte)(ValWrite | (val >> BitWrite)));
|
||||
ValWrite = 0;
|
||||
}
|
||||
ValWrite |= (byte)(val << TempBitWrite);
|
||||
ValWrite |= val << TempBitWrite;
|
||||
ValWrite &= 0xFF;
|
||||
}
|
||||
|
||||
public void CheckRead () { if (BitRead > 0) ValRead = 0; BitRead = 8; }
|
||||
public void CheckWrited() { if (BitWrite > 0) { Write(ValWrite); ValWrite = BitWrite = 0; } }
|
||||
public void CheckRead () { if (BitRead > 0) ValRead = 0; BitRead = 8; }
|
||||
public void CheckWrited() { if (BitWrite > 0) { WriteByte((byte)ValWrite); ValWrite = 0; BitWrite = 0; } }
|
||||
|
||||
public byte[] ToArray(bool Close)
|
||||
{ byte[] Data = ToArray(); if (Close) this.Close(); return Data; }
|
||||
@@ -374,8 +377,7 @@ namespace KKdMainLib.IO
|
||||
public byte[] ToArray()
|
||||
{
|
||||
long Position = stream.Position;
|
||||
stream.Position = 0;
|
||||
byte[] Data = ReadBytes(stream.Length);
|
||||
byte[] Data = ReadBytes(stream.Length, 0);
|
||||
stream.Position = Position;
|
||||
return Data;
|
||||
}
|
||||
|
||||
@@ -42,33 +42,27 @@
|
||||
<Compile Include="DB\Aet.cs" />
|
||||
<Compile Include="DB\Auth.cs" />
|
||||
<Compile Include="DB\Spr.cs" />
|
||||
<Compile Include="F2\Bloom.cs" />
|
||||
<Compile Include="F2\ColorCorrection.cs" />
|
||||
<Compile Include="F2\DOF.cs" />
|
||||
<Compile Include="F2\Light.cs" />
|
||||
<Compile Include="IO\Directory.cs" />
|
||||
<Compile Include="IO\Extensions.cs" />
|
||||
<Compile Include="IO\File.cs" />
|
||||
<Compile Include="IO\IOExtensions.cs" />
|
||||
<Compile Include="IO\JSON.cs" />
|
||||
<Compile Include="IO\MP.cs" />
|
||||
<Compile Include="IO\Path.cs" />
|
||||
<Compile Include="IO\Stream.cs" />
|
||||
<Compile Include="MessagePack\JSONIO.cs" />
|
||||
<Compile Include="MessagePack\MPExt.cs" />
|
||||
<Compile Include="MessagePack\MsgPack.cs" />
|
||||
<Compile Include="MessagePack\IO.cs" />
|
||||
<Compile Include="Types\Half.cs" />
|
||||
<Compile Include="Types\IKeyFrame.cs" />
|
||||
<Compile Include="Types\KKdList.cs" />
|
||||
<Compile Include="Types\Pointer.cs" />
|
||||
<Compile Include="Types\Vector.cs" />
|
||||
<Compile Include="A3DA.cs" />
|
||||
<Compile Include="Aet.cs" />
|
||||
<Compile Include="DataBank.cs" />
|
||||
<Compile Include="DCC.cs" />
|
||||
<Compile Include="DEX.cs" />
|
||||
<Compile Include="DIVAFILE.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="FARC.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="MathExtensions.cs" />
|
||||
<Compile Include="PDHeader.cs" />
|
||||
<Compile Include="POF.cs" />
|
||||
<Compile Include="Mot.cs" />
|
||||
<Compile Include="STR.cs" />
|
||||
<Compile Include="Text.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -77,5 +71,11 @@
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj">
|
||||
<Project>{437f63f1-8c23-429e-ab14-38b85c9edb16}</Project>
|
||||
<Name>KKdBaseLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
+27
-107
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
@@ -81,66 +82,48 @@ namespace KKdMainLib
|
||||
Multiselect = true, Title = "Choose file(s) to open:" };
|
||||
|
||||
ofd.Filter = GetArgs("All;", false, "*");
|
||||
if (filetype == "a3da") ofd.Filter = GetArgs("A3DA", "a3da", "farc", "json", "mp") +
|
||||
GetArgs("A3DA", true, "a3da") + GetArgs("FARC", true, "farc") + JSON + MsgPack;
|
||||
if (filetype == "a3da") ofd.Filter = GetArgs("A3DA", "a3da", "farc", "json", "mp") +
|
||||
GetArgs("A3DA", true, "a3da") + GetArgs("FARC", true, "farc") + JSON + MsgPack;
|
||||
else if (filetype == "bin" ) ofd.Filter = GetArgs("BIN" , "bin", "json", "mp") +
|
||||
BIN + JSON + MsgPack;
|
||||
else if (filetype == "blt" ) ofd.Filter = GetArgs("BLT" , "blt");
|
||||
else if (filetype == "bon" ) ofd.Filter = GetArgs("BON" , "bon", "bin", "json", "mp") +
|
||||
GetArgs("BON", true, "bon") + BIN + JSON + MsgPack;
|
||||
else if (filetype == "cct" ) ofd.Filter = GetArgs("CCT" , "cct");
|
||||
else if (filetype == "databank") ofd.Filter = GetArgs("DAT", "dat", "json", "mp") +
|
||||
GetArgs("DAT", true, "dat") + JSON + MsgPack;
|
||||
else if (filetype == "dex" ) ofd.Filter = GetArgs("DEX" , "dex", "bin", "json", "mp") +
|
||||
GetArgs("DEX", true, "dex") + BIN + JSON + MsgPack;
|
||||
else if (filetype == "dft") ofd.Filter = GetArgs("DFT" , "dft");
|
||||
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", "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 == "json") ofd.Filter = "JSON (*.json)|*.json";
|
||||
else if (filetype == "kki" ) ofd.Filter = GetArgs("KKI", "kki");
|
||||
else if (filetype == "mp" ) ofd.Filter = GetArgs("MessagePack", "mp");
|
||||
else if (filetype == "ppd" ) ofd.Filter = GetArgs("PPD", "ppd", "pak", "mod") +
|
||||
GetArgs("PPD", true, "ppd") + GetArgs("PAK", true, "pak") + GetArgs("MOD", true, "mod");
|
||||
else if (filetype == "str" ) ofd.Filter = GetArgs("STR", "str", "bin", "json", "mp") +
|
||||
else if (filetype == "lit") ofd.Filter = GetArgs("LIT" , "lit");
|
||||
else if (filetype == "str" ) ofd.Filter = GetArgs("STR" , "str", "bin", "json", "mp") +
|
||||
GetArgs("STR", true, "str") + BIN + JSON + MsgPack;
|
||||
else if (filetype == "vag" ) ofd.Filter = GetArgs("VAG", "vag", "wav") +
|
||||
else if (filetype == "vag" ) ofd.Filter = GetArgs("VAG" , "vag", "wav") +
|
||||
GetArgs("VAG", true, "vag") + GetArgs("WAV", true, "wav");
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
FileNames = ofd.FileNames;
|
||||
if (ofd.ShowDialog() == DialogResult.OK) FileNames = ofd.FileNames;
|
||||
ofd.Dispose();
|
||||
}
|
||||
else if (code == 2)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog { InitialDirectory = Application.StartupPath,
|
||||
ValidateNames = false, CheckFileExists = false, Filter = " | ", CheckPathExists = true,
|
||||
Title = "Choose any file in folder:", FileName = "Folder Selection." };
|
||||
string Return = "";
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
return Path.GetDirectoryName(ofd.FileName);
|
||||
Return = Path.GetDirectoryName(ofd.FileName);
|
||||
ofd.Dispose();
|
||||
return Return;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void ChooseSave(string filetype,
|
||||
out string InitialDirectory, out string[] FileNames)
|
||||
{
|
||||
InitialDirectory = "";
|
||||
FileNames = new string[0];
|
||||
Console.WriteLine("Choose file to save:");
|
||||
SaveFileDialog sfd = new SaveFileDialog { InitialDirectory = Application.StartupPath };
|
||||
switch (filetype)
|
||||
{
|
||||
case "kki":
|
||||
sfd.Filter = "KKI file (*.kki)|*.kki";
|
||||
break;
|
||||
}
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
InitialDirectory = sfd.InitialDirectory.ToString();
|
||||
FileNames = sfd.FileNames;
|
||||
}
|
||||
}
|
||||
|
||||
public static string NullTerminated(this string Source, ref int i, byte End)
|
||||
{
|
||||
@@ -163,8 +146,10 @@ namespace KKdMainLib
|
||||
public static bool StartsWith(this Dictionary<string, object> Dict, string[] args)
|
||||
{
|
||||
Dictionary<string, object> bufDict = new Dictionary<string, object>();
|
||||
if (Dict == null)
|
||||
Dict = new Dictionary<string, object>();
|
||||
if (Dict == null) return false;
|
||||
else if (args.Length < 1) return false;
|
||||
|
||||
args[0] = args[0].ToLower();
|
||||
if (args.Length > 1)
|
||||
{
|
||||
string[] NewArgs = new string[args.Length - 1];
|
||||
@@ -219,7 +204,7 @@ namespace KKdMainLib
|
||||
public static bool FindValue(this Dictionary<string, object> Dict,
|
||||
out double? value, string args)
|
||||
{ if (Dict.FindValue(out string val, args.Split('.' )))
|
||||
return ToDouble(val, out value); value = null; return false; }
|
||||
return val.ToDouble(out value); value = null; return false; }
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> Dict,
|
||||
out string value, string args)
|
||||
@@ -230,10 +215,11 @@ namespace KKdMainLib
|
||||
out string value, string[] args)
|
||||
{
|
||||
value = "";
|
||||
if (Dict == null) return false;
|
||||
if (Dict == null) return false;
|
||||
else if (args.Length < 1) return false;
|
||||
|
||||
if (!Dict.ContainsKey(args[0])) return false;
|
||||
args[0] = args[0].ToLower();
|
||||
if (!Dict.ContainsKey(args[0])) return false;
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
string[] NewArgs = new string[args.Length - 1];
|
||||
@@ -259,7 +245,10 @@ namespace KKdMainLib
|
||||
string[] args, string value)
|
||||
{
|
||||
Dictionary<string, object> bufDict = new Dictionary<string, object>();
|
||||
if (Dict == null) Dict = new Dictionary<string, object>();
|
||||
if (Dict == null) Dict = new Dictionary<string, object>();
|
||||
else if (args.Length < 1) return;
|
||||
|
||||
args[0] = args[0].ToLower();
|
||||
if (args.Length > 1)
|
||||
{
|
||||
string[] NewArgs = new string[args.Length - 1];
|
||||
@@ -294,74 +283,5 @@ namespace KKdMainLib
|
||||
for (i = 0; i < Length; i++) B[i] = int.Parse(A[i]);
|
||||
return B;
|
||||
}
|
||||
|
||||
private static readonly string NumberDecimalSeparator =
|
||||
NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
|
||||
|
||||
public static string ToString(this object d)
|
||||
{
|
||||
if (d == null) return "Null";
|
||||
else if (d is float F32) return ToString(F32);
|
||||
else if (d is double F64) return ToString(F64);
|
||||
return d.ToString();
|
||||
}
|
||||
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; }
|
||||
|
||||
public enum Format : byte
|
||||
{
|
||||
NULL = 0,
|
||||
DT = 1,
|
||||
PDA = 2,
|
||||
DT2 = 3,
|
||||
DTe = 4,
|
||||
F = 5,
|
||||
FT = 6,
|
||||
F2LE = 7,
|
||||
F2BE = 8,
|
||||
MGF = 9,
|
||||
X = 10,
|
||||
XHD = 11,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public static class MathExtensions
|
||||
{
|
||||
private const double RadPi = 180 / Math.PI;
|
||||
public static double ToDegrees(this double val) => val * RadPi;
|
||||
public static double ToRadians(this double val) => val / RadPi;
|
||||
|
||||
public static double Acos (this double d ) => Math.Acos (d );
|
||||
public static double Asin (this double d ) => Math.Asin (d );
|
||||
public static double Atan (this double d ) => Math.Atan (d );
|
||||
public static double Aсtg (this double d ) => 1 / Math.Atan (d );
|
||||
public static double Cos (this double d ) => Math.Cos (d );
|
||||
public static double Cosh (this double val) => Math.Cosh (val);
|
||||
public static double Sin (this double a ) => Math.Sin (a );
|
||||
public static double Sinh (this double val) => Math.Sinh (val);
|
||||
public static double Tan (this double a ) => Math.Tan (a );
|
||||
public static double Tanh (this double val) => Math.Tanh (val);
|
||||
public static double Ctg (this double a ) => 1 / Math.Tan (a );
|
||||
public static double Ctgh (this double val) => 1 / Math.Tanh (val);
|
||||
|
||||
public static double Abs (this double val) => Math.Abs (val);
|
||||
public static double Ceiling(this double a ) => Math.Ceiling(a );
|
||||
public static double Exp (this double d ) => Math.Exp (d );
|
||||
public static double Log (this double d ) => Math.Log (d );
|
||||
public static double Log10 (this double d ) => Math.Log10 (d );
|
||||
public static double Round (this double d ) => Math.Round (d );
|
||||
public static int Sign (this double val) => Math.Sign (val);
|
||||
public static double Sqrt (this double d ) => Math.Sqrt (d );
|
||||
|
||||
|
||||
public static double Atan2(this double y , double x ) => Math.Atan2(y , x );
|
||||
public static double Log (this double val , double newBase) => Math.Log (val , newBase);
|
||||
public static double Max (this double val1, double val2 ) => Math.Max (val1, val2 );
|
||||
public static double Min (this double val1, double val2 ) => Math.Min (val1, val2 );
|
||||
public static double Pow (this double x , double y ) => Math.Pow (x , y );
|
||||
public static double Round(this double val , int d ) => Math.Round(val , d );
|
||||
|
||||
public static void FloorCeiling( ref double Value) =>
|
||||
Value = Value % 1 >= 0.5 ? (long)(Value + 0.5) : (long) Value;
|
||||
|
||||
public static long FloorCeiling(this double Value) =>
|
||||
Value % 1 >= 0.5 ? (long)(Value + 0.5) : (long) Value;
|
||||
|
||||
public static int Align(this int value, int alignement, int divide = 1) =>
|
||||
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
|
||||
|
||||
public static uint Align(this uint value, uint alignement, uint divide = 1) =>
|
||||
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
|
||||
|
||||
public static long Align(this long value, long alignement, long divide = 1) =>
|
||||
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
|
||||
|
||||
public static ulong Align(this ulong value, ulong alignement, ulong divide = 1) =>
|
||||
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
|
||||
|
||||
public static byte[] buf = new byte[8];
|
||||
public static unsafe byte* bufPtr = buf.GetPtr();
|
||||
|
||||
public static unsafe long Endian(this long LE, byte Len, bool IsBE)
|
||||
{ if (IsBE) { for (byte i = 0; i < Len; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < Len; i++) { LE |= bufPtr[i]; if (i < Len - 1) LE <<= 8; } } return LE; }
|
||||
|
||||
public static unsafe ulong Endian(this ulong LE, byte Len, bool IsBE)
|
||||
{ if (IsBE) { for (byte i = 0; i < Len; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < Len; i++) { LE |= bufPtr[i]; if (i < Len - 1) LE <<= 8; } } return LE; }
|
||||
|
||||
public static sbyte CITSB(this int c)
|
||||
{
|
||||
if (c > 0x7F) c = 0x7F;
|
||||
else if (c < -0x80) c = -0x80;
|
||||
return (sbyte)c;
|
||||
}
|
||||
|
||||
public static byte CITB(this int c)
|
||||
{
|
||||
if (c > 0xFF) c = 0xFF;
|
||||
else if (c < 0x00) c = 0x00;
|
||||
return (byte)c;
|
||||
}
|
||||
|
||||
public static short CITS(this int c)
|
||||
{
|
||||
if (c > 0x7FFF) c = 0x7FFF;
|
||||
else if (c < -0x8000) c = -0x8000;
|
||||
return (short)c;
|
||||
}
|
||||
|
||||
public static ushort CITUS(this int c)
|
||||
{
|
||||
if (c > 0xFFFF) c = 0xFFFF;
|
||||
else if (c < 0x0000) c = 0x0000;
|
||||
return (ushort)c;
|
||||
}
|
||||
|
||||
public static sbyte CFTSB(this float c)
|
||||
{
|
||||
c = c.Round();
|
||||
if (c > 0x7F) c = 0x7F;
|
||||
else if (c < -0x80) c = -0x80;
|
||||
return (sbyte)c;
|
||||
}
|
||||
|
||||
public static byte CFTB(this float c)
|
||||
{
|
||||
c = c.Round();
|
||||
if (c > 0xFF) c = 0xFF;
|
||||
else if (c < 0x00) c = 0x00;
|
||||
return (byte)c;
|
||||
}
|
||||
|
||||
public static short CFTS(this float c)
|
||||
{
|
||||
c = c.Round();
|
||||
if (c > 0x7FFF) c = 0x7FFF;
|
||||
else if (c < -0x8000) c = -0x8000;
|
||||
return (short)c;
|
||||
}
|
||||
|
||||
public static ushort CFTUS(this float c)
|
||||
{
|
||||
c = c.Round();
|
||||
if (c > 0xFFFF) c = 0xFFFF;
|
||||
else if (c < 0x0000) c = 0x0000;
|
||||
return (ushort)c;
|
||||
}
|
||||
|
||||
public static int CFTI(this float c)
|
||||
{
|
||||
c = c.Round();
|
||||
if (c > 0x7FFFFFFF) c = 0x7FFFFFFF;
|
||||
else if (c < -0x80000000) c = -0x80000000;
|
||||
return (int)c;
|
||||
}
|
||||
|
||||
public static uint CFTUI(this float c)
|
||||
{
|
||||
c = c.Round();
|
||||
if (c > 0xFFFFFFFF) c = 0xFFFFFFFF;
|
||||
else if (c < 0x00000000) c = 0x00000000;
|
||||
return (uint)c;
|
||||
}
|
||||
|
||||
public static float Round(this float c) => (float)Math.Round(c);
|
||||
|
||||
public static sbyte CFTSB(this double c)
|
||||
{
|
||||
c = Math.Round(c);
|
||||
if (c > 0x7F) c = 0x7F;
|
||||
else if (c < -0x80) c = -0x80;
|
||||
return (sbyte)c;
|
||||
}
|
||||
|
||||
public static byte CFTB(this double c)
|
||||
{
|
||||
c = Math.Round(c);
|
||||
if (c > 0xFF) c = 0xFF;
|
||||
else if (c < 0x00) c = 0x00;
|
||||
return (byte)c;
|
||||
}
|
||||
|
||||
public static short CFTS(this double c)
|
||||
{
|
||||
c = Math.Round(c);
|
||||
if (c > 0x7FFF) c = 0x7FFF;
|
||||
else if (c < -0x8000) c = -0x8000;
|
||||
return (short)c;
|
||||
}
|
||||
|
||||
public static ushort CFTUS(this double c)
|
||||
{
|
||||
c = Math.Round(c);
|
||||
if (c > 0xFFFF) c = 0xFFFF;
|
||||
else if (c < 0x0000) c = 0x0000;
|
||||
return (ushort)c;
|
||||
}
|
||||
|
||||
public static int CFTI(this double c)
|
||||
{
|
||||
c = Math.Round(c);
|
||||
if (c > 0x7FFFFFFF) c = 0x7FFFFFFF;
|
||||
else if (c < -0x80000000) c = -0x80000000;
|
||||
return (int)c;
|
||||
}
|
||||
|
||||
public static uint CFTUI(this double c)
|
||||
{
|
||||
c = Math.Round(c);
|
||||
if (c > 0xFFFFFFFF) c = 0xFFFFFFFF;
|
||||
else if (c < 0x00000000) c = 0x00000000;
|
||||
return (uint)c;
|
||||
}
|
||||
|
||||
public static unsafe sbyte* GetPtr(this sbyte[] array)
|
||||
{ sbyte* Ptr; fixed ( sbyte* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
|
||||
public static unsafe byte* GetPtr(this byte[] array)
|
||||
{ byte* Ptr; fixed ( byte* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
|
||||
public static unsafe short* GetPtr(this short[] array)
|
||||
{ short* Ptr; fixed ( short* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
|
||||
public static unsafe ushort* GetPtr(this ushort[] array)
|
||||
{ ushort* Ptr; fixed (ushort* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
|
||||
public static unsafe int* GetPtr(this int[] array)
|
||||
{ int* Ptr; fixed ( int* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
|
||||
public static unsafe uint* GetPtr(this uint[] array)
|
||||
{ uint* Ptr; fixed ( uint* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
|
||||
public static unsafe long* GetPtr(this long[] array)
|
||||
{ long* Ptr; fixed ( long* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
|
||||
public static unsafe ulong* GetPtr(this ulong[] array)
|
||||
{ ulong* Ptr; fixed ( ulong* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
|
||||
public static unsafe float* GetPtr(this float[] array)
|
||||
{ float* Ptr; fixed ( float* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
|
||||
public static unsafe double* GetPtr(this double[] array)
|
||||
{ double* Ptr; fixed (double* tempPtr = array) Ptr = tempPtr; return Ptr; }
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
using KKdMainLib.IO;
|
||||
using MPIO = KKdMainLib.MessagePack.IO;
|
||||
|
||||
namespace KKdMainLib.MessagePack
|
||||
{
|
||||
public static class MPExt
|
||||
{
|
||||
public static MsgPack ReadMPAllAtOnce(this string file, bool JSON = false)
|
||||
{
|
||||
MsgPack MsgPack;
|
||||
if (JSON)
|
||||
{ JSONIO IO = new JSONIO(File.OpenReader(file + ".json", true));
|
||||
MsgPack = IO.Read(); IO.Close(); IO = null; }
|
||||
else
|
||||
{ MPIO IO = new MPIO(File.OpenReader(file + ".mp" , true));
|
||||
MsgPack = IO.Read(); IO.Close(); IO = null; }
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
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) MsgPack.New.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, "\n", " ").Close(); IO = null; }
|
||||
else
|
||||
{ MPIO IO = new MPIO(File.OpenWriter(file + ".mp" , true));
|
||||
IO.Write(mp ).Close(); IO = null; }
|
||||
return mp;
|
||||
}
|
||||
|
||||
public static void WriteAfterAll(this MsgPack mp, bool Temp, string file, bool JSON = false)
|
||||
{ if (Temp) MsgPack.New.Add(mp).WriteAfterAll(file, JSON).Dispose();
|
||||
else mp .WriteAfterAll(file, JSON); }
|
||||
|
||||
public static MsgPack WriteAfterAll(this MsgPack mp, string file, bool JSON = false)
|
||||
{
|
||||
byte[] data = null;
|
||||
if (JSON)
|
||||
{ JSONIO IO = new JSONIO(File.OpenWriter());
|
||||
IO.Write(mp, true); data = IO.ToArray(true); }
|
||||
else
|
||||
{ MPIO IO = new MPIO(File.OpenWriter());
|
||||
IO.Write(mp ); data = IO.ToArray(true); }
|
||||
File.WriteAllBytes(file + (JSON ? ".json" : ".mp"), data);
|
||||
return mp;
|
||||
}
|
||||
|
||||
public static void ToJSON (this string file) =>
|
||||
file.ReadMP( ).Write(file, true).Dispose();
|
||||
|
||||
public static void ToMsgPack(this string file) =>
|
||||
file.ReadMP(true).Write(file ).Dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public struct Mot
|
||||
{
|
||||
private int i, i0, i1;
|
||||
private MotHeader[] MOT;
|
||||
private Stream IO;
|
||||
|
||||
public void MOTReader(string file)
|
||||
{
|
||||
IO = File.OpenReader(file + ".bin");
|
||||
|
||||
i = 0;
|
||||
while (true)
|
||||
if (IO.ReadInt64() == 0) break;
|
||||
else { IO.ReadInt64(); i++; }
|
||||
if (i == 0) return;
|
||||
|
||||
int MOTCount = i;
|
||||
MsgPack m = new MsgPack(MOTCount, "Mot");
|
||||
MOT = new MotHeader[MOTCount];
|
||||
for (i = 0; i < MOTCount; i++)
|
||||
{
|
||||
ref MotHeader Mot = ref MOT[i];
|
||||
Mot.KeySet .Offset = IO.ReadInt32();
|
||||
Mot.KeySetTypesOffset = IO.ReadInt32();
|
||||
Mot. KeySetOffset = IO.ReadInt32();
|
||||
Mot.BoneInfo .Offset = IO.ReadInt32();
|
||||
}
|
||||
|
||||
for (i = 0; i < MOTCount; i++)
|
||||
{
|
||||
ref MotHeader Mot = ref MOT[i];
|
||||
|
||||
i0 = 1;
|
||||
IO.Position = Mot.BoneInfo.Offset;
|
||||
IO.ReadUInt16();
|
||||
while (IO.ReadUInt16() != 0) i0++;
|
||||
|
||||
Mot.BoneInfo.Value = new BoneInfo[i0];
|
||||
IO.Position = Mot.BoneInfo.Offset;
|
||||
for (i0 = 0; i0 < Mot.BoneInfo.Value.Length; i0++)
|
||||
Mot.BoneInfo.Value[i0].Id = IO.ReadUInt16();
|
||||
|
||||
IO.Position = Mot.KeySet.Offset;
|
||||
int info = IO.ReadUInt16();
|
||||
Mot.HighBits = info >> 14;
|
||||
Mot.FrameCount = IO.ReadUInt16();
|
||||
|
||||
Mot.KeySet.Value = new KeySet[info & 0x3FFF];
|
||||
IO.Position = Mot.KeySetTypesOffset;
|
||||
for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++)
|
||||
{
|
||||
if (i0 % 8 == 0) i1 = IO.ReadUInt16();
|
||||
|
||||
Mot.KeySet.Value[i0] = new KeySet { Type = (KeySetType)((i1 >> (i0 % 8 * 2)) & 0b11) };
|
||||
}
|
||||
|
||||
IO.Position = Mot.KeySetOffset;
|
||||
for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++)
|
||||
{
|
||||
ref KeySet Key = ref Mot.KeySet.Value[i0];
|
||||
if (Key.Type == KeySetType.Static)
|
||||
{ Key.Keys = new KFT2<ushort, float>[1];
|
||||
Key.Keys[0].V = IO.ReadSingle(); }
|
||||
else if (Key.Type == KeySetType.Linear)
|
||||
{
|
||||
Key.Keys = new KFT2<ushort, float>[IO.ReadUInt16()];
|
||||
for (i1 = 0; i1 < Key.Keys.Length; i1++)
|
||||
Key.Keys[i1].F = IO.ReadUInt16();
|
||||
IO.Align(0x4);
|
||||
for (i1 = 0; i1 < Key.Keys.Length; i1++)
|
||||
Key.Keys[i1].V = IO.ReadSingle();
|
||||
}
|
||||
else if (Key.Type == KeySetType.Interpolated)
|
||||
{
|
||||
Key.Keys = new KFT2<ushort, float>[IO.ReadUInt16()];
|
||||
for (i1 = 0; i1 < Key.Keys.Length; i1++)
|
||||
Key.Keys[i].F = IO.ReadUInt16();
|
||||
IO.Align(0x4);
|
||||
for (i1 = 0; i1 < Key.Keys.Length; i1++)
|
||||
{ Key.Keys[i1].V = IO.ReadSingle(); Key.Keys[i1].T = IO.ReadSingle(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void MOTWriter(string file)
|
||||
{
|
||||
if (MOT == null) return;
|
||||
IO = File.OpenWriter(file + ".bin");
|
||||
|
||||
int MOTCount = MOT.Length;
|
||||
IO.Position = (MOTCount + 1) << 4;
|
||||
for (i = 0; i < MOTCount; i++)
|
||||
{
|
||||
ref MotHeader Mot = ref MOT[i];
|
||||
Mot.KeySet.Offset = IO.Position;
|
||||
IO.Write((ushort)((Mot.HighBits << 14) | (Mot.KeySet.Value.Length & 0x3FFF)));
|
||||
IO.Write((ushort)Mot.FrameCount);
|
||||
|
||||
Mot.KeySetTypesOffset = IO.Position;
|
||||
for (i0 = 0, i1 = 0; i0 < Mot.KeySet.Value.Length; i0++)
|
||||
{
|
||||
i1 |= ((byte)Mot.KeySet.Value[i0].Type << (i0 % 8 * 2)) & (0b11 << (i0 % 8 * 2));
|
||||
|
||||
if (i0 % 8 == 7) { IO.Write((ushort)i1); i1 = 0; }
|
||||
}
|
||||
IO.Write((ushort)i1);
|
||||
|
||||
IO.Align(0x4);
|
||||
Mot.KeySetOffset = IO.Position;
|
||||
for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++)
|
||||
{
|
||||
ref KeySet Key = ref Mot.KeySet.Value[i0];
|
||||
if (Key.Type == KeySetType.Static)
|
||||
IO.Write(Key.Keys[0].V);
|
||||
else if (Key.Type == KeySetType.Linear)
|
||||
{
|
||||
IO.Write((ushort)Key.Keys.Length);
|
||||
for (i1 = 0; i1 < Key.Keys.Length; i1++)
|
||||
IO.Write(Key.Keys[i1].F);
|
||||
IO.Align(0x4);
|
||||
for (i1 = 0; i1 < Key.Keys.Length; i1++)
|
||||
IO.Write(Key.Keys[i1].V);
|
||||
}
|
||||
else if (Key.Type == KeySetType.Interpolated)
|
||||
{
|
||||
IO.Write((ushort)Key.Keys.Length);
|
||||
for (i1 = 0; i1 < Key.Keys.Length; i1++)
|
||||
IO.Write(Key.Keys[i1].F);
|
||||
IO.Align(0x4);
|
||||
for (i1 = 0; i1 < Key.Keys.Length; i1++)
|
||||
{ IO.Write(Key.Keys[i1].V); IO.Write(Key.Keys[i1].T); }
|
||||
}
|
||||
}
|
||||
IO.Align(0x4);
|
||||
|
||||
Mot.BoneInfo.Offset = IO.Position;
|
||||
for (i0 = 0; i0 < Mot.BoneInfo.Value.Length; i0++)
|
||||
IO.Write((ushort)Mot.BoneInfo.Value[i0].Id);
|
||||
IO.Write((ushort)0);
|
||||
}
|
||||
IO.Align(0x4, true);
|
||||
|
||||
IO.Position = 0;
|
||||
for (i = 0; i < MOTCount; i++)
|
||||
{
|
||||
ref MotHeader Mot = ref MOT[i];
|
||||
IO.Write(Mot.KeySet .Offset);
|
||||
IO.Write(Mot.KeySetTypesOffset);
|
||||
IO.Write(Mot. KeySetOffset);
|
||||
IO.Write(Mot.BoneInfo .Offset);
|
||||
}
|
||||
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
MOT = null;
|
||||
|
||||
MsgPack MsgPack = file.ReadMP(JSON);
|
||||
if (!MsgPack.ElementArray("MOT", out MsgPack MOTS)) { MsgPack.Dispose(); return; }
|
||||
|
||||
if (MOTS.Array != null)
|
||||
if (MOTS.Array.Length > 0)
|
||||
{
|
||||
MOT = new MotHeader[MOTS.Array.Length];
|
||||
for (int i = 0; i < MOT.Length; i++)
|
||||
MsgPackReader(MOTS.Array[i], ref MOT[i]);
|
||||
}
|
||||
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
int MOTCount = MOT.Length;
|
||||
MsgPack MOTS = new MsgPack(MOTCount, "MOT");
|
||||
for (i = 0; i < MOTCount; i++)
|
||||
MOTS[i] = MsgPackWriter(ref MOT[i]);
|
||||
MOTS.Write(true, file, JSON);
|
||||
}
|
||||
|
||||
public void MsgPackReader(MsgPack MOT, ref MotHeader Mot)
|
||||
{
|
||||
MsgPack Temp = MsgPack.New;
|
||||
Mot.HighBits = MOT.ReadInt32("HighBits" );
|
||||
Mot.FrameCount = MOT.ReadInt32("FrameCount");
|
||||
|
||||
if (!MOT.ElementArray("KeySets", out Temp)) return;
|
||||
|
||||
Mot.KeySet.Value = new KeySet[Temp.Array.Length];
|
||||
for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++)
|
||||
{
|
||||
ref KeySet KeySet = ref Mot.KeySet.Value[i0];
|
||||
|
||||
if (Temp.Array[i0].Array == null || Temp.Array[i0].Array.Length != 2) continue;
|
||||
KeySet.Type = (KeySetType)Temp.Array[i0].Array[0].ReadInt32();
|
||||
|
||||
MsgPack keySet = Temp.Array[i0].Array[1];
|
||||
|
||||
if (keySet.Array == null) { KeySet.Type = 0; continue; }
|
||||
else if (KeySet.Type == KeySetType.None) continue;
|
||||
else if (KeySet.Type == KeySetType.Static)
|
||||
{
|
||||
KeySet.Keys = new KFT2<ushort, float>[1];
|
||||
KeySet.Keys[0].F = keySet.Array[0][0].ReadUInt16();
|
||||
KeySet.Keys[0].V = keySet.Array[0][1].ReadSingle();
|
||||
}
|
||||
else if (KeySet.Type == KeySetType.Linear)
|
||||
{
|
||||
KeySet.Keys = new KFT2<ushort, float>[keySet.Array.Length];
|
||||
for (i1 = 0; i1 < keySet.Array.Length; i1++)
|
||||
{
|
||||
KeySet.Keys[i1].F = keySet.Array[i1][0].ReadUInt16();
|
||||
KeySet.Keys[i1].V = keySet.Array[i1][1].ReadSingle();
|
||||
}
|
||||
}
|
||||
else if (KeySet.Type == KeySetType.Interpolated)
|
||||
{
|
||||
KeySet.Keys = new KFT2<ushort, float>[keySet.Array.Length];
|
||||
for (i1 = 0; i1 < keySet.Array.Length; i1++)
|
||||
{
|
||||
KeySet.Keys[i1].F = keySet.Array[i1][0].ReadUInt16();
|
||||
KeySet.Keys[i1].V = keySet.Array[i1][1].ReadSingle();
|
||||
KeySet.Keys[i1].T = keySet.Array[i1][2].ReadSingle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (MOT.ElementArray("BoneInfo", out Temp))
|
||||
{
|
||||
Mot.BoneInfo.Value = new BoneInfo[Temp.Array.Length];
|
||||
for (i = 0; i < Mot.BoneInfo.Value.Length; i++)
|
||||
Mot.BoneInfo.Value[i].Id = Temp[i].ReadInt32();
|
||||
}
|
||||
else return;
|
||||
}
|
||||
|
||||
public MsgPack MsgPackWriter(ref MotHeader Mot)
|
||||
{
|
||||
MsgPack MOT = MsgPack.NewReserve(4).Add("FrameCount", Mot.FrameCount).Add("HighBits", Mot.HighBits);
|
||||
|
||||
MsgPack KeySets = new MsgPack(Mot.KeySet.Value.Length, "KeySets");
|
||||
for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++)
|
||||
{
|
||||
ref KeySet KeySet = ref Mot.KeySet.Value[i0];
|
||||
if (KeySet.Type == KeySetType.None) continue;
|
||||
|
||||
KeySets[i0] = new MsgPack(2);
|
||||
KeySets[i0].Array[0] = (MsgPack)(byte)KeySet.Type;
|
||||
KeySets[i0].Array[1] = new MsgPack(KeySet.Keys.Length);
|
||||
if (KeySet.Type == KeySetType.Static)
|
||||
{
|
||||
KeySets[i0].Array[1][0] = new MsgPack(2);
|
||||
KeySets[i0].Array[1][0].Array[0] = (MsgPack)KeySet.Keys[0].F;
|
||||
KeySets[i0].Array[1][0].Array[1] = (MsgPack)KeySet.Keys[0].V;
|
||||
}
|
||||
else if (KeySet.Type == KeySetType.Linear)
|
||||
for (i1 = 0; i1 < KeySet.Keys.Length; i1++)
|
||||
{
|
||||
KeySets[i0].Array[1][i1] = new MsgPack(2);
|
||||
KeySets[i0].Array[1][i1].Array[0] = (MsgPack)KeySet.Keys[i1].F;
|
||||
KeySets[i0].Array[1][i1].Array[1] = (MsgPack)KeySet.Keys[i1].V;
|
||||
}
|
||||
else
|
||||
for (i1 = 0; i1 < KeySet.Keys.Length; i1++)
|
||||
{
|
||||
KeySets[i0].Array[1][i1] = new MsgPack(3);
|
||||
KeySets[i0].Array[1][i1].Array[0] = (MsgPack)KeySet.Keys[i1].F;
|
||||
KeySets[i0].Array[1][i1].Array[1] = (MsgPack)KeySet.Keys[i1].V;
|
||||
KeySets[i0].Array[1][i1].Array[2] = (MsgPack)KeySet.Keys[i1].T;
|
||||
}
|
||||
}
|
||||
MOT.Add(KeySets);
|
||||
|
||||
MsgPack BoneInfo = new MsgPack(Mot.BoneInfo.Value.Length, "BoneInfo");
|
||||
for (i0 = 0; i0 < Mot.BoneInfo.Value.Length; i0++)
|
||||
BoneInfo[i0] = (MsgPack)Mot.BoneInfo.Value[i0].Id;
|
||||
MOT.Add(BoneInfo);
|
||||
|
||||
return MOT;
|
||||
}
|
||||
|
||||
public struct MotHeader
|
||||
{
|
||||
public int KeySetOffset;
|
||||
public int KeySetTypesOffset;
|
||||
public Pointer< KeySet []> KeySet ;
|
||||
public Pointer<BoneInfo[]> BoneInfo;
|
||||
|
||||
public int HighBits;
|
||||
public int FrameCount;
|
||||
}
|
||||
|
||||
public struct KeySet
|
||||
{
|
||||
public KFT2<ushort, float>[] Keys;
|
||||
public KeySetType Type;
|
||||
|
||||
public override string ToString() => $"Type: {Type}" + (Type == KeySetType.Static ?
|
||||
$"; Value: {Keys[0].Check()}" : Type > KeySetType.Static ? $"; Keys: {Keys.Length}" : "");
|
||||
}
|
||||
|
||||
public enum KeySetType : byte
|
||||
{
|
||||
None = 0b00,
|
||||
Static = 0b01,
|
||||
Linear = 0b10,
|
||||
Interpolated = 0b11,
|
||||
}
|
||||
|
||||
public struct BoneInfo
|
||||
{
|
||||
public string Name;
|
||||
public int Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public struct PDHead
|
||||
{
|
||||
public int ID;
|
||||
public int Lenght;
|
||||
public int DataSize;
|
||||
public int Signature;
|
||||
public int SectionSize;
|
||||
public int InnerSignature;
|
||||
public int SectionSignature;
|
||||
public Main.Format Format;
|
||||
public bool IsBE => Format == Main.Format.F2BE;
|
||||
public bool IsX => Format == Main.Format.X || Format == Main.Format.XHD;
|
||||
}
|
||||
|
||||
public static class PDHeadExtensions
|
||||
{
|
||||
public static PDHead ReadHeader(this Stream stream, bool Seek)
|
||||
{
|
||||
if (Seek)
|
||||
if (stream.Position > 4) stream.LongPosition -= 4;
|
||||
else stream.LongPosition = 0;
|
||||
return stream.ReadHeader();
|
||||
}
|
||||
|
||||
public static PDHead ReadHeader(this Stream stream)
|
||||
{
|
||||
long Position = stream.LongPosition;
|
||||
PDHead Header = new PDHead
|
||||
{ Format = Main.Format.F2LE, Signature = stream.ReadInt32(),
|
||||
DataSize = stream.ReadInt32(), Lenght = stream.ReadInt32() };
|
||||
if (stream.ReadUInt32() == 0x18000000)
|
||||
{ Header.Format = Main.Format.F2BE; }
|
||||
Header.ID = stream.ReadInt32();
|
||||
Header.SectionSize = stream.ReadInt32();
|
||||
if (Header.Lenght == 0x40)
|
||||
{
|
||||
stream.Position = 0x30;
|
||||
Header.InnerSignature = stream.ReadInt32();
|
||||
}
|
||||
stream.IsBE = Header.Format == Main.Format.F2BE;
|
||||
stream.Format = Header.Format;
|
||||
stream.LongPosition = Position + Header.Lenght;
|
||||
Header.SectionSignature = stream.ReadInt32Endian();
|
||||
return Header;
|
||||
}
|
||||
|
||||
public static void Write(this Stream stream, PDHead Header, bool X = false)
|
||||
{
|
||||
stream.Write(Header.Signature);
|
||||
stream.Write(Header.DataSize);
|
||||
stream.Write((Header.Format < Main.Format.X && !X) ? 0x40 : 0x20);
|
||||
if (Header.Format == Main.Format.F2BE) stream.Write(0x18000000);
|
||||
else stream.Write(0x10000000);
|
||||
stream.Write(Header.ID);
|
||||
stream.Write(Header.SectionSize);
|
||||
stream.Write(0x00);
|
||||
stream.Write(0x00);
|
||||
if (Header.Format < Main.Format.X && !X)
|
||||
{
|
||||
stream.Write(Header.Format < Main.Format.MGF ? (int)((Header.SectionSignature ^
|
||||
(Header.DataSize * (long)Header.Signature)) - Header.ID + Header.SectionSize) : 0);
|
||||
stream.Write(0x00);
|
||||
stream.Write(0x00L);
|
||||
stream.Write(Header.InnerSignature);
|
||||
stream.Write(0x00);
|
||||
stream.Write(0x00L);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteEOFC(this Stream stream, int ID = 0) =>
|
||||
stream.Write(new PDHead { ID = ID,
|
||||
Lenght = 0x20, Signature = 0x43464F45 }, true);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public class POF
|
||||
{
|
||||
public byte Type;
|
||||
public int Lenght;
|
||||
public int Offset;
|
||||
public int LastOffset;
|
||||
public List<long> Offsets;
|
||||
public List<long> POFOffsets;
|
||||
public PDHead Header;
|
||||
|
||||
public POF()
|
||||
{ Type = 0; Lenght = 0; Offset = 0; LastOffset = 0; Offsets = new List<long>();
|
||||
POFOffsets = new List<long>(); Header = new PDHead(); }
|
||||
}
|
||||
|
||||
public static class POFExtensions
|
||||
{
|
||||
public static POF AddPOF(this PDHead Header)
|
||||
{
|
||||
POF POF = new POF { Offsets = new List<long>(), POFOffsets =
|
||||
new List<long>(), Offset = Header.DataSize + Header.Lenght };
|
||||
return POF;
|
||||
}
|
||||
public static Stream GetOffset(this Stream stream, ref POF POF)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (stream.ReadString(3) == "POF")
|
||||
{
|
||||
POF.POFOffsets.Sort();
|
||||
POF.Type = byte.Parse(stream.ReadString(1));
|
||||
int IsX = POF.Type + 2;
|
||||
stream.Seek(-4, SeekOrigin.Current);
|
||||
POF.Header = stream.ReadHeader();
|
||||
stream.Seek(POF.Offset + POF.Header.Lenght, 0);
|
||||
POF.Lenght = stream.ReadInt32();
|
||||
while (POF.Lenght + POF.Offset + POF.Header.Lenght > stream.Position)
|
||||
{
|
||||
int a = stream.ReadByte();
|
||||
if (a >> 6 == 0) break;
|
||||
else if (a >> 6 == 1) a = a & 0x3F;
|
||||
else if (a >> 6 == 2)
|
||||
{
|
||||
a = a & 0x3F;
|
||||
a = (a << 8) | stream.ReadByte();
|
||||
}
|
||||
else if (a >> 6 == 3)
|
||||
{
|
||||
a = a & 0x3F;
|
||||
a = (a << 8) | stream.ReadByte();
|
||||
a = (a << 8) | stream.ReadByte();
|
||||
a = (a << 8) | stream.ReadByte();
|
||||
}
|
||||
a <<= IsX;
|
||||
POF.LastOffset += a;
|
||||
POF.Offsets.Add(POF.LastOffset);
|
||||
}
|
||||
|
||||
for (int i = 0; i < POF.Offsets.Count && i < POF.POFOffsets.Count; i++)
|
||||
if (POF.Offsets[i] != POF.POFOffsets[i])
|
||||
System.Console.WriteLine("Not right POF{0} offset table.\n" +
|
||||
" Expected: {1}\n Got: {2}", POF.Type,
|
||||
POF.Offsets[i].ToString("X8"), POF.POFOffsets[i].ToString("X8"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void Write(this Stream stream, ref POF POF, int ID)
|
||||
{
|
||||
POF.POFOffsets.Sort();
|
||||
long CurrentPOFOffset = 0;
|
||||
long POFOffset = 0;
|
||||
byte BitShift = (byte)(2 + POF.Type);
|
||||
int Max1 = (0x00FF >> BitShift) << BitShift;
|
||||
int Max2 = (0xFFFF >> BitShift) << BitShift;
|
||||
POF.Lenght = 5 + ID;
|
||||
for (int i = 0; i < POF.POFOffsets.Count; i++)
|
||||
{
|
||||
POFOffset = POF.POFOffsets[i] - CurrentPOFOffset;
|
||||
CurrentPOFOffset = POF.POFOffsets[i];
|
||||
if (POFOffset <= Max1) POF.Lenght += 1;
|
||||
else if (POFOffset <= Max2) POF.Lenght += 2;
|
||||
else POF.Lenght += 4;
|
||||
POF.POFOffsets[i] = POFOffset;
|
||||
}
|
||||
|
||||
long POFLenghtAling = POF.Lenght.Align(16);
|
||||
POF.Header = new PDHead { DataSize = (int)POFLenghtAling, ID = ID, Format = Main.Format.F2LE,
|
||||
Lenght = 0x20, SectionSize = (int)POFLenghtAling, Signature = 0x30464F50 };
|
||||
POF.Header.Signature += POF.Type << 24;
|
||||
stream.Write(POF.Header, true);
|
||||
|
||||
stream.Write(POF.Lenght);
|
||||
for (int i = 0; i < POF.POFOffsets.Count; i++)
|
||||
{
|
||||
POFOffset = POF.POFOffsets[i];
|
||||
if (POFOffset <= Max1) stream.Write (( byte)((1 << 6) | (POFOffset >> BitShift)));
|
||||
else if (POFOffset <= Max2) stream.WriteEndian((ushort)((2 << 14) | (POFOffset >> BitShift)), true);
|
||||
else stream.WriteEndian(( uint)((3 << 30) | (POFOffset >> BitShift)), true);
|
||||
}
|
||||
stream.Write(0x00);
|
||||
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 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.6.4")]
|
||||
[assembly: AssemblyFileVersion("0.4.6.4")]
|
||||
[assembly: AssemblyVersion("0.4.7.2")]
|
||||
[assembly: AssemblyFileVersion("0.4.7.2")]
|
||||
|
||||
+115
-104
@@ -1,204 +1,215 @@
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.Types;
|
||||
using KKdMainLib.MessagePack;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public class STR
|
||||
{
|
||||
public struct String
|
||||
{
|
||||
public int ID;
|
||||
public int StrOffset;
|
||||
public string Str;
|
||||
}
|
||||
|
||||
public STR()
|
||||
{ Offset = 0; OffsetX = 0; STRs = null; POF = null; Header = new PDHead(); }
|
||||
{ Offset = 0; OffsetX = 0; STRs = null; Header = new Header(); }
|
||||
|
||||
private long Offset;
|
||||
private long OffsetX;
|
||||
private KKdList<long> POF;
|
||||
private Header Header;
|
||||
private Stream IO;
|
||||
|
||||
public String[] STRs;
|
||||
private POF POF;
|
||||
private PDHead Header;
|
||||
|
||||
public int STRReader(string filepath, string ext)
|
||||
{
|
||||
Stream reader = File.OpenReader(filepath + ext);
|
||||
IO = File.OpenReader(filepath + ext);
|
||||
|
||||
Header = new PDHead();
|
||||
reader.Format = Main.Format.F;
|
||||
Header.Signature = reader.ReadInt32();
|
||||
Header = new Header();
|
||||
IO.Format = Format.F;
|
||||
Header.Signature = IO.ReadInt32();
|
||||
if (Header.Signature == 0x41525453)
|
||||
{
|
||||
Header = reader.ReadHeader(true);
|
||||
POF = Header.AddPOF();
|
||||
reader.Position = Header.Lenght;
|
||||
Header = IO.ReadHeader(true, false);
|
||||
POF = KKdList<long>.New;
|
||||
|
||||
long Count = reader.ReadInt32Endian();
|
||||
Offset = reader.ReadInt32Endian();
|
||||
long Count = IO.ReadInt32Endian();
|
||||
Offset = IO.ReadInt32Endian();
|
||||
|
||||
if (Offset == 0)
|
||||
{
|
||||
Offset = Count;
|
||||
OffsetX = reader.ReadInt64();
|
||||
Count = reader.ReadInt64();
|
||||
reader.Offset = Header.Lenght;
|
||||
reader.Format = Main.Format.X;
|
||||
OffsetX = IO.ReadInt64();
|
||||
Count = IO.ReadInt64();
|
||||
IO.Offset = Header.Length;
|
||||
IO.Format = Format.X;
|
||||
IO.LongOffset += Offset;
|
||||
IO.Position = 0;
|
||||
}
|
||||
reader.LongPosition = reader.IsX ? Offset + reader.Offset : Offset;
|
||||
else IO.Position = Header.Length + 0x40;
|
||||
|
||||
STRs = new String[Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
STRs[i].StrOffset = reader.GetOffset(ref POF).ReadInt32Endian();
|
||||
STRs[i].ID = reader.ReadInt32Endian();
|
||||
if (reader.IsX) STRs[i].StrOffset += (int)OffsetX;
|
||||
STRs[i].Str.Offset = IO.ReadInt32Endian();
|
||||
STRs[i].ID = IO.ReadInt32Endian();
|
||||
}
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (IO.IsX)
|
||||
{
|
||||
reader.LongPosition = STRs[i].StrOffset + (reader.IsX ? reader.Offset : 0);
|
||||
STRs[i].Str = reader.NullTerminatedUTF8();
|
||||
IO.LongOffset = Header.Length + OffsetX;
|
||||
for (int i = 0; i < Count; i++)
|
||||
STRs[i].Str.Value = IO.ReadStringAtOffset(STRs[i].Str.Offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
IO.Offset = 0;
|
||||
for (int i = 0; i < Count; i++)
|
||||
STRs[i].Str.Value = STRs[i].Str.Offset > 0 ?
|
||||
IO.ReadStringAtOffset(STRs[i].Str.Offset) : null;
|
||||
}
|
||||
|
||||
reader.Position = POF.Offset;
|
||||
reader.ReadPOF(ref POF);
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Position -= 4;
|
||||
IO.Position -= 4;
|
||||
int Count = 0;
|
||||
for (int a = 0, i = 0; reader.Position > 0 && reader.Position < reader.Length; i++, Count++)
|
||||
for (int a = 0, i = 0; IO.Position > 0 && IO.Position < IO.Length; i++, Count++)
|
||||
{
|
||||
a = reader.ReadInt32();
|
||||
a = IO.ReadInt32();
|
||||
if (a == 0) break;
|
||||
}
|
||||
STRs = new String[Count];
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
reader.LongPosition = STRs[i].StrOffset + (reader.IsX ? reader.Offset : 0);
|
||||
STRs[i].ID = i;
|
||||
STRs[i].Str = reader.NullTerminatedUTF8();
|
||||
IO.LongPosition = STRs[i].Str.Offset;
|
||||
STRs[i].ID = i;
|
||||
STRs[i].Str.Value = IO.NullTerminatedUTF8();
|
||||
}
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
IO.Close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void STRWriter(string filepath)
|
||||
{
|
||||
if (STRs == null || STRs.Length == 0 || Header.Format > Format.F2BE) return;
|
||||
uint Offset = 0;
|
||||
uint CurrentOffset = 0;
|
||||
Stream writer = File.OpenWriter(filepath + (Header.
|
||||
Format > Main.Format.FT ? ".str" : ".bin"), true);
|
||||
writer.Format = Header.Format;
|
||||
POF = new POF();
|
||||
writer.IsBE = writer.Format == Main.Format.F2BE;
|
||||
IO = File.OpenWriter(filepath + (Header.Format > Format.FT ? ".str" : ".bin"), true);
|
||||
IO.Format = Header.Format;
|
||||
POF = KKdList<long>.New;
|
||||
IO.IsBE = IO.Format == Format.F2BE;
|
||||
|
||||
long Count = STRs.LongLength;
|
||||
if (writer.Format > Main.Format.FT)
|
||||
if (IO.Format > Format.FT)
|
||||
{
|
||||
writer.Position = 0x40;
|
||||
writer.WriteEndian(Count);
|
||||
writer.GetOffset(ref POF).WriteEndian(0x80);
|
||||
writer.Position = 0x80;
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
writer.GetOffset(ref POF).Write(0x00);
|
||||
writer.WriteEndian(STRs[i].ID);
|
||||
}
|
||||
writer.Align(0x10);
|
||||
IO.Position = 0x40;
|
||||
IO.WriteX(Count, ref POF);
|
||||
IO.WriteX(0x80);
|
||||
IO.Position = 0x80;
|
||||
for (int i = 0; i < Count; i++) IO.Write(0x00L);
|
||||
IO.Align(0x10);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Count; i++) writer.Write(0x00);
|
||||
writer.Align(0x20);
|
||||
for (int i = 0; i < Count; i++) IO.Write(0x00);
|
||||
IO.Align(0x20);
|
||||
}
|
||||
|
||||
KKdList<string> UsedSTR = KKdList<string>.New;
|
||||
KKdList<int> UsedSTRPos = KKdList<int>.New;
|
||||
int[] STRPos = new int[Count];
|
||||
for (int i1 = 0; i1 < Count; i1++)
|
||||
|
||||
UsedSTRPos.Add(IO.Position);
|
||||
UsedSTR.Add("");
|
||||
IO.WriteByte(0);
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
if (UsedSTR.Contains(STRs[i1].Str))
|
||||
if (!UsedSTR.Contains(STRs[i].Str.Value))
|
||||
{
|
||||
for (int i2 = 0; i2 < Count; i2++)
|
||||
if (UsedSTR[i2] == STRs[i1].Str)
|
||||
{ STRPos[i1] = UsedSTRPos[i2]; break; }
|
||||
STRPos[i] = IO.Position;
|
||||
UsedSTRPos.Add(STRPos[i]);
|
||||
UsedSTR.Add(STRs[i].Str.Value);
|
||||
IO.Write(STRs[i].Str.Value);
|
||||
IO.WriteByte(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
STRPos[i1] = writer.Position;
|
||||
UsedSTRPos.Add(STRPos[i1]);
|
||||
UsedSTR.Add(STRs[i1].Str);
|
||||
writer.Write(STRs[i1].Str);
|
||||
writer.WriteByte(0);
|
||||
}
|
||||
}
|
||||
if (writer.Format > Main.Format.FT)
|
||||
{
|
||||
writer.Align(0x10);
|
||||
Offset = writer.UIntPosition;
|
||||
writer.Position = 0x80;
|
||||
}
|
||||
else
|
||||
writer.Position = 0;
|
||||
for (int i1 = 0; i1 < Count; i1++)
|
||||
{
|
||||
writer.WriteEndian(STRPos[i1]);
|
||||
if (writer.Format > Main.Format.FT) writer.Position += 4;
|
||||
for (int i2 = 0; i2 < Count; i2++)
|
||||
if (UsedSTR[i2] == STRs[i].Str.Value) { STRPos[i] = UsedSTRPos[i2]; break; }
|
||||
}
|
||||
|
||||
if (writer.Format > Main.Format.FT)
|
||||
if (IO.Format > Format.FT)
|
||||
{
|
||||
writer.UIntPosition = Offset;
|
||||
writer.Write(ref POF, 1);
|
||||
CurrentOffset = writer.UIntPosition;
|
||||
writer.WriteEOFC(0);
|
||||
Header.Lenght = 0x40;
|
||||
Header.DataSize = (int)(CurrentOffset - Header.Lenght);
|
||||
IO.Align(0x10);
|
||||
Offset = IO.UIntPosition;
|
||||
IO.Position = 0x80;
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
POF.Add(IO.Position);
|
||||
IO.WriteEndian(STRPos[i]);
|
||||
IO.WriteEndian(STRs[i].ID);
|
||||
}
|
||||
|
||||
IO.UIntPosition = Offset;
|
||||
IO.Write(ref POF, 0, false);
|
||||
CurrentOffset = IO.UIntPosition;
|
||||
IO.WriteEOFC(0);
|
||||
Header.DataSize = (int)(CurrentOffset - 0x40);
|
||||
Header.Signature = 0x41525453;
|
||||
Header.SectionSize = (int)(Offset - Header.Lenght);
|
||||
writer.Position = 0;
|
||||
writer.Write(Header);
|
||||
Header.SectionSize = (int)(Offset - 0x40);
|
||||
IO.Position = 0;
|
||||
IO.Write(Header, true);
|
||||
}
|
||||
writer.Close();
|
||||
else
|
||||
{
|
||||
IO.Position = 0;
|
||||
for (int i = 0; i < Count; i++) IO.Write(STRPos[i]);
|
||||
}
|
||||
IO.Close();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
|
||||
|
||||
if (!MsgPack.Element("STR", out MsgPack STR)) return;
|
||||
Header = new Header();
|
||||
System.Enum.TryParse(STR.ReadString("Format"), out Header.Format);
|
||||
|
||||
if (!STR.ElementArray("Strings", out MsgPack Strings)) return;
|
||||
|
||||
STRs = new String[Strings.Array.Length];
|
||||
for (int i = 0; i < STRs.Length; i++)
|
||||
{
|
||||
STRs[i].ID = Strings[i].ReadInt32 ("ID" );
|
||||
STRs[i].Str = Strings[i].ReadString("Str");
|
||||
STRs[i].ID = Strings[i].ReadInt32 ("ID" );
|
||||
STRs[i].Str.Value = Strings[i].ReadString("Str");
|
||||
if (STRs[i].Str.Value == null) STRs[i].Str.Value = "";
|
||||
}
|
||||
|
||||
MsgPack = MsgPack.New;
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
if (STRs == null || STRs.Length == 0) return;
|
||||
MsgPack STR_ = new MsgPack("STR").Add("Format", Header.Format.ToString());
|
||||
MsgPack Strings = new MsgPack(STRs.Length, "Strings");
|
||||
for (int i = 0; i < STRs.Length; i++)
|
||||
{
|
||||
Strings[i] = MsgPack.New.Add("ID", STRs[i].ID);
|
||||
if (STRs[i].Str != null) if (STRs[i].Str != "")
|
||||
Strings[i].Add("S", STRs[i].Str); ;
|
||||
if (STRs[i].Str.Value != null)
|
||||
if (STRs[i].Str.Value != "")
|
||||
Strings[i] = Strings[i].Add("Str", STRs[i].Str.Value);
|
||||
}
|
||||
STR_.Add(Strings);
|
||||
|
||||
STR_.Write(true, file, JSON);
|
||||
STR_.WriteAfterAll(true, file, JSON);
|
||||
}
|
||||
|
||||
public struct String
|
||||
{
|
||||
public int ID;
|
||||
public Pointer<string> Str;
|
||||
|
||||
public override string ToString() => "ID: " + ID + (Str.Value != null ||
|
||||
Str.Value != "" ? ("; Str: " + Str.Value) : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
namespace KKdMainLib.Types
|
||||
{
|
||||
public interface IKeyFrame<TKey, TVal>
|
||||
{
|
||||
IKeyFrame<TKey, TVal> Check();
|
||||
IKeyFrame<TKey, TVal> ToKeyFrameT0();
|
||||
IKeyFrame<TKey, TVal> ToKeyFrameT1();
|
||||
IKeyFrame<TKey, TVal> ToKeyFrameT2();
|
||||
IKeyFrame<TKey, TVal> ToKeyFrameT3();
|
||||
string ToString();
|
||||
string ToString(bool Brackets);
|
||||
}
|
||||
|
||||
public struct KeyFrameT0<TKey, TVal> : IKeyFrame<TKey, TVal>
|
||||
{
|
||||
public TKey Frame;
|
||||
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT0() =>
|
||||
new KeyFrameT0<TKey, TVal> { Frame = Frame };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT1() =>
|
||||
new KeyFrameT1<TKey, TVal> { Frame = Frame };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT2() =>
|
||||
new KeyFrameT2<TKey, TVal> { Frame = Frame };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT3() =>
|
||||
new KeyFrameT3<TKey, TVal> { Frame = Frame };
|
||||
|
||||
public IKeyFrame<TKey, TVal> Check() => this;
|
||||
|
||||
public override string ToString() =>
|
||||
Main.ToString(Frame);
|
||||
public string ToString(bool Brackets) =>
|
||||
Main.ToString(Frame);
|
||||
}
|
||||
|
||||
public struct KeyFrameT1<TKey, TVal> : IKeyFrame<TKey, TVal>
|
||||
{
|
||||
public TKey Frame;
|
||||
public TVal Value;
|
||||
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT0() =>
|
||||
new KeyFrameT0<TKey, TVal> { Frame = Frame };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT1() =>
|
||||
new KeyFrameT1<TKey, TVal> { Frame = Frame, Value = Value };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT2() =>
|
||||
new KeyFrameT2<TKey, TVal> { Frame = Frame, Value = Value };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT3() =>
|
||||
new KeyFrameT3<TKey, TVal> { Frame = Frame, Value = Value };
|
||||
|
||||
public IKeyFrame<TKey, TVal> Check() =>
|
||||
Value.Equals(default(TVal)) ? ToKeyFrameT0() : (this);
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets) =>
|
||||
(Brackets ? "(" : "") + Main.ToString(Frame) + "," +
|
||||
Main.ToString(Value) + (Brackets ? ")" : "");
|
||||
}
|
||||
|
||||
public struct KeyFrameT2<TKey, TVal> : IKeyFrame<TKey, TVal>
|
||||
{
|
||||
public TKey Frame;
|
||||
public TVal Value;
|
||||
public TVal Interpolation;
|
||||
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT0() =>
|
||||
new KeyFrameT0<TKey, TVal> { Frame = Frame };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT1() =>
|
||||
new KeyFrameT1<TKey, TVal> { Frame = Frame, Value = Value };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT2() =>
|
||||
new KeyFrameT2<TKey, TVal> { Frame = Frame, Value = Value,
|
||||
Interpolation = Interpolation};
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT3() =>
|
||||
new KeyFrameT3<TKey, TVal> { Frame = Frame, Value = Value,
|
||||
Interpolation1 = Interpolation, Interpolation2 = Interpolation };
|
||||
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT3(IKeyFrame<TKey, TVal> Previous) =>
|
||||
Previous is KeyFrameT2<TKey, TVal> PreviousT2 ?
|
||||
new KeyFrameT3<TKey, TVal> { Frame = Frame, Value = Value,
|
||||
Interpolation1 = PreviousT2.Interpolation, Interpolation2 = Interpolation } :
|
||||
new KeyFrameT3<TKey, TVal> { Frame = Frame, Value = Value,
|
||||
Interpolation1 = Interpolation, Interpolation2 = Interpolation };
|
||||
|
||||
public IKeyFrame<TKey, TVal> Check()
|
||||
{
|
||||
if (Value.Equals(default(TVal)) && Interpolation.Equals(default(TVal)))
|
||||
return ToKeyFrameT0();
|
||||
else if (Value.Equals(default(TVal))) return ToKeyFrameT1();
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets) =>
|
||||
(Brackets ? "(" : "") + Main.ToString(Frame) + "," + Main.
|
||||
ToString(Value) + "," + Main.ToString(Interpolation) + (Brackets ? ")" : "");
|
||||
}
|
||||
|
||||
public struct KeyFrameT3<TKey, TVal> : IKeyFrame<TKey, TVal>
|
||||
{
|
||||
public TKey Frame;
|
||||
public TVal Value;
|
||||
public TVal Interpolation1;
|
||||
public TVal Interpolation2;
|
||||
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT0() =>
|
||||
new KeyFrameT0<TKey, TVal> { Frame = Frame };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT1() =>
|
||||
new KeyFrameT1<TKey, TVal> { Frame = Frame, Value = Value };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT2() =>
|
||||
new KeyFrameT2<TKey, TVal> { Frame = Frame, Value = Value, Interpolation = Interpolation1 };
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT3() =>
|
||||
new KeyFrameT3<TKey, TVal> { Frame = Frame, Value = Value,
|
||||
Interpolation1 = Interpolation1, Interpolation2 = Interpolation2 };
|
||||
|
||||
public IKeyFrame<TKey, TVal> Check()
|
||||
{
|
||||
if (Value.Equals(default(TVal)) && Interpolation1.Equals(default(TVal)) &&
|
||||
Interpolation2.Equals(default(TVal))) return ToKeyFrameT0();
|
||||
else if (Interpolation1.Equals(default(TVal)) &&
|
||||
Interpolation2.Equals(default(TVal))) return ToKeyFrameT1();
|
||||
else if (Interpolation1.Equals(Interpolation2))
|
||||
return ToKeyFrameT2();
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets) =>
|
||||
(Brackets ? "(" : "") + Main.ToString(Frame) + "," + Main.ToString(Value) + "," +
|
||||
Main.ToString(Interpolation1) + "," + Main.ToString(Interpolation2) + (Brackets ? ")" : "");
|
||||
|
||||
public IKeyFrame<TKey, TVal> ToKeyFrameT2(IKeyFrame<TKey, TVal>
|
||||
Previous, out IKeyFrame<TKey, TVal> Current)
|
||||
{
|
||||
Current = Previous is KeyFrameT2<TKey, TVal> PreviousT2
|
||||
? new KeyFrameT2<TKey, TVal> { Frame = PreviousT2.Frame,
|
||||
Value = PreviousT2.Value, Interpolation = Interpolation1 }
|
||||
: new KeyFrameT2<TKey, TVal> { Frame = Frame,
|
||||
Value = Value, Interpolation = Interpolation1 };
|
||||
return new KeyFrameT2<TKey, TVal> { Frame = Frame,
|
||||
Value = Value, Interpolation = Interpolation2 };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib.Types
|
||||
{
|
||||
public struct Pointer<T>
|
||||
{
|
||||
public int Offset;
|
||||
public T Value;
|
||||
|
||||
public override string ToString() => Main.ToString(Value);
|
||||
}
|
||||
|
||||
public struct CountPointer<T>
|
||||
{
|
||||
public int Count { get => Entries != null ? Entries.Length : 0;
|
||||
set => Entries = new T[value]; }
|
||||
public int Offset;
|
||||
public T[] Entries;
|
||||
|
||||
|
||||
public T this[int index]
|
||||
{ get => Count > 0 ? Entries[index] : default;
|
||||
set { if (Count > 0) Entries[index] = value; } }
|
||||
|
||||
public override string ToString() => Count < 1 ? "No Entries" :
|
||||
Count == 1 ? Entries[0].ToString() : "Count: " + Count;
|
||||
}
|
||||
|
||||
public static class PointerExt
|
||||
{
|
||||
public static Pointer<T> ReadPointer<T>(this Stream IO) =>
|
||||
new Pointer<T> { Offset = IO.ReadInt32() };
|
||||
|
||||
public static Pointer<string> ReadPointerString(this Stream IO)
|
||||
{
|
||||
Pointer<string> val = IO.ReadPointer<string>();
|
||||
val.Value = IO.ReadStringAtOffset(val.Offset); return val;
|
||||
}
|
||||
|
||||
public static CountPointer<T> ReadCountPointer<T>(this Stream IO) =>
|
||||
new CountPointer<T> { Count = IO.ReadInt32(), Offset = IO.ReadInt32() };
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
using KKdMainLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdMainLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
|
||||
@@ -52,6 +52,10 @@
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj">
|
||||
<Project>{da55bfd3-927e-473c-a779-f9e6365384ae}</Project>
|
||||
<Name>KKdBaseLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KKdMainLib\KKdMainLib.csproj">
|
||||
<Project>{2BA7EFC6-91D1-8BBC-C487-06C7F36CC789}</Project>
|
||||
<Name>KKdMainLib</Name>
|
||||
|
||||
@@ -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.3")]
|
||||
[assembly: AssemblyFileVersion("0.0.2.3")]
|
||||
[assembly: AssemblyVersion("0.0.3.0")]
|
||||
[assembly: AssemblyFileVersion("0.0.3.0")]
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
using KKdMainLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
@@ -89,7 +89,6 @@ namespace KKdSoundLib
|
||||
VAGData.DataPtr[i * ch + c] = temp_bufferPtr[i ];
|
||||
VAGData.DataPtr[i2 * ch + c] = temp_bufferPtr[i2];
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
for (i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
|
||||
+11
-5
@@ -3,22 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29025.244
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PD_Tool", "PD_Tool\PD_Tool.csproj", "{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKdBaseLib", "KKdBaseLib\KKdBaseLib.csproj", "{437F63F1-8C23-429E-AB14-38B85C9EDB16}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKdMainLib", "KKdMainLib\KKdMainLib.csproj", "{2BA7EFC6-91D1-8BBC-C487-06C7F36CC789}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKdSoundLib", "KKdSoundLib\KKdSoundLib.csproj", "{D8A3F2D7-10CC-5723-EC9A-45D3B9C2DFEA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PD_Tool", "PD_Tool\PD_Tool.csproj", "{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{437F63F1-8C23-429E-AB14-38B85C9EDB16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{437F63F1-8C23-429E-AB14-38B85C9EDB16}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{437F63F1-8C23-429E-AB14-38B85C9EDB16}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{437F63F1-8C23-429E-AB14-38B85C9EDB16}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2BA7EFC6-91D1-8BBC-C487-06C7F36CC789}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2BA7EFC6-91D1-8BBC-C487-06C7F36CC789}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2BA7EFC6-91D1-8BBC-C487-06C7F36CC789}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -27,6 +29,10 @@ Global
|
||||
{D8A3F2D7-10CC-5723-EC9A-45D3B9C2DFEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D8A3F2D7-10CC-5723-EC9A-45D3B9C2DFEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D8A3F2D7-10CC-5723-EC9A-45D3B9C2DFEA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
+10
-1
@@ -39,14 +39,19 @@
|
||||
<NoWarn>IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="classes\DataBase.cs" />
|
||||
<Compile Include="classes\Tools\A3D.cs" />
|
||||
<Compile Include="classes\Tools\AET.cs" />
|
||||
<Compile Include="classes\Tools\BLT.cs" />
|
||||
<Compile Include="classes\Tools\CCT.cs" />
|
||||
<Compile Include="classes\Tools\DB.cs" />
|
||||
<Compile Include="classes\Tools\DEX.cs" />
|
||||
<Compile Include="classes\Tools\DFT.cs" />
|
||||
<Compile Include="classes\Tools\DIV.cs" />
|
||||
<Compile Include="classes\Tools\LIT.cs" />
|
||||
<Compile Include="classes\Tools\MOT.cs" />
|
||||
<Compile Include="classes\Tools\STR.cs" />
|
||||
<Compile Include="classes\Tools\VAG.cs" />
|
||||
<Compile Include="classes\DataBase.cs" />
|
||||
<Compile Include="classes\DIVAFILE.cs" />
|
||||
<Compile Include="classes\FARC.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
@@ -59,6 +64,10 @@
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj">
|
||||
<Project>{437f63f1-8c23-429e-ab14-38b85c9edb16}</Project>
|
||||
<Name>KKdBaseLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KKdMainLib\KKdMainLib.csproj">
|
||||
<Project>{2BA7EFC6-91D1-8BBC-C487-06C7F36CC789}</Project>
|
||||
<Name>KKdMainLib</Name>
|
||||
|
||||
+66
-17
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMain = KKdMainLib.Main;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
@@ -7,11 +8,16 @@ namespace PD_Tool
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool SetProcessDPIAware();
|
||||
|
||||
[ThreadStatic] public static string function = "";
|
||||
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
SetProcessDPIAware();
|
||||
|
||||
Console.Title = "PD_Tool";
|
||||
if (args.Length == 0)
|
||||
{
|
||||
@@ -41,6 +47,9 @@ namespace PD_Tool
|
||||
|
||||
private static void MainMenu()
|
||||
{
|
||||
GC.Collect();
|
||||
Console. InputEncoding = System.Text.Encoding.Unicode;
|
||||
Console.OutputEncoding = System.Text.Encoding.Unicode;
|
||||
Console.Title = "PD_Tool";
|
||||
Console.Clear();
|
||||
|
||||
@@ -52,8 +61,9 @@ namespace PD_Tool
|
||||
KKdMain.ConsoleDesign("3. Decrypt from DIVAFILE");
|
||||
KKdMain.ConsoleDesign("4. Encrypt to DIVAFILE");
|
||||
KKdMain.ConsoleDesign("5. DB_Tools");
|
||||
KKdMain.ConsoleDesign("6. Converting Tools");
|
||||
KKdMain.ConsoleDesign(JSON ? "7. MsgPack to JSON" : "7. JSON to MsgPack");
|
||||
KKdMain.ConsoleDesign("6. AC/DT/F/AFT/FT Converting Tools");
|
||||
KKdMain.ConsoleDesign("7. F/F2/X/FT Converting Tools");
|
||||
KKdMain.ConsoleDesign(JSON ? "8. MsgPack to JSON" : "9. JSON to MsgPack");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign(JSON ? "M. MessagePack" : "J. JSON");
|
||||
KKdMain.ConsoleDesign("Q. Quit");
|
||||
@@ -81,17 +91,17 @@ namespace PD_Tool
|
||||
else if (function == "6")
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "Converter Tools";
|
||||
Console.Title = "AC/DT/F/AFT/FT Converting Tools";
|
||||
KKdMain.ConsoleDesign(true);
|
||||
KKdMain.ConsoleDesign(" Choose tool:");
|
||||
KKdMain.ConsoleDesign(" Choose converter:");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign("1. A3DA Converter");
|
||||
KKdMain.ConsoleDesign("2. AET Converter");
|
||||
KKdMain.ConsoleDesign("3. DataBank Converter");
|
||||
KKdMain.ConsoleDesign("4. DEX Converter");
|
||||
KKdMain.ConsoleDesign("5. DIVA Converter");
|
||||
KKdMain.ConsoleDesign("6. STR Converter");
|
||||
KKdMain.ConsoleDesign("7. VAG Converter");
|
||||
KKdMain.ConsoleDesign("1. A3DA" );
|
||||
KKdMain.ConsoleDesign("2. AET" );
|
||||
KKdMain.ConsoleDesign("3. DataBank");
|
||||
KKdMain.ConsoleDesign("4. DEX" );
|
||||
KKdMain.ConsoleDesign("5. DIVA" );
|
||||
KKdMain.ConsoleDesign("6. MOT" );
|
||||
KKdMain.ConsoleDesign("7. STR" );
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign("R. Return to Main Menu");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
@@ -104,17 +114,56 @@ namespace PD_Tool
|
||||
else if (Function == "3") Tools.DB .Processor(JSON);
|
||||
else if (Function == "4") Tools.DEX.Processor(JSON);
|
||||
else if (Function == "5") Tools.DIV.Processor();
|
||||
else if (Function == "6") Tools.STR.Processor(JSON);
|
||||
else if (Function == "7") Tools.VAG.Processor();
|
||||
else if (Function == "6") Tools.MOT.Processor(JSON);
|
||||
else if (Function == "7") Tools.STR.Processor(JSON);
|
||||
else function = Function;
|
||||
}
|
||||
else if (function == "7")
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "F/F2/X/FT Converting Tools";
|
||||
KKdMain.ConsoleDesign(true);
|
||||
KKdMain.ConsoleDesign(" Choose converter:");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign("1. A3DA" );
|
||||
KKdMain.ConsoleDesign("2. Bloom" );
|
||||
KKdMain.ConsoleDesign("3. Color Correction");
|
||||
KKdMain.ConsoleDesign("4. DEX" );
|
||||
KKdMain.ConsoleDesign("5. DOF" );
|
||||
KKdMain.ConsoleDesign("6. Light" );
|
||||
KKdMain.ConsoleDesign("7. STR" );
|
||||
KKdMain.ConsoleDesign("8. VAG" );
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign("R. Return to Main Menu");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string Function = Console.ReadLine();
|
||||
Console.Clear();
|
||||
if (Function == "1") Tools.A3D.Processor(JSON);
|
||||
else if (Function == "2") Tools.BLT.Processor();
|
||||
else if (Function == "3") Tools.CCT.Processor();
|
||||
else if (Function == "4") Tools.DEX.Processor(JSON);
|
||||
else if (Function == "5") Tools.DFT.Processor();
|
||||
else if (Function == "6") Tools.LIT.Processor();
|
||||
else if (Function == "7") Tools.STR.Processor(JSON);
|
||||
else if (Function == "8") Tools.VAG.Processor();
|
||||
else function = Function;
|
||||
}
|
||||
else if (function == "8")
|
||||
{
|
||||
KKdMain.Choose(1, JSON ? "mp" : "json", out string[] FileNames);
|
||||
if (JSON) foreach (string file in FileNames)
|
||||
KKdMainLib.MessagePack.MPExt.ToJSON (file.Replace(Path.GetExtension(file), ""));
|
||||
else foreach (string file in FileNames)
|
||||
KKdMainLib.MessagePack.MPExt.ToMsgPack(file.Replace(Path.GetExtension(file), ""));
|
||||
foreach (string file in FileNames)
|
||||
if (JSON)
|
||||
{
|
||||
Console.Title = "MsgPack to JSON: " + Path.GetFileNameWithoutExtension(file);
|
||||
MPExt.ToJSON (file.Replace(Path.GetExtension(file), ""));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Title = "JSON to MsgPack: " + Path.GetFileNameWithoutExtension(file);
|
||||
MPExt.ToMsgPack(file.Replace(Path.GetExtension(file), ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
|
||||
[assembly: AssemblyVersion("0.4.6.4")]
|
||||
[assembly: AssemblyFileVersion("0.4.6.4")]
|
||||
[assembly: AssemblyVersion("0.4.7.2")]
|
||||
[assembly: AssemblyFileVersion("0.4.7.2")]
|
||||
|
||||
@@ -8,12 +8,7 @@ namespace PD_Tool
|
||||
public static void Decrypt(string file)
|
||||
{
|
||||
Stream reader = File.OpenReader(file);
|
||||
if (reader.ReadInt64() != 0x454C494641564944)
|
||||
{
|
||||
reader.Close();
|
||||
Encrypt(file);
|
||||
return;
|
||||
}
|
||||
if (reader.ReadInt64() != 0x454C494641564944) { reader.Close(); return; }
|
||||
reader.Close();
|
||||
file.Decrypt();
|
||||
}
|
||||
@@ -21,13 +16,7 @@ namespace PD_Tool
|
||||
public static void Encrypt(string file)
|
||||
{
|
||||
Stream reader = File.OpenReader(file);
|
||||
if (reader.ReadInt64() == 0x454C494641564944)
|
||||
{
|
||||
reader.Close();
|
||||
Decrypt(file);
|
||||
return;
|
||||
}
|
||||
|
||||
if (reader.ReadInt64() == 0x454C494641564944) { reader.Close(); return; }
|
||||
file.Encrypt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace PD_Tool
|
||||
else if (type == "R") return;
|
||||
else FARC.Signature = KKdFARC.Farc.FArC;
|
||||
Console.Title = "FARC Creator - Directory: " + Path.GetDirectoryName(file);
|
||||
new KKdFARC(file, true).Pack();
|
||||
new KKdFARC(file, true).Pack(FARC.Signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.MessagePack;
|
||||
using KKdMainLib;
|
||||
using KKdA3DA = KKdMainLib.A3DA.A3DA;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
@@ -19,11 +19,9 @@ namespace PD_Tool.Tools
|
||||
|
||||
bool MP = false;
|
||||
foreach (string file in FileNames)
|
||||
if (file.EndsWith(".mp" )) { MP = true; break; }
|
||||
else if (file.EndsWith(".json")) { MP = true; break; }
|
||||
else if (file.EndsWith(".farc")) { MP = true; break; }
|
||||
if (file.EndsWith(".mp") || file.EndsWith(".json") || file.EndsWith(".farc")) { MP = true; break; }
|
||||
|
||||
Main.Format Format = Main.Format.NULL;
|
||||
Format Format = Format.NULL;
|
||||
string format = "";
|
||||
if (MP)
|
||||
{
|
||||
@@ -42,13 +40,13 @@ namespace PD_Tool.Tools
|
||||
Main.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
format = Console.ReadLine();
|
||||
if (format == "1") Format = Main.Format.DT ;
|
||||
else if (format == "2") Format = Main.Format.F ;
|
||||
else if (format == "3") Format = Main.Format.FT ;
|
||||
else if (format == "4") Format = Main.Format.FT ;
|
||||
else if (format == "5") Format = Main.Format.F2LE;
|
||||
else if (format == "6") Format = Main.Format.MGF ;
|
||||
else if (format == "7") Format = Main.Format.X ;
|
||||
if (format == "1") Format = Format.DT ;
|
||||
else if (format == "2") Format = Format.F ;
|
||||
else if (format == "3") Format = Format.FT ;
|
||||
else if (format == "4") Format = Format.FT ;
|
||||
else if (format == "5") Format = Format.F2LE;
|
||||
else if (format == "6") Format = Format.MGF ;
|
||||
else if (format == "7") Format = Format.X ;
|
||||
else return;
|
||||
}
|
||||
|
||||
@@ -79,12 +77,9 @@ namespace PD_Tool.Tools
|
||||
A3DA = A.MsgPackWriter();
|
||||
A = new KKdA3DA();
|
||||
A.MsgPackReader(A3DA);
|
||||
A.IO = File.OpenWriter();
|
||||
A.Data._.CompressF16 = Format > Main.Format.FT ?
|
||||
Format == Main.Format.MGF ? 2 : 1 : 0;
|
||||
A.Data._.CompressF16 = Format > Format.FT ? Format == Format.MGF ? 2 : 1 : 0;
|
||||
A.Data.Format = Format;
|
||||
FARC.Files[i].Data = (format != "1" &&
|
||||
format != "3") ? A.A3DCWriter() : A.A3DAWriter();
|
||||
FARC.Files[i].Data = (format != "1" && format != "3") ? A.A3DCWriter() : A.A3DAWriter();
|
||||
}
|
||||
}
|
||||
FARC.Save();
|
||||
@@ -97,8 +92,7 @@ namespace PD_Tool.Tools
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
A.MsgPackReader(filepath, ext == ".json");
|
||||
A.Data._.CompressF16 = Format > Main.Format.FT ?
|
||||
Format == Main.Format.MGF ? 2 : 1 : 0;
|
||||
A.Data._.CompressF16 = Format > Format.FT ? Format == Format.MGF ? 2 : 1 : 0;
|
||||
A.Data.Format = Format;
|
||||
|
||||
File.WriteAllBytes(filepath + ".a3da", (format != "1" &&
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
public class BLT
|
||||
{
|
||||
public static void Processor()
|
||||
{
|
||||
Console.Title = "Bloom Converter";
|
||||
Bloom Bloom;
|
||||
Main.Choose(1, "blt", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
Bloom = new Bloom();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Bloom Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".blt") { Bloom.BLTReader(filepath); Bloom.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { Bloom.TXTReader(filepath); Bloom.BLTWriter(filepath); }
|
||||
Bloom = new Bloom();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
public class CCT
|
||||
{
|
||||
public static void Processor()
|
||||
{
|
||||
Console.Title = "Color Correction Converter";
|
||||
ColorCorrection ColorCorrection;
|
||||
Main.Choose(1, "cct", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
ColorCorrection = new ColorCorrection();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Color Correction Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".cct") { ColorCorrection.CCTReader(filepath); ColorCorrection.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { ColorCorrection.TXTReader(filepath); ColorCorrection.BLTWriter(filepath); }
|
||||
ColorCorrection = new ColorCorrection();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,6 @@ namespace PD_Tool.Tools
|
||||
|
||||
DataBank DB;
|
||||
string[] file_split;
|
||||
int File_Checksum = 0, Get_Checksum;
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
@@ -48,11 +47,6 @@ namespace PD_Tool.Tools
|
||||
DB = new DataBank();
|
||||
if (file_split.Length == 5 && ext == ".dat" && MP)
|
||||
{
|
||||
if (!int.TryParse(file_split[3], out File_Checksum)) continue;
|
||||
|
||||
Get_Checksum = DCC.CalculateChecksum(file);
|
||||
if (File_Checksum != Get_Checksum) continue;
|
||||
|
||||
filepath = file.Replace(filename + ".dat", "");
|
||||
Console.Title = "DataBank Converter: " + filename;
|
||||
DB. DBReader(file);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib;
|
||||
using KKdDEX = KKdMainLib.DEX;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
@@ -30,7 +31,7 @@ namespace PD_Tool.Tools
|
||||
Main.ConsoleDesign(" Choose type of exporting file:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. F/FT PS3/PS4/PSVita");
|
||||
Main.ConsoleDesign("2. F2nd PS3/PSVita");
|
||||
Main.ConsoleDesign("2. F2 PS3/PSVita");
|
||||
Main.ConsoleDesign("3. X PS4/PSVita");
|
||||
if ( MP && !JSON) Main.ConsoleDesign("9. MessagePack");
|
||||
if (_JSON && JSON) Main.ConsoleDesign("9. JSON");
|
||||
@@ -39,13 +40,14 @@ namespace PD_Tool.Tools
|
||||
Console.WriteLine();
|
||||
format = Console.ReadLine();
|
||||
|
||||
Main.Format Format = Main.Format.NULL;
|
||||
if (format == "1") Format = Main.Format.F ;
|
||||
else if (format == "2") Format = Main.Format.F2LE;
|
||||
else if (format == "3") Format = Main.Format.X ;
|
||||
else if (format == "9" && (MP && _JSON)) Format = Main.Format.NULL;
|
||||
Format Format = Format.NULL;
|
||||
if (format == "1") Format = Format.F ;
|
||||
else if (format == "2") Format = Format.F2LE;
|
||||
else if (format == "3") Format = Format.X ;
|
||||
else if (format == "9" && (MP && _JSON)) Format = Format.NULL;
|
||||
else return;
|
||||
|
||||
int state;
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
DEX = new KKdDEX();
|
||||
@@ -55,12 +57,15 @@ namespace PD_Tool.Tools
|
||||
|
||||
Console.Title = "DEX Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin" || ext == ".dex")
|
||||
DEX. DEXReader(filepath, ext );
|
||||
else DEX.MsgPackReader(filepath, JSON);
|
||||
state = DEX. DEXReader(filepath, ext );
|
||||
else state = DEX.MsgPackReader(filepath, JSON);
|
||||
|
||||
if (Format > Main.Format.NULL)
|
||||
DEX. DEXWriter(filepath, Format);
|
||||
else DEX.MsgPackWriter(filepath, JSON );
|
||||
if (state == 1)
|
||||
{
|
||||
if (Format > Format.NULL)
|
||||
DEX. DEXWriter(filepath, Format);
|
||||
else DEX.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
DEX = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
public class DFT
|
||||
{
|
||||
public static void Processor()
|
||||
{
|
||||
Console.Title = "DOF Converter";
|
||||
DOF DOF;
|
||||
Main.Choose(1, "dft", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
DOF = new DOF();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "DOF Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".dft") { DOF.DFTReader(filepath); DOF.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { DOF.TXTReader(filepath); DOF.DFTWriter(filepath); }
|
||||
DOF = new DOF();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
public class LIT
|
||||
{
|
||||
public static void Processor()
|
||||
{
|
||||
Console.Title = "Light Converter";
|
||||
Light LIT;
|
||||
Main.Choose(1, "lit", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
LIT = new Light();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Light Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".lit") { LIT.LITReader(filepath); LIT.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { LIT.TXTReader(filepath); LIT.LITWriter(filepath); }
|
||||
LIT = new Light();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
{
|
||||
public class MOT
|
||||
{
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "MOT Converter";
|
||||
Mot Mot;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
Mot = new Mot();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "MOT Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
{
|
||||
Mot. MOTReader(filepath);
|
||||
Mot.MsgPackWriter(filepath, JSON);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
Mot.MsgPackReader(filepath, ext == ".json");
|
||||
Mot. MOTWriter(filepath);
|
||||
}
|
||||
Mot = new Mot();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user