Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4698c75c7a | ||
|
|
792781a5f7 | ||
|
|
773e148783 |
+9
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public static class DCC //Databank_Checksum_Calculator
|
||||
public static class DCC //Databank Checksum Calculator
|
||||
{
|
||||
private static readonly ushort[] ChecksumLookupTable = {
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
|
||||
@@ -46,5 +46,13 @@ namespace KKdBaseLib
|
||||
result = (ushort)(ChecksumLookupTable[(result >> 8) ^ data[i]] ^ (result << 8));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static uint CalculateChecksumUInt(byte[] data)
|
||||
{
|
||||
uint result = 0xFFFFFFFF;
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
result = ChecksumLookupTable[((ushort)result >> 8) ^ data[i]] ^ (result << 8);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+73
-43
@@ -90,76 +90,88 @@ namespace KKdBaseLib
|
||||
|
||||
public static byte[] buf = new byte[8];
|
||||
public static byte* bufPtr = buf.GetPtr();
|
||||
|
||||
public static byte[] Endian(this byte[] LE, byte Len)
|
||||
{ CFUTRM(buf, ref bufPtr);
|
||||
for (byte i = 0; i < Len; i++) bufPtr[i] = LE[i];
|
||||
for (byte i = 0; i < Len; i++) LE[Len - i - 1] = bufPtr[i]; return LE; }
|
||||
|
||||
public static byte[] Endian(this byte[] LE, byte Len, bool IsBE)
|
||||
{ CFUTRM(buf, ref bufPtr);
|
||||
if (IsBE) { for (byte i = 0; i < Len; i++) bufPtr[i] = LE[i];
|
||||
for (byte i = 0; i < Len; i++) LE[Len - i - 1] = bufPtr[i]; } return LE; }
|
||||
|
||||
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 short Endian(this short LE, bool IsBE)
|
||||
{ CFUTRM(buf, ref bufPtr);
|
||||
if (IsBE) { int TLE = 0; for (byte i = 0; i < 2; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < 2; i++) { TLE |= bufPtr[i]; if (i < 1) TLE <<= 8; } LE = (short)TLE; } 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 ushort Endian(this ushort LE, bool IsBE)
|
||||
{ CFUTRM(buf, ref bufPtr);
|
||||
if (IsBE) { for (byte i = 0; i < 2; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < 2; i++) { LE |= bufPtr[i]; if (i < 1) LE <<= 8; } } return LE; }
|
||||
|
||||
public static int Endian(this int LE, bool IsBE)
|
||||
{ CFUTRM(buf, ref bufPtr);
|
||||
if (IsBE) { for (byte i = 0; i < 4; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < 4; i++) { LE |= bufPtr[i]; if (i < 3) LE <<= 8; } } return LE; }
|
||||
|
||||
public static uint Endian(this uint LE, bool IsBE)
|
||||
{ CFUTRM(buf, ref bufPtr);
|
||||
if (IsBE) { for (byte i = 0; i < 4; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < 4; i++) { LE |= bufPtr[i]; if (i < 3) LE <<= 8; } } return LE; }
|
||||
|
||||
public static long Endian(this long LE, bool IsBE)
|
||||
{ CFUTRM(buf, ref bufPtr);
|
||||
if (IsBE) { for (byte i = 0; i < 8; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < 8; i++) { LE |= bufPtr[i]; if (i < 7) LE <<= 8; } } return LE; }
|
||||
|
||||
public static ulong Endian(this ulong LE, bool IsBE)
|
||||
{ CFUTRM(buf, ref bufPtr);
|
||||
if (IsBE) { for (byte i = 0; i < 8; i++) { bufPtr[i] = (byte)LE; LE >>= 8; } LE = 0;
|
||||
for (byte i = 0; i < 8; i++) { LE |= bufPtr[i]; if (i < 7) 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; }
|
||||
{ return ( sbyte)(c > 0x0000007F ? 0x0000007F : c < -0x00000080 ? -0x00000080 : c); }
|
||||
|
||||
public static byte CITB (this int c)
|
||||
{ if (c > 0x000000FF) c = 0x000000FF;
|
||||
else if (c < 0x00000000) c = 0x00000000; return ( byte)c; }
|
||||
{ return ( byte)(c > 0x000000FF ? 0x000000FF : c < 0x00000000 ? 0x00000000 : c); }
|
||||
|
||||
public static short CITS (this int c)
|
||||
{ if (c > 0x00007FFF) c = 0x00007FFF;
|
||||
else if (c < -0x00008000) c = -0x00008000; return ( short)c; }
|
||||
{ return ( short)(c > 0x00007FFF ? 0x00007FFF : c < -0x00008000 ? -0x00008000 : c); }
|
||||
|
||||
public static ushort CITUS(this int c)
|
||||
{ if (c > 0x0000FFFF) c = 0x0000FFFF;
|
||||
else if (c < 0x00000000) c = 0x00000000; return (ushort)c; }
|
||||
{ return (ushort)(c > 0x0000FFFF ? 0x0000FFFF : c < 0x00000000 ? 0x00000000 : 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; }
|
||||
{ c = c.Round(); return ( sbyte)(c > 0x0000007F ? 0x0000007F : c < -0x00000080 ? -0x00000080 : 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; }
|
||||
{ c = c.Round(); return ( byte)(c > 0x000000FF ? 0x000000FF : c < 0x00000000 ? 0x00000000 : 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; }
|
||||
{ c = c.Round(); return ( short)(c > 0x00007FFF ? 0x00007FFF : c < -0x00008000 ? -0x00008000 : 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; }
|
||||
{ c = c.Round(); return (ushort)(c > 0x0000FFFF ? 0x0000FFFF : c < 0x00000000 ? 0x00000000 : 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; }
|
||||
{ c = c.Round(); return ( sbyte)(c > 0x0000007F ? 0x0000007F : c < -0x00000080 ? -0x00000080 : 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; }
|
||||
{ c = c.Round(); return ( byte)(c > 0x000000FF ? 0x000000FF : c < 0x00000000 ? 0x00000000 : 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; }
|
||||
{ c = c.Round(); return ( short)(c > 0x00007FFF ? 0x00007FFF : c < -0x00008000 ? -0x00008000 : 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; }
|
||||
{ c = c.Round(); return (ushort)(c > 0x0000FFFF ? 0x0000FFFF : c < 0x00000000 ? 0x00000000 : 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; }
|
||||
{ c = c.Round(); return ( int)(c > 0x7FFFFFFF ? 0x7FFFFFFF : c < -0x80000000 ? -0x80000000 : 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; }
|
||||
{ c = c.Round(); return ( uint)(c > 0xFFFFFFFF ? 0xFFFFFFFF : c < 0xFFFFFFFF ? 0x00000000 : c); }
|
||||
|
||||
public static int ToInt32(this float f) => *( int*)&f;
|
||||
public static uint ToUInt32(this float f) => *( uint*)&f;
|
||||
@@ -168,8 +180,8 @@ namespace KKdBaseLib
|
||||
|
||||
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 double ToDouble(this long i) => *(double*)&i;
|
||||
public static double ToDouble(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; }
|
||||
@@ -182,8 +194,19 @@ namespace KKdBaseLib
|
||||
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 IntPtr GetIntPtr(this sbyte[] array) { fixed ( sbyte* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this byte[] array) { fixed ( byte* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this short[] array) { fixed ( short* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this ushort[] array) { fixed (ushort* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this int[] array) { fixed ( int* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this uint[] array) { fixed ( uint* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this long[] array) { fixed ( long* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this ulong[] array) { fixed ( ulong* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this float[] array) { fixed ( float* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this double[] array) { fixed (double* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
|
||||
public static string ToString(this int d, bool IsBE) =>
|
||||
BitConverter.GetBytes((int)((long)d).Endian(4, IsBE)).ToASCII();
|
||||
BitConverter.GetBytes(d.Endian(IsBE)).ToASCII();
|
||||
|
||||
public static string ToString(this object d)
|
||||
{
|
||||
@@ -239,5 +262,12 @@ namespace KKdBaseLib
|
||||
{ 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; }
|
||||
|
||||
[System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptions]
|
||||
[System.Security.SecuritySafeCritical]
|
||||
private static void CFUTRM(byte[] buf, ref byte* bufPtr) //CheckForUnableToReadMemory
|
||||
{ try { if (buf[0] != bufPtr[0] || bufPtr[1] != bufPtr[1] || bufPtr[2] != bufPtr[2] || buf[3] != bufPtr[3] ||
|
||||
buf[4] != bufPtr[4] || bufPtr[5] != bufPtr[5] || bufPtr[6] != bufPtr[6] || buf[7] != bufPtr[7])
|
||||
bufPtr = buf.GetPtr(); } catch (AccessViolationException) { bufPtr = buf.GetPtr(); } }
|
||||
}
|
||||
}
|
||||
|
||||
+200
-51
@@ -1,102 +1,251 @@
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct ENRS
|
||||
public unsafe struct ENRSList : INull
|
||||
{
|
||||
public int Offset;
|
||||
public int Count;
|
||||
public int Size;
|
||||
public int Repeat;
|
||||
public SubENRS[] Sub;
|
||||
public int Depth;
|
||||
public KKdList<ENRS> List;
|
||||
|
||||
public static unsafe ENRS[] Read(byte[] data)
|
||||
public int Length => length();
|
||||
|
||||
public bool IsNull => List. IsNull;
|
||||
public bool NotNull => List.NotNull;
|
||||
|
||||
public static ENRSList Read(byte[] data, int Depth = 0)
|
||||
{
|
||||
if (data == null || data.Length < 0x10) return default;
|
||||
byte* ptr = data.GetPtr();
|
||||
int i, i0;
|
||||
int ENRSCount = ((int*)ptr)[1];
|
||||
ENRS[] ENRSArr = new ENRS[ENRSCount];
|
||||
KKdList<ENRS> List = KKdList<ENRS>.New;
|
||||
ptr += 0x10;
|
||||
ENRS ENR;
|
||||
ENRS.SubENRS Sub;
|
||||
|
||||
ENRS ENR = new ENRS();
|
||||
for (i = 0; i < ENRSCount; i++)
|
||||
{
|
||||
ENR.Offset = ReadENRSValue(ref ptr) + ENR.Offset;
|
||||
ENR = default;
|
||||
ENR.Offset = ReadENRSValue(ref ptr);
|
||||
ENR.Count = ReadENRSValue(ref ptr);
|
||||
ENR.Size = ReadENRSValue(ref ptr);
|
||||
ENR.Repeat = ReadENRSValue(ref ptr);
|
||||
|
||||
if (ENR.Repeat > 0)
|
||||
if (i > 0) ENR.Offset += List[List.Count - 1].Offset;
|
||||
|
||||
if (ENR.Repeat < 1) { ENR.Sub = null; List.Add(ENR); continue; }
|
||||
|
||||
ENR.Sub = new KKdList<ENRS.SubENRS> { Capacity = ENR.Count };
|
||||
for (i0 = 0; i0 < ENR.Count; i0++)
|
||||
{
|
||||
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);
|
||||
Sub = default;
|
||||
Sub.Skip = ReadENRSValue(ref ptr, out Sub.Type);
|
||||
Sub.Reverse = ReadENRSValue(ref ptr);
|
||||
if (i0 > 0) Sub.Skip += ENR.Sub[i0 - 1].SizeSkip;
|
||||
ENR.Sub.Add(Sub);
|
||||
|
||||
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);
|
||||
}
|
||||
if (ENR.Sub[i0].Type == ENRS.Type.Invalid) return default;
|
||||
}
|
||||
else ENR.Sub = null;
|
||||
ENRSArr[i] = ENR;
|
||||
List.Add(ENR);
|
||||
}
|
||||
return ENRSArr;
|
||||
return new ENRSList { Depth = Depth, List = List };
|
||||
}
|
||||
|
||||
private static unsafe int ReadENRSValue(ref byte* ptr, out Type Rev)
|
||||
public static byte[] Write(ENRSList ENRS)
|
||||
{
|
||||
int i, i0;
|
||||
byte[] data;
|
||||
byte* ptr;
|
||||
|
||||
KKdList<ENRS> List = (System.Collections.Generic.List<ENRS>)ENRS.List;
|
||||
if (ENRS.IsNull || ENRS.List.Count < 1) return new byte[0x20];
|
||||
|
||||
data = new byte[ENRS.Length];
|
||||
ptr = data.GetPtr();
|
||||
((int*)ptr)[1] = ENRS.List.Count;
|
||||
ptr += 0x10;
|
||||
|
||||
for (i = 0; i < ENRS.List.Count; i++)
|
||||
{
|
||||
ENRS ENR = ENRS.List[i];
|
||||
WriteENRSValue(ref ptr, i > 0 ? ENR.Offset - ENRS.List[i - 1].Offset : ENR.Offset);
|
||||
WriteENRSValue(ref ptr, ENR.Count );
|
||||
WriteENRSValue(ref ptr, ENR.Size );
|
||||
WriteENRSValue(ref ptr, ENR.Repeat);
|
||||
|
||||
if (ENR.Repeat < 1) continue;
|
||||
|
||||
for (i0 = 0; i0 < ENR.Count; i0++)
|
||||
{
|
||||
if (ENR.Sub[i0].Type < ENRSList.ENRS.Type. WORD ||
|
||||
ENR.Sub[i0].Type > ENRSList.ENRS.Type.QWORD)
|
||||
return data;
|
||||
|
||||
WriteENRSValue(ref ptr, i0 > 0 ? ENR.Sub[i0].Skip -
|
||||
ENR.Sub[i0 - 1].SizeSkip : ENR.Sub[i0].Skip, ENR.Sub[i0].Type);
|
||||
WriteENRSValue(ref ptr, ENR.Sub[i0].Reverse);
|
||||
}
|
||||
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private int length()
|
||||
{
|
||||
int i, i0;
|
||||
int length = 0x10;
|
||||
for (i = 0; i < List.Count; i++)
|
||||
{
|
||||
ENRS ENR = List[i];
|
||||
length += GetSize(i > 0 ? ENR.Offset - List[i - 1].Offset : ENR.Offset);
|
||||
length += GetSize(ENR.Count );
|
||||
length += GetSize(ENR.Size );
|
||||
length += GetSize(ENR.Repeat);
|
||||
|
||||
if (ENR.Repeat < 1) continue;
|
||||
|
||||
for (i0 = 0; i0 < ENR.Count; i0++)
|
||||
{
|
||||
if (ENR.Sub[i0].Type < ENRS.Type. WORD ||
|
||||
ENR.Sub[i0].Type > ENRS.Type.QWORD) return length.Align(0x10);
|
||||
|
||||
length += GetSizeType(i0 > 0 ? ENR.Sub[i0].Skip - ENR.Sub[i0 - 1].SizeSkip : ENR.Sub[i0].Skip);
|
||||
length += GetSize(ENR.Sub[i0].Reverse);
|
||||
}
|
||||
}
|
||||
return length.Align(0x10);
|
||||
|
||||
int GetSizeType(int Val) => Val < 0x00000010 ? 1 : Val < 0x00001000 ? 2 : 4;
|
||||
int GetSize (int Val) => Val < 0x00000040 ? 1 : Val < 0x00004000 ? 2 : 4;
|
||||
}
|
||||
|
||||
/*private static KKdList<ENRS.SubENRS> Optimize(KKdList<ENRS.SubENRS> Sub)
|
||||
{
|
||||
if (Sub.IsNull || Sub.Count < 2) return Sub;
|
||||
|
||||
for (int i = 1; i < Sub.Capacity; i++)
|
||||
if (Sub[i - 1].Skip == Sub[i].Skip - Sub[i - 1].Size && Sub[i - 1].Type == Sub[i].Type)
|
||||
{
|
||||
ENRS.SubENRS SubENRS = Sub[i - 1];
|
||||
SubENRS.Reverse++;
|
||||
Sub[i - 1] = SubENRS;
|
||||
Sub.RemoveAt(i);
|
||||
Sub.Capacity--;
|
||||
i--;
|
||||
}
|
||||
return Sub;
|
||||
}*/
|
||||
|
||||
[System.ThreadStatic] private static ENRS.Value Value;
|
||||
|
||||
private static int ReadENRSValue(ref byte* ptr, out ENRS.Type Type)
|
||||
{
|
||||
int V = *ptr & 0xF;
|
||||
Rev = (Type)(*ptr & 0x30);
|
||||
Value Val = (Value)(*ptr & 0xC0);
|
||||
Type = (ENRS. Type)((*ptr & 0x30) >> 4);
|
||||
Value = (ENRS.Value)((*ptr & 0xC0) >> 6);
|
||||
ptr++;
|
||||
if (Val == Value.Int32 )
|
||||
if (Value == ENRS.Value.Int32 )
|
||||
{ V = (V << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; }
|
||||
else if (Val == Value.Int16 )
|
||||
else if (Value == ENRS.Value.Int16 )
|
||||
{ V = (V << 8) | ptr[0]; ptr += 1; }
|
||||
else if (Val == Value.Invalid) V = 0;
|
||||
else if (Value == ENRS.Value.Invalid) V = 0;
|
||||
return V;
|
||||
}
|
||||
|
||||
private static unsafe int ReadENRSValue(ref byte* ptr)
|
||||
private static int ReadENRSValue(ref byte* ptr)
|
||||
{
|
||||
int V = *ptr & 0x3F;
|
||||
Value Val = (Value)(*ptr & 0xC0);
|
||||
Value = (ENRS.Value)((*ptr & 0xC0) >> 6);
|
||||
ptr++;
|
||||
if (Val == Value.Int32 )
|
||||
if (Value == ENRS.Value.Int32 )
|
||||
{ V = (V << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; }
|
||||
else if (Val == Value.Int16 )
|
||||
else if (Value == ENRS.Value.Int16 )
|
||||
{ V = (V << 8) | ptr[0]; ptr += 1; }
|
||||
else if (Val == Value.Invalid) V = 0;
|
||||
else if (Value == ENRS.Value.Invalid) V = 0;
|
||||
return V;
|
||||
}
|
||||
|
||||
public enum Type : byte
|
||||
private static void WriteENRSValue(ref byte* ptr, int Val, ENRS.Type Type)
|
||||
{
|
||||
WORD = 0b00000000,
|
||||
DWORD = 0b00010000,
|
||||
QWORD = 0b00100000,
|
||||
Invalid = 0b00110000,
|
||||
Value = ENRS.Value.Invalid;
|
||||
if (Val < 0x00000040) Value = ENRS.Value.Int8 ;
|
||||
else if (Val < 0x00004000) Value = ENRS.Value.Int16;
|
||||
else if (Val < 0x40000000) Value = ENRS.Value.Int32;
|
||||
*ptr = (byte)((((byte)Value << 6) & 0xC0) | (((byte)Type << 4) & 0x30));
|
||||
|
||||
if (Val < 0x00000010)
|
||||
{ *ptr |= (byte)( Val & 0x0F); }
|
||||
else if (Val < 0x00001000)
|
||||
{ *ptr |= (byte)((Val >> 8) & 0x0F); ptr++;
|
||||
*ptr = (byte)( Val & 0xFF); }
|
||||
else if (Val < 0x10000000)
|
||||
{ *ptr |= (byte)((Val >> 24) & 0x0F); ptr++;
|
||||
*ptr = (byte)((Val >> 16) & 0xFF); ptr++;
|
||||
*ptr = (byte)((Val >> 8) & 0xFF); ptr++;
|
||||
*ptr = (byte)( Val & 0xFF); }
|
||||
ptr++;
|
||||
}
|
||||
|
||||
public enum Value : byte
|
||||
private static void WriteENRSValue(ref byte* ptr, int Val)
|
||||
{
|
||||
Int8 = 0b00000000,
|
||||
Int16 = 0b01000000,
|
||||
Int32 = 0b10000000,
|
||||
Invalid = 0b11000000,
|
||||
Value = ENRS.Value.Invalid;
|
||||
if (Val < 0x00000040) Value = ENRS.Value.Int8 ;
|
||||
else if (Val < 0x00004000) Value = ENRS.Value.Int16;
|
||||
else if (Val < 0x40000000) Value = ENRS.Value.Int32;
|
||||
*ptr = (byte)(((byte)Value << 6) & 0xC0);
|
||||
|
||||
if (Val < 0x00000040)
|
||||
{ *ptr |= (byte)( Val & 0x3F); }
|
||||
else if (Val < 0x00004000)
|
||||
{ *ptr |= (byte)((Val >> 8) & 0x3F); ptr++;
|
||||
*ptr = (byte)( Val & 0xFF); }
|
||||
else if (Val < 0x40000000)
|
||||
{ *ptr |= (byte)((Val >> 24) & 0x3F); ptr++;
|
||||
*ptr = (byte)((Val >> 16) & 0xFF); ptr++;
|
||||
*ptr = (byte)((Val >> 8) & 0xFF); ptr++;
|
||||
*ptr = (byte)( Val & 0xFF); }
|
||||
ptr++;
|
||||
}
|
||||
|
||||
public struct SubENRS
|
||||
public struct ENRS
|
||||
{
|
||||
public int Skip;
|
||||
public int Reverse;
|
||||
public Type Type;
|
||||
public int Offset;
|
||||
public int Count;
|
||||
public int Size;
|
||||
public int Repeat;
|
||||
public KKdList<SubENRS> Sub;
|
||||
|
||||
public override string ToString() => "Skip: " + Skip + "; Reverse: " + Reverse + "; Type: " + Type;
|
||||
public enum Type : byte
|
||||
{
|
||||
WORD = 0b00,
|
||||
DWORD = 0b01,
|
||||
QWORD = 0b10,
|
||||
Invalid = 0b11,
|
||||
}
|
||||
|
||||
public enum Value : byte
|
||||
{
|
||||
Int8 = 0b00,
|
||||
Int16 = 0b01,
|
||||
Int32 = 0b10,
|
||||
Invalid = 0b11,
|
||||
}
|
||||
|
||||
public struct SubENRS
|
||||
{
|
||||
public int Skip;
|
||||
public int Reverse;
|
||||
public Type Type;
|
||||
|
||||
public int SizeSkip => Skip + Reverse * (2 << (byte)Type);
|
||||
public int Size => Reverse * (2 << (byte)Type);
|
||||
|
||||
public override string ToString() => "Skip: " + Skip + "; Reverse: " + Reverse + "; Type: " + Type;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
"Offset: " + Offset + "; Count: " + Count + "; " + "Size: " + Size + "; Repeat: " + Repeat;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
"Offset: " + Offset + "; Count: " + Count + "; " + "Size: " + Size + "; Repeat: " + Repeat;
|
||||
$"Depth: {Depth}{(NotNull ? $"; ENRS Count: {List.Count}" : "")}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,18 @@
|
||||
public int Signature;
|
||||
public int DataSize;
|
||||
public int Length;
|
||||
public Format Format;
|
||||
public int ID;
|
||||
public int Flags;
|
||||
public int Depth;
|
||||
public int SectionSize;
|
||||
public int SubID;
|
||||
public int Mode;
|
||||
public int InnerSignature;
|
||||
public int SectionSignature;
|
||||
|
||||
public Format Format;
|
||||
public bool NotUseDataSizeAsSectionSize;
|
||||
|
||||
public bool IsBE => Format == Format.F2BE;
|
||||
public bool IsX => Format == Format.X || Format == Format.XHD;
|
||||
public bool IsX => Format == Format.X || Format == Format.XHD;
|
||||
|
||||
public override string ToString() => Signature.ToString(false);
|
||||
}
|
||||
|
||||
+53
-32
@@ -1,8 +1,17 @@
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct POF
|
||||
public unsafe struct POF : INull
|
||||
{
|
||||
public static unsafe KKdList<long> Read(byte[] data, bool ShiftX)
|
||||
public int Depth;
|
||||
public KKdList<long> Offsets;
|
||||
|
||||
public bool IsNull => Offsets. IsNull;
|
||||
public bool NotNull => Offsets.NotNull;
|
||||
|
||||
public int Length => length(false).Align(0x10);
|
||||
public int LengthX => length( true).Align(0x10);
|
||||
|
||||
public static POF Read(byte[] data, bool ShiftX, int Depth = 0)
|
||||
{
|
||||
Value Val = 0;
|
||||
KKdList<long> Offsets = KKdList<long>.New;
|
||||
@@ -24,52 +33,61 @@
|
||||
Offset += V;
|
||||
Offsets.Add(Offset << BitShift);
|
||||
}
|
||||
return Offsets;
|
||||
return new POF { Depth = Depth, Offsets = Offsets };
|
||||
}
|
||||
|
||||
public static unsafe byte[] Write(KKdList<long> Offsets, bool ShiftX)
|
||||
public static byte[] Write(POF POF, bool ShiftX)
|
||||
{
|
||||
Offsets.Sort();
|
||||
int Length = 5;
|
||||
POF.Offsets.Sort();
|
||||
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; }
|
||||
int Max1 = 0x00100 >> BitShift;
|
||||
int Max2 = 0x10000 >> BitShift;
|
||||
|
||||
Offset >>= BitShift;
|
||||
if (Offset <= Max1) Length += 1;
|
||||
else if (Offset <= Max2) Length += 2;
|
||||
else Length += 4;
|
||||
}
|
||||
|
||||
byte[] data = new byte[Length.Align(0x10)];
|
||||
byte[] data = new byte[POF.Length];
|
||||
byte* ptr = data.GetPtr();
|
||||
|
||||
Value Val = 0;
|
||||
*(int*)ptr = Length; ptr += 4;
|
||||
for (int i = 0; i < Offsets.Count; i++)
|
||||
byte Val = 0;
|
||||
*(int*)ptr = POF.length(ShiftX); ptr += 4;
|
||||
for (int i = 0; i < POF.Offsets.Count; i++)
|
||||
{
|
||||
Offset = Offsets[i];
|
||||
if (i > 0) { Offset -= Offsets[i - 1]; if (Offset == 0) continue; }
|
||||
Offset = POF.Offsets[i];
|
||||
if (i > 0) { Offset -= POF.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 ; }
|
||||
Val = (byte)(Offset > Max2 ? Value.Int32 : Offset > Max1 ? Value.Int16 : Value.Int8);
|
||||
if (Offset < Max1) *ptr = (byte)(Val | Offset );
|
||||
else if (Offset < Max2) { *ptr = (byte)(Val | (Offset >> 8)); ptr++;
|
||||
*ptr = (byte) Offset ; }
|
||||
else { *ptr = (byte)(Val | (Offset >> 24)); ptr++;
|
||||
*ptr = (byte) (Offset >> 16) ; ptr++;
|
||||
*ptr = (byte) (Offset >> 8) ; ptr++;
|
||||
*ptr = (byte) Offset ; }
|
||||
ptr++;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private int length(bool ShiftX = false)
|
||||
{
|
||||
int length = 5;
|
||||
long Offset = 0;
|
||||
byte BitShift = (byte)(ShiftX ? 3 : 2);
|
||||
int Max1 = 0x00100 >> BitShift;
|
||||
int Max2 = 0x10000 >> 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;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
public enum Value : byte
|
||||
{
|
||||
Invalid = 0b00000000,
|
||||
@@ -77,5 +95,8 @@
|
||||
Int16 = 0b10000000,
|
||||
Int32 = 0b11000000,
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
$"Depth: {Depth}{(NotNull ? $"; Offsets Count: {Offsets.Count}" : "")}";
|
||||
}
|
||||
}
|
||||
|
||||
+36
-6
@@ -5,14 +5,44 @@
|
||||
public Header Header;
|
||||
public byte[] Data;
|
||||
public Struct[] SubStructs;
|
||||
public bool EOFC;
|
||||
public ENRS[] ENRS;
|
||||
public KKdList<long> POF;
|
||||
|
||||
public ENRSList ENRS;
|
||||
public POF POF;
|
||||
|
||||
public int Length => length(false);
|
||||
public int LengthX => length( true);
|
||||
|
||||
public int Depth => Header.Depth;
|
||||
|
||||
public bool HasPOF => POF .NotNull;
|
||||
public bool HasENRS => ENRS.NotNull;
|
||||
public bool HasSubStructs => SubStructs != null;
|
||||
|
||||
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" : "");
|
||||
public override string ToString() => $"{Header.ToString()}" +
|
||||
$"{(HasSubStructs ? $"; SubStructs: {SubStructs.Length}" : "")}" +
|
||||
$"{(HasENRS ? "; Has ENRS" : "")}{(HasPOF ? "; Has POF" : "")}";
|
||||
|
||||
private int length(bool ShiftX = false)
|
||||
{
|
||||
int length = Data != null ? Data.Length : 0;
|
||||
if (HasPOF ) length += 0x20 + (ShiftX ? POF.LengthX : POF.Length);
|
||||
if (HasENRS) length += 0x20 + ENRS.Length;
|
||||
|
||||
if (HasSubStructs)
|
||||
{
|
||||
for (int i = 0; i < SubStructs.Length; i++)
|
||||
length += (ShiftX ? SubStructs[i].LengthX : SubStructs[i].Length) + SubStructs[i].Header.Length;
|
||||
length += 0x20;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
public void Update(bool ShiftX = false)
|
||||
{
|
||||
Header.SectionSize = Data != null ? Data.Length : 0;
|
||||
Header.DataSize = length(ShiftX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+61
-57
@@ -6,78 +6,82 @@ namespace KKdBaseLib
|
||||
{
|
||||
private ushort _value;
|
||||
|
||||
public static Half NaN => new Half { _value = 0x7FFF };
|
||||
public static Half PositiveNaN => new Half { _value = 0x7FFF };
|
||||
public static Half NegativeNaN => new Half { _value = 0xFFFF };
|
||||
public static Half PositiveZero => new Half { _value = 0x0000 };
|
||||
public static Half NegativeZero => new Half { _value = 0x8000 };
|
||||
public static Half PositiveInfinity => new Half { _value = 0x7C00 };
|
||||
public static Half NegativeInfinity => new Half { _value = 0xFC00 };
|
||||
|
||||
public static explicit operator Half(ushort bits) => new Half() { _value = bits };
|
||||
|
||||
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)
|
||||
public static unsafe implicit operator float(Half h)
|
||||
{
|
||||
if (h._value == 0x0000) return +0;
|
||||
else if (h._value == 0x8000) return -0;
|
||||
else if (h._value == 0x7C00) return double.PositiveInfinity;
|
||||
else if (h._value == 0xFC00) return double.NegativeInfinity;
|
||||
else if (h._value >> 10 == 0x001F) return double.NaN;
|
||||
else if (h._value >> 10 == 0x003F) return -double.NaN;
|
||||
int sign = (h._value >> 15) & 0x001;
|
||||
int exponent = ((h._value >> 10) & 0x01F) + 127 - 15;
|
||||
int mantissa = h._value & 0x3FF;
|
||||
|
||||
long exponent = ((h._value >> 10) & 0x1F);
|
||||
long mantissa = (h._value & 0x3FF);
|
||||
sbyte n = (sbyte)(((h._value >> 15 & 0x01) == 0) ? 1 : -1);
|
||||
|
||||
double m = (((long)1 << 10) | mantissa) / Math.Pow(2, 10);
|
||||
double x = Math.Pow(2, exponent - (0x1F >> 1));
|
||||
double d = n * m * x;
|
||||
return d;
|
||||
int si32 = (sign << 31) | (exponent << 23) | (mantissa << 13);
|
||||
return *(float*)&si32;
|
||||
}
|
||||
|
||||
public static explicit operator Half( float val) => (Half)(double)val;
|
||||
|
||||
public static explicit operator Half(double val)
|
||||
public static unsafe implicit operator Half(float val)
|
||||
{
|
||||
Half h = new Half();
|
||||
if (val == +0 ) h._value = 0x0000;
|
||||
else if (val == -0 ) h._value = 0x8000;
|
||||
else if (val == double.PositiveInfinity) h._value = 0x7C00;
|
||||
else if (val == double.NegativeInfinity) h._value = 0xFC00;
|
||||
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 si32 = *(int*)&val;
|
||||
ushort sign = (ushort)( (si32 >> 16) & 0x8000);
|
||||
short exponent = ( short)(((si32 >> 23) & 0x00FF) - 127 + 15);
|
||||
ushort mantissa = (ushort)( (si32 >> 13) & 0x03FF);
|
||||
|
||||
int MaxPow = (1 << 4);
|
||||
if (exponent < 0) { exponent = 0; mantissa = 0; }
|
||||
else if (exponent > 30) exponent = 31;
|
||||
|
||||
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;
|
||||
return new Half { _value = (ushort)(sign | (exponent << 10) | mantissa) };
|
||||
}
|
||||
|
||||
public static unsafe implicit operator double(Half h)
|
||||
{
|
||||
int sign = (h._value >> 15) & 0x001;
|
||||
int exponent = ((h._value >> 10) & 0x01F) + 1023 - 15;
|
||||
int mantissa = h._value & 0x3FF;
|
||||
|
||||
long si64 = ((long)sign << 63) | ((long)exponent << 52) | ((long)mantissa << 42);
|
||||
return *(double*)&si64;
|
||||
}
|
||||
|
||||
public static unsafe implicit operator Half(double val)
|
||||
{
|
||||
long si64 = *(long*)&val;
|
||||
ushort sign = (ushort) ((si64 >> 48) & 0x8000);
|
||||
short exponent = ( short)(((si64 >> 52) & 0x07FF) - 1023 + 15);
|
||||
ushort mantissa = (ushort) ((si64 >> 42) & 0x03FF);
|
||||
|
||||
if (exponent < 0) { exponent = 0; mantissa = 0; }
|
||||
else if (exponent > 30) exponent = 31;
|
||||
|
||||
return new Half { _value = (ushort)(sign | (exponent << 10) | mantissa) };
|
||||
}
|
||||
|
||||
public static Half operator + (Half a, Half b) => (float)a + (float)b;
|
||||
public static Half operator - (Half a, Half b) => (float)a - (float)b;
|
||||
public static Half operator * (Half a, Half b) => (float)a * (float)b;
|
||||
public static Half operator / (Half a, Half b) => (float)a / (float)b;
|
||||
public static bool operator > (Half a, Half b) => (float)a > (float)b;
|
||||
public static bool operator < (Half a, Half b) => (float)a < (float)b;
|
||||
public static bool operator >=(Half a, Half b) => (float)a >= (float)b;
|
||||
public static bool operator <=(Half a, Half b) => (float)a <= (float)b;
|
||||
public static bool operator ==(Half a, Half b) => (float)a == (float)b;
|
||||
public static bool operator !=(Half a, Half b) => (float)a != (float)b;
|
||||
|
||||
public int CompareTo(object obj) => CompareTo((Half)obj);
|
||||
public int CompareTo(Half h) => this == h ? 0 : (this > h ? 1 : -1);
|
||||
public bool Equals(Half other) => this == other;
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
public override string ToString() => Extensions.ToString((double)this);
|
||||
public string ToString(string format, IFormatProvider formatProvider) =>
|
||||
((double)this).ToString(format, formatProvider);
|
||||
((float)this).ToString(format, formatProvider);
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public interface IKF<TKey, TVal>
|
||||
{
|
||||
TKey F { get; set; }
|
||||
|
||||
KFT0<TKey, TVal> ToT0();
|
||||
KFT1<TKey, TVal> ToT1();
|
||||
KFT2<TKey, TVal> ToT2();
|
||||
KFT3<TKey, TVal> ToT3();
|
||||
|
||||
IKF<TKey, TVal> Check();
|
||||
string ToString();
|
||||
string ToString(bool Brackets);
|
||||
}
|
||||
|
||||
public interface INull
|
||||
{
|
||||
bool IsNull { get; }
|
||||
bool NotNull { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
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; }
|
||||
@@ -17,15 +8,22 @@
|
||||
{ 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 KFT1<TKey, TVal> ToT1() => this;
|
||||
public KFT2<TKey, TVal> ToT2() => this;
|
||||
public KFT3<TKey, TVal> ToT3() => this;
|
||||
|
||||
public IKF<TKey, TVal> Check() => this;
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets = true) =>
|
||||
Extensions.ToString(F);
|
||||
|
||||
public static implicit operator KFT1<TKey, TVal>(KFT0<TKey, TVal> KF) =>
|
||||
new KFT1<TKey, TVal>(KF.F);
|
||||
public static implicit operator KFT2<TKey, TVal>(KFT0<TKey, TVal> KF) =>
|
||||
new KFT2<TKey, TVal>(KF.F);
|
||||
public static implicit operator KFT3<TKey, TVal>(KFT0<TKey, TVal> KF) =>
|
||||
new KFT3<TKey, TVal>(KF.F);
|
||||
}
|
||||
|
||||
public struct KFT1<TKey, TVal> : IKF<TKey, TVal>
|
||||
@@ -36,18 +34,25 @@
|
||||
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 KFT0<TKey, TVal> ToT0() => this;
|
||||
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 KFT2<TKey, TVal> ToT2() => this;
|
||||
public KFT3<TKey, TVal> ToT3() => this;
|
||||
|
||||
public IKF<TKey, TVal> Check() =>
|
||||
V.Equals(default(TVal)) ? (IKF<TKey, TVal>)ToT0() : this;
|
||||
V.Equals(default(TVal)) ? (KFT0<TKey, TVal>)this : (IKF<TKey, TVal>)this;
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets = true) =>
|
||||
(Brackets ? "(" : "") + Extensions.ToString(F) + "," +
|
||||
Extensions.ToString(V) + (Brackets ? ")" : "");
|
||||
|
||||
public static implicit operator KFT0<TKey, TVal>(KFT1<TKey, TVal> KF) =>
|
||||
new KFT0<TKey, TVal>(KF.F);
|
||||
public static implicit operator KFT2<TKey, TVal>(KFT1<TKey, TVal> KF) =>
|
||||
new KFT2<TKey, TVal>(KF.F, KF.V);
|
||||
public static implicit operator KFT3<TKey, TVal>(KFT1<TKey, TVal> KF) =>
|
||||
new KFT3<TKey, TVal>(KF.F, KF.V);
|
||||
}
|
||||
|
||||
public struct KFT2<TKey, TVal> : IKF<TKey, TVal>
|
||||
@@ -59,10 +64,10 @@
|
||||
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 KFT0<TKey, TVal> ToT0() => this;
|
||||
public KFT1<TKey, TVal> ToT1() => this;
|
||||
public KFT2<TKey, TVal> ToT2() => this;
|
||||
public KFT3<TKey, TVal> ToT3() => new KFT3<TKey, TVal>(F, V, T, T);
|
||||
public KFT3<TKey, TVal> ToT3() => this;
|
||||
|
||||
public KFT3<TKey, TVal> ToT3(IKF<TKey, TVal> Previous) =>
|
||||
Previous is KFT2<TKey, TVal> PreviousT2 ?
|
||||
@@ -71,12 +76,19 @@
|
||||
|
||||
public IKF<TKey, TVal> Check() =>
|
||||
T.Equals(default(TVal)) ? (V.Equals(default(TVal)) ?
|
||||
(IKF<TKey, TVal>)ToT0() : ToT1()) : this;
|
||||
(KFT0<TKey, TVal>)this : (IKF<TKey, TVal>)this) : this;
|
||||
|
||||
public override string ToString() => ToString(true);
|
||||
public string ToString(bool Brackets) =>
|
||||
(Brackets ? "(" : "") + Extensions.ToString(F) + "," + Extensions.
|
||||
ToString(V) + "," + Extensions.ToString(T) + (Brackets ? ")" : "");
|
||||
|
||||
public static implicit operator KFT0<TKey, TVal>(KFT2<TKey, TVal> KF) =>
|
||||
new KFT0<TKey, TVal>(KF.F);
|
||||
public static implicit operator KFT1<TKey, TVal>(KFT2<TKey, TVal> KF) =>
|
||||
new KFT1<TKey, TVal>(KF.F, KF.V);
|
||||
public static implicit operator KFT3<TKey, TVal>(KFT2<TKey, TVal> KF) =>
|
||||
new KFT3<TKey, TVal>(KF.F, KF.V, KF.T, KF.T);
|
||||
}
|
||||
|
||||
public struct KFT3<TKey, TVal> : IKF<TKey, TVal>
|
||||
@@ -89,21 +101,28 @@
|
||||
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 KFT0<TKey, TVal> ToT0() => this;
|
||||
public KFT1<TKey, TVal> ToT1() => this;
|
||||
public KFT2<TKey, TVal> ToT2() => this;
|
||||
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;
|
||||
T1.Equals(default(TVal)) && T2.Equals(default(TVal)) ? (V.Equals(default(TVal)) ?
|
||||
(IKF<TKey, TVal>)(KFT0<TKey, TVal>)this : (KFT1<TKey, TVal>)this) :
|
||||
T1.Equals(T2) ? (KFT2<TKey, TVal>)this : (IKF <TKey, TVal>)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 static implicit operator KFT0<TKey, TVal>(KFT3<TKey, TVal> KF) =>
|
||||
new KFT0<TKey, TVal>(KF.F);
|
||||
public static implicit operator KFT1<TKey, TVal>(KFT3<TKey, TVal> KF) =>
|
||||
new KFT1<TKey, TVal>(KF.F, KF.V);
|
||||
public static implicit operator KFT2<TKey, TVal>(KFT3<TKey, TVal> KF) =>
|
||||
new KFT2<TKey, TVal>(KF.F, KF.V, KF.T1);
|
||||
|
||||
public IKF<TKey, TVal> ToT2(IKF<TKey, TVal> Previous, out IKF<TKey, TVal> Current)
|
||||
{
|
||||
Current = Previous is KFT2<TKey, TVal> PreviousT2
|
||||
@@ -47,7 +47,8 @@
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="Format.cs" />
|
||||
<Compile Include="Half.cs" />
|
||||
<Compile Include="IKF.cs" />
|
||||
<Compile Include="Interfaces.cs" />
|
||||
<Compile Include="KF.cs" />
|
||||
<Compile Include="KKdList.cs" />
|
||||
<Compile Include="MsgPack.cs" />
|
||||
<Compile Include="Pointer.cs" />
|
||||
|
||||
+16
-11
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct KKdList<T> : IEnumerator, IEnumerable
|
||||
public struct KKdList<T> : System.IDisposable, IEnumerator, IEnumerable, INull
|
||||
{
|
||||
public static KKdList<T> Null => new KKdList<T>();
|
||||
public static KKdList<T> New => new KKdList<T>() { Capacity = 0 };
|
||||
public static KKdList<T> NewReserve(int Capacity) => new KKdList<T>() { Capacity = Capacity };
|
||||
public static KKdList<T> New => new KKdList<T>() { Count = 0, Capacity = 0 };
|
||||
public static KKdList<T> NewReserve(int Capacity) => new KKdList<T>() { Count = 0, Capacity = Capacity };
|
||||
|
||||
private int index;
|
||||
private T[] array;
|
||||
@@ -29,13 +29,17 @@ namespace KKdBaseLib
|
||||
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public T this[int index]
|
||||
public T this[ int index]
|
||||
{ get => array != null && index > -1 ? array[index] : default;
|
||||
set { if (array != null && index > -1) array[index] = value; } }
|
||||
|
||||
public T this[uint index]
|
||||
{ get => array != null ? array[index] : default;
|
||||
set { if (array != null) array[index] = value; } }
|
||||
|
||||
public bool MoveNext()
|
||||
{ if (index == (Count - 1)) { index = 0; return false; }
|
||||
else { index++ ; return true; } }
|
||||
{ if (index == Count - 1) { index = 0; return false; }
|
||||
else { index++ ; return true; } }
|
||||
|
||||
public IEnumerator GetEnumerator() => this;
|
||||
|
||||
@@ -67,8 +71,9 @@ namespace KKdBaseLib
|
||||
if (IsNull) return;
|
||||
if (IndexEnd - IndexStart < 1) return;
|
||||
|
||||
for (int i = IndexStart; i < Count; i++)
|
||||
array[i] = array[i + IndexEnd - IndexStart];
|
||||
if (IndexEnd - IndexStart != Count)
|
||||
for (int i = IndexStart; i < Count; i++)
|
||||
array[i] = array[i + IndexEnd - IndexStart];
|
||||
Count -= IndexEnd - IndexStart;
|
||||
}
|
||||
|
||||
@@ -95,12 +100,12 @@ namespace KKdBaseLib
|
||||
}
|
||||
|
||||
public void Sort()
|
||||
{ List<T> List = (List<T>)this; List.Sort(); array = List.ToArray(); Count = List.Count; }
|
||||
{ List<T> List = this; List.Sort(); array = List.ToArray(); Count = List.Count; }
|
||||
|
||||
public static explicit operator KKdList<T>( List<T> List) =>
|
||||
public static implicit operator KKdList<T>( List<T> List) =>
|
||||
new KKdList<T> { array = List.ToArray(), Count = List.Count };
|
||||
|
||||
public static explicit operator List<T>(KKdList<T> List)
|
||||
public static implicit operator List<T>(KKdList<T> List)
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
for (int i = 0; i < List.Count; i++) list.Add(List[i]);
|
||||
|
||||
+126
-102
@@ -2,18 +2,21 @@
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct MsgPack : IDisposable, IEquatable<MsgPack>
|
||||
public struct MsgPack : IDisposable, IEquatable<MsgPack>, INull
|
||||
{
|
||||
public string Name;
|
||||
public object Object;
|
||||
|
||||
public MsgPack[] Array => Object is MsgPack[] List ? List : null;
|
||||
public KKdList<MsgPack> List => Object is KKdList<MsgPack> List ? List : default;
|
||||
public MsgPack[] Array => Object is MsgPack[] Array ? Array : null;
|
||||
public KKdList<MsgPack> List => Object is KKdList<MsgPack> List ? List : default;
|
||||
|
||||
public static MsgPack New => new MsgPack { Object = KKdList<MsgPack>.New };
|
||||
public static MsgPack NewReserve(int Capacity) =>
|
||||
new MsgPack { Object = KKdList<MsgPack>.NewReserve(Capacity) };
|
||||
|
||||
public bool IsNull => Array == null && List. IsNull;
|
||||
public bool NotNull => Array != null || List.NotNull;
|
||||
|
||||
public MsgPack( string Name = null)
|
||||
{ Object = KKdList<MsgPack>.New; this.Name = Name; }
|
||||
|
||||
@@ -28,6 +31,14 @@ namespace KKdBaseLib
|
||||
public MsgPack this[int index]
|
||||
{ get => Object is MsgPack[] Array ? Array[index] : default;
|
||||
set { if (Object is MsgPack[] Array) { Array[index] = value; Object = Array; } } }
|
||||
|
||||
public MsgPack this[string key]
|
||||
{ get => Object is KKdList<MsgPack> List ? List[ElementIndex(key)] : default; }
|
||||
|
||||
public MsgPack this[string key, bool array]
|
||||
{ get { if (!array) return this[key];
|
||||
if (Object is KKdList<MsgPack> List) { MsgPack MsgPack = List[ElementIndex(key)];
|
||||
return MsgPack.Object is MsgPack[] ? MsgPack : default; } return default; } }
|
||||
|
||||
public MsgPack Add(MsgPack obj)
|
||||
{ if (Object is KKdList<MsgPack> List) { List.Add(obj); Object = List; } return this; }
|
||||
@@ -43,22 +54,20 @@ namespace KKdBaseLib
|
||||
(Array != null ? ((Name != null ? " " : "") + "Elements Count: " + Array.Length) :
|
||||
Object.ToString()));
|
||||
|
||||
public MsgPack Add(string Val, byte[] val) => val != null ? Add(new MsgPack(Val, val)) : this;
|
||||
public MsgPack Add(string Val, string val) => val != null ? Add(new MsgPack(Val, val)) : this;
|
||||
|
||||
public static explicit operator MsgPack(byte[] val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack(string val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack( sbyte val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack( byte val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack( short val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack(ushort val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack( int val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack( uint val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack( long val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack( ulong val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack( float val) => new MsgPack(null, val);
|
||||
public static explicit operator MsgPack(double val) => new MsgPack(null, val);
|
||||
|
||||
public static implicit operator MsgPack(byte[] val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack(string val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack( sbyte val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack( byte val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack( short val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack(ushort val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack( int val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack( uint val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack( long val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack( ulong val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack( float val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack(double val) => new MsgPack(null, val);
|
||||
|
||||
public MsgPack Add( bool? val) => val.HasValue ? Add(new MsgPack(null, val.Value)) : this;
|
||||
public MsgPack Add( sbyte? val) => val.HasValue ? Add(new MsgPack(null, val.Value)) : this;
|
||||
public MsgPack Add( byte? val) => val.HasValue ? Add(new MsgPack(null, val.Value)) : this;
|
||||
public MsgPack Add( short? val) => val.HasValue ? Add(new MsgPack(null, val.Value)) : this;
|
||||
@@ -84,6 +93,7 @@ namespace KKdBaseLib
|
||||
public MsgPack Add( float val) => Add(new MsgPack(null, val));
|
||||
public MsgPack Add(double val) => Add(new MsgPack(null, val));
|
||||
|
||||
public MsgPack Add(string Val, bool? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, sbyte? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, byte? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, short? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
@@ -94,7 +104,9 @@ namespace KKdBaseLib
|
||||
public MsgPack Add(string Val, ulong? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, float? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, double? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
|
||||
|
||||
public MsgPack Add(string Val, byte[] val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, string val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, bool val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, sbyte val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, byte val) => Add(new MsgPack(Val, val));
|
||||
@@ -121,122 +133,122 @@ namespace KKdBaseLib
|
||||
|
||||
public bool? ReadNBoolean(string Name)
|
||||
{
|
||||
if (Element(Name, out MsgPack MsgPack))
|
||||
if (MsgPack.Object is bool Boolean) return Boolean;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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 ;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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 ;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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;
|
||||
MsgPack MsgPack = this[Name];
|
||||
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;
|
||||
MsgPack MsgPack = this[Name];
|
||||
if (MsgPack.Object is string String) return String;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -325,10 +337,10 @@ namespace KKdBaseLib
|
||||
public string ReadString()
|
||||
{ if (Object is string String) return String; return null; }
|
||||
|
||||
public bool ElementArray(string Name, out MsgPack MsgPack) =>
|
||||
Element(Name, out MsgPack) ? MsgPack.Array != null : false;
|
||||
public bool ElementArray1(string Name, out MsgPack MsgPack) =>
|
||||
Element1(Name, out MsgPack) ? MsgPack.Array != null : false;
|
||||
|
||||
public bool Element(string Name, out MsgPack MsgPack)
|
||||
public bool Element1(string Name, out MsgPack MsgPack)
|
||||
{
|
||||
MsgPack = New;
|
||||
if (List.IsNull) return false;
|
||||
@@ -338,15 +350,27 @@ namespace KKdBaseLib
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ContainsKey(string Name)
|
||||
public MsgPack Element(string Name)
|
||||
{
|
||||
if (List.IsNull) return false;
|
||||
|
||||
for (int i = 0; i < List.Count ; i++)
|
||||
if (List[i].Name == Name) return true;
|
||||
return false;
|
||||
if (List.IsNull) return default;
|
||||
|
||||
for (int i = 0; i < List.Count; i++)
|
||||
if (List[i].Name == Name) return List[i];
|
||||
return default;
|
||||
}
|
||||
|
||||
|
||||
public bool ContainsKey(string Name) => ElementIndex(Name) > -1;
|
||||
|
||||
public int ElementIndex(string Name)
|
||||
{
|
||||
if (List.IsNull) return -1;
|
||||
|
||||
for (int i = 0; i < List.Count; i++)
|
||||
if (List[i].Name == Name) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public struct Ext
|
||||
{
|
||||
public sbyte Type;
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("437F63F1-8C23-429E-AB14-38B85C9EDB16")]
|
||||
[assembly: AssemblyVersion("0.4.7.2")]
|
||||
[assembly: AssemblyFileVersion("0.4.7.2")]
|
||||
[assembly: AssemblyVersion("0.4.7.5")]
|
||||
[assembly: AssemblyFileVersion("0.4.7.5")]
|
||||
|
||||
+11
-8
@@ -1,6 +1,6 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Vector2<T>
|
||||
public struct Vector2<T> : INull
|
||||
{
|
||||
public T X;
|
||||
public T Y;
|
||||
@@ -8,12 +8,13 @@
|
||||
public Vector2(T X, T Y)
|
||||
{ this.X = X; this.Y = Y; }
|
||||
|
||||
public bool NotNull => X != null && Y != null;
|
||||
public bool IsNull => X == null && Y == null;
|
||||
public bool NotNull => X != null || Y != null;
|
||||
|
||||
public override string ToString() => "X: " + X + "; Y: " + Y;
|
||||
}
|
||||
|
||||
public struct Vector3<T>
|
||||
public struct Vector3<T> : INull
|
||||
{
|
||||
public T X;
|
||||
public T Y;
|
||||
@@ -21,13 +22,14 @@
|
||||
|
||||
public Vector3(T X, T Y, T Z)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; }
|
||||
|
||||
public bool NotNull => X != null && Y != null && Z != null;
|
||||
|
||||
public bool IsNull => X == null && Y == null && Z == null;
|
||||
public bool NotNull => X != null || Y != null || Z != null;
|
||||
|
||||
public override string ToString() => "X: " + X + "; Y: " + Y + "; Z: " + Z;
|
||||
}
|
||||
|
||||
public struct Vector4<T>
|
||||
public struct Vector4<T> : INull
|
||||
{
|
||||
public T X;
|
||||
public T Y;
|
||||
@@ -36,8 +38,9 @@
|
||||
|
||||
public Vector4(T X, T Y, T Z, T W)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; this.W = W; }
|
||||
|
||||
public bool NotNull => X != null && Y != null && Z != null && W != null;
|
||||
|
||||
public bool IsNull => X == null && Y == null && Z == null && W == null;
|
||||
public bool NotNull => X != null || Y != null || Z != null || W != null;
|
||||
|
||||
public override string ToString() => "X: " + X + "; Y: " + Y + "; Z: " + Z + "; W: " + W;
|
||||
}
|
||||
|
||||
@@ -37,17 +37,17 @@
|
||||
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 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 = 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) =>
|
||||
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 };
|
||||
|
||||
@@ -38,14 +38,14 @@
|
||||
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,
|
||||
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) =>
|
||||
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,
|
||||
|
||||
+359
-372
File diff suppressed because it is too large
Load Diff
+173
-120
@@ -1,7 +1,6 @@
|
||||
//Original: AetSet.bt Version: 2.0 by samyuu
|
||||
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib.Aet
|
||||
@@ -61,15 +60,23 @@ namespace KKdMainLib.Aet
|
||||
Aet.Unk = IO.ReadSingle();
|
||||
Aet.Duration = IO.ReadSingle();
|
||||
Aet.FrameRate = IO.ReadSingle();
|
||||
IO.ReadInt32();
|
||||
Aet.Width = IO.ReadInt32();
|
||||
Aet.Height = IO.ReadInt32();
|
||||
Aet.DontChange = IO.ReadInt32();
|
||||
if (Aet.DontChange != 0) { IO.Close(); return; }
|
||||
Aet.BackgroundColor = IO.ReadInt32();
|
||||
Aet.Width = IO.ReadInt32();
|
||||
Aet.Height = IO.ReadInt32();
|
||||
Aet.Position = IO.ReadPointer<Vector2<KeyFrameEntry>>();
|
||||
Aet.Layers = IO.ReadCountPointer< AetLayer>();
|
||||
Aet.SpriteEntries = IO.ReadCountPointer<SpriteEntry>();
|
||||
Aet.Unknown = IO.ReadCountPointer<int>();
|
||||
|
||||
if (Aet.Position.Offset > 0)
|
||||
{
|
||||
IO.Position = Aet.Position.Offset;
|
||||
Aet.Position.Value.X.Offset = IO.ReadInt32();
|
||||
Aet.Position.Value.Y.Offset = IO.ReadInt32();
|
||||
IO.ReadKeyFrameEntry(ref Aet.Position.Value.X);
|
||||
IO.ReadKeyFrameEntry(ref Aet.Position.Value.Y);
|
||||
}
|
||||
|
||||
IO.Position = Aet.Layers.Offset;
|
||||
for (i = 0; i < Aet.Layers.Count; i++)
|
||||
Aet.Layers[i] = new AetLayer() { Pointer = IO.Position,
|
||||
@@ -149,16 +156,37 @@ namespace KKdMainLib.Aet
|
||||
for (i0 = 0; i0 < Aet.Layers.Entries[i].Count; i0++)
|
||||
IO.Write(ref Aet.Layers.Entries[i].Objects[i0]);
|
||||
}
|
||||
|
||||
|
||||
if (Aet.Position.Offset > 0)
|
||||
{
|
||||
IO.Align(0x10);
|
||||
int Flags = 0;
|
||||
Flags |= IO.Write(ref Aet.Position.Value.X) ? 0b10 : 0;
|
||||
Flags |= IO.Write(ref Aet.Position.Value.Y) ? 0b01 : 0;
|
||||
|
||||
IO.Align(0x20);
|
||||
Aet.Position.Offset = IO.Position;
|
||||
IO.Write(Aet.Position.Value.X.Count );
|
||||
if ((Flags & 0b10) == 0b10) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Aet.Position.Value.X.Offset);
|
||||
IO.Write(Aet.Position.Value.X.Count );
|
||||
if ((Flags & 0b01) == 0b01) NullValPointers.Add(IO.Position);
|
||||
IO.Write(Aet.Position.Value.Y.Offset);
|
||||
|
||||
IO.Write(ref Aet.Position.Value.X);
|
||||
IO.Write(ref Aet.Position.Value.Y);
|
||||
}
|
||||
else Aet.Position.Offset = 0;
|
||||
|
||||
IO.Align(0x20);
|
||||
AET.Offset = IO.Position;
|
||||
IO.Write(0L);
|
||||
IO.Write(Aet.Duration);
|
||||
IO.Write(Aet.FrameRate);
|
||||
IO.Write(0);
|
||||
IO.Write(Aet.BackgroundColor);
|
||||
IO.Write(Aet.Width);
|
||||
IO.Write(Aet.Height);
|
||||
IO.Write(0);
|
||||
IO.Write(Aet.Position.Offset);
|
||||
IO.Write(0L);
|
||||
IO.Write(0L);
|
||||
IO.Write(0L);
|
||||
@@ -212,7 +240,7 @@ namespace KKdMainLib.Aet
|
||||
for (i = 0; i < NullValPointers.Count; i++)
|
||||
{
|
||||
IO.Position = NullValPointers[i];
|
||||
IO.Write(ReturnPosition + i << 2);
|
||||
IO.Write(ReturnPosition + (i << 2));
|
||||
}
|
||||
|
||||
for (i = 0; i < Aet.Layers.Count; i++)
|
||||
@@ -321,23 +349,21 @@ namespace KKdMainLib.Aet
|
||||
AET = new AetHeader();
|
||||
|
||||
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
|
||||
if (!MsgPack.ElementArray("Aet", out MsgPack Aet)) { MsgPack.Dispose(); return; }
|
||||
|
||||
if (Aet.Array != null)
|
||||
if (Aet.Array.Length > 0)
|
||||
MsgPack Aet;
|
||||
if ((Aet = MsgPack["Aet", true]).NotNull)
|
||||
if (Aet.Array != null && Aet.Array.Length > 0)
|
||||
{
|
||||
AET.Data = new Pointer<AetData>[Aet.Array.Length];
|
||||
for (int i = 0; i < AET.Data.Length; i++)
|
||||
MsgPackReader(Aet.Array[i], ref AET.Data[i]);
|
||||
}
|
||||
|
||||
Aet.Dispose();
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool JSON)
|
||||
{
|
||||
if (this.AET.Data == null) return;
|
||||
if (this.AET.Data.Length == 0) return;
|
||||
if (this.AET.Data == null || this.AET.Data.Length == 0) return;
|
||||
|
||||
MsgPack AET = new MsgPack(this.AET.Data.Length, "Aet");
|
||||
for (int i = 0; i < this.AET.Data.Length; i++) AET[i] = MsgPackWriter(ref this.AET.Data[i]);
|
||||
@@ -355,39 +381,44 @@ namespace KKdMainLib.Aet
|
||||
Aet.Unk = AET.ReadSingle("Unk" );
|
||||
Aet.Duration = AET.ReadSingle("Duration" );
|
||||
Aet.FrameRate = AET.ReadSingle("FrameRate");
|
||||
Aet.Width = AET.ReadInt32("Width" );
|
||||
Aet.Height = AET.ReadInt32("Height");
|
||||
Aet.BackgroundColor = AET.ReadInt32("BackgroundColor");
|
||||
Aet.Width = AET.ReadInt32("Width" );
|
||||
Aet.Height = AET.ReadInt32("Height" );
|
||||
|
||||
if (AET.Element("Unknown", out Temp))
|
||||
if ((Temp = AET["Unknown"]).NotNull)
|
||||
Aet.Unknown.Count = Temp.ReadInt32();
|
||||
|
||||
|
||||
if (AET.ElementArray("SpriteEntries", out Temp))
|
||||
|
||||
if ((Temp = AET["Position"]).NotNull)
|
||||
{
|
||||
Aet.Position.Offset = 1;
|
||||
Aet.Position.Value.X.ReadMP(Temp, "X");
|
||||
Aet.Position.Value.Y.ReadMP(Temp, "Y");
|
||||
}
|
||||
|
||||
if ((Temp = AET["SpriteEntries", true]).NotNull)
|
||||
{
|
||||
Aet.SpriteEntries.Count = Temp.Array.Length;
|
||||
for (i = 0; i < Aet.SpriteEntries.Count; i++)
|
||||
Aet.SpriteEntries.Entries[i].ReadMP(Temp[i]);
|
||||
}
|
||||
else return;
|
||||
|
||||
|
||||
if (AET.ElementArray("Layers", out Temp))
|
||||
|
||||
if ((Temp = AET["Layers", true]).NotNull)
|
||||
{
|
||||
Aet.Layers.Count = Temp.Array.Length + 1;
|
||||
for (i = 0; i < Aet.Layers.Count - 1; i++)
|
||||
Aet.Layers.Entries[i].ReadMP(Temp[i]);
|
||||
}
|
||||
else return;
|
||||
|
||||
else Aet.Layers.Count = 1;
|
||||
|
||||
i = Aet.Layers.Count - 1;
|
||||
if (AET.ElementArray("RootLayer", out Temp))
|
||||
if ((Temp = AET["RootLayer", true]).NotNull)
|
||||
{
|
||||
Aet.Layers.Entries[i].Count = Temp.Array.Length;
|
||||
for (i0 = 0; i0 < Aet.Layers[i].Count; i0++)
|
||||
Aet.Layers.Entries[i].Objects[i0].ReadMP(Temp[i0]);
|
||||
}
|
||||
else if (AET.Element("RootLayer", out Temp))
|
||||
else if ((Temp = AET["RootLayer"]).NotNull)
|
||||
{
|
||||
Aet.Layers.Entries[i].Count = 1;
|
||||
Aet.Layers.Entries[i].Objects[0].ReadMP(Temp);
|
||||
@@ -395,6 +426,7 @@ namespace KKdMainLib.Aet
|
||||
else return;
|
||||
|
||||
AetData.Offset = 0;
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack MsgPackWriter(ref Pointer<AetData> AetData)
|
||||
@@ -402,12 +434,16 @@ namespace KKdMainLib.Aet
|
||||
if (AetData.Offset <= 0) return MsgPack.New;
|
||||
ref AetData Aet = ref AetData.Value;
|
||||
|
||||
MsgPack AET = MsgPack.New.Add("Name", Aet.Name.Value).Add("Duration",
|
||||
Aet.Duration).Add("FrameRate", Aet.FrameRate).Add("Width",
|
||||
Aet.Width).Add("Height", Aet.Height).Add("Unk", Aet.Unk);
|
||||
MsgPack AET = MsgPack.New.Add("Name", Aet.Name.Value).Add("Duration", Aet.Duration).
|
||||
Add("FrameRate", Aet.FrameRate).Add("BackgroundColor", Aet.BackgroundColor).
|
||||
Add("Width", Aet.Width).Add("Height", Aet.Height).Add("Unk", Aet.Unk);
|
||||
if (Aet.Unknown.Count > 0)
|
||||
AET.Add("Unknown", Aet.Unknown.Count);
|
||||
|
||||
if (Aet.Position.Offset > 0)
|
||||
AET.Add(new MsgPack("Position").Add(Aet.Position.Value.X.WriteMP("X"))
|
||||
.Add(Aet.Position.Value.Y.WriteMP("Y")));
|
||||
|
||||
i = Aet.Layers.Count - 1;
|
||||
if (Aet.Layers[i].Count == 1)
|
||||
AET.Add(Aet.Layers[i][0].WriteMP(ref Aet, "RootLayer"));
|
||||
@@ -417,12 +453,12 @@ namespace KKdMainLib.Aet
|
||||
for (i0 = 0; i0 < Aet.Layers[i].Count; i0++)
|
||||
RootLayer[i0] = Aet.Layers[i][i0].WriteMP(ref Aet);
|
||||
AET.Add(RootLayer);
|
||||
}
|
||||
|
||||
MsgPack Layers = new MsgPack(Aet.Layers.Count - 1, "Layers");
|
||||
for (i = 0; i < Aet.Layers.Count - 1; i++)
|
||||
Layers[i] = Aet.Layers[i].WriteMP(i, ref Aet);
|
||||
AET.Add(Layers);
|
||||
MsgPack Layers = new MsgPack(Aet.Layers.Count - 1, "Layers");
|
||||
for (i = 0; i < Aet.Layers.Count - 1; i++)
|
||||
Layers[i] = Aet.Layers[i].WriteMP(i, ref Aet);
|
||||
AET.Add(Layers);
|
||||
}
|
||||
|
||||
MsgPack SpriteEntries = new MsgPack(Aet.SpriteEntries.Count, "SpriteEntries");
|
||||
for (i = 0; i < Aet.SpriteEntries.Count; i++)
|
||||
@@ -437,19 +473,21 @@ namespace KKdMainLib.Aet
|
||||
{
|
||||
public static MsgPack ReadMP(this MsgPack msg, ref CountPointer<float> val, string Name)
|
||||
{
|
||||
MsgPack Temp;
|
||||
val.Offset = 0;
|
||||
val.Entries = null;
|
||||
if (msg.ContainsKey(Name))
|
||||
if ((Temp = msg[Name, true]).NotNull)
|
||||
{
|
||||
val.Count = 1;
|
||||
val[0] = msg.ReadSingle(Name);
|
||||
val[0] = Temp.ReadSingle();
|
||||
}
|
||||
else if(msg.ElementArray(Name, out MsgPack Temp))
|
||||
else if ((Temp = msg[Name]).NotNull)
|
||||
{
|
||||
val.Count = Temp.Array.Length;
|
||||
for (int i = 0; i < val.Count; i++)
|
||||
val[i] = Temp[i].ReadSingle();
|
||||
}
|
||||
Temp.Dispose();
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -459,7 +497,7 @@ namespace KKdMainLib.Aet
|
||||
else if (val.Count > 1)
|
||||
{
|
||||
MsgPack Val = new MsgPack(val.Count, Name);
|
||||
for (int i = 0; i < val.Count; i++) Val[i] = (MsgPack)val[i];
|
||||
for (int i = 0; i < val.Count; i++) Val[i] = val[i];
|
||||
return MsgPack.Add(Val);
|
||||
}
|
||||
return MsgPack;
|
||||
@@ -825,7 +863,7 @@ namespace KKdMainLib.Aet
|
||||
if (entry.Count > 2) IO.Align(0x20);
|
||||
entry.Offset = IO.Position;
|
||||
if (entry.Count == 1) if (entry.Value == 0) return true;
|
||||
else { IO.Write(entry.Value); return false; }
|
||||
else { IO.Write(entry.Value); return false; }
|
||||
|
||||
for (int i = 0; i < entry.Count; i++) IO.Write(entry.KeyFrame [i]);
|
||||
for (int i = 0; i < entry.Count; i++)
|
||||
@@ -835,17 +873,19 @@ namespace KKdMainLib.Aet
|
||||
|
||||
public static void ReadMP(this CountPointer<Marker> mark, MsgPack msg)
|
||||
{
|
||||
if (msg.Element("Marker", out MsgPack Marker))
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["Marker"]).NotNull)
|
||||
{
|
||||
mark.Count = 1;
|
||||
mark.Entries[0].ReadMP(Marker);
|
||||
mark.Entries[0].ReadMP(Temp);
|
||||
}
|
||||
else if (msg.ElementArray("Markers", out MsgPack Markers))
|
||||
else if ((Temp = msg["Markers", true]).NotNull)
|
||||
{
|
||||
mark.Count = Markers.Array.Length;
|
||||
mark.Count = Temp.Array.Length;
|
||||
for (int i = 0; i < mark.Count; i++)
|
||||
mark.Entries[i].ReadMP(Markers[i]);
|
||||
mark.Entries[i].ReadMP(Temp[i]);
|
||||
}
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public static void WritePointerString(this Stream IO,
|
||||
@@ -868,9 +908,10 @@ namespace KKdMainLib.Aet
|
||||
public float Unk;
|
||||
public float Duration;
|
||||
public float FrameRate;
|
||||
public int BackgroundColor;
|
||||
public int Width;
|
||||
public int Height;
|
||||
public int DontChange;
|
||||
public Pointer<Vector2<KeyFrameEntry>> Position;
|
||||
public CountPointer< AetLayer> Layers;
|
||||
public CountPointer<SpriteEntry> SpriteEntries;
|
||||
public CountPointer<int> Unknown;
|
||||
@@ -889,17 +930,19 @@ namespace KKdMainLib.Aet
|
||||
|
||||
public void ReadMP(MsgPack msg)
|
||||
{
|
||||
if (msg.Element("Object", out MsgPack Object))
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["Object"]).NotNull)
|
||||
{
|
||||
Count = 1;
|
||||
Objects[0].ReadMP(Object);
|
||||
Objects[0].ReadMP(Temp);
|
||||
}
|
||||
else if (msg.ElementArray("Objects", out MsgPack Objects))
|
||||
else if ((Temp = msg["Objects", true]).NotNull)
|
||||
{
|
||||
Count = Objects.Array.Length;
|
||||
Count = Temp.Array.Length;
|
||||
for (int i0 = 0; i0 < Count; i0++)
|
||||
this.Objects[i0].ReadMP(Objects[i0]);
|
||||
Objects[i0].ReadMP(Temp[i0]);
|
||||
}
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(int Id, ref AetData Aet)
|
||||
@@ -951,13 +994,13 @@ namespace KKdMainLib.Aet
|
||||
Unk0 = msg.ReadUInt8("Unk0");
|
||||
Unk1 = msg.ReadUInt8("Unk1");
|
||||
Unk2 = msg.ReadUInt8("Unk2");
|
||||
if (msg.Element("Pic", out MsgPack Pic))
|
||||
{ Type = ObjType.Pic; this.Pic.Value.ReadMP(Pic); }
|
||||
else if (msg.Element("Aif", out MsgPack Aif))
|
||||
{ Type = ObjType.Aif; this.Aif.Value.ReadMP(Aif); }
|
||||
else if (msg.Element("Eff", out MsgPack Eff))
|
||||
{ Type = ObjType.Eff; this.Eff.Value.ReadMP(Eff); }
|
||||
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["Pic"]).NotNull) { Type = ObjType.Pic; Pic.Value.ReadMP(Temp); }
|
||||
else if ((Temp = msg["Aif"]).NotNull) { Type = ObjType.Aif; Aif.Value.ReadMP(Temp); }
|
||||
else if ((Temp = msg["Eff"]).NotNull) { Type = ObjType.Eff; Eff.Value.ReadMP(Temp); }
|
||||
else Type = ObjType.Nop;
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(ref AetData Aet, string name = null)
|
||||
@@ -997,18 +1040,20 @@ namespace KKdMainLib.Aet
|
||||
if (ParentObjectID != null)
|
||||
this.ParentObjectID = ParentObjectID.Value;
|
||||
|
||||
if (msg.Element("Marker", out MsgPack Marker))
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["Marker"]).NotNull)
|
||||
{
|
||||
this.Marker.Count = 1;
|
||||
this.Marker.Entries[0].ReadMP(Marker);
|
||||
Marker.Count = 1;
|
||||
Marker.Entries[0].ReadMP(Temp);
|
||||
}
|
||||
else if (msg.ElementArray("Markers", out MsgPack Markers))
|
||||
if ((Temp = msg["Markers", true]).NotNull)
|
||||
{
|
||||
this.Marker.Count = Markers.Array.Length;
|
||||
for (int i = 0; i < Markers.Array.Length; i++)
|
||||
this.Marker.Entries[i].ReadMP(Markers[i]);
|
||||
Marker.Count = Temp.Array.Length;
|
||||
for (int i = 0; i < Marker.Count; i++)
|
||||
Marker.Entries[i].ReadMP(Temp[i]);
|
||||
}
|
||||
else this.Marker.Entries = null;
|
||||
else Marker.Entries = null;
|
||||
Temp.Dispose();
|
||||
|
||||
Data.Value.ReadMP(msg);
|
||||
|
||||
@@ -1081,18 +1126,20 @@ namespace KKdMainLib.Aet
|
||||
if (ParentObjectID != null)
|
||||
this.ParentObjectID = ParentObjectID.Value;
|
||||
|
||||
if (msg.Element("Marker", out MsgPack Marker))
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["Marker"]).NotNull)
|
||||
{
|
||||
this.Marker.Count = 1;
|
||||
this.Marker.Entries[0].ReadMP(Marker);
|
||||
Marker.Count = 1;
|
||||
Marker.Entries[0].ReadMP(Temp);
|
||||
}
|
||||
else if (msg.ElementArray("Markers", out MsgPack Markers))
|
||||
else if ((Temp = msg["Markers", true]).NotNull)
|
||||
{
|
||||
this.Marker.Count = Markers.Array.Length;
|
||||
for (int i = 0; i < Markers.Array.Length; i++)
|
||||
this.Marker.Entries[i].ReadMP(Markers[i]);
|
||||
Marker.Count = Temp.Array.Length;
|
||||
for (int i = 0; i < Marker.Count; i++)
|
||||
Marker.Entries[i].ReadMP(Temp[i]);
|
||||
}
|
||||
else this.Marker.Entries = null;
|
||||
else Marker.Entries = null;
|
||||
Temp.Dispose();
|
||||
|
||||
Data.Value.ReadMP(msg);
|
||||
}
|
||||
@@ -1103,11 +1150,10 @@ namespace KKdMainLib.Aet
|
||||
for (int i = 0; i < Aet.Layers.Count; i++)
|
||||
if (Aet.Layers[i].Pointer == LayerID)
|
||||
{ Eff.Add("LayerID", i); break; }
|
||||
if (ParentObjectID > 0)
|
||||
for (int i = 0; i < Aet.Layers.Count; i++)
|
||||
for (int i1 = 0; i1 < Aet.Layers[i].Count; i1++)
|
||||
if (Aet.Layers[i][i1].Offset == ParentObjectID)
|
||||
{ Eff.Add("ParentObjectID", Aet.Layers[i][i1].ID); break; }
|
||||
for (int i = 0; ParentObjectID > 0 && i < Aet.Layers.Count; i++)
|
||||
for (int i1 = 0; i1 < Aet.Layers[i].Count; i1++)
|
||||
if (Aet.Layers[i][i1].Offset == ParentObjectID)
|
||||
{ Eff.Add("ParentObjectID", Aet.Layers[i][i1].ID); break; }
|
||||
|
||||
if (Marker.Count == 1)
|
||||
Eff.Add(Marker[0].WriteMP("Marker"));
|
||||
@@ -1196,25 +1242,29 @@ namespace KKdMainLib.Aet
|
||||
|
||||
public void ReadMP(MsgPack msg)
|
||||
{
|
||||
if (!msg.Element("AnimationData", out MsgPack Data)) return;
|
||||
MsgPack Data;
|
||||
if ((Data = msg["AnimationData"]).NotNull)
|
||||
{
|
||||
System.Enum.TryParse(Data.ReadString("BlendMode"), out Mode);
|
||||
Unk0 = Data.ReadUInt8 ("Unk0");
|
||||
UseTextureMask = Data.ReadBoolean("UseTextureMask");
|
||||
Unk1 = Data.ReadUInt8 ("Unk1");
|
||||
|
||||
OriginX.ReadMP(Data, "OriginX");
|
||||
OriginY.ReadMP(Data, "OriginY");
|
||||
PositionX.ReadMP(Data, "PositionX");
|
||||
PositionY.ReadMP(Data, "PositionY");
|
||||
Rotation .ReadMP(Data, "Rotation" );
|
||||
ScaleX.ReadMP(Data, "ScaleX");
|
||||
ScaleY.ReadMP(Data, "ScaleY");
|
||||
Opacity .ReadMP(Data, "Opacity" );
|
||||
|
||||
System.Enum.TryParse(Data.ReadString("BlendMode"), out Mode);
|
||||
Unk0 = Data.ReadUInt8 ("Unk0");
|
||||
UseTextureMask = Data.ReadBoolean("UseTextureMask");
|
||||
Unk1 = Data.ReadUInt8 ("Unk1");
|
||||
|
||||
OriginX.ReadMP(Data, "OriginX");
|
||||
OriginY.ReadMP(Data, "OriginY");
|
||||
PositionX.ReadMP(Data, "PositionX");
|
||||
PositionY.ReadMP(Data, "PositionY");
|
||||
Rotation .ReadMP(Data, "Rotation" );
|
||||
ScaleX.ReadMP(Data, "ScaleX");
|
||||
ScaleY.ReadMP(Data, "ScaleY");
|
||||
Opacity .ReadMP(Data, "Opacity" );
|
||||
|
||||
this._3D.Offset = -1;
|
||||
if (Data.Element("3D", out MsgPack _3D))
|
||||
{ this._3D.Offset = 0; this._3D.Value.ReadMP(_3D); }
|
||||
MsgPack Temp;
|
||||
_3D.Offset = -1;
|
||||
if ((Temp = Data["3D"]).NotNull) { _3D.Offset = 0; _3D.Value.ReadMP(Temp); }
|
||||
Temp.Dispose();
|
||||
}
|
||||
Data.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMP()
|
||||
@@ -1231,8 +1281,7 @@ namespace KKdMainLib.Aet
|
||||
AnimationData.Add( ScaleX.WriteMP( "ScaleX"));
|
||||
AnimationData.Add( ScaleY.WriteMP( "ScaleY"));
|
||||
AnimationData.Add(Opacity .WriteMP("Opacity" ));
|
||||
if (_3D.Offset > 0)
|
||||
AnimationData.Add(_3D.Value.WriteMP());
|
||||
if (_3D.Offset > 0) AnimationData.Add(_3D.Value.WriteMP());
|
||||
return AnimationData;
|
||||
}
|
||||
|
||||
@@ -1257,21 +1306,23 @@ namespace KKdMainLib.Aet
|
||||
|
||||
public void ReadMP(MsgPack msg, string name)
|
||||
{
|
||||
MsgPack Temp;
|
||||
float? Value = msg.ReadNSingle(name);
|
||||
if (Value != null) { Count = 1; this.Value = Value.Value; return; }
|
||||
if (!msg.ElementArray(name, out MsgPack Temp)) return;
|
||||
|
||||
Count = Temp.Array.Length;
|
||||
if (Count == 0) return;
|
||||
ArrValue = new float[Count];
|
||||
KeyFrame = new float[Count];
|
||||
Interpolation = new float[Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (Value != null) { Count = 1; this.Value = Value.Value; }
|
||||
if ((Temp = msg[name, true]).NotNull && Temp.Array.Length > 1)
|
||||
{
|
||||
KeyFrame [i] = Temp[i].ReadSingle("KeyFrame" );
|
||||
ArrValue [i] = Temp[i].ReadSingle("Value" );
|
||||
Interpolation[i] = Temp[i].ReadSingle("Interpolation");
|
||||
Count = Temp.Array.Length;
|
||||
ArrValue = new float[Count];
|
||||
KeyFrame = new float[Count];
|
||||
Interpolation = new float[Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
KeyFrame [i] = Temp[i].ReadSingle("KeyFrame" );
|
||||
ArrValue [i] = Temp[i].ReadSingle("Value" );
|
||||
Interpolation[i] = Temp[i].ReadSingle("Interpolation");
|
||||
}
|
||||
}
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(string name)
|
||||
@@ -1301,19 +1352,21 @@ namespace KKdMainLib.Aet
|
||||
Height = msg.ReadInt16 ("Height" );
|
||||
Frames = msg.ReadSingle("Frames" );
|
||||
|
||||
if (msg.Element("Sprite", out MsgPack Sprite))
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["Sprite"]).NotNull)
|
||||
{
|
||||
Sprites.Count = 1;
|
||||
Sprites[0] = new Sprite() { Name = new Pointer<string>()
|
||||
{ Value = Sprite.ReadString("Name") }, ID = Sprite.ReadInt32("ID") };
|
||||
{ Value = Temp.ReadString("Name") }, ID = Temp.ReadInt32("ID") };
|
||||
}
|
||||
else if (msg.ElementArray("Sprites", out MsgPack Sprites))
|
||||
else if ((Temp = msg["Sprites", true]).NotNull)
|
||||
{
|
||||
this.Sprites.Count = Sprites.Array.Length;
|
||||
for (int i0 = 0; i0 < this.Sprites.Count; i0++)
|
||||
this.Sprites[i0] = new Sprite() { Name = new Pointer<string>()
|
||||
{ Value = Sprites[i0].ReadString("Name") }, ID = Sprites[i0].ReadInt32("ID") };
|
||||
Sprites.Count = Temp.Array.Length;
|
||||
for (int i0 = 0; i0 < Sprites.Count; i0++)
|
||||
Sprites[i0] = new Sprite() { Name = new Pointer<string>()
|
||||
{ Value = Temp[i0].ReadString("Name") }, ID = Temp[i0].ReadInt32("ID") };
|
||||
}
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(int Id)
|
||||
|
||||
+11
-7
@@ -192,12 +192,14 @@ namespace KKdMainLib.DB
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
|
||||
|
||||
if (MsgPack.ElementArray("AetDB", out MsgPack AetDB))
|
||||
MsgPack Temp = default;
|
||||
if ((Temp = MsgPack["AetDB", true]).NotNull)
|
||||
{
|
||||
AetSets = new AetSet[AetDB.Array.Length];
|
||||
AetSets = new AetSet[Temp.Array.Length];
|
||||
for (int i = 0; i < AetSets.Length; i++)
|
||||
AetSets[i].ReadMsgPack(AetDB[i]);
|
||||
AetSets[i].ReadMsgPack(Temp[i]);
|
||||
}
|
||||
Temp.Dispose();
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
@@ -246,12 +248,14 @@ namespace KKdMainLib.DB
|
||||
NewId = msg.ReadBoolean("NewId" );
|
||||
SpriteSetId = msg.ReadNUInt16("SpriteSetId");
|
||||
|
||||
if (msg.ElementArray("Aets", out MsgPack Aets))
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["Aets", true]).NotNull)
|
||||
{
|
||||
this.Aets = new AET[Aets.Array.Length];
|
||||
for (int i0 = 0; i0 < this.Aets.Length; i0++)
|
||||
this.Aets[i0].ReadMsgPack(Aets[i0]);
|
||||
Aets = new AET[Temp.Array.Length];
|
||||
for (int i0 = 0; i0 < Aets.Length; i0++)
|
||||
Aets[i0].ReadMsgPack(Temp[i0]);
|
||||
}
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMsgPack()
|
||||
|
||||
@@ -96,16 +96,18 @@ namespace KKdMainLib.DB
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
|
||||
|
||||
if (MsgPack.Element("AuthDB", out MsgPack AuthDB))
|
||||
MsgPack AuthDB;
|
||||
if ((AuthDB = MsgPack["AuthDB"]).NotNull)
|
||||
{
|
||||
if (AuthDB.ElementArray("Category", out MsgPack Temp))
|
||||
MsgPack Temp;
|
||||
if ((Temp = MsgPack["Category", true]).NotNull)
|
||||
{
|
||||
Category = new string[Temp.Array.Length];
|
||||
for (int i = 0; i < Category.Length; i++)
|
||||
Category[i] = Temp[i].ReadString();
|
||||
}
|
||||
|
||||
if (AuthDB.ElementArray("UID", out Temp))
|
||||
if ((Temp = MsgPack["UID", true]).NotNull)
|
||||
{
|
||||
_UID = new UID[Temp.Array.Length];
|
||||
for (int i = 0; i < _UID.Length; i++)
|
||||
@@ -116,7 +118,9 @@ namespace KKdMainLib.DB
|
||||
_UID[i].Value = Temp[i].ReadString("Value" );
|
||||
}
|
||||
}
|
||||
Temp.Dispose();
|
||||
}
|
||||
AuthDB.Dispose();
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
|
||||
+13
-9
@@ -231,12 +231,14 @@ namespace KKdMainLib.DB
|
||||
{
|
||||
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
|
||||
|
||||
if (MsgPack.ElementArray("SprDB", out MsgPack SprDB))
|
||||
MsgPack SprDB;
|
||||
if ((SprDB = MsgPack["SprDB", true]).NotNull)
|
||||
{
|
||||
SpriteSets = new SpriteSet[SprDB.Array.Length];
|
||||
for (int i = 0; i < SpriteSets.Length; i++)
|
||||
SpriteSets[i].ReadMsgPack(SprDB[i]);
|
||||
}
|
||||
SprDB.Dispose();
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
@@ -282,19 +284,21 @@ namespace KKdMainLib.DB
|
||||
Name = msg.ReadString ("Name" );
|
||||
NewId = msg.ReadBoolean("NewId" );
|
||||
|
||||
if (msg.ElementArray( "Sprites", out MsgPack Sprites))
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["Sprites", true]).NotNull)
|
||||
{
|
||||
this.Sprites = new SpriteTexture[Sprites.Array.Length];
|
||||
for (int i0 = 0; i0 < this.Sprites.Length; i0++)
|
||||
this.Sprites[i0].ReadMsgPack(Sprites[i0]);
|
||||
Sprites = new SpriteTexture[Temp.Array.Length];
|
||||
for (int i0 = 0; i0 < Sprites.Length; i0++)
|
||||
Sprites[i0].ReadMsgPack(Temp[i0]);
|
||||
}
|
||||
|
||||
if (msg.ElementArray("Textures", out MsgPack Textures))
|
||||
if ((Temp = msg["Textures", true]).NotNull)
|
||||
{
|
||||
this.Textures = new SpriteTexture[Textures.Array.Length];
|
||||
for (int i0 = 0; i0 < this.Textures.Length; i0++)
|
||||
this.Textures[i0].ReadMsgPack(Textures[i0]);
|
||||
Textures = new SpriteTexture[Temp.Array.Length];
|
||||
for (int i0 = 0; i0 < Textures.Length; i0++)
|
||||
Textures[i0].ReadMsgPack(Temp[i0]);
|
||||
}
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMsgPack()
|
||||
|
||||
+24
-19
@@ -35,7 +35,7 @@ namespace KKdMainLib
|
||||
|
||||
IO.Seek(DEXOffset, 0);
|
||||
for (int i0 = 0; i0 < Dex.Length; i0++)
|
||||
Dex[i0] = new EXP { Main = new List<EXPElement>(), Eyes = new List<EXPElement>() };
|
||||
Dex[i0] = new EXP { Main = KKdList<EXPElement>.New, Eyes = KKdList<EXPElement>.New };
|
||||
|
||||
for (int i0 = 0; i0 < Dex.Length; i0++)
|
||||
{
|
||||
@@ -176,26 +176,31 @@ namespace KKdMainLib
|
||||
Header = new Header();
|
||||
|
||||
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
|
||||
if (!MsgPack.ElementArray("Dex", out MsgPack Dex)) return 0;
|
||||
|
||||
this.Dex = new EXP[Dex.Array.Length];
|
||||
for (i0 = 0; i0 < this.Dex.Length; i0++)
|
||||
MsgPack Dex;
|
||||
if ((Dex = MsgPack["Dex", true]).NotNull)
|
||||
{
|
||||
this.Dex[i0] = new EXP { Name = Dex[i0].ReadString("Name") };
|
||||
this.Dex = new EXP[Dex.Array.Length];
|
||||
for (i0 = 0; i0 < this.Dex.Length; i0++)
|
||||
{
|
||||
this.Dex[i0] = new EXP { Name = Dex[i0].ReadString("Name") };
|
||||
|
||||
if (Dex[i0].ElementArray("Main", out MsgPack Main))
|
||||
{
|
||||
this.Dex[i0].Main = new List<EXPElement>();
|
||||
for (i1 = 0; i1 < Main.Array.Length; 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(EXPElement.Read(Eyes[i1]));
|
||||
MsgPack Temp;
|
||||
if ((Temp = MsgPack["Main", true]).NotNull)
|
||||
{
|
||||
this.Dex[i0].Main = KKdList<EXPElement>.New;
|
||||
for (i1 = 0; i1 < this.Dex[i0].Main.Count; i1++)
|
||||
this.Dex[i0].Main.Add(EXPElement.Read(Temp[i1]));
|
||||
}
|
||||
if ((Temp = MsgPack["Eyes", true]).NotNull)
|
||||
{
|
||||
this.Dex[i0].Eyes = KKdList<EXPElement>.New;
|
||||
for (i1 = 0; i1 < this.Dex[i0].Main.Count; i1++)
|
||||
this.Dex[i0].Eyes.Add(EXPElement.Read(Temp[i1]));
|
||||
}
|
||||
Temp.Dispose();
|
||||
}
|
||||
}
|
||||
Dex.Dispose();
|
||||
MsgPack.Dispose();
|
||||
return 1;
|
||||
}
|
||||
@@ -229,8 +234,8 @@ namespace KKdMainLib
|
||||
public int EyesOffset;
|
||||
public int NameOffset;
|
||||
public string Name;
|
||||
public List<EXPElement> Main;
|
||||
public List<EXPElement> Eyes;
|
||||
public KKdList<EXPElement> Main;
|
||||
public KKdList<EXPElement> Eyes;
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace KKdMainLib
|
||||
Stream IO = File.OpenReader(file);
|
||||
int FileLengthOrigin = IO.Length;
|
||||
int FileLength = FileLengthOrigin.Align(16);
|
||||
byte[] In = IO.ToArray();
|
||||
IO.Close();
|
||||
byte[] In = File.OpenReader(file).ToArray(true);
|
||||
byte[] Inalign = new byte[FileLength];
|
||||
for (int i = 0; i < In.Length; i++) Inalign[i] = In[i];
|
||||
In = null;
|
||||
|
||||
+25
-20
@@ -44,30 +44,28 @@ namespace KKdMainLib
|
||||
else if (file.Contains("PvList")) { pvList = null; Success = true; }
|
||||
}
|
||||
|
||||
public void DBWriter(string file)
|
||||
public void DBWriter(string file, uint num2)
|
||||
{
|
||||
if (!Success) return;
|
||||
|
||||
IO = File.OpenWriter();
|
||||
if (file.Contains("psrData"))
|
||||
{
|
||||
if (psrDat != null || psrDat.Length > 0)
|
||||
if (psrDat != null && psrDat.Length > 0)
|
||||
for (i = 0; i < psrDat.Length; i++)
|
||||
IO.Write(psrDat[i].ToString() + c);
|
||||
}
|
||||
else if (file.Contains("PvList"))
|
||||
{
|
||||
if (pvList != null || pvList.Length > 0)
|
||||
if (pvList != null && pvList.Length > 0)
|
||||
for (i = 0; i < pvList.Length; i++)
|
||||
IO.Write(UrlEncode(pvList[i].ToString() +
|
||||
(i < pvList.Length ? c : "")));
|
||||
else IO.Write("%2A%2A%2A");
|
||||
}
|
||||
else IO.Write("%2A%2A%2A");
|
||||
|
||||
|
||||
byte[] data = IO.ToArray(true);
|
||||
ushort num = DCC.CalculateChecksum(data);
|
||||
uint num2 = (uint)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
File.WriteAllBytes(file + "_" + num + "_" + num2 + ".dat", data);
|
||||
}
|
||||
|
||||
@@ -79,25 +77,29 @@ namespace KKdMainLib
|
||||
|
||||
if (file.Contains("psrData"))
|
||||
{
|
||||
if (MsgPack.ElementArray("psrData", out MsgPack psrData))
|
||||
MsgPack psrData;
|
||||
if ((psrData = MsgPack["psrData", true]).NotNull)
|
||||
{
|
||||
psrDat = new psrData[psrData.Array.Length];
|
||||
for (i = 0; i < psrDat.Length; i++)
|
||||
psrDat[i].SetValue(psrData[i]);
|
||||
}
|
||||
else if (MsgPack.ContainsKey("psrData")) psrDat = null;
|
||||
else if (MsgPack["psrData"].NotNull) psrDat = null;
|
||||
Success = true;
|
||||
psrData.Dispose();
|
||||
}
|
||||
else if (file.Contains("PvList"))
|
||||
{
|
||||
if (MsgPack.ElementArray("PvList", out MsgPack PvList))
|
||||
MsgPack PvList;
|
||||
if ((PvList = MsgPack["PvList", true]).NotNull)
|
||||
{
|
||||
pvList = new PvList[PvList.Array.Length];
|
||||
for (i = 0; i < pvList.Length; i++)
|
||||
pvList[i].SetValue(PvList[i], compact);
|
||||
}
|
||||
else if (MsgPack.ContainsKey("PvList")) pvList = null;
|
||||
else if (MsgPack["PvList"].NotNull) pvList = null;
|
||||
Success = true;
|
||||
PvList.Dispose();
|
||||
}
|
||||
|
||||
MsgPack.Dispose();
|
||||
@@ -156,9 +158,11 @@ namespace KKdMainLib
|
||||
int? ID = msg.ReadNInt32("PV_ID");
|
||||
if (ID != null) PV_ID = (int)ID;
|
||||
else { ID = msg.ReadNInt32("ID"); if (ID != null) PV_ID = (int)ID; }
|
||||
if (msg.Element("P1", out MsgPack P1)) p1.SetValue(P1);
|
||||
if (msg.Element("P2", out MsgPack P2)) p2.SetValue(P2);
|
||||
if (msg.Element("P3", out MsgPack P3)) p3.SetValue(P3);
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["P1", true]).NotNull) p1.SetValue(Temp);
|
||||
if ((Temp = msg["P2", true]).NotNull) p2.SetValue(Temp);
|
||||
if ((Temp = msg["P3", true]).NotNull) p3.SetValue(Temp);
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMP() =>
|
||||
@@ -251,7 +255,6 @@ namespace KKdMainLib
|
||||
|
||||
public void SetValue(MsgPack msg, bool Compact)
|
||||
{
|
||||
MsgPack Temp = MsgPack.New;
|
||||
this.Enable = true;
|
||||
this.Extra = false;
|
||||
|
||||
@@ -270,10 +273,12 @@ namespace KKdMainLib
|
||||
EndShow .SetValue(msg.ReadNInt32( "EndShow" ), true);
|
||||
return;
|
||||
}
|
||||
if (msg.Element("AdvDemoStart", out Temp)) AdvDemoStart.SetValue(Temp, true);
|
||||
if (msg.Element("AdvDemoEnd" , out Temp)) AdvDemoEnd .SetValue(Temp, false);
|
||||
if (msg.Element("StartShow" , out Temp)) StartShow .SetValue(Temp, false);
|
||||
if (msg.Element( "EndShow" , out Temp)) EndShow .SetValue(Temp, true);
|
||||
MsgPack Temp;
|
||||
if ((Temp = msg["AdvDemoStart", true]).NotNull) AdvDemoStart.SetValue(Temp, true);
|
||||
if ((Temp = msg["AdvDemoEnd" , true]).NotNull) AdvDemoEnd .SetValue(Temp, false);
|
||||
if ((Temp = msg["StartShow" , true]).NotNull) StartShow .SetValue(Temp, false);
|
||||
if ((Temp = msg[ "EndShow" , true]).NotNull) EndShow .SetValue(Temp, true);
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(bool Compact)
|
||||
@@ -284,14 +289,14 @@ namespace KKdMainLib
|
||||
if ( Extra ) MsgPack.Add("Extra" , Extra );
|
||||
if (Compact)
|
||||
{
|
||||
if (AdvDemoStart.WriteLower) MsgPack.Add("AdvDemoStart", AdvDemoStart.WriteInt());
|
||||
if (AdvDemoStart.WriteUpper) 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 (AdvDemoStart.WriteUpper) 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" ));
|
||||
|
||||
+110
-73
@@ -17,13 +17,12 @@ namespace KKdMainLib
|
||||
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();
|
||||
DataSize = stream.ReadInt32(), Length = stream.ReadInt32(), Flags = stream.ReadInt32(),
|
||||
Depth = stream.ReadInt32(), SectionSize = stream.ReadInt32(),
|
||||
Mode = stream.ReadInt32() };
|
||||
stream.ReadInt32();
|
||||
if ((Header.Flags & 0x08000000) == 0x08000000) Header.Format = Format.F2BE;
|
||||
Header.NotUseDataSizeAsSectionSize = (Header.Flags & 0x10000000) != 0x10000000;
|
||||
if (Header.Length == 0x40)
|
||||
{
|
||||
stream.ReadInt64();
|
||||
@@ -39,18 +38,22 @@ namespace KKdMainLib
|
||||
|
||||
public static void Write(this Stream stream, Header Header, bool Extended = false)
|
||||
{
|
||||
Header.Length = (Header.Format < Format.X && Extended) ? 0x40 : 0x20;
|
||||
Header.Flags = (!Header.NotUseDataSizeAsSectionSize ? 0x10000000 : 0) |
|
||||
(Header.Format == Format.F2BE ? 0x08000000 : 0);
|
||||
|
||||
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.Length);
|
||||
stream.Write(Header.Flags);
|
||||
stream.Write(Header.Depth);
|
||||
stream.Write(Header.SectionSize);
|
||||
stream.Write(Header.SubID);
|
||||
stream.Write(Header.Mode);
|
||||
stream.Write(0x00);
|
||||
if (Header.Format < Format.X && Extended)
|
||||
if (Header.Length == 0x40)
|
||||
{
|
||||
stream.Write(Header.Format < Format.MGF ? (int)((Header.SectionSignature ^
|
||||
(Header.DataSize * (long)Header.Signature)) - Header.ID + Header.SectionSize) : 0);
|
||||
(Header.DataSize * (long)Header.Signature)) - Header.Depth + Header.SectionSize) : 0);
|
||||
stream.Write(0x00);
|
||||
stream.Write(0x00L);
|
||||
stream.Write(Header.InnerSignature);
|
||||
@@ -60,30 +63,43 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
public static void WriteEOFC(this Stream stream, int ID = 0) =>
|
||||
stream.Write(new Header { ID = ID, Length = 0x20, Signature = 0x43464F45 });
|
||||
stream.Write(new Header { Depth = ID, Length = 0x20, Signature = 0x43464F45 });
|
||||
}
|
||||
|
||||
public static class POFExtensions
|
||||
{
|
||||
public static void Write(this Stream stream, ref KKdList<long> Offsets, int ID, bool ShiftX)
|
||||
public static void Write(this Stream stream, POF POF, bool ShiftX = false)
|
||||
{
|
||||
byte[] data = POF.Write(Offsets, ShiftX);
|
||||
Header Header = new Header { ID = ID, Format = Format.F2LE,
|
||||
byte[] data = POF.Write(POF, ShiftX);
|
||||
Header Header = new Header { Depth = POF.Depth, 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 ENRSExtensions
|
||||
{
|
||||
public static void Write(this Stream stream, ENRSList ENRS)
|
||||
{
|
||||
byte[] data = ENRSList.Write(ENRS);
|
||||
Header Header = new Header { Depth = ENRS.Depth,
|
||||
Format = Format.F2LE, Length = 0x20, Signature = 0x53524E45 };
|
||||
Header.DataSize = Header.SectionSize = data.Length;
|
||||
stream.Write(Header);
|
||||
stream.Write(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static class StructExtensions
|
||||
{
|
||||
public static Struct ReadStruct(byte[] Data)
|
||||
public static Struct ReadStruct(this byte[] Data)
|
||||
{
|
||||
Stream stream = File.OpenReader(Data);
|
||||
Struct Struct = stream.ReadStruct(stream.ReadHeader(false));
|
||||
stream.Close();
|
||||
if (Data == null || Data.Length < 1) return default;
|
||||
Struct Struct;
|
||||
using (Stream stream = File.OpenReader(Data))
|
||||
Struct = stream.ReadStruct(stream.ReadHeader(false));
|
||||
return Struct;
|
||||
}
|
||||
|
||||
@@ -91,41 +107,55 @@ namespace KKdMainLib
|
||||
{
|
||||
Struct Struct = new Struct { Header = Header, DataOffset =
|
||||
stream.Position, Data = stream.ReadBytes(Header.SectionSize) };
|
||||
int ID = Header.ID;
|
||||
int Depth = Header.Depth;
|
||||
|
||||
KKdList<Struct> SubStructs = KKdList<Struct>.New;
|
||||
int LastSig = 0, Sig;
|
||||
long Length = stream.Length - stream.Position;
|
||||
long Position = 0;
|
||||
KKdList<Struct> SubStructs = KKdList<Struct>.New;
|
||||
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")
|
||||
Sig = Header.Signature;
|
||||
Position += Header.Length + Header.SectionSize;
|
||||
if (Sig == 0x43464F45 && Header.Depth == Depth + 1) break;
|
||||
else if (Header.Depth == 0 && (Sig == 0x53524E45 ||
|
||||
(Sig & 0xF0FFFFFF) == 0x30464F50 || Sig == 0x43505854))
|
||||
{
|
||||
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--;
|
||||
byte[] Data = stream.ReadBytes(Header.SectionSize);
|
||||
if (Sig == 0x53524E45) Struct.ENRS = ENRSList.Read(Data, Header.Depth);
|
||||
else Struct.POF = POF .Read(Data, Sig == 0x31464F50, Header.Depth);
|
||||
}
|
||||
else if (Header.Depth <= Depth) { stream.LongPosition -= Header.Length; break; }
|
||||
else SubStructs.Add(stream.ReadStruct(Header));
|
||||
LastSig = Sig;
|
||||
}
|
||||
|
||||
if (SubStructs.Capacity > 0) Struct.SubStructs = SubStructs.ToArray();
|
||||
return Struct;
|
||||
}
|
||||
|
||||
public static byte[] Write(this Struct Struct, bool ShiftX = false)
|
||||
{
|
||||
byte[] Data;
|
||||
using (Stream stream = File.OpenWriter()) { Struct.Update(ShiftX);
|
||||
stream.Write(Struct, ShiftX); stream.WriteEOFC(); Data = stream.ToArray(); }
|
||||
return Data;
|
||||
}
|
||||
|
||||
public static void Write(this Stream stream, Struct Struct, bool ShiftX = false)
|
||||
{
|
||||
stream.Write(Struct.Header);
|
||||
stream.Write(Struct.Data );
|
||||
if (Struct.HasPOF ) stream.Write(Struct.POF , ShiftX);
|
||||
if (Struct.HasENRS) stream.Write(Struct.ENRS);
|
||||
if (Struct.HasSubStructs)
|
||||
{
|
||||
for (int i = 0; i < Struct.SubStructs.Length; i++)
|
||||
stream.Write(Struct.SubStructs[i], ShiftX);
|
||||
stream.WriteEOFC(Struct.Depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MPExt
|
||||
@@ -133,36 +163,24 @@ namespace KKdMainLib
|
||||
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(); }
|
||||
if (JSON) using (JSON IO = new JSON(File.OpenReader(array))) MsgPack = IO.Read( );
|
||||
else using ( MP IO = new MP(File.OpenReader(array))) MsgPack = IO.Read(true);
|
||||
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(); }
|
||||
if (JSON) using (JSON IO = new JSON(File.OpenReader(file + ".json", true))) MsgPack = IO.Read( );
|
||||
else using ( MP IO = new MP(File.OpenReader(file + ".mp" , true))) MsgPack = IO.Read(true);
|
||||
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(); }
|
||||
if (JSON) using (JSON IO = new JSON(File.OpenReader(file + ".json"))) MsgPack = IO.Read( );
|
||||
else using ( MP IO = new MP(File.OpenReader(file + ".mp" ))) MsgPack = IO.Read(true);
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
@@ -172,12 +190,8 @@ namespace KKdMainLib
|
||||
|
||||
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(); }
|
||||
if (JSON) using (JSON IO = new JSON(File.OpenWriter(file + ".json", true))) IO.Write(mp, "\n", " ");
|
||||
else using ( MP IO = new MP(File.OpenWriter(file + ".json", true))) IO.Write(mp);
|
||||
return mp;
|
||||
}
|
||||
|
||||
@@ -188,12 +202,8 @@ namespace KKdMainLib
|
||||
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); }
|
||||
if (JSON) using (JSON IO = new JSON(File.OpenWriter())) { IO.Write(mp, true); data = IO.ToArray(); }
|
||||
else using ( MP IO = new MP(File.OpenWriter())) { IO.Write(mp ); data = IO.ToArray(); }
|
||||
File.WriteAllBytes(file + (JSON ? ".json" : ".mp"), data);
|
||||
return mp;
|
||||
}
|
||||
@@ -204,4 +214,31 @@ namespace KKdMainLib
|
||||
public static void ToMsgPack(this string file) =>
|
||||
file.ReadMP(true).Write(file ).Dispose();
|
||||
}
|
||||
|
||||
public static class IKFExt
|
||||
{
|
||||
public static IKF<float, float> Round(this IKF<float, float> KF, int d)
|
||||
{
|
||||
if (KF is KFT0<float, float> KFT0) { KFT0.F = KFT0.F.Round(d); return KFT0; }
|
||||
else if (KF is KFT1<float, float> KFT1) { KFT1.F = KFT1.F.Round(d);
|
||||
KFT1.V = KFT1.V.Round(d); return KFT1; }
|
||||
else if (KF is KFT2<float, float> KFT2) { KFT2.F = KFT2.F.Round(d);
|
||||
KFT2.V = KFT2.V.Round(d); KFT2.T = KFT2.T .Round(d); return KFT2; }
|
||||
else if (KF is KFT3<float, float> KFT3) { KFT3.F = KFT3.F.Round(d);
|
||||
KFT3.V = KFT3.V.Round(d); KFT3.T1 = KFT3.T1.Round(d); KFT3.T2 = KFT3.T2.Round(d); return KFT3; }
|
||||
return KF;
|
||||
}
|
||||
|
||||
public static IKF<double, double> Round(this IKF<double, double> KF, int d)
|
||||
{
|
||||
if (KF is KFT0<double, double> KFT0) { KFT0.F = KFT0.F.Round(d); return KFT0; }
|
||||
else if (KF is KFT1<double, double> KFT1) { KFT1.F = KFT1.F.Round(d);
|
||||
KFT1.V = KFT1.V.Round(d); return KFT1; }
|
||||
else if (KF is KFT2<double, double> KFT2) { KFT2.F = KFT2.F.Round(d);
|
||||
KFT2.V = KFT2.V.Round(d); KFT2.T = KFT2.T .Round(d); return KFT2; }
|
||||
else if (KF is KFT3<double, double> KFT3) { KFT3.F = KFT3.F.Round(d);
|
||||
KFT3.V = KFT3.V.Round(d); KFT3.T1 = KFT3.T1.Round(d); KFT3.T2 = KFT3.T2.Round(d); return KFT3; }
|
||||
return KF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@ namespace KKdMainLib.F2
|
||||
if (BLTs.Count < 1) { IO.Close(); BLTs.Count = -1; return; }
|
||||
|
||||
if (BLTs.Count > 0 && BLTs.Offset == 0) { IO.Close(); BLTs.Count = -1; return; }
|
||||
/*{
|
||||
IO.Format = Header.Format = Format.X;
|
||||
IO.Offset = Header.Length;
|
||||
IO.Position = BLTs.Offset;
|
||||
BLTs = IO.ReadCountPointerX<BLT>();
|
||||
}*/
|
||||
|
||||
IO.Position = BLTs.Offset;
|
||||
for (i = 0; i < BLTs.Count; i++)
|
||||
|
||||
@@ -23,6 +23,12 @@ namespace KKdMainLib.F2
|
||||
if (CCTs.Count < 1) { IO.Close(); CCTs.Count = -1; return; }
|
||||
|
||||
if (CCTs.Count > 0 && CCTs.Offset == 0) { IO.Close(); CCTs.Count = -1; return; }
|
||||
/*{
|
||||
IO.Format = Header.Format = Format.X;
|
||||
IO.Offset = Header.Length;
|
||||
IO.Position = CCTs.Offset;
|
||||
CCTs = IO.ReadCountPointerX<CCT>();
|
||||
}*/
|
||||
|
||||
IO.Position = CCTs.Offset;
|
||||
for (i = 0; i < CCTs.Count; i++)
|
||||
|
||||
@@ -23,6 +23,12 @@ namespace KKdMainLib.F2
|
||||
if (DFTs.Count < 1) { IO.Close(); DFTs.Count = -1; return; }
|
||||
|
||||
if (DFTs.Count > 0 && DFTs.Offset == 0) { IO.Close(); DFTs.Count = -1; return; }
|
||||
/*{
|
||||
IO.Format = Header.Format = Format.X;
|
||||
IO.Offset = Header.Length;
|
||||
IO.Position = DFTs.Offset;
|
||||
DFTs = IO.ReadCountPointerX<DFT>();
|
||||
}*/
|
||||
|
||||
IO.Position = DFTs.Offset;
|
||||
for (i = 0; i < DFTs.Count; i++)
|
||||
|
||||
@@ -27,6 +27,13 @@ namespace KKdMainLib.F2
|
||||
{
|
||||
LITs[i] = IO.ReadCountPointerX<LIT>();
|
||||
if ((LITs[i].Count > 0 || LITs[i].Offset == 0) && !IO.IsX) { IO.Close(); LITs.Count = -1; return; }
|
||||
/*{
|
||||
IO.Format = Header.Format = Format.X;
|
||||
IO.Offset = Header.Length;
|
||||
IO.Position = LITs.Offset;
|
||||
LITs[i] = IO.ReadCountPointerX<LIT>();
|
||||
}
|
||||
if (IO.IsX) IO.ReadInt64();*/
|
||||
}
|
||||
|
||||
for (i = 0; i < LITs.Count; i++)
|
||||
|
||||
+34
-32
@@ -8,7 +8,7 @@ using MSIO = System.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public class FARC
|
||||
public class FARC : System.IDisposable
|
||||
{
|
||||
public FARC() => NewFARC();
|
||||
public FARC(string File, bool IsDirectory = false)
|
||||
@@ -29,13 +29,10 @@ namespace KKdMainLib
|
||||
private readonly byte[] KeyFT = { 0x13, 0x72, 0xD5, 0x7B, 0x6E, 0x9E,
|
||||
0x31, 0xEB, 0xA2, 0x39, 0xB8, 0x3C, 0x15, 0x57, 0xC6, 0xBB };
|
||||
|
||||
AesManaged GetAes(bool isFT, byte[] iv)
|
||||
{
|
||||
AesManaged AesManaged = new AesManaged { KeySize = 128, Key = isFT ? KeyFT : Key,
|
||||
AesManaged GetAes(bool isFT, byte[] iv) =>
|
||||
new AesManaged { KeySize = 128, Key = isFT ? KeyFT : Key,
|
||||
BlockSize = 128, Mode = isFT ? CipherMode.CBC : CipherMode.ECB,
|
||||
Padding = PaddingMode.Zeros, IV = iv ?? new byte[16] };
|
||||
return AesManaged;
|
||||
}
|
||||
|
||||
public void UnPack(bool SaveToDisk = true)
|
||||
{ if (HeaderReader()) { FileReader(); if (SaveToDisk) this.SaveToDisk(); } }
|
||||
@@ -68,8 +65,9 @@ namespace KKdMainLib
|
||||
MSIO.FileStream stream = new MSIO.FileStream(FilePath, MSIO.FileMode.Open,
|
||||
MSIO.FileAccess.ReadWrite, MSIO.FileShare.ReadWrite) { Position = 0x10 };
|
||||
|
||||
using (AesManaged aes = GetAes(true, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
GetAes(true, null).CreateDecryptor(), CryptoStreamMode.Read))
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(Header, 0x00, HeaderLength - 0x08);
|
||||
Header = SkipData(Header, 0x10);
|
||||
reader = File.OpenReader(Header);
|
||||
@@ -127,8 +125,8 @@ namespace KKdMainLib
|
||||
if (Signature == Farc.FArC)
|
||||
using (MSIO.MemoryStream memorystream = new MSIO.MemoryStream(
|
||||
File.ReadAllBytes(FilePath, Files[i].SizeComp, Files[i].Offset)))
|
||||
using (GZipStream gZipStream = new GZipStream(memorystream, CompressionMode.Decompress))
|
||||
{
|
||||
GZipStream gZipStream = new GZipStream(memorystream, CompressionMode.Decompress);
|
||||
Files[i].Data = new byte[Files[i].SizeUnc];
|
||||
gZipStream.Read(Files[i].Data, 0, Files[i].SizeUnc);
|
||||
}
|
||||
@@ -148,14 +146,16 @@ namespace KKdMainLib
|
||||
{
|
||||
if ((FT && Files[i].Type.HasFlag(Type.ECB)) || CBC)
|
||||
{
|
||||
using (AesManaged aes = GetAes(true, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
GetAes(true, null).CreateDecryptor(), CryptoStreamMode.Read))
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(Files[i].Data, 0, FileSize);
|
||||
Files[i].Data = SkipData(Files[i].Data, 0x10);
|
||||
}
|
||||
else
|
||||
using (AesManaged aes = GetAes(false, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
GetAes(false, null).CreateDecryptor(), CryptoStreamMode.Read))
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(Files[i].Data, 0, FileSize);
|
||||
Encrypted = true;
|
||||
}
|
||||
@@ -164,14 +164,12 @@ namespace KKdMainLib
|
||||
if (((FT && Files[i].Type.HasFlag(Type.GZip)) ||
|
||||
FARCType.HasFlag(Type.GZip)) && Files[i].SizeUnc > 0)
|
||||
{
|
||||
GZipStream gZipStream;
|
||||
if (Encrypted) { gZipStream = new GZipStream(new MSIO.MemoryStream(Files[i].Data),
|
||||
CompressionMode.Decompress); stream.Close(); }
|
||||
else gZipStream = new GZipStream(stream, CompressionMode.Decompress);
|
||||
GZipStream gZipStream = new GZipStream(Encrypted ? new MSIO.MemoryStream(Files[i].Data) :
|
||||
(MSIO.Stream)stream, CompressionMode.Decompress);
|
||||
byte[] Temp = new byte[Files[i].SizeUnc];
|
||||
gZipStream.Read(Temp, 0, Files[i].SizeUnc);
|
||||
Files[i].Data = Temp;
|
||||
|
||||
gZipStream.Dispose();
|
||||
Compressed = true;
|
||||
}
|
||||
|
||||
@@ -179,8 +177,8 @@ namespace KKdMainLib
|
||||
{
|
||||
Files[i].Data = new byte[Files[i].SizeUnc];
|
||||
stream.Read(Files[i].Data, 0, Files[i].SizeUnc);
|
||||
stream.Close();
|
||||
}
|
||||
stream.Dispose();
|
||||
return Files[i].Data;
|
||||
}
|
||||
|
||||
@@ -221,29 +219,30 @@ namespace KKdMainLib
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
{
|
||||
string ext = Path.GetExtension(Files[i].Name).ToLower();
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".drs" || ext == ".dve" || ext == ".vag")
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".vag")
|
||||
{ Signature = Farc.FArc; break; }
|
||||
}
|
||||
|
||||
Stream writer = File.OpenWriter(DirectoryPath + ".farc", true);
|
||||
writer.WriteEndian((int)Signature, true);
|
||||
|
||||
Stream HeaderWriter = File.OpenWriter();
|
||||
if (Signature == Farc.FArc) HeaderWriter.WriteEndian(0x20, true);
|
||||
else if (Signature == Farc.FArC) HeaderWriter.WriteEndian(0x10, true);
|
||||
else if (Signature == Farc.FARC)
|
||||
using (Stream HeaderWriter = File.OpenWriter())
|
||||
{
|
||||
HeaderWriter.WriteEndian((int)FARCType, true);
|
||||
HeaderWriter.Write (0x00);
|
||||
HeaderWriter.WriteEndian(0x40, true);
|
||||
HeaderWriter.Write (0x00);
|
||||
if (Signature == Farc.FArc) HeaderWriter.WriteEndian(0x20, true);
|
||||
else if (Signature == Farc.FArC) HeaderWriter.WriteEndian(0x10, true);
|
||||
else if (Signature == Farc.FARC)
|
||||
{
|
||||
HeaderWriter.WriteEndian((int)FARCType, true);
|
||||
HeaderWriter.Write (0x00);
|
||||
HeaderWriter.WriteEndian(0x40, true);
|
||||
HeaderWriter.Write (0x00);
|
||||
}
|
||||
int HeaderPartLength = Signature == Farc.FArc ? 0x09 : 0x0D;
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
HeaderWriter.Length += Path.GetFileName(Files[i].Name).Length + HeaderPartLength;
|
||||
writer.WriteEndian(HeaderWriter.Length, true);
|
||||
writer.Write(HeaderWriter.ToArray(true));
|
||||
}
|
||||
int HeaderPartLength = Signature == Farc.FArc ? 0x09 : 0x0D;
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
HeaderWriter.Length += Path.GetFileName(Files[i].Name).Length + HeaderPartLength;
|
||||
writer.WriteEndian(HeaderWriter.Length, true);
|
||||
writer.Write(HeaderWriter.ToArray(true));
|
||||
HeaderWriter = null;
|
||||
|
||||
int Align = writer.Position.Align(0x10) - writer.Position;
|
||||
for (int i1 = 0; i1 < Align; i1++)
|
||||
@@ -305,12 +304,15 @@ namespace KKdMainLib
|
||||
private byte[] Encrypt(byte[] Data, bool isFT)
|
||||
{
|
||||
MSIO.MemoryStream stream = new MSIO.MemoryStream();
|
||||
using (AesManaged aes = GetAes(isFT, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
GetAes(isFT, null).CreateEncryptor(), CryptoStreamMode.Write))
|
||||
aes.CreateEncryptor(), CryptoStreamMode.Write))
|
||||
cryptoStream.Write(Data, 0, Data.Length);
|
||||
return stream.ToArray();
|
||||
}
|
||||
|
||||
public void Dispose() => NewFARC();
|
||||
|
||||
public struct FARCFile
|
||||
{
|
||||
public int Offset;
|
||||
|
||||
+35
-34
@@ -1,4 +1,5 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
@@ -20,11 +21,11 @@ namespace KKdMainLib.IO
|
||||
return s.ToArray();
|
||||
}
|
||||
|
||||
public static byte PeekByte(this Stream stream)
|
||||
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)
|
||||
public static char PeekCharUTF8 (this Stream stream)
|
||||
{ long LongPosition = stream.LongPosition; char val = stream.ReadCharUTF8();
|
||||
stream.LongPosition = LongPosition; return val; }
|
||||
|
||||
@@ -68,12 +69,12 @@ namespace KKdMainLib.IO
|
||||
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)
|
||||
public static void WriteX(this Stream stream, long val, ref POF 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)
|
||||
else stream.WriteEndian((int)val); POF.Offsets.Add(stream.Position); }
|
||||
public static void WriteX(this Stream stream, long val, ref POF POF, bool IsBE)
|
||||
{ if (stream.IsX) stream.Write ( val );
|
||||
else stream.WriteEndian((int)val, IsBE); POF.Add(stream.Position); }
|
||||
else stream.WriteEndian((int)val, IsBE); POF.Offsets.Add(stream.Position); }
|
||||
|
||||
public static void WriteX(this Stream stream, long val)
|
||||
{ if (stream.IsX) stream.Write ( val);
|
||||
@@ -106,44 +107,44 @@ namespace KKdMainLib.IO
|
||||
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 Pointer<string> ReadPointerStringShiftJIS(this Stream stream)
|
||||
{ Pointer<string> val = stream.ReadPointer<string>();
|
||||
val.Value = stream.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 string ReadStringShiftJISAtOffset(this Stream stream, long Offset = 0, long Length = 0) =>
|
||||
Text.ShiftJIS.GetString(stream.ReadAtOffset(Offset, Length));
|
||||
|
||||
public static void WriteShiftJIS(this Stream IO, string String) =>
|
||||
IO.Write(Text.ShiftJIS.GetBytes(String));
|
||||
public static void WriteShiftJIS(this Stream stream, string String) =>
|
||||
stream.Write(Text.ShiftJIS.GetBytes(String));
|
||||
|
||||
public static Pointer<T> ReadPointer<T>(this Stream IO) =>
|
||||
new Pointer<T> { Offset = IO.ReadInt32() };
|
||||
public static Pointer<T> ReadPointer<T>(this Stream stream) =>
|
||||
new Pointer<T> { Offset = stream.ReadInt32() };
|
||||
|
||||
public static Pointer<string> ReadPointerString(this Stream IO)
|
||||
{ Pointer<string> val = IO.ReadPointer<string>();
|
||||
val.Value = IO.ReadStringAtOffset(val.Offset); return val; }
|
||||
public static Pointer<string> ReadPointerString(this Stream stream)
|
||||
{ Pointer<string> val = stream.ReadPointer<string>();
|
||||
val.Value = stream.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 CountPointer<T> ReadCountPointer<T>(this Stream stream) =>
|
||||
new CountPointer<T> { Count = stream.ReadInt32(), Offset = stream.ReadInt32() };
|
||||
|
||||
public static Pointer<T> ReadPointerEndian<T>(this Stream IO) =>
|
||||
new Pointer<T> { Offset = IO.ReadInt32Endian() };
|
||||
public static Pointer<T> ReadPointerEndian<T>(this Stream stream) =>
|
||||
new Pointer<T> { Offset = stream.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 Pointer<string> ReadPointerStringEndian(this Stream stream)
|
||||
{ Pointer<string> val = stream.ReadPointerEndian<string>();
|
||||
val.Value = stream.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 CountPointer<T> ReadCountPointerEndian<T>(this Stream stream) =>
|
||||
new CountPointer<T> { Count = stream.ReadInt32Endian(), Offset = stream.ReadInt32Endian() };
|
||||
|
||||
public static Pointer<T> ReadPointerX<T>(this Stream IO) =>
|
||||
new Pointer<T> { Offset = (int)IO.ReadIntX() };
|
||||
public static Pointer<T> ReadPointerX<T>(this Stream stream) =>
|
||||
new Pointer<T> { Offset = (int)stream.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 Pointer<string> ReadPointerStringX(this Stream stream)
|
||||
{ Pointer<string> val = stream.ReadPointerX<string>();
|
||||
val.Value = stream.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() };
|
||||
public static CountPointer<T> ReadCountPointerX<T>(this Stream stream) =>
|
||||
new CountPointer<T> { Count = (int)stream.ReadIntX(), Offset = (int)stream.ReadIntX() };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace KKdMainLib.IO
|
||||
public static Stream OpenWriter( ) => new Stream(new MSIO.MemoryStream( ));
|
||||
|
||||
public static Stream OpenReader(string file, bool ReadAllAtOnce)
|
||||
{ Stream IO = OpenReader(file); if (ReadAllAtOnce) return OpenReader(IO.ToArray(true)); return IO; }
|
||||
{ Stream IO = OpenReader(file); if (ReadAllAtOnce) { byte[] data =
|
||||
IO.ToArray(); IO.Close(); return OpenReader(data); } return IO; }
|
||||
public static Stream OpenReader(string file)
|
||||
{ Stream IO = new Stream(new MSIO.FileStream(file, MSIO.FileMode.Open, MSIO.FileAccess.ReadWrite,
|
||||
MSIO.FileShare.ReadWrite)) { File = file }; return IO; }
|
||||
|
||||
@@ -5,7 +5,7 @@ using BaseExtensions = KKdBaseLib.Extensions;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public struct JSON
|
||||
public struct JSON : System.IDisposable
|
||||
{
|
||||
public JSON(Stream IO) => _IO = IO;
|
||||
|
||||
@@ -235,6 +235,8 @@ namespace KKdMainLib.IO
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Dispose() => _IO.Close();
|
||||
|
||||
private void Write(string val) => _IO.Write("\"" + val
|
||||
.Replace("\\", "\\\\").Replace("/" , "\\/").Replace("\"", "\\\"")
|
||||
.Replace("\0", "\\0" ).Replace("\b", "\\b").Replace("\f", "\\f" )
|
||||
|
||||
+5
-4
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public struct MP
|
||||
public struct MP : System.IDisposable
|
||||
{
|
||||
public MP(Stream IO) => _IO = IO;
|
||||
|
||||
@@ -112,7 +111,7 @@ namespace KKdMainLib.IO
|
||||
return _IO.ReadString(Val - Types.FixStr);
|
||||
else if (Val >= Types. Str8 && Val <= Types. Str32 )
|
||||
{
|
||||
Enum.TryParse(Val.ToString(), out Types Type);
|
||||
System.Enum.TryParse(Val.ToString(), out Types Type);
|
||||
int Length = 0;
|
||||
if (Type == Types.Str8 ) Length = _IO.ReadByte();
|
||||
else if (Type == Types.Str16) Length = _IO.ReadInt16Endian(true);
|
||||
@@ -296,6 +295,8 @@ namespace KKdMainLib.IO
|
||||
_IO.Write(val.Type);
|
||||
_IO.Write(val.Data);
|
||||
}
|
||||
|
||||
public void Dispose() => _IO.Close();
|
||||
}
|
||||
|
||||
public enum Types : byte
|
||||
|
||||
+112
-176
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using KKdBaseLib;
|
||||
using MSIO = System.IO;
|
||||
|
||||
@@ -7,8 +8,9 @@ namespace KKdMainLib.IO
|
||||
public unsafe class Stream : IDisposable
|
||||
{
|
||||
private MSIO.Stream stream;
|
||||
private int I, i, i0, BitRead, BitWrite, TempBitRead, TempBitWrite, ValRead, ValWrite;
|
||||
private int I, i, BitRead, BitWrite, TempBitRead, TempBitWrite, ValRead, ValWrite;
|
||||
private byte[] buf;
|
||||
private byte* ptr;
|
||||
|
||||
private Format _format = Format.NULL;
|
||||
|
||||
@@ -54,7 +56,8 @@ namespace KKdMainLib.IO
|
||||
ValRead = ValRead = BitWrite = 0;
|
||||
stream = output;
|
||||
Format = Format.NULL;
|
||||
buf = new byte[128];
|
||||
buf = new byte[0x100];
|
||||
ptr = buf.GetPtr();
|
||||
IsBE = isBE;
|
||||
}
|
||||
|
||||
@@ -70,11 +73,10 @@ namespace KKdMainLib.IO
|
||||
public long? Seek(long? offset, SeekOrigin origin)
|
||||
{ if (offset == null) return null; return stream.Seek((long)offset, (MSIO.SeekOrigin)(int)origin); }
|
||||
|
||||
public void Dispose()
|
||||
{ CheckWrited(); Dispose(true); }
|
||||
public void Dispose() => Dispose(true);
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{ if (disposing && stream != MSIO.Stream.Null) stream.Flush(); stream.Dispose(); }
|
||||
protected virtual void Dispose(bool dispose)
|
||||
{ CW(); if (stream != MSIO.Stream.Null) { stream.Flush(); stream.Dispose(); } if (dispose) GC.SuppressFinalize(this); }
|
||||
|
||||
public MSIO.Stream BaseStream
|
||||
{ get { stream.Flush(); return stream; } set { stream = value; } }
|
||||
@@ -102,67 +104,64 @@ namespace KKdMainLib.IO
|
||||
if (SetLength1) stream.SetLength(Position + Offset);
|
||||
}
|
||||
|
||||
public bool ReadBoolean() => stream.ReadByte() == 1;
|
||||
public bool ReadBoolean() => stream.ReadByte() != 0;
|
||||
public sbyte ReadSByte() => ( sbyte)stream.ReadByte();
|
||||
public byte ReadByte() => ( byte)stream.ReadByte();
|
||||
public sbyte ReadInt8() => ( sbyte) IntFromArray(1);
|
||||
public byte ReadUInt8() => ( byte)UIntFromArray(1);
|
||||
public short ReadInt16() => ( short) IntFromArray(2);
|
||||
public ushort ReadUInt16() => (ushort)UIntFromArray(2);
|
||||
public int ReadInt24() => ( int) IntFromArray(3);
|
||||
public int ReadInt32() => ( int) IntFromArray(4);
|
||||
public uint ReadUInt32() => ( uint)UIntFromArray(4);
|
||||
public long ReadInt64() => IntFromArray(8);
|
||||
public ulong ReadUInt64() => UIntFromArray(8);
|
||||
public Half ReadHalf() { ushort a = ReadUInt16(); return ( Half ) a; }
|
||||
public float ReadSingle() { uint a = ReadUInt32(); return *( float*)&a; }
|
||||
public double ReadDouble() { ulong a = ReadUInt64(); return *(double*)&a; }
|
||||
public sbyte ReadInt8() => ( sbyte)stream.ReadByte();
|
||||
public byte ReadUInt8() => ( byte)stream.ReadByte();
|
||||
public short ReadInt16() { CR(); stream.Read(buf, 0, 2); return *( short*)ptr; }
|
||||
public ushort ReadUInt16() { CR(); stream.Read(buf, 0, 2); return *(ushort*)ptr; }
|
||||
public int ReadInt32() { CR(); stream.Read(buf, 0, 4); return *( int*)ptr; }
|
||||
public uint ReadUInt32() { CR(); stream.Read(buf, 0, 4); return *( uint*)ptr; }
|
||||
public long ReadInt64() { CR(); stream.Read(buf, 0, 8); return *( long*)ptr; }
|
||||
public ulong ReadUInt64() { CR(); stream.Read(buf, 0, 8); return *( ulong*)ptr; }
|
||||
public float ReadSingle() { CR(); stream.Read(buf, 0, 4); return *( float*)ptr; }
|
||||
public double ReadDouble() { CR(); stream.Read(buf, 0, 8); return *(double*)ptr; }
|
||||
|
||||
public short ReadInt16Endian() => ( short) IntFromArray(2, IsBE);
|
||||
public ushort ReadUInt16Endian() => (ushort)UIntFromArray(2, IsBE);
|
||||
public int ReadInt24Endian() => ( int) IntFromArray(3, IsBE);
|
||||
public int ReadInt32Endian() => ( int) IntFromArray(4, IsBE);
|
||||
public uint ReadUInt32Endian() => ( uint)UIntFromArray(4, IsBE);
|
||||
public long ReadInt64Endian() => IntFromArray(8, IsBE);
|
||||
public ulong ReadUInt64Endian() => UIntFromArray(8, IsBE);
|
||||
public Half ReadHalfEndian() { ushort a = ReadUInt16Endian(); return ( Half ) a; }
|
||||
public float ReadSingleEndian() { uint a = ReadUInt32Endian(); return *( float*)&a; }
|
||||
public double ReadDoubleEndian() { ulong a = ReadUInt64Endian(); return *(double*)&a; }
|
||||
public short ReadInt16Endian() { CR(); stream.Read(buf, 0, 2); buf.Endian(2, IsBE); return *( short*)ptr; }
|
||||
public ushort ReadUInt16Endian() { CR(); stream.Read(buf, 0, 2); buf.Endian(2, IsBE); return *(ushort*)ptr; }
|
||||
public int ReadInt32Endian() { CR(); stream.Read(buf, 0, 4); buf.Endian(4, IsBE); return *( int*)ptr; }
|
||||
public uint ReadUInt32Endian() { CR(); stream.Read(buf, 0, 4); buf.Endian(4, IsBE); return *( uint*)ptr; }
|
||||
public long ReadInt64Endian() { CR(); stream.Read(buf, 0, 8); buf.Endian(8, IsBE); return *( long*)ptr; }
|
||||
public ulong ReadUInt64Endian() { CR(); stream.Read(buf, 0, 8); buf.Endian(8, IsBE); return *( ulong*)ptr; }
|
||||
public float ReadSingleEndian() { CR(); stream.Read(buf, 0, 4); buf.Endian(4, IsBE); return *( float*)ptr; }
|
||||
public double ReadDoubleEndian() { CR(); stream.Read(buf, 0, 8); buf.Endian(8, IsBE); return *(double*)ptr; }
|
||||
|
||||
public short ReadInt16Endian(bool IsBE) => ( short) IntFromArray(2, IsBE);
|
||||
public ushort ReadUInt16Endian(bool IsBE) => (ushort)UIntFromArray(2, IsBE);
|
||||
public int ReadInt24Endian(bool IsBE) => ( int) IntFromArray(3, IsBE);
|
||||
public int ReadInt32Endian(bool IsBE) => ( int) IntFromArray(4, IsBE);
|
||||
public uint ReadUInt32Endian(bool IsBE) => ( uint)UIntFromArray(4, IsBE);
|
||||
public long ReadInt64Endian(bool IsBE) => IntFromArray(8, IsBE);
|
||||
public ulong ReadUInt64Endian(bool IsBE) => UIntFromArray(8, IsBE);
|
||||
public Half ReadHalfEndian(bool IsBE)
|
||||
{ ushort a = ReadUInt16Endian(IsBE); return ( Half ) a; }
|
||||
public short ReadInt16Endian(bool IsBE)
|
||||
{ CR(); stream.Read(buf, 0, 2); buf.Endian(2, IsBE); return *( short*)ptr; }
|
||||
public ushort ReadUInt16Endian(bool IsBE)
|
||||
{ CR(); stream.Read(buf, 0, 2); buf.Endian(2, IsBE); return *(ushort*)ptr; }
|
||||
public int ReadInt32Endian(bool IsBE)
|
||||
{ CR(); stream.Read(buf, 0, 4); buf.Endian(4, IsBE); return *( int*)ptr; }
|
||||
public uint ReadUInt32Endian(bool IsBE)
|
||||
{ CR(); stream.Read(buf, 0, 4); buf.Endian(4, IsBE); return *( uint*)ptr; }
|
||||
public long ReadInt64Endian(bool IsBE)
|
||||
{ CR(); stream.Read(buf, 0, 8); buf.Endian(8, IsBE); return *( long*)ptr; }
|
||||
public ulong ReadUInt64Endian(bool IsBE)
|
||||
{ CR(); stream.Read(buf, 0, 8); buf.Endian(8, IsBE); return *( ulong*)ptr; }
|
||||
public float ReadSingleEndian(bool IsBE)
|
||||
{ uint a = ReadUInt32Endian(IsBE); return *( float*)&a; }
|
||||
{ CR(); stream.Read(buf, 0, 4); buf.Endian(4, IsBE); return *( float*)ptr; }
|
||||
public double ReadDoubleEndian(bool IsBE)
|
||||
{ ulong a = ReadUInt64Endian(IsBE); return *(double*)&a; }
|
||||
{ CR(); stream.Read(buf, 0, 8); buf.Endian(8, IsBE); return *(double*)ptr; }
|
||||
|
||||
public void Write(byte[] Val) => stream.Write(Val, 0, Val. Length);
|
||||
public void Write(byte[] Val, int Length) => stream.Write(Val, 0 , Length);
|
||||
public void Write(byte[] Val, int Offset, int Length) => stream.Write(Val, Offset, Length);
|
||||
public void Write(char[] val, bool UTF8 = true)
|
||||
{ if (UTF8) Write(val.ToUTF8()); else Write(val.ToASCII()); }
|
||||
public void Write(byte[] Val ) => stream.Write(Val ?? new byte[0], 0, Val.Length);
|
||||
public void Write(byte[] Val, int Length) => stream.Write(Val ?? new byte[0], 0, Length);
|
||||
public void Write(byte[] Val, int Offset, int Length) => stream.Write(Val ?? new byte[0], Offset, Length);
|
||||
public void Write(char[] val, bool UTF8 = true) => Write(UTF8 ? val.ToUTF8() : val.ToASCII());
|
||||
|
||||
public void WriteByte(byte val) => stream.WriteByte(val);
|
||||
|
||||
public void Write( bool val) => stream.WriteByte((byte)(val ? 1 : 0));
|
||||
public void Write( sbyte val) => stream.WriteByte((byte) val);
|
||||
public void Write( byte val) => stream.WriteByte( val);
|
||||
public void Write( short val) => ToArray(2, val);
|
||||
public void Write(ushort val) => ToArray(2, val);
|
||||
public void Write( int val) => ToArray(4, val);
|
||||
public void Write( uint val) => ToArray(4, val);
|
||||
public void Write( long val) => ToArray(8, val);
|
||||
public void Write( ulong val) => ToArray(8, val);
|
||||
public void Write( Half val) => ToArray(2, (ushort) val);
|
||||
public void Write( float val) => ToArray(4, *( uint*)&val);
|
||||
public void Write(double val) => ToArray(8, *(ulong*)&val);
|
||||
public void Write( short val) { CW(); *( short*)ptr = val; stream.Write(buf, 0, 2); }
|
||||
public void Write(ushort val) { CW(); *(ushort*)ptr = val; stream.Write(buf, 0, 2); }
|
||||
public void Write( int val) { CW(); *( int*)ptr = val; stream.Write(buf, 0, 4); }
|
||||
public void Write( uint val) { CW(); *( uint*)ptr = val; stream.Write(buf, 0, 4); }
|
||||
public void Write( long val) { CW(); *( long*)ptr = val; stream.Write(buf, 0, 8); }
|
||||
public void Write( ulong val) { CW(); *( ulong*)ptr = val; stream.Write(buf, 0, 8); }
|
||||
public void Write( float val) { CW(); *( float*)ptr = val; stream.Write(buf, 0, 4); }
|
||||
public void Write(double val) { CW(); *(double*)ptr = val; stream.Write(buf, 0, 8); }
|
||||
|
||||
public void Write( sbyte? val) => Write(val.GetValueOrDefault());
|
||||
public void Write( byte? val) => Write(val.GetValueOrDefault());
|
||||
@@ -174,125 +173,55 @@ namespace KKdMainLib.IO
|
||||
public void Write( ulong? val) => Write(val.GetValueOrDefault());
|
||||
public void Write( float? val) => Write(val.GetValueOrDefault());
|
||||
public void Write(double? val) => Write(val.GetValueOrDefault());
|
||||
|
||||
public void Write( char val, bool UTF8 = true) =>
|
||||
Write(UTF8 ? val.ToString().ToUTF8() : val.ToString().ToASCII());
|
||||
public void Write(string val, bool UTF8 = true) =>
|
||||
Write(UTF8 ? val .ToUTF8() : val .ToASCII());
|
||||
|
||||
public void Write( bool* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) stream.WriteByte((byte)(val[i] ? 1 : 0)); }
|
||||
public void Write( sbyte* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) stream.WriteByte((byte) val[i]); }
|
||||
public void Write( byte* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) stream.WriteByte( val[i]); }
|
||||
public void Write( short* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, val[i]); }
|
||||
public void Write(ushort* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, val[i]); }
|
||||
public void Write( int* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, val[i]); }
|
||||
public void Write( uint* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, val[i]); }
|
||||
public void Write( long* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, val[i]); }
|
||||
public void Write( ulong* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, val[i]); }
|
||||
public void Write( float* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, *( uint*)&val[i]); }
|
||||
public void Write(double* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, *(ulong*)&val[i]); }
|
||||
public void WriteEndian( short val) { CW(); *( short*)ptr = val; buf.Endian(2, IsBE); stream.Write(buf, 0, 2); }
|
||||
public void WriteEndian(ushort val) { CW(); *(ushort*)ptr = val; buf.Endian(2, IsBE); stream.Write(buf, 0, 2); }
|
||||
public void WriteEndian( int val) { CW(); *( int*)ptr = val; buf.Endian(4, IsBE); stream.Write(buf, 0, 4); }
|
||||
public void WriteEndian( uint val) { CW(); *( uint*)ptr = val; buf.Endian(4, IsBE); stream.Write(buf, 0, 4); }
|
||||
public void WriteEndian( long val) { CW(); *( long*)ptr = val; buf.Endian(8, IsBE); stream.Write(buf, 0, 8); }
|
||||
public void WriteEndian( ulong val) { CW(); *( ulong*)ptr = val; buf.Endian(8, IsBE); stream.Write(buf, 0, 8); }
|
||||
public void WriteEndian( float val) { CW(); *( float*)ptr = val; buf.Endian(4, IsBE); stream.Write(buf, 0, 4); }
|
||||
public void WriteEndian(double val) { CW(); *(double*)ptr = val; buf.Endian(8, IsBE); stream.Write(buf, 0, 8); }
|
||||
|
||||
public void WriteEndian( short val, bool IsBE)
|
||||
{ CW(); *( short*)ptr = val; buf.Endian(2, IsBE); stream.Write(buf, 0, 2); }
|
||||
public void WriteEndian(ushort val, bool IsBE)
|
||||
{ CW(); *(ushort*)ptr = val; buf.Endian(2, IsBE); stream.Write(buf, 0, 2); }
|
||||
public void WriteEndian( int val, bool IsBE)
|
||||
{ CW(); *( int*)ptr = val; buf.Endian(4, IsBE); stream.Write(buf, 0, 4); }
|
||||
public void WriteEndian( uint val, bool IsBE)
|
||||
{ CW(); *( uint*)ptr = val; buf.Endian(4, IsBE); stream.Write(buf, 0, 4); }
|
||||
public void WriteEndian( long val, bool IsBE)
|
||||
{ CW(); *( long*)ptr = val; buf.Endian(8, IsBE); stream.Write(buf, 0, 8); }
|
||||
public void WriteEndian( ulong val, bool IsBE)
|
||||
{ CW(); *( ulong*)ptr = val; buf.Endian(8, IsBE); stream.Write(buf, 0, 8); }
|
||||
public void WriteEndian( float val, bool IsBE)
|
||||
{ CW(); *( float*)ptr = val; buf.Endian(4, IsBE); stream.Write(buf, 0, 4); }
|
||||
public void WriteEndian(double val, bool IsBE)
|
||||
{ CW(); *(double*)ptr = val; buf.Endian(8, IsBE); stream.Write(buf, 0, 8); }
|
||||
|
||||
public void WriteEndian( short* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, Endian(val[i], 2, IsBE)); }
|
||||
public void WriteEndian(ushort* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, Endian(val[i], 2, IsBE)); }
|
||||
public void WriteEndian( int* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(val[i], 4, IsBE)); }
|
||||
public void WriteEndian( uint* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(val[i], 4, IsBE)); }
|
||||
public void WriteEndian( long* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(val[i], 8, IsBE)); }
|
||||
public void WriteEndian( ulong* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(val[i], 8, IsBE)); }
|
||||
public void WriteEndian( float* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(*( uint*)&val[i], 4, IsBE)); }
|
||||
public void WriteEndian(double* val, int Length)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(*(ulong*)&val[i], 8, IsBE)); }
|
||||
|
||||
public void WriteEndian( short* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, Endian(val[i], 2, IsBE)); }
|
||||
public void WriteEndian(ushort* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) ToArray(2, Endian(val[i], 2, IsBE)); }
|
||||
public void WriteEndian( int* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(val[i], 4, IsBE)); }
|
||||
public void WriteEndian( uint* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(val[i], 4, IsBE)); }
|
||||
public void WriteEndian( long* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(val[i], 8, IsBE)); }
|
||||
public void WriteEndian( ulong* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(val[i], 8, IsBE)); }
|
||||
public void WriteEndian( float* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) ToArray(4, Endian(*( uint*)&val[i], 4, IsBE)); }
|
||||
public void WriteEndian(double* val, int Length, bool IsBE)
|
||||
{ for (i = 0; i < Length; i++) ToArray(8, Endian(*(ulong*)&val[i], 8, IsBE)); }
|
||||
public Half ReadHalf ( ) { ushort a = ReadUInt16 ( ); return (Half)a; }
|
||||
public Half ReadHalfEndian( ) { ushort a = ReadUInt16Endian( ); return (Half)a; }
|
||||
public Half ReadHalfEndian(bool IsBE) { ushort a = ReadUInt16Endian(IsBE); return (Half)a; }
|
||||
|
||||
public void Write( char val, bool UTF8 = true)
|
||||
{ if (UTF8) Write(val.ToString().ToUTF8()); else Write(val.ToString().ToASCII()); }
|
||||
public void Write(string val, bool UTF8 = true)
|
||||
{ if (UTF8) Write(val .ToUTF8()); else Write(val .ToASCII()); }
|
||||
public void Write ( Half val ) => Write ( (ushort ) val );
|
||||
public void WriteEndian( Half val ) => WriteEndian( (ushort ) val );
|
||||
public void WriteEndian( Half val, bool IsBE) => WriteEndian( (ushort ) val, IsBE);
|
||||
|
||||
public void WriteEndian( short val) => ToArray(2, Endian(val, 2, IsBE));
|
||||
public void WriteEndian(ushort val) => ToArray(2, Endian(val, 2, IsBE));
|
||||
public void WriteEndian( int val) => ToArray(4, Endian(val, 4, IsBE));
|
||||
public void WriteEndian( uint val) => ToArray(4, Endian(val, 4, IsBE));
|
||||
public void WriteEndian( long val) => ToArray(8, Endian(val, 8, IsBE));
|
||||
public void WriteEndian( ulong val) => ToArray(8, Endian(val, 8, IsBE));
|
||||
public void WriteEndian( float val) => ToArray(4, Endian(*( uint*)&val, 4, IsBE));
|
||||
public void WriteEndian(double val) => ToArray(8, Endian(*(ulong*)&val, 8, IsBE));
|
||||
|
||||
public void WriteEndian( short val, bool IsBE) => ToArray(2, Endian(val, 2, IsBE));
|
||||
public void WriteEndian(ushort val, bool IsBE) => ToArray(2, Endian(val, 2, IsBE));
|
||||
public void WriteEndian( int val, bool IsBE) => ToArray(4, Endian(val, 4, IsBE));
|
||||
public void WriteEndian( uint val, bool IsBE) => ToArray(4, Endian(val, 4, IsBE));
|
||||
public void WriteEndian( long val, bool IsBE) => ToArray(8, Endian(val, 8, IsBE));
|
||||
public void WriteEndian( ulong val, bool IsBE) => ToArray(8, Endian(val, 8, IsBE));
|
||||
public void WriteEndian( float val, bool IsBE) => ToArray(4, Endian(*( uint*)&val, 4, IsBE));
|
||||
public void WriteEndian(double val, bool IsBE) => ToArray(8, Endian(*(ulong*)&val, 8, IsBE));
|
||||
|
||||
public long Endian( long BE, byte Length, bool IsBE)
|
||||
{ if (IsBE) { for (I = 0; I < Length; I++) { buf[I] = (byte)BE; BE >>= 8; } BE = 0;
|
||||
for (I = 0; I < Length; I++) { BE |= buf[I]; if (I < Length - 1) BE <<= 8; } } return BE; }
|
||||
|
||||
public ulong Endian( ulong BE, byte Length, bool IsBE)
|
||||
{ if (IsBE) { for (I = 0; I < Length; I++) { buf[I] = (byte)BE; BE >>= 8; } BE = 0;
|
||||
for (I = 0; I < Length; I++) { BE |= buf[I]; if (I < Length - 1) BE <<= 8; } } return BE; }
|
||||
|
||||
private void ToArray(byte L, long val)
|
||||
{ CheckWrited(); for (I = 0; I < L; I++) { buf[I] = (byte)val; val >>= 8; } stream.Write(buf, 0, L); }
|
||||
|
||||
private void ToArray(byte L, ulong val)
|
||||
{ CheckWrited(); for (I = 0; I < L; I++) { buf[I] = (byte)val; val >>= 8; } stream.Write(buf, 0, L); }
|
||||
|
||||
private long IntFromArray(byte L) { stream.Read(buf, 0, L); long val = 0;
|
||||
for (I = L; I > 0; I--) { val <<= 8; val |= buf[I - 1]; } return val; }
|
||||
|
||||
private ulong UIntFromArray(byte L) { stream.Read(buf, 0, L); ulong val = 0;
|
||||
for (I = L; I > 0; I--) { val <<= 8; val |= buf[I - 1]; } return val; }
|
||||
|
||||
private long IntFromArray(byte L, bool IsBE) { stream.Read(buf, 0, L); long val = 0; if (IsBE)
|
||||
for (I = 0; I < L; I++) { val <<= 8; val |= buf[I ]; } else
|
||||
for (I = L; I > 0; I--) { val <<= 8; val |= buf[I - 1]; } return val; }
|
||||
|
||||
private ulong UIntFromArray(byte L, bool IsBE) { stream.Read(buf, 0, L); ulong val = 0; if (IsBE)
|
||||
for (I = 0; I < L; I++) { val <<= 8; val |= buf[I ]; } else
|
||||
for (I = L; I > 0; I--) { val <<= 8; val |= buf[I - 1]; } return val; }
|
||||
|
||||
public char ReadChar(bool UTF8 = true)
|
||||
{ if (UTF8) return ReadCharUTF8();
|
||||
else return (char)stream.ReadByte(); }
|
||||
public char ReadChar(bool UTF8 = true) => UTF8 ? ReadCharUTF8() : (char)stream.ReadByte();
|
||||
|
||||
public char ReadCharUTF8()
|
||||
{
|
||||
byte t;
|
||||
int T;
|
||||
int val = 0;
|
||||
for (I = 0, i0 = 4; I < i0; I++)
|
||||
for (I = 0, i = 4; I < i; I++)
|
||||
{
|
||||
T = stream.ReadByte();
|
||||
if (T == -1) return '\uFFFF';
|
||||
@@ -300,25 +229,23 @@ namespace KKdMainLib.IO
|
||||
|
||||
if ((t & 0xC0) == 0x80 && I > 0) val = (val << 6) | (t & 0x3F);
|
||||
else if ((t & 0x80) == 0x00 && I == 0) return (char)t;
|
||||
else if ((t & 0xE0) == 0xC0 && I == 0) { val = t & 0x1F; i0 = 2; }
|
||||
else if ((t & 0xF0) == 0xE0 && I == 0) { val = t & 0x0F; i0 = 3; }
|
||||
else if ((t & 0xF8) == 0xF0 && I == 0) { val = t & 0x07; i0 = 4; }
|
||||
else if ((t & 0xE0) == 0xC0 && I == 0) { val = t & 0x1F; i = 2; }
|
||||
else if ((t & 0xF0) == 0xE0 && I == 0) { val = t & 0x0F; i = 3; }
|
||||
else if ((t & 0xF8) == 0xF0 && I == 0) { val = t & 0x07; i = 4; }
|
||||
else return '\uFFFF';
|
||||
}
|
||||
return (char)val;
|
||||
}
|
||||
|
||||
public string ReadString(long Length, bool UTF8 = true)
|
||||
{ if (UTF8) return ReadStringUTF8 (Length);
|
||||
else return ReadStringASCII(Length); }
|
||||
|
||||
public string ReadString(long Length, bool UTF8 = true) =>
|
||||
UTF8 ? ReadStringUTF8(Length) : ReadStringASCII(Length);
|
||||
|
||||
public string ReadStringUTF8 (long Length) => ReadBytes(Length).ToUTF8 ();
|
||||
public string ReadStringASCII(long Length) => ReadBytes(Length).ToASCII();
|
||||
|
||||
|
||||
public string ReadString(long? Length, bool UTF8 = true)
|
||||
{ if (UTF8) return ReadStringUTF8 (Length);
|
||||
else return ReadStringASCII(Length); }
|
||||
public string ReadString(long? Length, bool UTF8 = true) =>
|
||||
UTF8 ? ReadStringUTF8(Length) : ReadStringASCII(Length);
|
||||
|
||||
public string ReadStringUTF8 (long? Length) => ReadBytes(Length).ToUTF8 ();
|
||||
public string ReadStringASCII(long? Length) => ReadBytes(Length).ToASCII();
|
||||
@@ -335,7 +262,7 @@ namespace KKdMainLib.IO
|
||||
|
||||
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); }
|
||||
if (Bits > 0 && Bits < 8) for (i = 0; i < Length; i++) Buf[i] = ReadBits(Bits); }
|
||||
|
||||
public byte ReadBits(byte Bits)
|
||||
{
|
||||
@@ -368,11 +295,20 @@ namespace KKdMainLib.IO
|
||||
ValWrite &= 0xFF;
|
||||
}
|
||||
|
||||
public void CheckRead () { if (BitRead > 0) ValRead = 0; BitRead = 8; }
|
||||
public void CheckWrited() { if (BitWrite > 0) { WriteByte((byte)ValWrite); ValWrite = 0; BitWrite = 0; } }
|
||||
public void CR() //CheckRead
|
||||
{ CFUTRM(); if (BitRead > 0) ValRead = 0; BitRead = 8; }
|
||||
public void CW() //CheckWrite
|
||||
{ CFUTRM(); if (BitWrite > 0) { stream.WriteByte((byte)ValWrite); ValWrite = 0; BitWrite = 0; } }
|
||||
|
||||
public byte[] ToArray(bool Close)
|
||||
{ byte[] Data = ToArray(); if (Close) this.Close(); return Data; }
|
||||
{ byte[] Data = ToArray(); if (Close) Dispose(); return Data; }
|
||||
|
||||
[System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptions]
|
||||
[System.Security.SecuritySafeCritical]
|
||||
private void CFUTRM() //CheckForUnableToReadMemory
|
||||
{ try { if (buf[0] != ptr[0] || buf[1] != ptr[1] || buf[2] != ptr[2] || buf[3] != ptr[3] ||
|
||||
buf[4] != ptr[4] || buf[5] != ptr[5] || buf[6] != ptr[6] || buf[7] != ptr[7])
|
||||
ptr = buf.GetPtr(); } catch (AccessViolationException) { ptr = buf.GetPtr(); } }
|
||||
|
||||
public byte[] ToArray()
|
||||
{
|
||||
|
||||
@@ -1,29 +1,13 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public static unsafe class Main
|
||||
{
|
||||
public static void ConsoleDesign(string text, params string[] args)
|
||||
{
|
||||
text = string.Format(text, args);
|
||||
string Text = "█ █";
|
||||
Text = Text.Remove(3) + text + Text.Remove(0, text.Length + 3);
|
||||
Console.WriteLine(Text);
|
||||
}
|
||||
|
||||
public static void ConsoleDesign(bool Fill)
|
||||
{
|
||||
if (Fill) Console.WriteLine("████████████████████████████████████████████████████");
|
||||
else Console.WriteLine("█ █");
|
||||
}
|
||||
|
||||
public const string TimeFormatHHmmssfff = "{0:d2}:{1:d2}:{2:d2}.{3:d3}";
|
||||
|
||||
public static void WriteTime(this TimeSpan time, bool WriteLine = false)
|
||||
@@ -41,89 +25,6 @@ namespace KKdMainLib
|
||||
else Console.Write (TimeFormatHHmmssfff + " - " + Text,
|
||||
time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
|
||||
}
|
||||
|
||||
private static string GetArgs(string name, bool And, params string[] ext)
|
||||
{
|
||||
string Out = "";
|
||||
if (And) Out = "|";
|
||||
Out += name + " files (";
|
||||
for (int i = 0; i < ext.Length; i++)
|
||||
{ Out += "*." + ext[i]; if (i + 1 < ext.Length) Out += ", "; }
|
||||
Out += ")|";
|
||||
for (int i = 0; i < ext.Length; i++)
|
||||
{ Out += "*." + ext[i]; if (i + 1 < ext.Length) Out += ";"; }
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
private static string GetArgs(string name, params string[] ext)
|
||||
{
|
||||
string Out = name + " files (";
|
||||
for (int i = 0; i < ext.Length; i++)
|
||||
{ Out += "*." + ext[i]; if (i + 1 < ext.Length) Out += ", "; }
|
||||
Out += ")|";
|
||||
for (int i = 0; i < ext.Length; i++)
|
||||
{ Out += "*." + ext[i]; if (i + 1 < ext.Length) Out += ";"; }
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
public static string Choose(int code, string filetype, out string[] FileNames)
|
||||
{
|
||||
string MsgPack = GetArgs("MessagePack", true, "mp");
|
||||
string JSON = GetArgs("JSON", true, "json");
|
||||
string BIN = GetArgs("BIN", true, "bin");
|
||||
string WAV = GetArgs("WAV", true, "wav");
|
||||
|
||||
FileNames = new string[0];
|
||||
if (code == 1)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog { InitialDirectory = Application.StartupPath,
|
||||
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;
|
||||
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 == "json") ofd.Filter = "JSON (*.json)|*.json";
|
||||
else if (filetype == "mp" ) ofd.Filter = GetArgs("MessagePack", "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") +
|
||||
GetArgs("VAG", true, "vag") + GetArgs("WAV", true, "wav");
|
||||
|
||||
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);
|
||||
ofd.Dispose();
|
||||
return Return;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string NullTerminated(this string Source, ref int i, byte End)
|
||||
{
|
||||
|
||||
+21
-23
@@ -167,16 +167,14 @@ namespace KKdMainLib
|
||||
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 MOTS;
|
||||
if ((MOTS = MsgPack["MOT"]).NotNull)
|
||||
{
|
||||
MOT = new MotHeader[MOTS.Array.Length];
|
||||
for (int i = 0; i < MOT.Length; i++)
|
||||
MsgPackReader(MOTS.Array[i], ref MOT[i]);
|
||||
}
|
||||
MOTS.Dispose();
|
||||
MsgPack.Dispose();
|
||||
}
|
||||
|
||||
@@ -195,7 +193,7 @@ namespace KKdMainLib
|
||||
Mot.HighBits = MOT.ReadInt32("HighBits" );
|
||||
Mot.FrameCount = MOT.ReadInt32("FrameCount");
|
||||
|
||||
if (!MOT.ElementArray("KeySets", out Temp)) return;
|
||||
if ((Temp = MOT["KeySets", true]).IsNull) { Temp.Dispose(); return; }
|
||||
|
||||
Mot.KeySet.Value = new KeySet[Temp.Array.Length];
|
||||
for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++)
|
||||
@@ -235,14 +233,14 @@ namespace KKdMainLib
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (MOT.ElementArray("BoneInfo", out Temp))
|
||||
|
||||
if ((Temp = MOT["BoneInfo", true]).NotNull)
|
||||
{
|
||||
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;
|
||||
Temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack MsgPackWriter(ref MotHeader Mot)
|
||||
@@ -256,35 +254,35 @@ namespace KKdMainLib
|
||||
if (KeySet.Type == KeySetType.None) continue;
|
||||
|
||||
KeySets[i0] = new MsgPack(2);
|
||||
KeySets[i0].Array[0] = (MsgPack)(byte)KeySet.Type;
|
||||
KeySets[i0].Array[0] = (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;
|
||||
KeySets[i0].Array[1][0].Array[0] = KeySet.Keys[0].F;
|
||||
KeySets[i0].Array[1][0].Array[1] = 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;
|
||||
KeySets[i0].Array[1][i1].Array[0] = KeySet.Keys[i1].F;
|
||||
KeySets[i0].Array[1][i1].Array[1] = 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;
|
||||
KeySets[i0].Array[1][i1].Array[0] = KeySet.Keys[i1].F;
|
||||
KeySets[i0].Array[1][i1].Array[1] = KeySet.Keys[i1].V;
|
||||
KeySets[i0].Array[1][i1].Array[2] = 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;
|
||||
BoneInfo[i0] = Mot.BoneInfo.Value[i0].Id;
|
||||
MOT.Add(BoneInfo);
|
||||
|
||||
return MOT;
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("2BA7EFC6-91D1-8BBC-C487-06C7F36CC789")]
|
||||
[assembly: AssemblyVersion("0.4.7.2")]
|
||||
[assembly: AssemblyFileVersion("0.4.7.2")]
|
||||
[assembly: AssemblyVersion("0.4.7.5")]
|
||||
[assembly: AssemblyFileVersion("0.4.7.5")]
|
||||
|
||||
+15
-12
@@ -11,7 +11,7 @@ namespace KKdMainLib
|
||||
|
||||
private long Offset;
|
||||
private long OffsetX;
|
||||
private KKdList<long> POF;
|
||||
private POF POF;
|
||||
private Header Header;
|
||||
private Stream IO;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace KKdMainLib
|
||||
if (Header.Signature == 0x41525453)
|
||||
{
|
||||
Header = IO.ReadHeader(true, false);
|
||||
POF = KKdList<long>.New;
|
||||
POF.Offsets = KKdList<long>.New;
|
||||
|
||||
long Count = IO.ReadInt32Endian();
|
||||
Offset = IO.ReadInt32Endian();
|
||||
@@ -95,7 +95,7 @@ namespace KKdMainLib
|
||||
uint CurrentOffset = 0;
|
||||
IO = File.OpenWriter(filepath + (Header.Format > Format.FT ? ".str" : ".bin"), true);
|
||||
IO.Format = Header.Format;
|
||||
POF = KKdList<long>.New;
|
||||
POF.Offsets = KKdList<long>.New;
|
||||
IO.IsBE = IO.Format == Format.F2BE;
|
||||
|
||||
long Count = STRs.LongLength;
|
||||
@@ -143,15 +143,16 @@ namespace KKdMainLib
|
||||
IO.Position = 0x80;
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
POF.Add(IO.Position);
|
||||
POF.Offsets.Add(IO.Position);
|
||||
IO.WriteEndian(STRPos[i]);
|
||||
IO.WriteEndian(STRs[i].ID);
|
||||
}
|
||||
|
||||
IO.UIntPosition = Offset;
|
||||
IO.Write(ref POF, 0, false);
|
||||
POF.Depth = 1;
|
||||
IO.Write(POF);
|
||||
CurrentOffset = IO.UIntPosition;
|
||||
IO.WriteEOFC(0);
|
||||
IO.WriteEOFC();
|
||||
Header.DataSize = (int)(CurrentOffset - 0x40);
|
||||
Header.Signature = 0x41525453;
|
||||
Header.SectionSize = (int)(Offset - 0x40);
|
||||
@@ -168,18 +169,20 @@ namespace KKdMainLib
|
||||
|
||||
public void MsgPackReader(string file, bool JSON)
|
||||
{
|
||||
MsgPack Temp;
|
||||
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
|
||||
if (!MsgPack.Element("STR", out MsgPack STR)) return;
|
||||
if ((Temp = MsgPack["STR"]).NotNull) return;
|
||||
|
||||
Header = new Header();
|
||||
System.Enum.TryParse(STR.ReadString("Format"), out Header.Format);
|
||||
System.Enum.TryParse(Temp.ReadString("Format"), out Header.Format);
|
||||
|
||||
if (!STR.ElementArray("Strings", out MsgPack Strings)) return;
|
||||
if ((Temp = MsgPack["Strings", true]).IsNull) return;
|
||||
|
||||
STRs = new String[Strings.Array.Length];
|
||||
STRs = new String[Temp.Array.Length];
|
||||
for (int i = 0; i < STRs.Length; i++)
|
||||
{
|
||||
STRs[i].ID = Strings[i].ReadInt32 ("ID" );
|
||||
STRs[i].Str.Value = Strings[i].ReadString("Str");
|
||||
STRs[i].ID = Temp[i].ReadInt32 ("ID" );
|
||||
STRs[i].Str.Value = Temp[i].ReadString("Str");
|
||||
if (STRs[i].Str.Value == null) STRs[i].Str.Value = "";
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ namespace KKdSoundLib
|
||||
ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
writer.Write(value, 4);
|
||||
}
|
||||
writer.CheckWrited();
|
||||
writer.CW();
|
||||
|
||||
writer.LongPosition = 0x00;
|
||||
writer.Write("DIVA");
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("D8A3F2D7-10CC-5723-EC9A-45D3B9C2DFEA")]
|
||||
[assembly: AssemblyVersion("0.0.3.0")]
|
||||
[assembly: AssemblyFileVersion("0.0.3.0")]
|
||||
[assembly: AssemblyVersion("0.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.1.0.0")]
|
||||
|
||||
+84
-66
@@ -109,29 +109,7 @@ namespace KKdSoundLib
|
||||
|
||||
VAG_1 = HEVAG1Ptr[PrNR]; VAG_2 = HEVAG2Ptr[PrNR];
|
||||
tS1 = S1Ptr[c]; tS2 = S2Ptr[c];
|
||||
|
||||
i = 0; i2 = 1;
|
||||
while (i < BS)
|
||||
{
|
||||
d0 = four_bitPtr[i];
|
||||
d1 = four_bitPtr[i2];
|
||||
if (d0 > 7) d0 -= 16;
|
||||
if (d1 > 7) d1 -= 16;
|
||||
d0 = d0 << (20 - ShF);
|
||||
d1 = d1 << (20 - ShF);
|
||||
|
||||
g = ((tS1 >> 8) * VAG_1 + (tS2 >> 8) * VAG_2) >> 5;
|
||||
tS2 = tS1; tS1 = g + d0;
|
||||
|
||||
g = ((tS1 >> 8) * VAG_1 + (tS2 >> 8) * VAG_2) >> 5;
|
||||
tS2 = tS1; tS1 = g + d1;
|
||||
|
||||
temp_bufferPtr[i ] = tS2;
|
||||
temp_bufferPtr[i2] = tS1;
|
||||
i += 2;
|
||||
i2 += 2;
|
||||
}
|
||||
|
||||
DecodeVAG();
|
||||
S1Ptr[c] = tS1; S2Ptr[c] = tS2;
|
||||
|
||||
for (i = 0, i2 = 1; i < BS; i += 2, i2 += 2)
|
||||
@@ -146,6 +124,31 @@ namespace KKdSoundLib
|
||||
Success = true;
|
||||
}
|
||||
|
||||
private void DecodeVAG()
|
||||
{
|
||||
i = 0; i2 = 1;
|
||||
while (i < BS)
|
||||
{
|
||||
d0 = four_bitPtr[i];
|
||||
d1 = four_bitPtr[i2];
|
||||
if (d0 > 7) d0 -= 16;
|
||||
if (d1 > 7) d1 -= 16;
|
||||
d0 <<= 20 - ShF;
|
||||
d1 <<= 20 - ShF;
|
||||
|
||||
g = ((tS1 >> 8) * VAG_1 + (tS2 >> 8) * VAG_2) >> 5;
|
||||
tS2 = tS1; tS1 = g + d0;
|
||||
|
||||
g = ((tS1 >> 8) * VAG_1 + (tS2 >> 8) * VAG_2) >> 5;
|
||||
tS2 = tS1; tS1 = g + d1;
|
||||
|
||||
temp_bufferPtr[i ] = tS2;
|
||||
temp_bufferPtr[i2] = tS1;
|
||||
i += 2;
|
||||
i2 += 2;
|
||||
}
|
||||
}
|
||||
|
||||
private void DecodeHEVAG()
|
||||
{
|
||||
i = 0; i2 = 1;
|
||||
@@ -155,8 +158,8 @@ namespace KKdSoundLib
|
||||
d1 = four_bitPtr[i2];
|
||||
if (d0 > 7) d0 -= 16;
|
||||
if (d1 > 7) d1 -= 16;
|
||||
d0 = d0 << (20 - ShF);
|
||||
d1 = d1 << (20 - ShF);
|
||||
d0 <<= 20 - ShF;
|
||||
d1 <<= 20 - ShF;
|
||||
|
||||
g = ((tS1 >> 8) * HEVAG_1 + (tS2 >> 8) * HEVAG_2 +
|
||||
(tS3 >> 8) * HEVAG_3 + (tS4 >> 8) * HEVAG_4) >> 5;
|
||||
@@ -197,7 +200,7 @@ namespace KKdSoundLib
|
||||
for (i1 = 0, i2 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
{
|
||||
Flag = VAGData.Flags[i1];
|
||||
if (!IgnoreEndFlags && Flag == 5 || Flag == 7) break;
|
||||
if (!IgnoreEndFlags && (Flag == 5 || Flag == 7)) break;
|
||||
if (Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
@@ -248,7 +251,7 @@ namespace KKdSoundLib
|
||||
for (i1 = 1, i2 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
{
|
||||
Flag = VAGData.Flags[i1];
|
||||
if (!IgnoreEndFlags && Flag == 5 || Flag == 7) break;
|
||||
if (!IgnoreEndFlags && (Flag == 5 || Flag == 7)) break;
|
||||
else if (!IgnoreEndFlags && Flag == 6)
|
||||
{
|
||||
Header = new WAV.Header { Bytes = 4, Channels = ch, Format = 3, SampleRate =
|
||||
@@ -476,7 +479,6 @@ namespace KKdSoundLib
|
||||
four_bit = new int[BS]; four_bitPtr = four_bit .GetPtr();
|
||||
data_buffer = new int[BS]; data_bufferPtr = data_buffer.GetPtr();
|
||||
temp_buffer = new int[BS]; temp_bufferPtr = temp_buffer.GetPtr();
|
||||
buffer = new int[PrNRCount, BS];
|
||||
|
||||
writer.Write(0x70474156);
|
||||
if (HEVAG) writer.WriteEndian(0x00020001, true);
|
||||
@@ -581,65 +583,81 @@ namespace KKdSoundLib
|
||||
private int min, ShM, S1, S2, S3, S4, tS1, tS2, tS3, tS4, PrNRf;
|
||||
private int VAG_1, VAG_2, HEVAG_1, HEVAG_2, HEVAG_3, HEVAG_4;
|
||||
private int[] data_buffer, error, four_bit, max, S_1, S_2, S_3, S_4, temp_buffer;
|
||||
private int[,] buffer;
|
||||
private int* data_bufferPtr, errorPtr, four_bitPtr, maxPtr, temp_bufferPtr;
|
||||
|
||||
|
||||
private void Calc4BitsVAG()
|
||||
{
|
||||
ShF = min = 134217728;
|
||||
for (j = 0; j < 5; j++)
|
||||
PrNRf = 0;
|
||||
min = 134217728;
|
||||
for (j = 0; j < PrNRCount; j++)
|
||||
{
|
||||
maxPtr[j] = 0;
|
||||
S1 = S1Ptr[c]; S2 = S2Ptr[c];
|
||||
VAG_1 = HEVAG1Ptr[j]; VAG_2 = HEVAG2Ptr[j];
|
||||
for (i = 0; i < 28; i++)
|
||||
PrNR = j;
|
||||
|
||||
Calc4Bits_VAG();
|
||||
|
||||
tS1 = S1Ptr[c]; tS2 = S2Ptr[c];
|
||||
DecodeVAG();
|
||||
i = 0;
|
||||
errorPtr[j] = 0;
|
||||
while (i < BS)
|
||||
{
|
||||
g = data_bufferPtr[i];
|
||||
e = ((S1 >> 8) * VAG_1 + (S2 >> 8) * VAG_2) >> 5;
|
||||
e = g - e;
|
||||
if (e > 7864319) e = 7864319;
|
||||
if (e < -7864320) e = -7864320;
|
||||
buffer[j, i] = e;
|
||||
e = data_bufferPtr[i] - temp_bufferPtr[i];
|
||||
if (e < 0) e = -e;
|
||||
if (e > maxPtr[j]) maxPtr[j] = e;
|
||||
S2 = S1; S1 = g;
|
||||
errorPtr[j] += e;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (maxPtr[j] < min) { PrNR = j; min = maxPtr[j]; }
|
||||
if (errorPtr[j] < min) { PrNRf = j; min = errorPtr[j]; }
|
||||
}
|
||||
|
||||
S1Ptr[c] = S1; S2Ptr[c] = S2;
|
||||
PrNR = PrNRf;
|
||||
|
||||
ShF = 0;
|
||||
ShM = 0x4000;
|
||||
min = min >> 8;
|
||||
|
||||
while (ShF < 12)
|
||||
Calc4Bits_VAG();
|
||||
S1Ptr[c] = S1; S2Ptr[c] = S2;
|
||||
S_1 [c] = tS1; S_2 [c] = tS2;
|
||||
}
|
||||
|
||||
private void Calc4Bits_VAG()
|
||||
{
|
||||
S1 = S1Ptr[c]; S2 = S2Ptr[c];
|
||||
VAG_1 = HEVAG1Ptr[PrNR]; HEVAG_2 = HEVAG2Ptr[PrNR];
|
||||
|
||||
i = 0;
|
||||
maxPtr[PrNR] = 0;
|
||||
while (i < BS)
|
||||
{
|
||||
e = min + (ShM >> 3);
|
||||
if ((ShM & e) == ShM)
|
||||
break;
|
||||
ShF++;
|
||||
ShM >>= 1;
|
||||
g = data_bufferPtr[i];
|
||||
e = ((S1 >> 8) * VAG_1 + (S2 >> 8) * VAG_2) >> 5;
|
||||
e = g - e;
|
||||
if (e > 7864319) e = 7864319;
|
||||
if (e < -7864320) e = -7864320;
|
||||
temp_bufferPtr[i] = e;
|
||||
if (e < 0) e = -e;
|
||||
if (e > maxPtr[PrNR]) maxPtr[PrNR] = e;
|
||||
S2 = S1; S1 = g;
|
||||
i++;
|
||||
}
|
||||
|
||||
S1 = S_1[c]; S2 = S_2[c];
|
||||
for (i = 0; i < 28; i++)
|
||||
for (ShF = 0, ShM = 0x400000; ShF < 15; ShF++, ShM >>= 1)
|
||||
{ e = maxPtr[PrNR] + (ShM >> 3); if ((ShM & e) == ShM) break; }
|
||||
|
||||
tS1 = S_1[c]; tS2 = S_2[c];
|
||||
i = 0;
|
||||
while (i < BS)
|
||||
{
|
||||
g = buffer[PrNR, i];
|
||||
e = ((S1 >> 8) * HEVAG1Ptr[PrNR] + (S2 >> 8) * HEVAG2Ptr[PrNR]) >> 5;
|
||||
g = temp_bufferPtr[i];
|
||||
e = ((tS1 >> 8) * VAG_1 + (tS2 >> 8) * VAG_2) >> 5;
|
||||
e = g - e;
|
||||
|
||||
d1 = e << ShF;
|
||||
d0 = (int)((uint)d1 + 0x80000) >> 20;
|
||||
d0 = (d1 + 0x80000) >> 20;
|
||||
if (d0 > 7) d0 = 7;
|
||||
if (d0 < -8) d0 = -8;
|
||||
four_bitPtr[i] = d0 & 0xF;
|
||||
d0 = d0 << (20 - ShF);
|
||||
d0 <<= 20 - ShF;
|
||||
|
||||
S2 = S1; S1 = d0 - e;
|
||||
tS2 = tS1; tS1 = d0 - e;
|
||||
i++;
|
||||
}
|
||||
S_1[c] = S1; S_2[c] = S2;
|
||||
}
|
||||
|
||||
private void Calc4BitsHEVAG()
|
||||
@@ -713,7 +731,7 @@ namespace KKdSoundLib
|
||||
if (d0 > 7) d0 = 7;
|
||||
if (d0 < -8) d0 = -8;
|
||||
four_bitPtr[i] = d0 & 0xF;
|
||||
d0 = d0 << (20 - ShF);
|
||||
d0 <<= 20 - ShF;
|
||||
|
||||
tS4 = tS3; tS3 = tS2; tS2 = tS1; tS1 = d0 - e;
|
||||
i++;
|
||||
|
||||
+140
-58
@@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMain = KKdMainLib.Main;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool SetProcessDPIAware();
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll")]
|
||||
private static extern bool SetProcessDPIAware();
|
||||
|
||||
[ThreadStatic] public static string function = "";
|
||||
|
||||
@@ -19,12 +19,7 @@ namespace PD_Tool
|
||||
SetProcessDPIAware();
|
||||
|
||||
Console.Title = "PD_Tool";
|
||||
if (args.Length == 0)
|
||||
{
|
||||
GC.Collect();
|
||||
while (function != "Q") MainMenu();
|
||||
Exit();
|
||||
}
|
||||
if (args.Length == 0) { while (function != "Q") MainMenu(); Exit(); }
|
||||
|
||||
long header;
|
||||
Stream reader;
|
||||
@@ -47,28 +42,27 @@ 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();
|
||||
|
||||
KKdMain.ConsoleDesign(true);
|
||||
KKdMain.ConsoleDesign(" Choose action:");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign("1. Extract FARC Archive");
|
||||
KKdMain.ConsoleDesign("2. Create FARC Archive");
|
||||
KKdMain.ConsoleDesign("3. Decrypt from DIVAFILE");
|
||||
KKdMain.ConsoleDesign("4. Encrypt to DIVAFILE");
|
||||
KKdMain.ConsoleDesign("5. DB_Tools");
|
||||
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");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
KKdMain.ConsoleDesign(true);
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose action:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. Extract FARC Archive");
|
||||
ConsoleDesign("2. Create FARC Archive");
|
||||
ConsoleDesign("3. Decrypt from DIVAFILE");
|
||||
ConsoleDesign("4. Encrypt to DIVAFILE");
|
||||
ConsoleDesign("5. DB_Tools");
|
||||
ConsoleDesign("6. AC/DT/F/AFT/FT Converting Tools");
|
||||
ConsoleDesign("7. F/F2/X/FT Converting Tools");
|
||||
ConsoleDesign(JSON ? "8. MsgPack to JSON" : "9. JSON to MsgPack");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(JSON ? "M. MessagePack" : "J. JSON");
|
||||
ConsoleDesign("Q. Quit");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
|
||||
function = Console.ReadLine().ToUpper();
|
||||
@@ -84,7 +78,7 @@ namespace PD_Tool
|
||||
if (function == "1" || function == "2") FARC.Processor(function == "1");
|
||||
else if (function == "3" || function == "4")
|
||||
{
|
||||
KKdMain.Choose(1, "", out string[] FileNames);
|
||||
Choose(1, "", out string[] FileNames);
|
||||
foreach (string FileName in FileNames) DIVAFILE.Decrypt(FileName);
|
||||
}
|
||||
else if (function == "5") DataBase.Processor(JSON);
|
||||
@@ -92,20 +86,20 @@ namespace PD_Tool
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "AC/DT/F/AFT/FT Converting Tools";
|
||||
KKdMain.ConsoleDesign(true);
|
||||
KKdMain.ConsoleDesign(" Choose converter:");
|
||||
KKdMain.ConsoleDesign(false);
|
||||
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);
|
||||
KKdMain.ConsoleDesign(true);
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. AET" );
|
||||
ConsoleDesign("3. DataBank");
|
||||
ConsoleDesign("4. DEX" );
|
||||
ConsoleDesign("5. DIVA" );
|
||||
ConsoleDesign("6. MOT" );
|
||||
ConsoleDesign("7. STR" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string Function = Console.ReadLine();
|
||||
Console.Clear();
|
||||
@@ -122,21 +116,21 @@ namespace PD_Tool
|
||||
{
|
||||
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);
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. Bloom" );
|
||||
ConsoleDesign("3. Color Correction");
|
||||
ConsoleDesign("4. DEX" );
|
||||
ConsoleDesign("5. DOF" );
|
||||
ConsoleDesign("6. Light" );
|
||||
ConsoleDesign("7. STR" );
|
||||
ConsoleDesign("8. VAG" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string Function = Console.ReadLine();
|
||||
Console.Clear();
|
||||
@@ -152,7 +146,7 @@ namespace PD_Tool
|
||||
}
|
||||
else if (function == "8")
|
||||
{
|
||||
KKdMain.Choose(1, JSON ? "mp" : "json", out string[] FileNames);
|
||||
Choose(1, JSON ? "mp" : "json", out string[] FileNames);
|
||||
foreach (string file in FileNames)
|
||||
if (JSON)
|
||||
{
|
||||
@@ -168,5 +162,93 @@ namespace PD_Tool
|
||||
}
|
||||
|
||||
public static void Exit() => Environment.Exit(0);
|
||||
|
||||
public static void ConsoleDesign(string text, params string[] args)
|
||||
{
|
||||
text = string.Format(text, args);
|
||||
string Text = "█ █";
|
||||
Text = Text.Remove(3) + text + Text.Remove(0, text.Length + 3);
|
||||
Console.WriteLine(Text);
|
||||
}
|
||||
|
||||
public static void ConsoleDesign(bool Fill)
|
||||
{
|
||||
if (Fill) Console.WriteLine("████████████████████████████████████████████████████");
|
||||
else Console.WriteLine("█ █");
|
||||
}
|
||||
|
||||
private static string GetArgs(string name, bool And, params string[] ext)
|
||||
{
|
||||
int L = ext.Length;
|
||||
string Out = (And ? "|" : "") + name + " files (";
|
||||
for (int i = 0; i < L; i++) { Out += "*." + ext[i]; if (i + 1 < L) Out += ", "; }
|
||||
Out += ")|";
|
||||
for (int i = 0; i < L; i++) { Out += "*." + ext[i]; if (i + 1 < L) Out += ";" ; }
|
||||
return Out;
|
||||
}
|
||||
|
||||
private static string GetArgs(string name, params string[] ext)
|
||||
{
|
||||
int L = ext.Length;
|
||||
string Out = name + " files (";
|
||||
for (int i = 0; i < L; i++) { Out += "*." + ext[i]; if (i + 1 < L) Out += ", "; }
|
||||
Out += ")|";
|
||||
for (int i = 0; i < L; i++) { Out += "*." + ext[i]; if (i + 1 < L) Out += ";" ; }
|
||||
return Out;
|
||||
}
|
||||
|
||||
public static string Choose(int code, string filetype, out string[] FileNames)
|
||||
{
|
||||
string MsgPack = GetArgs("MessagePack", true, "mp" );
|
||||
string JSON = GetArgs("JSON" , true, "json");
|
||||
string BIN = GetArgs("BIN" , true, "bin" );
|
||||
string WAV = GetArgs("WAV" , true, "wav" );
|
||||
|
||||
FileNames = new string[0];
|
||||
if (code == 1)
|
||||
{
|
||||
string Filter = GetArgs("All;", false, "*");
|
||||
if (filetype == "a3da") Filter = GetArgs("A3DA", "a3da", "farc", "json", "mp") +
|
||||
GetArgs("A3DA", true, "a3da") + GetArgs("FARC", true, "farc") + JSON + MsgPack;
|
||||
else if (filetype == "bin" ) Filter = GetArgs("BIN" , "bin", "json", "mp") +
|
||||
BIN + JSON + MsgPack;
|
||||
else if (filetype == "blt" ) Filter = GetArgs("BLT" , "blt");
|
||||
else if (filetype == "bon" ) Filter = GetArgs("BON" , "bon", "bin", "json", "mp") +
|
||||
GetArgs("BON", true, "bon") + BIN + JSON + MsgPack;
|
||||
else if (filetype == "cct" ) Filter = GetArgs("CCT" , "cct");
|
||||
else if (filetype == "databank") Filter = GetArgs("DAT", "dat", "json", "mp") +
|
||||
GetArgs("DAT", true, "dat") + JSON + MsgPack;
|
||||
else if (filetype == "dex" ) Filter = GetArgs("DEX" , "dex", "bin", "json", "mp") +
|
||||
GetArgs("DEX", true, "dex") + BIN + JSON + MsgPack;
|
||||
else if (filetype == "dft" ) Filter = GetArgs("DFT" , "dft");
|
||||
else if (filetype == "diva") Filter = GetArgs("DIVA", "diva", "wav") +
|
||||
GetArgs("DIVA", true, "diva") + GetArgs("WAV", true, "wav");
|
||||
else if (filetype == "dsc" ) Filter = GetArgs("DSC" , "dsc", "json", "mp") +
|
||||
GetArgs("DSC", true, "dsc") + JSON + MsgPack;
|
||||
else if (filetype == "dve" ) Filter = GetArgs("Particles", "farc");
|
||||
else if (filetype == "farc") Filter = "FARC Archives (*.farc)|*.farc";
|
||||
else if (filetype == "json") Filter = GetArgs("JSON", "json");
|
||||
else if (filetype == "mp" ) Filter = GetArgs("MessagePack", "mp");
|
||||
else if (filetype == "lit") Filter = GetArgs("LIT" , "lit");
|
||||
else if (filetype == "str" ) Filter = GetArgs("STR" , "str", "bin", "json", "mp") +
|
||||
GetArgs("STR", true, "str") + BIN + JSON + MsgPack;
|
||||
else if (filetype == "vag" ) Filter = GetArgs("VAG" , "vag", "wav") +
|
||||
GetArgs("VAG", true, "vag") + GetArgs("WAV", true, "wav");
|
||||
|
||||
using (OpenFileDialog ofd = new OpenFileDialog { InitialDirectory = Application.StartupPath,
|
||||
Filter = Filter, Multiselect = true, Title = "Choose file(s) to open:" })
|
||||
if (ofd.ShowDialog() == DialogResult.OK) FileNames = ofd.FileNames;
|
||||
}
|
||||
else if (code == 2)
|
||||
{
|
||||
string Return = "";
|
||||
using (OpenFileDialog ofd = new OpenFileDialog { InitialDirectory = Application.StartupPath,
|
||||
ValidateNames = false, CheckFileExists = false, Filter = " | ", CheckPathExists = true,
|
||||
Title = "Choose any file in folder:", FileName = "Folder Selection." })
|
||||
if (ofd.ShowDialog() == DialogResult.OK) Return = Path.GetDirectoryName(ofd.FileName);
|
||||
return Return;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
|
||||
[assembly: AssemblyVersion("0.4.7.2")]
|
||||
[assembly: AssemblyFileVersion("0.4.7.2")]
|
||||
[assembly: AssemblyVersion("0.4.7.5")]
|
||||
[assembly: AssemblyFileVersion("0.4.7.5")]
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace PD_Tool
|
||||
Stream reader = File.OpenReader(file);
|
||||
if (reader.ReadInt64() != 0x454C494641564944) { reader.Close(); return; }
|
||||
reader.Close();
|
||||
|
||||
System.Console.Title = "DIVAFILE Decrypt: " + Path.GetFileName(file);
|
||||
file.Decrypt();
|
||||
}
|
||||
|
||||
@@ -17,6 +19,9 @@ namespace PD_Tool
|
||||
{
|
||||
Stream reader = File.OpenReader(file);
|
||||
if (reader.ReadInt64() == 0x454C494641564944) { reader.Close(); return; }
|
||||
reader.Close();
|
||||
|
||||
System.Console.Title = "DIVAFILE Encrypt: " + Path.GetFileName(file);
|
||||
file.Encrypt();
|
||||
}
|
||||
}
|
||||
|
||||
+13
-14
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdMainLib;
|
||||
using DB = KKdMainLib.DB;
|
||||
|
||||
namespace PD_Tool
|
||||
@@ -11,16 +10,16 @@ namespace PD_Tool
|
||||
{
|
||||
Console.Title = "DB Converter";
|
||||
Console.Clear();
|
||||
Main.ConsoleDesign(true);
|
||||
Main.ConsoleDesign(" Choose type of DataBase file:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. Auth DB Converter");
|
||||
Main.ConsoleDesign("2. AET DB Converter");
|
||||
Main.ConsoleDesign("3. SPR DB Converter");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("R. Return to Main Menu");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of DataBase file:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. Auth DB Converter");
|
||||
Program.ConsoleDesign("2. AET DB Converter");
|
||||
Program.ConsoleDesign("3. SPR DB Converter");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("R. Return to Main Menu");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string format = Console.ReadLine();
|
||||
if (format == "1") AuthDBProcessor(JSON);
|
||||
@@ -32,7 +31,7 @@ namespace PD_Tool
|
||||
{
|
||||
Console.Title = "Auth DB Converter";
|
||||
DB.Auth Auth;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
Program.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
@@ -62,7 +61,7 @@ namespace PD_Tool
|
||||
{
|
||||
Console.Title = "AET DB Converter";
|
||||
DB.Aet Aet;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
Program.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
@@ -92,7 +91,7 @@ namespace PD_Tool
|
||||
{
|
||||
Console.Title = "SPR DB Converter";
|
||||
DB.Spr Spr;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
Program.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
+28
-25
@@ -14,29 +14,33 @@ namespace PD_Tool
|
||||
if (Extract)
|
||||
{
|
||||
Console.Title = "FARC Extractor";
|
||||
Main.Choose(1, "farc", out string[] FileNames);
|
||||
foreach (string FileName in FileNames)
|
||||
if (FileName != "" && File.Exists(FileName))
|
||||
new KKdFARC(FileName).UnPack();
|
||||
Program.Choose(1, "farc", out string[] FileNames);
|
||||
foreach (string file in FileNames)
|
||||
if (file != "" && File.Exists(file))
|
||||
{
|
||||
Console.Title = "FARC Extractor: " + Path.GetFileNameWithoutExtension(file);
|
||||
new KKdFARC(file).UnPack();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string file = Main.Choose(2, "", out string[] FileNames);
|
||||
string file = Program.Choose(2, "", out string[] FileNames);
|
||||
Console.Clear();
|
||||
Console.Title = "FARC Creator";
|
||||
if (file != "")
|
||||
{
|
||||
Console.Title = "FARC Creator: " + Path.GetDirectoryName(file);
|
||||
FARC = new KKdFARC();
|
||||
Main.ConsoleDesign(true);
|
||||
Main.ConsoleDesign(" Choose type of created FARC:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. FArc [DT/DT2nd/DTex/F/F2nd/X]");
|
||||
Main.ConsoleDesign("2. FArC [DT/DT2nd/DTex/F/F2nd/X] (Compressed)");
|
||||
Main.ConsoleDesign("3. FARC [F/F2nd/X]");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("R. Return to Main Menu");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of created FARC:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. FArc [DT/DT2/DTex/F/F2/X]");
|
||||
Program.ConsoleDesign("2. FArC [DT/DT2/DTex/F/F2/X] (Compressed)");
|
||||
Program.ConsoleDesign("3. FARC [F/F2/X]");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("R. Return to Main Menu");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Choosed folder: {0}", file);
|
||||
Console.WriteLine();
|
||||
@@ -47,15 +51,15 @@ namespace PD_Tool
|
||||
FARC.Signature = KKdFARC.Farc.FARC;
|
||||
|
||||
Console.WriteLine();
|
||||
Main.ConsoleDesign(true);
|
||||
Main.ConsoleDesign(" Choose type of FARC:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. FARC");
|
||||
Main.ConsoleDesign("2. FARC (Compressed)");
|
||||
Main.ConsoleDesign("3. FARC (Encrypted)");
|
||||
Main.ConsoleDesign("4. FARC (Compressed & Encrypted)");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of FARC:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. FARC");
|
||||
Program.ConsoleDesign("2. FARC (Compressed)");
|
||||
Program.ConsoleDesign("3. FARC (Encrypted)");
|
||||
Program.ConsoleDesign("4. FARC (Compressed & Encrypted)");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
type = Console.ReadLine();
|
||||
if (type == "2" || type == "4") FARC.FARCType |= KKdFARC.Type.GZip;
|
||||
@@ -63,7 +67,6 @@ 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(FARC.Signature);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib;
|
||||
using KKdA3DA = KKdMainLib.A3DA.A3DA;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
@@ -12,7 +11,7 @@ namespace PD_Tool.Tools
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "A3DA Converter";
|
||||
Main.Choose(1, "a3da", out string[] FileNames);
|
||||
Program.Choose(1, "a3da", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
@@ -26,18 +25,18 @@ namespace PD_Tool.Tools
|
||||
if (MP)
|
||||
{
|
||||
Console.Clear();
|
||||
Main.ConsoleDesign(true);
|
||||
Main.ConsoleDesign(" Choose type of format to export:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. A3DA [DT/AC/F]");
|
||||
Main.ConsoleDesign("2. A3DC [DT/AC/F]");
|
||||
Main.ConsoleDesign("3. A3DA [AFT/FT] ");
|
||||
Main.ConsoleDesign("4. A3DC [AFT/FT] ");
|
||||
Main.ConsoleDesign("5. A3DC [F2] ");
|
||||
Main.ConsoleDesign("6. A3DC [MGF] ");
|
||||
Main.ConsoleDesign("7. A3DC [X] ");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. A3DA [DT/AC/F]");
|
||||
Program.ConsoleDesign("2. A3DC [DT/AC/F]");
|
||||
Program.ConsoleDesign("3. A3DA [AFT/FT] ");
|
||||
Program.ConsoleDesign("4. A3DC [AFT/FT] ");
|
||||
Program.ConsoleDesign("5. A3DC [F2] ");
|
||||
Program.ConsoleDesign("6. A3DC [MGF] ");
|
||||
Program.ConsoleDesign("7. A3DC [X] ");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
format = Console.ReadLine();
|
||||
if (format == "1") Format = Format.DT ;
|
||||
@@ -61,29 +60,29 @@ namespace PD_Tool.Tools
|
||||
|
||||
Console.Title = "A3DA Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".farc")
|
||||
{
|
||||
KKdFARC FARC = new KKdFARC(file);
|
||||
if (!FARC.HeaderReader()) continue;
|
||||
if (!FARC.HasFiles) continue;
|
||||
|
||||
MsgPack A3DA = MsgPack.Null;
|
||||
byte[] data = null;
|
||||
for (int i = 0; i < FARC.Files.Length; i++)
|
||||
using (KKdFARC FARC = new KKdFARC(file))
|
||||
{
|
||||
data = FARC.FileReader(i);
|
||||
state = A.A3DAReader(data);
|
||||
if (state == 1)
|
||||
if (!FARC.HeaderReader()) continue;
|
||||
if (!FARC.HasFiles) continue;
|
||||
|
||||
MsgPack A3DA = MsgPack.Null;
|
||||
byte[] data = null;
|
||||
for (int i = 0; i < FARC.Files.Length; i++)
|
||||
{
|
||||
A3DA = A.MsgPackWriter();
|
||||
A = new KKdA3DA();
|
||||
A.MsgPackReader(A3DA);
|
||||
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();
|
||||
data = FARC.FileReader(i);
|
||||
state = A.A3DAReader(data);
|
||||
if (state == 1)
|
||||
{
|
||||
A3DA = A.MsgPackWriter();
|
||||
A = new KKdA3DA();
|
||||
A.MsgPackReader(A3DA);
|
||||
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.Save();
|
||||
}
|
||||
FARC.Save();
|
||||
}
|
||||
else if (ext == ".a3da")
|
||||
{
|
||||
state = A.A3DAReader(filepath);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdAet = KKdMainLib.Aet.Aet;
|
||||
|
||||
@@ -11,7 +10,7 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
Console.Title = "AET Converter";
|
||||
KKdAet Aet;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
Program.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -11,7 +10,7 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
Console.Title = "Bloom Converter";
|
||||
Bloom Bloom;
|
||||
Main.Choose(1, "blt", out string[] FileNames);
|
||||
Program.Choose(1, "blt", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -11,7 +10,7 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
Console.Title = "Color Correction Converter";
|
||||
ColorCorrection ColorCorrection;
|
||||
Main.Choose(1, "cct", out string[] FileNames);
|
||||
Program.Choose(1, "cct", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
+13
-13
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
@@ -9,7 +8,7 @@ namespace PD_Tool.Tools
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "DataBank Converter";
|
||||
Main.Choose(1, "databank", out string[] FileNames);
|
||||
Program.Choose(1, "databank", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
@@ -23,18 +22,19 @@ namespace PD_Tool.Tools
|
||||
if (MP)
|
||||
{
|
||||
Console.Clear();
|
||||
Main.ConsoleDesign(true);
|
||||
Main.ConsoleDesign(" Choose type of exporting file:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. Compact");
|
||||
Main.ConsoleDesign("2. Normal");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of exporting file:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. Compact");
|
||||
Program.ConsoleDesign("2. Normal");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
format = Console.ReadLine();
|
||||
}
|
||||
|
||||
DataBank DB;
|
||||
uint num2 = (uint)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
KKdMainLib.DataBank DB;
|
||||
string[] file_split;
|
||||
foreach (string file in FileNames)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ namespace PD_Tool.Tools
|
||||
|
||||
string filename = Path.GetFileNameWithoutExtension(file);
|
||||
file_split = filename.Split('_');
|
||||
DB = new DataBank();
|
||||
DB = new KKdMainLib.DataBank();
|
||||
if (file_split.Length == 5 && ext == ".dat" && MP)
|
||||
{
|
||||
filepath = file.Replace(filename + ".dat", "");
|
||||
@@ -53,11 +53,11 @@ namespace PD_Tool.Tools
|
||||
DB.MsgPackWriter(filepath + file_split[0] + "_" +
|
||||
file_split[1] + "_" + file_split[2], JSON, format != "2");
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json" && !MP)
|
||||
else if ((ext == ".mp" || ext == ".json") && !MP)
|
||||
{
|
||||
Console.Title = "DataBank Converter: " + filename;
|
||||
DB.MsgPackReader(filepath, JSON);
|
||||
DB. DBWriter(filepath);
|
||||
DB. DBWriter(filepath, num2);
|
||||
}
|
||||
DB = null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib;
|
||||
using KKdDEX = KKdMainLib.DEX;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
@@ -12,7 +11,7 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
Console.Title = "DEX Converter";
|
||||
KKdDEX DEX;
|
||||
Main.Choose(1, "dex", out string[] FileNames);
|
||||
Program.Choose(1, "dex", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
@@ -27,16 +26,16 @@ namespace PD_Tool.Tools
|
||||
|
||||
Console.Clear();
|
||||
string format = "";
|
||||
Main.ConsoleDesign(true);
|
||||
Main.ConsoleDesign(" Choose type of exporting file:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. F/FT PS3/PS4/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");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of exporting file:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. F/FT PS3/PS4/PSVita");
|
||||
Program.ConsoleDesign("2. F2 PS3/PSVita");
|
||||
Program.ConsoleDesign("3. X PS4/PSVita");
|
||||
if ( MP && !JSON) Program.ConsoleDesign("9. MessagePack");
|
||||
if (_JSON && JSON) Program.ConsoleDesign("9. JSON");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
format = Console.ReadLine();
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -11,7 +10,7 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
Console.Title = "DOF Converter";
|
||||
DOF DOF;
|
||||
Main.Choose(1, "dft", out string[] FileNames);
|
||||
Program.Choose(1, "dft", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdMainLib;
|
||||
using KKdSoundLib;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
@@ -10,7 +9,7 @@ namespace PD_Tool.Tools
|
||||
public static void Processor()
|
||||
{
|
||||
Console.Title = "DIVA Converter";
|
||||
Main.Choose(1, "diva", out string[] FileNames);
|
||||
Program.Choose(1, "diva", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -11,7 +10,7 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
Console.Title = "Light Converter";
|
||||
Light LIT;
|
||||
Main.Choose(1, "lit", out string[] FileNames);
|
||||
Program.Choose(1, "lit", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PD_Tool.Tools
|
||||
{
|
||||
Console.Title = "MOT Converter";
|
||||
Mot Mot;
|
||||
Main.Choose(1, "bin", out string[] FileNames);
|
||||
Program.Choose(1, "bin", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdSTR = KKdMainLib.STR;
|
||||
|
||||
@@ -10,7 +9,7 @@ namespace PD_Tool.Tools
|
||||
public static void Processor(bool JSON)
|
||||
{
|
||||
Console.Title = "STR Converter";
|
||||
Main.Choose(1, "str", out string[] FileNames);
|
||||
Program.Choose(1, "str", out string[] FileNames);
|
||||
|
||||
KKdSTR Data;
|
||||
string filepath = "";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdMainLib;
|
||||
using KKdVAG = KKdSoundLib.VAG;
|
||||
|
||||
namespace PD_Tool.Tools
|
||||
@@ -10,7 +9,7 @@ namespace PD_Tool.Tools
|
||||
public static void Processor()
|
||||
{
|
||||
Console.Title = "VAG Converter";
|
||||
Main.Choose(1, "vag", out string[] FileNames);
|
||||
Program.Choose(1, "vag", out string[] FileNames);
|
||||
if (FileNames.Length < 1) return;
|
||||
string filepath = "";
|
||||
string ext = "";
|
||||
@@ -24,13 +23,13 @@ namespace PD_Tool.Tools
|
||||
if (InputWAV)
|
||||
{
|
||||
Console.Clear();
|
||||
Main.ConsoleDesign(true);
|
||||
Main.ConsoleDesign(" Choose type of format to export:");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign("1. VAG (Downmix to 1 ch)");
|
||||
Main.ConsoleDesign("2. HEVAG");
|
||||
Main.ConsoleDesign(false);
|
||||
Main.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. VAG (Downmix to 1 ch)");
|
||||
Program.ConsoleDesign("2. HEVAG");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string format = Console.ReadLine();
|
||||
HE_VAG = format == "2";
|
||||
|
||||
Reference in New Issue
Block a user